]> git.ipfire.org Git - thirdparty/linux.git/blob - include/linux/mhi.h
io_uring: reset -EBUSY error when io sq thread is waken up
[thirdparty/linux.git] / include / linux / mhi.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
4 *
5 */
6 #ifndef _MHI_H_
7 #define _MHI_H_
8
9 #include <linux/device.h>
10 #include <linux/dma-direction.h>
11 #include <linux/mutex.h>
12 #include <linux/rwlock_types.h>
13 #include <linux/skbuff.h>
14 #include <linux/slab.h>
15 #include <linux/spinlock_types.h>
16 #include <linux/wait.h>
17 #include <linux/workqueue.h>
18
19 struct mhi_chan;
20 struct mhi_event;
21 struct mhi_ctxt;
22 struct mhi_cmd;
23 struct mhi_buf_info;
24
25 /**
26 * enum mhi_callback - MHI callback
27 * @MHI_CB_IDLE: MHI entered idle state
28 * @MHI_CB_PENDING_DATA: New data available for client to process
29 * @MHI_CB_LPM_ENTER: MHI host entered low power mode
30 * @MHI_CB_LPM_EXIT: MHI host about to exit low power mode
31 * @MHI_CB_EE_RDDM: MHI device entered RDDM exec env
32 * @MHI_CB_EE_MISSION_MODE: MHI device entered Mission Mode exec env
33 * @MHI_CB_SYS_ERROR: MHI device entered error state (may recover)
34 * @MHI_CB_FATAL_ERROR: MHI device entered fatal error state
35 * @MHI_CB_BW_REQ: Received a bandwidth switch request from device
36 */
37 enum mhi_callback {
38 MHI_CB_IDLE,
39 MHI_CB_PENDING_DATA,
40 MHI_CB_LPM_ENTER,
41 MHI_CB_LPM_EXIT,
42 MHI_CB_EE_RDDM,
43 MHI_CB_EE_MISSION_MODE,
44 MHI_CB_SYS_ERROR,
45 MHI_CB_FATAL_ERROR,
46 MHI_CB_BW_REQ,
47 };
48
49 /**
50 * enum mhi_flags - Transfer flags
51 * @MHI_EOB: End of buffer for bulk transfer
52 * @MHI_EOT: End of transfer
53 * @MHI_CHAIN: Linked transfer
54 */
55 enum mhi_flags {
56 MHI_EOB,
57 MHI_EOT,
58 MHI_CHAIN,
59 };
60
61 /**
62 * enum mhi_device_type - Device types
63 * @MHI_DEVICE_XFER: Handles data transfer
64 * @MHI_DEVICE_CONTROLLER: Control device
65 */
66 enum mhi_device_type {
67 MHI_DEVICE_XFER,
68 MHI_DEVICE_CONTROLLER,
69 };
70
71 /**
72 * enum mhi_ch_type - Channel types
73 * @MHI_CH_TYPE_INVALID: Invalid channel type
74 * @MHI_CH_TYPE_OUTBOUND: Outbound channel to the device
75 * @MHI_CH_TYPE_INBOUND: Inbound channel from the device
76 * @MHI_CH_TYPE_INBOUND_COALESCED: Coalesced channel for the device to combine
77 * multiple packets and send them as a single
78 * large packet to reduce CPU consumption
79 */
80 enum mhi_ch_type {
81 MHI_CH_TYPE_INVALID = 0,
82 MHI_CH_TYPE_OUTBOUND = DMA_TO_DEVICE,
83 MHI_CH_TYPE_INBOUND = DMA_FROM_DEVICE,
84 MHI_CH_TYPE_INBOUND_COALESCED = 3,
85 };
86
87 /**
88 * struct image_info - Firmware and RDDM table table
89 * @mhi_buf - Buffer for firmware and RDDM table
90 * @entries - # of entries in table
91 */
92 struct image_info {
93 struct mhi_buf *mhi_buf;
94 struct bhi_vec_entry *bhi_vec;
95 u32 entries;
96 };
97
98 /**
99 * struct mhi_link_info - BW requirement
100 * target_link_speed - Link speed as defined by TLS bits in LinkControl reg
101 * target_link_width - Link width as defined by NLW bits in LinkStatus reg
102 */
103 struct mhi_link_info {
104 unsigned int target_link_speed;
105 unsigned int target_link_width;
106 };
107
108 /**
109 * enum mhi_ee_type - Execution environment types
110 * @MHI_EE_PBL: Primary Bootloader
111 * @MHI_EE_SBL: Secondary Bootloader
112 * @MHI_EE_AMSS: Modem, aka the primary runtime EE
113 * @MHI_EE_RDDM: Ram dump download mode
114 * @MHI_EE_WFW: WLAN firmware mode
115 * @MHI_EE_PTHRU: Passthrough
116 * @MHI_EE_EDL: Embedded downloader
117 */
118 enum mhi_ee_type {
119 MHI_EE_PBL,
120 MHI_EE_SBL,
121 MHI_EE_AMSS,
122 MHI_EE_RDDM,
123 MHI_EE_WFW,
124 MHI_EE_PTHRU,
125 MHI_EE_EDL,
126 MHI_EE_MAX_SUPPORTED = MHI_EE_EDL,
127 MHI_EE_DISABLE_TRANSITION, /* local EE, not related to mhi spec */
128 MHI_EE_NOT_SUPPORTED,
129 MHI_EE_MAX,
130 };
131
132 /**
133 * enum mhi_state - MHI states
134 * @MHI_STATE_RESET: Reset state
135 * @MHI_STATE_READY: Ready state
136 * @MHI_STATE_M0: M0 state
137 * @MHI_STATE_M1: M1 state
138 * @MHI_STATE_M2: M2 state
139 * @MHI_STATE_M3: M3 state
140 * @MHI_STATE_M3_FAST: M3 Fast state
141 * @MHI_STATE_BHI: BHI state
142 * @MHI_STATE_SYS_ERR: System Error state
143 */
144 enum mhi_state {
145 MHI_STATE_RESET = 0x0,
146 MHI_STATE_READY = 0x1,
147 MHI_STATE_M0 = 0x2,
148 MHI_STATE_M1 = 0x3,
149 MHI_STATE_M2 = 0x4,
150 MHI_STATE_M3 = 0x5,
151 MHI_STATE_M3_FAST = 0x6,
152 MHI_STATE_BHI = 0x7,
153 MHI_STATE_SYS_ERR = 0xFF,
154 MHI_STATE_MAX,
155 };
156
157 /**
158 * enum mhi_ch_ee_mask - Execution environment mask for channel
159 * @MHI_CH_EE_PBL: Allow channel to be used in PBL EE
160 * @MHI_CH_EE_SBL: Allow channel to be used in SBL EE
161 * @MHI_CH_EE_AMSS: Allow channel to be used in AMSS EE
162 * @MHI_CH_EE_RDDM: Allow channel to be used in RDDM EE
163 * @MHI_CH_EE_PTHRU: Allow channel to be used in PTHRU EE
164 * @MHI_CH_EE_WFW: Allow channel to be used in WFW EE
165 * @MHI_CH_EE_EDL: Allow channel to be used in EDL EE
166 */
167 enum mhi_ch_ee_mask {
168 MHI_CH_EE_PBL = BIT(MHI_EE_PBL),
169 MHI_CH_EE_SBL = BIT(MHI_EE_SBL),
170 MHI_CH_EE_AMSS = BIT(MHI_EE_AMSS),
171 MHI_CH_EE_RDDM = BIT(MHI_EE_RDDM),
172 MHI_CH_EE_PTHRU = BIT(MHI_EE_PTHRU),
173 MHI_CH_EE_WFW = BIT(MHI_EE_WFW),
174 MHI_CH_EE_EDL = BIT(MHI_EE_EDL),
175 };
176
177 /**
178 * enum mhi_er_data_type - Event ring data types
179 * @MHI_ER_DATA: Only client data over this ring
180 * @MHI_ER_CTRL: MHI control data and client data
181 */
182 enum mhi_er_data_type {
183 MHI_ER_DATA,
184 MHI_ER_CTRL,
185 };
186
187 /**
188 * enum mhi_db_brst_mode - Doorbell mode
189 * @MHI_DB_BRST_DISABLE: Burst mode disable
190 * @MHI_DB_BRST_ENABLE: Burst mode enable
191 */
192 enum mhi_db_brst_mode {
193 MHI_DB_BRST_DISABLE = 0x2,
194 MHI_DB_BRST_ENABLE = 0x3,
195 };
196
197 /**
198 * struct mhi_channel_config - Channel configuration structure for controller
199 * @name: The name of this channel
200 * @num: The number assigned to this channel
201 * @num_elements: The number of elements that can be queued to this channel
202 * @local_elements: The local ring length of the channel
203 * @event_ring: The event rung index that services this channel
204 * @dir: Direction that data may flow on this channel
205 * @type: Channel type
206 * @ee_mask: Execution Environment mask for this channel
207 * @pollcfg: Polling configuration for burst mode. 0 is default. milliseconds
208 for UL channels, multiple of 8 ring elements for DL channels
209 * @doorbell: Doorbell mode
210 * @lpm_notify: The channel master requires low power mode notifications
211 * @offload_channel: The client manages the channel completely
212 * @doorbell_mode_switch: Channel switches to doorbell mode on M0 transition
213 * @auto_queue: Framework will automatically queue buffers for DL traffic
214 * @auto_start: Automatically start (open) this channel
215 * @wake-capable: Channel capable of waking up the system
216 */
217 struct mhi_channel_config {
218 char *name;
219 u32 num;
220 u32 num_elements;
221 u32 local_elements;
222 u32 event_ring;
223 enum dma_data_direction dir;
224 enum mhi_ch_type type;
225 u32 ee_mask;
226 u32 pollcfg;
227 enum mhi_db_brst_mode doorbell;
228 bool lpm_notify;
229 bool offload_channel;
230 bool doorbell_mode_switch;
231 bool auto_queue;
232 bool auto_start;
233 bool wake_capable;
234 };
235
236 /**
237 * struct mhi_event_config - Event ring configuration structure for controller
238 * @num_elements: The number of elements that can be queued to this ring
239 * @irq_moderation_ms: Delay irq for additional events to be aggregated
240 * @irq: IRQ associated with this ring
241 * @channel: Dedicated channel number. U32_MAX indicates a non-dedicated ring
242 * @priority: Priority of this ring. Use 1 for now
243 * @mode: Doorbell mode
244 * @data_type: Type of data this ring will process
245 * @hardware_event: This ring is associated with hardware channels
246 * @client_managed: This ring is client managed
247 * @offload_channel: This ring is associated with an offloaded channel
248 */
249 struct mhi_event_config {
250 u32 num_elements;
251 u32 irq_moderation_ms;
252 u32 irq;
253 u32 channel;
254 u32 priority;
255 enum mhi_db_brst_mode mode;
256 enum mhi_er_data_type data_type;
257 bool hardware_event;
258 bool client_managed;
259 bool offload_channel;
260 };
261
262 /**
263 * struct mhi_controller_config - Root MHI controller configuration
264 * @max_channels: Maximum number of channels supported
265 * @timeout_ms: Timeout value for operations. 0 means use default
266 * @buf_len: Size of automatically allocated buffers. 0 means use default
267 * @num_channels: Number of channels defined in @ch_cfg
268 * @ch_cfg: Array of defined channels
269 * @num_events: Number of event rings defined in @event_cfg
270 * @event_cfg: Array of defined event rings
271 * @use_bounce_buf: Use a bounce buffer pool due to limited DDR access
272 * @m2_no_db: Host is not allowed to ring DB in M2 state
273 */
274 struct mhi_controller_config {
275 u32 max_channels;
276 u32 timeout_ms;
277 u32 buf_len;
278 u32 num_channels;
279 struct mhi_channel_config *ch_cfg;
280 u32 num_events;
281 struct mhi_event_config *event_cfg;
282 bool use_bounce_buf;
283 bool m2_no_db;
284 };
285
286 /**
287 * struct mhi_controller - Master MHI controller structure
288 * @cntrl_dev: Pointer to the struct device of physical bus acting as the MHI
289 * controller (required)
290 * @mhi_dev: MHI device instance for the controller
291 * @regs: Base address of MHI MMIO register space (required)
292 * @bhi: Points to base of MHI BHI register space
293 * @bhie: Points to base of MHI BHIe register space
294 * @wake_db: MHI WAKE doorbell register address
295 * @iova_start: IOMMU starting address for data (required)
296 * @iova_stop: IOMMU stop address for data (required)
297 * @fw_image: Firmware image name for normal booting (required)
298 * @edl_image: Firmware image name for emergency download mode (optional)
299 * @rddm_size: RAM dump size that host should allocate for debugging purpose
300 * @sbl_size: SBL image size downloaded through BHIe (optional)
301 * @seg_len: BHIe vector size (optional)
302 * @fbc_image: Points to firmware image buffer
303 * @rddm_image: Points to RAM dump buffer
304 * @mhi_chan: Points to the channel configuration table
305 * @lpm_chans: List of channels that require LPM notifications
306 * @irq: base irq # to request (required)
307 * @max_chan: Maximum number of channels the controller supports
308 * @total_ev_rings: Total # of event rings allocated
309 * @hw_ev_rings: Number of hardware event rings
310 * @sw_ev_rings: Number of software event rings
311 * @nr_irqs_req: Number of IRQs required to operate (optional)
312 * @nr_irqs: Number of IRQ allocated by bus master (required)
313 * @family_number: MHI controller family number
314 * @device_number: MHI controller device number
315 * @major_version: MHI controller major revision number
316 * @minor_version: MHI controller minor revision number
317 * @mhi_event: MHI event ring configurations table
318 * @mhi_cmd: MHI command ring configurations table
319 * @mhi_ctxt: MHI device context, shared memory between host and device
320 * @pm_mutex: Mutex for suspend/resume operation
321 * @pm_lock: Lock for protecting MHI power management state
322 * @timeout_ms: Timeout in ms for state transitions
323 * @pm_state: MHI power management state
324 * @db_access: DB access states
325 * @ee: MHI device execution environment
326 * @dev_state: MHI device state
327 * @dev_wake: Device wakeup count
328 * @pending_pkts: Pending packets for the controller
329 * @transition_list: List of MHI state transitions
330 * @transition_lock: Lock for protecting MHI state transition list
331 * @wlock: Lock for protecting device wakeup
332 * @mhi_link_info: Device bandwidth info
333 * @st_worker: State transition worker
334 * @fw_worker: Firmware download worker
335 * @syserr_worker: System error worker
336 * @state_event: State change event
337 * @status_cb: CB function to notify power states of the device (required)
338 * @link_status: CB function to query link status of the device (required)
339 * @wake_get: CB function to assert device wake (optional)
340 * @wake_put: CB function to de-assert device wake (optional)
341 * @wake_toggle: CB function to assert and de-assert device wake (optional)
342 * @runtime_get: CB function to controller runtime resume (required)
343 * @runtimet_put: CB function to decrement pm usage (required)
344 * @map_single: CB function to create TRE buffer
345 * @unmap_single: CB function to destroy TRE buffer
346 * @buffer_len: Bounce buffer length
347 * @bounce_buf: Use of bounce buffer
348 * @fbc_download: MHI host needs to do complete image transfer (optional)
349 * @pre_init: MHI host needs to do pre-initialization before power up
350 * @wake_set: Device wakeup set flag
351 *
352 * Fields marked as (required) need to be populated by the controller driver
353 * before calling mhi_register_controller(). For the fields marked as (optional)
354 * they can be populated depending on the usecase.
355 *
356 * The following fields are present for the purpose of implementing any device
357 * specific quirks or customizations for specific MHI revisions used in device
358 * by the controller drivers. The MHI stack will just populate these fields
359 * during mhi_register_controller():
360 * family_number
361 * device_number
362 * major_version
363 * minor_version
364 */
365 struct mhi_controller {
366 struct device *cntrl_dev;
367 struct mhi_device *mhi_dev;
368 void __iomem *regs;
369 void __iomem *bhi;
370 void __iomem *bhie;
371 void __iomem *wake_db;
372
373 dma_addr_t iova_start;
374 dma_addr_t iova_stop;
375 const char *fw_image;
376 const char *edl_image;
377 size_t rddm_size;
378 size_t sbl_size;
379 size_t seg_len;
380 struct image_info *fbc_image;
381 struct image_info *rddm_image;
382 struct mhi_chan *mhi_chan;
383 struct list_head lpm_chans;
384 int *irq;
385 u32 max_chan;
386 u32 total_ev_rings;
387 u32 hw_ev_rings;
388 u32 sw_ev_rings;
389 u32 nr_irqs_req;
390 u32 nr_irqs;
391 u32 family_number;
392 u32 device_number;
393 u32 major_version;
394 u32 minor_version;
395
396 struct mhi_event *mhi_event;
397 struct mhi_cmd *mhi_cmd;
398 struct mhi_ctxt *mhi_ctxt;
399
400 struct mutex pm_mutex;
401 rwlock_t pm_lock;
402 u32 timeout_ms;
403 u32 pm_state;
404 u32 db_access;
405 enum mhi_ee_type ee;
406 enum mhi_state dev_state;
407 atomic_t dev_wake;
408 atomic_t pending_pkts;
409 struct list_head transition_list;
410 spinlock_t transition_lock;
411 spinlock_t wlock;
412 struct mhi_link_info mhi_link_info;
413 struct work_struct st_worker;
414 struct work_struct fw_worker;
415 struct work_struct syserr_worker;
416 wait_queue_head_t state_event;
417
418 void (*status_cb)(struct mhi_controller *mhi_cntrl,
419 enum mhi_callback cb);
420 int (*link_status)(struct mhi_controller *mhi_cntrl);
421 void (*wake_get)(struct mhi_controller *mhi_cntrl, bool override);
422 void (*wake_put)(struct mhi_controller *mhi_cntrl, bool override);
423 void (*wake_toggle)(struct mhi_controller *mhi_cntrl);
424 int (*runtime_get)(struct mhi_controller *mhi_cntrl);
425 void (*runtime_put)(struct mhi_controller *mhi_cntrl);
426 int (*map_single)(struct mhi_controller *mhi_cntrl,
427 struct mhi_buf_info *buf);
428 void (*unmap_single)(struct mhi_controller *mhi_cntrl,
429 struct mhi_buf_info *buf);
430
431 size_t buffer_len;
432 bool bounce_buf;
433 bool fbc_download;
434 bool pre_init;
435 bool wake_set;
436 };
437
438 /**
439 * struct mhi_device - Structure representing a MHI device which binds
440 * to channels
441 * @id: Pointer to MHI device ID struct
442 * @chan_name: Name of the channel to which the device binds
443 * @mhi_cntrl: Controller the device belongs to
444 * @ul_chan: UL channel for the device
445 * @dl_chan: DL channel for the device
446 * @dev: Driver model device node for the MHI device
447 * @dev_type: MHI device type
448 * @ul_chan_id: MHI channel id for UL transfer
449 * @dl_chan_id: MHI channel id for DL transfer
450 * @dev_wake: Device wakeup counter
451 */
452 struct mhi_device {
453 const struct mhi_device_id *id;
454 const char *chan_name;
455 struct mhi_controller *mhi_cntrl;
456 struct mhi_chan *ul_chan;
457 struct mhi_chan *dl_chan;
458 struct device dev;
459 enum mhi_device_type dev_type;
460 int ul_chan_id;
461 int dl_chan_id;
462 u32 dev_wake;
463 };
464
465 /**
466 * struct mhi_result - Completed buffer information
467 * @buf_addr: Address of data buffer
468 * @bytes_xferd: # of bytes transferred
469 * @dir: Channel direction
470 * @transaction_status: Status of last transaction
471 */
472 struct mhi_result {
473 void *buf_addr;
474 size_t bytes_xferd;
475 enum dma_data_direction dir;
476 int transaction_status;
477 };
478
479 /**
480 * struct mhi_buf - MHI Buffer description
481 * @buf: Virtual address of the buffer
482 * @name: Buffer label. For offload channel, configurations name must be:
483 * ECA - Event context array data
484 * CCA - Channel context array data
485 * @dma_addr: IOMMU address of the buffer
486 * @len: # of bytes
487 */
488 struct mhi_buf {
489 void *buf;
490 const char *name;
491 dma_addr_t dma_addr;
492 size_t len;
493 };
494
495 /**
496 * struct mhi_driver - Structure representing a MHI client driver
497 * @probe: CB function for client driver probe function
498 * @remove: CB function for client driver remove function
499 * @ul_xfer_cb: CB function for UL data transfer
500 * @dl_xfer_cb: CB function for DL data transfer
501 * @status_cb: CB functions for asynchronous status
502 * @driver: Device driver model driver
503 */
504 struct mhi_driver {
505 const struct mhi_device_id *id_table;
506 int (*probe)(struct mhi_device *mhi_dev,
507 const struct mhi_device_id *id);
508 void (*remove)(struct mhi_device *mhi_dev);
509 void (*ul_xfer_cb)(struct mhi_device *mhi_dev,
510 struct mhi_result *result);
511 void (*dl_xfer_cb)(struct mhi_device *mhi_dev,
512 struct mhi_result *result);
513 void (*status_cb)(struct mhi_device *mhi_dev, enum mhi_callback mhi_cb);
514 struct device_driver driver;
515 };
516
517 #define to_mhi_driver(drv) container_of(drv, struct mhi_driver, driver)
518 #define to_mhi_device(dev) container_of(dev, struct mhi_device, dev)
519
520 /**
521 * mhi_register_controller - Register MHI controller
522 * @mhi_cntrl: MHI controller to register
523 * @config: Configuration to use for the controller
524 */
525 int mhi_register_controller(struct mhi_controller *mhi_cntrl,
526 struct mhi_controller_config *config);
527
528 /**
529 * mhi_unregister_controller - Unregister MHI controller
530 * @mhi_cntrl: MHI controller to unregister
531 */
532 void mhi_unregister_controller(struct mhi_controller *mhi_cntrl);
533
534 /*
535 * module_mhi_driver() - Helper macro for drivers that don't do
536 * anything special other than using default mhi_driver_register() and
537 * mhi_driver_unregister(). This eliminates a lot of boilerplate.
538 * Each module may only use this macro once.
539 */
540 #define module_mhi_driver(mhi_drv) \
541 module_driver(mhi_drv, mhi_driver_register, \
542 mhi_driver_unregister)
543
544 /*
545 * Macro to avoid include chaining to get THIS_MODULE
546 */
547 #define mhi_driver_register(mhi_drv) \
548 __mhi_driver_register(mhi_drv, THIS_MODULE)
549
550 /**
551 * __mhi_driver_register - Register driver with MHI framework
552 * @mhi_drv: Driver associated with the device
553 * @owner: The module owner
554 */
555 int __mhi_driver_register(struct mhi_driver *mhi_drv, struct module *owner);
556
557 /**
558 * mhi_driver_unregister - Unregister a driver for mhi_devices
559 * @mhi_drv: Driver associated with the device
560 */
561 void mhi_driver_unregister(struct mhi_driver *mhi_drv);
562
563 /**
564 * mhi_set_mhi_state - Set MHI device state
565 * @mhi_cntrl: MHI controller
566 * @state: State to set
567 */
568 void mhi_set_mhi_state(struct mhi_controller *mhi_cntrl,
569 enum mhi_state state);
570
571 /**
572 * mhi_prepare_for_power_up - Do pre-initialization before power up.
573 * This is optional, call this before power up if
574 * the controller does not want bus framework to
575 * automatically free any allocated memory during
576 * shutdown process.
577 * @mhi_cntrl: MHI controller
578 */
579 int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl);
580
581 /**
582 * mhi_async_power_up - Start MHI power up sequence
583 * @mhi_cntrl: MHI controller
584 */
585 int mhi_async_power_up(struct mhi_controller *mhi_cntrl);
586
587 /**
588 * mhi_sync_power_up - Start MHI power up sequence and wait till the device
589 * device enters valid EE state
590 * @mhi_cntrl: MHI controller
591 */
592 int mhi_sync_power_up(struct mhi_controller *mhi_cntrl);
593
594 /**
595 * mhi_power_down - Start MHI power down sequence
596 * @mhi_cntrl: MHI controller
597 * @graceful: Link is still accessible, so do a graceful shutdown process
598 */
599 void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful);
600
601 /**
602 * mhi_unprepare_after_power_down - Free any allocated memory after power down
603 * @mhi_cntrl: MHI controller
604 */
605 void mhi_unprepare_after_power_down(struct mhi_controller *mhi_cntrl);
606
607 /**
608 * mhi_download_rddm_img - Download ramdump image from device for
609 * debugging purpose.
610 * @mhi_cntrl: MHI controller
611 * @in_panic: Download rddm image during kernel panic
612 */
613 int mhi_download_rddm_img(struct mhi_controller *mhi_cntrl, bool in_panic);
614
615 /**
616 * mhi_force_rddm_mode - Force device into rddm mode
617 * @mhi_cntrl: MHI controller
618 */
619 int mhi_force_rddm_mode(struct mhi_controller *mhi_cntrl);
620
621 /**
622 * mhi_get_mhi_state - Get MHI state of the device
623 * @mhi_cntrl: MHI controller
624 */
625 enum mhi_state mhi_get_mhi_state(struct mhi_controller *mhi_cntrl);
626
627 /**
628 * mhi_device_get - Disable device low power mode
629 * @mhi_dev: Device associated with the channel
630 */
631 void mhi_device_get(struct mhi_device *mhi_dev);
632
633 /**
634 * mhi_device_get_sync - Disable device low power mode. Synchronously
635 * take the controller out of suspended state
636 * @mhi_dev: Device associated with the channel
637 */
638 int mhi_device_get_sync(struct mhi_device *mhi_dev);
639
640 /**
641 * mhi_device_put - Re-enable device low power mode
642 * @mhi_dev: Device associated with the channel
643 */
644 void mhi_device_put(struct mhi_device *mhi_dev);
645
646 /**
647 * mhi_prepare_for_transfer - Setup channel for data transfer
648 * @mhi_dev: Device associated with the channels
649 */
650 int mhi_prepare_for_transfer(struct mhi_device *mhi_dev);
651
652 /**
653 * mhi_unprepare_from_transfer - Unprepare the channels
654 * @mhi_dev: Device associated with the channels
655 */
656 void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev);
657
658 /**
659 * mhi_poll - Poll for any available data in DL direction
660 * @mhi_dev: Device associated with the channels
661 * @budget: # of events to process
662 */
663 int mhi_poll(struct mhi_device *mhi_dev, u32 budget);
664
665 /**
666 * mhi_queue_dma - Send or receive DMA mapped buffers from client device
667 * over MHI channel
668 * @mhi_dev: Device associated with the channels
669 * @dir: DMA direction for the channel
670 * @mhi_buf: Buffer for holding the DMA mapped data
671 * @len: Buffer length
672 * @mflags: MHI transfer flags used for the transfer
673 */
674 int mhi_queue_dma(struct mhi_device *mhi_dev, enum dma_data_direction dir,
675 struct mhi_buf *mhi_buf, size_t len, enum mhi_flags mflags);
676
677 /**
678 * mhi_queue_buf - Send or receive raw buffers from client device over MHI
679 * channel
680 * @mhi_dev: Device associated with the channels
681 * @dir: DMA direction for the channel
682 * @buf: Buffer for holding the data
683 * @len: Buffer length
684 * @mflags: MHI transfer flags used for the transfer
685 */
686 int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir,
687 void *buf, size_t len, enum mhi_flags mflags);
688
689 /**
690 * mhi_queue_skb - Send or receive SKBs from client device over MHI channel
691 * @mhi_dev: Device associated with the channels
692 * @dir: DMA direction for the channel
693 * @skb: Buffer for holding SKBs
694 * @len: Buffer length
695 * @mflags: MHI transfer flags used for the transfer
696 */
697 int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir,
698 struct sk_buff *skb, size_t len, enum mhi_flags mflags);
699
700 #endif /* _MHI_H_ */