gpio.h 918 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2011, Google Inc. All rights reserved.
  4. */
  5. #ifndef _TEGRA_GPIO_H_
  6. #define _TEGRA_GPIO_H_
  7. #include <dt-bindings/gpio/tegra-gpio.h>
  8. #define TEGRA_GPIOS_PER_PORT 8
  9. #define TEGRA_PORTS_PER_BANK 4
  10. #define MAX_NUM_GPIOS (TEGRA_GPIO_PORTS * TEGRA_GPIO_BANKS * 8)
  11. #define GPIO_NAME_SIZE 20 /* gpio_request max label len */
  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. enum tegra_gpio_init {
  17. TEGRA_GPIO_INIT_IN,
  18. TEGRA_GPIO_INIT_OUT0,
  19. TEGRA_GPIO_INIT_OUT1,
  20. };
  21. struct tegra_gpio_config {
  22. u32 gpio:16;
  23. u32 init:2;
  24. };
  25. /**
  26. * Configure a list of GPIOs
  27. *
  28. * @param config List of GPIO configurations
  29. * @param len Number of config items in list
  30. */
  31. void gpio_config_table(const struct tegra_gpio_config *config, int len);
  32. #endif /* TEGRA_GPIO_H_ */