gpio.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2011, Google Inc. All rights reserved.
  3. * See file CREDITS for list of people who contributed to this
  4. * project.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  19. * MA 02111-1307 USA
  20. */
  21. #ifndef _TEGRA2_GPIO_H_
  22. #define _TEGRA2_GPIO_H_
  23. /*
  24. * The Tegra 2x GPIO controller has 222 GPIOs arranged in 8 banks of 4 ports,
  25. * each with 8 GPIOs.
  26. */
  27. #define TEGRA_GPIO_PORTS 4 /* The number of ports per bank */
  28. #define TEGRA_GPIO_BANKS 8 /* The number of banks */
  29. /* GPIO Controller registers for a single bank */
  30. struct gpio_ctlr_bank {
  31. uint gpio_config[TEGRA_GPIO_PORTS];
  32. uint gpio_dir_out[TEGRA_GPIO_PORTS];
  33. uint gpio_out[TEGRA_GPIO_PORTS];
  34. uint gpio_in[TEGRA_GPIO_PORTS];
  35. uint gpio_int_status[TEGRA_GPIO_PORTS];
  36. uint gpio_int_enable[TEGRA_GPIO_PORTS];
  37. uint gpio_int_level[TEGRA_GPIO_PORTS];
  38. uint gpio_int_clear[TEGRA_GPIO_PORTS];
  39. };
  40. struct gpio_ctlr {
  41. struct gpio_ctlr_bank gpio_bank[TEGRA_GPIO_BANKS];
  42. };
  43. #define GPIO_BANK(x) ((x) >> 5)
  44. #define GPIO_PORT(x) (((x) >> 3) & 0x3)
  45. #define GPIO_BIT(x) ((x) & 0x7)
  46. /*
  47. * GPIO_PI3 = Port I = 8, bit = 3.
  48. * Seaboard: used for UART/SPI selection
  49. * Harmony: not used
  50. */
  51. #define GPIO_PI3 ((8 << 3) | 3)
  52. #endif /* TEGRA2_GPIO_H_ */