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