ar531x.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #ifndef __AR531X_H
  2. #define __AR531X_H
  3. #include <linux/version.h>
  4. #include <asm/cpu-info.h>
  5. #include <ar531x_platform.h>
  6. #include <ar5312/ar5312.h>
  7. #include <ar5315/ar5315.h>
  8. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
  9. extern void (*board_time_init)(void);
  10. #endif
  11. /*
  12. * Atheros CPUs before the AR2315 are using MIPS 4Kc core, later designs are
  13. * using MIPS 4KEc R2 core. This makes it easy to determine the board at runtime.
  14. */
  15. #ifdef CONFIG_ATHEROS_AR5312
  16. #define DO_AR5312(...) \
  17. if (current_cpu_data.cputype != CPU_4KEC) { \
  18. __VA_ARGS__ \
  19. }
  20. #else
  21. #define DO_AR5312(...)
  22. #endif
  23. #ifdef CONFIG_ATHEROS_AR5315
  24. #define DO_AR5315(...) \
  25. if (current_cpu_data.cputype == CPU_4KEC) { \
  26. __VA_ARGS__ \
  27. }
  28. #else
  29. #define DO_AR5315(...)
  30. #endif
  31. #define AR531X_MISC_IRQ_BASE 0x20
  32. #define AR531X_GPIO_IRQ_BASE 0x30
  33. /* Software's idea of interrupts handled by "CPU Interrupt Controller" */
  34. #define AR531X_IRQ_NONE MIPS_CPU_IRQ_BASE+0
  35. #define AR531X_IRQ_CPU_CLOCK MIPS_CPU_IRQ_BASE+7 /* C0_CAUSE: 0x8000 */
  36. /* Miscellaneous interrupts, which share IP6 */
  37. #define AR531X_MISC_IRQ_NONE AR531X_MISC_IRQ_BASE+0
  38. #define AR531X_MISC_IRQ_TIMER AR531X_MISC_IRQ_BASE+1
  39. #define AR531X_MISC_IRQ_AHB_PROC AR531X_MISC_IRQ_BASE+2
  40. #define AR531X_MISC_IRQ_AHB_DMA AR531X_MISC_IRQ_BASE+3
  41. #define AR531X_MISC_IRQ_GPIO AR531X_MISC_IRQ_BASE+4
  42. #define AR531X_MISC_IRQ_UART0 AR531X_MISC_IRQ_BASE+5
  43. #define AR531X_MISC_IRQ_UART0_DMA AR531X_MISC_IRQ_BASE+6
  44. #define AR531X_MISC_IRQ_WATCHDOG AR531X_MISC_IRQ_BASE+7
  45. #define AR531X_MISC_IRQ_LOCAL AR531X_MISC_IRQ_BASE+8
  46. #define AR531X_MISC_IRQ_SPI AR531X_MISC_IRQ_BASE+9
  47. #define AR531X_MISC_IRQ_COUNT 10
  48. /* GPIO Interrupts [0..7], share AR531X_MISC_IRQ_GPIO */
  49. #define AR531X_GPIO_IRQ_NONE AR531X_GPIO_IRQ_BASE+0
  50. #define AR531X_GPIO_IRQ(n) AR531X_GPIO_IRQ_BASE+n
  51. #define AR531X_GPIO_IRQ_COUNT 22
  52. #define sysRegRead(phys) \
  53. (*(volatile u32 *)KSEG1ADDR(phys))
  54. #define sysRegWrite(phys, val) \
  55. ((*(volatile u32 *)KSEG1ADDR(phys)) = (val))
  56. /*
  57. * This is board-specific data that is stored in a "fixed" location in flash.
  58. * It is shared across operating systems, so it should not be changed lightly.
  59. * The main reason we need it is in order to extract the ethernet MAC
  60. * address(es).
  61. */
  62. struct ar531x_boarddata {
  63. u32 magic; /* board data is valid */
  64. #define AR531X_BD_MAGIC 0x35333131 /* "5311", for all 531x platforms */
  65. u16 cksum; /* checksum (starting with BD_REV 2) */
  66. u16 rev; /* revision of this struct */
  67. #define BD_REV 4
  68. char boardName[64]; /* Name of board */
  69. u16 major; /* Board major number */
  70. u16 minor; /* Board minor number */
  71. u32 config; /* Board configuration */
  72. #define BD_ENET0 0x00000001 /* ENET0 is stuffed */
  73. #define BD_ENET1 0x00000002 /* ENET1 is stuffed */
  74. #define BD_UART1 0x00000004 /* UART1 is stuffed */
  75. #define BD_UART0 0x00000008 /* UART0 is stuffed (dma) */
  76. #define BD_RSTFACTORY 0x00000010 /* Reset factory defaults stuffed */
  77. #define BD_SYSLED 0x00000020 /* System LED stuffed */
  78. #define BD_EXTUARTCLK 0x00000040 /* External UART clock */
  79. #define BD_CPUFREQ 0x00000080 /* cpu freq is valid in nvram */
  80. #define BD_SYSFREQ 0x00000100 /* sys freq is set in nvram */
  81. #define BD_WLAN0 0x00000200 /* Enable WLAN0 */
  82. #define BD_MEMCAP 0x00000400 /* CAP SDRAM @ memCap for testing */
  83. #define BD_DISWATCHDOG 0x00000800 /* disable system watchdog */
  84. #define BD_WLAN1 0x00001000 /* Enable WLAN1 (ar5212) */
  85. #define BD_ISCASPER 0x00002000 /* FLAG for AR2312 */
  86. #define BD_WLAN0_2G_EN 0x00004000 /* FLAG for radio0_2G */
  87. #define BD_WLAN0_5G_EN 0x00008000 /* FLAG for radio0_2G */
  88. #define BD_WLAN1_2G_EN 0x00020000 /* FLAG for radio0_2G */
  89. #define BD_WLAN1_5G_EN 0x00040000 /* FLAG for radio0_2G */
  90. u16 resetConfigGpio; /* Reset factory GPIO pin */
  91. u16 sysLedGpio; /* System LED GPIO pin */
  92. u32 cpuFreq; /* CPU core frequency in Hz */
  93. u32 sysFreq; /* System frequency in Hz */
  94. u32 cntFreq; /* Calculated C0_COUNT frequency */
  95. u8 wlan0Mac[6];
  96. u8 enet0Mac[6];
  97. u8 enet1Mac[6];
  98. u16 pciId; /* Pseudo PCIID for common code */
  99. u16 memCap; /* cap bank1 in MB */
  100. /* version 3 */
  101. u8 wlan1Mac[6]; /* (ar5212) */
  102. };
  103. #define BOARD_CONFIG_BUFSZ 0x1000
  104. extern char *board_config, *radio_config;
  105. extern void serial_setup(unsigned long mapbase, unsigned int uartclk);
  106. extern int ar531x_find_config(char *flash_limit);
  107. extern void ar5312_prom_init(void);
  108. extern void ar5312_misc_intr_init(int irq_base);
  109. extern void ar5312_plat_setup(void);
  110. extern asmlinkage void ar5312_irq_dispatch(void);
  111. extern void ar5315_prom_init(void);
  112. extern void ar5315_misc_intr_init(int irq_base);
  113. extern void ar5315_plat_setup(void);
  114. extern asmlinkage void ar5315_irq_dispatch(void);
  115. extern void ar5315_pci_irq(int irq);
  116. static inline u32 sysRegMask(u32 phys, u32 mask, u32 value)
  117. {
  118. u32 reg;
  119. reg = sysRegRead(phys);
  120. reg &= ~mask;
  121. reg |= value & mask;
  122. sysRegWrite(phys, reg);
  123. reg = sysRegRead(phys); /* flush write to the hardware */
  124. return reg;
  125. }
  126. #define AR531X_NUM_GPIO 8
  127. #endif