summaryrefslogtreecommitdiffstats
path: root/src/soc/nvidia/tegra
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2014-07-31 14:54:12 -0500
committerPatrick Georgi <pgeorgi@google.com>2015-03-24 15:27:40 +0100
commit401b3b6ea66731c3d665659d869ed06008db19e6 (patch)
tree4829aa08420e52d0956e1e10531324f054d1c9f7 /src/soc/nvidia/tegra
parentaee84263363e4fdc2b7e4762f0b4c7c68a48bea1 (diff)
downloadcoreboot-401b3b6ea66731c3d665659d869ed06008db19e6.tar.gz
coreboot-401b3b6ea66731c3d665659d869ed06008db19e6.tar.bz2
coreboot-401b3b6ea66731c3d665659d869ed06008db19e6.zip
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 <pgeorgi@chromium.org> Original-Commit-Id: 9329c17bbadcaab803b38842e38e1704d262817d Original-Change-Id: I3a119b4068e880b74a0a1597f143d7c4e108a6c1 Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/210833 Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: http://review.coreboot.org/8875 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/soc/nvidia/tegra')
-rw-r--r--src/soc/nvidia/tegra/gpio.c31
-rw-r--r--src/soc/nvidia/tegra/gpio.h48
2 files changed, 48 insertions, 31 deletions
diff --git a/src/soc/nvidia/tegra/gpio.c b/src/soc/nvidia/tegra/gpio.c
index 17b90aa1d9fd..9f09f245474c 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 43f898958ea3..da8a4dad71db 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__ */