gpio.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (C) 2006, 2008 Atmel Corporation
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __ASM_AVR32_ARCH_GPIO_H__
  23. #define __ASM_AVR32_ARCH_GPIO_H__
  24. #include <asm/arch/chip-features.h>
  25. #include <asm/arch/memory-map.h>
  26. #define NR_GPIO_CONTROLLERS 5
  27. /*
  28. * Pin numbers identifying specific GPIO pins on the chip.
  29. */
  30. #define GPIO_PIOA_BASE (0)
  31. #define GPIO_PIOB_BASE (GPIO_PIOA_BASE + 32)
  32. #define GPIO_PIOC_BASE (GPIO_PIOB_BASE + 32)
  33. #define GPIO_PIOD_BASE (GPIO_PIOC_BASE + 32)
  34. #define GPIO_PIOE_BASE (GPIO_PIOD_BASE + 32)
  35. #define GPIO_PIN_PA(x) (GPIO_PIOA_BASE + (x))
  36. #define GPIO_PIN_PB(x) (GPIO_PIOB_BASE + (x))
  37. #define GPIO_PIN_PC(x) (GPIO_PIOC_BASE + (x))
  38. #define GPIO_PIN_PD(x) (GPIO_PIOD_BASE + (x))
  39. #define GPIO_PIN_PE(x) (GPIO_PIOE_BASE + (x))
  40. static inline void *pio_pin_to_port(unsigned int pin)
  41. {
  42. switch (pin >> 5) {
  43. case 0:
  44. return (void *)PIOA_BASE;
  45. case 1:
  46. return (void *)PIOB_BASE;
  47. case 2:
  48. return (void *)PIOC_BASE;
  49. case 3:
  50. return (void *)PIOD_BASE;
  51. case 4:
  52. return (void *)PIOE_BASE;
  53. default:
  54. return NULL;
  55. }
  56. }
  57. #include <asm/arch-common/portmux-pio.h>
  58. #endif /* __ASM_AVR32_ARCH_GPIO_H__ */