diff mbox series

[v3,2/3] bus: mhi: host: Add a new API for getting channel doorbell address

Message ID 1713170945-44640-3-git-send-email-quic_qianyu@quicinc.com (mailing list archive)
State Superseded
Headers show
Series Add sysfs entry to EDL mode | expand

Commit Message

Qiang Yu April 15, 2024, 8:49 a.m. UTC
Some controllers may want to know the address of a certain doorbell. Hence
add a new API where we read CHDBOFF register to get the base address of
doorbell, so that the controller can calculate the address of the doorbell
it wants by adding additional offset.

Signed-off-by: Qiang Yu <quic_qianyu@quicinc.com>
---
 drivers/bus/mhi/host/main.c | 17 +++++++++++++++++
 include/linux/mhi.h         |  7 +++++++
 2 files changed, 24 insertions(+)

Comments

Manivannan Sadhasivam April 15, 2024, 12:02 p.m. UTC | #1
On Mon, Apr 15, 2024 at 04:49:04PM +0800, Qiang Yu wrote:
> Some controllers may want to know the address of a certain doorbell. Hence
> add a new API where we read CHDBOFF register to get the base address of
> doorbell, so that the controller can calculate the address of the doorbell
> it wants by adding additional offset.
> 
> Signed-off-by: Qiang Yu <quic_qianyu@quicinc.com>
> ---
>  drivers/bus/mhi/host/main.c | 17 +++++++++++++++++
>  include/linux/mhi.h         |  7 +++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c
> index 15d657a..947b5ec 100644
> --- a/drivers/bus/mhi/host/main.c
> +++ b/drivers/bus/mhi/host/main.c
> @@ -1691,3 +1691,20 @@ void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev)
>  	}
>  }
>  EXPORT_SYMBOL_GPL(mhi_unprepare_from_transfer);
> +
> +int mhi_get_channel_doorbell(struct mhi_controller *mhi_cntrl, u32 *chdb_offset)

s/mhi_get_channel_doorbell/mhi_get_channel_doorbell_offset

> +{
> +	struct device *dev = &mhi_cntrl->mhi_dev->dev;
> +	void __iomem *base = mhi_cntrl->regs;
> +	int ret;
> +
> +	/* Read channel db offset */

No need of this comment.

> +	ret = mhi_read_reg(mhi_cntrl, base, CHDBOFF, chdb_offset);
> +	if (ret) {
> +		dev_err(dev, "Unable to read CHDBOFF register\n");
> +		return -EIO;
> +	}
> +
> +	return 0;
> +}

Why can't you use this API in mhi_init_mmio()?

> +EXPORT_SYMBOL_GPL(mhi_get_channel_doorbell);
> diff --git a/include/linux/mhi.h b/include/linux/mhi.h
> index 8280545..1135142 100644
> --- a/include/linux/mhi.h
> +++ b/include/linux/mhi.h
> @@ -816,4 +816,11 @@ int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir,
>   */
>  bool mhi_queue_is_full(struct mhi_device *mhi_dev, enum dma_data_direction dir);
>  
> +/**
> + * mhi_get_channel_doorbell - read channel doorbell offset register to get

'Get the channel doorbell offset'

> + *                            channel doorbell address
> + * @mhi_cntrl: MHI controller
> + * @chdb_offset: channel doorbell address

s/channel doorbell address/Channel doorbell offset

- Mani
diff mbox series

Patch

diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c
index 15d657a..947b5ec 100644
--- a/drivers/bus/mhi/host/main.c
+++ b/drivers/bus/mhi/host/main.c
@@ -1691,3 +1691,20 @@  void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev)
 	}
 }
 EXPORT_SYMBOL_GPL(mhi_unprepare_from_transfer);
+
+int mhi_get_channel_doorbell(struct mhi_controller *mhi_cntrl, u32 *chdb_offset)
+{
+	struct device *dev = &mhi_cntrl->mhi_dev->dev;
+	void __iomem *base = mhi_cntrl->regs;
+	int ret;
+
+	/* Read channel db offset */
+	ret = mhi_read_reg(mhi_cntrl, base, CHDBOFF, chdb_offset);
+	if (ret) {
+		dev_err(dev, "Unable to read CHDBOFF register\n");
+		return -EIO;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(mhi_get_channel_doorbell);
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index 8280545..1135142 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -816,4 +816,11 @@  int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir,
  */
 bool mhi_queue_is_full(struct mhi_device *mhi_dev, enum dma_data_direction dir);
 
+/**
+ * mhi_get_channel_doorbell - read channel doorbell offset register to get
+ *                            channel doorbell address
+ * @mhi_cntrl: MHI controller
+ * @chdb_offset: channel doorbell address
+ */
+int mhi_get_channel_doorbell(struct mhi_controller *mhi_cntrl, u32 *chdb_offset);
 #endif /* _MHI_H_ */