blob: c5031c10d5dc39f2fa88bacdb5775d5521e4406e [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
146 */
147struct slim_addrt {
148 bool valid;
149 u8 eaddr[6];
150};
151
152/*
153 * struct slim_msg_txn: Message to be sent by the controller.
154 * Linux framework uses this structure with drivers implementing controller.
155 * This structure has packet header, payload and buffer to be filled (if any)
156 * For the header information, refer to Table 34-36.
157 * @rl: Header field. remaining length.
158 * @mt: Header field. Message type.
Sagar Dharia45ee38a2011-08-03 17:01:31 -0600159 * @mc: Header field. LSB is message code for type mt. Framework will set MSB to
160 * SLIM_MSG_CLK_PAUSE_SEQ_FLG in case "mc" in the reconfiguration sequence
161 * is for pausing the clock.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700162 * @dt: Header field. Destination type.
163 * @ec: Element size. Used for elemental access APIs.
164 * @len: Length of payload. (excludes ec)
165 * @tid: Transaction ID. Used for messages expecting response.
166 * (e.g. relevant for mc = SLIM_MSG_MC_REQUEST_INFORMATION)
167 * @la: Logical address of the device this message is going to.
168 * (Not used when destination type is broadcast.)
169 * @rbuf: Buffer to be populated by controller when response is received.
170 * @wbuf: Payload of the message. (e.g. channel number for DATA channel APIs)
171 * @comp: Completion structure. Used by controller to notify response.
172 * (Field is relevant when tid is used)
173 */
174struct slim_msg_txn {
175 u8 rl;
176 u8 mt;
Sagar Dharia45ee38a2011-08-03 17:01:31 -0600177 u16 mc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700178 u8 dt;
179 u16 ec;
180 u8 len;
181 u8 tid;
182 u8 la;
183 u8 *rbuf;
184 const u8 *wbuf;
185 struct completion *comp;
186};
187
188/* Internal port state used by slimbus framework to manage data-ports */
189enum slim_port_state {
190 SLIM_P_FREE,
191 SLIM_P_UNCFG,
192 SLIM_P_CFG,
193};
194
195/*
196 * enum slim_port_req: Request port type by user through APIs to manage ports
197 * User can request default, half-duplex or port to be used in multi-channel
198 * configuration. Default indicates a simplex port.
199 */
200enum slim_port_req {
201 SLIM_REQ_DEFAULT,
202 SLIM_REQ_HALF_DUP,
203 SLIM_REQ_MULTI_CH,
204};
205
206/*
207 * enum slim_port_cfg: Port configuration parameters requested.
208 * User can request no configuration, packed data, or MSB aligned data port
209 */
210enum slim_port_cfg {
211 SLIM_CFG_NONE,
212 SLIM_CFG_PACKED,
213 SLIM_CFG_ALIGN_MSB,
214};
215
216/* enum slim_port_flow: Port flow type (inbound/outbound). */
217enum slim_port_flow {
218 SLIM_SRC,
219 SLIM_SINK,
220};
221
222/* enum slim_port_err: Port errors */
223enum slim_port_err {
224 SLIM_P_INPROGRESS,
225 SLIM_P_OVERFLOW,
226 SLIM_P_UNDERFLOW,
227 SLIM_P_DISCONNECT,
228 SLIM_P_NOT_OWNED,
229};
230
231/*
232 * struct slim_port: Internal structure used by framework to manage ports
233 * @err: Port error if any for this port. Refer to enum above.
234 * @state: Port state. Refer to enum above.
235 * @req: Port request for this port.
236 * @cfg: Port configuration for this port.
237 * @flow: Flow type of this port.
238 * @ch: Channel association of this port.
239 * @xcomp: Completion to indicate error, data transfer done event.
240 * @ctrl: Controller to which this port belongs to. This is useful to associate
241 * port with the SW since port hardware interrupts may only contain port
242 * information.
243 */
244struct slim_port {
245 enum slim_port_err err;
246 enum slim_port_state state;
247 enum slim_port_req req;
248 enum slim_port_cfg cfg;
249 enum slim_port_flow flow;
250 struct slim_ch *ch;
251 struct completion *xcomp;
252 struct slim_controller *ctrl;
253};
254
255/*
256 * enum slim_ch_state: Channel state of a channel.
257 * Channel transition happens from free-to-allocated-to-defined-to-pending-
258 * active-to-active.
259 * Once active, channel can be removed or suspended. Suspended channels are
260 * still scheduled, but data transfer doesn't happen.
261 * Removed channels are not deallocated until dealloc_ch API is used.
262 * Deallocation reset channel state back to free.
263 * Removed channels can be defined with different parameters.
264 */
265enum slim_ch_state {
266 SLIM_CH_FREE,
267 SLIM_CH_ALLOCATED,
268 SLIM_CH_DEFINED,
269 SLIM_CH_PENDING_ACTIVE,
270 SLIM_CH_ACTIVE,
271 SLIM_CH_SUSPENDED,
272 SLIM_CH_PENDING_REMOVAL,
273};
274
275/*
276 * enum slim_ch_proto: Channel protocol used by the channel.
277 * Hard Isochronous channel is not scheduled if current frequency doesn't allow
278 * the channel to be run without flow-control.
279 * Auto isochronous channel will be scheduled as hard-isochronous or push-pull
280 * depending on current bus frequency.
281 * Currently, Push-pull or async or extended channels are not supported.
282 * For more details, refer to slimbus spec
283 */
284enum slim_ch_proto {
285 SLIM_HARD_ISO,
286 SLIM_AUTO_ISO,
287 SLIM_PUSH,
288 SLIM_PULL,
289 SLIM_ASYNC_SMPLX,
290 SLIM_ASYNC_HALF_DUP,
291 SLIM_EXT_SMPLX,
292 SLIM_EXT_HALF_DUP,
293};
294
295/*
296 * enum slim_ch_rate: Most commonly used frequency rate families.
297 * Use 1HZ for push-pull transport.
298 * 4KHz and 11.025KHz are most commonly used in audio applications.
299 * Typically, slimbus runs at frequencies to support channels running at 4KHz
300 * and/or 11.025KHz isochronously.
301 */
302enum slim_ch_rate {
303 SLIM_RATE_1HZ,
304 SLIM_RATE_4000HZ,
305 SLIM_RATE_11025HZ,
306};
307
308/*
309 * enum slim_ch_coeff: Coefficient of a channel used internally by framework.
310 * Coefficient is applicable to channels running isochronously.
311 * Coefficient is calculated based on channel rate multiplier.
312 * (If rate multiplier is power of 2, it's coeff.1 channel. Otherwise it's
313 * coeff.3 channel.
314 */
315enum slim_ch_coeff {
316 SLIM_COEFF_1,
317 SLIM_COEFF_3,
318};
319
320/*
321 * enum slim_ch_control: Channel control.
322 * Activate will schedule channel and/or group of channels in the TDM frame.
323 * Suspend will keep the schedule but data-transfer won't happen.
324 * Remove will remove the channel/group from the TDM frame.
325 */
326enum slim_ch_control {
327 SLIM_CH_ACTIVATE,
328 SLIM_CH_SUSPEND,
329 SLIM_CH_REMOVE,
330};
331
332/* enum slim_ch_dataf: Data format per table 60 from slimbus spec 1.01.01 */
333enum slim_ch_dataf {
334 SLIM_CH_DATAF_NOT_DEFINED = 0,
335 SLIM_CH_DATAF_LPCM_AUDIO = 1,
336 SLIM_CH_DATAF_IEC61937_COMP_AUDIO = 2,
337 SLIM_CH_DATAF_PACKED_PDM_AUDIO = 3,
338};
339
340/* enum slim_ch_auxf: Auxiliary field format per table 59 from slimbus spec */
341enum slim_ch_auxf {
342 SLIM_CH_AUXF_NOT_APPLICABLE = 0,
343 SLIM_CH_AUXF_ZCUV_TUNNEL_IEC60958 = 1,
344 SLIM_CH_USER_DEFINED = 0xF,
345};
346
347/*
348 * struct slim_ch: Channel structure used externally by users of channel APIs.
349 * @prot: Desired slimbus protocol.
350 * @baser: Desired base rate. (Typical isochronous rates are: 4KHz, or 11.025KHz
351 * @dataf: Data format.
352 * @auxf: Auxiliary format.
353 * @ratem: Channel rate multiplier. (e.g. 48KHz channel will have 4KHz base rate
354 * and 12 as rate multiplier.
355 * @sampleszbits: Sample size in bits.
356 */
357struct slim_ch {
358 enum slim_ch_proto prot;
359 enum slim_ch_rate baser;
360 enum slim_ch_dataf dataf;
361 enum slim_ch_auxf auxf;
362 u32 ratem;
363 u32 sampleszbits;
364};
365
366/*
367 * struct slim_ich: Internal channel structure used by slimbus framework.
368 * @prop: structure passed by the client.
369 * @coeff: Coefficient of this channel.
370 * @state: Current state of the channel.
371 * @nextgrp: If this channel is part of group, next channel in this group.
372 * @prrate: Presence rate of this channel (per table 62 of the spec)
373 * @offset: Offset of this channel in the superframe.
374 * @newoff: Used during scheduling to hold temporary new offset until the offset
375 * is accepted/rejected by slimbus reconfiguration.
376 * @interval: Interval of this channel per superframe.
377 * @newintr: Used during scheduling to new interval temporarily.
378 * @seglen: Segment length of this channel.
379 * @rootexp: root exponent of this channel. Rate can be found using rootexp and
380 * coefficient. Used during scheduling.
Sagar Dharia29f35f02011-10-01 20:37:50 -0600381 * @srch: Source port used by this channel.
382 * @sinkh: Sink ports used by this channel.
383 * @nsink: number of sink ports used by this channel.
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600384 * @chan: Channel number sent on hardware lines for this channel. May not be
385 * equal to array-index into chans if client requested to use number beyond
386 * channel-array for the controller.
387 * @ref: Reference number to keep track of how many clients (upto 2) are using
388 * this channel.
389 * @def: Used to keep track of how many times the channel definition is sent
390 * to hardware and this will decide if channel-remove can be sent for the
391 * channel. Channel definition may be sent upto twice (once per producer
392 * and once per consumer). Channel removal should be sent only once to
393 * avoid clients getting underflow/overflow errors.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700394 */
395struct slim_ich {
396 struct slim_ch prop;
397 enum slim_ch_coeff coeff;
398 enum slim_ch_state state;
399 u16 nextgrp;
400 u32 prrate;
401 u32 offset;
402 u32 newoff;
403 u32 interval;
404 u32 newintr;
405 u32 seglen;
406 u8 rootexp;
Sagar Dharia29f35f02011-10-01 20:37:50 -0600407 u32 srch;
408 u32 *sinkh;
409 int nsink;
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600410 u8 chan;
411 int ref;
412 int def;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700413};
414
415/*
416 * struct slim_sched: Framework uses this structure internally for scheduling.
417 * @chc3: Array of all active coeffient 3 channels.
418 * @num_cc3: Number of active coeffient 3 channels.
419 * @chc1: Array of all active coeffient 1 channels.
420 * @num_cc1: Number of active coeffient 1 channels.
421 * @subfrmcode: Current subframe-code used by TDM. This is decided based on
422 * requested message bandwidth and current channels scheduled.
423 * @usedslots: Slots used by all active channels.
424 * @msgsl: Slots used by message-bandwidth.
425 * @pending_msgsl: Used to store pending request of message bandwidth (in slots)
426 * until the scheduling is accepted by reconfiguration.
427 * @m_reconf: This mutex is held until current reconfiguration (data channel
428 * scheduling, message bandwidth reservation) is done. Message APIs can
429 * use the bus concurrently when this mutex is held since elemental access
430 * messages can be sent on the bus when reconfiguration is in progress.
431 * @slots: Used for debugging purposes to debug/verify current schedule in TDM.
432 */
433struct slim_sched {
434 struct slim_ich **chc3;
435 int num_cc3;
436 struct slim_ich **chc1;
437 int num_cc1;
438 u32 subfrmcode;
439 u32 usedslots;
440 u32 msgsl;
441 u32 pending_msgsl;
442 struct mutex m_reconf;
443 u8 *slots;
444};
445
446/*
Sagar Dharia33f34442011-08-08 16:22:03 -0600447 * enum slim_clk_state: Slimbus controller's clock state used internally for
448 * maintaining current clock state.
449 * @SLIM_CLK_ACTIVE: Slimbus clock is active
450 * @SLIM_CLK_PAUSE_FAILED: Slimbus controlled failed to go in clock pause.
451 * Hardware-wise, this state is same as active but controller will wait on
452 * completion before making transition to SLIM_CLK_ACTIVE in framework
453 * @SLIM_CLK_ENTERING_PAUSE: Slimbus clock pause sequence is being sent on the
454 * bus. If this succeeds, state changes to SLIM_CLK_PAUSED. If the
455 * transition fails, state changes to SLIM_CLK_PAUSE_FAILED
456 * @SLIM_CLK_PAUSED: Slimbus controller clock has paused.
457 */
458enum slim_clk_state {
459 SLIM_CLK_ACTIVE,
460 SLIM_CLK_ENTERING_PAUSE,
461 SLIM_CLK_PAUSE_FAILED,
462 SLIM_CLK_PAUSED,
463};
464/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700465 * struct slim_controller: Represents manager for a SlimBUS
466 * (similar to 'master' on I2C)
467 * @dev: Device interface to this driver
468 * @nr: Board-specific number identifier for this controller/bus
469 * @list: Link with other slimbus controllers
470 * @name: Name for this controller
471 * @clkgear: Current clock gear in which this bus is running
Sagar Dharia98a7ecb2011-07-25 15:25:35 -0600472 * @min_cg: Minimum clock gear supported by this controller (default value: 1)
473 * @max_cg: Maximum clock gear supported by this controller (default value: 10)
Sagar Dharia33f34442011-08-08 16:22:03 -0600474 * @clk_state: Controller's clock state from enum slim_clk_state
475 * @pause_comp: Signals completion of clock pause sequence. This is useful when
476 * client tries to call slimbus transaction when controller may be entering
477 * clock pause.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700478 * @a_framer: Active framer which is clocking the bus managed by this controller
479 * @m_ctrl: Mutex protecting controller data structures (ports, channels etc)
480 * @addrt: Logical address table
481 * @num_dev: Number of active slimbus slaves on this bus
Sagar Dharia9c706fb2012-07-23 19:38:57 -0600482 * @devs: List of devices on this controller
483 * @wq: Workqueue per controller used to notify devices when they report present
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700484 * @txnt: Table of transactions having transaction ID
485 * @last_tid: size of the table txnt (can't grow beyond 256 since TID is 8-bits)
486 * @ports: Ports associated with this controller
487 * @nports: Number of ports supported by the controller
488 * @chans: Channels associated with this controller
489 * @nchans: Number of channels supported
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600490 * @reserved: Reserved channels that controller wants to use internally
491 * Clients will be assigned channel numbers after this number
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700492 * @sched: scheduler structure used by the controller
493 * @dev_released: completion used to signal when sysfs has released this
494 * controller so that it can be deleted during shutdown
495 * @xfer_msg: Transfer a message on this controller (this can be a broadcast
496 * control/status message like data channel setup, or a unicast message
497 * like value element read/write.
498 * @set_laddr: Setup logical address at laddr for the slave with elemental
499 * address e_addr. Drivers implementing controller will be expected to
500 * send unicast message to this device with its logical address.
Sagar Dharia36097c42012-07-24 23:44:26 -0600501 * @allocbw: Controller can override default reconfiguration and channel
502 * scheduling algorithm.
Sagar Dharia33f34442011-08-08 16:22:03 -0600503 * @wakeup: This function pointer implements controller-specific procedure
504 * to wake it up from clock-pause. Framework will call this to bring
505 * the controller out of clock pause.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700506 * @config_port: Configure a port and make it ready for data transfer. This is
507 * called by framework after connect_port message is sent successfully.
508 * @framer_handover: If this controller has multiple framers, this API will
509 * be called to switch between framers if controller desires to change
510 * the active framer.
511 * @port_xfer: Called to schedule a transfer on port pn. iobuf is physical
512 * address and the buffer may have to be DMA friendly since data channels
513 * will be using data from this buffers without SW intervention.
514 * @port_xfer_status: Called by framework when client calls get_xfer_status
515 * API. Returns how much buffer is actually processed and the port
516 * errors (e.g. overflow/underflow) if any.
517 */
518struct slim_controller {
519 struct device dev;
520 unsigned int nr;
521 struct list_head list;
522 char name[SLIMBUS_NAME_SIZE];
523 int clkgear;
Sagar Dharia98a7ecb2011-07-25 15:25:35 -0600524 int min_cg;
525 int max_cg;
Sagar Dharia33f34442011-08-08 16:22:03 -0600526 enum slim_clk_state clk_state;
527 struct completion pause_comp;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700528 struct slim_framer *a_framer;
529 struct mutex m_ctrl;
530 struct slim_addrt *addrt;
531 u8 num_dev;
Sagar Dharia9c706fb2012-07-23 19:38:57 -0600532 struct list_head devs;
533 struct workqueue_struct *wq;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700534 struct slim_msg_txn **txnt;
535 u8 last_tid;
536 struct slim_port *ports;
537 int nports;
538 struct slim_ich *chans;
539 int nchans;
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600540 u8 reserved;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700541 struct slim_sched sched;
542 struct completion dev_released;
543 int (*xfer_msg)(struct slim_controller *ctrl,
544 struct slim_msg_txn *txn);
545 int (*set_laddr)(struct slim_controller *ctrl,
546 const u8 *ea, u8 elen, u8 laddr);
Sagar Dharia36097c42012-07-24 23:44:26 -0600547 int (*allocbw)(struct slim_device *sb,
548 int *subfrmc, int *clkgear);
Sagar Dharia33f34442011-08-08 16:22:03 -0600549 int (*wakeup)(struct slim_controller *ctrl);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700550 int (*config_port)(struct slim_controller *ctrl,
551 u8 port);
552 int (*framer_handover)(struct slim_controller *ctrl,
553 struct slim_framer *new_framer);
554 int (*port_xfer)(struct slim_controller *ctrl,
555 u8 pn, u8 *iobuf, u32 len,
556 struct completion *comp);
557 enum slim_port_err (*port_xfer_status)(struct slim_controller *ctr,
558 u8 pn, u8 **done_buf, u32 *done_len);
559};
560#define to_slim_controller(d) container_of(d, struct slim_controller, dev)
561
562/*
563 * struct slim_driver: Manage Slimbus generic/slave device driver
564 * @probe: Binds this driver to a slimbus device.
565 * @remove: Unbinds this driver from the slimbus device.
566 * @shutdown: Standard shutdown callback used during powerdown/halt.
567 * @suspend: Standard suspend callback used during system suspend
568 * @resume: Standard resume callback used during system resume
569 * @driver: Slimbus device drivers should initialize name and owner field of
570 * this structure
571 * @id_table: List of slimbus devices supported by this driver
572 */
573struct slim_driver {
574 int (*probe)(struct slim_device *sldev);
575 int (*remove)(struct slim_device *sldev);
576 void (*shutdown)(struct slim_device *sldev);
577 int (*suspend)(struct slim_device *sldev,
578 pm_message_t pmesg);
579 int (*resume)(struct slim_device *sldev);
Sagar Dharia9c706fb2012-07-23 19:38:57 -0600580 int (*device_up)(struct slim_device *sldev);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700581
582 struct device_driver driver;
583 const struct slim_device_id *id_table;
584};
585#define to_slim_driver(d) container_of(d, struct slim_driver, driver)
586
587/*
588 * struct slim_pending_ch: List of pending channels used by framework.
589 * @chan: Channel number
590 * @pending: list of channels
591 */
592struct slim_pending_ch {
593 u8 chan;
594 struct list_head pending;
595};
596
597/*
598 * Client/device handle (struct slim_device):
599 * ------------------------------------------
600 * This is the client/device handle returned when a slimbus
601 * device is registered with a controller. This structure can be provided
602 * during register_board_info, or can be allocated using slim_add_device API.
603 * Pointer to this structure is used by client-driver as a handle.
604 * @dev: Driver model representation of the device.
605 * @name: Name of driver to use with this device.
606 * @e_addr: 6-byte elemental address of this device.
607 * @driver: Device's driver. Pointer to access routines.
608 * @ctrl: Slimbus controller managing the bus hosting this device.
609 * @laddr: 1-byte Logical address of this device.
610 * @mark_define: List of channels pending definition/activation.
611 * @mark_suspend: List of channels pending suspend.
612 * @mark_removal: List of channels pending removal.
Sagar Dharia9c706fb2012-07-23 19:38:57 -0600613 * @notified: Flag to indicate whether this device has been notified. The
614 * device may report present multiple times, but should be notified only
615 * first time it has reported present.
616 * @dev_list: List of devices on a controller
617 * @wd: Work structure associated with workqueue for presence notification
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700618 * @sldev_reconf: Mutex to protect the pending data-channel lists.
619 * @pending_msgsl: Message bandwidth reservation request by this client in
620 * slots that's pending reconfiguration.
621 * @cur_msgsl: Message bandwidth reserved by this client in slots.
622 * These 3 lists are managed by framework. Lists are populated when client
623 * calls channel control API without reconfig-flag set and the lists are
624 * emptied when the reconfiguration is done by this client.
625 */
626struct slim_device {
627 struct device dev;
628 const char *name;
629 u8 e_addr[6];
630 struct slim_driver *driver;
631 struct slim_controller *ctrl;
632 u8 laddr;
633 struct list_head mark_define;
634 struct list_head mark_suspend;
635 struct list_head mark_removal;
Sagar Dharia9c706fb2012-07-23 19:38:57 -0600636 bool notified;
637 struct list_head dev_list;
638 struct work_struct wd;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700639 struct mutex sldev_reconf;
640 u32 pending_msgsl;
641 u32 cur_msgsl;
642};
643#define to_slim_device(d) container_of(d, struct slim_device, dev)
644
645/*
646 * struct slim_boardinfo: Declare board info for Slimbus device bringup.
647 * @bus_num: Controller number (bus) on which this device will sit.
648 * @slim_slave: Device to be registered with slimbus.
649 */
650struct slim_boardinfo {
651 int bus_num;
652 struct slim_device *slim_slave;
653};
654
655/*
656 * slim_get_logical_addr: Return the logical address of a slimbus device.
657 * @sb: client handle requesting the adddress.
658 * @e_addr: Elemental address of the device.
659 * @e_len: Length of e_addr
660 * @laddr: output buffer to store the address
661 * context: can sleep
662 * -EINVAL is returned in case of invalid parameters, and -ENXIO is returned if
663 * the device with this elemental address is not found.
664 */
665
666extern int slim_get_logical_addr(struct slim_device *sb, const u8 *e_addr,
667 u8 e_len, u8 *laddr);
668
669
670/* Message APIs Unicast message APIs used by slimbus slave drivers */
671
672/*
673 * Message API access routines.
674 * @sb: client handle requesting elemental message reads, writes.
675 * @msg: Input structure for start-offset, number of bytes to read.
676 * @rbuf: data buffer to be filled with values read.
677 * @len: data buffer size
678 * @wbuf: data buffer containing value/information to be written
679 * context: can sleep
680 * Returns:
681 * -EINVAL: Invalid parameters
682 * -ETIMEDOUT: If controller could not complete the request. This may happen if
683 * the bus lines are not clocked, controller is not powered-on, slave with
684 * given address is not enumerated/responding.
685 */
686extern int slim_request_val_element(struct slim_device *sb,
687 struct slim_ele_access *msg, u8 *buf,
688 u8 len);
689extern int slim_request_inf_element(struct slim_device *sb,
690 struct slim_ele_access *msg, u8 *buf,
691 u8 len);
692extern int slim_change_val_element(struct slim_device *sb,
693 struct slim_ele_access *msg,
694 const u8 *buf, u8 len);
695extern int slim_clear_inf_element(struct slim_device *sb,
696 struct slim_ele_access *msg, u8 *buf,
697 u8 len);
698extern int slim_request_change_val_element(struct slim_device *sb,
699 struct slim_ele_access *msg, u8 *rbuf,
700 const u8 *wbuf, u8 len);
701extern int slim_request_clear_inf_element(struct slim_device *sb,
702 struct slim_ele_access *msg, u8 *rbuf,
703 const u8 *wbuf, u8 len);
704
705/*
706 * Broadcast message API:
707 * call this API directly with sbdev = NULL.
708 * For broadcast reads, make sure that buffers are big-enough to incorporate
709 * replies from all logical addresses.
710 * All controllers may not support broadcast
711 */
712extern int slim_xfer_msg(struct slim_controller *ctrl,
713 struct slim_device *sbdev, struct slim_ele_access *msg,
Sagar Dharia45ee38a2011-08-03 17:01:31 -0600714 u16 mc, u8 *rbuf, const u8 *wbuf, u8 len);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700715/* end of message apis */
716
717/* Port management for manager device APIs */
718
719/*
720 * slim_alloc_mgrports: Allocate port on manager side.
721 * @sb: device/client handle.
722 * @req: Port request type.
723 * @nports: Number of ports requested
724 * @rh: output buffer to store the port handles
725 * @hsz: size of buffer storing handles
726 * context: can sleep
727 * This port will be typically used by SW. e.g. client driver wants to receive
728 * some data from audio codec HW using a data channel.
729 * Port allocated using this API will be used to receive the data.
730 * If half-duplex ports are requested, two adjacent ports are allocated for
731 * 1 half-duplex port. So the handle-buffer size should be twice the number
732 * of half-duplex ports to be allocated.
733 * -EDQUOT is returned if all ports are in use.
734 */
735extern int slim_alloc_mgrports(struct slim_device *sb, enum slim_port_req req,
736 int nports, u32 *rh, int hsz);
737
738/* Deallocate the port(s) allocated using the API above */
739extern int slim_dealloc_mgrports(struct slim_device *sb, u32 *hdl, int hsz);
740
741/*
742 * slim_port_xfer: Schedule buffer to be transferred/received using port-handle.
743 * @sb: client handle
744 * @ph: port-handle
745 * @iobuf: buffer to be transferred or populated
746 * @len: buffer size.
747 * @comp: completion signal to indicate transfer done or error.
748 * context: can sleep
749 * Returns number of bytes transferred/received if used synchronously.
750 * Will return 0 if used asynchronously.
751 * Client will call slim_port_get_xfer_status to get error and/or number of
752 * bytes transferred if used asynchronously.
753 */
754extern int slim_port_xfer(struct slim_device *sb, u32 ph, u8 *iobuf, u32 len,
755 struct completion *comp);
756
757/*
758 * slim_port_get_xfer_status: Poll for port transfers, or get transfer status
759 * after completion is done.
760 * @sb: client handle
761 * @ph: port-handle
762 * @done_buf: return pointer (iobuf from slim_port_xfer) which is processed.
763 * @done_len: Number of bytes transferred.
764 * This can be called when port_xfer complition is signalled.
765 * The API will return port transfer error (underflow/overflow/disconnect)
766 * and/or done_len will reflect number of bytes transferred. Note that
767 * done_len may be valid even if port error (overflow/underflow) has happened.
768 * e.g. If the transfer was scheduled with a few bytes to be transferred and
769 * client has not supplied more data to be transferred, done_len will indicate
770 * number of bytes transferred with underflow error. To avoid frequent underflow
771 * errors, multiple transfers can be queued (e.g. ping-pong buffers) so that
772 * channel has data to be transferred even if client is not ready to transfer
773 * data all the time. done_buf will indicate address of the last buffer
774 * processed from the multiple transfers.
775 */
776extern enum slim_port_err slim_port_get_xfer_status(struct slim_device *sb,
777 u32 ph, u8 **done_buf, u32 *done_len);
778
779/*
Sagar Dharia29f35f02011-10-01 20:37:50 -0600780 * slim_connect_src: Connect source port to channel.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700781 * @sb: client handle
Sagar Dharia29f35f02011-10-01 20:37:50 -0600782 * @srch: source handle to be connected to this channel
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700783 * @chanh: Channel with which the ports need to be associated with.
Sagar Dharia29f35f02011-10-01 20:37:50 -0600784 * Per slimbus specification, a channel may have 1 source port.
785 * Channel specified in chanh needs to be allocated first.
786 * Returns -EALREADY if source is already configured for this channel.
787 * Returns -ENOTCONN if channel is not allocated
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700788 */
Sagar Dharia29f35f02011-10-01 20:37:50 -0600789extern int slim_connect_src(struct slim_device *sb, u32 srch, u16 chanh);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700790
791/*
Sagar Dharia29f35f02011-10-01 20:37:50 -0600792 * slim_connect_sink: Connect sink port(s) to channel.
793 * @sb: client handle
794 * @sinkh: sink handle(s) to be connected to this channel
795 * @nsink: number of sinks
796 * @chanh: Channel with which the ports need to be associated with.
797 * Per slimbus specification, a channel may have multiple sink-ports.
798 * Channel specified in chanh needs to be allocated first.
799 * Returns -EALREADY if sink is already configured for this channel.
800 * Returns -ENOTCONN if channel is not allocated
801 */
802extern int slim_connect_sink(struct slim_device *sb, u32 *sinkh, int nsink,
803 u16 chanh);
804/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700805 * slim_disconnect_ports: Disconnect port(s) from channel
806 * @sb: client handle
807 * @ph: ports to be disconnected
808 * @nph: number of ports.
809 * Disconnects ports from a channel.
810 */
811extern int slim_disconnect_ports(struct slim_device *sb, u32 *ph, int nph);
812
813/*
814 * slim_get_slaveport: Get slave port handle
815 * @la: slave device logical address.
816 * @idx: port index at slave
817 * @rh: return handle
818 * @flw: Flow type (source or destination)
819 * This API only returns a slave port's representation as expected by slimbus
820 * driver. This port is not managed by the slimbus driver. Caller is expected
821 * to have visibility of this port since it's a device-port.
822 */
823extern int slim_get_slaveport(u8 la, int idx, u32 *rh, enum slim_port_flow flw);
824
825
826/* Channel functions. */
827
828/*
829 * slim_alloc_ch: Allocate a slimbus channel and return its handle.
830 * @sb: client handle.
831 * @chanh: return channel handle
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600832 * Slimbus channels are limited to 256 per specification.
833 * -EXFULL is returned if all channels are in use.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700834 * Although slimbus specification supports 256 channels, a controller may not
835 * support that many channels.
836 */
837extern int slim_alloc_ch(struct slim_device *sb, u16 *chanh);
838
839/*
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600840 * slim_query_ch: Get reference-counted handle for a channel number. Every
841 * channel is reference counted by one as producer and the others as
842 * consumer)
843 * @sb: client handle
844 * @chan: slimbus channel number
845 * @chanh: return channel handle
846 * If request channel number is not in use, it is allocated, and reference
847 * count is set to one. If the channel was was already allocated, this API
848 * will return handle to that channel and reference count is incremented.
849 * -EXFULL is returned if all channels are in use
850 */
851extern int slim_query_ch(struct slim_device *sb, u8 chan, u16 *chanh);
852/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700853 * slim_dealloc_ch: Deallocate channel allocated using the API above
854 * -EISCONN is returned if the channel is tried to be deallocated without
855 * being removed first.
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600856 * -ENOTCONN is returned if deallocation is tried on a channel that's not
857 * allocated.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700858 */
859extern int slim_dealloc_ch(struct slim_device *sb, u16 chanh);
860
861
862/*
863 * slim_define_ch: Define a channel.This API defines channel parameters for a
864 * given channel.
865 * @sb: client handle.
866 * @prop: slim_ch structure with channel parameters desired to be used.
867 * @chanh: list of channels to be defined.
868 * @nchan: number of channels in a group (1 if grp is false)
869 * @grp: Are the channels grouped
870 * @grph: return group handle if grouping of channels is desired.
871 * Channels can be grouped if multiple channels use same parameters
872 * (e.g. 5.1 audio has 6 channels with same parameters. They will all be
873 * grouped and given 1 handle for simplicity and avoid repeatedly calling
874 * the API)
Sagar Dharia4ec2ff42011-09-26 10:20:17 -0600875 * -EISCONN is returned if channel is already used with different parameters.
876 * -ENXIO is returned if the channel is not yet allocated.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700877 */
878extern int slim_define_ch(struct slim_device *sb, struct slim_ch *prop,
879 u16 *chanh, u8 nchan, bool grp, u16 *grph);
880
881/*
882 * slim_control_ch: Channel control API.
883 * @sb: client handle
884 * @grpchanh: group or channel handle to be controlled
885 * @chctrl: Control command (activate/suspend/remove)
886 * @commit: flag to indicate whether the control should take effect right-away.
887 * This API activates, removes or suspends a channel (or group of channels)
888 * grpchanh indicates the channel or group handle (returned by the define_ch
889 * API). Reconfiguration may be time-consuming since it can change all other
890 * active channel allocations on the bus, change in clock gear used by the
891 * slimbus, and change in the control space width used for messaging.
892 * commit makes sure that multiple channels can be activated/deactivated before
893 * reconfiguration is started.
894 * -EXFULL is returned if there is no space in TDM to reserve the bandwidth.
895 * -EISCONN/-ENOTCONN is returned if the channel is already connected or not
896 * yet defined.
Sagar Dharia2e7026a2012-02-21 17:48:14 -0700897 * -EINVAL is returned if individual control of a grouped-channel is attempted.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700898 */
899extern int slim_control_ch(struct slim_device *sb, u16 grpchanh,
900 enum slim_ch_control chctrl, bool commit);
901
902/*
903 * slim_get_ch_state: Channel state.
904 * This API returns the channel's state (active, suspended, inactive etc)
905 */
906extern enum slim_ch_state slim_get_ch_state(struct slim_device *sb,
907 u16 chanh);
908
909/*
910 * slim_reservemsg_bw: Request to reserve bandwidth for messages.
911 * @sb: client handle
912 * @bw_bps: message bandwidth in bits per second to be requested
913 * @commit: indicates whether the reconfiguration needs to be acted upon.
914 * This API call can be grouped with slim_control_ch API call with only one of
915 * the APIs specifying the commit flag to avoid reconfiguration being called too
916 * frequently. -EXFULL is returned if there is no space in TDM to reserve the
917 * bandwidth. -EBUSY is returned if reconfiguration is requested, but a request
918 * is already in progress.
919 */
920extern int slim_reservemsg_bw(struct slim_device *sb, u32 bw_bps, bool commit);
921
922/*
923 * slim_reconfigure_now: Request reconfiguration now.
924 * @sb: client handle
925 * This API does what commit flag in other scheduling APIs do.
926 * -EXFULL is returned if there is no space in TDM to reserve the
927 * bandwidth. -EBUSY is returned if reconfiguration request is already in
928 * progress.
929 */
930extern int slim_reconfigure_now(struct slim_device *sb);
931
932/*
Sagar Dharia33f34442011-08-08 16:22:03 -0600933 * slim_ctrl_clk_pause: Called by slimbus controller to request clock to be
934 * paused or woken up out of clock pause
935 * @ctrl: controller requesting bus to be paused or woken up
936 * @wakeup: Wakeup this controller from clock pause.
937 * @restart: Restart time value per spec used for clock pause. This value
938 * isn't used when controller is to be woken up.
939 * This API executes clock pause reconfiguration sequence if wakeup is false.
940 * If wakeup is true, controller's wakeup is called
941 * Slimbus clock is idle and can be disabled by the controller later.
942 */
943extern int slim_ctrl_clk_pause(struct slim_controller *ctrl, bool wakeup,
944 u8 restart);
945
946/*
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700947 * slim_driver_register: Client driver registration with slimbus
948 * @drv:Client driver to be associated with client-device.
949 * This API will register the client driver with the slimbus
950 * It is called from the driver's module-init function.
951 */
952extern int slim_driver_register(struct slim_driver *drv);
953
954/*
955 * slim_add_numbered_controller: Controller bring-up.
956 * @ctrl: Controller to be registered.
957 * A controller is registered with the framework using this API. ctrl->nr is the
958 * desired number with which slimbus framework registers the controller.
959 * Function will return -EBUSY if the number is in use.
960 */
961extern int slim_add_numbered_controller(struct slim_controller *ctrl);
962
963/*
964 * slim_del_controller: Controller tear-down.
965 * Controller added with the above API is teared down using this API.
966 */
967extern int slim_del_controller(struct slim_controller *ctrl);
968
969/*
970 * slim_add_device: Add a new device without register board info.
971 * @ctrl: Controller to which this device is to be added to.
972 * Called when device doesn't have an explicit client-driver to be probed, or
973 * the client-driver is a module installed dynamically.
974 */
975extern int slim_add_device(struct slim_controller *ctrl,
976 struct slim_device *sbdev);
977
978/* slim_remove_device: Remove the effect of slim_add_device() */
979extern void slim_remove_device(struct slim_device *sbdev);
980
981/*
982 * slim_assign_laddr: Assign logical address to a device enumerated.
983 * @ctrl: Controller with which device is enumerated.
984 * @e_addr: 6-byte elemental address of the device.
985 * @e_len: buffer length for e_addr
986 * @laddr: Return logical address.
987 * Called by controller in response to REPORT_PRESENT. Framework will assign
988 * a logical address to this enumeration address.
989 * Function returns -EXFULL to indicate that all logical addresses are already
990 * taken.
991 */
992extern int slim_assign_laddr(struct slim_controller *ctrl, const u8 *e_addr,
993 u8 e_len, u8 *laddr);
994
995/*
996 * slim_msg_response: Deliver Message response received from a device to the
997 * framework.
998 * @ctrl: Controller handle
999 * @reply: Reply received from the device
1000 * @len: Length of the reply
1001 * @tid: Transaction ID received with which framework can associate reply.
1002 * Called by controller to inform framework about the response received.
1003 * This helps in making the API asynchronous, and controller-driver doesn't need
1004 * to manage 1 more table other than the one managed by framework mapping TID
1005 * with buffers
1006 */
1007extern void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid,
1008 u8 len);
1009
1010/*
1011 * slim_busnum_to_ctrl: Map bus number to controller
1012 * @busnum: Bus number
1013 * Returns controller representing this bus number
1014 */
1015extern struct slim_controller *slim_busnum_to_ctrl(u32 busnum);
1016
1017/*
1018 * slim_register_board_info: Board-initialization routine.
1019 * @info: List of all devices on all controllers present on the board.
1020 * @n: number of entries.
1021 * API enumerates respective devices on corresponding controller.
1022 * Called from board-init function.
1023 */
1024#ifdef CONFIG_SLIMBUS
1025extern int slim_register_board_info(struct slim_boardinfo const *info,
1026 unsigned n);
1027#else
1028int slim_register_board_info(struct slim_boardinfo const *info,
1029 unsigned n)
1030{
1031 return 0;
1032}
1033#endif
1034
1035static inline void *slim_get_ctrldata(const struct slim_controller *dev)
1036{
1037 return dev_get_drvdata(&dev->dev);
1038}
1039
1040static inline void slim_set_ctrldata(struct slim_controller *dev, void *data)
1041{
1042 dev_set_drvdata(&dev->dev, data);
1043}
1044
1045static inline void *slim_get_devicedata(const struct slim_device *dev)
1046{
1047 return dev_get_drvdata(&dev->dev);
1048}
1049
1050static inline void slim_set_clientdata(struct slim_device *dev, void *data)
1051{
1052 dev_set_drvdata(&dev->dev, data);
1053}
1054#endif /* _LINUX_SLIMBUS_H */