]> git.sur5r.net Git - u-boot/blob - include/lh7a40x.h
081009c32cc78d91bfdb0424ffcd8d22c45273af
[u-boot] / include / lh7a40x.h
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 /*
22  * lh7a40x SoC series common interface
23  */
24
25 #ifndef __LH7A40X_H__
26 #define __LH7A40X_H__
27
28 /* (SMC) Static Memory Controller (usersguide 4.2.1) */
29 typedef struct {
30         volatile u32  attib;
31         volatile u32  com;
32         volatile u32  io;
33         volatile u32  rsvd1;
34 } /*__attribute__((__packed__))*/ lh7a40x_pccard_t;
35
36 typedef struct {
37         volatile u32      bcr[8];
38         lh7a40x_pccard_t  pccard[2];
39         volatile u32      pcmciacon;
40 } /*__attribute__((__packed__))*/ lh7a40x_smc_t;
41 #define LH7A40X_SMC_BASE    (0x80002000)
42 #define LH7A40X_SMC_PTR(name)  lh7a40x_smc_t* name = (lh7a40x_smc_t*) LH7A40X_SMC_BASE
43
44 /* (SDMC) Synchronous Dynamic Ram Controller (usersguide 5.3.1) */
45 typedef struct {
46         volatile u32  rsvd1;
47         volatile u32  gblcnfg;
48         volatile u32  rfshtmr;
49         volatile u32  bootstat;
50         volatile u32  sdcsc[4];
51 } /*__attribute__((__packed__))*/ lh7a40x_sdmc_t;
52 #define LH7A40X_SDMC_BASE    (0x80002400)
53 #define LH7A40X_SDMC_PTR(name)  lh7a40x_sdmc_t* name = (lh7a40x_sdmc_t*) LH7A40X_SDMC_BASE
54
55 /* (CSC) Clock and State Controller (userguide 6.2.1) */
56 typedef struct {
57         volatile u32  pwrsr;
58         volatile u32  pwrcnt;
59         volatile u32  halt;
60         volatile u32  stby;
61         volatile u32  bleoi;
62         volatile u32  mceoi;
63         volatile u32  teoi;
64         volatile u32  stfclr;
65         volatile u32  clkset;
66         volatile u32  scrreg[2];
67         volatile u32  rsvd1;
68         volatile u32  usbreset;
69 } /*__attribute__((__packed__))*/ lh7a40x_csc_t;
70 #define LH7A40X_STPWR_BASE  (0x80000400)
71 #define LH7A40X_CSC_PTR(name)  lh7a40x_csc_t* name = (lh7a40x_csc_t*) LH7A40X_STPWR_BASE
72
73 #define CLKSET_SMCROM           (0x01000000)
74 #define CLKSET_PS               (0x000C0000)
75 #define CLKSET_PS_0             (0x00000000)
76 #define CLKSET_PS_1             (0x00040000)
77 #define CLKSET_PS_2             (0x00080000)
78 #define CLKSET_PS_3             (0x000C0000)
79 #define CLKSET_PCLKDIV          (0x00030000)
80 #define CLKSET_PCLKDIV_2        (0x00000000)
81 #define CLKSET_PCLKDIV_4        (0x00010000)
82 #define CLKSET_PCLKDIV_8        (0x00020000)
83 #define CLKSET_MAINDIV2         (0x0000f800)
84 #define CLKSET_MAINDIV1         (0x00000780)
85 #define CLKSET_PREDIV           (0x0000007C)
86 #define CLKSET_HCLKDIV          (0x00000003)
87
88 /* (WDT) Watchdog Timer (userguide 11.2.1) */
89 typedef struct {
90         volatile u32  ctl;
91         volatile u32  rst;
92         volatile u32  status;
93         volatile u32  count[4];
94 } /*__attribute__((__packed__))*/ lh7a40x_wdt_t;
95 #define LH7A40X_WDT_BASE    (0x80001400)
96 #define LH7A40X_WDT_PTR(name)  lh7a40x_wdt_t* name = (lh7a40x_wdt_t*) LH7A40X_WDT_BASE
97
98 /* (RTC) Real Time Clock (lh7a400 userguide 12.2.1, lh7a404 userguide 13.2.1) */
99 typedef struct {
100         volatile u32  rtcdr;
101         volatile u32  rtclr;
102         volatile u32  rtcmr;
103         volatile u32  unk1;
104         volatile u32  rtcstat_eoi;
105         volatile u32  rtccr;
106         volatile u32  rsvd1[58];
107 } /*__attribute__((__packed__))*/ lh7a40x_rtc_t;
108 #define LH7A40X_RTC_BASE    (0x80000D00)
109 #define LH7A40X_RTC_PTR(name)  lh7a40x_rtc_t* name = (lh7a40x_rtc_t*) LH7A40X_RTC_BASE
110
111 /* Timers (lh7a400 userguide 13.2.1, lh7a404 userguide 11.2.1) */
112 typedef struct {
113         volatile u32  load;
114         volatile u32  value;
115         volatile u32  control;
116         volatile u32  tceoi;
117 } /*__attribute__((__packed__))*/ lh7a40x_timer_t;
118
119 typedef struct {
120         lh7a40x_timer_t  timer1;
121         volatile u32     rsvd1[4];
122         lh7a40x_timer_t  timer2;
123         volatile u32     unk1[4];
124         volatile u32     bzcon;
125         volatile u32     unk2[15];
126         lh7a40x_timer_t  timer3;
127         /*volatile u32     rsvd2;*/
128 } /*__attribute__((__packed__))*/ lh7a40x_timers_t;
129 #define LH7A40X_TIMERS_BASE    (0x80000C00)
130 #define LH7A40X_TIMERS_PTR(name)  lh7a40x_timers_t* name = (lh7a40x_timers_t*) LH7A40X_TIMERS_BASE
131
132 #define TIMER_EN        (0x00000080)
133 #define TIMER_PER       (0x00000040)
134 #define TIMER_FREE      (0x00000000)
135 #define TIMER_CLK508K   (0x00000008)
136 #define TIMER_CLK2K     (0x00000000)
137
138 /* (SSP) Sychronous Serial Ports (lh7a400 userguide 14.2.1, lh7a404 userguide 14.2.1) */
139 typedef struct {
140         volatile u32  cr0;
141         volatile u32  cr1;
142         volatile u32  irr_roeoi;
143         volatile u32  dr;
144         volatile u32  cpr;
145         volatile u32  sr;
146         /*volatile u32  rsvd1[58];*/
147 } /*__attribute__((__packed__))*/ lh7a40x_ssp_t;
148 #define LH7A40X_SSP_BASE    (0x80000B00)
149 #define LH7A40X_SSP_PTR(name)  lh7a40x_ssp_t* name = (lh7a40x_ssp_t*) LH7A40X_SSP_BASE
150
151 /* (UART) Universal Asychronous Receiver/Transmitter (lh7a400 userguide 15.2.1, lh7a404 userguide 15.2.1) */
152 typedef struct {
153         volatile u32  data;
154         volatile u32  fcon;
155         volatile u32  brcon;
156         volatile u32  con;
157         volatile u32  status;
158         volatile u32  rawisr;
159         volatile u32  inten;
160         volatile u32  isr;
161         volatile u32  rsvd1[56];
162 } /*__attribute__((__packed__))*/ lh7a40x_uart_t;
163 #define LH7A40X_UART_BASE      (0x80000600)
164 #define LH7A40X_UART_PTR(name,n) \
165         lh7a40x_uart_t* name = (lh7a40x_uart_t*) (LH7A40X_UART_BASE + ((n-1) * sizeof(lh7a40x_uart_t)))
166
167 #define UART_BE         (0x00000800)      /* the rx error bits */
168 #define UART_OE         (0x00000400)
169 #define UART_PE         (0x00000200)
170 #define UART_FE         (0x00000100)
171
172 #define UART_WLEN       (0x00000060)    /* fcon bits */
173 #define UART_WLEN_8     (0x00000060)
174 #define UART_WLEN_7     (0x00000040)
175 #define UART_WLEN_6     (0x00000020)
176 #define UART_WLEN_5     (0x00000000)
177 #define UART_FEN        (0x00000010)
178 #define UART_STP2       (0x00000008)
179 #define UART_STP2_2     (0x00000008)
180 #define UART_STP2_1     (0x00000000)
181 #define UART_EPS        (0x00000004)
182 #define UART_EPS_EVEN   (0x00000004)
183 #define UART_EPS_ODD    (0x00000000)
184 #define UART_PEN        (0x00000002)
185 #define UART_BRK        (0x00000001)
186
187 #define UART_BAUDDIV    (0x0000ffff)    /* brcon bits */
188
189 #define UART_SIRBD      (0x00000080)    /* con bits */
190 #define UART_LBE        (0x00000040)
191 #define UART_MXP        (0x00000020)
192 #define UART_TXP        (0x00000010)
193 #define UART_RXP        (0x00000008)
194 #define UART_SIRLP      (0x00000004)
195 #define UART_SIRD       (0x00000002)
196 #define UART_EN         (0x00000001)
197
198 #define UART_TXFE       (0x00000080)    /* status bits */
199 #define UART_RXFF       (0x00000040)
200 #define UART_TXFF       (0x00000020)
201 #define UART_RXFE       (0x00000010)
202 #define UART_BUSY       (0x00000008)
203 #define UART_DCD        (0x00000004)
204 #define UART_DSR        (0x00000002)
205 #define UART_CTS        (0x00000001)
206
207 #define UART_MSEOI      (0xfffffff0)    /* rawisr interrupt bits */
208
209 #define UART_RTI        (0x00000008)    /* generic interrupt bits */
210 #define UART_MI         (0x00000004)
211 #define UART_TI         (0x00000002)
212 #define UART_RI         (0x00000001)
213
214 /* (GPIO) General Purpose IO and External Interrupts (userguide 16.2.1) */
215 typedef struct {
216         volatile u32  pad;
217         volatile u32  pbd;
218         volatile u32  pcd;
219         volatile u32  pdd;
220         volatile u32  padd;
221         volatile u32  pbdd;
222         volatile u32  pcdd;
223         volatile u32  pddd;
224         volatile u32  ped;
225         volatile u32  pedd;
226         volatile u32  kbdctl;
227         volatile u32  pinmux;
228         volatile u32  pfd;
229         volatile u32  pfdd;
230         volatile u32  pgd;
231         volatile u32  pgdd;
232         volatile u32  phd;
233         volatile u32  phdd;
234         volatile u32  rsvd1;
235         volatile u32  inttype1;
236         volatile u32  inttype2;
237         volatile u32  gpiofeoi;
238         volatile u32  gpiointen;
239         volatile u32  intstatus;
240         volatile u32  rawintstatus;
241         volatile u32  gpiodb;
242         volatile u32  papd;
243         volatile u32  pbpd;
244         volatile u32  pcpd;
245         volatile u32  pdpd;
246         volatile u32  pepd;
247         volatile u32  pfpd;
248         volatile u32  pgpd;
249         volatile u32  phpd;
250 } /*__attribute__((__packed__))*/ lh7a40x_gpioint_t;
251 #define LH7A40X_GPIOINT_BASE    (0x80000E00)
252 #define LH7A40X_GPIOINT_PTR(name)  lh7a40x_gpioint_t* name = (lh7a40x_gpioint_t*) LH7A40X_GPIOINT_BASE
253
254 /* Embedded SRAM */
255 #define CFG_SRAM_BASE   (0xB0000000)
256 #define CFG_SRAM_SIZE   (80*1024)       /* 80kB */
257
258 #endif  /* __LH7A40X_H__ */