1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2011, Google Inc. All rights reserved.
4  */
5 
6 #ifndef _TEGRA_GPIO_H_
7 #define _TEGRA_GPIO_H_
8 
9 #include <linux/types.h>
10 #include <dt-bindings/gpio/tegra-gpio.h>
11 
12 #define TEGRA_GPIOS_PER_PORT	8
13 #define TEGRA_PORTS_PER_BANK	4
14 #define MAX_NUM_GPIOS           (TEGRA_GPIO_PORTS * TEGRA_GPIO_BANKS * 8)
15 #define GPIO_NAME_SIZE		20	/* gpio_request max label len */
16 
17 #define GPIO_BANK(x)		((x) >> 5)
18 #define GPIO_PORT(x)		(((x) >> 3) & 0x3)
19 #define GPIO_FULLPORT(x)	((x) >> 3)
20 #define GPIO_BIT(x)		((x) & 0x7)
21 
22 enum tegra_gpio_init {
23 	TEGRA_GPIO_INIT_IN,
24 	TEGRA_GPIO_INIT_OUT0,
25 	TEGRA_GPIO_INIT_OUT1,
26 };
27 
28 struct tegra_gpio_config {
29 	u32 gpio:16;
30 	u32 init:2;
31 };
32 
33 /**
34  * Configure a list of GPIOs
35  *
36  * @param config	List of GPIO configurations
37  * @param len		Number of config items in list
38  */
39 void gpio_config_table(const struct tegra_gpio_config *config, int len);
40 
41 #endif	/* TEGRA_GPIO_H_ */
42