| .. | .. |
|---|
| 1 | | -// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) |
|---|
| 2 | | -// Copyright(c) 2015-17 Intel Corporation. |
|---|
| 1 | +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ |
|---|
| 2 | +/* Copyright(c) 2015-17 Intel Corporation. */ |
|---|
| 3 | 3 | #include <sound/soc.h> |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | #ifndef __SDW_CADENCE_H |
|---|
| 6 | 6 | #define __SDW_CADENCE_H |
|---|
| 7 | 7 | |
|---|
| 8 | +#define SDW_CADENCE_GSYNC_KHZ 4 /* 4 kHz */ |
|---|
| 9 | +#define SDW_CADENCE_GSYNC_HZ (SDW_CADENCE_GSYNC_KHZ * 1000) |
|---|
| 10 | + |
|---|
| 8 | 11 | /** |
|---|
| 9 | 12 | * struct sdw_cdns_pdi: PDI (Physical Data Interface) instance |
|---|
| 10 | 13 | * |
|---|
| 11 | | - * @assigned: pdi assigned |
|---|
| 12 | 14 | * @num: pdi number |
|---|
| 13 | 15 | * @intel_alh_id: link identifier |
|---|
| 14 | 16 | * @l_ch_num: low channel for PDI |
|---|
| .. | .. |
|---|
| 18 | 20 | * @type: stream type, PDM or PCM |
|---|
| 19 | 21 | */ |
|---|
| 20 | 22 | struct sdw_cdns_pdi { |
|---|
| 21 | | - bool assigned; |
|---|
| 22 | 23 | int num; |
|---|
| 23 | 24 | int intel_alh_id; |
|---|
| 24 | 25 | int l_ch_num; |
|---|
| .. | .. |
|---|
| 26 | 27 | int ch_count; |
|---|
| 27 | 28 | enum sdw_data_direction dir; |
|---|
| 28 | 29 | enum sdw_stream_type type; |
|---|
| 29 | | -}; |
|---|
| 30 | | - |
|---|
| 31 | | -/** |
|---|
| 32 | | - * struct sdw_cdns_port: Cadence port structure |
|---|
| 33 | | - * |
|---|
| 34 | | - * @num: port number |
|---|
| 35 | | - * @assigned: port assigned |
|---|
| 36 | | - * @ch: channel count |
|---|
| 37 | | - * @direction: data port direction |
|---|
| 38 | | - * @pdi: pdi for this port |
|---|
| 39 | | - */ |
|---|
| 40 | | -struct sdw_cdns_port { |
|---|
| 41 | | - unsigned int num; |
|---|
| 42 | | - bool assigned; |
|---|
| 43 | | - unsigned int ch; |
|---|
| 44 | | - enum sdw_data_direction direction; |
|---|
| 45 | | - struct sdw_cdns_pdi *pdi; |
|---|
| 46 | 30 | }; |
|---|
| 47 | 31 | |
|---|
| 48 | 32 | /** |
|---|
| .. | .. |
|---|
| 95 | 79 | * struct sdw_cdns_dma_data: Cadence DMA data |
|---|
| 96 | 80 | * |
|---|
| 97 | 81 | * @name: SoundWire stream name |
|---|
| 98 | | - * @nr_ports: Number of ports |
|---|
| 99 | | - * @port: Ports |
|---|
| 82 | + * @stream: stream runtime |
|---|
| 83 | + * @pdi: PDI used for this dai |
|---|
| 100 | 84 | * @bus: Bus handle |
|---|
| 101 | 85 | * @stream_type: Stream type |
|---|
| 102 | 86 | * @link_id: Master link id |
|---|
| 87 | + * @hw_params: hw_params to be applied in .prepare step |
|---|
| 88 | + * @suspended: status set when suspended, to be used in .prepare |
|---|
| 103 | 89 | */ |
|---|
| 104 | 90 | struct sdw_cdns_dma_data { |
|---|
| 105 | 91 | char *name; |
|---|
| 106 | 92 | struct sdw_stream_runtime *stream; |
|---|
| 107 | | - int nr_ports; |
|---|
| 108 | | - struct sdw_cdns_port **port; |
|---|
| 93 | + struct sdw_cdns_pdi *pdi; |
|---|
| 109 | 94 | struct sdw_bus *bus; |
|---|
| 110 | 95 | enum sdw_stream_type stream_type; |
|---|
| 111 | 96 | int link_id; |
|---|
| 97 | + struct snd_pcm_hw_params *hw_params; |
|---|
| 98 | + bool suspended; |
|---|
| 112 | 99 | }; |
|---|
| 113 | 100 | |
|---|
| 114 | 101 | /** |
|---|
| .. | .. |
|---|
| 146 | 133 | |
|---|
| 147 | 134 | bool link_up; |
|---|
| 148 | 135 | unsigned int msg_count; |
|---|
| 136 | + bool interrupt_enabled; |
|---|
| 137 | + |
|---|
| 138 | + struct work_struct work; |
|---|
| 139 | + |
|---|
| 140 | + struct list_head list; |
|---|
| 149 | 141 | }; |
|---|
| 150 | 142 | |
|---|
| 151 | 143 | #define bus_to_cdns(_bus) container_of(_bus, struct sdw_cdns, bus) |
|---|
| .. | .. |
|---|
| 160 | 152 | |
|---|
| 161 | 153 | int sdw_cdns_init(struct sdw_cdns *cdns); |
|---|
| 162 | 154 | int sdw_cdns_pdi_init(struct sdw_cdns *cdns, |
|---|
| 163 | | - struct sdw_cdns_stream_config config); |
|---|
| 164 | | -int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns); |
|---|
| 155 | + struct sdw_cdns_stream_config config); |
|---|
| 156 | +int sdw_cdns_exit_reset(struct sdw_cdns *cdns); |
|---|
| 157 | +int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns, bool state); |
|---|
| 165 | 158 | |
|---|
| 166 | | -int sdw_cdns_get_stream(struct sdw_cdns *cdns, |
|---|
| 167 | | - struct sdw_cdns_streams *stream, |
|---|
| 168 | | - u32 ch, u32 dir); |
|---|
| 169 | | -int sdw_cdns_alloc_stream(struct sdw_cdns *cdns, |
|---|
| 170 | | - struct sdw_cdns_streams *stream, |
|---|
| 171 | | - struct sdw_cdns_port *port, u32 ch, u32 dir); |
|---|
| 172 | | -void sdw_cdns_config_stream(struct sdw_cdns *cdns, struct sdw_cdns_port *port, |
|---|
| 173 | | - u32 ch, u32 dir, struct sdw_cdns_pdi *pdi); |
|---|
| 159 | +bool sdw_cdns_is_clock_stop(struct sdw_cdns *cdns); |
|---|
| 160 | +int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake); |
|---|
| 161 | +int sdw_cdns_clock_restart(struct sdw_cdns *cdns, bool bus_reset); |
|---|
| 174 | 162 | |
|---|
| 175 | | -void sdw_cdns_shutdown(struct snd_pcm_substream *substream, |
|---|
| 176 | | - struct snd_soc_dai *dai); |
|---|
| 177 | | -int sdw_cdns_pcm_set_stream(struct snd_soc_dai *dai, |
|---|
| 178 | | - void *stream, int direction); |
|---|
| 179 | | -int sdw_cdns_pdm_set_stream(struct snd_soc_dai *dai, |
|---|
| 180 | | - void *stream, int direction); |
|---|
| 163 | +#ifdef CONFIG_DEBUG_FS |
|---|
| 164 | +void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root); |
|---|
| 165 | +#endif |
|---|
| 166 | + |
|---|
| 167 | +struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns, |
|---|
| 168 | + struct sdw_cdns_streams *stream, |
|---|
| 169 | + u32 ch, u32 dir, int dai_id); |
|---|
| 170 | +void sdw_cdns_config_stream(struct sdw_cdns *cdns, |
|---|
| 171 | + u32 ch, u32 dir, struct sdw_cdns_pdi *pdi); |
|---|
| 181 | 172 | |
|---|
| 182 | 173 | enum sdw_command_response |
|---|
| 183 | 174 | cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num); |
|---|
| .. | .. |
|---|
| 187 | 178 | |
|---|
| 188 | 179 | enum sdw_command_response |
|---|
| 189 | 180 | cdns_xfer_msg_defer(struct sdw_bus *bus, |
|---|
| 190 | | - struct sdw_msg *msg, struct sdw_defer *defer); |
|---|
| 181 | + struct sdw_msg *msg, struct sdw_defer *defer); |
|---|
| 191 | 182 | |
|---|
| 192 | 183 | enum sdw_command_response |
|---|
| 193 | 184 | cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num); |
|---|
| .. | .. |
|---|
| 195 | 186 | int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params); |
|---|
| 196 | 187 | |
|---|
| 197 | 188 | int cdns_set_sdw_stream(struct snd_soc_dai *dai, |
|---|
| 198 | | - void *stream, bool pcm, int direction); |
|---|
| 189 | + void *stream, bool pcm, int direction); |
|---|
| 199 | 190 | #endif /* __SDW_CADENCE_H */ |
|---|