blob: db60864a25db1d5a490eb909110fc4bf8a3a6136 [file] [log] [blame]
Tom Warren150c2492012-09-19 15:50:56 -07001/*
2 * Copyright (c) 2011, Google Inc. All rights reserved.
Wolfgang Denk1a459662013-07-08 09:37:19 +02003 * SPDX-License-Identifier: GPL-2.0+
Tom Warren150c2492012-09-19 15:50:56 -07004 */
5
6#ifndef _TEGRA_GPIO_H_
7#define _TEGRA_GPIO_H_
8
Stephen Warren01a97a12016-05-12 12:07:39 -06009#include <dt-bindings/gpio/tegra-gpio.h>
10
Simon Glass2fccd2d2014-09-03 17:37:03 -060011#define TEGRA_GPIOS_PER_PORT 8
12#define TEGRA_PORTS_PER_BANK 4
Tom Warren150c2492012-09-19 15:50:56 -070013#define MAX_NUM_GPIOS (TEGRA_GPIO_PORTS * TEGRA_GPIO_BANKS * 8)
14#define GPIO_NAME_SIZE 20 /* gpio_request max label len */
15
16#define GPIO_BANK(x) ((x) >> 5)
17#define GPIO_PORT(x) (((x) >> 3) & 0x3)
18#define GPIO_FULLPORT(x) ((x) >> 3)
19#define GPIO_BIT(x) ((x) & 0x7)
20
Stephen Warreneceb3f22014-04-22 14:37:53 -060021enum tegra_gpio_init {
22 TEGRA_GPIO_INIT_IN,
23 TEGRA_GPIO_INIT_OUT0,
24 TEGRA_GPIO_INIT_OUT1,
25};
26
27struct tegra_gpio_config {
28 u32 gpio:16;
29 u32 init:2;
30};
31
Simon Glass2fccd2d2014-09-03 17:37:03 -060032/**
Stephen Warreneceb3f22014-04-22 14:37:53 -060033 * Configure a list of GPIOs
34 *
35 * @param config List of GPIO configurations
36 * @param len Number of config items in list
37 */
38void gpio_config_table(const struct tegra_gpio_config *config, int len);
39
Tom Warren150c2492012-09-19 15:50:56 -070040#endif /* TEGRA_GPIO_H_ */