gpio.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2011, Google Inc. All rights reserved.
  3. * SPDX-License-Identifier: GPL-2.0+
  4. */
  5. #ifndef _TEGRA_GPIO_H_
  6. #define _TEGRA_GPIO_H_
  7. #define TEGRA_GPIOS_PER_PORT 8
  8. #define TEGRA_PORTS_PER_BANK 4
  9. #define MAX_NUM_GPIOS (TEGRA_GPIO_PORTS * TEGRA_GPIO_BANKS * 8)
  10. #define GPIO_NAME_SIZE 20 /* gpio_request max label len */
  11. #define GPIO_BANK(x) ((x) >> 5)
  12. #define GPIO_PORT(x) (((x) >> 3) & 0x3)
  13. #define GPIO_FULLPORT(x) ((x) >> 3)
  14. #define GPIO_BIT(x) ((x) & 0x7)
  15. enum tegra_gpio_init {
  16. TEGRA_GPIO_INIT_IN,
  17. TEGRA_GPIO_INIT_OUT0,
  18. TEGRA_GPIO_INIT_OUT1,
  19. };
  20. struct tegra_gpio_config {
  21. u32 gpio:16;
  22. u32 init:2;
  23. };
  24. /**
  25. * tegra_spl_gpio_direction_output() - set the output value of a GPIO
  26. *
  27. * This function is only used from SPL on seaboard, which needs to enable a
  28. * GPIO to get the UART running. It could be done in U-Boot rather than SPL,
  29. * but for now, this gets it working
  30. */
  31. int tegra_spl_gpio_direction_output(int gpio, int value);
  32. /**
  33. * Configure a list of GPIOs
  34. *
  35. * @param config List of GPIO configurations
  36. * @param len Number of config items in list
  37. */
  38. void gpio_config_table(const struct tegra_gpio_config *config, int len);
  39. #endif /* TEGRA_GPIO_H_ */