1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
2 /* Copyright(c) 2015-17 Intel Corporation. */
7 #define DEFAULT_BANK_SWITCH_TIMEOUT 3000
8 #define DEFAULT_PROBE_TIMEOUT 2000
10 #if IS_ENABLED(CONFIG_ACPI)
11 int sdw_acpi_find_slaves(struct sdw_bus
*bus
);
13 static inline int sdw_acpi_find_slaves(struct sdw_bus
*bus
)
19 int sdw_of_find_slaves(struct sdw_bus
*bus
);
20 void sdw_extract_slave_id(struct sdw_bus
*bus
,
21 u64 addr
, struct sdw_slave_id
*id
);
22 int sdw_master_device_add(struct sdw_bus
*bus
, struct device
*parent
,
23 struct fwnode_handle
*fwnode
);
24 int sdw_master_device_del(struct sdw_bus
*bus
);
26 #ifdef CONFIG_DEBUG_FS
27 void sdw_bus_debugfs_init(struct sdw_bus
*bus
);
28 void sdw_bus_debugfs_exit(struct sdw_bus
*bus
);
29 void sdw_slave_debugfs_init(struct sdw_slave
*slave
);
30 void sdw_slave_debugfs_exit(struct sdw_slave
*slave
);
31 void sdw_debugfs_init(void);
32 void sdw_debugfs_exit(void);
34 static inline void sdw_bus_debugfs_init(struct sdw_bus
*bus
) {}
35 static inline void sdw_bus_debugfs_exit(struct sdw_bus
*bus
) {}
36 static inline void sdw_slave_debugfs_init(struct sdw_slave
*slave
) {}
37 static inline void sdw_slave_debugfs_exit(struct sdw_slave
*slave
) {}
38 static inline void sdw_debugfs_init(void) {}
39 static inline void sdw_debugfs_exit(void) {}
43 SDW_MSG_FLAG_READ
= 0,
48 * struct sdw_msg - Message structure
49 * @addr: Register address accessed in the Slave
50 * @len: number of messages
51 * @dev_num: Slave device number
52 * @addr_page1: SCP address page 1 Slave register
53 * @addr_page2: SCP address page 2 Slave register
54 * @flags: transfer flags, indicate if xfer is read or write
55 * @buf: message data buffer
56 * @ssp_sync: Send message at SSP (Stream Synchronization Point)
57 * @page: address requires paging
71 #define SDW_DOUBLE_RATE_FACTOR 2
73 extern int sdw_rows
[SDW_FRAME_ROWS
];
74 extern int sdw_cols
[SDW_FRAME_COLS
];
76 int sdw_find_row_index(int row
);
77 int sdw_find_col_index(int col
);
80 * sdw_port_runtime: Runtime port parameters for Master or Slave
82 * @num: Port number. For audio streams, valid port number ranges from
84 * @ch_mask: Channel mask
85 * @transport_params: Transport parameters
86 * @port_params: Port parameters
87 * @port_node: List node for Master or Slave port_list
89 * SoundWire spec has no mention of ports for Master interface but the
90 * concept is logically extended.
92 struct sdw_port_runtime
{
95 struct sdw_transport_params transport_params
;
96 struct sdw_port_params port_params
;
97 struct list_head port_node
;
101 * sdw_slave_runtime: Runtime Stream parameters for Slave
103 * @slave: Slave handle
104 * @direction: Data direction for Slave
105 * @ch_count: Number of channels handled by the Slave for
107 * @m_rt_node: sdw_master_runtime list node
108 * @port_list: List of Slave Ports configured for this stream
110 struct sdw_slave_runtime
{
111 struct sdw_slave
*slave
;
112 enum sdw_data_direction direction
;
113 unsigned int ch_count
;
114 struct list_head m_rt_node
;
115 struct list_head port_list
;
119 * sdw_master_runtime: Runtime stream parameters for Master
122 * @stream: Stream runtime handle
123 * @direction: Data direction for Master
124 * @ch_count: Number of channels handled by the Master for
125 * this stream, can be zero.
126 * @slave_rt_list: Slave runtime list
127 * @port_list: List of Master Ports configured for this stream, can be zero.
128 * @stream_node: sdw_stream_runtime master_list node
129 * @bus_node: sdw_bus m_rt_list node
131 struct sdw_master_runtime
{
133 struct sdw_stream_runtime
*stream
;
134 enum sdw_data_direction direction
;
135 unsigned int ch_count
;
136 struct list_head slave_rt_list
;
137 struct list_head port_list
;
138 struct list_head stream_node
;
139 struct list_head bus_node
;
142 struct sdw_dpn_prop
*sdw_get_slave_dpn_prop(struct sdw_slave
*slave
,
143 enum sdw_data_direction direction
,
144 unsigned int port_num
);
145 int sdw_configure_dpn_intr(struct sdw_slave
*slave
, int port
,
146 bool enable
, int mask
);
148 int sdw_transfer(struct sdw_bus
*bus
, struct sdw_msg
*msg
);
149 int sdw_transfer_defer(struct sdw_bus
*bus
, struct sdw_msg
*msg
,
150 struct sdw_defer
*defer
);
152 #define SDW_READ_INTR_CLEAR_RETRY 10
154 int sdw_fill_msg(struct sdw_msg
*msg
, struct sdw_slave
*slave
,
155 u32 addr
, size_t count
, u16 dev_num
, u8 flags
, u8
*buf
);
157 /* Read-Modify-Write Slave register */
159 sdw_update(struct sdw_slave
*slave
, u32 addr
, u8 mask
, u8 val
)
163 tmp
= sdw_read(slave
, addr
);
167 tmp
= (tmp
& ~mask
) | val
;
168 return sdw_write(slave
, addr
, tmp
);
172 * At the moment we only track Master-initiated hw_reset.
173 * Additional fields can be added as needed
175 #define SDW_UNATTACH_REQUEST_MASTER_RESET BIT(0)
177 void sdw_clear_slave_status(struct sdw_bus
*bus
, u32 request
);
178 int sdw_slave_modalias(const struct sdw_slave
*slave
, char *buf
, size_t size
);
180 #endif /* __SDW_BUS_H */