2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <soc/addressmap.h>
21 struct rockchip_gpio_regs
*gpio_port
[] = {
22 (struct rockchip_gpio_regs
*)GPIO0_BASE
,
23 (struct rockchip_gpio_regs
*)GPIO1_BASE
,
24 (struct rockchip_gpio_regs
*)GPIO2_BASE
,
25 (struct rockchip_gpio_regs
*)GPIO3_BASE
,
26 (struct rockchip_gpio_regs
*)GPIO4_BASE
,
29 #define PMU_GPIO_PORT0 0
30 #define PMU_GPIO_PORT1 1
32 int is_pmu_gpio(gpio_t gpio
)
34 if (gpio
.port
== PMU_GPIO_PORT0
|| gpio
.port
== PMU_GPIO_PORT1
)
39 void *gpio_grf_reg(gpio_t gpio
)
41 if (is_pmu_gpio(gpio
))
42 return &rk3399_pmugrf
->gpio0_p
[gpio
.port
][gpio
.bank
];
43 /* There are two pmu gpio, 0 and 1, so " - 2" */
44 return &rk3399_grf
->gpio2_p
[(gpio
.port
- 2)][gpio
.bank
];
47 #define IS_GPIO_BANK(g, p, b) (g.port == p && g.bank == GPIO_##b)
55 u32
gpio_get_pull_val(gpio_t gpio
, enum gpio_pull pull
)
57 /* The default pull bias setting defined in soc/gpio.h */
60 /* GPIO0_A, GPIO0_B, GPIO2_C, GPIO2_D use the 1V8 pull bias setting.
61 * Defined in TRM V.03 Part1 Page 331 and Page 458
63 if (IS_GPIO_BANK(gpio
, 0, A
) || IS_GPIO_BANK(gpio
, 0, B
) ||
64 IS_GPIO_BANK(gpio
, 2, C
) || IS_GPIO_BANK(gpio
, 2, D
)) {
67 pull_val
= PULLUP_1V8
;
70 pull_val
= PULLDOWN_1V8
;
73 pull_val
= PULLNONE_1V8
;