aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/slimbus.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/slimbus.h')
-rw-r--r--include/linux/slimbus.h60
1 files changed, 54 insertions, 6 deletions
diff --git a/include/linux/slimbus.h b/include/linux/slimbus.h
index c36cf121d2cd..12c9719b2a55 100644
--- a/include/linux/slimbus.h
+++ b/include/linux/slimbus.h
@@ -14,16 +14,16 @@ extern struct bus_type slimbus_bus;
14 14
15/** 15/**
16 * struct slim_eaddr - Enumeration address for a SLIMbus device 16 * struct slim_eaddr - Enumeration address for a SLIMbus device
17 * @manf_id: Manufacturer Id for the device
18 * @prod_code: Product code
19 * @dev_index: Device index
20 * @instance: Instance value 17 * @instance: Instance value
18 * @dev_index: Device index
19 * @prod_code: Product code
20 * @manf_id: Manufacturer Id for the device
21 */ 21 */
22struct slim_eaddr { 22struct slim_eaddr {
23 u16 manf_id;
24 u16 prod_code;
25 u8 dev_index;
26 u8 instance; 23 u8 instance;
24 u8 dev_index;
25 u16 prod_code;
26 u16 manf_id;
27} __packed; 27} __packed;
28 28
29/** 29/**
@@ -48,6 +48,8 @@ struct slim_controller;
48 * @ctrl: slim controller instance. 48 * @ctrl: slim controller instance.
49 * @laddr: 1-byte Logical address of this device. 49 * @laddr: 1-byte Logical address of this device.
50 * @is_laddr_valid: indicates if the laddr is valid or not 50 * @is_laddr_valid: indicates if the laddr is valid or not
51 * @stream_list: List of streams on this device
52 * @stream_list_lock: lock to protect the stream list
51 * 53 *
52 * This is the client/device handle returned when a SLIMbus 54 * This is the client/device handle returned when a SLIMbus
53 * device is registered with a controller. 55 * device is registered with a controller.
@@ -60,6 +62,8 @@ struct slim_device {
60 enum slim_device_status status; 62 enum slim_device_status status;
61 u8 laddr; 63 u8 laddr;
62 bool is_laddr_valid; 64 bool is_laddr_valid;
65 struct list_head stream_list;
66 spinlock_t stream_list_lock;
63}; 67};
64 68
65#define to_slim_device(d) container_of(d, struct slim_device, dev) 69#define to_slim_device(d) container_of(d, struct slim_device, dev)
@@ -108,6 +112,36 @@ struct slim_val_inf {
108 struct completion *comp; 112 struct completion *comp;
109}; 113};
110 114
115#define SLIM_DEVICE_MAX_CHANNELS 256
116/* A SLIMBus Device may have frmo 0 to 31 Ports (inclusive) */
117#define SLIM_DEVICE_MAX_PORTS 32
118
119/**
120 * struct slim_stream_config - SLIMbus stream configuration
121 * Configuring a stream is done at hw_params or prepare call
122 * from audio drivers where they have all the required information
123 * regarding rate, number of channels and so on.
124 * There is a 1:1 mapping of channel and ports.
125 *
126 * @rate: data rate
127 * @bps: bits per data sample
128 * @ch_count: number of channels
129 * @chs: pointer to list of channel numbers
130 * @port_mask: port mask of ports to use for this stream
131 * @direction: direction of the stream, SNDRV_PCM_STREAM_PLAYBACK
132 * or SNDRV_PCM_STREAM_CAPTURE.
133 */
134struct slim_stream_config {
135 unsigned int rate;
136 unsigned int bps;
137 /* MAX 256 channels */
138 unsigned int ch_count;
139 unsigned int *chs;
140 /* Max 32 ports per device */
141 unsigned long port_mask;
142 int direction;
143};
144
111/* 145/*
112 * use a macro to avoid include chaining to get THIS_MODULE 146 * use a macro to avoid include chaining to get THIS_MODULE
113 */ 147 */
@@ -138,6 +172,8 @@ static inline void slim_set_devicedata(struct slim_device *dev, void *data)
138 dev_set_drvdata(&dev->dev, data); 172 dev_set_drvdata(&dev->dev, data);
139} 173}
140 174
175struct slim_device *of_slim_get_device(struct slim_controller *ctrl,
176 struct device_node *np);
141struct slim_device *slim_get_device(struct slim_controller *ctrl, 177struct slim_device *slim_get_device(struct slim_controller *ctrl,
142 struct slim_eaddr *e_addr); 178 struct slim_eaddr *e_addr);
143int slim_get_logical_addr(struct slim_device *sbdev); 179int slim_get_logical_addr(struct slim_device *sbdev);
@@ -161,4 +197,16 @@ int slim_readb(struct slim_device *sdev, u32 addr);
161int slim_writeb(struct slim_device *sdev, u32 addr, u8 value); 197int slim_writeb(struct slim_device *sdev, u32 addr, u8 value);
162int slim_read(struct slim_device *sdev, u32 addr, size_t count, u8 *val); 198int slim_read(struct slim_device *sdev, u32 addr, size_t count, u8 *val);
163int slim_write(struct slim_device *sdev, u32 addr, size_t count, u8 *val); 199int slim_write(struct slim_device *sdev, u32 addr, size_t count, u8 *val);
200
201/* SLIMbus Stream apis */
202struct slim_stream_runtime;
203struct slim_stream_runtime *slim_stream_allocate(struct slim_device *dev,
204 const char *sname);
205int slim_stream_prepare(struct slim_stream_runtime *stream,
206 struct slim_stream_config *c);
207int slim_stream_enable(struct slim_stream_runtime *stream);
208int slim_stream_disable(struct slim_stream_runtime *stream);
209int slim_stream_unprepare(struct slim_stream_runtime *stream);
210int slim_stream_free(struct slim_stream_runtime *stream);
211
164#endif /* _LINUX_SLIMBUS_H */ 212#endif /* _LINUX_SLIMBUS_H */