portmux.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_PORTMUX_H__
  23. #define __ASM_AVR32_ARCH_PORTMUX_H__
  24. #include <asm/arch/gpio.h>
  25. #define PORTMUX_PORT_A ((void *)PIOA_BASE)
  26. #define PORTMUX_PORT_B ((void *)PIOB_BASE)
  27. #define PORTMUX_PORT_C ((void *)PIOC_BASE)
  28. #define PORTMUX_PORT_D ((void *)PIOD_BASE)
  29. #define PORTMUX_PORT_E ((void *)PIOE_BASE)
  30. void portmux_enable_ebi(unsigned int bus_width, unsigned int addr_width,
  31. unsigned long flags, unsigned long drive_strength);
  32. #define PORTMUX_EBI_CS(x) (1 << (x))
  33. #define PORTMUX_EBI_NAND (1 << 6)
  34. #define PORTMUX_EBI_CF(x) (1 << ((x) + 7))
  35. #define PORTMUX_EBI_NWAIT (1 << 9)
  36. #ifdef AT32AP700x_CHIP_HAS_USART
  37. static inline void portmux_enable_usart0(unsigned long drive_strength)
  38. {
  39. portmux_select_peripheral(PORTMUX_PORT_A, (1 << 8) | (1 << 9),
  40. PORTMUX_FUNC_B, 0);
  41. }
  42. static inline void portmux_enable_usart1(unsigned long drive_strength)
  43. {
  44. portmux_select_peripheral(PORTMUX_PORT_A, (1 << 17) | (1 << 18),
  45. PORTMUX_FUNC_A, 0);
  46. }
  47. static inline void portmux_enable_usart2(unsigned long drive_strength)
  48. {
  49. portmux_select_peripheral(PORTMUX_PORT_B, (1 << 26) | (1 << 27),
  50. PORTMUX_FUNC_B, 0);
  51. }
  52. static inline void portmux_enable_usart3(unsigned long drive_strength)
  53. {
  54. portmux_select_peripheral(PORTMUX_PORT_B, (1 << 17) | (1 << 18),
  55. PORTMUX_FUNC_B, 0);
  56. }
  57. #endif
  58. #ifdef AT32AP700x_CHIP_HAS_MACB
  59. void portmux_enable_macb0(unsigned long flags, unsigned long drive_strength);
  60. void portmux_enable_macb1(unsigned long flags, unsigned long drive_strength);
  61. #define PORTMUX_MACB_RMII (0)
  62. #define PORTMUX_MACB_MII (1 << 0)
  63. #define PORTMUX_MACB_SPEED (1 << 1)
  64. #endif
  65. #ifdef AT32AP700x_CHIP_HAS_MMCI
  66. void portmux_enable_mmci(unsigned int slot, unsigned long flags,
  67. unsigned long drive_strength);
  68. #define PORTMUX_MMCI_4BIT (1 << 0)
  69. #define PORTMUX_MMCI_8BIT (PORTMUX_MMCI_4BIT | (1 << 1))
  70. #define PORTMUX_MMCI_EXT_PULLUP (1 << 2)
  71. #endif
  72. #ifdef AT32AP700x_CHIP_HAS_SPI
  73. void portmux_enable_spi0(unsigned long cs_mask, unsigned long drive_strength);
  74. void portmux_enable_spi1(unsigned long cs_mask, unsigned long drive_strength);
  75. #endif
  76. #endif /* __ASM_AVR32_ARCH_PORTMUX_H__ */