Skip to content

Commit

Permalink
bus: mhi: core: Add support for processing events from client device
Browse files Browse the repository at this point in the history
This commit adds support for processing the MHI data and control
events from the client device. The client device can report various
events such as EE events, state change events by interrupting the
host through IRQ and adding events to the event rings allocated by
the host during initialization.

This is based on the patch submitted by Sujeev Dias:
https://lkml.org/lkml/2018/7/9/988

Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
[mani: splitted the data transfer patch and cleaned up for upstream]
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Jeffrey Hugo <jhugo@codeaurora.org>
Tested-by: Jeffrey Hugo <jhugo@codeaurora.org>
Link: https://lore.kernel.org/r/20200220095854.4804-11-manivannan.sadhasivam@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Mani-Sadhasivam authored and gregkh committed Mar 19, 2020
1 parent 6fdfdd2 commit 1d3173a
Show file tree
Hide file tree
Showing 4 changed files with 510 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/bus/mhi/core/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,18 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl,

mhi_event->data_type = event_cfg->data_type;

switch (mhi_event->data_type) {
case MHI_ER_DATA:
mhi_event->process_event = mhi_process_data_event_ring;
break;
case MHI_ER_CTRL:
mhi_event->process_event = mhi_process_ctrl_ev_ring;
break;
default:
dev_err(dev, "Event Ring type not supported\n");
goto error_ev_cfg;
}

mhi_event->hw_ring = event_cfg->hardware_event;
if (mhi_event->hw_ring)
mhi_cntrl->hw_ev_rings++;
Expand Down Expand Up @@ -772,6 +784,12 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,

mhi_event->mhi_cntrl = mhi_cntrl;
spin_lock_init(&mhi_event->lock);
if (mhi_event->data_type == MHI_ER_CTRL)
tasklet_init(&mhi_event->task, mhi_ctrl_ev_task,
(ulong)mhi_event);
else
tasklet_init(&mhi_event->task, mhi_ev_task,
(ulong)mhi_event);
}

mhi_chan = mhi_cntrl->mhi_chan;
Expand Down
10 changes: 10 additions & 0 deletions drivers/bus/mhi/core/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ struct mhi_buf_info {
dma_addr_t p_addr;
size_t len;
enum dma_data_direction dir;
bool used; /* Indicates whether the buffer is used or not */
bool pre_mapped; /* Already pre-mapped by client */
};

struct mhi_event {
Expand Down Expand Up @@ -637,6 +639,14 @@ static inline void mhi_free_coherent(struct mhi_controller *mhi_cntrl,
dma_free_coherent(mhi_cntrl->cntrl_dev, size, vaddr, dma_handle);
}

/* Event processing methods */
void mhi_ctrl_ev_task(unsigned long data);
void mhi_ev_task(unsigned long data);
int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl,
struct mhi_event *mhi_event, u32 event_quota);
int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
struct mhi_event *mhi_event, u32 event_quota);

/* ISR handlers */
irqreturn_t mhi_irq_handler(int irq_number, void *dev);
irqreturn_t mhi_intvec_threaded_handler(int irq_number, void *dev);
Expand Down
Loading

0 comments on commit 1d3173a

Please sign in to comment.