diff mbox series

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

Message ID 1713868417-37856-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 23, 2024, 10:33 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/init.c |  6 ++----
 drivers/bus/mhi/host/main.c | 16 ++++++++++++++++
 include/linux/mhi.h         |  6 ++++++
 3 files changed, 24 insertions(+), 4 deletions(-)

Comments

Jeffrey Hugo April 23, 2024, 6:45 p.m. UTC | #1
On 4/23/2024 4:33 AM, 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>
> diff --git a/include/linux/mhi.h b/include/linux/mhi.h
> index d968e1a..cb3b676 100644
> --- a/include/linux/mhi.h
> +++ b/include/linux/mhi.h
> @@ -816,4 +816,10 @@ 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_offset - Get the channel doorbell offset
> + * @mhi_cntrl: MHI controller
> + * @chdb_offset: Channel doorbell offset
> + */
> +int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 *chdb_offset);

Should have a blank line here before the #endif just like how the file 
was before this change

>   #endif /* _MHI_H_ */

With the above
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Manivannan Sadhasivam April 25, 2024, 1:55 p.m. UTC | #2
On Tue, Apr 23, 2024 at 06:33:36PM +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>

One nitpick below. But I'll fix it.

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

> ---
>  drivers/bus/mhi/host/init.c |  6 ++----
>  drivers/bus/mhi/host/main.c | 16 ++++++++++++++++
>  include/linux/mhi.h         |  6 ++++++
>  3 files changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c
> index 7104c18..6e0fa79 100644
> --- a/drivers/bus/mhi/host/init.c
> +++ b/drivers/bus/mhi/host/init.c
> @@ -541,11 +541,9 @@ int mhi_init_mmio(struct mhi_controller *mhi_cntrl)
>  	dev_dbg(dev, "Initializing MHI registers\n");
>  
>  	/* Read channel db offset */
> -	ret = mhi_read_reg(mhi_cntrl, base, CHDBOFF, &val);
> -	if (ret) {
> -		dev_err(dev, "Unable to read CHDBOFF register\n");
> +	ret = mhi_get_channel_doorbell_offset(mhi_cntrl, &val);
> +	if (ret)
>  		return -EIO;

	return ret;

- Mani

> -	}
>  
>  	if (val >= mhi_cntrl->reg_len - (8 * MHI_DEV_WAKE_DB)) {
>  		dev_err(dev, "CHDB offset: 0x%x is out of range: 0x%zx\n",
> diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c
> index 15d657a..4de7567 100644
> --- a/drivers/bus/mhi/host/main.c
> +++ b/drivers/bus/mhi/host/main.c
> @@ -1691,3 +1691,19 @@ void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev)
>  	}
>  }
>  EXPORT_SYMBOL_GPL(mhi_unprepare_from_transfer);
> +
> +int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 *chdb_offset)
> +{
> +	struct device *dev = &mhi_cntrl->mhi_dev->dev;
> +	void __iomem *base = mhi_cntrl->regs;
> +	int ret;
> +
> +	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_offset);
> diff --git a/include/linux/mhi.h b/include/linux/mhi.h
> index d968e1a..cb3b676 100644
> --- a/include/linux/mhi.h
> +++ b/include/linux/mhi.h
> @@ -816,4 +816,10 @@ 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_offset - Get the channel doorbell offset
> + * @mhi_cntrl: MHI controller
> + * @chdb_offset: Channel doorbell offset
> + */
> +int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 *chdb_offset);
>  #endif /* _MHI_H_ */
> -- 
> 2.7.4
> 
>
diff mbox series

Patch

diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c
index 7104c18..6e0fa79 100644
--- a/drivers/bus/mhi/host/init.c
+++ b/drivers/bus/mhi/host/init.c
@@ -541,11 +541,9 @@  int mhi_init_mmio(struct mhi_controller *mhi_cntrl)
 	dev_dbg(dev, "Initializing MHI registers\n");
 
 	/* Read channel db offset */
-	ret = mhi_read_reg(mhi_cntrl, base, CHDBOFF, &val);
-	if (ret) {
-		dev_err(dev, "Unable to read CHDBOFF register\n");
+	ret = mhi_get_channel_doorbell_offset(mhi_cntrl, &val);
+	if (ret)
 		return -EIO;
-	}
 
 	if (val >= mhi_cntrl->reg_len - (8 * MHI_DEV_WAKE_DB)) {
 		dev_err(dev, "CHDB offset: 0x%x is out of range: 0x%zx\n",
diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c
index 15d657a..4de7567 100644
--- a/drivers/bus/mhi/host/main.c
+++ b/drivers/bus/mhi/host/main.c
@@ -1691,3 +1691,19 @@  void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev)
 	}
 }
 EXPORT_SYMBOL_GPL(mhi_unprepare_from_transfer);
+
+int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 *chdb_offset)
+{
+	struct device *dev = &mhi_cntrl->mhi_dev->dev;
+	void __iomem *base = mhi_cntrl->regs;
+	int ret;
+
+	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_offset);
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index d968e1a..cb3b676 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -816,4 +816,10 @@  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_offset - Get the channel doorbell offset
+ * @mhi_cntrl: MHI controller
+ * @chdb_offset: Channel doorbell offset
+ */
+int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 *chdb_offset);
 #endif /* _MHI_H_ */