1
2
3#include <sound/soc.h>
4
5#ifndef __SDW_CADENCE_H
6#define __SDW_CADENCE_H
7
8#define SDW_CADENCE_GSYNC_KHZ 4
9#define SDW_CADENCE_GSYNC_HZ (SDW_CADENCE_GSYNC_KHZ * 1000)
10
11
12
13
14
15
16
17
18
19
20
21
22struct sdw_cdns_pdi {
23 int num;
24 int intel_alh_id;
25 int l_ch_num;
26 int h_ch_num;
27 int ch_count;
28 enum sdw_data_direction dir;
29 enum sdw_stream_type type;
30};
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46struct sdw_cdns_streams {
47 unsigned int num_bd;
48 unsigned int num_in;
49 unsigned int num_out;
50 unsigned int num_ch_bd;
51 unsigned int num_ch_in;
52 unsigned int num_ch_out;
53 unsigned int num_pdi;
54 struct sdw_cdns_pdi *bd;
55 struct sdw_cdns_pdi *in;
56 struct sdw_cdns_pdi *out;
57};
58
59
60
61
62
63
64
65
66
67
68
69struct sdw_cdns_stream_config {
70 unsigned int pcm_bd;
71 unsigned int pcm_in;
72 unsigned int pcm_out;
73 unsigned int pdm_bd;
74 unsigned int pdm_in;
75 unsigned int pdm_out;
76};
77
78
79
80
81
82
83
84
85
86
87
88
89
90struct sdw_cdns_dma_data {
91 char *name;
92 struct sdw_stream_runtime *stream;
93 struct sdw_cdns_pdi *pdi;
94 struct sdw_bus *bus;
95 enum sdw_stream_type stream_type;
96 int link_id;
97 struct snd_pcm_hw_params *hw_params;
98 bool suspended;
99};
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117struct sdw_cdns {
118 struct device *dev;
119 struct sdw_bus bus;
120 unsigned int instance;
121
122 u32 response_buf[0x80];
123 struct completion tx_complete;
124 struct sdw_defer *defer;
125
126 struct sdw_cdns_port *ports;
127 int num_ports;
128
129 struct sdw_cdns_streams pcm;
130 struct sdw_cdns_streams pdm;
131
132 int pdi_loopback_source;
133 int pdi_loopback_target;
134
135 void __iomem *registers;
136
137 bool link_up;
138 unsigned int msg_count;
139 bool interrupt_enabled;
140
141 struct work_struct work;
142
143 struct list_head list;
144};
145
146#define bus_to_cdns(_bus) container_of(_bus, struct sdw_cdns, bus)
147
148
149
150int sdw_cdns_probe(struct sdw_cdns *cdns);
151extern struct sdw_master_ops sdw_cdns_master_ops;
152
153irqreturn_t sdw_cdns_irq(int irq, void *dev_id);
154irqreturn_t sdw_cdns_thread(int irq, void *dev_id);
155
156int sdw_cdns_init(struct sdw_cdns *cdns);
157int sdw_cdns_pdi_init(struct sdw_cdns *cdns,
158 struct sdw_cdns_stream_config config);
159int sdw_cdns_exit_reset(struct sdw_cdns *cdns);
160int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns, bool state);
161
162bool sdw_cdns_is_clock_stop(struct sdw_cdns *cdns);
163int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake);
164int sdw_cdns_clock_restart(struct sdw_cdns *cdns, bool bus_reset);
165
166#ifdef CONFIG_DEBUG_FS
167void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root);
168#endif
169
170struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns,
171 struct sdw_cdns_streams *stream,
172 u32 ch, u32 dir, int dai_id);
173void sdw_cdns_config_stream(struct sdw_cdns *cdns,
174 u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
175
176enum sdw_command_response
177cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
178
179enum sdw_command_response
180cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg);
181
182enum sdw_command_response
183cdns_xfer_msg_defer(struct sdw_bus *bus,
184 struct sdw_msg *msg, struct sdw_defer *defer);
185
186int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params);
187
188int cdns_set_sdw_stream(struct snd_soc_dai *dai,
189 void *stream, bool pcm, int direction);
190
191void sdw_cdns_check_self_clearing_bits(struct sdw_cdns *cdns, const char *string,
192 bool initial_delay, int reset_iterations);
193
194#endif
195