1
2
3
4#ifndef __SDW_BUS_H
5#define __SDW_BUS_H
6
7#define DEFAULT_BANK_SWITCH_TIMEOUT 3000
8
9#if IS_ENABLED(CONFIG_ACPI)
10int sdw_acpi_find_slaves(struct sdw_bus *bus);
11#else
12static inline int sdw_acpi_find_slaves(struct sdw_bus *bus)
13{
14 return -ENOTSUPP;
15}
16#endif
17
18int sdw_of_find_slaves(struct sdw_bus *bus);
19void sdw_extract_slave_id(struct sdw_bus *bus,
20 u64 addr, struct sdw_slave_id *id);
21
22#ifdef CONFIG_DEBUG_FS
23void sdw_bus_debugfs_init(struct sdw_bus *bus);
24void sdw_bus_debugfs_exit(struct sdw_bus *bus);
25void sdw_slave_debugfs_init(struct sdw_slave *slave);
26void sdw_slave_debugfs_exit(struct sdw_slave *slave);
27void sdw_debugfs_init(void);
28void sdw_debugfs_exit(void);
29#else
30static inline void sdw_bus_debugfs_init(struct sdw_bus *bus) {}
31static inline void sdw_bus_debugfs_exit(struct sdw_bus *bus) {}
32static inline void sdw_slave_debugfs_init(struct sdw_slave *slave) {}
33static inline void sdw_slave_debugfs_exit(struct sdw_slave *slave) {}
34static inline void sdw_debugfs_init(void) {}
35static inline void sdw_debugfs_exit(void) {}
36#endif
37
38enum {
39 SDW_MSG_FLAG_READ = 0,
40 SDW_MSG_FLAG_WRITE,
41};
42
43
44
45
46
47
48
49
50
51
52
53
54
55struct sdw_msg {
56 u16 addr;
57 u16 len;
58 u8 dev_num;
59 u8 addr_page1;
60 u8 addr_page2;
61 u8 flags;
62 u8 *buf;
63 bool ssp_sync;
64 bool page;
65};
66
67#define SDW_DOUBLE_RATE_FACTOR 2
68
69extern int sdw_rows[SDW_FRAME_ROWS];
70extern int sdw_cols[SDW_FRAME_COLS];
71
72int sdw_find_row_index(int row);
73int sdw_find_col_index(int col);
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88struct sdw_port_runtime {
89 int num;
90 int ch_mask;
91 struct sdw_transport_params transport_params;
92 struct sdw_port_params port_params;
93 struct list_head port_node;
94};
95
96
97
98
99
100
101
102
103
104
105
106struct sdw_slave_runtime {
107 struct sdw_slave *slave;
108 enum sdw_data_direction direction;
109 unsigned int ch_count;
110 struct list_head m_rt_node;
111 struct list_head port_list;
112};
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127struct sdw_master_runtime {
128 struct sdw_bus *bus;
129 struct sdw_stream_runtime *stream;
130 enum sdw_data_direction direction;
131 unsigned int ch_count;
132 struct list_head slave_rt_list;
133 struct list_head port_list;
134 struct list_head stream_node;
135 struct list_head bus_node;
136};
137
138struct sdw_dpn_prop *sdw_get_slave_dpn_prop(struct sdw_slave *slave,
139 enum sdw_data_direction direction,
140 unsigned int port_num);
141int sdw_configure_dpn_intr(struct sdw_slave *slave, int port,
142 bool enable, int mask);
143
144int sdw_transfer(struct sdw_bus *bus, struct sdw_msg *msg);
145int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg,
146 struct sdw_defer *defer);
147
148#define SDW_READ_INTR_CLEAR_RETRY 10
149
150int sdw_fill_msg(struct sdw_msg *msg, struct sdw_slave *slave,
151 u32 addr, size_t count, u16 dev_num, u8 flags, u8 *buf);
152
153
154static inline int
155sdw_update(struct sdw_slave *slave, u32 addr, u8 mask, u8 val)
156{
157 int tmp;
158
159 tmp = sdw_read(slave, addr);
160 if (tmp < 0)
161 return tmp;
162
163 tmp = (tmp & ~mask) | val;
164 return sdw_write(slave, addr, tmp);
165}
166
167#endif
168