Angel Pons | bbc99cf | 2020-04-04 18:51:23 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
huang lin | d5fb66e | 2014-08-26 18:22:08 +0800 | [diff] [blame] | 2 | |
Julius Werner | eaa9c45 | 2014-09-24 15:40:49 -0700 | [diff] [blame] | 3 | #include <gpio.h> |
Elyes HAOUAS | 78efb84 | 2020-10-13 11:13:59 +0200 | [diff] [blame] | 4 | #include <soc/addressmap.h> |
Julius Werner | 7a453eb | 2014-10-20 13:14:55 -0700 | [diff] [blame] | 5 | #include <soc/grf.h> |
| 6 | #include <soc/pmu.h> |
Julius Werner | eaa9c45 | 2014-09-24 15:40:49 -0700 | [diff] [blame] | 7 | #include <soc/soc.h> |
huang lin | d5fb66e | 2014-08-26 18:22:08 +0800 | [diff] [blame] | 8 | |
Shunqian Zheng | 015ae11 | 2016-04-20 20:35:09 +0800 | [diff] [blame] | 9 | struct rockchip_gpio_regs *gpio_port[] = { |
Elyes HAOUAS | 78efb84 | 2020-10-13 11:13:59 +0200 | [diff] [blame] | 10 | (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 lin | d5fb66e | 2014-08-26 18:22:08 +0800 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | #define PMU_GPIO_PORT 0 |
| 22 | |
Shunqian Zheng | 015ae11 | 2016-04-20 20:35:09 +0800 | [diff] [blame] | 23 | int is_pmu_gpio(gpio_t gpio) |
huang lin | d5fb66e | 2014-08-26 18:22:08 +0800 | [diff] [blame] | 24 | { |
huang lin | d5fb66e | 2014-08-26 18:22:08 +0800 | [diff] [blame] | 25 | if (gpio.port == PMU_GPIO_PORT) |
Shunqian Zheng | 015ae11 | 2016-04-20 20:35:09 +0800 | [diff] [blame] | 26 | return 1; |
| 27 | return 0; |
huang lin | d5fb66e | 2014-08-26 18:22:08 +0800 | [diff] [blame] | 28 | } |
| 29 | |
Shunqian Zheng | 015ae11 | 2016-04-20 20:35:09 +0800 | [diff] [blame] | 30 | void *gpio_grf_reg(gpio_t gpio) |
huang lin | d5fb66e | 2014-08-26 18:22:08 +0800 | [diff] [blame] | 31 | { |
Shunqian Zheng | 015ae11 | 2016-04-20 20:35:09 +0800 | [diff] [blame] | 32 | if (is_pmu_gpio(gpio)) |
| 33 | return &rk3288_pmu->gpio0pull[gpio.bank]; |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 34 | /* There is one pmu gpio, gpio0, so " - 1" */ |
Shunqian Zheng | 015ae11 | 2016-04-20 20:35:09 +0800 | [diff] [blame] | 35 | return &rk3288_grf->gpio1_p[(gpio.port - 1)][gpio.bank]; |
huang lin | d5fb66e | 2014-08-26 18:22:08 +0800 | [diff] [blame] | 36 | } |
Shunqian Zheng | 74bb412 | 2016-05-17 14:00:04 +0800 | [diff] [blame] | 37 | |
Julius Werner | 2768a11 | 2016-09-01 22:55:58 -0700 | [diff] [blame] | 38 | u32 gpio_get_pull_val(gpio_t gpio, enum gpio_pull pull) |
Shunqian Zheng | 74bb412 | 2016-05-17 14:00:04 +0800 | [diff] [blame] | 39 | { |
| 40 | /* use the default gpio pull bias setting defined in soc/gpio.h */ |
| 41 | return pull; |
| 42 | } |