lh7a40x.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /*
  2. * See file CREDITS for list of people who contributed to this
  3. * project.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  18. * MA 02111-1307 USA
  19. */
  20. /*
  21. * lh7a40x SoC series common interface
  22. */
  23. #ifndef __LH7A40X_H__
  24. #define __LH7A40X_H__
  25. /* (SMC) Static Memory Controller (usersguide 4.2.1) */
  26. typedef struct {
  27. volatile u32 attib;
  28. volatile u32 com;
  29. volatile u32 io;
  30. volatile u32 rsvd1;
  31. } /*__attribute__((__packed__))*/ lh7a40x_pccard_t;
  32. typedef struct {
  33. volatile u32 bcr[8];
  34. lh7a40x_pccard_t pccard[2];
  35. volatile u32 pcmciacon;
  36. } /*__attribute__((__packed__))*/ lh7a40x_smc_t;
  37. #define LH7A40X_SMC_BASE (0x80002000)
  38. #define LH7A40X_SMC_PTR(name) lh7a40x_smc_t* name = (lh7a40x_smc_t*) LH7A40X_SMC_BASE
  39. /* (SDMC) Synchronous Dynamic Ram Controller (usersguide 5.3.1) */
  40. typedef struct {
  41. volatile u32 rsvd1;
  42. volatile u32 gblcnfg;
  43. volatile u32 rfshtmr;
  44. volatile u32 bootstat;
  45. volatile u32 sdcsc[4];
  46. } /*__attribute__((__packed__))*/ lh7a40x_sdmc_t;
  47. #define LH7A40X_SDMC_BASE (0x80002400)
  48. #define LH7A40X_SDMC_PTR(name) lh7a40x_sdmc_t* name = (lh7a40x_sdmc_t*) LH7A40X_SDMC_BASE
  49. /* (CSC) Clock and State Controller (userguide 6.2.1) */
  50. typedef struct {
  51. volatile u32 pwrsr;
  52. volatile u32 pwrcnt;
  53. volatile u32 halt;
  54. volatile u32 stby;
  55. volatile u32 bleoi;
  56. volatile u32 mceoi;
  57. volatile u32 teoi;
  58. volatile u32 stfclr;
  59. volatile u32 clkset;
  60. volatile u32 scrreg[2];
  61. volatile u32 rsvd1;
  62. volatile u32 usbreset;
  63. } /*__attribute__((__packed__))*/ lh7a40x_csc_t;
  64. #define LH7A40X_STPWR_BASE (0x80000400)
  65. #define LH7A40X_CSC_PTR(name) lh7a40x_csc_t* name = (lh7a40x_csc_t*) LH7A40X_STPWR_BASE
  66. #define CLKSET_SMCROM (0x01000000)
  67. #define CLKSET_PS (0x000C0000)
  68. #define CLKSET_PS_0 (0x00000000)
  69. #define CLKSET_PS_1 (0x00040000)
  70. #define CLKSET_PS_2 (0x00080000)
  71. #define CLKSET_PS_3 (0x000C0000)
  72. #define CLKSET_PCLKDIV (0x00030000)
  73. #define CLKSET_PCLKDIV_2 (0x00000000)
  74. #define CLKSET_PCLKDIV_4 (0x00010000)
  75. #define CLKSET_PCLKDIV_8 (0x00020000)
  76. #define CLKSET_MAINDIV2 (0x0000f800)
  77. #define CLKSET_MAINDIV1 (0x00000780)
  78. #define CLKSET_PREDIV (0x0000007C)
  79. #define CLKSET_HCLKDIV (0x00000003)
  80. /* (WDT) Watchdog Timer (userguide 11.2.1) */
  81. typedef struct {
  82. volatile u32 ctl;
  83. volatile u32 rst;
  84. volatile u32 status;
  85. volatile u32 count[4];
  86. } /*__attribute__((__packed__))*/ lh7a40x_wdt_t;
  87. #define LH7A40X_WDT_BASE (0x80001400)
  88. #define LH7A40X_WDT_PTR(name) lh7a40x_wdt_t* name = (lh7a40x_wdt_t*) LH7A40X_WDT_BASE
  89. /* (RTC) Real Time Clock (lh7a400 userguide 12.2.1, lh7a404 userguide 13.2.1) */
  90. typedef struct {
  91. volatile u32 rtcdr;
  92. volatile u32 rtclr;
  93. volatile u32 rtcmr;
  94. volatile u32 unk1;
  95. volatile u32 rtcstat_eoi;
  96. volatile u32 rtccr;
  97. volatile u32 rsvd1[58];
  98. } /*__attribute__((__packed__))*/ lh7a40x_rtc_t;
  99. #define LH7A40X_RTC_BASE (0x80000D00)
  100. #define LH7A40X_RTC_PTR(name) lh7a40x_rtc_t* name = (lh7a40x_rtc_t*) LH7A40X_RTC_BASE
  101. /* Timers (lh7a400 userguide 13.2.1, lh7a404 userguide 11.2.1) */
  102. typedef struct {
  103. volatile u32 load;
  104. volatile u32 value;
  105. volatile u32 control;
  106. volatile u32 tceoi;
  107. } /*__attribute__((__packed__))*/ lh7a40x_timer_t;
  108. typedef struct {
  109. lh7a40x_timer_t timer1;
  110. volatile u32 rsvd1[4];
  111. lh7a40x_timer_t timer2;
  112. volatile u32 unk1[4];
  113. volatile u32 bzcon;
  114. volatile u32 unk2[15];
  115. lh7a40x_timer_t timer3;
  116. /*volatile u32 rsvd2;*/
  117. } /*__attribute__((__packed__))*/ lh7a40x_timers_t;
  118. #define LH7A40X_TIMERS_BASE (0x80000C00)
  119. #define LH7A40X_TIMERS_PTR(name) lh7a40x_timers_t* name = (lh7a40x_timers_t*) LH7A40X_TIMERS_BASE
  120. #define TIMER_EN (0x00000080)
  121. #define TIMER_PER (0x00000040)
  122. #define TIMER_FREE (0x00000000)
  123. #define TIMER_CLK508K (0x00000008)
  124. #define TIMER_CLK2K (0x00000000)
  125. /* (SSP) Sychronous Serial Ports (lh7a400 userguide 14.2.1, lh7a404 userguide 14.2.1) */
  126. typedef struct {
  127. volatile u32 cr0;
  128. volatile u32 cr1;
  129. volatile u32 irr_roeoi;
  130. volatile u32 dr;
  131. volatile u32 cpr;
  132. volatile u32 sr;
  133. /*volatile u32 rsvd1[58];*/
  134. } /*__attribute__((__packed__))*/ lh7a40x_ssp_t;
  135. #define LH7A40X_SSP_BASE (0x80000B00)
  136. #define LH7A40X_SSP_PTR(name) lh7a40x_ssp_t* name = (lh7a40x_ssp_t*) LH7A40X_SSP_BASE
  137. /* (UART) Universal Asychronous Receiver/Transmitter (lh7a400 userguide 15.2.1, lh7a404 userguide 15.2.1) */
  138. typedef struct {
  139. volatile u32 data;
  140. volatile u32 fcon;
  141. volatile u32 brcon;
  142. volatile u32 con;
  143. volatile u32 status;
  144. volatile u32 rawisr;
  145. volatile u32 inten;
  146. volatile u32 isr;
  147. volatile u32 rsvd1[56];
  148. } /*__attribute__((__packed__))*/ lh7a40x_uart_t;
  149. #define LH7A40X_UART_BASE (0x80000600)
  150. #define LH7A40X_UART_PTR(name,n) \
  151. lh7a40x_uart_t* name = (lh7a40x_uart_t*) (LH7A40X_UART_BASE + ((n-1) * sizeof(lh7a40x_uart_t)))
  152. #define UART_BE (0x00000800) /* the rx error bits */
  153. #define UART_OE (0x00000400)
  154. #define UART_PE (0x00000200)
  155. #define UART_FE (0x00000100)
  156. #define UART_WLEN (0x00000060) /* fcon bits */
  157. #define UART_WLEN_8 (0x00000060)
  158. #define UART_WLEN_7 (0x00000040)
  159. #define UART_WLEN_6 (0x00000020)
  160. #define UART_WLEN_5 (0x00000000)
  161. #define UART_FEN (0x00000010)
  162. #define UART_STP2 (0x00000008)
  163. #define UART_STP2_2 (0x00000008)
  164. #define UART_STP2_1 (0x00000000)
  165. #define UART_EPS (0x00000004)
  166. #define UART_EPS_EVEN (0x00000004)
  167. #define UART_EPS_ODD (0x00000000)
  168. #define UART_PEN (0x00000002)
  169. #define UART_BRK (0x00000001)
  170. #define UART_BAUDDIV (0x0000ffff) /* brcon bits */
  171. #define UART_SIRBD (0x00000080) /* con bits */
  172. #define UART_LBE (0x00000040)
  173. #define UART_MXP (0x00000020)
  174. #define UART_TXP (0x00000010)
  175. #define UART_RXP (0x00000008)
  176. #define UART_SIRLP (0x00000004)
  177. #define UART_SIRD (0x00000002)
  178. #define UART_EN (0x00000001)
  179. #define UART_TXFE (0x00000080) /* status bits */
  180. #define UART_RXFF (0x00000040)
  181. #define UART_TXFF (0x00000020)
  182. #define UART_RXFE (0x00000010)
  183. #define UART_BUSY (0x00000008)
  184. #define UART_DCD (0x00000004)
  185. #define UART_DSR (0x00000002)
  186. #define UART_CTS (0x00000001)
  187. #define UART_MSEOI (0xfffffff0) /* rawisr interrupt bits */
  188. #define UART_RTI (0x00000008) /* generic interrupt bits */
  189. #define UART_MI (0x00000004)
  190. #define UART_TI (0x00000002)
  191. #define UART_RI (0x00000001)
  192. /* (GPIO) General Purpose IO and External Interrupts (userguide 16.2.1) */
  193. typedef struct {
  194. volatile u32 pad;
  195. volatile u32 pbd;
  196. volatile u32 pcd;
  197. volatile u32 pdd;
  198. volatile u32 padd;
  199. volatile u32 pbdd;
  200. volatile u32 pcdd;
  201. volatile u32 pddd;
  202. volatile u32 ped;
  203. volatile u32 pedd;
  204. volatile u32 kbdctl;
  205. volatile u32 pinmux;
  206. volatile u32 pfd;
  207. volatile u32 pfdd;
  208. volatile u32 pgd;
  209. volatile u32 pgdd;
  210. volatile u32 phd;
  211. volatile u32 phdd;
  212. volatile u32 rsvd1;
  213. volatile u32 inttype1;
  214. volatile u32 inttype2;
  215. volatile u32 gpiofeoi;
  216. volatile u32 gpiointen;
  217. volatile u32 intstatus;
  218. volatile u32 rawintstatus;
  219. volatile u32 gpiodb;
  220. volatile u32 papd;
  221. volatile u32 pbpd;
  222. volatile u32 pcpd;
  223. volatile u32 pdpd;
  224. volatile u32 pepd;
  225. volatile u32 pfpd;
  226. volatile u32 pgpd;
  227. volatile u32 phpd;
  228. } /*__attribute__((__packed__))*/ lh7a40x_gpioint_t;
  229. #define LH7A40X_GPIOINT_BASE (0x80000E00)
  230. #define LH7A40X_GPIOINT_PTR(name) lh7a40x_gpioint_t* name = (lh7a40x_gpioint_t*) LH7A40X_GPIOINT_BASE
  231. /* Embedded SRAM */
  232. #define CFG_SRAM_BASE (0xB0000000)
  233. #define CFG_SRAM_SIZE (80*1024) /* 80kB */
  234. #endif /* __LH7A40X_H__ */