From 74bb41275326cd34046454ab5a06bd7a17d5f887 Mon Sep 17 00:00:00 2001 From: Shunqian Zheng Date: Tue, 17 May 2016 14:00:04 +0800 Subject: rockchip/rk3399: Fix pinctrl pull bias settings The pull bias settings for GPIO0_A, GPIO0_B, GPIO2_C and GPIO2_D are different from the other GPIO banks. This patch adds a callback function to get the GPIO pull value of each SoC(rk3288 and rk3399) so we can still use the common GPIO driver. BRANCH=none BUG=chrome-os-partner:53251 TEST=Jerry and Gru still boot Change-Id: I2a00b7ffd2699190582f5f50a1e21b61c500bf4f Signed-off-by: Martin Roth Original-Commit-Id: 46d5fa7297693216a2da9bcf15ccce4af796e80e Original-Change-Id: If53f47181bdc235a1ccfefeeb2a77e0eb0e3b1ca Original-Signed-off-by: Shunqian Zheng Original-Reviewed-on: https://chromium-review.googlesource.com/358110 Original-Commit-Ready: Julius Werner Original-Tested-by: Julius Werner Original-Reviewed-by: Julius Werner Reviewed-on: https://review.coreboot.org/15587 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh --- src/soc/rockchip/rk3399/gpio.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/soc/rockchip/rk3399/gpio.c') diff --git a/src/soc/rockchip/rk3399/gpio.c b/src/soc/rockchip/rk3399/gpio.c index 18e0b70931..a0cf05974c 100644 --- a/src/soc/rockchip/rk3399/gpio.c +++ b/src/soc/rockchip/rk3399/gpio.c @@ -47,3 +47,36 @@ void *gpio_grf_reg(gpio_t gpio) /* There are two pmu gpio, 0 and 1, so " - 2" */ return &rk3399_grf->gpio2_p[(gpio.port - 2)][gpio.bank]; } + +#define IS_GPIO_BANK(g, p, b) (g.port == p && g.bank == GPIO_##b) + +enum { + PULLNONE_1V8 = 0, + PULLDOWN_1V8 = 1, + PULLUP_1V8 = 3, +}; + +u32 gpio_get_pull_val(gpio_t gpio, u32 pull) +{ + /* The default pull bias setting defined in soc/gpio.h */ + u32 pull_val = pull; + + /* GPIO0_A, GPIO0_B, GPIO2_C, GPIO2_D use the 1V8 pull bias setting. + * Defined in TRM V.03 Part1 Page 331 and Page 458 + */ + if (IS_GPIO_BANK(gpio, 0, A) || IS_GPIO_BANK(gpio, 0, B) || + IS_GPIO_BANK(gpio, 2, C) || IS_GPIO_BANK(gpio, 2, D)) { + switch (pull) { + case PULLUP: + pull_val = PULLUP_1V8; + break; + case PULLDOWN: + pull_val = PULLDOWN_1V8; + break; + default: + pull_val = PULLNONE_1V8; + } + } + + return pull_val; +} -- cgit v1.2.3