Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 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 | |
| 22 | extern 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 Dharia | 98a7ecb | 2011-07-25 15:25:35 -0600 | [diff] [blame^] | 28 | #define SLIM_MIN_CLK_GEAR 1 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 29 | #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 | |
| 86 | /* Value management messages */ |
| 87 | #define SLIM_MSG_MC_REQUEST_VALUE 0x60 |
| 88 | #define SLIM_MSG_MC_REQUEST_CHANGE_VALUE 0x61 |
| 89 | #define SLIM_MSG_MC_REPLY_VALUE 0x64 |
| 90 | #define SLIM_MSG_MC_CHANGE_VALUE 0x68 |
| 91 | |
| 92 | struct slim_controller; |
| 93 | struct slim_device; |
| 94 | |
| 95 | /* Destination type Values defined in Table 33 (slimbus spec 1.01.01) */ |
| 96 | #define SLIM_MSG_DEST_LOGICALADDR 0 |
| 97 | #define SLIM_MSG_DEST_ENUMADDR 1 |
| 98 | #define SLIM_MSG_DEST_BROADCAST 3 |
| 99 | |
| 100 | /* |
| 101 | * @start_offset: Specifies starting offset in information/value element map |
| 102 | * @num_bytes: Can be 1, 2, 3, 4, 6, 8, 12, 16 per spec. This ensures that the |
| 103 | * message will fit in the 40-byte message limit and the slicesize can be |
| 104 | * compatible with values in table 21 (slimbus spec 1.01.01) |
| 105 | * @comp: Completion to indicate end of message-transfer. Used if client wishes |
| 106 | * to use the API asynchronously. |
| 107 | */ |
| 108 | struct slim_ele_access { |
| 109 | u16 start_offset; |
| 110 | u8 num_bytes; |
| 111 | struct completion *comp; |
| 112 | }; |
| 113 | |
| 114 | /* |
| 115 | * struct slim_framer - Represents Slimbus framer. |
| 116 | * Every controller may have multiple framers. |
| 117 | * Manager is responsible for framer hand-over. |
| 118 | * @e_addr: 6 byte Elemental address of the framer. |
| 119 | * @rootfreq: Root Frequency at which the framer can run. This is maximum |
| 120 | * frequency (clock gear 10 per slimbus spec) at which the bus can operate. |
| 121 | * @superfreq: Superframes per root frequency. Every frame is 6144 cells (bits) |
| 122 | * per slimbus specification. |
| 123 | */ |
| 124 | struct slim_framer { |
| 125 | u8 e_addr[6]; |
| 126 | int rootfreq; |
| 127 | int superfreq; |
| 128 | }; |
| 129 | #define to_slim_framer(d) container_of(d, struct slim_framer, dev); |
| 130 | |
| 131 | /* |
| 132 | * struct slim_addrt: slimbus address used internally by the slimbus framework. |
| 133 | * @valid: If the device is still there or if the address can be reused. |
| 134 | * @eaddr: 6-bytes-long elemental address |
| 135 | */ |
| 136 | struct slim_addrt { |
| 137 | bool valid; |
| 138 | u8 eaddr[6]; |
| 139 | }; |
| 140 | |
| 141 | /* |
| 142 | * struct slim_msg_txn: Message to be sent by the controller. |
| 143 | * Linux framework uses this structure with drivers implementing controller. |
| 144 | * This structure has packet header, payload and buffer to be filled (if any) |
| 145 | * For the header information, refer to Table 34-36. |
| 146 | * @rl: Header field. remaining length. |
| 147 | * @mt: Header field. Message type. |
| 148 | * @mc: Header field. Message code for type mt. |
| 149 | * @dt: Header field. Destination type. |
| 150 | * @ec: Element size. Used for elemental access APIs. |
| 151 | * @len: Length of payload. (excludes ec) |
| 152 | * @tid: Transaction ID. Used for messages expecting response. |
| 153 | * (e.g. relevant for mc = SLIM_MSG_MC_REQUEST_INFORMATION) |
| 154 | * @la: Logical address of the device this message is going to. |
| 155 | * (Not used when destination type is broadcast.) |
| 156 | * @rbuf: Buffer to be populated by controller when response is received. |
| 157 | * @wbuf: Payload of the message. (e.g. channel number for DATA channel APIs) |
| 158 | * @comp: Completion structure. Used by controller to notify response. |
| 159 | * (Field is relevant when tid is used) |
| 160 | */ |
| 161 | struct slim_msg_txn { |
| 162 | u8 rl; |
| 163 | u8 mt; |
| 164 | u8 mc; |
| 165 | u8 dt; |
| 166 | u16 ec; |
| 167 | u8 len; |
| 168 | u8 tid; |
| 169 | u8 la; |
| 170 | u8 *rbuf; |
| 171 | const u8 *wbuf; |
| 172 | struct completion *comp; |
| 173 | }; |
| 174 | |
| 175 | /* Internal port state used by slimbus framework to manage data-ports */ |
| 176 | enum slim_port_state { |
| 177 | SLIM_P_FREE, |
| 178 | SLIM_P_UNCFG, |
| 179 | SLIM_P_CFG, |
| 180 | }; |
| 181 | |
| 182 | /* |
| 183 | * enum slim_port_req: Request port type by user through APIs to manage ports |
| 184 | * User can request default, half-duplex or port to be used in multi-channel |
| 185 | * configuration. Default indicates a simplex port. |
| 186 | */ |
| 187 | enum slim_port_req { |
| 188 | SLIM_REQ_DEFAULT, |
| 189 | SLIM_REQ_HALF_DUP, |
| 190 | SLIM_REQ_MULTI_CH, |
| 191 | }; |
| 192 | |
| 193 | /* |
| 194 | * enum slim_port_cfg: Port configuration parameters requested. |
| 195 | * User can request no configuration, packed data, or MSB aligned data port |
| 196 | */ |
| 197 | enum slim_port_cfg { |
| 198 | SLIM_CFG_NONE, |
| 199 | SLIM_CFG_PACKED, |
| 200 | SLIM_CFG_ALIGN_MSB, |
| 201 | }; |
| 202 | |
| 203 | /* enum slim_port_flow: Port flow type (inbound/outbound). */ |
| 204 | enum slim_port_flow { |
| 205 | SLIM_SRC, |
| 206 | SLIM_SINK, |
| 207 | }; |
| 208 | |
| 209 | /* enum slim_port_err: Port errors */ |
| 210 | enum slim_port_err { |
| 211 | SLIM_P_INPROGRESS, |
| 212 | SLIM_P_OVERFLOW, |
| 213 | SLIM_P_UNDERFLOW, |
| 214 | SLIM_P_DISCONNECT, |
| 215 | SLIM_P_NOT_OWNED, |
| 216 | }; |
| 217 | |
| 218 | /* |
| 219 | * struct slim_port: Internal structure used by framework to manage ports |
| 220 | * @err: Port error if any for this port. Refer to enum above. |
| 221 | * @state: Port state. Refer to enum above. |
| 222 | * @req: Port request for this port. |
| 223 | * @cfg: Port configuration for this port. |
| 224 | * @flow: Flow type of this port. |
| 225 | * @ch: Channel association of this port. |
| 226 | * @xcomp: Completion to indicate error, data transfer done event. |
| 227 | * @ctrl: Controller to which this port belongs to. This is useful to associate |
| 228 | * port with the SW since port hardware interrupts may only contain port |
| 229 | * information. |
| 230 | */ |
| 231 | struct slim_port { |
| 232 | enum slim_port_err err; |
| 233 | enum slim_port_state state; |
| 234 | enum slim_port_req req; |
| 235 | enum slim_port_cfg cfg; |
| 236 | enum slim_port_flow flow; |
| 237 | struct slim_ch *ch; |
| 238 | struct completion *xcomp; |
| 239 | struct slim_controller *ctrl; |
| 240 | }; |
| 241 | |
| 242 | /* |
| 243 | * enum slim_ch_state: Channel state of a channel. |
| 244 | * Channel transition happens from free-to-allocated-to-defined-to-pending- |
| 245 | * active-to-active. |
| 246 | * Once active, channel can be removed or suspended. Suspended channels are |
| 247 | * still scheduled, but data transfer doesn't happen. |
| 248 | * Removed channels are not deallocated until dealloc_ch API is used. |
| 249 | * Deallocation reset channel state back to free. |
| 250 | * Removed channels can be defined with different parameters. |
| 251 | */ |
| 252 | enum slim_ch_state { |
| 253 | SLIM_CH_FREE, |
| 254 | SLIM_CH_ALLOCATED, |
| 255 | SLIM_CH_DEFINED, |
| 256 | SLIM_CH_PENDING_ACTIVE, |
| 257 | SLIM_CH_ACTIVE, |
| 258 | SLIM_CH_SUSPENDED, |
| 259 | SLIM_CH_PENDING_REMOVAL, |
| 260 | }; |
| 261 | |
| 262 | /* |
| 263 | * enum slim_ch_proto: Channel protocol used by the channel. |
| 264 | * Hard Isochronous channel is not scheduled if current frequency doesn't allow |
| 265 | * the channel to be run without flow-control. |
| 266 | * Auto isochronous channel will be scheduled as hard-isochronous or push-pull |
| 267 | * depending on current bus frequency. |
| 268 | * Currently, Push-pull or async or extended channels are not supported. |
| 269 | * For more details, refer to slimbus spec |
| 270 | */ |
| 271 | enum slim_ch_proto { |
| 272 | SLIM_HARD_ISO, |
| 273 | SLIM_AUTO_ISO, |
| 274 | SLIM_PUSH, |
| 275 | SLIM_PULL, |
| 276 | SLIM_ASYNC_SMPLX, |
| 277 | SLIM_ASYNC_HALF_DUP, |
| 278 | SLIM_EXT_SMPLX, |
| 279 | SLIM_EXT_HALF_DUP, |
| 280 | }; |
| 281 | |
| 282 | /* |
| 283 | * enum slim_ch_rate: Most commonly used frequency rate families. |
| 284 | * Use 1HZ for push-pull transport. |
| 285 | * 4KHz and 11.025KHz are most commonly used in audio applications. |
| 286 | * Typically, slimbus runs at frequencies to support channels running at 4KHz |
| 287 | * and/or 11.025KHz isochronously. |
| 288 | */ |
| 289 | enum slim_ch_rate { |
| 290 | SLIM_RATE_1HZ, |
| 291 | SLIM_RATE_4000HZ, |
| 292 | SLIM_RATE_11025HZ, |
| 293 | }; |
| 294 | |
| 295 | /* |
| 296 | * enum slim_ch_coeff: Coefficient of a channel used internally by framework. |
| 297 | * Coefficient is applicable to channels running isochronously. |
| 298 | * Coefficient is calculated based on channel rate multiplier. |
| 299 | * (If rate multiplier is power of 2, it's coeff.1 channel. Otherwise it's |
| 300 | * coeff.3 channel. |
| 301 | */ |
| 302 | enum slim_ch_coeff { |
| 303 | SLIM_COEFF_1, |
| 304 | SLIM_COEFF_3, |
| 305 | }; |
| 306 | |
| 307 | /* |
| 308 | * enum slim_ch_control: Channel control. |
| 309 | * Activate will schedule channel and/or group of channels in the TDM frame. |
| 310 | * Suspend will keep the schedule but data-transfer won't happen. |
| 311 | * Remove will remove the channel/group from the TDM frame. |
| 312 | */ |
| 313 | enum slim_ch_control { |
| 314 | SLIM_CH_ACTIVATE, |
| 315 | SLIM_CH_SUSPEND, |
| 316 | SLIM_CH_REMOVE, |
| 317 | }; |
| 318 | |
| 319 | /* enum slim_ch_dataf: Data format per table 60 from slimbus spec 1.01.01 */ |
| 320 | enum slim_ch_dataf { |
| 321 | SLIM_CH_DATAF_NOT_DEFINED = 0, |
| 322 | SLIM_CH_DATAF_LPCM_AUDIO = 1, |
| 323 | SLIM_CH_DATAF_IEC61937_COMP_AUDIO = 2, |
| 324 | SLIM_CH_DATAF_PACKED_PDM_AUDIO = 3, |
| 325 | }; |
| 326 | |
| 327 | /* enum slim_ch_auxf: Auxiliary field format per table 59 from slimbus spec */ |
| 328 | enum slim_ch_auxf { |
| 329 | SLIM_CH_AUXF_NOT_APPLICABLE = 0, |
| 330 | SLIM_CH_AUXF_ZCUV_TUNNEL_IEC60958 = 1, |
| 331 | SLIM_CH_USER_DEFINED = 0xF, |
| 332 | }; |
| 333 | |
| 334 | /* |
| 335 | * struct slim_ch: Channel structure used externally by users of channel APIs. |
| 336 | * @prot: Desired slimbus protocol. |
| 337 | * @baser: Desired base rate. (Typical isochronous rates are: 4KHz, or 11.025KHz |
| 338 | * @dataf: Data format. |
| 339 | * @auxf: Auxiliary format. |
| 340 | * @ratem: Channel rate multiplier. (e.g. 48KHz channel will have 4KHz base rate |
| 341 | * and 12 as rate multiplier. |
| 342 | * @sampleszbits: Sample size in bits. |
| 343 | */ |
| 344 | struct slim_ch { |
| 345 | enum slim_ch_proto prot; |
| 346 | enum slim_ch_rate baser; |
| 347 | enum slim_ch_dataf dataf; |
| 348 | enum slim_ch_auxf auxf; |
| 349 | u32 ratem; |
| 350 | u32 sampleszbits; |
| 351 | }; |
| 352 | |
| 353 | /* |
| 354 | * struct slim_ich: Internal channel structure used by slimbus framework. |
| 355 | * @prop: structure passed by the client. |
| 356 | * @coeff: Coefficient of this channel. |
| 357 | * @state: Current state of the channel. |
| 358 | * @nextgrp: If this channel is part of group, next channel in this group. |
| 359 | * @prrate: Presence rate of this channel (per table 62 of the spec) |
| 360 | * @offset: Offset of this channel in the superframe. |
| 361 | * @newoff: Used during scheduling to hold temporary new offset until the offset |
| 362 | * is accepted/rejected by slimbus reconfiguration. |
| 363 | * @interval: Interval of this channel per superframe. |
| 364 | * @newintr: Used during scheduling to new interval temporarily. |
| 365 | * @seglen: Segment length of this channel. |
| 366 | * @rootexp: root exponent of this channel. Rate can be found using rootexp and |
| 367 | * coefficient. Used during scheduling. |
| 368 | * @srch: Source ports used by this channel. |
| 369 | * @nsrc: number of source ports used by this channel. |
| 370 | * @sinkh: Sink port used by this channel. |
| 371 | */ |
| 372 | struct slim_ich { |
| 373 | struct slim_ch prop; |
| 374 | enum slim_ch_coeff coeff; |
| 375 | enum slim_ch_state state; |
| 376 | u16 nextgrp; |
| 377 | u32 prrate; |
| 378 | u32 offset; |
| 379 | u32 newoff; |
| 380 | u32 interval; |
| 381 | u32 newintr; |
| 382 | u32 seglen; |
| 383 | u8 rootexp; |
| 384 | u32 *srch; |
| 385 | int nsrc; |
| 386 | u32 sinkh; |
| 387 | }; |
| 388 | |
| 389 | /* |
| 390 | * struct slim_sched: Framework uses this structure internally for scheduling. |
| 391 | * @chc3: Array of all active coeffient 3 channels. |
| 392 | * @num_cc3: Number of active coeffient 3 channels. |
| 393 | * @chc1: Array of all active coeffient 1 channels. |
| 394 | * @num_cc1: Number of active coeffient 1 channels. |
| 395 | * @subfrmcode: Current subframe-code used by TDM. This is decided based on |
| 396 | * requested message bandwidth and current channels scheduled. |
| 397 | * @usedslots: Slots used by all active channels. |
| 398 | * @msgsl: Slots used by message-bandwidth. |
| 399 | * @pending_msgsl: Used to store pending request of message bandwidth (in slots) |
| 400 | * until the scheduling is accepted by reconfiguration. |
| 401 | * @m_reconf: This mutex is held until current reconfiguration (data channel |
| 402 | * scheduling, message bandwidth reservation) is done. Message APIs can |
| 403 | * use the bus concurrently when this mutex is held since elemental access |
| 404 | * messages can be sent on the bus when reconfiguration is in progress. |
| 405 | * @slots: Used for debugging purposes to debug/verify current schedule in TDM. |
| 406 | */ |
| 407 | struct slim_sched { |
| 408 | struct slim_ich **chc3; |
| 409 | int num_cc3; |
| 410 | struct slim_ich **chc1; |
| 411 | int num_cc1; |
| 412 | u32 subfrmcode; |
| 413 | u32 usedslots; |
| 414 | u32 msgsl; |
| 415 | u32 pending_msgsl; |
| 416 | struct mutex m_reconf; |
| 417 | u8 *slots; |
| 418 | }; |
| 419 | |
| 420 | /* |
| 421 | * struct slim_controller: Represents manager for a SlimBUS |
| 422 | * (similar to 'master' on I2C) |
| 423 | * @dev: Device interface to this driver |
| 424 | * @nr: Board-specific number identifier for this controller/bus |
| 425 | * @list: Link with other slimbus controllers |
| 426 | * @name: Name for this controller |
| 427 | * @clkgear: Current clock gear in which this bus is running |
Sagar Dharia | 98a7ecb | 2011-07-25 15:25:35 -0600 | [diff] [blame^] | 428 | * @min_cg: Minimum clock gear supported by this controller (default value: 1) |
| 429 | * @max_cg: Maximum clock gear supported by this controller (default value: 10) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 430 | * @a_framer: Active framer which is clocking the bus managed by this controller |
| 431 | * @m_ctrl: Mutex protecting controller data structures (ports, channels etc) |
| 432 | * @addrt: Logical address table |
| 433 | * @num_dev: Number of active slimbus slaves on this bus |
| 434 | * @txnt: Table of transactions having transaction ID |
| 435 | * @last_tid: size of the table txnt (can't grow beyond 256 since TID is 8-bits) |
| 436 | * @ports: Ports associated with this controller |
| 437 | * @nports: Number of ports supported by the controller |
| 438 | * @chans: Channels associated with this controller |
| 439 | * @nchans: Number of channels supported |
| 440 | * @sched: scheduler structure used by the controller |
| 441 | * @dev_released: completion used to signal when sysfs has released this |
| 442 | * controller so that it can be deleted during shutdown |
| 443 | * @xfer_msg: Transfer a message on this controller (this can be a broadcast |
| 444 | * control/status message like data channel setup, or a unicast message |
| 445 | * like value element read/write. |
| 446 | * @set_laddr: Setup logical address at laddr for the slave with elemental |
| 447 | * address e_addr. Drivers implementing controller will be expected to |
| 448 | * send unicast message to this device with its logical address. |
| 449 | * @config_port: Configure a port and make it ready for data transfer. This is |
| 450 | * called by framework after connect_port message is sent successfully. |
| 451 | * @framer_handover: If this controller has multiple framers, this API will |
| 452 | * be called to switch between framers if controller desires to change |
| 453 | * the active framer. |
| 454 | * @port_xfer: Called to schedule a transfer on port pn. iobuf is physical |
| 455 | * address and the buffer may have to be DMA friendly since data channels |
| 456 | * will be using data from this buffers without SW intervention. |
| 457 | * @port_xfer_status: Called by framework when client calls get_xfer_status |
| 458 | * API. Returns how much buffer is actually processed and the port |
| 459 | * errors (e.g. overflow/underflow) if any. |
| 460 | */ |
| 461 | struct slim_controller { |
| 462 | struct device dev; |
| 463 | unsigned int nr; |
| 464 | struct list_head list; |
| 465 | char name[SLIMBUS_NAME_SIZE]; |
| 466 | int clkgear; |
Sagar Dharia | 98a7ecb | 2011-07-25 15:25:35 -0600 | [diff] [blame^] | 467 | int min_cg; |
| 468 | int max_cg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 469 | struct slim_framer *a_framer; |
| 470 | struct mutex m_ctrl; |
| 471 | struct slim_addrt *addrt; |
| 472 | u8 num_dev; |
| 473 | struct slim_msg_txn **txnt; |
| 474 | u8 last_tid; |
| 475 | struct slim_port *ports; |
| 476 | int nports; |
| 477 | struct slim_ich *chans; |
| 478 | int nchans; |
| 479 | struct slim_sched sched; |
| 480 | struct completion dev_released; |
| 481 | int (*xfer_msg)(struct slim_controller *ctrl, |
| 482 | struct slim_msg_txn *txn); |
| 483 | int (*set_laddr)(struct slim_controller *ctrl, |
| 484 | const u8 *ea, u8 elen, u8 laddr); |
| 485 | int (*config_port)(struct slim_controller *ctrl, |
| 486 | u8 port); |
| 487 | int (*framer_handover)(struct slim_controller *ctrl, |
| 488 | struct slim_framer *new_framer); |
| 489 | int (*port_xfer)(struct slim_controller *ctrl, |
| 490 | u8 pn, u8 *iobuf, u32 len, |
| 491 | struct completion *comp); |
| 492 | enum slim_port_err (*port_xfer_status)(struct slim_controller *ctr, |
| 493 | u8 pn, u8 **done_buf, u32 *done_len); |
| 494 | }; |
| 495 | #define to_slim_controller(d) container_of(d, struct slim_controller, dev) |
| 496 | |
| 497 | /* |
| 498 | * struct slim_driver: Manage Slimbus generic/slave device driver |
| 499 | * @probe: Binds this driver to a slimbus device. |
| 500 | * @remove: Unbinds this driver from the slimbus device. |
| 501 | * @shutdown: Standard shutdown callback used during powerdown/halt. |
| 502 | * @suspend: Standard suspend callback used during system suspend |
| 503 | * @resume: Standard resume callback used during system resume |
| 504 | * @driver: Slimbus device drivers should initialize name and owner field of |
| 505 | * this structure |
| 506 | * @id_table: List of slimbus devices supported by this driver |
| 507 | */ |
| 508 | struct slim_driver { |
| 509 | int (*probe)(struct slim_device *sldev); |
| 510 | int (*remove)(struct slim_device *sldev); |
| 511 | void (*shutdown)(struct slim_device *sldev); |
| 512 | int (*suspend)(struct slim_device *sldev, |
| 513 | pm_message_t pmesg); |
| 514 | int (*resume)(struct slim_device *sldev); |
| 515 | |
| 516 | struct device_driver driver; |
| 517 | const struct slim_device_id *id_table; |
| 518 | }; |
| 519 | #define to_slim_driver(d) container_of(d, struct slim_driver, driver) |
| 520 | |
| 521 | /* |
| 522 | * struct slim_pending_ch: List of pending channels used by framework. |
| 523 | * @chan: Channel number |
| 524 | * @pending: list of channels |
| 525 | */ |
| 526 | struct slim_pending_ch { |
| 527 | u8 chan; |
| 528 | struct list_head pending; |
| 529 | }; |
| 530 | |
| 531 | /* |
| 532 | * Client/device handle (struct slim_device): |
| 533 | * ------------------------------------------ |
| 534 | * This is the client/device handle returned when a slimbus |
| 535 | * device is registered with a controller. This structure can be provided |
| 536 | * during register_board_info, or can be allocated using slim_add_device API. |
| 537 | * Pointer to this structure is used by client-driver as a handle. |
| 538 | * @dev: Driver model representation of the device. |
| 539 | * @name: Name of driver to use with this device. |
| 540 | * @e_addr: 6-byte elemental address of this device. |
| 541 | * @driver: Device's driver. Pointer to access routines. |
| 542 | * @ctrl: Slimbus controller managing the bus hosting this device. |
| 543 | * @laddr: 1-byte Logical address of this device. |
| 544 | * @mark_define: List of channels pending definition/activation. |
| 545 | * @mark_suspend: List of channels pending suspend. |
| 546 | * @mark_removal: List of channels pending removal. |
| 547 | * @sldev_reconf: Mutex to protect the pending data-channel lists. |
| 548 | * @pending_msgsl: Message bandwidth reservation request by this client in |
| 549 | * slots that's pending reconfiguration. |
| 550 | * @cur_msgsl: Message bandwidth reserved by this client in slots. |
| 551 | * These 3 lists are managed by framework. Lists are populated when client |
| 552 | * calls channel control API without reconfig-flag set and the lists are |
| 553 | * emptied when the reconfiguration is done by this client. |
| 554 | */ |
| 555 | struct slim_device { |
| 556 | struct device dev; |
| 557 | const char *name; |
| 558 | u8 e_addr[6]; |
| 559 | struct slim_driver *driver; |
| 560 | struct slim_controller *ctrl; |
| 561 | u8 laddr; |
| 562 | struct list_head mark_define; |
| 563 | struct list_head mark_suspend; |
| 564 | struct list_head mark_removal; |
| 565 | struct mutex sldev_reconf; |
| 566 | u32 pending_msgsl; |
| 567 | u32 cur_msgsl; |
| 568 | }; |
| 569 | #define to_slim_device(d) container_of(d, struct slim_device, dev) |
| 570 | |
| 571 | /* |
| 572 | * struct slim_boardinfo: Declare board info for Slimbus device bringup. |
| 573 | * @bus_num: Controller number (bus) on which this device will sit. |
| 574 | * @slim_slave: Device to be registered with slimbus. |
| 575 | */ |
| 576 | struct slim_boardinfo { |
| 577 | int bus_num; |
| 578 | struct slim_device *slim_slave; |
| 579 | }; |
| 580 | |
| 581 | /* |
| 582 | * slim_get_logical_addr: Return the logical address of a slimbus device. |
| 583 | * @sb: client handle requesting the adddress. |
| 584 | * @e_addr: Elemental address of the device. |
| 585 | * @e_len: Length of e_addr |
| 586 | * @laddr: output buffer to store the address |
| 587 | * context: can sleep |
| 588 | * -EINVAL is returned in case of invalid parameters, and -ENXIO is returned if |
| 589 | * the device with this elemental address is not found. |
| 590 | */ |
| 591 | |
| 592 | extern int slim_get_logical_addr(struct slim_device *sb, const u8 *e_addr, |
| 593 | u8 e_len, u8 *laddr); |
| 594 | |
| 595 | |
| 596 | /* Message APIs Unicast message APIs used by slimbus slave drivers */ |
| 597 | |
| 598 | /* |
| 599 | * Message API access routines. |
| 600 | * @sb: client handle requesting elemental message reads, writes. |
| 601 | * @msg: Input structure for start-offset, number of bytes to read. |
| 602 | * @rbuf: data buffer to be filled with values read. |
| 603 | * @len: data buffer size |
| 604 | * @wbuf: data buffer containing value/information to be written |
| 605 | * context: can sleep |
| 606 | * Returns: |
| 607 | * -EINVAL: Invalid parameters |
| 608 | * -ETIMEDOUT: If controller could not complete the request. This may happen if |
| 609 | * the bus lines are not clocked, controller is not powered-on, slave with |
| 610 | * given address is not enumerated/responding. |
| 611 | */ |
| 612 | extern int slim_request_val_element(struct slim_device *sb, |
| 613 | struct slim_ele_access *msg, u8 *buf, |
| 614 | u8 len); |
| 615 | extern int slim_request_inf_element(struct slim_device *sb, |
| 616 | struct slim_ele_access *msg, u8 *buf, |
| 617 | u8 len); |
| 618 | extern int slim_change_val_element(struct slim_device *sb, |
| 619 | struct slim_ele_access *msg, |
| 620 | const u8 *buf, u8 len); |
| 621 | extern int slim_clear_inf_element(struct slim_device *sb, |
| 622 | struct slim_ele_access *msg, u8 *buf, |
| 623 | u8 len); |
| 624 | extern int slim_request_change_val_element(struct slim_device *sb, |
| 625 | struct slim_ele_access *msg, u8 *rbuf, |
| 626 | const u8 *wbuf, u8 len); |
| 627 | extern int slim_request_clear_inf_element(struct slim_device *sb, |
| 628 | struct slim_ele_access *msg, u8 *rbuf, |
| 629 | const u8 *wbuf, u8 len); |
| 630 | |
| 631 | /* |
| 632 | * Broadcast message API: |
| 633 | * call this API directly with sbdev = NULL. |
| 634 | * For broadcast reads, make sure that buffers are big-enough to incorporate |
| 635 | * replies from all logical addresses. |
| 636 | * All controllers may not support broadcast |
| 637 | */ |
| 638 | extern int slim_xfer_msg(struct slim_controller *ctrl, |
| 639 | struct slim_device *sbdev, struct slim_ele_access *msg, |
| 640 | u8 mc, u8 *rbuf, const u8 *wbuf, u8 len); |
| 641 | /* end of message apis */ |
| 642 | |
| 643 | /* Port management for manager device APIs */ |
| 644 | |
| 645 | /* |
| 646 | * slim_alloc_mgrports: Allocate port on manager side. |
| 647 | * @sb: device/client handle. |
| 648 | * @req: Port request type. |
| 649 | * @nports: Number of ports requested |
| 650 | * @rh: output buffer to store the port handles |
| 651 | * @hsz: size of buffer storing handles |
| 652 | * context: can sleep |
| 653 | * This port will be typically used by SW. e.g. client driver wants to receive |
| 654 | * some data from audio codec HW using a data channel. |
| 655 | * Port allocated using this API will be used to receive the data. |
| 656 | * If half-duplex ports are requested, two adjacent ports are allocated for |
| 657 | * 1 half-duplex port. So the handle-buffer size should be twice the number |
| 658 | * of half-duplex ports to be allocated. |
| 659 | * -EDQUOT is returned if all ports are in use. |
| 660 | */ |
| 661 | extern int slim_alloc_mgrports(struct slim_device *sb, enum slim_port_req req, |
| 662 | int nports, u32 *rh, int hsz); |
| 663 | |
| 664 | /* Deallocate the port(s) allocated using the API above */ |
| 665 | extern int slim_dealloc_mgrports(struct slim_device *sb, u32 *hdl, int hsz); |
| 666 | |
| 667 | /* |
| 668 | * slim_port_xfer: Schedule buffer to be transferred/received using port-handle. |
| 669 | * @sb: client handle |
| 670 | * @ph: port-handle |
| 671 | * @iobuf: buffer to be transferred or populated |
| 672 | * @len: buffer size. |
| 673 | * @comp: completion signal to indicate transfer done or error. |
| 674 | * context: can sleep |
| 675 | * Returns number of bytes transferred/received if used synchronously. |
| 676 | * Will return 0 if used asynchronously. |
| 677 | * Client will call slim_port_get_xfer_status to get error and/or number of |
| 678 | * bytes transferred if used asynchronously. |
| 679 | */ |
| 680 | extern int slim_port_xfer(struct slim_device *sb, u32 ph, u8 *iobuf, u32 len, |
| 681 | struct completion *comp); |
| 682 | |
| 683 | /* |
| 684 | * slim_port_get_xfer_status: Poll for port transfers, or get transfer status |
| 685 | * after completion is done. |
| 686 | * @sb: client handle |
| 687 | * @ph: port-handle |
| 688 | * @done_buf: return pointer (iobuf from slim_port_xfer) which is processed. |
| 689 | * @done_len: Number of bytes transferred. |
| 690 | * This can be called when port_xfer complition is signalled. |
| 691 | * The API will return port transfer error (underflow/overflow/disconnect) |
| 692 | * and/or done_len will reflect number of bytes transferred. Note that |
| 693 | * done_len may be valid even if port error (overflow/underflow) has happened. |
| 694 | * e.g. If the transfer was scheduled with a few bytes to be transferred and |
| 695 | * client has not supplied more data to be transferred, done_len will indicate |
| 696 | * number of bytes transferred with underflow error. To avoid frequent underflow |
| 697 | * errors, multiple transfers can be queued (e.g. ping-pong buffers) so that |
| 698 | * channel has data to be transferred even if client is not ready to transfer |
| 699 | * data all the time. done_buf will indicate address of the last buffer |
| 700 | * processed from the multiple transfers. |
| 701 | */ |
| 702 | extern enum slim_port_err slim_port_get_xfer_status(struct slim_device *sb, |
| 703 | u32 ph, u8 **done_buf, u32 *done_len); |
| 704 | |
| 705 | /* |
| 706 | * slim_connect_ports: Connect port(s) to channel. |
| 707 | * @sb: client handle |
| 708 | * @srch: source handles to be connected to this channel |
| 709 | * @nrsc: number of source ports |
| 710 | * @sinkh: sink handle to be connected to this channel |
| 711 | * @chanh: Channel with which the ports need to be associated with. |
| 712 | * Per slimbus specification, a channel may have multiple source-ports and 1 |
| 713 | * sink port.Channel specified in chanh needs to be allocated first. |
| 714 | */ |
| 715 | extern int slim_connect_ports(struct slim_device *sb, u32 *srch, int nsrc, |
| 716 | u32 sinkh, u16 chanh); |
| 717 | |
| 718 | /* |
| 719 | * slim_disconnect_ports: Disconnect port(s) from channel |
| 720 | * @sb: client handle |
| 721 | * @ph: ports to be disconnected |
| 722 | * @nph: number of ports. |
| 723 | * Disconnects ports from a channel. |
| 724 | */ |
| 725 | extern int slim_disconnect_ports(struct slim_device *sb, u32 *ph, int nph); |
| 726 | |
| 727 | /* |
| 728 | * slim_get_slaveport: Get slave port handle |
| 729 | * @la: slave device logical address. |
| 730 | * @idx: port index at slave |
| 731 | * @rh: return handle |
| 732 | * @flw: Flow type (source or destination) |
| 733 | * This API only returns a slave port's representation as expected by slimbus |
| 734 | * driver. This port is not managed by the slimbus driver. Caller is expected |
| 735 | * to have visibility of this port since it's a device-port. |
| 736 | */ |
| 737 | extern int slim_get_slaveport(u8 la, int idx, u32 *rh, enum slim_port_flow flw); |
| 738 | |
| 739 | |
| 740 | /* Channel functions. */ |
| 741 | |
| 742 | /* |
| 743 | * slim_alloc_ch: Allocate a slimbus channel and return its handle. |
| 744 | * @sb: client handle. |
| 745 | * @chanh: return channel handle |
| 746 | * Slimbus channels are limited to 256 per specification. LSB of the handle |
| 747 | * indicates channel number and MSB of the handle is used by the slimbus |
| 748 | * framework. -EXFULL is returned if all channels are in use. |
| 749 | * Although slimbus specification supports 256 channels, a controller may not |
| 750 | * support that many channels. |
| 751 | */ |
| 752 | extern int slim_alloc_ch(struct slim_device *sb, u16 *chanh); |
| 753 | |
| 754 | /* |
| 755 | * slim_dealloc_ch: Deallocate channel allocated using the API above |
| 756 | * -EISCONN is returned if the channel is tried to be deallocated without |
| 757 | * being removed first. |
| 758 | */ |
| 759 | extern int slim_dealloc_ch(struct slim_device *sb, u16 chanh); |
| 760 | |
| 761 | |
| 762 | /* |
| 763 | * slim_define_ch: Define a channel.This API defines channel parameters for a |
| 764 | * given channel. |
| 765 | * @sb: client handle. |
| 766 | * @prop: slim_ch structure with channel parameters desired to be used. |
| 767 | * @chanh: list of channels to be defined. |
| 768 | * @nchan: number of channels in a group (1 if grp is false) |
| 769 | * @grp: Are the channels grouped |
| 770 | * @grph: return group handle if grouping of channels is desired. |
| 771 | * Channels can be grouped if multiple channels use same parameters |
| 772 | * (e.g. 5.1 audio has 6 channels with same parameters. They will all be |
| 773 | * grouped and given 1 handle for simplicity and avoid repeatedly calling |
| 774 | * the API) |
| 775 | * -EISCONN is returned if the channel is already connected. -EBUSY is |
| 776 | * returned if the channel is already allocated to some other client. |
| 777 | */ |
| 778 | extern int slim_define_ch(struct slim_device *sb, struct slim_ch *prop, |
| 779 | u16 *chanh, u8 nchan, bool grp, u16 *grph); |
| 780 | |
| 781 | /* |
| 782 | * slim_control_ch: Channel control API. |
| 783 | * @sb: client handle |
| 784 | * @grpchanh: group or channel handle to be controlled |
| 785 | * @chctrl: Control command (activate/suspend/remove) |
| 786 | * @commit: flag to indicate whether the control should take effect right-away. |
| 787 | * This API activates, removes or suspends a channel (or group of channels) |
| 788 | * grpchanh indicates the channel or group handle (returned by the define_ch |
| 789 | * API). Reconfiguration may be time-consuming since it can change all other |
| 790 | * active channel allocations on the bus, change in clock gear used by the |
| 791 | * slimbus, and change in the control space width used for messaging. |
| 792 | * commit makes sure that multiple channels can be activated/deactivated before |
| 793 | * reconfiguration is started. |
| 794 | * -EXFULL is returned if there is no space in TDM to reserve the bandwidth. |
| 795 | * -EISCONN/-ENOTCONN is returned if the channel is already connected or not |
| 796 | * yet defined. |
| 797 | */ |
| 798 | extern int slim_control_ch(struct slim_device *sb, u16 grpchanh, |
| 799 | enum slim_ch_control chctrl, bool commit); |
| 800 | |
| 801 | /* |
| 802 | * slim_get_ch_state: Channel state. |
| 803 | * This API returns the channel's state (active, suspended, inactive etc) |
| 804 | */ |
| 805 | extern enum slim_ch_state slim_get_ch_state(struct slim_device *sb, |
| 806 | u16 chanh); |
| 807 | |
| 808 | /* |
| 809 | * slim_reservemsg_bw: Request to reserve bandwidth for messages. |
| 810 | * @sb: client handle |
| 811 | * @bw_bps: message bandwidth in bits per second to be requested |
| 812 | * @commit: indicates whether the reconfiguration needs to be acted upon. |
| 813 | * This API call can be grouped with slim_control_ch API call with only one of |
| 814 | * the APIs specifying the commit flag to avoid reconfiguration being called too |
| 815 | * frequently. -EXFULL is returned if there is no space in TDM to reserve the |
| 816 | * bandwidth. -EBUSY is returned if reconfiguration is requested, but a request |
| 817 | * is already in progress. |
| 818 | */ |
| 819 | extern int slim_reservemsg_bw(struct slim_device *sb, u32 bw_bps, bool commit); |
| 820 | |
| 821 | /* |
| 822 | * slim_reconfigure_now: Request reconfiguration now. |
| 823 | * @sb: client handle |
| 824 | * This API does what commit flag in other scheduling APIs do. |
| 825 | * -EXFULL is returned if there is no space in TDM to reserve the |
| 826 | * bandwidth. -EBUSY is returned if reconfiguration request is already in |
| 827 | * progress. |
| 828 | */ |
| 829 | extern int slim_reconfigure_now(struct slim_device *sb); |
| 830 | |
| 831 | /* |
| 832 | * slim_driver_register: Client driver registration with slimbus |
| 833 | * @drv:Client driver to be associated with client-device. |
| 834 | * This API will register the client driver with the slimbus |
| 835 | * It is called from the driver's module-init function. |
| 836 | */ |
| 837 | extern int slim_driver_register(struct slim_driver *drv); |
| 838 | |
| 839 | /* |
| 840 | * slim_add_numbered_controller: Controller bring-up. |
| 841 | * @ctrl: Controller to be registered. |
| 842 | * A controller is registered with the framework using this API. ctrl->nr is the |
| 843 | * desired number with which slimbus framework registers the controller. |
| 844 | * Function will return -EBUSY if the number is in use. |
| 845 | */ |
| 846 | extern int slim_add_numbered_controller(struct slim_controller *ctrl); |
| 847 | |
| 848 | /* |
| 849 | * slim_del_controller: Controller tear-down. |
| 850 | * Controller added with the above API is teared down using this API. |
| 851 | */ |
| 852 | extern int slim_del_controller(struct slim_controller *ctrl); |
| 853 | |
| 854 | /* |
| 855 | * slim_add_device: Add a new device without register board info. |
| 856 | * @ctrl: Controller to which this device is to be added to. |
| 857 | * Called when device doesn't have an explicit client-driver to be probed, or |
| 858 | * the client-driver is a module installed dynamically. |
| 859 | */ |
| 860 | extern int slim_add_device(struct slim_controller *ctrl, |
| 861 | struct slim_device *sbdev); |
| 862 | |
| 863 | /* slim_remove_device: Remove the effect of slim_add_device() */ |
| 864 | extern void slim_remove_device(struct slim_device *sbdev); |
| 865 | |
| 866 | /* |
| 867 | * slim_assign_laddr: Assign logical address to a device enumerated. |
| 868 | * @ctrl: Controller with which device is enumerated. |
| 869 | * @e_addr: 6-byte elemental address of the device. |
| 870 | * @e_len: buffer length for e_addr |
| 871 | * @laddr: Return logical address. |
| 872 | * Called by controller in response to REPORT_PRESENT. Framework will assign |
| 873 | * a logical address to this enumeration address. |
| 874 | * Function returns -EXFULL to indicate that all logical addresses are already |
| 875 | * taken. |
| 876 | */ |
| 877 | extern int slim_assign_laddr(struct slim_controller *ctrl, const u8 *e_addr, |
| 878 | u8 e_len, u8 *laddr); |
| 879 | |
| 880 | /* |
| 881 | * slim_msg_response: Deliver Message response received from a device to the |
| 882 | * framework. |
| 883 | * @ctrl: Controller handle |
| 884 | * @reply: Reply received from the device |
| 885 | * @len: Length of the reply |
| 886 | * @tid: Transaction ID received with which framework can associate reply. |
| 887 | * Called by controller to inform framework about the response received. |
| 888 | * This helps in making the API asynchronous, and controller-driver doesn't need |
| 889 | * to manage 1 more table other than the one managed by framework mapping TID |
| 890 | * with buffers |
| 891 | */ |
| 892 | extern void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid, |
| 893 | u8 len); |
| 894 | |
| 895 | /* |
| 896 | * slim_busnum_to_ctrl: Map bus number to controller |
| 897 | * @busnum: Bus number |
| 898 | * Returns controller representing this bus number |
| 899 | */ |
| 900 | extern struct slim_controller *slim_busnum_to_ctrl(u32 busnum); |
| 901 | |
| 902 | /* |
| 903 | * slim_register_board_info: Board-initialization routine. |
| 904 | * @info: List of all devices on all controllers present on the board. |
| 905 | * @n: number of entries. |
| 906 | * API enumerates respective devices on corresponding controller. |
| 907 | * Called from board-init function. |
| 908 | */ |
| 909 | #ifdef CONFIG_SLIMBUS |
| 910 | extern int slim_register_board_info(struct slim_boardinfo const *info, |
| 911 | unsigned n); |
| 912 | #else |
| 913 | int slim_register_board_info(struct slim_boardinfo const *info, |
| 914 | unsigned n) |
| 915 | { |
| 916 | return 0; |
| 917 | } |
| 918 | #endif |
| 919 | |
| 920 | static inline void *slim_get_ctrldata(const struct slim_controller *dev) |
| 921 | { |
| 922 | return dev_get_drvdata(&dev->dev); |
| 923 | } |
| 924 | |
| 925 | static inline void slim_set_ctrldata(struct slim_controller *dev, void *data) |
| 926 | { |
| 927 | dev_set_drvdata(&dev->dev, data); |
| 928 | } |
| 929 | |
| 930 | static inline void *slim_get_devicedata(const struct slim_device *dev) |
| 931 | { |
| 932 | return dev_get_drvdata(&dev->dev); |
| 933 | } |
| 934 | |
| 935 | static inline void slim_set_clientdata(struct slim_device *dev, void *data) |
| 936 | { |
| 937 | dev_set_drvdata(&dev->dev, data); |
| 938 | } |
| 939 | #endif /* _LINUX_SLIMBUS_H */ |