leon2.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /* LEON2 header file. LEON2 is a SOC processor.
  2. *
  3. * (C) Copyright 2008
  4. * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
  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. */
  22. #ifndef __LEON2_H__
  23. #define __LEON2_H__
  24. #ifdef CONFIG_LEON2
  25. /* LEON 2 I/O register definitions */
  26. #define LEON2_PREGS 0x80000000
  27. #define LEON2_MCFG1 0x00
  28. #define LEON2_MCFG2 0x04
  29. #define LEON2_ECTRL 0x08
  30. #define LEON2_FADDR 0x0C
  31. #define LEON2_MSTAT 0x10
  32. #define LEON2_CCTRL 0x14
  33. #define LEON2_PWDOWN 0x18
  34. #define LEON2_WPROT1 0x1C
  35. #define LEON2_WPROT2 0x20
  36. #define LEON2_LCONF 0x24
  37. #define LEON2_TCNT0 0x40
  38. #define LEON2_TRLD0 0x44
  39. #define LEON2_TCTRL0 0x48
  40. #define LEON2_TCNT1 0x50
  41. #define LEON2_TRLD1 0x54
  42. #define LEON2_TCTRL1 0x58
  43. #define LEON2_SCNT 0x60
  44. #define LEON2_SRLD 0x64
  45. #define LEON2_UART0 0x70
  46. #define LEON2_UDATA0 0x70
  47. #define LEON2_USTAT0 0x74
  48. #define LEON2_UCTRL0 0x78
  49. #define LEON2_USCAL0 0x7C
  50. #define LEON2_UART1 0x80
  51. #define LEON2_UDATA1 0x80
  52. #define LEON2_USTAT1 0x84
  53. #define LEON2_UCTRL1 0x88
  54. #define LEON2_USCAL1 0x8C
  55. #define LEON2_IMASK 0x90
  56. #define LEON2_IPEND 0x94
  57. #define LEON2_IFORCE 0x98
  58. #define LEON2_ICLEAR 0x9C
  59. #define LEON2_IOREG 0xA0
  60. #define LEON2_IODIR 0xA4
  61. #define LEON2_IOICONF 0xA8
  62. #define LEON2_IPEND2 0xB0
  63. #define LEON2_IMASK2 0xB4
  64. #define LEON2_ISTAT2 0xB8
  65. #define LEON2_ICLEAR2 0xBC
  66. #ifndef __ASSEMBLER__
  67. /*
  68. * Structure for LEON memory mapped registers.
  69. *
  70. * Source: Section 6.1 - On-chip registers
  71. *
  72. * NOTE: There is only one of these structures per CPU, its base address
  73. * is 0x80000000, and the variable LEON_REG is placed there by the
  74. * linkcmds file.
  75. */
  76. typedef struct {
  77. volatile unsigned int Memory_Config_1;
  78. volatile unsigned int Memory_Config_2;
  79. volatile unsigned int Edac_Control;
  80. volatile unsigned int Failed_Address;
  81. volatile unsigned int Memory_Status;
  82. volatile unsigned int Cache_Control;
  83. volatile unsigned int Power_Down;
  84. volatile unsigned int Write_Protection_1;
  85. volatile unsigned int Write_Protection_2;
  86. volatile unsigned int Leon_Configuration;
  87. volatile unsigned int dummy2;
  88. volatile unsigned int dummy3;
  89. volatile unsigned int dummy4;
  90. volatile unsigned int dummy5;
  91. volatile unsigned int dummy6;
  92. volatile unsigned int dummy7;
  93. volatile unsigned int Timer_Counter_1;
  94. volatile unsigned int Timer_Reload_1;
  95. volatile unsigned int Timer_Control_1;
  96. volatile unsigned int Watchdog;
  97. volatile unsigned int Timer_Counter_2;
  98. volatile unsigned int Timer_Reload_2;
  99. volatile unsigned int Timer_Control_2;
  100. volatile unsigned int dummy8;
  101. volatile unsigned int Scaler_Counter;
  102. volatile unsigned int Scaler_Reload;
  103. volatile unsigned int dummy9;
  104. volatile unsigned int dummy10;
  105. volatile unsigned int UART_Channel_1;
  106. volatile unsigned int UART_Status_1;
  107. volatile unsigned int UART_Control_1;
  108. volatile unsigned int UART_Scaler_1;
  109. volatile unsigned int UART_Channel_2;
  110. volatile unsigned int UART_Status_2;
  111. volatile unsigned int UART_Control_2;
  112. volatile unsigned int UART_Scaler_2;
  113. volatile unsigned int Interrupt_Mask;
  114. volatile unsigned int Interrupt_Pending;
  115. volatile unsigned int Interrupt_Force;
  116. volatile unsigned int Interrupt_Clear;
  117. volatile unsigned int PIO_Data;
  118. volatile unsigned int PIO_Direction;
  119. volatile unsigned int PIO_Interrupt;
  120. } LEON2_regs;
  121. typedef struct {
  122. volatile unsigned int UART_Channel;
  123. volatile unsigned int UART_Status;
  124. volatile unsigned int UART_Control;
  125. volatile unsigned int UART_Scaler;
  126. } LEON2_Uart_regs;
  127. #endif
  128. /*
  129. * The following constants are intended to be used ONLY in assembly
  130. * language files.
  131. *
  132. * NOTE: The intended style of usage is to load the address of LEON REGS
  133. * into a register and then use these as displacements from
  134. * that register.
  135. */
  136. #define LEON_REG_MEMCFG1_OFFSET 0x00
  137. #define LEON_REG_MEMCFG2_OFFSET 0x04
  138. #define LEON_REG_EDACCTRL_OFFSET 0x08
  139. #define LEON_REG_FAILADDR_OFFSET 0x0C
  140. #define LEON_REG_MEMSTATUS_OFFSET 0x10
  141. #define LEON_REG_CACHECTRL_OFFSET 0x14
  142. #define LEON_REG_POWERDOWN_OFFSET 0x18
  143. #define LEON_REG_WRITEPROT1_OFFSET 0x1C
  144. #define LEON_REG_WRITEPROT2_OFFSET 0x20
  145. #define LEON_REG_LEONCONF_OFFSET 0x24
  146. #define LEON_REG_UNIMPLEMENTED_2_OFFSET 0x28
  147. #define LEON_REG_UNIMPLEMENTED_3_OFFSET 0x2C
  148. #define LEON_REG_UNIMPLEMENTED_4_OFFSET 0x30
  149. #define LEON_REG_UNIMPLEMENTED_5_OFFSET 0x34
  150. #define LEON_REG_UNIMPLEMENTED_6_OFFSET 0x38
  151. #define LEON_REG_UNIMPLEMENTED_7_OFFSET 0x3C
  152. #define LEON_REG_TIMERCNT1_OFFSET 0x40
  153. #define LEON_REG_TIMERLOAD1_OFFSET 0x44
  154. #define LEON_REG_TIMERCTRL1_OFFSET 0x48
  155. #define LEON_REG_WDOG_OFFSET 0x4C
  156. #define LEON_REG_TIMERCNT2_OFFSET 0x50
  157. #define LEON_REG_TIMERLOAD2_OFFSET 0x54
  158. #define LEON_REG_TIMERCTRL2_OFFSET 0x58
  159. #define LEON_REG_UNIMPLEMENTED_8_OFFSET 0x5C
  160. #define LEON_REG_SCALERCNT_OFFSET 0x60
  161. #define LEON_REG_SCALER_LOAD_OFFSET 0x64
  162. #define LEON_REG_UNIMPLEMENTED_9_OFFSET 0x68
  163. #define LEON_REG_UNIMPLEMENTED_10_OFFSET 0x6C
  164. #define LEON_REG_UARTDATA1_OFFSET 0x70
  165. #define LEON_REG_UARTSTATUS1_OFFSET 0x74
  166. #define LEON_REG_UARTCTRL1_OFFSET 0x78
  167. #define LEON_REG_UARTSCALER1_OFFSET 0x7C
  168. #define LEON_REG_UARTDATA2_OFFSET 0x80
  169. #define LEON_REG_UARTSTATUS2_OFFSET 0x84
  170. #define LEON_REG_UARTCTRL2_OFFSET 0x88
  171. #define LEON_REG_UARTSCALER2_OFFSET 0x8C
  172. #define LEON_REG_IRQMASK_OFFSET 0x90
  173. #define LEON_REG_IRQPEND_OFFSET 0x94
  174. #define LEON_REG_IRQFORCE_OFFSET 0x98
  175. #define LEON_REG_IRQCLEAR_OFFSET 0x9C
  176. #define LEON_REG_PIODATA_OFFSET 0xA0
  177. #define LEON_REG_PIODIR_OFFSET 0xA4
  178. #define LEON_REG_PIOIRQ_OFFSET 0xA8
  179. #define LEON_REG_SIM_RAM_SIZE_OFFSET 0xF4
  180. #define LEON_REG_SIM_ROM_SIZE_OFFSET 0xF8
  181. /*
  182. * Interrupt Sources
  183. *
  184. * The interrupt source numbers directly map to the trap type and to
  185. * the bits used in the Interrupt Clear, Interrupt Force, Interrupt Mask,
  186. * and the Interrupt Pending Registers.
  187. */
  188. #define LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR 1
  189. #define LEON_INTERRUPT_UART_1_RX_TX 2
  190. #define LEON_INTERRUPT_UART_0_RX_TX 3
  191. #define LEON_INTERRUPT_EXTERNAL_0 4
  192. #define LEON_INTERRUPT_EXTERNAL_1 5
  193. #define LEON_INTERRUPT_EXTERNAL_2 6
  194. #define LEON_INTERRUPT_EXTERNAL_3 7
  195. #define LEON_INTERRUPT_TIMER1 8
  196. #define LEON_INTERRUPT_TIMER2 9
  197. #define LEON_INTERRUPT_EMPTY1 10
  198. #define LEON_INTERRUPT_EMPTY2 11
  199. #define LEON_INTERRUPT_OPEN_ETH 12
  200. #define LEON_INTERRUPT_EMPTY4 13
  201. #define LEON_INTERRUPT_EMPTY5 14
  202. #define LEON_INTERRUPT_EMPTY6 15
  203. /* Timer Bits */
  204. #define LEON2_TIMER_CTRL_EN 0x1 /* Timer enable */
  205. #define LEON2_TIMER_CTRL_RS 0x2 /* Timer reStart */
  206. #define LEON2_TIMER_CTRL_LD 0x4 /* Timer reLoad */
  207. #define LEON2_TIMER1_IRQNO 8 /* Timer 1 IRQ number */
  208. #define LEON2_TIMER2_IRQNO 9 /* Timer 2 IRQ number */
  209. #define LEON2_TIMER1_IE (1<<LEON2_TIMER1_IRQNO) /* Timer 1 interrupt enable */
  210. #define LEON2_TIMER2_IE (1<<LEON2_TIMER2_IRQNO) /* Timer 2 interrupt enable */
  211. /* UART bits */
  212. #define LEON2_UART_CTRL_RE 1 /* UART Receiver enable */
  213. #define LEON2_UART_CTRL_TE 2 /* UART Transmitter enable */
  214. #define LEON2_UART_CTRL_RI 4 /* UART Receiver Interrupt enable */
  215. #define LEON2_UART_CTRL_TI 8 /* UART Transmitter Interrupt enable */
  216. #define LEON2_UART_CTRL_DBG (1<<11) /* Debug Bit used by GRMON */
  217. #define LEON2_UART_STAT_DR 1 /* UART Data Ready */
  218. #define LEON2_UART_STAT_TSE 2 /* UART Transmit Shift Reg empty */
  219. #define LEON2_UART_STAT_THE 4 /* UART Transmit Hold Reg empty */
  220. #else
  221. #error Include LEON2 header file only if LEON2 processor
  222. #endif
  223. #endif