diff mbox series

[05/17] ufs/ufs.h: Add definition of 'ufshcd_rmwl()'

Message ID 20230814215457.4075025-6-bhupesh.sharma@linaro.org
State New
Headers show
Series Enable UFS on DragonBoard845c | expand

Commit Message

Bhupesh Sharma Aug. 14, 2023, 9:54 p.m. UTC
Add definition of 'ufshcd_rmwl()' helper function
which would be later used by Qualcomm UFS driver
to read-modify-write registers.

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
---
 drivers/ufs/ufs.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/drivers/ufs/ufs.h b/drivers/ufs/ufs.h
index 8a38832b05..c9320a905e 100644
--- a/drivers/ufs/ufs.h
+++ b/drivers/ufs/ufs.h
@@ -2,6 +2,7 @@ 
 #ifndef __UFS_H
 #define __UFS_H
 
+#include <asm/io.h>
 #include "unipro.h"
 
 struct udevice;
@@ -906,6 +907,23 @@  enum {
 #define ufshcd_readl(hba, reg) \
 	readl((hba)->mmio_base + (reg))
 
+/**
+ * ufshcd_rmwl - perform read/modify/write for a controller register
+ * @hba: per adapter instance
+ * @mask: mask to apply on read value
+ * @val: actual value to write
+ * @reg: register address
+ */
+static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg)
+{
+	u32 tmp;
+
+	tmp = ufshcd_readl(hba, reg);
+	tmp &= ~mask;
+	tmp |= (val & mask);
+	ufshcd_writel(hba, tmp, reg);
+}
+
 /* UTRLRSR - UTP Transfer Request Run-Stop Register 60h */
 #define UTP_TRANSFER_REQ_LIST_RUN_STOP_BIT	0x1