leon_amba.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. *Copyright (C) 2004 Konrad Eisele ([email protected],[email protected]), Gaisler Research
  4. *Copyright (C) 2004 Stefan Holst ([email protected]), Uni-Stuttgart
  5. *Copyright (C) 2009 Daniel Hellstrom ([email protected]),Konrad Eisele ([email protected]) Aeroflex Gaisler AB
  6. */
  7. #ifndef LEON_AMBA_H_INCLUDE
  8. #define LEON_AMBA_H_INCLUDE
  9. #ifndef __ASSEMBLY__
  10. struct amba_prom_registers {
  11. unsigned int phys_addr; /* The physical address of this register */
  12. unsigned int reg_size; /* How many bytes does this register take up? */
  13. };
  14. #endif
  15. /*
  16. * The following defines the bits in the LEON UART Status Registers.
  17. */
  18. #define LEON_REG_UART_STATUS_DR 0x00000001 /* Data Ready */
  19. #define LEON_REG_UART_STATUS_TSE 0x00000002 /* TX Send Register Empty */
  20. #define LEON_REG_UART_STATUS_THE 0x00000004 /* TX Hold Register Empty */
  21. #define LEON_REG_UART_STATUS_BR 0x00000008 /* Break Error */
  22. #define LEON_REG_UART_STATUS_OE 0x00000010 /* RX Overrun Error */
  23. #define LEON_REG_UART_STATUS_PE 0x00000020 /* RX Parity Error */
  24. #define LEON_REG_UART_STATUS_FE 0x00000040 /* RX Framing Error */
  25. #define LEON_REG_UART_STATUS_ERR 0x00000078 /* Error Mask */
  26. /*
  27. * The following defines the bits in the LEON UART Ctrl Registers.
  28. */
  29. #define LEON_REG_UART_CTRL_RE 0x00000001 /* Receiver enable */
  30. #define LEON_REG_UART_CTRL_TE 0x00000002 /* Transmitter enable */
  31. #define LEON_REG_UART_CTRL_RI 0x00000004 /* Receiver interrupt enable */
  32. #define LEON_REG_UART_CTRL_TI 0x00000008 /* Transmitter irq */
  33. #define LEON_REG_UART_CTRL_PS 0x00000010 /* Parity select */
  34. #define LEON_REG_UART_CTRL_PE 0x00000020 /* Parity enable */
  35. #define LEON_REG_UART_CTRL_FL 0x00000040 /* Flow control enable */
  36. #define LEON_REG_UART_CTRL_LB 0x00000080 /* Loop Back enable */
  37. #define LEON3_GPTIMER_EN 1
  38. #define LEON3_GPTIMER_RL 2
  39. #define LEON3_GPTIMER_LD 4
  40. #define LEON3_GPTIMER_IRQEN 8
  41. #define LEON3_GPTIMER_SEPIRQ 8
  42. #define LEON3_GPTIMER_TIMERS 0x7
  43. #define LEON23_REG_TIMER_CONTROL_EN 0x00000001 /* 1 = enable counting */
  44. /* 0 = hold scalar and counter */
  45. #define LEON23_REG_TIMER_CONTROL_RL 0x00000002 /* 1 = reload at 0 */
  46. /* 0 = stop at 0 */
  47. #define LEON23_REG_TIMER_CONTROL_LD 0x00000004 /* 1 = load counter */
  48. /* 0 = no function */
  49. #define LEON23_REG_TIMER_CONTROL_IQ 0x00000008 /* 1 = irq enable */
  50. /* 0 = no function */
  51. /*
  52. * The following defines the bits in the LEON PS/2 Status Registers.
  53. */
  54. #define LEON_REG_PS2_STATUS_DR 0x00000001 /* Data Ready */
  55. #define LEON_REG_PS2_STATUS_PE 0x00000002 /* Parity error */
  56. #define LEON_REG_PS2_STATUS_FE 0x00000004 /* Framing error */
  57. #define LEON_REG_PS2_STATUS_KI 0x00000008 /* Keyboard inhibit */
  58. #define LEON_REG_PS2_STATUS_RF 0x00000010 /* RX buffer full */
  59. #define LEON_REG_PS2_STATUS_TF 0x00000020 /* TX buffer full */
  60. /*
  61. * The following defines the bits in the LEON PS/2 Ctrl Registers.
  62. */
  63. #define LEON_REG_PS2_CTRL_RE 0x00000001 /* Receiver enable */
  64. #define LEON_REG_PS2_CTRL_TE 0x00000002 /* Transmitter enable */
  65. #define LEON_REG_PS2_CTRL_RI 0x00000004 /* Keyboard receive irq */
  66. #define LEON_REG_PS2_CTRL_TI 0x00000008 /* Keyboard transmit irq */
  67. #define LEON3_IRQMPSTATUS_CPUNR 28
  68. #define LEON3_IRQMPSTATUS_BROADCAST 27
  69. #define GPTIMER_CONFIG_IRQNT(a) (((a) >> 3) & 0x1f)
  70. #define GPTIMER_CONFIG_ISSEP(a) ((a) & (1 << 8))
  71. #define GPTIMER_CONFIG_NTIMERS(a) ((a) & (0x7))
  72. #define LEON3_GPTIMER_CTRL_PENDING 0x10
  73. #define LEON3_GPTIMER_CONFIG_NRTIMERS(c) ((c)->config & 0x7)
  74. #define LEON3_GPTIMER_CTRL_ISPENDING(r) (((r)&LEON3_GPTIMER_CTRL_PENDING) ? 1 : 0)
  75. #ifndef __ASSEMBLY__
  76. struct leon3_irqctrl_regs_map {
  77. u32 ilevel;
  78. u32 ipend;
  79. u32 iforce;
  80. u32 iclear;
  81. u32 mpstatus;
  82. u32 mpbroadcast;
  83. u32 notused02;
  84. u32 notused03;
  85. u32 ampctrl;
  86. u32 icsel[2];
  87. u32 notused13;
  88. u32 notused20;
  89. u32 notused21;
  90. u32 notused22;
  91. u32 notused23;
  92. u32 mask[16];
  93. u32 force[16];
  94. /* Extended IRQ registers */
  95. u32 intid[16]; /* 0xc0 */
  96. u32 unused[(0x1000-0x100)/4];
  97. };
  98. struct leon3_apbuart_regs_map {
  99. u32 data;
  100. u32 status;
  101. u32 ctrl;
  102. u32 scaler;
  103. };
  104. struct leon3_gptimerelem_regs_map {
  105. u32 val;
  106. u32 rld;
  107. u32 ctrl;
  108. u32 unused;
  109. };
  110. struct leon3_gptimer_regs_map {
  111. u32 scalar;
  112. u32 scalar_reload;
  113. u32 config;
  114. u32 unused;
  115. struct leon3_gptimerelem_regs_map e[8];
  116. };
  117. /*
  118. * Types and structure used for AMBA Plug & Play bus scanning
  119. */
  120. #define AMBA_MAXAPB_DEVS 64
  121. #define AMBA_MAXAPB_DEVS_PERBUS 16
  122. struct amba_device_table {
  123. int devnr; /* number of devices on AHB or APB bus */
  124. unsigned int *addr[16]; /* addresses to the devices configuration tables */
  125. unsigned int allocbits[1]; /* 0=unallocated, 1=allocated driver */
  126. };
  127. struct amba_apbslv_device_table {
  128. int devnr; /* number of devices on AHB or APB bus */
  129. unsigned int *addr[AMBA_MAXAPB_DEVS]; /* addresses to the devices configuration tables */
  130. unsigned int apbmst[AMBA_MAXAPB_DEVS]; /* apb master if a entry is a apb slave */
  131. unsigned int apbmstidx[AMBA_MAXAPB_DEVS]; /* apb master idx if a entry is a apb slave */
  132. unsigned int allocbits[4]; /* 0=unallocated, 1=allocated driver */
  133. };
  134. struct amba_confarea_type {
  135. struct amba_confarea_type *next;/* next bus in chain */
  136. struct amba_device_table ahbmst;
  137. struct amba_device_table ahbslv;
  138. struct amba_apbslv_device_table apbslv;
  139. unsigned int apbmst;
  140. };
  141. /* collect apb slaves */
  142. struct amba_apb_device {
  143. unsigned int start, irq, bus_id;
  144. struct amba_confarea_type *bus;
  145. };
  146. /* collect ahb slaves */
  147. struct amba_ahb_device {
  148. unsigned int start[4], irq, bus_id;
  149. struct amba_confarea_type *bus;
  150. };
  151. struct device_node;
  152. void _amba_init(struct device_node *dp, struct device_node ***nextp);
  153. extern unsigned long amba_system_id;
  154. extern struct leon3_irqctrl_regs_map *leon3_irqctrl_regs;
  155. extern struct leon3_gptimer_regs_map *leon3_gptimer_regs;
  156. extern struct amba_apb_device leon_percpu_timer_dev[16];
  157. extern int leondebug_irq_disable;
  158. extern int leon_debug_irqout;
  159. extern unsigned long leon3_gptimer_irq;
  160. extern unsigned int sparc_leon_eirq;
  161. #endif /* __ASSEMBLY__ */
  162. #define LEON3_IO_AREA 0xfff00000
  163. #define LEON3_CONF_AREA 0xff000
  164. #define LEON3_AHB_SLAVE_CONF_AREA (1 << 11)
  165. #define LEON3_AHB_CONF_WORDS 8
  166. #define LEON3_APB_CONF_WORDS 2
  167. #define LEON3_AHB_MASTERS 16
  168. #define LEON3_AHB_SLAVES 16
  169. #define LEON3_APB_SLAVES 16
  170. #define LEON3_APBUARTS 8
  171. /* Vendor codes */
  172. #define VENDOR_GAISLER 1
  173. #define VENDOR_PENDER 2
  174. #define VENDOR_ESA 4
  175. #define VENDOR_OPENCORES 8
  176. /* Gaisler Research device id's */
  177. #define GAISLER_LEON3 0x003
  178. #define GAISLER_LEON3DSU 0x004
  179. #define GAISLER_ETHAHB 0x005
  180. #define GAISLER_APBMST 0x006
  181. #define GAISLER_AHBUART 0x007
  182. #define GAISLER_SRCTRL 0x008
  183. #define GAISLER_SDCTRL 0x009
  184. #define GAISLER_APBUART 0x00C
  185. #define GAISLER_IRQMP 0x00D
  186. #define GAISLER_AHBRAM 0x00E
  187. #define GAISLER_GPTIMER 0x011
  188. #define GAISLER_PCITRG 0x012
  189. #define GAISLER_PCISBRG 0x013
  190. #define GAISLER_PCIFBRG 0x014
  191. #define GAISLER_PCITRACE 0x015
  192. #define GAISLER_PCIDMA 0x016
  193. #define GAISLER_AHBTRACE 0x017
  194. #define GAISLER_ETHDSU 0x018
  195. #define GAISLER_PIOPORT 0x01A
  196. #define GAISLER_GRGPIO 0x01A
  197. #define GAISLER_AHBJTAG 0x01c
  198. #define GAISLER_ETHMAC 0x01D
  199. #define GAISLER_AHB2AHB 0x020
  200. #define GAISLER_USBDC 0x021
  201. #define GAISLER_ATACTRL 0x024
  202. #define GAISLER_DDRSPA 0x025
  203. #define GAISLER_USBEHC 0x026
  204. #define GAISLER_USBUHC 0x027
  205. #define GAISLER_I2CMST 0x028
  206. #define GAISLER_SPICTRL 0x02D
  207. #define GAISLER_DDR2SPA 0x02E
  208. #define GAISLER_SPIMCTRL 0x045
  209. #define GAISLER_LEON4 0x048
  210. #define GAISLER_LEON4DSU 0x049
  211. #define GAISLER_AHBSTAT 0x052
  212. #define GAISLER_FTMCTRL 0x054
  213. #define GAISLER_KBD 0x060
  214. #define GAISLER_VGA 0x061
  215. #define GAISLER_SVGA 0x063
  216. #define GAISLER_GRSYSMON 0x066
  217. #define GAISLER_GRACECTRL 0x067
  218. #define GAISLER_L2TIME 0xffd /* internal device: leon2 timer */
  219. #define GAISLER_L2C 0xffe /* internal device: leon2compat */
  220. #define GAISLER_PLUGPLAY 0xfff /* internal device: plug & play configarea */
  221. /* Chip IDs */
  222. #define AEROFLEX_UT699 0x0699
  223. #define LEON4_NEXTREME1 0x0102
  224. #define GAISLER_GR712RC 0x0712
  225. #define amba_vendor(x) (((x) >> 24) & 0xff)
  226. #define amba_device(x) (((x) >> 12) & 0xfff)
  227. #endif