History

bus: mhi: core: Add support for data transfer

Add support for transferring data between external modem and host processor using MHI protocol. This is based on the patch submitted by Sujeev Dias: https://lkml.org/lkml/2018/7/9/988

Manivannan Sadhasivam committed 6 years ago

Commit 189ff971 parent 1d3173a5 files · +979 −8Browse files

Showing the changes to include/linux (1 of 5 files). Show all

Unified · Split

include/linux/mhi.h+80−0
@@ -10,6 +10,7 @@ · 9 unmodified lines
1010 #include <linux/dma-direction.h>
1111 #include <linux/mutex.h>
1212 #include <linux/rwlock_types.h>
13+#include <linux/skbuff.h>
1314 #include <linux/slab.h>
1415 #include <linux/spinlock_types.h>
1516 #include <linux/wait.h>
@@ -336,6 +337,8 @@ struct mhi_controller_config { · 320 unmodified lines
336337 * @wake_toggle: CB function to assert and de-assert device wake (optional)
337338 * @runtime_get: CB function to controller runtime resume (required)
338339 * @runtimet_put: CB function to decrement pm usage (required)
340+ * @map_single: CB function to create TRE buffer
341+ * @unmap_single: CB function to destroy TRE buffer
339342 * @buffer_len: Bounce buffer length
340343 * @bounce_buf: Use of bounce buffer
341344 * @fbc_download: MHI host needs to do complete image transfer (optional)
@@ -403,6 +406,10 @@ struct mhi_controller { · 61 unmodified lines
403406 void (*wake_toggle)(struct mhi_controller *mhi_cntrl);
404407 int (*runtime_get)(struct mhi_controller *mhi_cntrl);
405408 void (*runtime_put)(struct mhi_controller *mhi_cntrl);
409+ int (*map_single)(struct mhi_controller *mhi_cntrl,
410+ struct mhi_buf_info *buf);
411+ void (*unmap_single)(struct mhi_controller *mhi_cntrl,
412+ struct mhi_buf_info *buf);
406413
407414 size_t buffer_len;
408415 bool bounce_buf;
@@ -583,4 +590,77 @@ int mhi_force_rddm_mode(struct mhi_controller *mhi_cntrl); · 174 unmodified lines
583590 */
584591 enum mhi_state mhi_get_mhi_state(struct mhi_controller *mhi_cntrl);
585592
593+/**
594+ * mhi_device_get - Disable device low power mode
595+ * @mhi_dev: Device associated with the channel
596+ */
597+void mhi_device_get(struct mhi_device *mhi_dev);
598+
599+/**
600+ * mhi_device_get_sync - Disable device low power mode. Synchronously
601+ * take the controller out of suspended state
602+ * @mhi_dev: Device associated with the channel
603+ */
604+int mhi_device_get_sync(struct mhi_device *mhi_dev);
605+
606+/**
607+ * mhi_device_put - Re-enable device low power mode
608+ * @mhi_dev: Device associated with the channel
609+ */
610+void mhi_device_put(struct mhi_device *mhi_dev);
611+
612+/**
613+ * mhi_prepare_for_transfer - Setup channel for data transfer
614+ * @mhi_dev: Device associated with the channels
615+ */
616+int mhi_prepare_for_transfer(struct mhi_device *mhi_dev);
617+
618+/**
619+ * mhi_unprepare_from_transfer - Unprepare the channels
620+ * @mhi_dev: Device associated with the channels
621+ */
622+void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev);
623+
624+/**
625+ * mhi_poll - Poll for any available data in DL direction
626+ * @mhi_dev: Device associated with the channels
627+ * @budget: # of events to process
628+ */
629+int mhi_poll(struct mhi_device *mhi_dev, u32 budget);
630+
631+/**
632+ * mhi_queue_dma - Send or receive DMA mapped buffers from client device
633+ * over MHI channel
634+ * @mhi_dev: Device associated with the channels
635+ * @dir: DMA direction for the channel
636+ * @mhi_buf: Buffer for holding the DMA mapped data
637+ * @len: Buffer length
638+ * @mflags: MHI transfer flags used for the transfer
639+ */
640+int mhi_queue_dma(struct mhi_device *mhi_dev, enum dma_data_direction dir,
641+ struct mhi_buf *mhi_buf, size_t len, enum mhi_flags mflags);
642+
643+/**
644+ * mhi_queue_buf - Send or receive raw buffers from client device over MHI
645+ * channel
646+ * @mhi_dev: Device associated with the channels
647+ * @dir: DMA direction for the channel
648+ * @buf: Buffer for holding the data
649+ * @len: Buffer length
650+ * @mflags: MHI transfer flags used for the transfer
651+ */
652+int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir,
653+ void *buf, size_t len, enum mhi_flags mflags);
654+
655+/**
656+ * mhi_queue_skb - Send or receive SKBs from client device over MHI channel
657+ * @mhi_dev: Device associated with the channels
658+ * @dir: DMA direction for the channel
659+ * @skb: Buffer for holding SKBs
660+ * @len: Buffer length
661+ * @mflags: MHI transfer flags used for the transfer
662+ */
663+int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir,
664+ struct sk_buff *skb, size_t len, enum mhi_flags mflags);
665+
586666 #endif /* _MHI_H_ */