]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ufs/ufs.h: Add definition of 'ufshcd_rmwl()'
authorBhupesh Sharma <bhupesh.linux@gmail.com>
Mon, 30 Sep 2024 12:44:29 +0000 (14:44 +0200)
committerNeil Armstrong <neil.armstrong@linaro.org>
Mon, 14 Oct 2024 06:55:28 +0000 (08:55 +0200)
Add definition of 'ufshcd_rmwl()' helper function
which would be later used by Qualcomm UFS driver
to read-modify-write registers.

Ported from Linux kernel commits:
e785060ea3a1 ("ufs: definitions for phy interface")
cff91daf52d3 ("scsi: ufs: Fix kernel-doc syntax in ufshcd.h")

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
Tested-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
Tested-by: Julius Lehmann <lehmanju@devpi.de>
Link: https://lore.kernel.org/r/20240930-topic-ufs-enhancements-v3-7-58234f84ab89@linaro.org
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
drivers/ufs/ufs.h

index b55c4a9e99694d2f80a21951d5eb0415c1723a21..555f8a6857d39361b030006921137f210e3a4e2f 100644 (file)
@@ -3,6 +3,7 @@
 #define __UFS_H
 
 #include <linux/types.h>
+#include <asm/io.h>
 #include "unipro.h"
 
 struct udevice;
@@ -933,6 +934,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