From e550c6310118d1369796751ce98fe66167db0861 Mon Sep 17 00:00:00 2001 From: Caesar Wang Date: Sat, 10 Sep 2016 02:43:15 +0800 Subject: rockchip: support disable/enable specific gpio when suspend/resume some specific board need to disable/enable specific gpio when suspend/resume, so we add this function, bootloader can pass the specific gpio, and we can handle these gpios in bl31 suspend/resuem function. Change-Id: I373b03ef9202ee4a05a2b9caacdfa01b47ee2177 --- plat/rockchip/common/params_setup.c | 55 +++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'plat/rockchip/common/params_setup.c') diff --git a/plat/rockchip/common/params_setup.c b/plat/rockchip/common/params_setup.c index 2a49556f..351d2136 100644 --- a/plat/rockchip/common/params_setup.c +++ b/plat/rockchip/common/params_setup.c @@ -40,25 +40,32 @@ #include #include -static struct bl31_plat_param *bl31_params_head; -static struct bl31_gpio_param param_reset; -static struct bl31_gpio_param param_poweroff; +static struct gpio_info param_reset; +static struct gpio_info param_poweroff; static struct gpio_info *rst_gpio; static struct gpio_info *poweroff_gpio; +static struct gpio_info suspend_gpio[10]; +uint32_t suspend_gpio_cnt; -void *plat_get_rockchip_gpio_reset(void) +struct gpio_info *plat_get_rockchip_gpio_reset(void) { return rst_gpio; } -void *plat_get_rockchip_gpio_poweroff(void) +struct gpio_info *plat_get_rockchip_gpio_poweroff(void) { return poweroff_gpio; } +struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count) +{ + *count = suspend_gpio_cnt; + + return &suspend_gpio[0]; +} + void params_early_setup(void *plat_param_from_bl2) { - struct bl31_plat_param *param; struct bl31_plat_param *bl2_param; struct bl31_gpio_param *gpio_param; @@ -67,25 +74,33 @@ void params_early_setup(void *plat_param_from_bl2) while (bl2_param) { switch (bl2_param->type) { case PARAM_RESET: - param = (struct bl31_plat_param *)¶m_reset; - memcpy((void *)param, (void *)bl2_param, - sizeof(struct bl31_gpio_param)); - gpio_param = (struct bl31_gpio_param *)param; - rst_gpio = &gpio_param->gpio; + gpio_param = (struct bl31_gpio_param *)bl2_param; + memcpy(¶m_reset, &gpio_param->gpio, + sizeof(struct gpio_info)); + rst_gpio = ¶m_reset; break; case PARAM_POWEROFF: - param = (struct bl31_plat_param *)¶m_poweroff; - memcpy((void *)param, (void *)bl2_param, - sizeof(struct bl31_gpio_param)); - gpio_param = (struct bl31_gpio_param *)param; - poweroff_gpio = &gpio_param->gpio; + gpio_param = (struct bl31_gpio_param *)bl2_param; + memcpy(¶m_poweroff, &gpio_param->gpio, + sizeof(struct gpio_info)); + poweroff_gpio = ¶m_poweroff; + break; + case PARAM_SUSPEND_GPIO: + if (suspend_gpio_cnt >= ARRAY_SIZE(suspend_gpio)) { + ERROR("exceed support suspend gpio number\n"); + break; + } + gpio_param = (struct bl31_gpio_param *)bl2_param; + memcpy(&suspend_gpio[suspend_gpio_cnt], + &gpio_param->gpio, + sizeof(struct gpio_info)); + suspend_gpio_cnt++; break; default: - NOTICE("not expected type found\n"); - return; /* don't continue if unexpected type found */ + ERROR("not expected type found %ld\n", + bl2_param->type); + break; } - param->next = bl31_params_head; - bl31_params_head = param; bl2_param = bl2_param->next; } } -- cgit From 2bff35bb7c3a20edddce8c5c3bfa8d7e948679e9 Mon Sep 17 00:00:00 2001 From: Caesar Wang Date: Sat, 10 Sep 2016 02:47:53 +0800 Subject: rockchip: set gpio2 ~ gpio4 to input and pull none mode For save power cosumption, if gpio power supply shut down, we need to set gpio2 ~ gpio4 to input and HiZ status when suspend, and recovery they status when rusume. we do it base on apio pass from loader. Change-Id: I59fd2395e5e37e63425472a39f519822c9197e4c --- plat/rockchip/common/params_setup.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'plat/rockchip/common/params_setup.c') diff --git a/plat/rockchip/common/params_setup.c b/plat/rockchip/common/params_setup.c index 351d2136..646c1e13 100644 --- a/plat/rockchip/common/params_setup.c +++ b/plat/rockchip/common/params_setup.c @@ -42,10 +42,12 @@ static struct gpio_info param_reset; static struct gpio_info param_poweroff; +static struct bl31_apio_param param_apio; static struct gpio_info *rst_gpio; static struct gpio_info *poweroff_gpio; static struct gpio_info suspend_gpio[10]; uint32_t suspend_gpio_cnt; +static struct apio_info *suspend_apio; struct gpio_info *plat_get_rockchip_gpio_reset(void) { @@ -64,6 +66,11 @@ struct gpio_info *plat_get_rockchip_suspend_gpio(uint32_t *count) return &suspend_gpio[0]; } +struct apio_info *plat_get_rockchip_suspend_apio(void) +{ + return suspend_apio; +} + void params_early_setup(void *plat_param_from_bl2) { struct bl31_plat_param *bl2_param; @@ -96,6 +103,11 @@ void params_early_setup(void *plat_param_from_bl2) sizeof(struct gpio_info)); suspend_gpio_cnt++; break; + case PARAM_SUSPEND_APIO: + memcpy(¶m_apio, bl2_param, + sizeof(struct bl31_apio_param)); + suspend_apio = ¶m_apio.apio; + break; default: ERROR("not expected type found %ld\n", bl2_param->type); -- cgit