MA-17046-3 Add implementation to get ONOFF button status
authorJi Luo <ji.luo@nxp.com>
Tue, 28 Apr 2020 02:52:56 +0000 (10:52 +0800)
committerJi Luo <ji.luo@nxp.com>
Thu, 13 May 2021 01:49:18 +0000 (09:49 +0800)
Add board level implementation to get the ON-OFF button
status for imx8q/imx8m.

Test: Get ON-OFF button status on imx7ulp/imx8m/imx8q.

Change-Id: I8e4ea61ec1c52ab7cfa20b5498756a25f3cd2f8d
Signed-off-by: Ji Luo <ji.luo@nxp.com>
(cherry picked from commit 44c6edfbd2607f1458220031467fc7de20dc46be)

arch/arm/include/asm/arch-mx7ulp/imx-regs.h
board/freescale/imx8mm_evk/imx8mm_evk.c
board/freescale/imx8mn_evk/imx8mn_evk.c
board/freescale/imx8mp_evk/imx8mp_evk.c
board/freescale/imx8mq_evk/imx8mq_evk.c
board/freescale/imx8qm_mek/imx8qm_mek.c
board/freescale/imx8qxp_mek/imx8qxp_mek.c
board/freescale/mx7ulp_evk/mx7ulp_evk.c

index de4e329..4103c6e 100644 (file)
 
 #define SNVS_LPCR_DPEN                         (0x20)
 #define SNVS_LPCR_SRTC_ENV                     (0x1)
+#define SNVS_BASE_REVB                         (0x41070000)
+#define SNVS_HPSR_REVB                         (SNVS_BASE_REVB + 0x14)
 
 #define SRC_BASE_ADDR                  CMC1_RBASE
 #define IRAM_BASE_ADDR                 OCRAM_0_BASE
index 562a251..e979d32 100644 (file)
@@ -329,3 +329,9 @@ int board_late_init(void)
 #endif
        return 0;
 }
+
+#ifdef CONFIG_ANDROID_SUPPORT
+bool is_power_key_pressed(void) {
+       return (bool)(!!(readl(SNVS_HPSR) & (0x1 << 6)));
+}
+#endif
index 0f43e02..3e39074 100644 (file)
@@ -329,3 +329,9 @@ int board_late_init(void)
 #endif
        return 0;
 }
+
+#ifdef CONFIG_ANDROID_SUPPORT
+bool is_power_key_pressed(void) {
+       return (bool)(!!(readl(SNVS_HPSR) & (0x1 << 6)));
+}
+#endif
index 2afee7d..b4923b5 100644 (file)
@@ -496,6 +496,12 @@ ulong board_get_usable_ram_top(ulong total_size)
 }
 #endif
 
+#ifdef CONFIG_ANDROID_SUPPORT
+bool is_power_key_pressed(void) {
+       return (bool)(!!(readl(SNVS_HPSR) & (0x1 << 6)));
+}
+#endif
+
 #ifdef CONFIG_SPL_MMC_SUPPORT
 #define UBOOT_RAW_SECTOR_OFFSET 0x40
 unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc)
index 92e3949..688d47a 100644 (file)
@@ -279,3 +279,9 @@ int board_late_init(void)
 
        return 0;
 }
+
+#ifdef CONFIG_ANDROID_SUPPORT
+bool is_power_key_pressed(void) {
+       return (bool)(!!(readl(SNVS_HPSR) & (0x1 << 6)));
+}
+#endif
index 80e60aa..fafd23f 100644 (file)
@@ -520,3 +520,12 @@ int board_late_init(void)
 
        return 0;
 }
+
+#ifdef CONFIG_ANDROID_SUPPORT
+bool is_power_key_pressed(void) {
+       sc_bool_t status = SC_FALSE;
+
+       sc_misc_get_button_status(-1, &status);
+       return (bool)status;
+}
+#endif
index 96f99c7..8c2a21a 100644 (file)
@@ -419,3 +419,12 @@ int board_late_init(void)
 
        return 0;
 }
+
+#ifdef CONFIG_ANDROID_SUPPORT
+bool is_power_key_pressed(void) {
+       sc_bool_t status = SC_FALSE;
+
+       sc_misc_get_button_status(-1, &status);
+       return (bool)status;
+}
+#endif
index 247dd4e..ce71675 100644 (file)
@@ -158,3 +158,10 @@ int board_late_init(void)
 
        return 0;
 }
+
+#ifdef CONFIG_ANDROID_SUPPORT
+bool is_power_key_pressed(void) {
+       /* the onoff button is 'pressed' by default on evk board */
+       return (bool)(!(readl(SNVS_HPSR_REVB) & (0x1 << 6)));
+}
+#endif