From 401b3b6ea66731c3d665659d869ed06008db19e6 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Thu, 31 Jul 2014 14:54:12 -0500 Subject: tegra132: provide pad configuration interface Instead of sprinkling the pad configuration and pinmux selection throughout the code allow for a data-driven initialization sequence. Most of the calls in the original pinmux functions require 12 bytes per pad plus the support code. This implementation allows for 4 bytes per pad in addition to the support code. BUG=chrome-os-partner:29981 TEST=Built and booted into depthcharge on rush. Change-Id: I22c243a5f9891a97e14b78d8c8064e36adaf50b8 Signed-off-by: Patrick Georgi Original-Commit-Id: 9329c17bbadcaab803b38842e38e1704d262817d Original-Change-Id: I3a119b4068e880b74a0a1597f143d7c4e108a6c1 Original-Signed-off-by: Aaron Durbin Original-Reviewed-on: https://chromium-review.googlesource.com/210833 Original-Reviewed-by: Furquan Shaikh Reviewed-on: http://review.coreboot.org/8875 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/soc/nvidia/tegra/gpio.c | 31 ----------------------------- src/soc/nvidia/tegra/gpio.h | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 31 deletions(-) (limited to 'src/soc/nvidia/tegra') diff --git a/src/soc/nvidia/tegra/gpio.c b/src/soc/nvidia/tegra/gpio.c index 17b90aa1d9..9f09f24547 100644 --- a/src/soc/nvidia/tegra/gpio.c +++ b/src/soc/nvidia/tegra/gpio.c @@ -47,37 +47,6 @@ void __gpio_output(gpio_t gpio, int value, u32 od) pinmux_set_config(gpio >> GPIO_PINMUX_SHIFT, PINMUX_PULL_NONE | od); } -enum { - GPIO_GPIOS_PER_PORT = 8, - GPIO_PORTS_PER_BANK = 4, - GPIO_BANKS = 8, - - GPIO_GPIOS_PER_BANK = GPIO_GPIOS_PER_PORT * GPIO_PORTS_PER_BANK, - GPIO_GPIOS = GPIO_BANKS * GPIO_GPIOS_PER_BANK -}; - -struct gpio_bank { - // Values - u32 config[GPIO_PORTS_PER_BANK]; - u32 out_enable[GPIO_PORTS_PER_BANK]; - u32 out_value[GPIO_PORTS_PER_BANK]; - u32 in_value[GPIO_PORTS_PER_BANK]; - u32 int_status[GPIO_PORTS_PER_BANK]; - u32 int_enable[GPIO_PORTS_PER_BANK]; - u32 int_level[GPIO_PORTS_PER_BANK]; - u32 int_clear[GPIO_PORTS_PER_BANK]; - - // Masks - u32 config_mask[GPIO_PORTS_PER_BANK]; - u32 out_enable_mask[GPIO_PORTS_PER_BANK]; - u32 out_value_mask[GPIO_PORTS_PER_BANK]; - u32 in_value_mask[GPIO_PORTS_PER_BANK]; - u32 int_status_mask[GPIO_PORTS_PER_BANK]; - u32 int_enable_mask[GPIO_PORTS_PER_BANK]; - u32 int_level_mask[GPIO_PORTS_PER_BANK]; - u32 int_clear_mask[GPIO_PORTS_PER_BANK]; -}; - static const struct gpio_bank *gpio_banks = (void *)TEGRA_GPIO_BASE; static u32 gpio_read_port(int index, size_t offset) diff --git a/src/soc/nvidia/tegra/gpio.h b/src/soc/nvidia/tegra/gpio.h index 43f898958e..da8a4dad71 100644 --- a/src/soc/nvidia/tegra/gpio.h +++ b/src/soc/nvidia/tegra/gpio.h @@ -72,4 +72,52 @@ void gpio_get_int_level(gpio_t gpio, int *high_rise, int *edge, int *delta); void gpio_set_int_clear(gpio_t gpio); +/* Hardware definitions. */ + +enum { + GPIO_GPIOS_PER_PORT = 8, + GPIO_PORTS_PER_BANK = 4, + GPIO_BANKS = 8, + + GPIO_GPIOS_PER_BANK = GPIO_GPIOS_PER_PORT * GPIO_PORTS_PER_BANK, + GPIO_GPIOS = GPIO_BANKS * GPIO_GPIOS_PER_BANK +}; + +static inline int gpio_index_to_bank(int index) +{ + return index / GPIO_GPIOS_PER_BANK; +} + +static inline int gpio_index_to_port(int index) +{ + return (index % GPIO_GPIOS_PER_BANK) / GPIO_PORTS_PER_BANK; +} + +static inline int gpio_to_bit(int index) +{ + return index % GPIO_GPIOS_PER_PORT; +} + +struct gpio_bank { + // Values + u32 config[GPIO_PORTS_PER_BANK]; + u32 out_enable[GPIO_PORTS_PER_BANK]; + u32 out_value[GPIO_PORTS_PER_BANK]; + u32 in_value[GPIO_PORTS_PER_BANK]; + u32 int_status[GPIO_PORTS_PER_BANK]; + u32 int_enable[GPIO_PORTS_PER_BANK]; + u32 int_level[GPIO_PORTS_PER_BANK]; + u32 int_clear[GPIO_PORTS_PER_BANK]; + + // Masks + u32 config_mask[GPIO_PORTS_PER_BANK]; + u32 out_enable_mask[GPIO_PORTS_PER_BANK]; + u32 out_value_mask[GPIO_PORTS_PER_BANK]; + u32 in_value_mask[GPIO_PORTS_PER_BANK]; + u32 int_status_mask[GPIO_PORTS_PER_BANK]; + u32 int_enable_mask[GPIO_PORTS_PER_BANK]; + u32 int_level_mask[GPIO_PORTS_PER_BANK]; + u32 int_clear_mask[GPIO_PORTS_PER_BANK]; +}; + #endif /* __SOC_NVIDIA_TEGRA_GPIO_H__ */ -- cgit v1.2.3