| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #include <printf.h>
- #include <platform/mt_typedefs.h>
- #include <platform/mtk_key.h>
- #include <platform/boot_mode.h>
- #include <platform/mt_pmic.h>
- #include <platform/mt_gpio.h>
- #include <platform/mt_pmic_wrap_init.h>
- #include <platform/sync_write.h>
- #include <platform/upmu_common.h>
- #include <platform/upmu_hw.h>
- #include <target/cust_key.h>
- extern int pmic_detect_powerkey(void);
- extern int pmic_detect_homekey(void);
- void set_kpd_pmic_mode(void)
- {
- return;
- }
- void disable_PMIC_kpd_clock(void)
- {
- return;
- }
- void enable_PMIC_kpd_clock(void)
- {
- return;
- }
- BOOL mtk_detect_key(unsigned short key) /* key: HW keycode */
- {
- #ifdef MACH_FPGA
- return FALSE;
- #else
- dprintf(ALWAYS, "mtk detect key function key = %d\n", key);
- unsigned short idx, bit, din;
- if (key >= KPD_NUM_KEYS)
- return FALSE;
- #if 0
- if (key % 9 == 8)
- key = 8;
- #endif
- if (key == MTK_PMIC_PWR_KEY)
- { /* Power key */
- if (1 == pmic_detect_powerkey())
- {
- //dbg_print ("power key is pressed\n");
- return TRUE;
- }
- return FALSE;
- }
- #ifdef MTK_PMIC_RST_KEY
- if (key == MTK_PMIC_RST_KEY)
- {
- dprintf(INFO, "mtk detect key function pmic_detect_homekey MTK_PMIC_RST_KEY = %d\n", MTK_PMIC_RST_KEY);
- if (1 == pmic_detect_homekey())
- {
- dprintf(ALWAYS, "mtk detect key function pmic_detect_homekey pressed\n");
- return TRUE;
- }
- return FALSE;
- }
- #endif
- idx = key / 16;
- bit = key % 16;
- din = DRV_Reg16(KP_MEM1 + (idx << 2)) & (1U << bit);
- if (!din) {
- dprintf(ALWAYS, "key %d is pressed\n", key);
- return TRUE;
- }
- return FALSE;
- #endif
- }
- BOOL mtk_detect_pmic_just_rst(void)
- {
- kal_uint32 just_rst = 0;
- dprintf(ALWAYS, "detecting pmic just reset\n");
- just_rst=pmic_get_register_value(PMIC_JUST_PWRKEY_RST);
- if (just_rst)
- {
- dprintf(ALWAYS, "Just recover from a reset\n");
- pmic_set_register_value(PMIC_CLR_JUST_RST, 0x01);
- return TRUE;
- }
- return FALSE;
- }
|