blob: daf5698e6625ef4c6663ac659f6142c6dbecc904 [file] [log] [blame]
Thierry Redingf3685592011-11-17 00:10:23 +00001/*
2 * Copyright (c) 2011, Google Inc. All rights reserved.
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02003 * SPDX-License-Identifier: GPL-2.0+
Thierry Redingf3685592011-11-17 00:10:23 +00004 */
5
Tom Warrenab371962012-09-19 15:50:56 -07006#ifndef _TEGRA_GPIO_H_
7#define _TEGRA_GPIO_H_
Thierry Redingf3685592011-11-17 00:10:23 +00008
Simon Glassb0461042014-09-03 17:37:03 -06009#define TEGRA_GPIOS_PER_PORT 8
10#define TEGRA_PORTS_PER_BANK 4
Tom Warrenab371962012-09-19 15:50:56 -070011#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 Warren4b27bf12014-04-22 14:37:53 -060019enum tegra_gpio_init {
20 TEGRA_GPIO_INIT_IN,
21 TEGRA_GPIO_INIT_OUT0,
22 TEGRA_GPIO_INIT_OUT1,
23};
24
25struct tegra_gpio_config {
26 u32 gpio:16;
27 u32 init:2;
28};
29
Simon Glassb0461042014-09-03 17:37:03 -060030/**
Stephen Warren4b27bf12014-04-22 14:37:53 -060031 * Configure a list of GPIOs
32 *
33 * @param config List of GPIO configurations
34 * @param len Number of config items in list
35 */
36void gpio_config_table(const struct tegra_gpio_config *config, int len);
37
Tom Warrenab371962012-09-19 15:50:56 -070038#endif /* TEGRA_GPIO_H_ */