aboutsummaryrefslogtreecommitdiff
path: root/src/soc/nvidia/tegra/gpio.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc/nvidia/tegra/gpio.h')
-rw-r--r--src/soc/nvidia/tegra/gpio.h48
1 files changed, 48 insertions, 0 deletions
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__ */