hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/soundwire/bus.h
....@@ -1,8 +1,11 @@
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. */
33
44 #ifndef __SDW_BUS_H
55 #define __SDW_BUS_H
6
+
7
+#define DEFAULT_BANK_SWITCH_TIMEOUT 3000
8
+#define DEFAULT_PROBE_TIMEOUT 2000
69
710 #if IS_ENABLED(CONFIG_ACPI)
811 int sdw_acpi_find_slaves(struct sdw_bus *bus);
....@@ -13,8 +16,30 @@
1316 }
1417 #endif
1518
19
+int sdw_of_find_slaves(struct sdw_bus *bus);
1620 void sdw_extract_slave_id(struct sdw_bus *bus,
17
- u64 addr, struct sdw_slave_id *id);
21
+ u64 addr, struct sdw_slave_id *id);
22
+int sdw_slave_add(struct sdw_bus *bus, struct sdw_slave_id *id,
23
+ struct fwnode_handle *fwnode);
24
+int sdw_master_device_add(struct sdw_bus *bus, struct device *parent,
25
+ struct fwnode_handle *fwnode);
26
+int sdw_master_device_del(struct sdw_bus *bus);
27
+
28
+#ifdef CONFIG_DEBUG_FS
29
+void sdw_bus_debugfs_init(struct sdw_bus *bus);
30
+void sdw_bus_debugfs_exit(struct sdw_bus *bus);
31
+void sdw_slave_debugfs_init(struct sdw_slave *slave);
32
+void sdw_slave_debugfs_exit(struct sdw_slave *slave);
33
+void sdw_debugfs_init(void);
34
+void sdw_debugfs_exit(void);
35
+#else
36
+static inline void sdw_bus_debugfs_init(struct sdw_bus *bus) {}
37
+static inline void sdw_bus_debugfs_exit(struct sdw_bus *bus) {}
38
+static inline void sdw_slave_debugfs_init(struct sdw_slave *slave) {}
39
+static inline void sdw_slave_debugfs_exit(struct sdw_slave *slave) {}
40
+static inline void sdw_debugfs_init(void) {}
41
+static inline void sdw_debugfs_exit(void) {}
42
+#endif
1843
1944 enum {
2045 SDW_MSG_FLAG_READ = 0,
....@@ -46,9 +71,13 @@
4671 };
4772
4873 #define SDW_DOUBLE_RATE_FACTOR 2
74
+#define SDW_STRM_RATE_GROUPING 1
4975
50
-extern int rows[SDW_FRAME_ROWS];
51
-extern int cols[SDW_FRAME_COLS];
76
+extern int sdw_rows[SDW_FRAME_ROWS];
77
+extern int sdw_cols[SDW_FRAME_COLS];
78
+
79
+int sdw_find_row_index(int row);
80
+int sdw_find_col_index(int col);
5281
5382 /**
5483 * sdw_port_runtime: Runtime port parameters for Master or Slave
....@@ -99,6 +128,7 @@
99128 * this stream, can be zero.
100129 * @slave_rt_list: Slave runtime list
101130 * @port_list: List of Master Ports configured for this stream, can be zero.
131
+ * @stream_node: sdw_stream_runtime master_list node
102132 * @bus_node: sdw_bus m_rt_list node
103133 */
104134 struct sdw_master_runtime {
....@@ -108,27 +138,69 @@
108138 unsigned int ch_count;
109139 struct list_head slave_rt_list;
110140 struct list_head port_list;
141
+ struct list_head stream_node;
111142 struct list_head bus_node;
112143 };
113144
114145 struct sdw_dpn_prop *sdw_get_slave_dpn_prop(struct sdw_slave *slave,
115
- enum sdw_data_direction direction,
116
- unsigned int port_num);
146
+ enum sdw_data_direction direction,
147
+ unsigned int port_num);
117148 int sdw_configure_dpn_intr(struct sdw_slave *slave, int port,
118
- bool enable, int mask);
149
+ bool enable, int mask);
119150
120151 int sdw_transfer(struct sdw_bus *bus, struct sdw_msg *msg);
121152 int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg,
122
- struct sdw_defer *defer);
153
+ struct sdw_defer *defer);
123154
124155 #define SDW_READ_INTR_CLEAR_RETRY 10
125156
126157 int sdw_fill_msg(struct sdw_msg *msg, struct sdw_slave *slave,
127
- u32 addr, size_t count, u16 dev_num, u8 flags, u8 *buf);
158
+ u32 addr, size_t count, u16 dev_num, u8 flags, u8 *buf);
159
+
160
+/* Retrieve and return channel count from channel mask */
161
+static inline int sdw_ch_mask_to_ch(int ch_mask)
162
+{
163
+ int c = 0;
164
+
165
+ for (c = 0; ch_mask; ch_mask >>= 1)
166
+ c += ch_mask & 1;
167
+
168
+ return c;
169
+}
170
+
171
+/* Fill transport parameter data structure */
172
+static inline void sdw_fill_xport_params(struct sdw_transport_params *params,
173
+ int port_num, bool grp_ctrl_valid,
174
+ int grp_ctrl, int sample_int,
175
+ int off1, int off2,
176
+ int hstart, int hstop,
177
+ int pack_mode, int lane_ctrl)
178
+{
179
+ params->port_num = port_num;
180
+ params->blk_grp_ctrl_valid = grp_ctrl_valid;
181
+ params->blk_grp_ctrl = grp_ctrl;
182
+ params->sample_interval = sample_int;
183
+ params->offset1 = off1;
184
+ params->offset2 = off2;
185
+ params->hstart = hstart;
186
+ params->hstop = hstop;
187
+ params->blk_pkg_mode = pack_mode;
188
+ params->lane_ctrl = lane_ctrl;
189
+}
190
+
191
+/* Fill port parameter data structure */
192
+static inline void sdw_fill_port_params(struct sdw_port_params *params,
193
+ int port_num, int bps,
194
+ int flow_mode, int data_mode)
195
+{
196
+ params->num = port_num;
197
+ params->bps = bps;
198
+ params->flow_mode = flow_mode;
199
+ params->data_mode = data_mode;
200
+}
128201
129202 /* Read-Modify-Write Slave register */
130
-static inline int
131
-sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val)
203
+static inline int sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val)
132204 {
133205 int tmp;
134206
....@@ -140,4 +212,17 @@
140212 return sdw_write(slave, addr, tmp);
141213 }
142214
215
+/* broadcast read/write for tests */
216
+int sdw_bread_no_pm_unlocked(struct sdw_bus *bus, u16 dev_num, u32 addr);
217
+int sdw_bwrite_no_pm_unlocked(struct sdw_bus *bus, u16 dev_num, u32 addr, u8 value);
218
+
219
+/*
220
+ * At the moment we only track Master-initiated hw_reset.
221
+ * Additional fields can be added as needed
222
+ */
223
+#define SDW_UNATTACH_REQUEST_MASTER_RESET BIT(0)
224
+
225
+void sdw_clear_slave_status(struct sdw_bus *bus, u32 request);
226
+int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size);
227
+
143228 #endif /* __SDW_BUS_H */