| .. | .. |
|---|
| 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 | |
|---|
| 4 | 4 | #ifndef __SDW_BUS_H |
|---|
| 5 | 5 | #define __SDW_BUS_H |
|---|
| 6 | + |
|---|
| 7 | +#define DEFAULT_BANK_SWITCH_TIMEOUT 3000 |
|---|
| 8 | +#define DEFAULT_PROBE_TIMEOUT 2000 |
|---|
| 6 | 9 | |
|---|
| 7 | 10 | #if IS_ENABLED(CONFIG_ACPI) |
|---|
| 8 | 11 | int sdw_acpi_find_slaves(struct sdw_bus *bus); |
|---|
| .. | .. |
|---|
| 13 | 16 | } |
|---|
| 14 | 17 | #endif |
|---|
| 15 | 18 | |
|---|
| 19 | +int sdw_of_find_slaves(struct sdw_bus *bus); |
|---|
| 16 | 20 | 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 |
|---|
| 18 | 43 | |
|---|
| 19 | 44 | enum { |
|---|
| 20 | 45 | SDW_MSG_FLAG_READ = 0, |
|---|
| .. | .. |
|---|
| 46 | 71 | }; |
|---|
| 47 | 72 | |
|---|
| 48 | 73 | #define SDW_DOUBLE_RATE_FACTOR 2 |
|---|
| 74 | +#define SDW_STRM_RATE_GROUPING 1 |
|---|
| 49 | 75 | |
|---|
| 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); |
|---|
| 52 | 81 | |
|---|
| 53 | 82 | /** |
|---|
| 54 | 83 | * sdw_port_runtime: Runtime port parameters for Master or Slave |
|---|
| .. | .. |
|---|
| 99 | 128 | * this stream, can be zero. |
|---|
| 100 | 129 | * @slave_rt_list: Slave runtime list |
|---|
| 101 | 130 | * @port_list: List of Master Ports configured for this stream, can be zero. |
|---|
| 131 | + * @stream_node: sdw_stream_runtime master_list node |
|---|
| 102 | 132 | * @bus_node: sdw_bus m_rt_list node |
|---|
| 103 | 133 | */ |
|---|
| 104 | 134 | struct sdw_master_runtime { |
|---|
| .. | .. |
|---|
| 108 | 138 | unsigned int ch_count; |
|---|
| 109 | 139 | struct list_head slave_rt_list; |
|---|
| 110 | 140 | struct list_head port_list; |
|---|
| 141 | + struct list_head stream_node; |
|---|
| 111 | 142 | struct list_head bus_node; |
|---|
| 112 | 143 | }; |
|---|
| 113 | 144 | |
|---|
| 114 | 145 | 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); |
|---|
| 117 | 148 | int sdw_configure_dpn_intr(struct sdw_slave *slave, int port, |
|---|
| 118 | | - bool enable, int mask); |
|---|
| 149 | + bool enable, int mask); |
|---|
| 119 | 150 | |
|---|
| 120 | 151 | int sdw_transfer(struct sdw_bus *bus, struct sdw_msg *msg); |
|---|
| 121 | 152 | int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg, |
|---|
| 122 | | - struct sdw_defer *defer); |
|---|
| 153 | + struct sdw_defer *defer); |
|---|
| 123 | 154 | |
|---|
| 124 | 155 | #define SDW_READ_INTR_CLEAR_RETRY 10 |
|---|
| 125 | 156 | |
|---|
| 126 | 157 | 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 | +} |
|---|
| 128 | 201 | |
|---|
| 129 | 202 | /* 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) |
|---|
| 132 | 204 | { |
|---|
| 133 | 205 | int tmp; |
|---|
| 134 | 206 | |
|---|
| .. | .. |
|---|
| 140 | 212 | return sdw_write(slave, addr, tmp); |
|---|
| 141 | 213 | } |
|---|
| 142 | 214 | |
|---|
| 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 | + |
|---|
| 143 | 228 | #endif /* __SDW_BUS_H */ |
|---|