]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arch/arm: meson: sm: introduce power domain functions
authorAlexey Romanov <avromanov@sberdevices.ru>
Wed, 31 May 2023 09:31:54 +0000 (12:31 +0300)
committerNeil Armstrong <neil.armstrong@linaro.org>
Wed, 28 Jun 2023 08:05:34 +0000 (10:05 +0200)
This commit adds functions to manage secure power domain for
Amlogic SoC's using smc functionality.

Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20230531093156.29240-2-avromanov@sberdevices.ru
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
arch/arm/include/asm/arch-meson/sm.h
arch/arm/mach-meson/sm.c

index 53b751764936585da614660f9cc3dd84ac51cf62..4b1d564bc480bd546ca94b5e53ba0a5936f6cd28 100644 (file)
@@ -58,4 +58,34 @@ enum {
  */
 int meson_sm_get_reboot_reason(void);
 
+#define PWRDM_OFF 0
+#define PWRDM_ON 1
+
+/**
+ * meson_sm_pwrdm_set - do command at specified power domain.
+ *
+ * @index: power domain index.
+ * @cmd: command index.
+ * @return: zero on success or error code on failure.
+ */
+int meson_sm_pwrdm_set(size_t index, int cmd);
+
+/**
+ * meson_sm_pwrdm_off - disable specified power domain.
+ *
+ * @index: power domain index.
+ * @return: zero on success or error code on failure.
+ */
+#define meson_sm_pwrdm_off(index) \
+       meson_sm_pwrdm_set(index, PWRDM_OFF)
+
+/**
+ * meson_sm_pwrdm_on - enable specified power domain.
+ *
+ * @index: power domain index.
+ * @return: zero on success or error code on failure.
+ */
+#define meson_sm_pwrdm_on(index) \
+       meson_sm_pwrdm_set(index, PWRDM_ON)
+
 #endif /* __MESON_SM_H__ */
index f2ca7e7693217f6df4f2a25951d17e00cfa620b9..d600c64d0bead8c38892e16712f4b76fbe451854 100644 (file)
@@ -24,6 +24,7 @@
 #define FN_EFUSE_READ                  0x82000030
 #define FN_EFUSE_WRITE                 0x82000031
 #define FN_CHIP_ID                     0x82000044
+#define FN_PWRDM_SET                   0x82000093
 
 static void *shmem_input;
 static void *shmem_output;
@@ -137,3 +138,16 @@ int meson_sm_get_reboot_reason(void)
        /* The SMC call is not used, we directly use AO_SEC_SD_CFG15 */
        return FIELD_GET(REBOOT_REASON_MASK, reason);
 }
+
+int meson_sm_pwrdm_set(size_t index, int cmd)
+{
+       struct pt_regs regs;
+
+       regs.regs[0] = FN_PWRDM_SET;
+       regs.regs[1] = index;
+       regs.regs[2] = cmd;
+
+       smc_call(&regs);
+
+       return regs.regs[0];
+}