0001
0002
0003 #include <sound/soc.h>
0004
0005 #ifndef __SDW_CADENCE_H
0006 #define __SDW_CADENCE_H
0007
0008 #define SDW_CADENCE_GSYNC_KHZ 4
0009 #define SDW_CADENCE_GSYNC_HZ (SDW_CADENCE_GSYNC_KHZ * 1000)
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 struct sdw_cdns_pdi {
0023 int num;
0024 int intel_alh_id;
0025 int l_ch_num;
0026 int h_ch_num;
0027 int ch_count;
0028 enum sdw_data_direction dir;
0029 enum sdw_stream_type type;
0030 };
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 struct sdw_cdns_streams {
0047 unsigned int num_bd;
0048 unsigned int num_in;
0049 unsigned int num_out;
0050 unsigned int num_ch_bd;
0051 unsigned int num_ch_in;
0052 unsigned int num_ch_out;
0053 unsigned int num_pdi;
0054 struct sdw_cdns_pdi *bd;
0055 struct sdw_cdns_pdi *in;
0056 struct sdw_cdns_pdi *out;
0057 };
0058
0059
0060
0061
0062
0063
0064
0065
0066 struct sdw_cdns_stream_config {
0067 unsigned int pcm_bd;
0068 unsigned int pcm_in;
0069 unsigned int pcm_out;
0070 };
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 struct sdw_cdns_dma_data {
0086 char *name;
0087 struct sdw_stream_runtime *stream;
0088 struct sdw_cdns_pdi *pdi;
0089 struct sdw_bus *bus;
0090 enum sdw_stream_type stream_type;
0091 int link_id;
0092 struct snd_pcm_hw_params *hw_params;
0093 bool suspended;
0094 bool paused;
0095 };
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112 struct sdw_cdns {
0113 struct device *dev;
0114 struct sdw_bus bus;
0115 unsigned int instance;
0116
0117 u32 response_buf[0x80];
0118 struct completion tx_complete;
0119 struct sdw_defer *defer;
0120
0121 struct sdw_cdns_port *ports;
0122 int num_ports;
0123
0124 struct sdw_cdns_streams pcm;
0125
0126 int pdi_loopback_source;
0127 int pdi_loopback_target;
0128
0129 void __iomem *registers;
0130
0131 bool link_up;
0132 unsigned int msg_count;
0133 bool interrupt_enabled;
0134
0135 struct work_struct work;
0136
0137 struct list_head list;
0138 };
0139
0140 #define bus_to_cdns(_bus) container_of(_bus, struct sdw_cdns, bus)
0141
0142
0143
0144 int sdw_cdns_probe(struct sdw_cdns *cdns);
0145 extern struct sdw_master_ops sdw_cdns_master_ops;
0146
0147 irqreturn_t sdw_cdns_irq(int irq, void *dev_id);
0148 irqreturn_t sdw_cdns_thread(int irq, void *dev_id);
0149
0150 int sdw_cdns_init(struct sdw_cdns *cdns);
0151 int sdw_cdns_pdi_init(struct sdw_cdns *cdns,
0152 struct sdw_cdns_stream_config config);
0153 int sdw_cdns_exit_reset(struct sdw_cdns *cdns);
0154 int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns, bool state);
0155
0156 bool sdw_cdns_is_clock_stop(struct sdw_cdns *cdns);
0157 int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake);
0158 int sdw_cdns_clock_restart(struct sdw_cdns *cdns, bool bus_reset);
0159
0160 #ifdef CONFIG_DEBUG_FS
0161 void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root);
0162 #endif
0163
0164 struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
0165 struct sdw_cdns_streams *stream,
0166 u32 ch, u32 dir, int dai_id);
0167 void sdw_cdns_config_stream(struct sdw_cdns *cdns,
0168 u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
0169
0170 enum sdw_command_response
0171 cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
0172
0173 enum sdw_command_response
0174 cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg);
0175
0176 enum sdw_command_response
0177 cdns_xfer_msg_defer(struct sdw_bus *bus,
0178 struct sdw_msg *msg, struct sdw_defer *defer);
0179
0180 int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params);
0181
0182 int cdns_set_sdw_stream(struct snd_soc_dai *dai,
0183 void *stream, int direction);
0184
0185 void sdw_cdns_check_self_clearing_bits(struct sdw_cdns *cdns, const char *string,
0186 bool initial_delay, int reset_iterations);
0187
0188 #endif