leon2.h 8.5 KB

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