soc: samsung: exynos-pmu: add support for PMU_ALIVE non atomic registers
authorPeter Griffin <peter.griffin@linaro.org>
Tue, 2 Jul 2024 06:35:09 +0000 (08:35 +0200)
committerArnd Bergmann <arnd@arndb.de>
Tue, 9 Jul 2024 09:16:42 +0000 (11:16 +0200)
Not all registers in PMU_ALIVE block support atomic set/clear operations.
GS101_SYSIP_DAT0 and GS101_SYSTEM_CONFIGURATION registers are two regs
where attempting atomic access fails.

As documentation on exactly which registers support atomic operations is
not forthcoming. We default to atomic access, unless the register is
explicitly added to the tensor_is_atomic() function. Update the comment
to reflect this as well.

Reviewed-by: Will McVicker <willmcvicker@google.com>
Tested-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Link: https://lore.kernel.org/r/20240628223506.1237523-4-peter.griffin@linaro.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240702063514.6215-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
drivers/soc/samsung/exynos-pmu.c
include/linux/soc/samsung/exynos-regs-pmu.h

index fd8b6ac066562ff1415f561e17e893e607fff497..a0123070a81601795534d46a21f70dfdf5c51942 100644 (file)
@@ -129,14 +129,30 @@ static int tensor_set_bits_atomic(void *ctx, unsigned int offset, u32 val,
        return ret;
 }
 
-static int tensor_sec_update_bits(void *ctx, unsigned int reg,
-                                 unsigned int mask, unsigned int val)
+static bool tensor_is_atomic(unsigned int reg)
 {
        /*
         * Use atomic operations for PMU_ALIVE registers (offset 0~0x3FFF)
-        * as the target registers can be accessed by multiple masters.
+        * as the target registers can be accessed by multiple masters. SFRs
+        * that don't support atomic are added to the switch statement below.
         */
        if (reg > PMUALIVE_MASK)
+               return false;
+
+       switch (reg) {
+       case GS101_SYSIP_DAT0:
+       case GS101_SYSTEM_CONFIGURATION:
+               return false;
+       default:
+               return true;
+       }
+}
+
+static int tensor_sec_update_bits(void *ctx, unsigned int reg,
+                                 unsigned int mask, unsigned int val)
+{
+
+       if (!tensor_is_atomic(reg))
                return tensor_sec_reg_rmw(ctx, reg, mask, val);
 
        return tensor_set_bits_atomic(ctx, reg, val, mask);
index aa840ed043e138f0f4f03f1fdde7c5fc3ab087b4..f411c176536d2d19abdc4e3911d84f34bb71d656 100644 (file)
 #define EXYNOS5433_PAD_RETENTION_UFS_OPTION                    (0x3268)
 #define EXYNOS5433_PAD_RETENTION_FSYSGENIO_OPTION              (0x32A8)
 
+/* For Tensor GS101 */
+#define GS101_SYSIP_DAT0                                       (0x810)
+#define GS101_SYSTEM_CONFIGURATION                             (0x3A00)
+
 #endif /* __LINUX_SOC_EXYNOS_REGS_PMU_H */