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 | |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 9 | #define MAX_NUM_GPIOS (TEGRA_GPIO_PORTS * TEGRA_GPIO_BANKS * 8) |
| 10 | #define GPIO_NAME_SIZE 20 /* gpio_request max label len */ |
| 11 | |
| 12 | #define GPIO_BANK(x) ((x) >> 5) |
| 13 | #define GPIO_PORT(x) (((x) >> 3) & 0x3) |
| 14 | #define GPIO_FULLPORT(x) ((x) >> 3) |
| 15 | #define GPIO_BIT(x) ((x) & 0x7) |
| 16 | |
Stephen Warren | 4b27bf1 | 2014-04-22 14:37:53 -0600 | [diff] [blame^] | 17 | enum tegra_gpio_init { |
| 18 | TEGRA_GPIO_INIT_IN, |
| 19 | TEGRA_GPIO_INIT_OUT0, |
| 20 | TEGRA_GPIO_INIT_OUT1, |
| 21 | }; |
| 22 | |
| 23 | struct tegra_gpio_config { |
| 24 | u32 gpio:16; |
| 25 | u32 init:2; |
| 26 | }; |
| 27 | |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 28 | /* |
| 29 | * Tegra-specific GPIO API |
| 30 | */ |
| 31 | |
Stephen Warren | 4b27bf1 | 2014-04-22 14:37:53 -0600 | [diff] [blame^] | 32 | /** |
| 33 | * Configure a list of GPIOs |
| 34 | * |
| 35 | * @param config List of GPIO configurations |
| 36 | * @param len Number of config items in list |
| 37 | */ |
| 38 | void gpio_config_table(const struct tegra_gpio_config *config, int len); |
| 39 | |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 40 | void gpio_info(void); |
Thierry Reding | f368559 | 2011-11-17 00:10:23 +0000 | [diff] [blame] | 41 | |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 42 | #define gpio_status() gpio_info() |
Stephen Warren | 4b27bf1 | 2014-04-22 14:37:53 -0600 | [diff] [blame^] | 43 | |
Tom Warren | ab37196 | 2012-09-19 15:50:56 -0700 | [diff] [blame] | 44 | #endif /* TEGRA_GPIO_H_ */ |