blob: 3c1838cf1372dace41b2c0fd0174fa1a3e240453 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Thierry Redingf3685592011-11-17 00:10:23 +00002/*
3 * Copyright (c) 2011, Google Inc. All rights reserved.
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
Tom Rinidec7ea02024-05-20 13:35:03 -06009#include <linux/types.h>
Stephen Warren7f20bb22016-05-12 12:07:39 -060010#include <dt-bindings/gpio/tegra-gpio.h>
11
Simon Glassb0461042014-09-03 17:37:03 -060012#define TEGRA_GPIOS_PER_PORT 8
13#define TEGRA_PORTS_PER_BANK 4
Tom Warrenab371962012-09-19 15:50:56 -070014#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
Stephen Warren4b27bf12014-04-22 14:37:53 -060022enum tegra_gpio_init {
23 TEGRA_GPIO_INIT_IN,
24 TEGRA_GPIO_INIT_OUT0,
25 TEGRA_GPIO_INIT_OUT1,
26};
27
28struct tegra_gpio_config {
29 u32 gpio:16;
30 u32 init:2;
31};
32
Simon Glassb0461042014-09-03 17:37:03 -060033/**
Stephen Warren4b27bf12014-04-22 14:37:53 -060034 * Configure a list of GPIOs
35 *
36 * @param config List of GPIO configurations
37 * @param len Number of config items in list
38 */
39void gpio_config_table(const struct tegra_gpio_config *config, int len);
40
Tom Warrenab371962012-09-19 15:50:56 -070041#endif /* TEGRA_GPIO_H_ */