Thierry Reding | f368559 | 2011-11-17 00:10:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011, Google Inc. All rights reserved. |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 3 | * SPDX-License-Identifier: GPL-2.0+ |
Thierry Reding | f368559 | 2011-11-17 00:10:23 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 6 | #ifndef _TEGRA_GPIO_H_ |
| 7 | #define _TEGRA_GPIO_H_ |
Thierry Reding | f368559 | 2011-11-17 00:10:23 +0000 | [diff] [blame] | 8 | |
Simon Glass | b046104 | 2014-09-03 17:37:03 -0600 | [diff] [blame] | 9 | #define TEGRA_GPIOS_PER_PORT 8 |
| 10 | #define TEGRA_PORTS_PER_BANK 4 |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 11 | #define MAX_NUM_GPIOS (TEGRA_GPIO_PORTS * TEGRA_GPIO_BANKS * 8) |
| 12 | #define GPIO_NAME_SIZE 20 /* gpio_request max label len */ |
| 13 | |
| 14 | #define GPIO_BANK(x) ((x) >> 5) |
| 15 | #define GPIO_PORT(x) (((x) >> 3) & 0x3) |
| 16 | #define GPIO_FULLPORT(x) ((x) >> 3) |
| 17 | #define GPIO_BIT(x) ((x) & 0x7) |
| 18 | |
Stephen Warren | 4b27bf1 | 2014-04-22 14:37:53 -0600 | [diff] [blame] | 19 | enum tegra_gpio_init { |
| 20 | TEGRA_GPIO_INIT_IN, |
| 21 | TEGRA_GPIO_INIT_OUT0, |
| 22 | TEGRA_GPIO_INIT_OUT1, |
| 23 | }; |
| 24 | |
| 25 | struct tegra_gpio_config { |
| 26 | u32 gpio:16; |
| 27 | u32 init:2; |
| 28 | }; |
| 29 | |
Simon Glass | b046104 | 2014-09-03 17:37:03 -0600 | [diff] [blame] | 30 | /** |
| 31 | * tegra_spl_gpio_direction_output() - set the output value of a GPIO |
| 32 | * |
| 33 | * This function is only used from SPL on seaboard, which needs to enable a |
| 34 | * GPIO to get the UART running. It could be done in U-Boot rather than SPL, |
| 35 | * but for now, this gets it working |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 36 | */ |
Simon Glass | b046104 | 2014-09-03 17:37:03 -0600 | [diff] [blame] | 37 | int tegra_spl_gpio_direction_output(int gpio, int value); |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 38 | |
Stephen Warren | 4b27bf1 | 2014-04-22 14:37:53 -0600 | [diff] [blame] | 39 | /** |
| 40 | * Configure a list of GPIOs |
| 41 | * |
| 42 | * @param config List of GPIO configurations |
| 43 | * @param len Number of config items in list |
| 44 | */ |
| 45 | void gpio_config_table(const struct tegra_gpio_config *config, int len); |
| 46 | |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 47 | #endif /* TEGRA_GPIO_H_ */ |