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