blob: f06f632632333ed20e801a6343562023aae07b0c [file] [log] [blame]
Duy Truonge833aca2013-02-12 13:35:08 -08001/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _LINUX_SLIMBUS_H
14#define _LINUX_SLIMBUS_H
15#include <linux/module.h>
16#include <linux/device.h>
17#include <linux/mutex.h>
18#include <linux/mod_devicetable.h>
19
20/* Interfaces between SLIMbus manager drivers and SLIMbus infrastructure. */
21
22extern struct bus_type slimbus_type;
23
24/* Standard values per SLIMbus spec needed by controllers and devices */
25#define SLIM_CL_PER_SUPERFRAME 6144
26#define SLIM_CL_PER_SUPERFRAME_DIV8 (SLIM_CL_PER_SUPERFRAME >> 3)
27#define SLIM_MAX_CLK_GEAR 10
Sagar Dharia98a7ecb2011-07-25 15:25:35 -060028#define SLIM_MIN_CLK_GEAR 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029#define SLIM_CL_PER_SL 4
30#define SLIM_SL_PER_SUPERFRAME (SLIM_CL_PER_SUPERFRAME >> 2)
31#define SLIM_FRM_SLOTS_PER_SUPERFRAME 16
32#define SLIM_GDE_SLOTS_PER_SUPERFRAME 2
33
34/*
35 * SLIMbus message types. Related to interpretation of message code.
36 * Values are defined in Table 32 (slimbus spec 1.01.01)
37 */
38#define SLIM_MSG_MT_CORE 0x0
39#define SLIM_MSG_MT_DEST_REFERRED_CLASS 0x1
40#define SLIM_MSG_MT_DEST_REFERRED_USER 0x2
41#define SLIM_MSG_MT_SRC_REFERRED_CLASS 0x5
42#define SLIM_MSG_MT_SRC_REFERRED_USER 0x6
43
44/*
45 * SLIMbus core type Message Codes.
46 * Values are defined in Table 65 (slimbus spec 1.01.01)
47 */
48/* Device management messages */
49#define SLIM_MSG_MC_REPORT_PRESENT 0x1
50#define SLIM_MSG_MC_ASSIGN_LOGICAL_ADDRESS 0x2
51#define SLIM_MSG_MC_RESET_DEVICE 0x4
52#define SLIM_MSG_MC_CHANGE_LOGICAL_ADDRESS 0x8
53#define SLIM_MSG_MC_CHANGE_ARBITRATION_PRIORITY 0x9
54#define SLIM_MSG_MC_REQUEST_SELF_ANNOUNCEMENT 0xC
55#define SLIM_MSG_MC_REPORT_ABSENT 0xF
56
57/* Data channel management messages */
58#define SLIM_MSG_MC_CONNECT_SOURCE 0x10
59#define SLIM_MSG_MC_CONNECT_SINK 0x11
60#define SLIM_MSG_MC_DISCONNECT_PORT 0x14
61#define SLIM_MSG_MC_CHANGE_CONTENT 0x18
62
63/* Information management messages */
64#define SLIM_MSG_MC_REQUEST_INFORMATION 0x20
65#define SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION 0x21
66#define SLIM_MSG_MC_REPLY_INFORMATION 0x24
67#define SLIM_MSG_MC_CLEAR_INFORMATION 0x28
68#define SLIM_MSG_MC_REPORT_INFORMATION 0x29
69
70/* Reconfiguration messages */
71#define SLIM_MSG_MC_BEGIN_RECONFIGURATION 0x40
72#define SLIM_MSG_MC_NEXT_ACTIVE_FRAMER 0x44
73#define SLIM_MSG_MC_NEXT_SUBFRAME_MODE 0x45
74#define SLIM_MSG_MC_NEXT_CLOCK_GEAR 0x46
75#define SLIM_MSG_MC_NEXT_ROOT_FREQUENCY 0x47
76#define SLIM_MSG_MC_NEXT_PAUSE_CLOCK 0x4A
77#define SLIM_MSG_MC_NEXT_RESET_BUS 0x4B
78#define SLIM_MSG_MC_NEXT_SHUTDOWN_BUS 0x4C
79#define SLIM_MSG_MC_NEXT_DEFINE_CHANNEL 0x50
80#define SLIM_MSG_MC_NEXT_DEFINE_CONTENT 0x51
81#define SLIM_MSG_MC_NEXT_ACTIVATE_CHANNEL 0x54
82#define SLIM_MSG_MC_NEXT_DEACTIVATE_CHANNEL 0x55
83#define SLIM_MSG_MC_NEXT_REMOVE_CHANNEL 0x58
84#define SLIM_MSG_MC_RECONFIGURE_NOW 0x5F
85
Sagar Dharia45ee38a2011-08-03 17:01:31 -060086/*
87 * Clock pause flag to indicate that the reconfig message
88 * corresponds to clock pause sequence
89 */
90#define SLIM_MSG_CLK_PAUSE_SEQ_FLG (1U << 8)
91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092/* Value management messages */
93#define SLIM_MSG_MC_REQUEST_VALUE 0x60
94#define SLIM_MSG_MC_REQUEST_CHANGE_VALUE 0x61
95#define SLIM_MSG_MC_REPLY_VALUE 0x64
96#define SLIM_MSG_MC_CHANGE_VALUE 0x68
97
Sagar Dharia33f34442011-08-08 16:22:03 -060098/* Clock pause values defined in Table 66 (slimbus spec 1.01.01) */
99#define SLIM_CLK_FAST 0
100#define SLIM_CLK_CONST_PHASE 1
101#define SLIM_CLK_UNSPECIFIED 2
102
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700103struct slim_controller;
104struct slim_device;
105
106/* Destination type Values defined in Table 33 (slimbus spec 1.01.01) */
107#define SLIM_MSG_DEST_LOGICALADDR 0
108#define SLIM_MSG_DEST_ENUMADDR 1
109#define SLIM_MSG_DEST_BROADCAST 3
110
111/*
112 * @start_offset: Specifies starting offset in information/value element map
113 * @num_bytes: Can be 1, 2, 3, 4, 6, 8, 12, 16 per spec. This ensures that the
114 * message will fit in the 40-byte message limit and the slicesize can be
115 * compatible with values in table 21 (slimbus spec 1.01.01)
116 * @comp: Completion to indicate end of message-transfer. Used if client wishes
117 * to use the API asynchronously.
118 */
119struct slim_ele_access {
120 u16 start_offset;
121 u8 num_bytes;
122 struct completion *comp;
123};
124
125/*
126 * struct slim_framer - Represents Slimbus framer.
127 * Every controller may have multiple framers.
128 * Manager is responsible for framer hand-over.
129 * @e_addr: 6 byte Elemental address of the framer.
130 * @rootfreq: Root Frequency at which the framer can run. This is maximum
131 * frequency (clock gear 10 per slimbus spec) at which the bus can operate.
132 * @superfreq: Superframes per root frequency. Every frame is 6144 cells (bits)
133 * per slimbus specification.
134 */
135struct slim_framer {
136 u8 e_addr[6];
137 int rootfreq;
138 int superfreq;
139};
140#define to_slim_framer(d) container_of(d, struct slim_framer, dev);
141
142/*
143 * struct slim_addrt: slimbus address used internally by the slimbus framework.
144 * @valid: If the device is still there or if the address can be reused.
145 * @eaddr: 6-bytes-long elemental address
Sagar Dharia6d430092012-09-09 17:32:46 -0600146 * @laddr: It is possible that controller will set a predefined logical address
147 * rather than the one assigned by framework. (i.e. logical address may
148 * not be same as index into this table). This entry will store the
149 * logical address value for this enumeration address.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150 */
151struct slim_addrt {
152 bool valid;
153 u8 eaddr[6];
Sagar Dharia6d430092012-09-09 17:32:46 -0600154 u8 laddr;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700155};
156
157/*
158 * struct slim_msg_txn: Message to be sent by the controller.
159 * Linux framework uses this structure with drivers implementing controller.
160 * This structure has packet header, payload and buffer to be filled (if any)
161 * For the header information, refer to Table 34-36.
162 * @rl: Header field. remaining length.
163 * @mt: Header field. Message type.
Sagar Dharia45ee38a2011-08-03 17:01:31 -0600164 * @mc: Header field. LSB is message code for type mt. Framework will set MSB to
165 * SLIM_MSG_CLK_PAUSE_SEQ_FLG in case "mc" in the reconfiguration sequence
166 * is for pausing the clock.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700167 * @dt: Header field. Destination type.
168 * @ec: Element size. Used for elemental access APIs.
169 * @len: Length of payload. (excludes ec)
170 * @tid: Transaction ID. Used for messages expecting response.
171 * (e.g. relevant for mc = SLIM_MSG_MC_REQUEST_INFORMATION)
172 * @la: Logical address of the device this message is going to.
173 * (Not used when destination type is broadcast.)
174 * @rbuf: Buffer to be populated by controller when response is received.
175 * @wbuf: Payload of the message. (e.g. channel number for DATA channel APIs)
176 * @comp: Completion structure. Used by controller to notify response.
177 * (Field is relevant when tid is used)
178 */
179struct slim_msg_txn {
180 u8 rl;
181 u8 mt;
Sagar Dharia45ee38a2011-08-03 17:01:31 -0600182 u16 mc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700183 u8 dt;
184 u16 ec;
185 u8 len;
186 u8 tid;
187 u8 la;
188 u8 *rbuf;
189 const u8 *wbuf;
190 struct completion *comp;
191};
192
193/* Internal port state used by slimbus framework to manage data-ports */
194enum slim_port_state {
195 SLIM_P_FREE,
196 SLIM_P_UNCFG,
197 SLIM_P_CFG,
198};
199
200/*
201 * enum slim_port_req: Request port type by user through APIs to manage ports
202 * User can request default, half-duplex or port to be used in multi-channel
203 * configuration. Default indicates a simplex port.
204 */
205enum slim_port_req {
206 SLIM_REQ_DEFAULT,
207 SLIM_REQ_HALF_DUP,
208 SLIM_REQ_MULTI_CH,
209};
210
211/*
212 * enum slim_port_cfg: Port configuration parameters requested.
213 * User can request no configuration, packed data, or MSB aligned data port
214 */
215enum slim_port_cfg {
216 SLIM_CFG_NONE,
217 SLIM_CFG_PACKED,
218 SLIM_CFG_ALIGN_MSB,
219};
220
221/* enum slim_port_flow: Port flow type (inbound/outbound). */
222enum slim_port_flow {
223 SLIM_SRC,
224 SLIM_SINK,
225};
226
227/* enum slim_port_err: Port errors */
228enum slim_port_err {
229 SLIM_P_INPROGRESS,
230 SLIM_P_OVERFLOW,
231 SLIM_P_UNDERFLOW,
232 SLIM_P_DISCONNECT,
233 SLIM_P_NOT_OWNED,
234};
235
236/*
237 * struct slim_port: Internal structure used by framework to manage ports
238 * @err: Port error if any for this port. Refer to enum above.
239 * @state: Port state. Refer to enum above.
240 * @req: Port request for this port.
241 * @cfg: Port configuration for this port.
242 * @flow: Flow type of this port.
243 * @ch: Channel association of this port.
244 * @xcomp: Completion to indicate error, data transfer done event.
245 * @ctrl: Controller to which this port belongs to. This is useful to associate
246 * port with the SW since port hardware interrupts may only contain port
247 * information.
248 */
249struct slim_port {
250 enum slim_port_err err;
251 enum slim_port_state state;
252 enum slim_port_req req;
253 enum slim_port_cfg cfg;
254 enum slim_port_flow flow;
255 struct slim_ch *ch;
256 struct completion *xcomp;
257 struct slim_controller *ctrl;
258};
259
260/*
261 * enum slim_ch_state: Channel state of a channel.
262 * Channel transition happens from free-to-allocated-to-defined-to-pending-
263 * active-to-active.
264 * Once active, channel can be removed or suspended. Suspended channels are
265 * still scheduled, but data transfer doesn't happen.
266 * Removed channels are not deallocated until dealloc_ch API is used.
267 * Deallocation reset channel state back to free.
268 * Removed channels can be defined with different parameters.
269 */
270enum slim_ch_state {
271 SLIM_CH_FREE,
272 SLIM_CH_ALLOCATED,
273 SLIM_CH_DEFINED,
274 SLIM_CH_PENDING_ACTIVE,
275 SLIM_CH_ACTIVE,
276 SLIM_CH_SUSPENDED,
277 SLIM_CH_PENDING_REMOVAL,
278};
279
280/*
281 * enum slim_ch_proto: Channel protocol used by the channel.
282 * Hard Isochronous channel is not scheduled if current frequency doesn't allow
283 * the channel to be run without flow-control.
284 * Auto isochronous channel will be scheduled as hard-isochronous or push-pull
285 * depending on current bus frequency.
286 * Currently, Push-pull or async or extended channels are not supported.
287 * For more details, refer to slimbus spec
288 */
289enum slim_ch_proto {
290 SLIM_HARD_ISO,
291 SLIM_AUTO_ISO,
292 SLIM_PUSH,
293 SLIM_PULL,
294 SLIM_ASYNC_SMPLX,
295 SLIM_ASYNC_HALF_DUP,
296 SLIM_EXT_SMPLX,
297 SLIM_EXT_HALF_DUP,
298};
299
300/*
301 * enum slim_ch_rate: Most commonly used frequency rate families.
302 * Use 1HZ for push-pull transport.
303 * 4KHz and 11.025KHz are most commonly used in audio applications.
304 * Typically, slimbus runs at frequencies to support channels running at 4KHz
305 * and/or 11.025KHz isochronously.
306 */
307enum slim_ch_rate {
308 SLIM_RATE_1HZ,
309 SLIM_RATE_4000HZ,
310 SLIM_RATE_11025HZ,
311};
312
313/*
314 * enum slim_ch_coeff: Coefficient of a channel used internally by framework.
315 * Coefficient is applicable to channels running isochronously.
316 * Coefficient is calculated based on channel rate multiplier.
317 * (If rate multiplier is power of 2, it's coeff.1 channel. Otherwise it's
318 * coeff.3 channel.
319 */
320enum slim_ch_coeff {
321 SLIM_COEFF_1,
322 SLIM_COEFF_3,
323};
324
325/*
326 * enum slim_ch_control: Channel control.
327 * Activate will schedule channel and/or group of channels in the TDM frame.
328 * Suspend will keep the schedule but data-transfer won't happen.
329 * Remove will remove the channel/group from the TDM frame.
330 */
331enum slim_ch_control {
332 SLIM_CH_ACTIVATE,
333 SLIM_CH_SUSPEND,
334 SLIM_CH_REMOVE,
335};
336
337/* enum slim_ch_dataf: Data format per table 60 from slimbus spec 1.01.01 */
338enum slim_ch_dataf {
339 SLIM_CH_DATAF_NOT_DEFINED = 0,
340 SLIM_CH_DATAF_LPCM_AUDIO = 1,
341 SLIM_CH_DATAF_IEC61937_COMP_AUDIO = 2,
342 SLIM_CH_DATAF_PACKED_PDM_AUDIO = 3,
343};
344
345/* enum slim_ch_auxf: Auxiliary field format per table 59 from slimbus spec */
346enum slim_ch_auxf {
347 SLIM_CH_AUXF_NOT_APPLICABLE = 0,
348 SLIM_CH_AUXF_ZCUV_TUNNEL_IEC60958 = 1,
349 SLIM_CH_USER_DEFINED = 0xF,
350};
351
352/*
353 * struct slim_ch: Channel structure used externally by users of channel APIs.
354 * @prot: Desired slimbus protocol.
355 * @baser: Desired base rate. (Typical isochronous rates are: 4KHz, or 11.025KHz
356 * @dataf: Data format.
357 * @auxf: Auxiliary format.
358 * @ratem: Channel rate multiplier. (e.g. 48KHz channel will have 4KHz base rate
359 * and 12 as rate multiplier.
360 * @sampleszbits: Sample size in bits.
361 */
362struct slim_ch {
363 enum slim_ch_proto prot;
364 enum slim_ch_rate baser;
365 enum slim_ch_dataf dataf;
366 enum slim_ch_auxf auxf;
367 u32 ratem;
368 u32 sampleszbits;
369};
370
371/*
372 * struct slim_ich: Internal channel structure used by slimbus framework.
373 * @prop: structure passed by the client.
374 * @coeff: Coefficient of this channel.
375 * @state: Current state of the channel.
376 * @nextgrp: If this channel is part of group, next channel in this group.
377 * @prrate: Presence rate of this channel (per table 62 of the spec)
378 * @offset: Offset of this channel in the superframe.
379 * @newoff: Used during scheduling to hold temporary new offset until the offset
380 * is accepted/rejected by slimbus reconfiguration.
381 * @interval: Interval of this channel per superframe.
382 * @newintr: Used during scheduling to new interval temporarily.
383 * @seglen: Segment length of this channel.
384 * @rootexp: root exponent of this channel. Rate can be found using rootexp and
385 * coefficient. Used during scheduling.
Sagar Dharia29f35f02011-10-01 20:37:50 -0600386 * @srch: Source port used by this channel.
387 * @sinkh: Sink ports used by this channel.
388 * @nsink: number of sink ports used by this channel.
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600389 * @chan: Channel number sent on hardware lines for this channel. May not be
390 * equal to array-index into chans if client requested to use number beyond
391 * channel-array for the controller.
392 * @ref: Reference number to keep track of how many clients (upto 2) are using
393 * this channel.
394 * @def: Used to keep track of how many times the channel definition is sent
395 * to hardware and this will decide if channel-remove can be sent for the
396 * channel. Channel definition may be sent upto twice (once per producer
397 * and once per consumer). Channel removal should be sent only once to
398 * avoid clients getting underflow/overflow errors.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700399 */
400struct slim_ich {
401 struct slim_ch prop;
402 enum slim_ch_coeff coeff;
403 enum slim_ch_state state;
404 u16 nextgrp;
405 u32 prrate;
406 u32 offset;
407 u32 newoff;
408 u32 interval;
409 u32 newintr;
410 u32 seglen;
411 u8 rootexp;
Sagar Dharia29f35f02011-10-01 20:37:50 -0600412 u32 srch;
413 u32 *sinkh;
414 int nsink;
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600415 u8 chan;
416 int ref;
417 int def;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700418};
419
420/*
421 * struct slim_sched: Framework uses this structure internally for scheduling.
422 * @chc3: Array of all active coeffient 3 channels.
423 * @num_cc3: Number of active coeffient 3 channels.
424 * @chc1: Array of all active coeffient 1 channels.
425 * @num_cc1: Number of active coeffient 1 channels.
426 * @subfrmcode: Current subframe-code used by TDM. This is decided based on
427 * requested message bandwidth and current channels scheduled.
428 * @usedslots: Slots used by all active channels.
429 * @msgsl: Slots used by message-bandwidth.
430 * @pending_msgsl: Used to store pending request of message bandwidth (in slots)
431 * until the scheduling is accepted by reconfiguration.
432 * @m_reconf: This mutex is held until current reconfiguration (data channel
433 * scheduling, message bandwidth reservation) is done. Message APIs can
434 * use the bus concurrently when this mutex is held since elemental access
435 * messages can be sent on the bus when reconfiguration is in progress.
436 * @slots: Used for debugging purposes to debug/verify current schedule in TDM.
437 */
438struct slim_sched {
439 struct slim_ich **chc3;
440 int num_cc3;
441 struct slim_ich **chc1;
442 int num_cc1;
443 u32 subfrmcode;
444 u32 usedslots;
445 u32 msgsl;
446 u32 pending_msgsl;
447 struct mutex m_reconf;
448 u8 *slots;
449};
450
451/*
Sagar Dharia33f34442011-08-08 16:22:03 -0600452 * enum slim_clk_state: Slimbus controller's clock state used internally for
453 * maintaining current clock state.
454 * @SLIM_CLK_ACTIVE: Slimbus clock is active
455 * @SLIM_CLK_PAUSE_FAILED: Slimbus controlled failed to go in clock pause.
456 * Hardware-wise, this state is same as active but controller will wait on
457 * completion before making transition to SLIM_CLK_ACTIVE in framework
458 * @SLIM_CLK_ENTERING_PAUSE: Slimbus clock pause sequence is being sent on the
459 * bus. If this succeeds, state changes to SLIM_CLK_PAUSED. If the
460 * transition fails, state changes to SLIM_CLK_PAUSE_FAILED
461 * @SLIM_CLK_PAUSED: Slimbus controller clock has paused.
462 */
463enum slim_clk_state {
464 SLIM_CLK_ACTIVE,
465 SLIM_CLK_ENTERING_PAUSE,
466 SLIM_CLK_PAUSE_FAILED,
467 SLIM_CLK_PAUSED,
468};
469/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700470 * struct slim_controller: Represents manager for a SlimBUS
471 * (similar to 'master' on I2C)
472 * @dev: Device interface to this driver
473 * @nr: Board-specific number identifier for this controller/bus
474 * @list: Link with other slimbus controllers
475 * @name: Name for this controller
476 * @clkgear: Current clock gear in which this bus is running
Sagar Dharia98a7ecb2011-07-25 15:25:35 -0600477 * @min_cg: Minimum clock gear supported by this controller (default value: 1)
478 * @max_cg: Maximum clock gear supported by this controller (default value: 10)
Sagar Dharia33f34442011-08-08 16:22:03 -0600479 * @clk_state: Controller's clock state from enum slim_clk_state
480 * @pause_comp: Signals completion of clock pause sequence. This is useful when
481 * client tries to call slimbus transaction when controller may be entering
482 * clock pause.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700483 * @a_framer: Active framer which is clocking the bus managed by this controller
484 * @m_ctrl: Mutex protecting controller data structures (ports, channels etc)
485 * @addrt: Logical address table
486 * @num_dev: Number of active slimbus slaves on this bus
Sagar Dharia9c706fb2012-07-23 19:38:57 -0600487 * @devs: List of devices on this controller
488 * @wq: Workqueue per controller used to notify devices when they report present
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700489 * @txnt: Table of transactions having transaction ID
490 * @last_tid: size of the table txnt (can't grow beyond 256 since TID is 8-bits)
491 * @ports: Ports associated with this controller
492 * @nports: Number of ports supported by the controller
493 * @chans: Channels associated with this controller
494 * @nchans: Number of channels supported
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600495 * @reserved: Reserved channels that controller wants to use internally
496 * Clients will be assigned channel numbers after this number
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700497 * @sched: scheduler structure used by the controller
498 * @dev_released: completion used to signal when sysfs has released this
499 * controller so that it can be deleted during shutdown
500 * @xfer_msg: Transfer a message on this controller (this can be a broadcast
501 * control/status message like data channel setup, or a unicast message
502 * like value element read/write.
503 * @set_laddr: Setup logical address at laddr for the slave with elemental
504 * address e_addr. Drivers implementing controller will be expected to
505 * send unicast message to this device with its logical address.
Sagar Dharia36097c42012-07-24 23:44:26 -0600506 * @allocbw: Controller can override default reconfiguration and channel
507 * scheduling algorithm.
Sagar Dharia6d430092012-09-09 17:32:46 -0600508 * @get_laddr: It is possible that controller needs to set fixed logical
509 * address table and get_laddr can be used in that case so that controller
510 * can do this assignment.
Sagar Dharia33f34442011-08-08 16:22:03 -0600511 * @wakeup: This function pointer implements controller-specific procedure
512 * to wake it up from clock-pause. Framework will call this to bring
513 * the controller out of clock pause.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700514 * @config_port: Configure a port and make it ready for data transfer. This is
515 * called by framework after connect_port message is sent successfully.
516 * @framer_handover: If this controller has multiple framers, this API will
517 * be called to switch between framers if controller desires to change
518 * the active framer.
519 * @port_xfer: Called to schedule a transfer on port pn. iobuf is physical
520 * address and the buffer may have to be DMA friendly since data channels
521 * will be using data from this buffers without SW intervention.
522 * @port_xfer_status: Called by framework when client calls get_xfer_status
523 * API. Returns how much buffer is actually processed and the port
524 * errors (e.g. overflow/underflow) if any.
525 */
526struct slim_controller {
527 struct device dev;
528 unsigned int nr;
529 struct list_head list;
530 char name[SLIMBUS_NAME_SIZE];
531 int clkgear;
Sagar Dharia98a7ecb2011-07-25 15:25:35 -0600532 int min_cg;
533 int max_cg;
Sagar Dharia33f34442011-08-08 16:22:03 -0600534 enum slim_clk_state clk_state;
535 struct completion pause_comp;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700536 struct slim_framer *a_framer;
537 struct mutex m_ctrl;
538 struct slim_addrt *addrt;
539 u8 num_dev;
Sagar Dharia9c706fb2012-07-23 19:38:57 -0600540 struct list_head devs;
541 struct workqueue_struct *wq;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700542 struct slim_msg_txn **txnt;
543 u8 last_tid;
544 struct slim_port *ports;
545 int nports;
546 struct slim_ich *chans;
547 int nchans;
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600548 u8 reserved;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700549 struct slim_sched sched;
550 struct completion dev_released;
551 int (*xfer_msg)(struct slim_controller *ctrl,
552 struct slim_msg_txn *txn);
553 int (*set_laddr)(struct slim_controller *ctrl,
554 const u8 *ea, u8 elen, u8 laddr);
Sagar Dharia36097c42012-07-24 23:44:26 -0600555 int (*allocbw)(struct slim_device *sb,
556 int *subfrmc, int *clkgear);
Sagar Dharia6d430092012-09-09 17:32:46 -0600557 int (*get_laddr)(struct slim_controller *ctrl,
558 const u8 *ea, u8 elen, u8 *laddr);
Sagar Dharia33f34442011-08-08 16:22:03 -0600559 int (*wakeup)(struct slim_controller *ctrl);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700560 int (*config_port)(struct slim_controller *ctrl,
561 u8 port);
562 int (*framer_handover)(struct slim_controller *ctrl,
563 struct slim_framer *new_framer);
564 int (*port_xfer)(struct slim_controller *ctrl,
565 u8 pn, u8 *iobuf, u32 len,
566 struct completion *comp);
567 enum slim_port_err (*port_xfer_status)(struct slim_controller *ctr,
568 u8 pn, u8 **done_buf, u32 *done_len);
569};
570#define to_slim_controller(d) container_of(d, struct slim_controller, dev)
571
572/*
573 * struct slim_driver: Manage Slimbus generic/slave device driver
574 * @probe: Binds this driver to a slimbus device.
575 * @remove: Unbinds this driver from the slimbus device.
576 * @shutdown: Standard shutdown callback used during powerdown/halt.
577 * @suspend: Standard suspend callback used during system suspend
578 * @resume: Standard resume callback used during system resume
579 * @driver: Slimbus device drivers should initialize name and owner field of
580 * this structure
581 * @id_table: List of slimbus devices supported by this driver
582 */
583struct slim_driver {
584 int (*probe)(struct slim_device *sldev);
585 int (*remove)(struct slim_device *sldev);
586 void (*shutdown)(struct slim_device *sldev);
587 int (*suspend)(struct slim_device *sldev,
588 pm_message_t pmesg);
589 int (*resume)(struct slim_device *sldev);
Sagar Dharia9c706fb2012-07-23 19:38:57 -0600590 int (*device_up)(struct slim_device *sldev);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700591
592 struct device_driver driver;
593 const struct slim_device_id *id_table;
594};
595#define to_slim_driver(d) container_of(d, struct slim_driver, driver)
596
597/*
598 * struct slim_pending_ch: List of pending channels used by framework.
599 * @chan: Channel number
600 * @pending: list of channels
601 */
602struct slim_pending_ch {
603 u8 chan;
604 struct list_head pending;
605};
606
607/*
608 * Client/device handle (struct slim_device):
609 * ------------------------------------------
610 * This is the client/device handle returned when a slimbus
611 * device is registered with a controller. This structure can be provided
612 * during register_board_info, or can be allocated using slim_add_device API.
613 * Pointer to this structure is used by client-driver as a handle.
614 * @dev: Driver model representation of the device.
615 * @name: Name of driver to use with this device.
616 * @e_addr: 6-byte elemental address of this device.
617 * @driver: Device's driver. Pointer to access routines.
618 * @ctrl: Slimbus controller managing the bus hosting this device.
619 * @laddr: 1-byte Logical address of this device.
620 * @mark_define: List of channels pending definition/activation.
621 * @mark_suspend: List of channels pending suspend.
622 * @mark_removal: List of channels pending removal.
Sagar Dharia9c706fb2012-07-23 19:38:57 -0600623 * @notified: Flag to indicate whether this device has been notified. The
624 * device may report present multiple times, but should be notified only
625 * first time it has reported present.
626 * @dev_list: List of devices on a controller
627 * @wd: Work structure associated with workqueue for presence notification
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700628 * @sldev_reconf: Mutex to protect the pending data-channel lists.
629 * @pending_msgsl: Message bandwidth reservation request by this client in
630 * slots that's pending reconfiguration.
631 * @cur_msgsl: Message bandwidth reserved by this client in slots.
632 * These 3 lists are managed by framework. Lists are populated when client
633 * calls channel control API without reconfig-flag set and the lists are
634 * emptied when the reconfiguration is done by this client.
635 */
636struct slim_device {
637 struct device dev;
638 const char *name;
639 u8 e_addr[6];
640 struct slim_driver *driver;
641 struct slim_controller *ctrl;
642 u8 laddr;
643 struct list_head mark_define;
644 struct list_head mark_suspend;
645 struct list_head mark_removal;
Sagar Dharia9c706fb2012-07-23 19:38:57 -0600646 bool notified;
647 struct list_head dev_list;
648 struct work_struct wd;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700649 struct mutex sldev_reconf;
650 u32 pending_msgsl;
651 u32 cur_msgsl;
652};
653#define to_slim_device(d) container_of(d, struct slim_device, dev)
654
655/*
656 * struct slim_boardinfo: Declare board info for Slimbus device bringup.
657 * @bus_num: Controller number (bus) on which this device will sit.
658 * @slim_slave: Device to be registered with slimbus.
659 */
660struct slim_boardinfo {
661 int bus_num;
662 struct slim_device *slim_slave;
663};
664
665/*
666 * slim_get_logical_addr: Return the logical address of a slimbus device.
667 * @sb: client handle requesting the adddress.
668 * @e_addr: Elemental address of the device.
669 * @e_len: Length of e_addr
670 * @laddr: output buffer to store the address
671 * context: can sleep
672 * -EINVAL is returned in case of invalid parameters, and -ENXIO is returned if
673 * the device with this elemental address is not found.
674 */
675
676extern int slim_get_logical_addr(struct slim_device *sb, const u8 *e_addr,
677 u8 e_len, u8 *laddr);
678
679
680/* Message APIs Unicast message APIs used by slimbus slave drivers */
681
682/*
683 * Message API access routines.
684 * @sb: client handle requesting elemental message reads, writes.
685 * @msg: Input structure for start-offset, number of bytes to read.
686 * @rbuf: data buffer to be filled with values read.
687 * @len: data buffer size
688 * @wbuf: data buffer containing value/information to be written
689 * context: can sleep
690 * Returns:
691 * -EINVAL: Invalid parameters
692 * -ETIMEDOUT: If controller could not complete the request. This may happen if
693 * the bus lines are not clocked, controller is not powered-on, slave with
694 * given address is not enumerated/responding.
695 */
696extern int slim_request_val_element(struct slim_device *sb,
697 struct slim_ele_access *msg, u8 *buf,
698 u8 len);
699extern int slim_request_inf_element(struct slim_device *sb,
700 struct slim_ele_access *msg, u8 *buf,
701 u8 len);
702extern int slim_change_val_element(struct slim_device *sb,
703 struct slim_ele_access *msg,
704 const u8 *buf, u8 len);
705extern int slim_clear_inf_element(struct slim_device *sb,
706 struct slim_ele_access *msg, u8 *buf,
707 u8 len);
708extern int slim_request_change_val_element(struct slim_device *sb,
709 struct slim_ele_access *msg, u8 *rbuf,
710 const u8 *wbuf, u8 len);
711extern int slim_request_clear_inf_element(struct slim_device *sb,
712 struct slim_ele_access *msg, u8 *rbuf,
713 const u8 *wbuf, u8 len);
714
715/*
716 * Broadcast message API:
717 * call this API directly with sbdev = NULL.
718 * For broadcast reads, make sure that buffers are big-enough to incorporate
719 * replies from all logical addresses.
720 * All controllers may not support broadcast
721 */
722extern int slim_xfer_msg(struct slim_controller *ctrl,
723 struct slim_device *sbdev, struct slim_ele_access *msg,
Sagar Dharia45ee38a2011-08-03 17:01:31 -0600724 u16 mc, u8 *rbuf, const u8 *wbuf, u8 len);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700725/* end of message apis */
726
727/* Port management for manager device APIs */
728
729/*
730 * slim_alloc_mgrports: Allocate port on manager side.
731 * @sb: device/client handle.
732 * @req: Port request type.
733 * @nports: Number of ports requested
734 * @rh: output buffer to store the port handles
735 * @hsz: size of buffer storing handles
736 * context: can sleep
737 * This port will be typically used by SW. e.g. client driver wants to receive
738 * some data from audio codec HW using a data channel.
739 * Port allocated using this API will be used to receive the data.
740 * If half-duplex ports are requested, two adjacent ports are allocated for
741 * 1 half-duplex port. So the handle-buffer size should be twice the number
742 * of half-duplex ports to be allocated.
743 * -EDQUOT is returned if all ports are in use.
744 */
745extern int slim_alloc_mgrports(struct slim_device *sb, enum slim_port_req req,
746 int nports, u32 *rh, int hsz);
747
748/* Deallocate the port(s) allocated using the API above */
749extern int slim_dealloc_mgrports(struct slim_device *sb, u32 *hdl, int hsz);
750
751/*
752 * slim_port_xfer: Schedule buffer to be transferred/received using port-handle.
753 * @sb: client handle
754 * @ph: port-handle
755 * @iobuf: buffer to be transferred or populated
756 * @len: buffer size.
757 * @comp: completion signal to indicate transfer done or error.
758 * context: can sleep
759 * Returns number of bytes transferred/received if used synchronously.
760 * Will return 0 if used asynchronously.
761 * Client will call slim_port_get_xfer_status to get error and/or number of
762 * bytes transferred if used asynchronously.
763 */
764extern int slim_port_xfer(struct slim_device *sb, u32 ph, u8 *iobuf, u32 len,
765 struct completion *comp);
766
767/*
768 * slim_port_get_xfer_status: Poll for port transfers, or get transfer status
769 * after completion is done.
770 * @sb: client handle
771 * @ph: port-handle
772 * @done_buf: return pointer (iobuf from slim_port_xfer) which is processed.
773 * @done_len: Number of bytes transferred.
774 * This can be called when port_xfer complition is signalled.
775 * The API will return port transfer error (underflow/overflow/disconnect)
776 * and/or done_len will reflect number of bytes transferred. Note that
777 * done_len may be valid even if port error (overflow/underflow) has happened.
778 * e.g. If the transfer was scheduled with a few bytes to be transferred and
779 * client has not supplied more data to be transferred, done_len will indicate
780 * number of bytes transferred with underflow error. To avoid frequent underflow
781 * errors, multiple transfers can be queued (e.g. ping-pong buffers) so that
782 * channel has data to be transferred even if client is not ready to transfer
783 * data all the time. done_buf will indicate address of the last buffer
784 * processed from the multiple transfers.
785 */
786extern enum slim_port_err slim_port_get_xfer_status(struct slim_device *sb,
787 u32 ph, u8 **done_buf, u32 *done_len);
788
789/*
Sagar Dharia29f35f02011-10-01 20:37:50 -0600790 * slim_connect_src: Connect source port to channel.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700791 * @sb: client handle
Sagar Dharia29f35f02011-10-01 20:37:50 -0600792 * @srch: source handle to be connected to this channel
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700793 * @chanh: Channel with which the ports need to be associated with.
Sagar Dharia29f35f02011-10-01 20:37:50 -0600794 * Per slimbus specification, a channel may have 1 source port.
795 * Channel specified in chanh needs to be allocated first.
796 * Returns -EALREADY if source is already configured for this channel.
797 * Returns -ENOTCONN if channel is not allocated
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700798 */
Sagar Dharia29f35f02011-10-01 20:37:50 -0600799extern int slim_connect_src(struct slim_device *sb, u32 srch, u16 chanh);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700800
801/*
Sagar Dharia29f35f02011-10-01 20:37:50 -0600802 * slim_connect_sink: Connect sink port(s) to channel.
803 * @sb: client handle
804 * @sinkh: sink handle(s) to be connected to this channel
805 * @nsink: number of sinks
806 * @chanh: Channel with which the ports need to be associated with.
807 * Per slimbus specification, a channel may have multiple sink-ports.
808 * Channel specified in chanh needs to be allocated first.
809 * Returns -EALREADY if sink is already configured for this channel.
810 * Returns -ENOTCONN if channel is not allocated
811 */
812extern int slim_connect_sink(struct slim_device *sb, u32 *sinkh, int nsink,
813 u16 chanh);
814/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700815 * slim_disconnect_ports: Disconnect port(s) from channel
816 * @sb: client handle
817 * @ph: ports to be disconnected
818 * @nph: number of ports.
819 * Disconnects ports from a channel.
820 */
821extern int slim_disconnect_ports(struct slim_device *sb, u32 *ph, int nph);
822
823/*
824 * slim_get_slaveport: Get slave port handle
825 * @la: slave device logical address.
826 * @idx: port index at slave
827 * @rh: return handle
828 * @flw: Flow type (source or destination)
829 * This API only returns a slave port's representation as expected by slimbus
830 * driver. This port is not managed by the slimbus driver. Caller is expected
831 * to have visibility of this port since it's a device-port.
832 */
833extern int slim_get_slaveport(u8 la, int idx, u32 *rh, enum slim_port_flow flw);
834
835
836/* Channel functions. */
837
838/*
839 * slim_alloc_ch: Allocate a slimbus channel and return its handle.
840 * @sb: client handle.
841 * @chanh: return channel handle
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600842 * Slimbus channels are limited to 256 per specification.
843 * -EXFULL is returned if all channels are in use.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700844 * Although slimbus specification supports 256 channels, a controller may not
845 * support that many channels.
846 */
847extern int slim_alloc_ch(struct slim_device *sb, u16 *chanh);
848
849/*
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600850 * slim_query_ch: Get reference-counted handle for a channel number. Every
851 * channel is reference counted by one as producer and the others as
852 * consumer)
853 * @sb: client handle
854 * @chan: slimbus channel number
855 * @chanh: return channel handle
856 * If request channel number is not in use, it is allocated, and reference
857 * count is set to one. If the channel was was already allocated, this API
858 * will return handle to that channel and reference count is incremented.
859 * -EXFULL is returned if all channels are in use
860 */
861extern int slim_query_ch(struct slim_device *sb, u8 chan, u16 *chanh);
862/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700863 * slim_dealloc_ch: Deallocate channel allocated using the API above
864 * -EISCONN is returned if the channel is tried to be deallocated without
865 * being removed first.
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600866 * -ENOTCONN is returned if deallocation is tried on a channel that's not
867 * allocated.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700868 */
869extern int slim_dealloc_ch(struct slim_device *sb, u16 chanh);
870
871
872/*
873 * slim_define_ch: Define a channel.This API defines channel parameters for a
874 * given channel.
875 * @sb: client handle.
876 * @prop: slim_ch structure with channel parameters desired to be used.
877 * @chanh: list of channels to be defined.
878 * @nchan: number of channels in a group (1 if grp is false)
879 * @grp: Are the channels grouped
880 * @grph: return group handle if grouping of channels is desired.
881 * Channels can be grouped if multiple channels use same parameters
882 * (e.g. 5.1 audio has 6 channels with same parameters. They will all be
883 * grouped and given 1 handle for simplicity and avoid repeatedly calling
884 * the API)
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600885 * -EISCONN is returned if channel is already used with different parameters.
886 * -ENXIO is returned if the channel is not yet allocated.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700887 */
888extern int slim_define_ch(struct slim_device *sb, struct slim_ch *prop,
889 u16 *chanh, u8 nchan, bool grp, u16 *grph);
890
891/*
892 * slim_control_ch: Channel control API.
893 * @sb: client handle
894 * @grpchanh: group or channel handle to be controlled
895 * @chctrl: Control command (activate/suspend/remove)
896 * @commit: flag to indicate whether the control should take effect right-away.
897 * This API activates, removes or suspends a channel (or group of channels)
898 * grpchanh indicates the channel or group handle (returned by the define_ch
899 * API). Reconfiguration may be time-consuming since it can change all other
900 * active channel allocations on the bus, change in clock gear used by the
901 * slimbus, and change in the control space width used for messaging.
902 * commit makes sure that multiple channels can be activated/deactivated before
903 * reconfiguration is started.
904 * -EXFULL is returned if there is no space in TDM to reserve the bandwidth.
905 * -EISCONN/-ENOTCONN is returned if the channel is already connected or not
906 * yet defined.
Sagar Dharia2e7026a2012-02-21 17:48:14 -0700907 * -EINVAL is returned if individual control of a grouped-channel is attempted.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700908 */
909extern int slim_control_ch(struct slim_device *sb, u16 grpchanh,
910 enum slim_ch_control chctrl, bool commit);
911
912/*
913 * slim_get_ch_state: Channel state.
914 * This API returns the channel's state (active, suspended, inactive etc)
915 */
916extern enum slim_ch_state slim_get_ch_state(struct slim_device *sb,
917 u16 chanh);
918
919/*
920 * slim_reservemsg_bw: Request to reserve bandwidth for messages.
921 * @sb: client handle
922 * @bw_bps: message bandwidth in bits per second to be requested
923 * @commit: indicates whether the reconfiguration needs to be acted upon.
924 * This API call can be grouped with slim_control_ch API call with only one of
925 * the APIs specifying the commit flag to avoid reconfiguration being called too
926 * frequently. -EXFULL is returned if there is no space in TDM to reserve the
927 * bandwidth. -EBUSY is returned if reconfiguration is requested, but a request
928 * is already in progress.
929 */
930extern int slim_reservemsg_bw(struct slim_device *sb, u32 bw_bps, bool commit);
931
932/*
933 * slim_reconfigure_now: Request reconfiguration now.
934 * @sb: client handle
935 * This API does what commit flag in other scheduling APIs do.
936 * -EXFULL is returned if there is no space in TDM to reserve the
937 * bandwidth. -EBUSY is returned if reconfiguration request is already in
938 * progress.
939 */
940extern int slim_reconfigure_now(struct slim_device *sb);
941
942/*
Sagar Dharia33f34442011-08-08 16:22:03 -0600943 * slim_ctrl_clk_pause: Called by slimbus controller to request clock to be
944 * paused or woken up out of clock pause
945 * @ctrl: controller requesting bus to be paused or woken up
946 * @wakeup: Wakeup this controller from clock pause.
947 * @restart: Restart time value per spec used for clock pause. This value
948 * isn't used when controller is to be woken up.
949 * This API executes clock pause reconfiguration sequence if wakeup is false.
950 * If wakeup is true, controller's wakeup is called
951 * Slimbus clock is idle and can be disabled by the controller later.
952 */
953extern int slim_ctrl_clk_pause(struct slim_controller *ctrl, bool wakeup,
954 u8 restart);
955
956/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700957 * slim_driver_register: Client driver registration with slimbus
958 * @drv:Client driver to be associated with client-device.
959 * This API will register the client driver with the slimbus
960 * It is called from the driver's module-init function.
961 */
962extern int slim_driver_register(struct slim_driver *drv);
963
964/*
965 * slim_add_numbered_controller: Controller bring-up.
966 * @ctrl: Controller to be registered.
967 * A controller is registered with the framework using this API. ctrl->nr is the
968 * desired number with which slimbus framework registers the controller.
969 * Function will return -EBUSY if the number is in use.
970 */
971extern int slim_add_numbered_controller(struct slim_controller *ctrl);
972
973/*
974 * slim_del_controller: Controller tear-down.
975 * Controller added with the above API is teared down using this API.
976 */
977extern int slim_del_controller(struct slim_controller *ctrl);
978
979/*
980 * slim_add_device: Add a new device without register board info.
981 * @ctrl: Controller to which this device is to be added to.
982 * Called when device doesn't have an explicit client-driver to be probed, or
983 * the client-driver is a module installed dynamically.
984 */
985extern int slim_add_device(struct slim_controller *ctrl,
986 struct slim_device *sbdev);
987
988/* slim_remove_device: Remove the effect of slim_add_device() */
989extern void slim_remove_device(struct slim_device *sbdev);
990
991/*
992 * slim_assign_laddr: Assign logical address to a device enumerated.
993 * @ctrl: Controller with which device is enumerated.
994 * @e_addr: 6-byte elemental address of the device.
995 * @e_len: buffer length for e_addr
Sagar Dharia6d430092012-09-09 17:32:46 -0600996 * @laddr: Return logical address (if valid flag is false)
997 * @valid: true if laddr holds a valid address that controller wants to
998 * set for this enumeration address. Otherwise framework sets index into
999 * address table as logical address.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001000 * Called by controller in response to REPORT_PRESENT. Framework will assign
1001 * a logical address to this enumeration address.
1002 * Function returns -EXFULL to indicate that all logical addresses are already
1003 * taken.
1004 */
1005extern int slim_assign_laddr(struct slim_controller *ctrl, const u8 *e_addr,
Sagar Dharia6d430092012-09-09 17:32:46 -06001006 u8 e_len, u8 *laddr, bool valid);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001007
1008/*
1009 * slim_msg_response: Deliver Message response received from a device to the
1010 * framework.
1011 * @ctrl: Controller handle
1012 * @reply: Reply received from the device
1013 * @len: Length of the reply
1014 * @tid: Transaction ID received with which framework can associate reply.
1015 * Called by controller to inform framework about the response received.
1016 * This helps in making the API asynchronous, and controller-driver doesn't need
1017 * to manage 1 more table other than the one managed by framework mapping TID
1018 * with buffers
1019 */
1020extern void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid,
1021 u8 len);
1022
1023/*
1024 * slim_busnum_to_ctrl: Map bus number to controller
1025 * @busnum: Bus number
1026 * Returns controller representing this bus number
1027 */
1028extern struct slim_controller *slim_busnum_to_ctrl(u32 busnum);
1029
1030/*
1031 * slim_register_board_info: Board-initialization routine.
1032 * @info: List of all devices on all controllers present on the board.
1033 * @n: number of entries.
1034 * API enumerates respective devices on corresponding controller.
1035 * Called from board-init function.
1036 */
1037#ifdef CONFIG_SLIMBUS
1038extern int slim_register_board_info(struct slim_boardinfo const *info,
1039 unsigned n);
1040#else
1041int slim_register_board_info(struct slim_boardinfo const *info,
1042 unsigned n)
1043{
1044 return 0;
1045}
1046#endif
1047
1048static inline void *slim_get_ctrldata(const struct slim_controller *dev)
1049{
1050 return dev_get_drvdata(&dev->dev);
1051}
1052
1053static inline void slim_set_ctrldata(struct slim_controller *dev, void *data)
1054{
1055 dev_set_drvdata(&dev->dev, data);
1056}
1057
1058static inline void *slim_get_devicedata(const struct slim_device *dev)
1059{
1060 return dev_get_drvdata(&dev->dev);
1061}
1062
1063static inline void slim_set_clientdata(struct slim_device *dev, void *data)
1064{
1065 dev_set_drvdata(&dev->dev, data);
1066}
1067#endif /* _LINUX_SLIMBUS_H */