blob: a1da1d791ba3b2b22c3ec4c4d4be86c83be13b67 [file] [log] [blame]
Angel Ponsbbc99cf2020-04-04 18:51:23 +02001/* SPDX-License-Identifier: GPL-2.0-only */
huang lind5fb66e2014-08-26 18:22:08 +08002
Julius Wernereaa9c452014-09-24 15:40:49 -07003#include <gpio.h>
Elyes HAOUAS78efb842020-10-13 11:13:59 +02004#include <soc/addressmap.h>
Julius Werner7a453eb2014-10-20 13:14:55 -07005#include <soc/grf.h>
6#include <soc/pmu.h>
Julius Wernereaa9c452014-09-24 15:40:49 -07007#include <soc/soc.h>
huang lind5fb66e2014-08-26 18:22:08 +08008
Shunqian Zheng015ae112016-04-20 20:35:09 +08009struct rockchip_gpio_regs *gpio_port[] = {
Elyes HAOUAS78efb842020-10-13 11:13:59 +020010 (struct rockchip_gpio_regs *)GPIO0_BASE,
11 (struct rockchip_gpio_regs *)GPIO1_BASE,
12 (struct rockchip_gpio_regs *)GPIO2_BASE,
13 (struct rockchip_gpio_regs *)GPIO3_BASE,
14 (struct rockchip_gpio_regs *)GPIO4_BASE,
15 (struct rockchip_gpio_regs *)GPIO5_BASE,
16 (struct rockchip_gpio_regs *)GPIO6_BASE,
17 (struct rockchip_gpio_regs *)GPIO7_BASE,
18 (struct rockchip_gpio_regs *)GPIO8_BASE
huang lind5fb66e2014-08-26 18:22:08 +080019};
20
21#define PMU_GPIO_PORT 0
22
Shunqian Zheng015ae112016-04-20 20:35:09 +080023int is_pmu_gpio(gpio_t gpio)
huang lind5fb66e2014-08-26 18:22:08 +080024{
huang lind5fb66e2014-08-26 18:22:08 +080025 if (gpio.port == PMU_GPIO_PORT)
Shunqian Zheng015ae112016-04-20 20:35:09 +080026 return 1;
27 return 0;
huang lind5fb66e2014-08-26 18:22:08 +080028}
29
Shunqian Zheng015ae112016-04-20 20:35:09 +080030void *gpio_grf_reg(gpio_t gpio)
huang lind5fb66e2014-08-26 18:22:08 +080031{
Shunqian Zheng015ae112016-04-20 20:35:09 +080032 if (is_pmu_gpio(gpio))
33 return &rk3288_pmu->gpio0pull[gpio.bank];
Elyes HAOUASa342f392018-10-17 10:56:26 +020034 /* There is one pmu gpio, gpio0, so " - 1" */
Shunqian Zheng015ae112016-04-20 20:35:09 +080035 return &rk3288_grf->gpio1_p[(gpio.port - 1)][gpio.bank];
huang lind5fb66e2014-08-26 18:22:08 +080036}
Shunqian Zheng74bb4122016-05-17 14:00:04 +080037
Julius Werner2768a112016-09-01 22:55:58 -070038u32 gpio_get_pull_val(gpio_t gpio, enum gpio_pull pull)
Shunqian Zheng74bb4122016-05-17 14:00:04 +080039{
40 /* use the default gpio pull bias setting defined in soc/gpio.h */
41 return pull;
42}