merge of '01bddb578c9dd04edfbb56d0c1c15f81b4161479'
[vuplus_openembedded] / packages / u-boot / u-boot-git / beagleboard / base.patch
1 diff --git a/Makefile b/Makefile
2 index e557d0d..3eac691 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -141,7 +141,7 @@ ifeq ($(ARCH),ppc)
6  CROSS_COMPILE = ppc_8xx-
7  endif
8  ifeq ($(ARCH),arm)
9 -CROSS_COMPILE = arm-linux-
10 +CROSS_COMPILE = arm-none-linux-gnueabi-
11  endif
12  ifeq ($(ARCH),i386)
13  CROSS_COMPILE = i386-linux-
14 @@ -253,7 +253,7 @@ LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).a
15  LIBBOARD := $(addprefix $(obj),$(LIBBOARD))
16  
17  # Add GCC lib
18 -PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
19 +PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc -lgcc_eh
20  
21  # The "tools" are needed early, so put this first
22  # Don't include stuff already done in $(LIBS)
23 @@ -2569,6 +2569,12 @@ SMN42_config     :       unconfig
24         @$(MKCONFIG) $(@:_config=) arm arm720t SMN42 siemens lpc2292
25  
26  #########################################################################
27 +## ARM CORTEX Systems
28 +#########################################################################
29 +omap3530beagle_config :    unconfig
30 +       @./mkconfig $(@:_config=) arm omap3 omap3530beagle
31 +
32 +#########################################################################
33  ## XScale Systems
34  #########################################################################
35  
36 diff --git a/board/omap3530beagle/Makefile b/board/omap3530beagle/Makefile
37 new file mode 100644
38 index 0000000..7065345
39 --- /dev/null
40 +++ b/board/omap3530beagle/Makefile
41 @@ -0,0 +1,47 @@
42 +#
43 +# (C) Copyright 2000, 2001, 2002
44 +# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
45 +#
46 +# See file CREDITS for list of people who contributed to this
47 +# project.
48 +#
49 +# This program is free software; you can redistribute it and/or
50 +# modify it under the terms of the GNU General Public License as
51 +# published by the Free Software Foundation; either version 2 of
52 +# the License, or (at your option) any later version.
53 +#
54 +# This program is distributed in the hope that it will be useful,
55 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
56 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57 +# GNU General Public License for more details.
58 +#
59 +# You should have received a copy of the GNU General Public License
60 +# along with this program; if not, write to the Free Software
61 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
62 +# MA 02111-1307 USA
63 +#
64 +
65 +include $(TOPDIR)/config.mk
66 +
67 +LIB    = lib$(BOARD).a
68 +
69 +OBJS   := omap3530beagle.o mem.o clock.o syslib.o sys_info.o nand.o
70 +SOBJS  := lowlevel_init.o
71 +
72 +$(LIB):        $(OBJS) $(SOBJS)
73 +       $(AR) crv $@ $^
74 +
75 +clean:
76 +       rm -f $(SOBJS) $(OBJS)
77 +
78 +distclean:     clean
79 +       rm -f $(LIB) core *.bak .depend
80 +
81 +#########################################################################
82 +
83 +.depend:       Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
84 +               $(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
85 +
86 +-include .depend
87 +
88 +#########################################################################
89 diff --git a/board/omap3530beagle/clock.c b/board/omap3530beagle/clock.c
90 new file mode 100644
91 index 0000000..1f4b4f3
92 --- /dev/null
93 +++ b/board/omap3530beagle/clock.c
94 @@ -0,0 +1,314 @@
95 +/*
96 + * (C) Copyright 2008
97 + * Texas Instruments, <www.ti.com>
98 + *
99 + * Author :
100 + *      Sunil Kumar <sunilsaini05@gmail.com>
101 + *      Shashi Ranjan <shashiranjanmca05@gmail.com>
102 + *
103 + * Derived from Beagle Board and OMAP3 SDP code by
104 + *      Richard Woodruff <r-woodruff2@ti.com>
105 + *      Syed Mohammed Khasim <khasim@ti.com>
106 + *
107 + * This program is free software; you can redistribute it and/or
108 + * modify it under the terms of the GNU General Public License as
109 + * published by the Free Software Foundation; either version 2 of
110 + * the License, or (at your option) any later version.
111 + *
112 + * This program is distributed in the hope that it will be useful,
113 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
114 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
115 + * GNU General Public License for more details.
116 + *
117 + * You should have received a copy of the GNU General Public License
118 + * along with this program; if not, write to the Free Software
119 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
120 + * MA 02111-1307 USA
121 + */
122 +
123 +#include <common.h>
124 +#include <asm/io.h>
125 +#include <asm/arch/bits.h>
126 +#include <asm/arch/clocks.h>
127 +#include <asm/arch/clocks_omap3.h>
128 +#include <asm/arch/mem.h>
129 +#include <asm/arch/sys_proto.h>
130 +#include <environment.h>
131 +#include <command.h>
132 +
133 +/******************************************************************************
134 + * get_sys_clk_speed() - determine reference oscillator speed
135 + *                       based on known 32kHz clock and gptimer.
136 + *****************************************************************************/
137 +u32 get_osc_clk_speed(void)
138 +{
139 +       u32 start, cstart, cend, cdiff, val;
140 +
141 +       val = __raw_readl(PRM_CLKSRC_CTRL);
142 +
143 +       /* If SYS_CLK is being divided by 2, remove for now */
144 +       val = (val & (~BIT7)) | BIT6;
145 +       __raw_writel(val, PRM_CLKSRC_CTRL);
146 +
147 +       /* enable timer2 */
148 +       val = __raw_readl(CM_CLKSEL_WKUP) | BIT0;
149 +       __raw_writel(val, CM_CLKSEL_WKUP);      /* select sys_clk for GPT1 */
150 +
151 +       /* Enable I and F Clocks for GPT1 */
152 +       val = __raw_readl(CM_ICLKEN_WKUP) | BIT0 | BIT2;
153 +       __raw_writel(val, CM_ICLKEN_WKUP);
154 +       val = __raw_readl(CM_FCLKEN_WKUP) | BIT0;
155 +       __raw_writel(val, CM_FCLKEN_WKUP);
156 +
157 +       __raw_writel(0, OMAP34XX_GPT1 + TLDR);  /* start counting at 0 */
158 +       __raw_writel(GPT_EN, OMAP34XX_GPT1 + TCLR);     /* enable clock */
159 +
160 +       /* enable 32kHz source, determine sys_clk via gauging */
161 +       start = 20 + __raw_readl(S32K_CR);      /* start time in 20 cycles */
162 +       while (__raw_readl(S32K_CR) < start) ;  /* dead loop till start time */
163 +       /* get start sys_clk count */
164 +       cstart = __raw_readl(OMAP34XX_GPT1 + TCRR);
165 +       /* wait for 40 cycles */
166 +       while (__raw_readl(S32K_CR) < (start + 20)) ;
167 +       cend = __raw_readl(OMAP34XX_GPT1 + TCRR);  /* get end sys_clk count */
168 +       cdiff = cend - cstart;  /* get elapsed ticks */
169 +
170 +       /* based on number of ticks assign speed */
171 +       if (cdiff > 19000)
172 +               return (S38_4M);
173 +       else if (cdiff > 15200)
174 +               return (S26M);
175 +       else if (cdiff > 13000)
176 +               return (S24M);
177 +       else if (cdiff > 9000)
178 +               return (S19_2M);
179 +       else if (cdiff > 7600)
180 +               return (S13M);
181 +       else
182 +               return (S12M);
183 +}
184 +
185 +/******************************************************************************
186 + * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
187 + *                       input oscillator clock frequency.
188 + *****************************************************************************/
189 +void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
190 +{
191 +       if (osc_clk == S38_4M)
192 +               *sys_clkin_sel = 4;
193 +       else if (osc_clk == S26M)
194 +               *sys_clkin_sel = 3;
195 +       else if (osc_clk == S19_2M)
196 +               *sys_clkin_sel = 2;
197 +       else if (osc_clk == S13M)
198 +               *sys_clkin_sel = 1;
199 +       else if (osc_clk == S12M)
200 +               *sys_clkin_sel = 0;
201 +}
202 +
203 +/******************************************************************************
204 + * prcm_init() - inits clocks for PRCM as defined in clocks.h
205 + *               called from SRAM, or Flash (using temp SRAM stack).
206 + *****************************************************************************/
207 +void prcm_init(void)
208 +{
209 +       void (*f_lock_pll) (u32, u32, u32, u32);
210 +       int xip_safe, p0, p1, p2, p3;
211 +       u32 osc_clk = 0, sys_clkin_sel;
212 +       u32 clk_index, sil_index;
213 +       dpll_param *dpll_param_p;
214 +
215 +       f_lock_pll = (void *) ((u32) &_end_vect - (u32) &_start +
216 +                              SRAM_VECT_CODE);
217 +
218 +       xip_safe = running_in_sram();
219 +
220 +       /* Gauge the input clock speed and find out the sys_clkin_sel
221 +        * value corresponding to the input clock.
222 +        */
223 +       osc_clk = get_osc_clk_speed();
224 +       get_sys_clkin_sel(osc_clk, &sys_clkin_sel);
225 +
226 +       sr32(PRM_CLKSEL, 0, 3, sys_clkin_sel);  /* set input crystal speed */
227 +
228 +       /* If the input clock is greater than 19.2M always divide/2 */
229 +       if (sys_clkin_sel > 2) {
230 +               sr32(PRM_CLKSRC_CTRL, 6, 2, 2); /* input clock divider */
231 +               clk_index = sys_clkin_sel / 2;
232 +       } else {
233 +               sr32(PRM_CLKSRC_CTRL, 6, 2, 1); /* input clock divider */
234 +               clk_index = sys_clkin_sel;
235 +       }
236 +
237 +       /* The DPLL tables are defined according to sysclk value and
238 +        * silicon revision. The clk_index value will be used to get
239 +        * the values for that input sysclk from the DPLL param table
240 +        * and sil_index will get the values for that SysClk for the
241 +        * appropriate silicon rev.
242 +        */
243 +       sil_index = get_cpu_rev() - 1;
244 +       /* Unlock MPU DPLL (slows things down, and needed later) */
245 +       sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOW_POWER_BYPASS);
246 +       wait_on_value(BIT0, 0, CM_IDLEST_PLL_MPU, LDELAY);
247 +
248 +       /* Getting the base address of Core DPLL param table */
249 +       dpll_param_p = (dpll_param *) get_core_dpll_param();
250 +       /* Moving it to the right sysclk and ES rev base */
251 +       dpll_param_p = dpll_param_p + 3 * clk_index + sil_index;
252 +       if (xip_safe) {
253 +               /* CORE DPLL */
254 +               /* sr32(CM_CLKSEL2_EMU) set override to work when asleep */
255 +               sr32(CM_CLKEN_PLL, 0, 3, PLL_FAST_RELOCK_BYPASS);
256 +               wait_on_value(BIT0, 0, CM_IDLEST_CKGEN, LDELAY);
257 +               /* For OMAP3 ES1.0 Errata 1.50, default value directly doesnt
258 +                  work. write another value and then default value. */
259 +               sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2 + 1);     /* m3x2 */
260 +               sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2);         /* m3x2 */
261 +               sr32(CM_CLKSEL1_PLL, 27, 2, dpll_param_p->m2);  /* Set M2 */
262 +               sr32(CM_CLKSEL1_PLL, 16, 11, dpll_param_p->m);  /* Set M */
263 +               sr32(CM_CLKSEL1_PLL, 8, 7, dpll_param_p->n);    /* Set N */
264 +               sr32(CM_CLKSEL1_PLL, 6, 1, 0);                  /* 96M Src */
265 +               sr32(CM_CLKSEL_CORE, 8, 4, CORE_SSI_DIV);       /* ssi */
266 +               sr32(CM_CLKSEL_CORE, 4, 2, CORE_FUSB_DIV);      /* fsusb */
267 +               sr32(CM_CLKSEL_CORE, 2, 2, CORE_L4_DIV);        /* l4 */
268 +               sr32(CM_CLKSEL_CORE, 0, 2, CORE_L3_DIV);        /* l3 */
269 +               sr32(CM_CLKSEL_GFX, 0, 3, GFX_DIV);             /* gfx */
270 +               sr32(CM_CLKSEL_WKUP, 1, 2, WKUP_RSM);           /* reset mgr */
271 +               sr32(CM_CLKEN_PLL, 4, 4, dpll_param_p->fsel);   /* FREQSEL */
272 +               sr32(CM_CLKEN_PLL, 0, 3, PLL_LOCK);             /* lock mode */
273 +               wait_on_value(BIT0, 1, CM_IDLEST_CKGEN, LDELAY);
274 +       } else if (running_in_flash()) {
275 +               /* if running from flash, jump to small relocated code
276 +                  area in SRAM. */
277 +               p0 = __raw_readl(CM_CLKEN_PLL);
278 +               sr32((u32) &p0, 0, 3, PLL_FAST_RELOCK_BYPASS);
279 +               sr32((u32) &p0, 4, 4, dpll_param_p->fsel);      /* FREQSEL */
280 +
281 +               p1 = __raw_readl(CM_CLKSEL1_PLL);
282 +               sr32((u32) &p1, 27, 2, dpll_param_p->m2);       /* Set M2 */
283 +               sr32((u32) &p1, 16, 11, dpll_param_p->m);       /* Set M */
284 +               sr32((u32) &p1, 8, 7, dpll_param_p->n);         /* Set N */
285 +               sr32((u32) &p1, 6, 1, 0);           /* set source for 96M */
286 +               p2 = __raw_readl(CM_CLKSEL_CORE);
287 +               sr32((u32) &p2, 8, 4, CORE_SSI_DIV);    /* ssi */
288 +               sr32((u32) &p2, 4, 2, CORE_FUSB_DIV);   /* fsusb */
289 +               sr32((u32) &p2, 2, 2, CORE_L4_DIV);     /* l4 */
290 +               sr32((u32) &p2, 0, 2, CORE_L3_DIV);     /* l3 */
291 +
292 +               p3 = CM_IDLEST_CKGEN;
293 +
294 +               (*f_lock_pll) (p0, p1, p2, p3);
295 +       }
296 +
297 +       /* PER DPLL */
298 +       sr32(CM_CLKEN_PLL, 16, 3, PLL_STOP);
299 +       wait_on_value(BIT1, 0, CM_IDLEST_CKGEN, LDELAY);
300 +
301 +       /* Getting the base address to PER  DPLL param table */
302 +       /* Set N */
303 +       dpll_param_p = (dpll_param *) get_per_dpll_param();
304 +       /* Moving it to the right sysclk base */
305 +       dpll_param_p = dpll_param_p + clk_index;
306 +       /* Errata 1.50 Workaround for OMAP3 ES1.0 only */
307 +       /* If using default divisors, write default divisor + 1
308 +          and then the actual divisor value */
309 +       /* Need to change it to silicon and revision check */
310 +       if (1) {
311 +               sr32(CM_CLKSEL1_EMU, 24, 5, PER_M6X2 + 1);        /* set M6 */
312 +               sr32(CM_CLKSEL1_EMU, 24, 5, PER_M6X2);            /* set M6 */
313 +               sr32(CM_CLKSEL_CAM, 0, 5, PER_M5X2 + 1);          /* set M5 */
314 +               sr32(CM_CLKSEL_CAM, 0, 5, PER_M5X2);              /* set M5 */
315 +               sr32(CM_CLKSEL_DSS, 0, 5, PER_M4X2 + 1);          /* set M4 */
316 +               sr32(CM_CLKSEL_DSS, 0, 5, PER_M4X2);              /* set M4 */
317 +               sr32(CM_CLKSEL_DSS, 8, 5, PER_M3X2 + 1);          /* set M3 */
318 +               sr32(CM_CLKSEL_DSS, 8, 5, PER_M3X2);              /* set M3 */
319 +               sr32(CM_CLKSEL3_PLL, 0, 5, dpll_param_p->m2 + 1); /* set M2 */
320 +               sr32(CM_CLKSEL3_PLL, 0, 5, dpll_param_p->m2);     /* set M2 */
321 +       } else {
322 +               sr32(CM_CLKSEL1_EMU, 24, 5, PER_M6X2);            /* set M6 */
323 +               sr32(CM_CLKSEL_CAM, 0, 5, PER_M5X2);              /* set M5 */
324 +               sr32(CM_CLKSEL_DSS, 0, 5, PER_M4X2);              /* set M4 */
325 +               sr32(CM_CLKSEL_DSS, 8, 5, PER_M3X2);              /* set M3 */
326 +               sr32(CM_CLKSEL3_PLL, 0, 5, dpll_param_p->m2);     /* set M2 */
327 +       }
328 +       sr32(CM_CLKSEL2_PLL, 8, 11, dpll_param_p->m);   /* set m */
329 +       sr32(CM_CLKSEL2_PLL, 0, 7, dpll_param_p->n);    /* set n */
330 +       sr32(CM_CLKEN_PLL, 20, 4, dpll_param_p->fsel);  /* FREQSEL */
331 +       sr32(CM_CLKEN_PLL, 16, 3, PLL_LOCK);    /* lock mode */
332 +       wait_on_value(BIT1, 2, CM_IDLEST_CKGEN, LDELAY);
333 +
334 +       /* Getting the base address to MPU DPLL param table */
335 +       dpll_param_p = (dpll_param *) get_mpu_dpll_param();
336 +       /* Moving it to the right sysclk and ES rev base */
337 +       dpll_param_p = dpll_param_p + 3 * clk_index + sil_index;
338 +       /* MPU DPLL (unlocked already) */
339 +       sr32(CM_CLKSEL2_PLL_MPU, 0, 5, dpll_param_p->m2);       /* Set M2 */
340 +       sr32(CM_CLKSEL1_PLL_MPU, 8, 11, dpll_param_p->m);       /* Set M */
341 +       sr32(CM_CLKSEL1_PLL_MPU, 0, 7, dpll_param_p->n);        /* Set N */
342 +       sr32(CM_CLKEN_PLL_MPU, 4, 4, dpll_param_p->fsel);       /* FREQSEL */
343 +       sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOCK); /* lock mode */
344 +       wait_on_value(BIT0, 1, CM_IDLEST_PLL_MPU, LDELAY);
345 +
346 +       /* Getting the base address to IVA DPLL param table */
347 +       dpll_param_p = (dpll_param *) get_iva_dpll_param();
348 +       /* Moving it to the right sysclk and ES rev base */
349 +       dpll_param_p = dpll_param_p + 3 * clk_index + sil_index;
350 +       /* IVA DPLL (set to 12*20=240MHz) */
351 +       sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_STOP);
352 +       wait_on_value(BIT0, 0, CM_IDLEST_PLL_IVA2, LDELAY);
353 +       sr32(CM_CLKSEL2_PLL_IVA2, 0, 5, dpll_param_p->m2);      /* set M2 */
354 +       sr32(CM_CLKSEL1_PLL_IVA2, 8, 11, dpll_param_p->m);      /* set M */
355 +       sr32(CM_CLKSEL1_PLL_IVA2, 0, 7, dpll_param_p->n);       /* set N */
356 +       sr32(CM_CLKEN_PLL_IVA2, 4, 4, dpll_param_p->fsel);      /* FREQSEL */
357 +       sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_LOCK);        /* lock mode */
358 +       wait_on_value(BIT0, 1, CM_IDLEST_PLL_IVA2, LDELAY);
359 +
360 +       /* Set up GPTimers to sys_clk source only */
361 +       sr32(CM_CLKSEL_PER, 0, 8, 0xff);
362 +       sr32(CM_CLKSEL_WKUP, 0, 1, 1);
363 +
364 +       sdelay(5000);
365 +}
366 +
367 +/******************************************************************************
368 + * peripheral_enable() - Enable the clks & power for perifs (GPT2, UART1,...)
369 + *****************************************************************************/
370 +void per_clocks_enable(void)
371 +{
372 +       /* Enable GP2 timer. */
373 +       sr32(CM_CLKSEL_PER, 0, 1, 0x1); /* GPT2 = sys clk */
374 +       sr32(CM_ICLKEN_PER, 3, 1, 0x1); /* ICKen GPT2 */
375 +       sr32(CM_FCLKEN_PER, 3, 1, 0x1); /* FCKen GPT2 */
376 +
377 +#ifdef CFG_NS16550
378 +       /* Enable UART1 clocks */
379 +       sr32(CM_FCLKEN1_CORE, 13, 1, 0x1);
380 +       sr32(CM_ICLKEN1_CORE, 13, 1, 0x1);
381 +
382 +       /* UART 3 Clocks */
383 +       sr32(CM_FCLKEN_PER, 11, 1, 0x1);
384 +       sr32(CM_ICLKEN_PER, 11, 1, 0x1);
385 +#endif
386 +#ifdef CONFIG_DRIVER_OMAP34XX_I2C
387 +       /* Turn on all 3 I2C clocks */
388 +       sr32(CM_FCLKEN1_CORE, 15, 3, 0x7);
389 +       sr32(CM_ICLKEN1_CORE, 15, 3, 0x7);      /* I2C1,2,3 = on */
390 +#endif
391 +       /* Enable the ICLK for 32K Sync Timer as its used in udelay */
392 +       sr32(CM_ICLKEN_WKUP, 2, 1, 0x1);
393 +
394 +       sr32(CM_FCLKEN_IVA2, 0, 32, FCK_IVA2_ON);
395 +       sr32(CM_FCLKEN1_CORE, 0, 32, FCK_CORE1_ON);
396 +       sr32(CM_ICLKEN1_CORE, 0, 32, ICK_CORE1_ON);
397 +       sr32(CM_ICLKEN2_CORE, 0, 32, ICK_CORE2_ON);
398 +       sr32(CM_FCLKEN_WKUP, 0, 32, FCK_WKUP_ON);
399 +       sr32(CM_ICLKEN_WKUP, 0, 32, ICK_WKUP_ON);
400 +       sr32(CM_FCLKEN_DSS, 0, 32, FCK_DSS_ON);
401 +       sr32(CM_ICLKEN_DSS, 0, 32, ICK_DSS_ON);
402 +       sr32(CM_FCLKEN_CAM, 0, 32, FCK_CAM_ON);
403 +       sr32(CM_ICLKEN_CAM, 0, 32, ICK_CAM_ON);
404 +       sr32(CM_FCLKEN_PER, 0, 32, FCK_PER_ON);
405 +       sr32(CM_ICLKEN_PER, 0, 32, ICK_PER_ON);
406 +
407 +       sdelay(1000);
408 +}
409 diff --git a/board/omap3530beagle/config.mk b/board/omap3530beagle/config.mk
410 new file mode 100644
411 index 0000000..9639c43
412 --- /dev/null
413 +++ b/board/omap3530beagle/config.mk
414 @@ -0,0 +1,17 @@
415 +#
416 +# (C) Copyright 2006
417 +# Texas Instruments, <www.ti.com>
418 +#
419 +# Begale Board uses OMAP3 (ARM-CortexA8) cpu
420 +# see http://www.ti.com/ for more information on Texas Instruments
421 +#
422 +# Physical Address:
423 +# 8000'0000 (bank0)
424 +# A000/0000 (bank1)
425 +# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
426 +# (mem base + reserved)
427 +
428 +# For use with external or internal boots.
429 +TEXT_BASE = 0x80e80000
430 +
431 +
432 diff --git a/board/omap3530beagle/lowlevel_init.S b/board/omap3530beagle/lowlevel_init.S
433 new file mode 100644
434 index 0000000..1f9a0e9
435 --- /dev/null
436 +++ b/board/omap3530beagle/lowlevel_init.S
437 @@ -0,0 +1,360 @@
438 +/*
439 + * Board specific setup info
440 + *
441 + * (C) Copyright 2008
442 + * Texas Instruments, <www.ti.com>
443 + *
444 + * Initial Code by:
445 + * Richard Woodruff <r-woodruff2@ti.com>
446 + * Syed Mohammed Khasim <khasim@ti.com>
447 + *
448 + * See file CREDITS for list of people who contributed to this
449 + * project.
450 + *
451 + * This program is free software; you can redistribute it and/or
452 + * modify it under the terms of the GNU General Public License as
453 + * published by the Free Software Foundation; either version 2 of
454 + * the License, or (at your option) any later version.
455 + *
456 + * This program is distributed in the hope that it will be useful,
457 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
458 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
459 + * GNU General Public License for more details.
460 + *
461 + * You should have received a copy of the GNU General Public License
462 + * along with this program; if not, write to the Free Software
463 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
464 + * MA 02111-1307 USA
465 + */
466 +
467 +#include <config.h>
468 +#include <version.h>
469 +#include <asm/arch/mem.h>
470 +#include <asm/arch/clocks_omap3.h>
471 +
472 +_TEXT_BASE:
473 +       .word   TEXT_BASE       /* sdram load addr from config.mk */
474 +
475 +#if !defined(CFG_NAND_BOOT) && !defined(CFG_NAND_BOOT)
476 +/**************************************************************************
477 + * cpy_clk_code: relocates clock code into SRAM where its safer to execute
478 + * R1 = SRAM destination address.
479 + *************************************************************************/
480 +.global cpy_clk_code
481 + cpy_clk_code:
482 +        /* Copy DPLL code into SRAM */
483 +        adr     r0, go_to_speed         /* get addr of clock setting code */
484 +        mov     r2, #384                /* r2 size to copy (div by 32 bytes) */
485 +        mov     r1, r1                  /* r1 <- dest address (passed in) */
486 +        add     r2, r2, r0              /* r2 <- source end address */
487 +next2:
488 +        ldmia   r0!, {r3-r10}           /* copy from source address [r0]    */
489 +        stmia   r1!, {r3-r10}           /* copy to   target address [r1]    */
490 +        cmp     r0, r2                  /* until source end address [r2]    */
491 +        bne     next2
492 +       mov     pc, lr                  /* back to caller */
493 +
494 +/* ***************************************************************************
495 + *  go_to_speed: -Moves to bypass, -Commits clock dividers, -puts dpll at speed
496 + *               -executed from SRAM.
497 + *  R0 = CM_CLKEN_PLL-bypass value
498 + *  R1 = CM_CLKSEL1_PLL-m, n, and divider values
499 + *  R2 = CM_CLKSEL_CORE-divider values
500 + *  R3 = CM_IDLEST_CKGEN - addr dpll lock wait
501 + *
502 + *  Note: If core unlocks/relocks and SDRAM is running fast already it gets
503 + *        confused.  A reset of the controller gets it back.  Taking away its
504 + *        L3 when its not in self refresh seems bad for it.  Normally, this
505 + *       code runs from flash before SDR is init so that should be ok.
506 + ****************************************************************************/
507 +.global go_to_speed
508 + go_to_speed:
509 +        stmfd sp!, {r4-r6}
510 +
511 +        /* move into fast relock bypass */
512 +        ldr     r4, pll_ctl_add
513 +        str     r0, [r4]
514 +wait1:
515 +        ldr     r5, [r3]       /* get status */
516 +        and     r5, r5, #0x1   /* isolate core status */
517 +        cmp     r5, #0x1       /* still locked? */
518 +        beq     wait1          /* if lock, loop */
519 +
520 +       /* set new dpll dividers _after_ in bypass */
521 +       ldr     r5, pll_div_add1
522 +        str     r1, [r5]          /* set m, n, m2 */
523 +        ldr     r5, pll_div_add2
524 +        str     r2, [r5]          /* set l3/l4/.. dividers*/
525 +        ldr     r5, pll_div_add3  /* wkup */
526 +        ldr     r2, pll_div_val3  /* rsm val */
527 +        str     r2, [r5]
528 +        ldr     r5, pll_div_add4  /* gfx */
529 +        ldr     r2, pll_div_val4
530 +        str     r2, [r5]
531 +        ldr     r5, pll_div_add5  /* emu */
532 +        ldr     r2, pll_div_val5
533 +        str     r2, [r5]
534 +
535 +        /* now prepare GPMC (flash) for new dpll speed */
536 +       /* flash needs to be stable when we jump back to it */
537 +        ldr     r5, flash_cfg3_addr
538 +        ldr     r2, flash_cfg3_val
539 +        str     r2, [r5]
540 +        ldr     r5, flash_cfg4_addr
541 +        ldr     r2, flash_cfg4_val
542 +        str     r2, [r5]
543 +        ldr     r5, flash_cfg5_addr
544 +        ldr     r2, flash_cfg5_val
545 +        str     r2, [r5]
546 +        ldr     r5, flash_cfg1_addr
547 +        ldr     r2, [r5]
548 +        orr     r2, r2, #0x3     /* up gpmc divider */
549 +        str     r2, [r5]
550 +
551 +        /* lock DPLL3 and wait a bit */
552 +        orr     r0, r0, #0x7   /* set up for lock mode */
553 +        str     r0, [r4]       /* lock */
554 +        nop                    /* ARM slow at this point working at sys_clk */
555 +        nop
556 +        nop
557 +        nop
558 +wait2:
559 +        ldr     r5, [r3]       /* get status */
560 +        and     r5, r5, #0x1   /* isolate core status */
561 +        cmp     r5, #0x1       /* still locked? */
562 +        bne     wait2          /* if lock, loop */
563 +        nop
564 +        nop
565 +        nop
566 +        nop
567 +        ldmfd sp!, {r4-r6}
568 +        mov     pc, lr           /* back to caller, locked */
569 +
570 +_go_to_speed: .word go_to_speed
571 +
572 +/* these constants need to be close for PIC code */
573 +/* The Nor has to be in the Flash Base CS0 for this condition to happen */
574 +flash_cfg1_addr:
575 +    .word (GPMC_CONFIG_CS0 + GPMC_CONFIG1)
576 +flash_cfg3_addr:
577 +    .word  (GPMC_CONFIG_CS0 + GPMC_CONFIG3)
578 +flash_cfg3_val:
579 +    .word  STNOR_GPMC_CONFIG3
580 +flash_cfg4_addr:
581 +    .word (GPMC_CONFIG_CS0 + GPMC_CONFIG4)
582 +flash_cfg4_val:
583 +    .word  STNOR_GPMC_CONFIG4
584 +flash_cfg5_val:
585 +    .word  STNOR_GPMC_CONFIG5
586 +flash_cfg5_addr:
587 +    .word (GPMC_CONFIG_CS0 + GPMC_CONFIG5)
588 +pll_ctl_add:
589 +    .word CM_CLKEN_PLL
590 +pll_div_add1:
591 +    .word CM_CLKSEL1_PLL
592 +pll_div_add2:
593 +    .word CM_CLKSEL_CORE
594 +pll_div_add3:
595 +    .word CM_CLKSEL_WKUP
596 +pll_div_val3:
597 +    .word (WKUP_RSM << 1)
598 +pll_div_add4:
599 +    .word CM_CLKSEL_GFX
600 +pll_div_val4:
601 +    .word (GFX_DIV << 0)
602 +pll_div_add5:
603 +    .word CM_CLKSEL1_EMU
604 +pll_div_val5:
605 +    .word CLSEL1_EMU_VAL
606 +
607 +#endif
608 +
609 +.globl lowlevel_init
610 +lowlevel_init:
611 +       ldr     sp,     SRAM_STACK
612 +        str     ip,    [sp]    /* stash old link register */
613 +       mov     ip,     lr      /* save link reg across call */
614 +       bl      s_init          /* go setup pll,mux,memory */
615 +        ldr     ip,    [sp]    /* restore save ip */
616 +       mov     lr,     ip      /* restore link reg */
617 +
618 +       /* back to arch calling code */
619 +       mov     pc,     lr
620 +
621 +       /* the literal pools origin */
622 +       .ltorg
623 +
624 +REG_CONTROL_STATUS:
625 +       .word CONTROL_STATUS
626 +SRAM_STACK:
627 +       .word LOW_LEVEL_SRAM_STACK
628 +
629 +/* DPLL(1-4) PARAM TABLES */
630 +/* Each of the tables has M, N, FREQSEL, M2 values defined for nominal
631 + * OPP (1.2V). The fields are defined according to dpll_param struct(clock.c).
632 + * The values are defined for all possible sysclk and for ES1 and ES2.
633 + */
634 +
635 +mpu_dpll_param:
636 +/* 12MHz */
637 +/* ES1 */
638 +.word 0x0FE,0x07,0x05,0x01
639 +/* ES2 */
640 +.word 0x0FA,0x05,0x07,0x01
641 +/* 3410 */
642 +.word 0x085,0x05,0x07,0x01
643 +
644 +/* 13MHz */
645 +/* ES1 */
646 +.word 0x17D,0x0C,0x03,0x01
647 +/* ES2 */
648 +.word 0x1F4,0x0C,0x03,0x01
649 +/* 3410 */
650 +.word 0x10A,0x0C,0x03,0x01
651 +
652 +/* 19.2MHz */
653 +/* ES1 */
654 +.word 0x179,0x12,0x04,0x01
655 +/* ES2 */
656 +.word 0x271,0x17,0x03,0x01
657 +/* 3410 */
658 +.word 0x14C,0x17,0x03,0x01
659 +
660 +/* 26MHz */
661 +/* ES1 */
662 +.word 0x17D,0x19,0x03,0x01
663 +/* ES2 */
664 +.word 0x0FA,0x0C,0x07,0x01
665 +/* 3410 */
666 +.word 0x085,0x0C,0x07,0x01
667 +
668 +/* 38.4MHz */
669 +/* ES1 */
670 +.word 0x1FA,0x32,0x03,0x01
671 +/* ES2 */
672 +.word 0x271,0x2F,0x03,0x01
673 +/* 3410 */
674 +.word 0x14C,0x2F,0x03,0x01
675 +
676 +
677 +.globl get_mpu_dpll_param
678 +get_mpu_dpll_param:
679 +       adr r0, mpu_dpll_param
680 +       mov pc, lr
681 +
682 +iva_dpll_param:
683 +/* 12MHz */
684 +/* ES1 */
685 +.word 0x07D,0x05,0x07,0x01
686 +/* ES2 */
687 +.word 0x0B4,0x05,0x07,0x01
688 +/* 3410 */
689 +.word 0x085,0x05,0x07,0x01
690 +
691 +/* 13MHz */
692 +/* ES1 */
693 +.word 0x0FA,0x0C,0x03,0x01
694 +/* ES2 */
695 +.word 0x168,0x0C,0x03,0x01
696 +/* 3410 */
697 +.word 0x10A,0x0C,0x03,0x01
698 +
699 +/* 19.2MHz */
700 +/* ES1 */
701 +.word 0x082,0x09,0x07,0x01
702 +/* ES2 */
703 +.word 0x0E1,0x0B,0x06,0x01
704 +/* 3410 */
705 +.word 0x14C,0x17,0x03,0x01
706 +
707 +/* 26MHz */
708 +/* ES1 */
709 +.word 0x07D,0x0C,0x07,0x01
710 +/* ES2 */
711 +.word 0x0B4,0x0C,0x07,0x01
712 +/* 3410 */
713 +.word 0x085,0x0C,0x07,0x01
714 +
715 +/* 38.4MHz */
716 +/* ES1 */
717 +.word 0x13F,0x30,0x03,0x01
718 +/* ES2 */
719 +.word 0x0E1,0x17,0x06,0x01
720 +/* 3410 */
721 +.word 0x14C,0x2F,0x03,0x01
722 +
723 +
724 +.globl get_iva_dpll_param
725 +get_iva_dpll_param:
726 +       adr r0, iva_dpll_param
727 +       mov pc, lr
728 +
729 +/* Core DPLL targets for L3 at 166 & L133 */
730 +core_dpll_param:
731 +/* 12MHz */
732 +/* ES1 */
733 +.word M_12_ES1,M_12_ES1,FSL_12_ES1,M2_12_ES1
734 +/* ES2 */
735 +.word M_12,N_12,FSEL_12,M2_12
736 +/* 3410 */
737 +.word M_12,N_12,FSEL_12,M2_12
738 +
739 +/* 13MHz */
740 +/* ES1 */
741 +.word M_13_ES1,N_13_ES1,FSL_13_ES1,M2_13_ES1
742 +/* ES2 */
743 +.word M_13,N_13,FSEL_13,M2_13
744 +/* 3410 */
745 +.word M_13,N_13,FSEL_13,M2_13
746 +
747 +/* 19.2MHz */
748 +/* ES1 */
749 +.word M_19p2_ES1,N_19p2_ES1,FSL_19p2_ES1,M2_19p2_ES1
750 +/* ES2 */
751 +.word M_19p2,N_19p2,FSEL_19p2,M2_19p2
752 +/* 3410 */
753 +.word M_19p2,N_19p2,FSEL_19p2,M2_19p2
754 +
755 +/* 26MHz */
756 +/* ES1 */
757 +.word M_26_ES1,N_26_ES1,FSL_26_ES1,M2_26_ES1
758 +/* ES2 */
759 +.word M_26,N_26,FSEL_26,M2_26
760 +/* 3410 */
761 +.word M_26,N_26,FSEL_26,M2_26
762 +
763 +/* 38.4MHz */
764 +/* ES1 */
765 +.word M_38p4_ES1,N_38p4_ES1,FSL_38p4_ES1,M2_38p4_ES1
766 +/* ES2 */
767 +.word M_38p4,N_38p4,FSEL_38p4,M2_38p4
768 +/* 3410 */
769 +.word M_38p4,N_38p4,FSEL_38p4,M2_38p4
770 +
771 +.globl get_core_dpll_param
772 +get_core_dpll_param:
773 +       adr r0, core_dpll_param
774 +       mov pc, lr
775 +
776 +/* PER DPLL values are same for both ES1 and ES2 */
777 +per_dpll_param:
778 +/* 12MHz */
779 +.word 0xD8,0x05,0x07,0x09
780 +
781 +/* 13MHz */
782 +.word 0x1B0,0x0C,0x03,0x09
783 +
784 +/* 19.2MHz */
785 +.word 0xE1,0x09,0x07,0x09
786 +
787 +/* 26MHz */
788 +.word 0xD8,0x0C,0x07,0x09
789 +
790 +/* 38.4MHz */
791 +.word 0xE1,0x13,0x07,0x09
792 +
793 +.globl get_per_dpll_param
794 +get_per_dpll_param:
795 +       adr r0, per_dpll_param
796 +       mov pc, lr
797 +
798 diff --git a/board/omap3530beagle/mem.c b/board/omap3530beagle/mem.c
799 new file mode 100644
800 index 0000000..fb803be
801 --- /dev/null
802 +++ b/board/omap3530beagle/mem.c
803 @@ -0,0 +1,250 @@
804 +/*
805 + * (C) Copyright 2008
806 + * Texas Instruments, <www.ti.com>
807 + *
808 + * Initial Code from:
809 + *     Richard Woodruff <r-woodruff2@ti.com>
810 + *     Syed Mohammed Khasim <khasim@ti.com>
811 + *
812 + * This program is free software; you can redistribute it and/or
813 + * modify it under the terms of the GNU General Public License as
814 + * published by the Free Software Foundation; either version 2 of
815 + * the License, or (at your option) any later version.
816 + *
817 + * This program is distributed in the hope that it will be useful,
818 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
819 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
820 + * GNU General Public License for more details.
821 + *
822 + * You should have received a copy of the GNU General Public License
823 + * along with this program; if not, write to the Free Software
824 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
825 + * MA 02111-1307 USA
826 + */
827 +
828 +#include <common.h>
829 +#include <asm/io.h>
830 +#include <asm/arch/bits.h>
831 +#include <asm/arch/mem.h>
832 +#include <asm/arch/sys_proto.h>
833 +#include <command.h>
834 +
835 +/* Only One NAND allowed on board at a time.
836 + * The GPMC CS Base for the same
837 + */
838 +unsigned int nand_cs_base;
839 +unsigned int boot_flash_base;
840 +unsigned int boot_flash_off;
841 +unsigned int boot_flash_sec;
842 +unsigned int boot_flash_type;
843 +volatile unsigned int boot_flash_env_addr;
844 +
845 +/* help common/env_flash.c */
846 +#ifdef ENV_IS_VARIABLE
847 +
848 +uchar(*boot_env_get_char_spec) (int index);
849 +int (*boot_env_init) (void);
850 +int (*boot_saveenv) (void);
851 +void (*boot_env_relocate_spec) (void);
852 +
853 +/* 16 bit NAND */
854 +uchar env_get_char_spec(int index);
855 +int env_init(void);
856 +int saveenv(void);
857 +void env_relocate_spec(void);
858 +extern char *env_name_spec;
859 +
860 +u8 is_nand;
861 +
862 +#endif /* ENV_IS_VARIABLE */
863 +
864 +static u32 gpmc_m_nand[GPMC_MAX_REG] = {
865 +       M_NAND_GPMC_CONFIG1,
866 +       M_NAND_GPMC_CONFIG2,
867 +       M_NAND_GPMC_CONFIG3,
868 +       M_NAND_GPMC_CONFIG4,
869 +       M_NAND_GPMC_CONFIG5,
870 +       M_NAND_GPMC_CONFIG6, 0
871 +};
872 +
873 +/**************************************************************************
874 + * make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
875 + *  command line mem=xyz use all memory with out discontinuous support
876 + *  compiled in.  Could do it at the ATAG, but there really is two banks...
877 + * Called as part of 2nd phase DDR init.
878 + **************************************************************************/
879 +void make_cs1_contiguous(void)
880 +{
881 +       u32 size, a_add_low, a_add_high;
882 +
883 +       size = get_sdr_cs_size(SDRC_CS0_OSET);
884 +       size /= SZ_32M;                 /* find size to offset CS1 */
885 +       a_add_high = (size & 3) << 8;   /* set up low field */
886 +       a_add_low = (size & 0x3C) >> 2; /* set up high field */
887 +       __raw_writel((a_add_high | a_add_low), SDRC_CS_CFG);
888 +
889 +}
890 +
891 +/********************************************************
892 + *  mem_ok() - test used to see if timings are correct
893 + *             for a part. Helps in guessing which part
894 + *             we are currently using.
895 + *******************************************************/
896 +u32 mem_ok(void)
897 +{
898 +       u32 val1, val2, addr;
899 +       u32 pattern = 0x12345678;
900 +
901 +       addr = OMAP34XX_SDRC_CS0;
902 +
903 +       __raw_writel(0x0, addr + 0x400);  /* clear pos A */
904 +       __raw_writel(pattern, addr);      /* pattern to pos B */
905 +       __raw_writel(0x0, addr + 4);      /* remove pattern off the bus */
906 +       val1 = __raw_readl(addr + 0x400); /* get pos A value */
907 +       val2 = __raw_readl(addr);         /* get val2 */
908 +
909 +       if ((val1 != 0) || (val2 != pattern))  /* see if pos A value changed */
910 +               return (0);
911 +       else
912 +               return (1);
913 +}
914 +
915 +/********************************************************
916 + *  sdrc_init() - init the sdrc chip selects CS0 and CS1
917 + *  - early init routines, called from flash or
918 + *  SRAM.
919 + *******************************************************/
920 +void sdrc_init(void)
921 +{
922 +       /* only init up first bank here */
923 +       do_sdrc_init(SDRC_CS0_OSET, EARLY_INIT);
924 +}
925 +
926 +/*************************************************************************
927 + * do_sdrc_init(): initialize the SDRAM for use.
928 + *  -code sets up SDRAM basic SDRC timings for CS0
929 + *  -optimal settings can be placed here, or redone after i2c
930 + *      inspection of board info
931 + *
932 + *  - code called ones in C-Stack only context for CS0 and a possible 2nd
933 + *      time depending on memory configuration from stack+global context
934 + **************************************************************************/
935 +
936 +void do_sdrc_init(u32 offset, u32 early)
937 +{
938 +
939 +       /* reset sdrc controller */
940 +       __raw_writel(SOFTRESET, SDRC_SYSCONFIG);
941 +       wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000);
942 +       __raw_writel(0, SDRC_SYSCONFIG);
943 +
944 +       /* setup sdrc to ball mux */
945 +       __raw_writel(SDP_SDRC_SHARING, SDRC_SHARING);
946 +
947 +       /* SDRC_MCFG0 register */
948 +       (*(unsigned int *) 0x6D000080) = 0x02584099; /* from Micron */
949 +
950 +       /* SDRC_RFR_CTRL0 register */
951 +       (*(unsigned int *) 0x6D0000a4) = 0x54601;    /* for 166M */
952 +
953 +       /* SDRC_ACTIM_CTRLA0 register */
954 +       (*(unsigned int *) 0x6D00009c) = 0xa29db4c6; /* for 166M */
955 +
956 +       /* SDRC_ACTIM_CTRLB0 register */
957 +       (*(unsigned int *) 0x6D0000a0) = 0x12214;    /* for 166M */
958 +
959 +       /* Disble Power Down of CKE cuz of 1 CKE on combo part */
960 +       (*(unsigned int *) 0x6D000070) = 0x00000081;
961 +
962 +       /* SDRC_Manual command register */
963 +       (*(unsigned int *) 0x6D0000a8) = 0x00000000; /* NOP command */
964 +       (*(unsigned int *) 0x6D0000a8) = 0x00000001; /* Precharge command */
965 +       (*(unsigned int *) 0x6D0000a8) = 0x00000002; /* Auto-refresh command */
966 +       (*(unsigned int *) 0x6D0000a8) = 0x00000002; /* Auto-refresh command */
967 +
968 +       /* SDRC MR0 register */
969 +       (*(int *) 0x6D000084) = 0x00000032;     /*  Burst length = 4 */
970 +       /* CAS latency = 3, Write Burst = Read Burst Serial Mode */
971 +
972 +       /* SDRC DLLA control register */
973 +       (*(unsigned int *) 0x6D000060) = 0x0000A;
974 +       sdelay(0x20000);
975 +}
976 +
977 +void enable_gpmc_config(u32 *gpmc_config, u32 gpmc_base, u32 base, u32 size)
978 +{
979 +       __raw_writel(0, GPMC_CONFIG7 + gpmc_base);
980 +       sdelay(1000);
981 +       /* Delay for settling */
982 +       __raw_writel(gpmc_config[0], GPMC_CONFIG1 + gpmc_base);
983 +       __raw_writel(gpmc_config[1], GPMC_CONFIG2 + gpmc_base);
984 +       __raw_writel(gpmc_config[2], GPMC_CONFIG3 + gpmc_base);
985 +       __raw_writel(gpmc_config[3], GPMC_CONFIG4 + gpmc_base);
986 +       __raw_writel(gpmc_config[4], GPMC_CONFIG5 + gpmc_base);
987 +       __raw_writel(gpmc_config[5], GPMC_CONFIG6 + gpmc_base);
988 +       /* Enable the config */
989 +       __raw_writel((((size & 0xF) << 8) | ((base >> 24) & 0x3F) |
990 +                     (1 << 6)), GPMC_CONFIG7 + gpmc_base);
991 +       sdelay(2000);
992 +}
993 +
994 +/*****************************************************
995 + * gpmc_init(): init gpmc bus
996 + * Init GPMC for x16, MuxMode (SDRAM in x32).
997 + * This code can only be executed from SRAM or SDRAM.
998 + *****************************************************/
999 +void gpmc_init(void)
1000 +{
1001 +       /* putting a blanket check on GPMC based on ZeBu for now */
1002 +       u32 mux = 0, mwidth;
1003 +       u32 *gpmc_config = NULL;
1004 +       u32 gpmc_base = 0;
1005 +       u32 base = 0;
1006 +       u32 size = 0;
1007 +       u32 f_off = CFG_MONITOR_LEN;
1008 +       u32 f_sec = 0;
1009 +       u32 config = 0;
1010 +
1011 +       mux = BIT9;
1012 +       mwidth = get_gpmc0_width();
1013 +
1014 +       /* global settings */
1015 +       __raw_writel(0x0, GPMC_IRQENABLE);      /* isr's sources masked */
1016 +       __raw_writel(0, GPMC_TIMEOUT_CONTROL);  /* timeout disable */
1017 +
1018 +       config = __raw_readl(GPMC_CONFIG);
1019 +       config &= (~0xf00);
1020 +       __raw_writel(config, GPMC_CONFIG);
1021 +
1022 +       /* Disable the GPMC0 config set by ROM code
1023 +        * It conflicts with our MPDB (both at 0x08000000)
1024 +        */
1025 +       __raw_writel(0, GPMC_CONFIG7 + GPMC_CONFIG_CS0);
1026 +       sdelay(1000);
1027 +
1028 +       /* CS 0 */
1029 +       gpmc_config = gpmc_m_nand;
1030 +       gpmc_base = GPMC_CONFIG_CS0 + (0 * GPMC_CONFIG_WIDTH);
1031 +       base = PISMO1_NAND_BASE;
1032 +       size = PISMO1_NAND_SIZE;
1033 +       enable_gpmc_config(gpmc_config, gpmc_base, base, size);
1034 +
1035 +       f_off = SMNAND_ENV_OFFSET;
1036 +       f_sec = SZ_128K;
1037 +       is_nand = 1;
1038 +       nand_cs_base = gpmc_base;
1039 +
1040 +       /* env setup */
1041 +       boot_flash_base = base;
1042 +       boot_flash_off = f_off;
1043 +       boot_flash_sec = f_sec;
1044 +       boot_flash_env_addr = f_off;
1045 +
1046 +#ifdef ENV_IS_VARIABLE
1047 +       boot_env_get_char_spec = env_get_char_spec;
1048 +       boot_env_init = env_init;
1049 +       boot_saveenv = saveenv;
1050 +       boot_env_relocate_spec = env_relocate_spec;
1051 +#endif
1052 +
1053 +}
1054 diff --git a/board/omap3530beagle/nand.c b/board/omap3530beagle/nand.c
1055 new file mode 100644
1056 index 0000000..2f94684
1057 --- /dev/null
1058 +++ b/board/omap3530beagle/nand.c
1059 @@ -0,0 +1,408 @@
1060 +/*
1061 + * (C) Copyright 2004-2008 Texas Instruments, <www.ti.com>
1062 + * Rohit Choraria <rohitkc@ti.com>
1063 + *
1064 + * See file CREDITS for list of people who contributed to this
1065 + * project.
1066 + *
1067 + * This program is free software; you can redistribute it and/or
1068 + * modify it under the terms of the GNU General Public License as
1069 + * published by the Free Software Foundation; either version 2 of
1070 + * the License, or (at your option) any later version.
1071 + *
1072 + * This program is distributed in the hope that it will be useful,
1073 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1074 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1075 + * GNU General Public License for more details.
1076 + *
1077 + * You should have received a copy of the GNU General Public License
1078 + * along with this program; if not, write to the Free Software
1079 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1080 + * MA 02111-1307 USA
1081 + */
1082 +
1083 +#include <common.h>
1084 +#include <asm/io.h>
1085 +#include <asm/arch/mem.h>
1086 +#include <linux/mtd/nand_ecc.h>
1087 +
1088 +#if defined(CONFIG_CMD_NAND)
1089 +
1090 +#include <nand.h>
1091 +
1092 +unsigned char cs;
1093 +volatile unsigned long gpmc_cs_base_add;
1094 +
1095 +#define GPMC_BUF_EMPTY 0
1096 +#define GPMC_BUF_FULL 1
1097 +
1098 +#define ECC_P1_128_E(val)    ((val)  & 0x000000FF)     /* Bit 0 to 7 */
1099 +#define ECC_P512_2048_E(val) (((val) & 0x00000F00)>>8) /* Bit 8 to 11 */
1100 +#define ECC_P1_128_O(val)    (((val) & 0x00FF0000)>>16)        /* Bit 16 to Bit 23 */
1101 +#define ECC_P512_2048_O(val) (((val) & 0x0F000000)>>24)        /* Bit 24 to Bit 27 */
1102 +
1103 +/*
1104 + * omap_nand_hwcontrol - Set the address pointers corretly for the
1105 + *                     following address/data/command operation
1106 + * @mtd:        MTD device structure
1107 + * @ctrl:      Says whether Address or Command or Data is following.
1108 + */
1109 +static void omap_nand_hwcontrol(struct mtd_info *mtd, int ctrl)
1110 +{
1111 +       register struct nand_chip *this = mtd->priv;
1112 +
1113 +       /* Point the IO_ADDR to DATA and ADDRESS registers instead
1114 +          of chip address */
1115 +       switch (ctrl) {
1116 +       case NAND_CTL_SETCLE:
1117 +               this->IO_ADDR_W = (void *) gpmc_cs_base_add + GPMC_NAND_CMD;
1118 +               this->IO_ADDR_R = (void *) gpmc_cs_base_add + GPMC_NAND_DAT;
1119 +               break;
1120 +       case NAND_CTL_SETALE:
1121 +               this->IO_ADDR_W = (void *) gpmc_cs_base_add + GPMC_NAND_ADR;
1122 +               this->IO_ADDR_R = (void *) gpmc_cs_base_add + GPMC_NAND_DAT;
1123 +               break;
1124 +       case NAND_CTL_CLRCLE:
1125 +               this->IO_ADDR_W = (void *) gpmc_cs_base_add + GPMC_NAND_DAT;
1126 +               this->IO_ADDR_R = (void *) gpmc_cs_base_add + GPMC_NAND_DAT;
1127 +               break;
1128 +       case NAND_CTL_CLRALE:
1129 +               this->IO_ADDR_W = (void *) gpmc_cs_base_add + GPMC_NAND_DAT;
1130 +               this->IO_ADDR_R = (void *) gpmc_cs_base_add + GPMC_NAND_DAT;
1131 +               break;
1132 +       }
1133 +}
1134 +
1135 +/*
1136 + * omap_nand_wait - called primarily after a program/erase operation
1137 + *                     so that we access NAND again only after the device
1138 + *                     is ready again.
1139 + * @mtd:        MTD device structure
1140 + * @chip:      nand_chip structure
1141 + * @state:     State from which wait function is being called i.e write/erase.
1142 + */
1143 +static int omap_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,
1144 +                         int state)
1145 +{
1146 +       register struct nand_chip *this = mtd->priv;
1147 +       int status = 0;
1148 +
1149 +       this->IO_ADDR_W = (void *) gpmc_cs_base_add + GPMC_NAND_CMD;
1150 +       this->IO_ADDR_R = (void *) gpmc_cs_base_add + GPMC_NAND_DAT;
1151 +       /* Send the status command and loop until the device is free */
1152 +       while (!(status & 0x40)) {
1153 +               __raw_writeb(NAND_CMD_STATUS & 0xFF, this->IO_ADDR_W);
1154 +               status = __raw_readb(this->IO_ADDR_R);
1155 +       }
1156 +       return status;
1157 +}
1158 +
1159 +#ifdef CFG_NAND_WIDTH_16
1160 +/*
1161 + * omap_nand_write_buf16 - [DEFAULT] write buffer to chip
1162 + * @mtd:       MTD device structure
1163 + * @buf:       data buffer
1164 + * @len:       number of bytes to write
1165 + *
1166 + * Default write function for 16bit buswith
1167 + */
1168 +static void omap_nand_write_buf(struct mtd_info *mtd, const u_char *buf,
1169 +                               int len)
1170 +{
1171 +       int i;
1172 +       struct nand_chip *this = mtd->priv;
1173 +       u16 *p = (u16 *) buf;
1174 +       len >>= 1;
1175 +
1176 +       for (i = 0; i < len; i++) {
1177 +               writew(p[i], this->IO_ADDR_W);
1178 +               while (GPMC_BUF_EMPTY == (readl(GPMC_STATUS) & GPMC_BUF_FULL)) ;
1179 +       }
1180 +}
1181 +
1182 +/*
1183 + * nand_read_buf16 - [DEFAULT] read chip data into buffer
1184 + * @mtd:       MTD device structure
1185 + * @buf:       buffer to store date
1186 + * @len:       number of bytes to read
1187 + *
1188 + * Default read function for 16bit buswith
1189 + */
1190 +static void omap_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
1191 +{
1192 +       int i;
1193 +       struct nand_chip *this = mtd->priv;
1194 +       u16 *p = (u16 *) buf;
1195 +       len >>= 1;
1196 +
1197 +       for (i = 0; i < len; i++)
1198 +               p[i] = readw(this->IO_ADDR_R);
1199 +}
1200 +
1201 +#else
1202 +/*
1203 + * omap_nand_write_buf -  write buffer to NAND controller
1204 + * @mtd:        MTD device structure
1205 + * @buf:        data buffer
1206 + * @len:        number of bytes to write
1207 + *
1208 + */
1209 +static void omap_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf,
1210 +                               int len)
1211 +{
1212 +       int i;
1213 +       int j = 0;
1214 +       struct nand_chip *chip = mtd->priv;
1215 +
1216 +       for (i = 0; i < len; i++) {
1217 +               writeb(buf[i], chip->IO_ADDR_W);
1218 +               for (j = 0; j < 10; j++) ;
1219 +       }
1220 +
1221 +}
1222 +
1223 +/*
1224 + * omap_nand_read_buf - read data from NAND controller into buffer
1225 + * @mtd:        MTD device structure
1226 + * @buf:        buffer to store date
1227 + * @len:        number of bytes to read
1228 + *
1229 + */
1230 +static void omap_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
1231 +{
1232 +       int i;
1233 +       int j = 0;
1234 +       struct nand_chip *chip = mtd->priv;
1235 +
1236 +       for (i = 0; i < len; i++) {
1237 +               buf[i] = readb(chip->IO_ADDR_R);
1238 +               while (GPMC_BUF_EMPTY == (readl(GPMC_STATUS) & GPMC_BUF_FULL));
1239 +       }
1240 +}
1241 +#endif /* CFG_NAND_WIDTH_16 */
1242 +
1243 +/*
1244 + * omap_hwecc_init - Initialize the Hardware ECC for NAND flash in
1245 + *                   GPMC controller
1246 + * @mtd:        MTD device structure
1247 + *
1248 + */
1249 +static void omap_hwecc_init(struct nand_chip *chip)
1250 +{
1251 +       unsigned long val = 0x0;
1252 +
1253 +       /* Init ECC Control Register */
1254 +       /* Clear all ECC  | Enable Reg1 */
1255 +       val = ((0x00000001 << 8) | 0x00000001);
1256 +       __raw_writel(val, GPMC_BASE + GPMC_ECC_CONTROL);
1257 +       __raw_writel(0x3fcff000, GPMC_BASE + GPMC_ECC_SIZE_CONFIG);
1258 +}
1259 +
1260 +/*
1261 + * omap_correct_data - Compares the ecc read from nand spare area with
1262 + *                     ECC registers values
1263 + *                     and corrects one bit error if it has occured
1264 + * @mtd:                MTD device structure
1265 + * @dat:                page data
1266 + * @read_ecc:           ecc read from nand flash
1267 + * @calc_ecc:           ecc read from ECC registers
1268 + */
1269 +static int omap_correct_data(struct mtd_info *mtd, u_char *dat,
1270 +                            u_char *read_ecc, u_char *calc_ecc)
1271 +{
1272 +       return 0;
1273 +}
1274 +
1275 +/*
1276 + *  omap_calculate_ecc - Generate non-inverted ECC bytes.
1277 + *
1278 + *  Using noninverted ECC can be considered ugly since writing a blank
1279 + *  page ie. padding will clear the ECC bytes. This is no problem as
1280 + *  long nobody is trying to write data on the seemingly unused page.
1281 + *  Reading an erased page will produce an ECC mismatch between
1282 + *  generated and read ECC bytes that has to be dealt with separately.
1283 + *  @mtd:      MTD structure
1284 + *  @dat:      unused
1285 + *  @ecc_code: ecc_code buffer
1286 + */
1287 +static int omap_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
1288 +                             u_char *ecc_code)
1289 +{
1290 +       unsigned long val = 0x0;
1291 +       unsigned long reg;
1292 +
1293 +       /* Start Reading from HW ECC1_Result = 0x200 */
1294 +       reg = (unsigned long) (GPMC_BASE + GPMC_ECC1_RESULT);
1295 +       val = __raw_readl(reg);
1296 +
1297 +       *ecc_code++ = ECC_P1_128_E(val);
1298 +       *ecc_code++ = ECC_P1_128_O(val);
1299 +       *ecc_code++ = ECC_P512_2048_E(val) | ECC_P512_2048_O(val) << 4;
1300 +
1301 +       return 0;
1302 +}
1303 +
1304 +/*
1305 + * omap_enable_ecc - This function enables the hardware ecc functionality
1306 + * @mtd:        MTD device structure
1307 + * @mode:       Read/Write mode
1308 + */
1309 +static void omap_enable_hwecc(struct mtd_info *mtd, int mode)
1310 +{
1311 +       struct nand_chip *chip = mtd->priv;
1312 +       unsigned int val = __raw_readl(GPMC_BASE + GPMC_ECC_CONFIG);
1313 +       unsigned int dev_width = (chip->options & NAND_BUSWIDTH_16) >> 1;
1314 +
1315 +       switch (mode) {
1316 +       case NAND_ECC_READ:
1317 +               __raw_writel(0x101, GPMC_BASE + GPMC_ECC_CONTROL);
1318 +               /* ECC col width | CS | ECC Enable */
1319 +               val = (dev_width << 7) | (cs << 1) | (0x1);
1320 +               break;
1321 +       case NAND_ECC_READSYN:
1322 +               __raw_writel(0x100, GPMC_BASE + GPMC_ECC_CONTROL);
1323 +               /* ECC col width | CS | ECC Enable */
1324 +               val = (dev_width << 7) | (cs << 1) | (0x1);
1325 +               break;
1326 +       case NAND_ECC_WRITE:
1327 +               __raw_writel(0x101, GPMC_BASE + GPMC_ECC_CONTROL);
1328 +               /* ECC col width | CS | ECC Enable */
1329 +               val = (dev_width << 7) | (cs << 1) | (0x1);
1330 +               break;
1331 +       default:
1332 +               printf("Error: Unrecognized Mode[%d]!\n", mode);
1333 +               break;
1334 +       }
1335 +
1336 +       __raw_writel(val, GPMC_BASE + GPMC_ECC_CONFIG);
1337 +}
1338 +
1339 +static struct nand_oobinfo hw_nand_oob_64 = {
1340 +       .useecc = MTD_NANDECC_AUTOPLACE,
1341 +       .eccbytes = 12,
1342 +       .eccpos = {
1343 +                  2, 3, 4, 5,
1344 +                  6, 7, 8, 9,
1345 +                  10, 11, 12, 13},
1346 +       .oobfree = { {20, 50} } /* don't care */
1347 +};
1348 +
1349 +static struct nand_oobinfo sw_nand_oob_64 = {
1350 +       .useecc = MTD_NANDECC_AUTOPLACE,
1351 +       .eccbytes = 24,
1352 +       .eccpos = {
1353 +                  40, 41, 42, 43, 44, 45, 46, 47,
1354 +                  48, 49, 50, 51, 52, 53, 54, 55,
1355 +                  56, 57, 58, 59, 60, 61, 62, 63},
1356 +       .oobfree = { {2, 38} }
1357 +};
1358 +
1359 +void omap_nand_switch_ecc(struct mtd_info *mtd, int hardware)
1360 +{
1361 +       struct nand_chip *nand = mtd->priv;
1362 +
1363 +       if (!hardware) {
1364 +               nand->eccmode = NAND_ECC_SOFT;
1365 +               nand->autooob = &sw_nand_oob_64;
1366 +               nand->eccsize = 256;    /* set default eccsize */
1367 +               nand->eccbytes = 3;
1368 +               nand->eccsteps = 8;
1369 +               nand->enable_hwecc = 0;
1370 +               nand->calculate_ecc = nand_calculate_ecc;
1371 +               nand->correct_data = nand_correct_data;
1372 +       } else {
1373 +               nand->eccmode = NAND_ECC_HW3_512;
1374 +               nand->autooob = &hw_nand_oob_64;
1375 +               nand->eccsize = 512;
1376 +               nand->eccbytes = 3;
1377 +               nand->eccsteps = 4;
1378 +               nand->enable_hwecc = omap_enable_hwecc;
1379 +               nand->correct_data = omap_correct_data;
1380 +               nand->calculate_ecc = omap_calculate_ecc;
1381 +
1382 +               omap_hwecc_init(nand);
1383 +       }
1384 +
1385 +       mtd->eccsize = nand->eccsize;
1386 +       nand->oobdirty = 1;
1387 +
1388 +       if (nand->options & NAND_BUSWIDTH_16) {
1389 +               mtd->oobavail = mtd->oobsize - (nand->autooob->eccbytes + 2);
1390 +               if (nand->autooob->eccbytes & 0x01)
1391 +                       mtd->oobavail--;
1392 +       } else
1393 +               mtd->oobavail = mtd->oobsize - (nand->autooob->eccbytes + 1);
1394 +}
1395 +
1396 +/*
1397 + * Board-specific NAND initialization. The following members of the
1398 + * argument are board-specific (per include/linux/mtd/nand_new.h):
1399 + * - IO_ADDR_R?: address to read the 8 I/O lines of the flash device
1400 + * - IO_ADDR_W?: address to write the 8 I/O lines of the flash device
1401 + * - hwcontrol: hardwarespecific function for accesing control-lines
1402 + * - dev_ready: hardwarespecific function for  accesing device ready/busy line
1403 + * - enable_hwecc?: function to enable (reset)  hardware ecc generator. Must
1404 + *   only be provided if a hardware ECC is available
1405 + * - eccmode: mode of ecc, see defines
1406 + * - chip_delay: chip dependent delay for transfering data from array to
1407 + *   read regs (tR)
1408 + * - options: various chip options. They can partly be set to inform
1409 + *   nand_scan about special functionality. See the defines for further
1410 + *   explanation
1411 + * Members with a "?" were not set in the merged testing-NAND branch,
1412 + * so they are not set here either.
1413 + */
1414 +int board_nand_init(struct nand_chip *nand)
1415 +{
1416 +       int gpmc_config = 0;
1417 +       cs = 0;
1418 +       while (cs <= GPMC_MAX_CS) {
1419 +               /* Each GPMC set for a single CS is at offset 0x30 */
1420 +               /* already remapped for us */
1421 +               gpmc_cs_base_add = (GPMC_CONFIG_CS0 + (cs * 0x30));
1422 +               /* xloader/Uboot would have written the NAND type for us
1423 +                * NOTE: This is a temporary measure and cannot handle ONENAND.
1424 +                * The proper way of doing this is to pass the setup of
1425 +                * u-boot up to kernel using kernel params - something on
1426 +                * the lines of machineID
1427 +                */
1428 +               /* Check if NAND type is set */
1429 +               if ((__raw_readl(gpmc_cs_base_add + GPMC_CONFIG1) & 0xC00) ==
1430 +                   0x800) {
1431 +                       /* Found it!! */
1432 +                       break;
1433 +               }
1434 +               cs++;
1435 +       }
1436 +       if (cs > GPMC_MAX_CS) {
1437 +               printf("NAND: Unable to find NAND settings in " \
1438 +                      "GPMC Configuration - quitting\n");
1439 +       }
1440 +
1441 +       gpmc_config = __raw_readl(GPMC_CONFIG);
1442 +       /* Disable Write protect */
1443 +       gpmc_config |= 0x10;
1444 +       __raw_writel(gpmc_config, GPMC_CONFIG);
1445 +
1446 +       nand->IO_ADDR_R = (int *) gpmc_cs_base_add + GPMC_NAND_DAT;
1447 +       nand->IO_ADDR_W = (int *) gpmc_cs_base_add + GPMC_NAND_CMD;
1448 +
1449 +       nand->hwcontrol = omap_nand_hwcontrol;
1450 +       nand->options = NAND_NO_PADDING | NAND_CACHEPRG | NAND_NO_AUTOINCR |
1451 +                       NAND_BUSWIDTH_16 | NAND_NO_AUTOINCR;
1452 +       nand->read_buf = omap_nand_read_buf;
1453 +       nand->write_buf = omap_nand_write_buf;
1454 +       nand->eccmode = NAND_ECC_SOFT;
1455 +       /* if RDY/BSY line is connected to OMAP then use the omap ready
1456 +        * function and the generic nand_wait function which reads the
1457 +        * status register after monitoring the RDY/BSY line. Otherwise
1458 +        * use a standard chip delay which is slightly more than tR
1459 +        * (AC Timing) of the NAND device and read the status register
1460 +        * until you get a failure or success
1461 +        */
1462 +       nand->waitfunc = omap_nand_wait;
1463 +       nand->chip_delay = 50;
1464 +
1465 +       return 0;
1466 +}
1467 +#endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */
1468 diff --git a/board/omap3530beagle/omap3530beagle.c b/board/omap3530beagle/omap3530beagle.c
1469 new file mode 100644
1470 index 0000000..7d9a566
1471 --- /dev/null
1472 +++ b/board/omap3530beagle/omap3530beagle.c
1473 @@ -0,0 +1,388 @@
1474 +/*
1475 + * (C) Copyright 2004-2008
1476 + * Texas Instruments, <www.ti.com>
1477 + *
1478 + * Author :
1479 + *      Sunil Kumar <sunilsaini05@gmail.com>
1480 + *      Shashi Ranjan <shashiranjanmca05@gmail.com>
1481 + *
1482 + * Derived from Beagle Board and 3430 SDP code by
1483 + *      Richard Woodruff <r-woodruff2@ti.com>
1484 + *      Syed Mohammed Khasim <khasim@ti.com>
1485 + *
1486 + *
1487 + * See file CREDITS for list of people who contributed to this
1488 + * project.
1489 + *
1490 + * This program is free software; you can redistribute it and/or
1491 + * modify it under the terms of the GNU General Public License as
1492 + * published by the Free Software Foundation; either version 2 of
1493 + * the License, or (at your option) any later version.
1494 + *
1495 + * This program is distributed in the hope that it will be useful,
1496 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1497 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1498 + * GNU General Public License for more details.
1499 + *
1500 + * You should have received a copy of the GNU General Public License
1501 + * along with this program; if not, write to the Free Software
1502 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1503 + * MA 02111-1307 USA
1504 + */
1505 +#include <common.h>
1506 +#include <asm/io.h>
1507 +#include <asm/arch/bits.h>
1508 +#include <asm/arch/mux.h>
1509 +#include <asm/arch/sys_proto.h>
1510 +#include <asm/arch/mem.h>
1511 +#include <i2c.h>
1512 +#include <asm/mach-types.h>
1513 +
1514 +#if (CONFIG_COMMANDS & CFG_CMD_NAND) && defined(CFG_NAND_LEGACY)
1515 +#include <linux/mtd/nand_legacy.h>
1516 +extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
1517 +#endif
1518 +
1519 +#define NOT_EARLY 0
1520 +
1521 +/* Permission values for registers -Full fledged permissions to all */
1522 +#define UNLOCK_1 0xFFFFFFFF
1523 +#define UNLOCK_2 0x00000000
1524 +#define UNLOCK_3 0x0000FFFF
1525 +
1526 +/******************************************************************************
1527 + * Routine: delay
1528 + * Description: spinning delay to use before udelay works
1529 + *****************************************************************************/
1530 +static inline void delay(unsigned long loops)
1531 +{
1532 +       __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
1533 +                         "bne 1b":"=r" (loops):"0"(loops));
1534 +}
1535 +
1536 +/******************************************************************************
1537 + * Routine: board_init
1538 + * Description: Early hardware init.
1539 + *****************************************************************************/
1540 +int board_init(void)
1541 +{
1542 +       DECLARE_GLOBAL_DATA_PTR;
1543 +
1544 +       gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
1545 +       /* board id for Linux */
1546 +       gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
1547 +       /* boot param addr */
1548 +       gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
1549 +
1550 +       return 0;
1551 +}
1552 +
1553 +/******************************************************************************
1554 + * Routine: secure_unlock
1555 + * Description: Setup security registers for access
1556 + *              (GP Device only)
1557 + *****************************************************************************/
1558 +void secure_unlock_mem(void)
1559 +{
1560 +       /* Protection Module Register Target APE (PM_RT) */
1561 +       __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
1562 +       __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
1563 +       __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
1564 +       __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
1565 +
1566 +       __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
1567 +       __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
1568 +       __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
1569 +
1570 +       __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
1571 +       __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
1572 +       __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
1573 +       __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
1574 +
1575 +       /* IVA Changes */
1576 +       __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
1577 +       __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
1578 +       __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
1579 +
1580 +       __raw_writel(UNLOCK_1, SMS_RG_ATT0);    /* SDRC region 0 public */
1581 +}
1582 +
1583 +/******************************************************************************
1584 + * Routine: secureworld_exit()
1585 + * Description: If chip is EMU and boot type is external
1586 + *             configure secure registers and exit secure world
1587 + *              general use.
1588 + *****************************************************************************/
1589 +void secureworld_exit()
1590 +{
1591 +       unsigned long i;
1592 +
1593 +       /* configrue non-secure access control register */
1594 +       __asm__ __volatile__("mrc p15, 0, %0, c1, c1, 2":"=r"(i));
1595 +       /* enabling co-processor CP10 and CP11 accesses in NS world */
1596 +       __asm__ __volatile__("orr %0, %0, #0xC00":"=r"(i));
1597 +       /* allow allocation of locked TLBs and L2 lines in NS world */
1598 +       /* allow use of PLE registers in NS world also */
1599 +       __asm__ __volatile__("orr %0, %0, #0x70000":"=r"(i));
1600 +       __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 2":"=r"(i));
1601 +
1602 +       /* Enable ASA in ACR register */
1603 +       __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i));
1604 +       __asm__ __volatile__("orr %0, %0, #0x10":"=r"(i));
1605 +       __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i));
1606 +
1607 +       /* Exiting secure world */
1608 +       __asm__ __volatile__("mrc p15, 0, %0, c1, c1, 0":"=r"(i));
1609 +       __asm__ __volatile__("orr %0, %0, #0x31":"=r"(i));
1610 +       __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 0":"=r"(i));
1611 +}
1612 +
1613 +/******************************************************************************
1614 + * Routine: setup_auxcr()
1615 + * Description: Write to AuxCR desired value using SMI.
1616 + *              general use.
1617 + *****************************************************************************/
1618 +void setup_auxcr()
1619 +{
1620 +       unsigned long i;
1621 +       volatile unsigned int j;
1622 +       /* Save r0, r12 and restore them after usage */
1623 +       __asm__ __volatile__("mov %0, r12":"=r"(j));
1624 +       __asm__ __volatile__("mov %0, r0":"=r"(i));
1625 +
1626 +       /* GP Device ROM code API usage here */
1627 +       /* r12 = AUXCR Write function and r0 value */
1628 +       __asm__ __volatile__("mov r12, #0x3");
1629 +       __asm__ __volatile__("mrc p15, 0, r0, c1, c0, 1");
1630 +       /* Enabling ASA */
1631 +       __asm__ __volatile__("orr r0, r0, #0x10");
1632 +       /* SMI instruction to call ROM Code API */
1633 +       __asm__ __volatile__(".word 0xE1600070");
1634 +       __asm__ __volatile__("mov r0, %0":"=r"(i));
1635 +       __asm__ __volatile__("mov r12, %0":"=r"(j));
1636 +}
1637 +
1638 +/******************************************************************************
1639 + * Routine: try_unlock_sram()
1640 + * Description: If chip is GP/EMU(special) type, unlock the SRAM for
1641 + *              general use.
1642 + *****************************************************************************/
1643 +void try_unlock_memory()
1644 +{
1645 +       int mode;
1646 +       int in_sdram = running_in_sdram();
1647 +
1648 +       /* if GP device unlock device SRAM for general use */
1649 +       /* secure code breaks for Secure/Emulation device - HS/E/T */
1650 +       mode = get_device_type();
1651 +       if (mode == GP_DEVICE)
1652 +               secure_unlock_mem();
1653 +
1654 +       /* If device is EMU and boot is XIP external booting
1655 +        * Unlock firewalls and disable L2 and put chip
1656 +        * out of secure world
1657 +        */
1658 +       /* Assuming memories are unlocked by the demon who put us in SDRAM */
1659 +       if ((mode <= EMU_DEVICE) && (get_boot_type() == 0x1F)
1660 +           && (!in_sdram)) {
1661 +               secure_unlock_mem();
1662 +               secureworld_exit();
1663 +       }
1664 +
1665 +       return;
1666 +}
1667 +
1668 +/******************************************************************************
1669 + * Routine: s_init
1670 + * Description: Does early system init of muxing and clocks.
1671 + *              - Called path is with SRAM stack.
1672 + *****************************************************************************/
1673 +void s_init(void)
1674 +{
1675 +       int in_sdram = running_in_sdram();
1676 +
1677 +       watchdog_init();
1678 +
1679 +       try_unlock_memory();
1680 +
1681 +       /* Right now flushing at low MPU speed.
1682 +          Need to move after clock init */
1683 +       v7_flush_dcache_all(get_device_type());
1684 +#ifndef CONFIG_ICACHE_OFF
1685 +       icache_enable();
1686 +#endif
1687 +
1688 +#ifdef CONFIG_L2_OFF
1689 +       l2cache_disable();
1690 +#else
1691 +       l2cache_enable();
1692 +#endif
1693 +       /* Writing to AuxCR in U-boot using SMI for GP DEV */
1694 +       /* Currently SMI in Kernel on ES2 devices seems to have an isse
1695 +        * Once that is resolved, we can postpone this config to kernel
1696 +        */
1697 +       if (get_device_type() == GP_DEVICE)
1698 +               setup_auxcr();
1699 +
1700 +       set_muxconf_regs();
1701 +       delay(100);
1702 +
1703 +       prcm_init();
1704 +
1705 +       per_clocks_enable();
1706 +
1707 +       if (!in_sdram)
1708 +               sdrc_init();
1709 +}
1710 +
1711 +/******************************************************************************
1712 + * Routine: misc_init_r
1713 + * Description: Init ethernet (done here so udelay works)
1714 + *****************************************************************************/
1715 +int misc_init_r(void)
1716 +{
1717 +
1718 +       unsigned char byte;
1719 +
1720 +#ifdef CONFIG_DRIVER_OMAP34XX_I2C
1721 +       i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE);
1722 +#endif
1723 +       byte = 0x20;
1724 +       i2c_write(0x4B, 0x7A, 1, &byte, 1);
1725 +       byte = 0x03;
1726 +       i2c_write(0x4B, 0x7D, 1, &byte, 1);
1727 +       byte = 0xE0;
1728 +       i2c_write(0x4B, 0x8E, 1, &byte, 1);
1729 +       byte = 0x05;
1730 +       i2c_write(0x4B, 0x91, 1, &byte, 1);
1731 +       byte = 0x20;
1732 +       i2c_write(0x4B, 0x96, 1, &byte, 1);
1733 +       byte = 0x03;
1734 +       i2c_write(0x4B, 0x99, 1, &byte, 1);
1735 +       byte = 0x33;
1736 +       i2c_write(0x4A, 0xEE, 1, &byte, 1);
1737 +
1738 +       *((uint *) 0x49058034) = 0xFFFFFAF9;
1739 +       *((uint *) 0x49056034) = 0x0F9F0FFF;
1740 +       *((uint *) 0x49058094) = 0x00000506;
1741 +       *((uint *) 0x49056094) = 0xF060F000;
1742 +
1743 +       return (0);
1744 +}
1745 +
1746 +
1747 +/******************************************************************************
1748 + * Routine: wait_for_command_complete
1749 + * Description: Wait for posting to finish on watchdog
1750 + *****************************************************************************/
1751 +void wait_for_command_complete(unsigned int wd_base)
1752 +{
1753 +       int pending = 1;
1754 +       do {
1755 +               pending = __raw_readl(wd_base + WWPS);
1756 +       } while (pending);
1757 +}
1758 +
1759 +/******************************************************************************
1760 + * Routine: watchdog_init
1761 + * Description: Shut down watch dogs
1762 + *****************************************************************************/
1763 +void watchdog_init(void)
1764 +{
1765 +       /* There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is
1766 +        * either taken care of by ROM (HS/EMU) or not accessible (GP).
1767 +        * We need to take care of WD2-MPU or take a PRCM reset. WD3
1768 +        * should not be running and does not generate a PRCM reset.
1769 +        */
1770 +
1771 +       sr32(CM_FCLKEN_WKUP, 5, 1, 1);
1772 +       sr32(CM_ICLKEN_WKUP, 5, 1, 1);
1773 +       wait_on_value(BIT5, 0x20, CM_IDLEST_WKUP, 5);   /* some issue here */
1774 +
1775 +       __raw_writel(WD_UNLOCK1, WD2_BASE + WSPR);
1776 +       wait_for_command_complete(WD2_BASE);
1777 +       __raw_writel(WD_UNLOCK2, WD2_BASE + WSPR);
1778 +}
1779 +
1780 +/******************************************************************************
1781 + * Routine: dram_init
1782 + * Description: sets uboots idea of sdram size
1783 + *****************************************************************************/
1784 +int dram_init(void)
1785 +{
1786 +       DECLARE_GLOBAL_DATA_PTR;
1787 +       unsigned int size0 = 0, size1 = 0;
1788 +       u32 mtype, btype;
1789 +
1790 +       btype = get_board_type();
1791 +       mtype = get_mem_type();
1792 +
1793 +       display_board_info(btype);
1794 +
1795 +       /* If a second bank of DDR is attached to CS1 this is
1796 +        * where it can be started.  Early init code will init
1797 +        * memory on CS0.
1798 +        */
1799 +       if ((mtype == DDR_COMBO) || (mtype == DDR_STACKED))
1800 +               do_sdrc_init(SDRC_CS1_OSET, NOT_EARLY);
1801 +
1802 +       size0 = get_sdr_cs_size(SDRC_CS0_OSET);
1803 +       size1 = get_sdr_cs_size(SDRC_CS1_OSET);
1804 +
1805 +       gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
1806 +       gd->bd->bi_dram[0].size = size0;
1807 +       gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + size0;
1808 +       gd->bd->bi_dram[1].size = size1;
1809 +
1810 +       return 0;
1811 +}
1812 +
1813 +/******************************************************************************
1814 + * Routine: set_muxconf_regs
1815 + * Description: Setting up the configuration Mux registers specific to the
1816 + *              hardware. Many pins need to be moved from protect to primary
1817 + *              mode.
1818 + *****************************************************************************/
1819 +void set_muxconf_regs(void)
1820 +{
1821 +       MUX_DEFAULT_ES2();
1822 +}
1823 +
1824 +#if (CONFIG_COMMANDS & CFG_CMD_NAND) && defined(CFG_NAND_LEGACY)
1825 +/******************************************************************************
1826 + * Routine: nand+_init
1827 + * Description: Set up nand for nand and jffs2 commands
1828 + *****************************************************************************/
1829 +void nand_init(void)
1830 +{
1831 +       extern flash_info_t flash_info[];
1832 +
1833 +       nand_probe(CFG_NAND_ADDR);
1834 +       if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN)
1835 +               print_size(nand_dev_desc[0].totlen, "\n");
1836 +
1837 +#ifdef CFG_JFFS2_MEM_NAND
1838 +       flash_info[CFG_JFFS2_FIRST_BANK].flash_id = nand_dev_desc[0].id;
1839 +       /* only read kernel single meg partition */
1840 +       flash_info[CFG_JFFS2_FIRST_BANK].size = 1024 * 1024 * 2;
1841 +       /* 1024 blocks in 16meg chip (use less for raw/copied partition) */
1842 +       flash_info[CFG_JFFS2_FIRST_BANK].sector_count = 1024;
1843 +       /* ?, ram for now, open question, copy to RAM or adapt for NAND */
1844 +       flash_info[CFG_JFFS2_FIRST_BANK].start[0] = 0x80200000;
1845 +#endif
1846 +}
1847 +#endif
1848 +
1849 +/******************************************************************************
1850 + * Dummy function to handle errors for EABI incompatibility
1851 + *****************************************************************************/
1852 +void raise(void)
1853 +{
1854 +}
1855 +
1856 +/******************************************************************************
1857 + * Dummy function to handle errors for EABI incompatibility
1858 + *****************************************************************************/
1859 +void abort(void)
1860 +{
1861 +}
1862 diff --git a/board/omap3530beagle/sys_info.c b/board/omap3530beagle/sys_info.c
1863 new file mode 100644
1864 index 0000000..a275557
1865 --- /dev/null
1866 +++ b/board/omap3530beagle/sys_info.c
1867 @@ -0,0 +1,309 @@
1868 +/*
1869 + * (C) Copyright 2008
1870 + * Texas Instruments, <www.ti.com>
1871 + *
1872 + * Derived from Beagle Board and 3430 SDP code by
1873 + *      Richard Woodruff <r-woodruff2@ti.com>
1874 + *      Syed Mohammed Khasim <khasim@ti.com>
1875 + *
1876 + * This program is free software; you can redistribute it and/or
1877 + * modify it under the terms of the GNU General Public License as
1878 + * published by the Free Software Foundation; either version 2 of
1879 + * the License, or (at your option) any later version.
1880 + *
1881 + * This program is distributed in the hope that it will be useful,
1882 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1883 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
1884 + * GNU General Public License for more details.
1885 + *
1886 + * You should have received a copy of the GNU General Public License
1887 + * along with this program; if not, write to the Free Software
1888 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1889 + * MA 02111-1307 USA
1890 + */
1891 +
1892 +#include <common.h>
1893 +#include <asm/io.h>
1894 +#include <asm/arch/bits.h>
1895 +#include <asm/arch/mem.h>      /* get mem tables */
1896 +#include <asm/arch/sys_proto.h>
1897 +#include <i2c.h>
1898 +
1899 +/**************************************************************************
1900 + * get_gpmc0_type()
1901 + ***************************************************************************/
1902 +u32 get_gpmc0_type(void)
1903 +{
1904 +       /* Default NAND */
1905 +       return (2);
1906 +}
1907 +
1908 +/****************************************************
1909 + * get_cpu_type() - low level get cpu type
1910 + * - no C globals yet.
1911 + ****************************************************/
1912 +u32 get_cpu_type(void)
1913 +{
1914 +       /* fixme, need to get register defines for OMAP3 */
1915 +       return (CPU_3430);
1916 +}
1917 +
1918 +/******************************************
1919 + * get_cpu_rev(void) - extract version info
1920 + ******************************************/
1921 +u32 get_cpu_rev(void)
1922 +{
1923 +       u32 cpuid = 0;
1924 +       /* On ES1.0 the IDCODE register is not exposed on L4
1925 +        * so using CPU ID to differentiate
1926 +        * between ES2.0 and ES1.0.
1927 +        */
1928 +       __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
1929 +       if ((cpuid & 0xf) == 0x0)
1930 +               return CPU_3430_ES1;
1931 +       else
1932 +               return CPU_3430_ES2;
1933 +
1934 +}
1935 +
1936 +/****************************************************
1937 + * is_mem_sdr() - return 1 if mem type in use is SDR
1938 + ****************************************************/
1939 +u32 is_mem_sdr(void)
1940 +{
1941 +       volatile u32 *burst = (volatile u32 *) (SDRC_MR_0 + SDRC_CS0_OSET);
1942 +       if (*burst == SDP_SDRC_MR_0_SDR)
1943 +               return (1);
1944 +       return (0);
1945 +}
1946 +
1947 +/***********************************************************
1948 + * get_mem_type() - identify type of mDDR part used.
1949 + ***********************************************************/
1950 +u32 get_mem_type(void)
1951 +{
1952 +       /* Current SDP3430 uses 2x16 MDDR Infenion parts */
1953 +       return (DDR_DISCRETE);
1954 +}
1955 +
1956 +/***********************************************************************
1957 + * get_cs0_size() - get size of chip select 0/1
1958 + ************************************************************************/
1959 +u32 get_sdr_cs_size(u32 offset)
1960 +{
1961 +       u32 size;
1962 +
1963 +       /* get ram size field */
1964 +       size = __raw_readl(SDRC_MCFG_0 + offset) >> 8;
1965 +       size &= 0x3FF;          /* remove unwanted bits */
1966 +       size *= SZ_2M;          /* find size in MB */
1967 +       return (size);
1968 +}
1969 +
1970 +/***********************************************************************
1971 + * get_board_type() - get board type based on current production stats.
1972 + *  - NOTE-1-: 2 I2C EEPROMs will someday be populated with proper info.
1973 + *    when they are available we can get info from there.  This should
1974 + *    be correct of all known boards up until today.
1975 + *  - NOTE-2- EEPROMs are populated but they are updated very slowly.  To
1976 + *    avoid waiting on them we will use ES version of the chip to get info.
1977 + *    A later version of the FPGA migth solve their speed issue.
1978 + ************************************************************************/
1979 +u32 get_board_type(void)
1980 +{
1981 +       if (get_cpu_rev() == CPU_3430_ES2)
1982 +               return SDP_3430_V2;
1983 +       else
1984 +               return SDP_3430_V1;
1985 +}
1986 +
1987 +/******************************************************************
1988 + * get_sysboot_value() - get init word settings
1989 + ******************************************************************/
1990 +inline u32 get_sysboot_value(void)
1991 +{
1992 +       return (0x0000003F & __raw_readl(CONTROL_STATUS));
1993 +}
1994 +
1995 +/***************************************************************************
1996 + *  get_gpmc0_base() - Return current address hardware will be
1997 + *     fetching from. The below effectively gives what is correct, its a bit
1998 + *   mis-leading compared to the TRM.  For the most general case the mask
1999 + *   needs to be also taken into account this does work in practice.
2000 + *   - for u-boot we currently map:
2001 + *       -- 0 to nothing,
2002 + *       -- 4 to flash
2003 + *       -- 8 to enent
2004 + *       -- c to wifi
2005 + ****************************************************************************/
2006 +u32 get_gpmc0_base(void)
2007 +{
2008 +       u32 b;
2009 +
2010 +       b = __raw_readl(GPMC_CONFIG_CS0 + GPMC_CONFIG7);
2011 +       b &= 0x1F;              /* keep base [5:0] */
2012 +       b = b << 24;            /* ret 0x0b000000 */
2013 +       return (b);
2014 +}
2015 +
2016 +/*******************************************************************
2017 + * get_gpmc0_width() - See if bus is in x8 or x16 (mainly for nand)
2018 + *******************************************************************/
2019 +u32 get_gpmc0_width(void)
2020 +{
2021 +       return (WIDTH_16BIT);
2022 +}
2023 +
2024 +/*************************************************************************
2025 + * get_board_rev() - setup to pass kernel board revision information
2026 + * returns:(bit[0-3] sub version, higher bit[7-4] is higher version)
2027 + *************************************************************************/
2028 +u32 get_board_rev(void)
2029 +{
2030 +       return (0x20);
2031 +}
2032 +
2033 +/*********************************************************************
2034 + *  display_board_info() - print banner with board info.
2035 + *********************************************************************/
2036 +void display_board_info(u32 btype)
2037 +{
2038 +       char *bootmode[] = {
2039 +               "NOR",
2040 +               "ONND",
2041 +               "NAND",
2042 +               "P2a",
2043 +               "NOR",
2044 +               "NOR",
2045 +               "P2a",
2046 +               "P2b",
2047 +       };
2048 +       u32 brev = get_board_rev();
2049 +       char cpu_3430s[] = "3530";
2050 +       char db_ver[] = "0.0";  /* board type */
2051 +       char mem_sdr[] = "mSDR";        /* memory type */
2052 +       char mem_ddr[] = "LPDDR";
2053 +       char t_tst[] = "TST";   /* security level */
2054 +       char t_emu[] = "EMU";
2055 +       char t_hs[] = "HS";
2056 +       char t_gp[] = "GP";
2057 +       char unk[] = "?";
2058 +#ifdef CONFIG_LED_INFO
2059 +       char led_string[CONFIG_LED_LEN] = { 0 };
2060 +#endif
2061 +       char p_l3[] = "165";
2062 +       char p_cpu[] = "2";
2063 +
2064 +       char *cpu_s, *db_s, *mem_s, *sec_s;
2065 +       u32 cpu, rev, sec;
2066 +
2067 +       rev = get_cpu_rev();
2068 +       cpu = get_cpu_type();
2069 +       sec = get_device_type();
2070 +
2071 +       if (is_mem_sdr())
2072 +               mem_s = mem_sdr;
2073 +       else
2074 +               mem_s = mem_ddr;
2075 +
2076 +       cpu_s = cpu_3430s;
2077 +
2078 +       db_s = db_ver;
2079 +       db_s[0] += (brev >> 4) & 0xF;
2080 +       db_s[2] += brev & 0xF;
2081 +
2082 +       switch (sec) {
2083 +       case TST_DEVICE:
2084 +               sec_s = t_tst;
2085 +               break;
2086 +       case EMU_DEVICE:
2087 +               sec_s = t_emu;
2088 +               break;
2089 +       case HS_DEVICE:
2090 +               sec_s = t_hs;
2091 +               break;
2092 +       case GP_DEVICE:
2093 +               sec_s = t_gp;
2094 +               break;
2095 +       default:
2096 +               sec_s = unk;
2097 +       }
2098 +
2099 +       printf("OMAP%s-%s rev %d, CPU-OPP%s L3-%sMHz\n", cpu_s, sec_s, rev,
2100 +              p_cpu, p_l3);
2101 +       printf("OMAP3 Beagle Board + %s/%s\n",
2102 +              mem_s, bootmode[get_gpmc0_type()]);
2103 +
2104 +}
2105 +
2106 +/********************************************************
2107 + *  get_base(); get upper addr of current execution
2108 + *******************************************************/
2109 +u32 get_base(void)
2110 +{
2111 +       u32 val;
2112 +
2113 +       __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
2114 +       val &= 0xF0000000;
2115 +       val >>= 28;
2116 +       return (val);
2117 +}
2118 +
2119 +/********************************************************
2120 + *  running_in_flash() - tell if currently running in
2121 + *   flash.
2122 + *******************************************************/
2123 +u32 running_in_flash(void)
2124 +{
2125 +       if (get_base() < 4)
2126 +               return (1);     /* in flash */
2127 +
2128 +       return (0);             /* running in SRAM or SDRAM */
2129 +}
2130 +
2131 +/********************************************************
2132 + *  running_in_sram() - tell if currently running in
2133 + *   sram.
2134 + *******************************************************/
2135 +u32 running_in_sram(void)
2136 +{
2137 +       if (get_base() == 4)
2138 +               return (1);     /* in SRAM */
2139 +
2140 +       return (0);             /* running in FLASH or SDRAM */
2141 +}
2142 +
2143 +/********************************************************
2144 + *  running_in_sdram() - tell if currently running in
2145 + *   flash.
2146 + *******************************************************/
2147 +u32 running_in_sdram(void)
2148 +{
2149 +       if (get_base() > 4)
2150 +               return (1);     /* in sdram */
2151 +
2152 +       return (0);             /* running in SRAM or FLASH */
2153 +}
2154 +
2155 +/***************************************************************
2156 + *  get_boot_type() - Is this an XIP type device or a stream one
2157 + *   bits 4-0 specify type.  Bit 5 sys mem/perif
2158 + ***************************************************************/
2159 +u32 get_boot_type(void)
2160 +{
2161 +       u32 v;
2162 +
2163 +       v = get_sysboot_value() & (BIT4 | BIT3 | BIT2 | BIT1 | BIT0);
2164 +       return v;
2165 +}
2166 +
2167 +/*************************************************************
2168 + *  get_device_type(): tell if GP/HS/EMU/TST
2169 + *************************************************************/
2170 +u32 get_device_type(void)
2171 +{
2172 +       int mode;
2173 +
2174 +       mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
2175 +       return (mode >>= 8);
2176 +}
2177 diff --git a/board/omap3530beagle/syslib.c b/board/omap3530beagle/syslib.c
2178 new file mode 100644
2179 index 0000000..002c6e8
2180 --- /dev/null
2181 +++ b/board/omap3530beagle/syslib.c
2182 @@ -0,0 +1,72 @@
2183 +/*
2184 + * (C) Copyright 2008
2185 + * Texas Instruments, <www.ti.com>
2186 + *
2187 + * Richard Woodruff <r-woodruff2@ti.com>
2188 + * Syed Mohammed Khasim <khasim@ti.com>
2189 + *
2190 + * This program is free software; you can redistribute it and/or
2191 + * modify it under the terms of the GNU General Public License as
2192 + * published by the Free Software Foundation; either version 2 of
2193 + * the License, or (at your option) any later version.
2194 + *
2195 + * This program is distributed in the hope that it will be useful,
2196 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2197 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2198 + * GNU General Public License for more details.
2199 + *
2200 + * You should have received a copy of the GNU General Public License
2201 + * along with this program; if not, write to the Free Software
2202 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2203 + * MA 02111-1307 USA
2204 + */
2205 +
2206 +#include <common.h>
2207 +#include <asm/io.h>
2208 +#include <asm/arch/bits.h>
2209 +#include <asm/arch/mem.h>
2210 +#include <asm/arch/clocks.h>
2211 +#include <asm/arch/sys_proto.h>
2212 +
2213 +/************************************************************
2214 + * sdelay() - simple spin loop.  Will be constant time as
2215 + *  its generally used in bypass conditions only.  This
2216 + *  is necessary until timers are accessible.
2217 + *
2218 + *  not inline to increase chances its in cache when called
2219 + *************************************************************/
2220 +void sdelay(unsigned long loops)
2221 +{
2222 +       __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
2223 +                         "bne 1b":"=r" (loops):"0"(loops));
2224 +}
2225 +
2226 +/*****************************************************************
2227 + * sr32 - clear & set a value in a bit range for a 32 bit address
2228 + *****************************************************************/
2229 +void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
2230 +{
2231 +       u32 tmp, msk = 0;
2232 +       msk = 1 << num_bits;
2233 +       --msk;
2234 +       tmp = __raw_readl(addr) & ~(msk << start_bit);
2235 +       tmp |= value << start_bit;
2236 +       __raw_writel(tmp, addr);
2237 +}
2238 +
2239 +/*********************************************************************
2240 + * wait_on_value() - common routine to allow waiting for changes in
2241 + *   volatile regs.
2242 + *********************************************************************/
2243 +u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
2244 +{
2245 +       u32 i = 0, val;
2246 +       do {
2247 +               ++i;
2248 +               val = __raw_readl(read_addr) & read_bit_mask;
2249 +               if (val == match_value)
2250 +                       return (1);
2251 +               if (i == bound)
2252 +                       return (0);
2253 +       } while (1);
2254 +}
2255 diff --git a/board/omap3530beagle/u-boot.lds b/board/omap3530beagle/u-boot.lds
2256 new file mode 100644
2257 index 0000000..72f15f6
2258 --- /dev/null
2259 +++ b/board/omap3530beagle/u-boot.lds
2260 @@ -0,0 +1,63 @@
2261 +/*
2262 + * January 2004 - Changed to support H4 device 
2263 + * Copyright (c) 2004 Texas Instruments 
2264 + *
2265 + * (C) Copyright 2002
2266 + * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
2267 + *
2268 + * See file CREDITS for list of people who contributed to this
2269 + * project.
2270 + *
2271 + * This program is free software; you can redistribute it and/or
2272 + * modify it under the terms of the GNU General Public License as
2273 + * published by the Free Software Foundation; either version 2 of
2274 + * the License, or (at your option) any later version.
2275 + *
2276 + * This program is distributed in the hope that it will be useful,
2277 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2278 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2279 + * GNU General Public License for more details.
2280 + *
2281 + * You should have received a copy of the GNU General Public License
2282 + * along with this program; if not, write to the Free Software
2283 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2284 + * MA 02111-1307 USA
2285 + */
2286 +
2287 +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
2288 +OUTPUT_ARCH(arm)
2289 +ENTRY(_start)
2290 +SECTIONS
2291 +{
2292 +       . = 0x00000000;
2293 +
2294 +       . = ALIGN(4);
2295 +       .text      :
2296 +       {
2297 +         cpu/omap3/start.o     (.text)
2298 +         *(.text)
2299 +       }
2300 +
2301 +       . = ALIGN(4);
2302 +       .rodata : { *(.rodata) }
2303 +
2304 +       .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) }
2305 +       __exidx_start = .;
2306 +       .ARM.exidx   : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
2307 +       __exidx_end = .;
2308 +
2309 +       . = ALIGN(4);
2310 +       .data : { *(.data) }
2311 +
2312 +       . = ALIGN(4);
2313 +       .got : { *(.got) }
2314 +
2315 +       __u_boot_cmd_start = .;
2316 +       .u_boot_cmd : { *(.u_boot_cmd) }
2317 +       __u_boot_cmd_end = .;
2318 +
2319 +       . = ALIGN(4);
2320 +       __bss_start = .;
2321 +       .bss : { *(.bss) }
2322 +       _end = .;
2323 +}
2324 diff --git a/common/cmd_nand.c b/common/cmd_nand.c
2325 index 9e38bf7..0ae362c 100644
2326 --- a/common/cmd_nand.c
2327 +++ b/common/cmd_nand.c
2328 @@ -37,6 +37,12 @@ int find_dev_and_part(const char *id, struct mtd_device **dev,
2329                 u8 *part_num, struct part_info **part);
2330  #endif
2331  
2332 +#if defined(CONFIG_OMAP) && (defined(CONFIG_OMAP3_BEAGLE))
2333 +extern void omap_nand_switch_ecc(nand_info_t *nand, int hardware);
2334 +#else
2335 +#define omap_nand_switch_ecc(x, y) do {} while(0)
2336 +#endif
2337 +
2338  static int nand_dump_oob(nand_info_t *nand, ulong off)
2339  {
2340         return 0;
2341 @@ -222,7 +228,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
2342             strncmp(cmd, "dump", 4) != 0 &&
2343             strncmp(cmd, "read", 4) != 0 && strncmp(cmd, "write", 5) != 0 &&
2344             strcmp(cmd, "scrub") != 0 && strcmp(cmd, "markbad") != 0 &&
2345 -           strcmp(cmd, "biterr") != 0 &&
2346 +           strcmp(cmd, "biterr") != 0 && strncmp(cmd, "ecc", 3) != 0 &&
2347             strcmp(cmd, "lock") != 0 && strcmp(cmd, "unlock") != 0 )
2348                 goto usage;
2349  
2350 @@ -307,6 +313,19 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
2351  
2352         }
2353  
2354 +       if (strncmp(cmd, "ecc", 3) == 0) {
2355 +               if (argc < 2)
2356 +                       goto usage;
2357 +               if (strncmp(argv[2], "hw", 2) == 0)
2358 +                       omap_nand_switch_ecc(nand, 1);
2359 +               else if (strncmp(argv[2], "sw", 2) == 0)
2360 +                       omap_nand_switch_ecc(nand, 0);
2361 +               else
2362 +                       goto usage;
2363 +
2364 +               return 0;
2365 +       }
2366 +
2367         /* read write */
2368         if (strncmp(cmd, "read", 4) == 0 || strncmp(cmd, "write", 5) == 0) {
2369                 int read;
2370 @@ -472,6 +491,7 @@ U_BOOT_CMD(nand, 5, 1, do_nand,
2371         "nand scrub - really clean NAND erasing bad blocks (UNSAFE)\n"
2372         "nand markbad off - mark bad block at offset (UNSAFE)\n"
2373         "nand biterr off - make a bit error at offset (UNSAFE)\n"
2374 +       "nand ecc [hw/sw] - switch the ecc calculation algorithm \n"
2375         "nand lock [tight] [status] - bring nand to lock state or display locked pages\n"
2376         "nand unlock [offset] [size] - unlock section\n");
2377  
2378 diff --git a/cpu/omap3/Makefile b/cpu/omap3/Makefile
2379 new file mode 100644
2380 index 0000000..097447a
2381 --- /dev/null
2382 +++ b/cpu/omap3/Makefile
2383 @@ -0,0 +1,43 @@
2384 +#
2385 +# (C) Copyright 2000-2003
2386 +# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
2387 +#
2388 +# See file CREDITS for list of people who contributed to this
2389 +# project.
2390 +#
2391 +# This program is free software; you can redistribute it and/or
2392 +# modify it under the terms of the GNU General Public License as
2393 +# published by the Free Software Foundation; either version 2 of
2394 +# the License, or (at your option) any later version.
2395 +#
2396 +# This program is distributed in the hope that it will be useful,
2397 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2398 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2399 +# GNU General Public License for more details.
2400 +#
2401 +# You should have received a copy of the GNU General Public License
2402 +# along with this program; if not, write to the Free Software
2403 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2404 +# MA 02111-1307 USA
2405 +#
2406 +
2407 +include $(TOPDIR)/config.mk
2408 +
2409 +LIB    = lib$(CPU).a
2410 +
2411 +START  = start.o
2412 +OBJS   = interrupts.o cpu.o mmc.o
2413 +
2414 +all:   .depend $(START) $(LIB)
2415 +
2416 +$(LIB):        $(OBJS)
2417 +       $(AR) crv $@ $(OBJS)
2418 +
2419 +#########################################################################
2420 +
2421 +.depend:       Makefile $(START:.o=.S) $(OBJS:.o=.c)
2422 +               $(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
2423 +
2424 +sinclude .depend
2425 +
2426 +#########################################################################
2427 diff --git a/cpu/omap3/config.mk b/cpu/omap3/config.mk
2428 new file mode 100644
2429 index 0000000..7551677
2430 --- /dev/null
2431 +++ b/cpu/omap3/config.mk
2432 @@ -0,0 +1,34 @@
2433 +#
2434 +# (C) Copyright 2002
2435 +# Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
2436 +#
2437 +# See file CREDITS for list of people who contributed to this
2438 +# project.
2439 +#
2440 +# This program is free software; you can redistribute it and/or
2441 +# modify it under the terms of the GNU General Public License as
2442 +# published by the Free Software Foundation; either version 2 of
2443 +# the License, or (at your option) any later version.
2444 +#
2445 +# This program is distributed in the hope that it will be useful,
2446 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
2447 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2448 +# GNU General Public License for more details.
2449 +#
2450 +# You should have received a copy of the GNU General Public License
2451 +# along with this program; if not, write to the Free Software
2452 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2453 +# MA 02111-1307 USA
2454 +#
2455 +PLATFORM_RELFLAGS += -fno-strict-aliasing  -fno-common -ffixed-r8 \
2456 +       -msoft-float
2457 +
2458 +PLATFORM_CPPFLAGS += -march=armv7a
2459 +# =========================================================================
2460 +#
2461 +# Supply options according to compiler version
2462 +#
2463 +# =========================================================================
2464 +#PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
2465 +PLATFORM_CPPFLAGS +=$(call cc-option)
2466 +PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
2467 diff --git a/cpu/omap3/cpu.c b/cpu/omap3/cpu.c
2468 new file mode 100644
2469 index 0000000..59e6a58
2470 --- /dev/null
2471 +++ b/cpu/omap3/cpu.c
2472 @@ -0,0 +1,221 @@
2473 +/*
2474 + * (C) Copyright 2008 Texas Insturments
2475 + *
2476 + * (C) Copyright 2002
2477 + * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
2478 + * Marius Groeger <mgroeger@sysgo.de>
2479 + *
2480 + * (C) Copyright 2002
2481 + * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
2482 + *
2483 + * See file CREDITS for list of people who contributed to this
2484 + * project.
2485 + *
2486 + * This program is free software; you can redistribute it and/or
2487 + * modify it under the terms of the GNU General Public License as
2488 + * published by the Free Software Foundation; either version 2 of
2489 + * the License, or (at your option) any later version.
2490 + *
2491 + * This program is distributed in the hope that it will be useful,
2492 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2493 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2494 + * GNU General Public License for more details.
2495 + *
2496 + * You should have received a copy of the GNU General Public License
2497 + * along with this program; if not, write to the Free Software
2498 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2499 + * MA 02111-1307 USA
2500 + */
2501 +
2502 +/*
2503 + * CPU specific code
2504 + */
2505 +
2506 +#include <common.h>
2507 +#include <command.h>
2508 +#include <asm/arch/sys_proto.h>
2509 +
2510 +#ifdef CONFIG_USE_IRQ
2511 +DECLARE_GLOBAL_DATA_PTR;
2512 +#endif
2513 +
2514 +#ifndef CONFIG_L2_OFF
2515 +void l2cache_disable(void);
2516 +#endif
2517 +
2518 +/* read co-processor 15, register #1 (control register) */
2519 +static unsigned long read_p15_c1(void)
2520 +{
2521 +       unsigned long value;
2522 +
2523 +       __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 0\
2524 +                            @ read control reg\n":"=r"(value)
2525 +                            ::"memory");
2526 +       return value;
2527 +}
2528 +
2529 +/* write to co-processor 15, register #1 (control register) */
2530 +static void write_p15_c1(unsigned long value)
2531 +{
2532 +       __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 0\
2533 +                            @ write it back\n"::"r"(value)
2534 +                            : "memory");
2535 +
2536 +       read_p15_c1();
2537 +}
2538 +
2539 +static void cp_delay(void)
2540 +{
2541 +       volatile int i;
2542 +
2543 +       /* Many OMAP regs need at least 2 nops  */
2544 +       for (i = 0; i < 100; i++) ;
2545 +}
2546 +
2547 +/* See also ARM Ref. Man. */
2548 +#define C1_MMU         (1<<0)  /* mmu off/on */
2549 +#define C1_ALIGN       (1<<1)  /* alignment faults off/on */
2550 +#define C1_DC          (1<<2)  /* dcache off/on */
2551 +#define C1_WB          (1<<3)  /* merging write buffer on/off */
2552 +#define C1_BIG_ENDIAN  (1<<7)  /* big endian off/on */
2553 +#define C1_SYS_PROT    (1<<8)  /* system protection */
2554 +#define C1_ROM_PROT    (1<<9)  /* ROM protection */
2555 +#define C1_IC          (1<<12) /* icache off/on */
2556 +#define C1_HIGH_VECTORS        (1<<13) /* location of vectors: low/high addresses */
2557 +#define RESERVED_1     (0xf << 3)      /* must be 111b for R/W */
2558 +
2559 +int cpu_init(void)
2560 +{
2561 +       /*
2562 +        * setup up stacks if necessary
2563 +        */
2564 +#ifdef CONFIG_USE_IRQ
2565 +       IRQ_STACK_START =
2566 +           _armboot_start - CFG_MALLOC_LEN - CFG_GBL_DATA_SIZE - 4;
2567 +       FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ;
2568 +#endif
2569 +       return 0;
2570 +}
2571 +
2572 +int cleanup_before_linux(void)
2573 +{
2574 +       unsigned int i;
2575 +
2576 +       /*
2577 +        * this function is called just before we call linux
2578 +        * it prepares the processor for linux
2579 +        *
2580 +        * we turn off caches etc ...
2581 +        */
2582 +       disable_interrupts();
2583 +
2584 +       /* turn off I/D-cache */
2585 +       asm("mrc p15, 0, %0, c1, c0, 0":"=r"(i));
2586 +       i &= ~(C1_DC | C1_IC);
2587 +       asm("mcr p15, 0, %0, c1, c0, 0": :"r"(i));
2588 +
2589 +       /* invalidate I-cache */
2590 +       arm_cache_flush();
2591 +#ifndef CONFIG_L2_OFF
2592 +       /* turn off L2 cache */
2593 +       l2cache_disable();
2594 +       /* invalidate L2 cache also */
2595 +       v7_flush_dcache_all(get_device_type());
2596 +#endif
2597 +       i = 0;
2598 +       /* mem barrier to sync up things */
2599 +       asm("mcr p15, 0, %0, c7, c10, 4": :"r"(i));
2600 +
2601 +#ifndef CONFIG_L2_OFF
2602 +       l2cache_enable();
2603 +#endif
2604 +
2605 +       return (0);
2606 +}
2607 +
2608 +int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2609 +{
2610 +       disable_interrupts();
2611 +       reset_cpu(0);
2612 +
2613 +       /* NOTREACHED */
2614 +       return (0);
2615 +}
2616 +
2617 +void icache_enable(void)
2618 +{
2619 +       ulong reg;
2620 +
2621 +       reg = read_p15_c1();    /* get control reg. */
2622 +       cp_delay();
2623 +       write_p15_c1(reg | C1_IC);
2624 +}
2625 +
2626 +void icache_disable(void)
2627 +{
2628 +       ulong reg;
2629 +
2630 +       reg = read_p15_c1();
2631 +       cp_delay();
2632 +       write_p15_c1(reg & ~C1_IC);
2633 +}
2634 +
2635 +void l2cache_enable()
2636 +{
2637 +       unsigned long i;
2638 +       volatile unsigned int j;
2639 +
2640 +       /* ES2 onwards we can disable/enable L2 ourselves */
2641 +       if (get_cpu_rev() == CPU_3430_ES2) {
2642 +               __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i));
2643 +               __asm__ __volatile__("orr %0, %0, #0x2":"=r"(i));
2644 +               __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i));
2645 +       } else {
2646 +               /* Save r0, r12 and restore them after usage */
2647 +               __asm__ __volatile__("mov %0, r12":"=r"(j));
2648 +               __asm__ __volatile__("mov %0, r0":"=r"(i));
2649 +
2650 +               /* GP Device ROM code API usage here */
2651 +               /* r12 = AUXCR Write function and r0 value */
2652 +               __asm__ __volatile__("mov r12, #0x3");
2653 +               __asm__ __volatile__("mrc p15, 0, r0, c1, c0, 1");
2654 +               __asm__ __volatile__("orr r0, r0, #0x2");
2655 +               /* SMI instruction to call ROM Code API */
2656 +               __asm__ __volatile__(".word 0xE1600070");
2657 +               __asm__ __volatile__("mov r0, %0":"=r"(i));
2658 +               __asm__ __volatile__("mov r12, %0":"=r"(j));
2659 +       }
2660 +
2661 +}
2662 +
2663 +void l2cache_disable()
2664 +{
2665 +       unsigned long i;
2666 +       volatile unsigned int j;
2667 +
2668 +       /* ES2 onwards we can disable/enable L2 ourselves */
2669 +       if (get_cpu_rev() == CPU_3430_ES2) {
2670 +               __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i));
2671 +               __asm__ __volatile__("bic %0, %0, #0x2":"=r"(i));
2672 +               __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i));
2673 +       } else {
2674 +               /* Save r0, r12 and restore them after usage */
2675 +               __asm__ __volatile__("mov %0, r12":"=r"(j));
2676 +               __asm__ __volatile__("mov %0, r0":"=r"(i));
2677 +
2678 +               /* GP Device ROM code API usage here */
2679 +               /* r12 = AUXCR Write function and r0 value */
2680 +               __asm__ __volatile__("mov r12, #0x3");
2681 +               __asm__ __volatile__("mrc p15, 0, r0, c1, c0, 1");
2682 +               __asm__ __volatile__("bic r0, r0, #0x2");
2683 +               /* SMI instruction to call ROM Code API */
2684 +               __asm__ __volatile__(".word 0xE1600070");
2685 +               __asm__ __volatile__("mov r0, %0":"=r"(i));
2686 +               __asm__ __volatile__("mov r12, %0":"=r"(j));
2687 +       }
2688 +}
2689 +
2690 +int icache_status(void)
2691 +{
2692 +       return (read_p15_c1() & C1_IC) != 0;
2693 +}
2694 diff --git a/cpu/omap3/interrupts.c b/cpu/omap3/interrupts.c
2695 new file mode 100644
2696 index 0000000..818b833
2697 --- /dev/null
2698 +++ b/cpu/omap3/interrupts.c
2699 @@ -0,0 +1,304 @@
2700 +/*
2701 + * (C) Copyright 2008
2702 + * Texas Instruments
2703 + *
2704 + * Richard Woodruff <r-woodruff2@ti.com>
2705 + * Syed Moahmmed Khasim <khasim@ti.com>
2706 + *
2707 + * (C) Copyright 2002
2708 + * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
2709 + * Marius Groeger <mgroeger@sysgo.de>
2710 + * Alex Zuepke <azu@sysgo.de>
2711 + *
2712 + * (C) Copyright 2002
2713 + * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
2714 + *
2715 + * See file CREDITS for list of people who contributed to this
2716 + * project.
2717 + *
2718 + * This program is free software; you can redistribute it and/or
2719 + * modify it under the terms of the GNU General Public License as
2720 + * published by the Free Software Foundation; either version 2 of
2721 + * the License, or (at your option) any later version.
2722 + *
2723 + * This program is distributed in the hope that it will be useful,
2724 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2725 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2726 + * GNU General Public License for more details.
2727 + *
2728 + * You should have received a copy of the GNU General Public License
2729 + * along with this program; if not, write to the Free Software
2730 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2731 + * MA 02111-1307 USA
2732 + */
2733 +
2734 +#include <common.h>
2735 +#include <asm/arch/bits.h>
2736 +
2737 +#include <asm/proc-armv/ptrace.h>
2738 +
2739 +#define TIMER_LOAD_VAL 0
2740 +
2741 +/* macro to read the 32 bit timer */
2742 +#define READ_TIMER (*(volatile ulong *)(CFG_TIMERBASE+TCRR))
2743 +
2744 +#ifdef CONFIG_USE_IRQ
2745 +/* enable IRQ interrupts */
2746 +void enable_interrupts(void)
2747 +{
2748 +       unsigned long temp;
2749 +       __asm__ __volatile__("mrs %0, cpsr\n"
2750 +                            "bic %0, %0, #0x80\n" "msr cpsr_c, %0":"=r"(temp)
2751 +                            ::"memory");
2752 +}
2753 +
2754 +/*
2755 + * disable IRQ/FIQ interrupts
2756 + * returns true if interrupts had been enabled before we disabled them
2757 + */
2758 +int disable_interrupts(void)
2759 +{
2760 +       unsigned long old, temp;
2761 +       __asm__ __volatile__("mrs %0, cpsr\n"
2762 +                            "orr %1, %0, #0xc0\n"
2763 +                            "msr cpsr_c, %1":"=r"(old), "=r"(temp)
2764 +                            ::"memory");
2765 +       return (old & 0x80) == 0;
2766 +}
2767 +#else
2768 +void enable_interrupts(void)
2769 +{
2770 +       return;
2771 +}
2772 +int disable_interrupts(void)
2773 +{
2774 +       return 0;
2775 +}
2776 +#endif
2777 +
2778 +void bad_mode(void)
2779 +{
2780 +       panic("Resetting CPU ...\n");
2781 +       reset_cpu(0);
2782 +}
2783 +
2784 +void show_regs(struct pt_regs *regs)
2785 +{
2786 +       unsigned long flags;
2787 +       const char *processor_modes[] = {
2788 +               "USER_26", "FIQ_26", "IRQ_26", "SVC_26",
2789 +               "UK4_26", "UK5_26", "UK6_26", "UK7_26",
2790 +               "UK8_26", "UK9_26", "UK10_26", "UK11_26",
2791 +               "UK12_26", "UK13_26", "UK14_26", "UK15_26",
2792 +               "USER_32", "FIQ_32", "IRQ_32", "SVC_32",
2793 +               "UK4_32", "UK5_32", "UK6_32", "ABT_32",
2794 +               "UK8_32", "UK9_32", "UK10_32", "UND_32",
2795 +               "UK12_32", "UK13_32", "UK14_32", "SYS_32",
2796 +       };
2797 +
2798 +       flags = condition_codes(regs);
2799 +
2800 +       printf("pc : [<%08lx>]    lr : [<%08lx>]\n"
2801 +              "sp : %08lx  ip : %08lx  fp : %08lx\n",
2802 +              instruction_pointer(regs),
2803 +              regs->ARM_lr, regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
2804 +       printf("r10: %08lx  r9 : %08lx  r8 : %08lx\n",
2805 +              regs->ARM_r10, regs->ARM_r9, regs->ARM_r8);
2806 +       printf("r7 : %08lx  r6 : %08lx  r5 : %08lx  r4 : %08lx\n",
2807 +              regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4);
2808 +       printf("r3 : %08lx  r2 : %08lx  r1 : %08lx  r0 : %08lx\n",
2809 +              regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0);
2810 +       printf("Flags: %c%c%c%c",
2811 +              flags & CC_N_BIT ? 'N' : 'n',
2812 +              flags & CC_Z_BIT ? 'Z' : 'z',
2813 +              flags & CC_C_BIT ? 'C' : 'c', flags & CC_V_BIT ? 'V' : 'v');
2814 +       printf("  IRQs %s  FIQs %s  Mode %s%s\n",
2815 +              interrupts_enabled(regs) ? "on" : "off",
2816 +              fast_interrupts_enabled(regs) ? "on" : "off",
2817 +              processor_modes[processor_mode(regs)],
2818 +              thumb_mode(regs) ? " (T)" : "");
2819 +}
2820 +
2821 +void do_undefined_instruction(struct pt_regs *pt_regs)
2822 +{
2823 +       printf("undefined instruction\n");
2824 +       show_regs(pt_regs);
2825 +       bad_mode();
2826 +}
2827 +
2828 +void do_software_interrupt(struct pt_regs *pt_regs)
2829 +{
2830 +       printf("software interrupt\n");
2831 +       show_regs(pt_regs);
2832 +       bad_mode();
2833 +}
2834 +
2835 +void do_prefetch_abort(struct pt_regs *pt_regs)
2836 +{
2837 +       printf("prefetch abort\n");
2838 +       show_regs(pt_regs);
2839 +       bad_mode();
2840 +}
2841 +
2842 +void do_data_abort(struct pt_regs *pt_regs)
2843 +{
2844 +       printf("data abort\n");
2845 +       show_regs(pt_regs);
2846 +       bad_mode();
2847 +}
2848 +
2849 +void do_not_used(struct pt_regs *pt_regs)
2850 +{
2851 +       printf("not used\n");
2852 +       show_regs(pt_regs);
2853 +       bad_mode();
2854 +}
2855 +
2856 +void do_fiq(struct pt_regs *pt_regs)
2857 +{
2858 +       printf("fast interrupt request\n");
2859 +       show_regs(pt_regs);
2860 +       bad_mode();
2861 +}
2862 +
2863 +void do_irq(struct pt_regs *pt_regs)
2864 +{
2865 +       printf("interrupt request\n");
2866 +       show_regs(pt_regs);
2867 +       bad_mode();
2868 +}
2869 +
2870 +
2871 +static ulong timestamp;
2872 +static ulong lastinc;
2873 +
2874 +/* nothing really to do with interrupts, just starts up a counter. */
2875 +int interrupt_init(void)
2876 +{
2877 +       int32_t val;
2878 +
2879 +       /* Start the counter ticking up */
2880 +       /* reload value on overflow */
2881 +       *((int32_t *) (CFG_TIMERBASE + TLDR)) = TIMER_LOAD_VAL;
2882 +       /* mask to enable timer */
2883 +       val = (CFG_PVT << 2) | BIT5 | BIT1 | BIT0;
2884 +       *((int32_t *) (CFG_TIMERBASE + TCLR)) = val;    /* start timer */
2885 +
2886 +       reset_timer_masked();   /* init the timestamp and lastinc value */
2887 +
2888 +       return (0);
2889 +}
2890 +
2891 +/*
2892 + * timer without interrupts
2893 + */
2894 +void reset_timer(void)
2895 +{
2896 +       reset_timer_masked();
2897 +}
2898 +
2899 +ulong get_timer(ulong base)
2900 +{
2901 +       return get_timer_masked() - base;
2902 +}
2903 +
2904 +void set_timer(ulong t)
2905 +{
2906 +       timestamp = t;
2907 +}
2908 +
2909 +/* delay x useconds AND perserve advance timstamp value */
2910 +void udelay(unsigned long usec)
2911 +{
2912 +       ulong tmo, tmp;
2913 +
2914 +       /* if "big" number, spread normalization to seconds */
2915 +       if (usec >= 1000) {
2916 +               /* if "big" number, spread normalization to seconds */
2917 +               tmo = usec / 1000;
2918 +               /* find number of "ticks" to wait to achieve target */
2919 +               tmo *= CFG_HZ;
2920 +               tmo /= 1000;    /* finish normalize. */
2921 +       } else {/* else small number, don't kill it prior to HZ multiply */
2922 +               tmo = usec * CFG_HZ;
2923 +               tmo /= (1000 * 1000);
2924 +       }
2925 +
2926 +       tmp = get_timer(0);     /* get current timestamp */
2927 +       /* if setting this forward will roll time stamp */
2928 +       if ((tmo + tmp + 1) < tmp)
2929 +               /* reset "advancing" timestamp to 0, set lastinc value */
2930 +               reset_timer_masked();
2931 +       else
2932 +               tmo += tmp;     /* else, set advancing stamp wake up time */
2933 +       while (get_timer_masked() < tmo)        /* loop till event */
2934 +                /*NOP*/;
2935 +}
2936 +
2937 +void reset_timer_masked(void)
2938 +{
2939 +       /* reset time */
2940 +       lastinc = READ_TIMER;   /* capture current incrementer value time */
2941 +       timestamp = 0;          /* start "advancing" time stamp from 0 */
2942 +}
2943 +
2944 +ulong get_timer_masked(void)
2945 +{
2946 +       ulong now = READ_TIMER; /* current tick value */
2947 +
2948 +       if (now >= lastinc)     /* normal mode (non roll) */
2949 +               /* move stamp fordward with absoulte diff ticks */
2950 +               timestamp += (now - lastinc);
2951 +       else    /* we have rollover of incrementer */
2952 +               timestamp += (0xFFFFFFFF - lastinc) + now;
2953 +       lastinc = now;
2954 +       return timestamp;
2955 +}
2956 +
2957 +/* waits specified delay value and resets timestamp */
2958 +void udelay_masked(unsigned long usec)
2959 +{
2960 +       ulong tmo;
2961 +       ulong endtime;
2962 +       signed long diff;
2963 +
2964 +       /* if "big" number, spread normalization to seconds */
2965 +       if (usec >= 1000) {
2966 +               /* start to normalize for usec to ticks per sec */
2967 +               tmo = usec / 1000;
2968 +               /* find number of "ticks" to wait to achieve target */
2969 +               tmo *= CFG_HZ;
2970 +               tmo /= 1000;    /* finish normalize. */
2971 +       } else {                /* else small number, */
2972 +                               /* don't kill it prior to HZ multiply */
2973 +               tmo = usec * CFG_HZ;
2974 +               tmo /= (1000 * 1000);
2975 +       }
2976 +       endtime = get_timer_masked() + tmo;
2977 +
2978 +       do {
2979 +               ulong now = get_timer_masked();
2980 +               diff = endtime - now;
2981 +       } while (diff >= 0);
2982 +}
2983 +
2984 +/*
2985 + * This function is derived from PowerPC code (read timebase as long long).
2986 + * On ARM it just returns the timer value.
2987 + */
2988 +unsigned long long get_ticks(void)
2989 +{
2990 +       return get_timer(0);
2991 +}
2992 +
2993 +/*
2994 + * This function is derived from PowerPC code (timebase clock frequency).
2995 + * On ARM it returns the number of timer ticks per second.
2996 + */
2997 +ulong get_tbclk(void)
2998 +{
2999 +       ulong tbclk;
3000 +       tbclk = CFG_HZ;
3001 +       return tbclk;
3002 +}
3003 +
3004 diff --git a/cpu/omap3/mmc.c b/cpu/omap3/mmc.c
3005 new file mode 100644
3006 index 0000000..741360b
3007 --- /dev/null
3008 +++ b/cpu/omap3/mmc.c
3009 @@ -0,0 +1,559 @@
3010 +/*
3011 + * (C) Copyright 2008
3012 + * Texas Instruments, <www.ti.com>
3013 + * Syed Mohammed Khasim <khasim@ti.com>
3014 + *
3015 + * See file CREDITS for list of people who contributed to this
3016 + * project.
3017 + *
3018 + * This program is free software; you can redistribute it and/or
3019 + * modify it under the terms of the GNU General Public License as
3020 + * published by the Free Software Foundation's version 2 of
3021 + * the License.
3022 + *
3023 + * This program is distributed in the hope that it will be useful,
3024 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3025 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3026 + * GNU General Public License for more details.
3027 + *
3028 + * You should have received a copy of the GNU General Public License
3029 + * along with this program; if not, write to the Free Software
3030 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
3031 + * MA 02111-1307 USA
3032 + */
3033 +
3034 +#include <config.h>
3035 +#include <common.h>
3036 +#include <fat.h>
3037 +#include <mmc.h>
3038 +#include <part.h>
3039 +#include <i2c.h>
3040 +
3041 +const unsigned short mmc_transspeed_val[15][4] = {
3042 +       {CLKD(10, 1), CLKD(10, 10), CLKD(10, 100), CLKD(10, 1000)},
3043 +       {CLKD(12, 1), CLKD(12, 10), CLKD(12, 100), CLKD(12, 1000)},
3044 +       {CLKD(13, 1), CLKD(13, 10), CLKD(13, 100), CLKD(13, 1000)},
3045 +       {CLKD(15, 1), CLKD(15, 10), CLKD(15, 100), CLKD(15, 1000)},
3046 +       {CLKD(20, 1), CLKD(20, 10), CLKD(20, 100), CLKD(20, 1000)},
3047 +       {CLKD(26, 1), CLKD(26, 10), CLKD(26, 100), CLKD(26, 1000)},
3048 +       {CLKD(30, 1), CLKD(30, 10), CLKD(30, 100), CLKD(30, 1000)},
3049 +       {CLKD(35, 1), CLKD(35, 10), CLKD(35, 100), CLKD(35, 1000)},
3050 +       {CLKD(40, 1), CLKD(40, 10), CLKD(40, 100), CLKD(40, 1000)},
3051 +       {CLKD(45, 1), CLKD(45, 10), CLKD(45, 100), CLKD(45, 1000)},
3052 +       {CLKD(52, 1), CLKD(52, 10), CLKD(52, 100), CLKD(52, 1000)},
3053 +       {CLKD(55, 1), CLKD(55, 10), CLKD(55, 100), CLKD(55, 1000)},
3054 +       {CLKD(60, 1), CLKD(60, 10), CLKD(60, 100), CLKD(60, 1000)},
3055 +       {CLKD(70, 1), CLKD(70, 10), CLKD(70, 100), CLKD(70, 1000)},
3056 +       {CLKD(80, 1), CLKD(80, 10), CLKD(80, 100), CLKD(80, 1000)}
3057 +};
3058 +
3059 +mmc_card_data cur_card_data;
3060 +static block_dev_desc_t mmc_blk_dev;
3061 +
3062 +block_dev_desc_t *mmc_get_dev(int dev)
3063 +{
3064 +       return ((block_dev_desc_t *) &mmc_blk_dev);
3065 +}
3066 +
3067 +void twl4030_mmc_config(void)
3068 +{
3069 +       unsigned char data;
3070 +
3071 +       data = 0x20;
3072 +       i2c_write(0x4B, 0x82, 1, &data, 1);
3073 +       data = 0x2;
3074 +       i2c_write(0x4B, 0x85, 1, &data, 1);
3075 +}
3076 +
3077 +unsigned char mmc_board_init(void)
3078 +{
3079 +       unsigned int value = 0;
3080 +
3081 +       twl4030_mmc_config();
3082 +
3083 +       value = CONTROL_PBIAS_LITE;
3084 +       CONTROL_PBIAS_LITE = value | (1 << 2) | (1 << 1) | (1 << 9);
3085 +
3086 +       value = CONTROL_DEV_CONF0;
3087 +       CONTROL_DEV_CONF0 = value | (1 << 24);
3088 +
3089 +       return 1;
3090 +}
3091 +
3092 +void mmc_init_stream(void)
3093 +{
3094 +       volatile unsigned int mmc_stat;
3095 +
3096 +       OMAP_HSMMC_CON |= INIT_INITSTREAM;
3097 +
3098 +       OMAP_HSMMC_CMD = MMC_CMD0;
3099 +       do {
3100 +               mmc_stat = OMAP_HSMMC_STAT;
3101 +       } while (!(mmc_stat & CC_MASK));
3102 +
3103 +       OMAP_HSMMC_STAT = CC_MASK;
3104 +
3105 +       OMAP_HSMMC_CMD = MMC_CMD0;
3106 +       do {
3107 +               mmc_stat = OMAP_HSMMC_STAT;
3108 +       } while (!(mmc_stat & CC_MASK));
3109 +
3110 +       OMAP_HSMMC_STAT = OMAP_HSMMC_STAT;
3111 +       OMAP_HSMMC_CON &= ~INIT_INITSTREAM;
3112 +}
3113 +
3114 +unsigned char mmc_clock_config(unsigned int iclk, unsigned short clk_div)
3115 +{
3116 +       unsigned int val;
3117 +
3118 +       mmc_reg_out(OMAP_HSMMC_SYSCTL, (ICE_MASK | DTO_MASK | CEN_MASK),
3119 +                   (ICE_STOP | DTO_15THDTO | CEN_DISABLE));
3120 +
3121 +       switch (iclk) {
3122 +       case CLK_INITSEQ:
3123 +               val = MMC_INIT_SEQ_CLK / 2;
3124 +               break;
3125 +       case CLK_400KHZ:
3126 +               val = MMC_400kHz_CLK;
3127 +               break;
3128 +       case CLK_MISC:
3129 +               val = clk_div;
3130 +               break;
3131 +       default:
3132 +               return 0;
3133 +       }
3134 +       mmc_reg_out(OMAP_HSMMC_SYSCTL,
3135 +                   ICE_MASK | CLKD_MASK, (val << CLKD_OFFSET) | ICE_OSCILLATE);
3136 +
3137 +       while ((OMAP_HSMMC_SYSCTL & ICS_MASK) == ICS_NOTREADY) {
3138 +       }
3139 +
3140 +       OMAP_HSMMC_SYSCTL |= CEN_ENABLE;
3141 +       return 1;
3142 +}
3143 +
3144 +unsigned char mmc_init_setup(void)
3145 +{
3146 +       unsigned int reg_val;
3147 +
3148 +       mmc_board_init();
3149 +
3150 +       OMAP_HSMMC_SYSCONFIG |= MMC_SOFTRESET;
3151 +       while ((OMAP_HSMMC_SYSSTATUS & RESETDONE) == 0) ;
3152 +
3153 +       OMAP_HSMMC_SYSCTL |= SOFTRESETALL;
3154 +       while ((OMAP_HSMMC_SYSCTL & SOFTRESETALL) != 0x0) ;
3155 +
3156 +       OMAP_HSMMC_HCTL = DTW_1_BITMODE | SDBP_PWROFF | SDVS_3V0;
3157 +       OMAP_HSMMC_CAPA |= VS30_3V0SUP | VS18_1V8SUP;
3158 +
3159 +       reg_val = OMAP_HSMMC_CON & RESERVED_MASK;
3160 +
3161 +       OMAP_HSMMC_CON = CTPL_MMC_SD | reg_val | WPP_ACTIVEHIGH |
3162 +           CDP_ACTIVEHIGH | MIT_CTO | DW8_1_4BITMODE | MODE_FUNC |
3163 +           STR_BLOCK | HR_NOHOSTRESP | INIT_NOINIT | NOOPENDRAIN;
3164 +
3165 +       mmc_clock_config(CLK_INITSEQ, 0);
3166 +       OMAP_HSMMC_HCTL |= SDBP_PWRON;
3167 +
3168 +       OMAP_HSMMC_IE = 0x307f0033;
3169 +
3170 +       mmc_init_stream();
3171 +       return 1;
3172 +}
3173 +
3174 +unsigned char mmc_send_cmd(unsigned int cmd, unsigned int arg,
3175 +                          unsigned int *response)
3176 +{
3177 +       volatile unsigned int mmc_stat;
3178 +
3179 +       while ((OMAP_HSMMC_PSTATE & DATI_MASK) == DATI_CMDDIS) {
3180 +       }
3181 +
3182 +       OMAP_HSMMC_BLK = BLEN_512BYTESLEN | NBLK_STPCNT;
3183 +       OMAP_HSMMC_STAT = 0xFFFFFFFF;
3184 +       OMAP_HSMMC_ARG = arg;
3185 +       OMAP_HSMMC_CMD = cmd | CMD_TYPE_NORMAL | CICE_NOCHECK |
3186 +           CCCE_NOCHECK | MSBS_SGLEBLK | ACEN_DISABLE | BCE_DISABLE |
3187 +           DE_DISABLE;
3188 +
3189 +       while (1) {
3190 +               do {
3191 +                       mmc_stat = OMAP_HSMMC_STAT;
3192 +               } while (mmc_stat == 0);
3193 +
3194 +               if ((mmc_stat & ERRI_MASK) != 0)
3195 +                       return (unsigned char) mmc_stat;
3196 +
3197 +               if (mmc_stat & CC_MASK) {
3198 +                       OMAP_HSMMC_STAT = CC_MASK;
3199 +                       response[0] = OMAP_HSMMC_RSP10;
3200 +                       if ((cmd & RSP_TYPE_MASK) == RSP_TYPE_LGHT136) {
3201 +                               response[1] = OMAP_HSMMC_RSP32;
3202 +                               response[2] = OMAP_HSMMC_RSP54;
3203 +                               response[3] = OMAP_HSMMC_RSP76;
3204 +                       }
3205 +                       break;
3206 +               }
3207 +       }
3208 +       return 1;
3209 +}
3210 +
3211 +unsigned char mmc_read_data(unsigned int *output_buf)
3212 +{
3213 +       volatile unsigned int mmc_stat;
3214 +       unsigned int read_count = 0;
3215 +
3216 +       /*
3217 +        * Start Polled Read
3218 +        */
3219 +       while (1) {
3220 +               do {
3221 +                       mmc_stat = OMAP_HSMMC_STAT;
3222 +               } while (mmc_stat == 0);
3223 +
3224 +               if ((mmc_stat & ERRI_MASK) != 0)
3225 +                       return (unsigned char) mmc_stat;
3226 +
3227 +               if (mmc_stat & BRR_MASK) {
3228 +                       unsigned int k;
3229 +
3230 +                       OMAP_HSMMC_STAT |= BRR_MASK;
3231 +                       for (k = 0; k < MMCSD_SECTOR_SIZE / 4; k++) {
3232 +                               *output_buf = OMAP_HSMMC_DATA;
3233 +                               output_buf++;
3234 +                               read_count += 4;
3235 +                       }
3236 +               }
3237 +
3238 +               if (mmc_stat & BWR_MASK)
3239 +                       OMAP_HSMMC_STAT |= BWR_MASK;
3240 +
3241 +               if (mmc_stat & TC_MASK) {
3242 +                       OMAP_HSMMC_STAT |= TC_MASK;
3243 +                       break;
3244 +               }
3245 +       }
3246 +       return 1;
3247 +}
3248 +
3249 +unsigned char mmc_detect_card(mmc_card_data *mmc_card_cur)
3250 +{
3251 +       unsigned char err;
3252 +       unsigned int argument = 0;
3253 +       unsigned int ocr_value, ocr_recvd, ret_cmd41, hcs_val;
3254 +       unsigned int resp[4];
3255 +       unsigned short retry_cnt = 2000;
3256 +
3257 +       /* Set to Initialization Clock */
3258 +       err = mmc_clock_config(CLK_400KHZ, 0);
3259 +       if (err != 1)
3260 +               return err;
3261 +
3262 +       mmc_card_cur->RCA = MMC_RELATIVE_CARD_ADDRESS;
3263 +       argument = 0x00000000;
3264 +
3265 +       ocr_value = (0x1FF << 15);
3266 +       err = mmc_send_cmd(MMC_CMD0, argument, resp);
3267 +       if (err != 1)
3268 +               return err;
3269 +
3270 +       argument = SD_CMD8_CHECK_PATTERN | SD_CMD8_2_7_3_6_V_RANGE;
3271 +       err = mmc_send_cmd(MMC_SDCMD8, argument, resp);
3272 +       hcs_val = (err == 1) ?
3273 +           MMC_OCR_REG_HOST_CAPACITY_SUPPORT_SECTOR :
3274 +           MMC_OCR_REG_HOST_CAPACITY_SUPPORT_BYTE;
3275 +
3276 +       argument = 0x0000 << 16;
3277 +       err = mmc_send_cmd(MMC_CMD55, argument, resp);
3278 +       if (err == 1) {
3279 +               mmc_card_cur->card_type = SD_CARD;
3280 +               ocr_value |= hcs_val;
3281 +               ret_cmd41 = MMC_ACMD41;
3282 +       } else {
3283 +               mmc_card_cur->card_type = MMC_CARD;
3284 +               ocr_value |= MMC_OCR_REG_ACCESS_MODE_SECTOR;
3285 +               ret_cmd41 = MMC_CMD1;
3286 +               OMAP_HSMMC_CON &= ~OD;
3287 +               OMAP_HSMMC_CON |= OPENDRAIN;
3288 +       }
3289 +
3290 +       argument = ocr_value;
3291 +       err = mmc_send_cmd(ret_cmd41, argument, resp);
3292 +       if (err != 1)
3293 +               return err;
3294 +
3295 +       ocr_recvd = ((mmc_resp_r3 *) resp)->ocr;
3296 +
3297 +       while (!(ocr_recvd & (0x1 << 31)) && (retry_cnt > 0)) {
3298 +               retry_cnt--;
3299 +               if (mmc_card_cur->card_type == SD_CARD) {
3300 +                       argument = 0x0000 << 16;
3301 +                       err = mmc_send_cmd(MMC_CMD55, argument, resp);
3302 +               }
3303 +
3304 +               argument = ocr_value;
3305 +               err = mmc_send_cmd(ret_cmd41, argument, resp);
3306 +               if (err != 1)
3307 +                       return err;
3308 +               ocr_recvd = ((mmc_resp_r3 *) resp)->ocr;
3309 +       }
3310 +
3311 +       if (!(ocr_recvd & (0x1 << 31)))
3312 +               return 0;
3313 +
3314 +       if (mmc_card_cur->card_type == MMC_CARD) {
3315 +               if ((ocr_recvd & MMC_OCR_REG_ACCESS_MODE_MASK) ==
3316 +                   MMC_OCR_REG_ACCESS_MODE_SECTOR) {
3317 +                       mmc_card_cur->mode = SECTOR_MODE;
3318 +               } else {
3319 +                       mmc_card_cur->mode = BYTE_MODE;
3320 +               }
3321 +
3322 +               ocr_recvd &= ~MMC_OCR_REG_ACCESS_MODE_MASK;
3323 +       } else {
3324 +               if ((ocr_recvd & MMC_OCR_REG_HOST_CAPACITY_SUPPORT_MASK)
3325 +                   == MMC_OCR_REG_HOST_CAPACITY_SUPPORT_SECTOR) {
3326 +                       mmc_card_cur->mode = SECTOR_MODE;
3327 +               } else {
3328 +                       mmc_card_cur->mode = BYTE_MODE;
3329 +               }
3330 +               ocr_recvd &= ~MMC_OCR_REG_HOST_CAPACITY_SUPPORT_MASK;
3331 +       }
3332 +
3333 +       ocr_recvd &= ~(0x1 << 31);
3334 +       if (!(ocr_recvd & ocr_value))
3335 +               return 0;
3336 +
3337 +       err = mmc_send_cmd(MMC_CMD2, argument, resp);
3338 +       if (err != 1)
3339 +               return err;
3340 +
3341 +       if (mmc_card_cur->card_type == MMC_CARD) {
3342 +               argument = mmc_card_cur->RCA << 16;
3343 +               err = mmc_send_cmd(MMC_CMD3, argument, resp);
3344 +               if (err != 1)
3345 +                       return err;
3346 +       } else {
3347 +               argument = 0x00000000;
3348 +               err = mmc_send_cmd(MMC_SDCMD3, argument, resp);
3349 +               if (err != 1)
3350 +                       return err;
3351 +
3352 +               mmc_card_cur->RCA = ((mmc_resp_r6 *) resp)->newpublishedrca;
3353 +       }
3354 +
3355 +       OMAP_HSMMC_CON &= ~OD;
3356 +       OMAP_HSMMC_CON |= NOOPENDRAIN;
3357 +       return 1;
3358 +}
3359 +
3360 +unsigned char mmc_read_cardsize(mmc_card_data *mmc_dev_data,
3361 +                               mmc_csd_reg_t *cur_csd)
3362 +{
3363 +       mmc_extended_csd_reg_t ext_csd;
3364 +       unsigned int size, count, blk_len, blk_no, card_size, argument;
3365 +       unsigned char err;
3366 +       unsigned int resp[4];
3367 +
3368 +       if (mmc_dev_data->mode == SECTOR_MODE) {
3369 +               if (mmc_dev_data->card_type == SD_CARD) {
3370 +                       card_size =
3371 +                           (((mmc_sd2_csd_reg_t *) cur_csd)->
3372 +                            c_size_lsb & MMC_SD2_CSD_C_SIZE_LSB_MASK) |
3373 +                           ((((mmc_sd2_csd_reg_t *) cur_csd)->
3374 +                             c_size_msb & MMC_SD2_CSD_C_SIZE_MSB_MASK)
3375 +                            << MMC_SD2_CSD_C_SIZE_MSB_OFFSET);
3376 +                       mmc_dev_data->size = card_size * 1024;
3377 +                       if (mmc_dev_data->size == 0)
3378 +                               return 0;
3379 +               } else {
3380 +                       argument = 0x00000000;
3381 +                       err = mmc_send_cmd(MMC_CMD8, argument, resp);
3382 +                       if (err != 1)
3383 +                               return err;
3384 +                       err = mmc_read_data((unsigned int *) &ext_csd);
3385 +                       if (err != 1)
3386 +                               return err;
3387 +                       mmc_dev_data->size = ext_csd.sectorcount;
3388 +
3389 +                       if (mmc_dev_data->size == 0)
3390 +                               mmc_dev_data->size = 8388608;
3391 +               }
3392 +       } else {
3393 +               if (cur_csd->c_size_mult >= 8)
3394 +                       return 0;
3395 +
3396 +               if (cur_csd->read_bl_len >= 12)
3397 +                       return 0;
3398 +
3399 +               /* Compute size */
3400 +               count = 1 << (cur_csd->c_size_mult + 2);
3401 +               card_size = (cur_csd->c_size_lsb & MMC_CSD_C_SIZE_LSB_MASK) |
3402 +                   ((cur_csd->c_size_msb & MMC_CSD_C_SIZE_MSB_MASK)
3403 +                    << MMC_CSD_C_SIZE_MSB_OFFSET);
3404 +               blk_no = (card_size + 1) * count;
3405 +               blk_len = 1 << cur_csd->read_bl_len;
3406 +               size = blk_no * blk_len;
3407 +               mmc_dev_data->size = size / MMCSD_SECTOR_SIZE;
3408 +               if (mmc_dev_data->size == 0)
3409 +                       return 0;
3410 +       }
3411 +       return 1;
3412 +}
3413 +
3414 +unsigned char omap_mmc_read_sect(unsigned int start_sec, unsigned int num_bytes,
3415 +                                mmc_card_data *mmc_c,
3416 +                                unsigned long *output_buf)
3417 +{
3418 +       unsigned char err;
3419 +       unsigned int argument;
3420 +       unsigned int resp[4];
3421 +       unsigned int num_sec_val =
3422 +           (num_bytes + (MMCSD_SECTOR_SIZE - 1)) / MMCSD_SECTOR_SIZE;
3423 +       unsigned int sec_inc_val;
3424 +
3425 +       if (num_sec_val == 0)
3426 +               return 1;
3427 +
3428 +       if (mmc_c->mode == SECTOR_MODE) {
3429 +               argument = start_sec;
3430 +               sec_inc_val = 1;
3431 +       } else {
3432 +               argument = start_sec * MMCSD_SECTOR_SIZE;
3433 +               sec_inc_val = MMCSD_SECTOR_SIZE;
3434 +       }
3435 +
3436 +       while (num_sec_val) {
3437 +               err = mmc_send_cmd(MMC_CMD17, argument, resp);
3438 +               if (err != 1)
3439 +                       return err;
3440 +
3441 +               err = mmc_read_data((unsigned int *) output_buf);
3442 +               if (err != 1)
3443 +                       return err;
3444 +
3445 +               output_buf += (MMCSD_SECTOR_SIZE / 4);
3446 +               argument += sec_inc_val;
3447 +               num_sec_val--;
3448 +       }
3449 +       return 1;
3450 +}
3451 +
3452 +unsigned char configure_mmc(mmc_card_data *mmc_card_cur)
3453 +{
3454 +       unsigned char ret_val;
3455 +       unsigned int argument;
3456 +       unsigned int resp[4];
3457 +       unsigned int trans_clk, trans_fact, trans_unit, retries = 2;
3458 +       mmc_csd_reg_t Card_CSD;
3459 +       unsigned char trans_speed;
3460 +
3461 +       ret_val = mmc_init_setup();
3462 +
3463 +       if (ret_val != 1)
3464 +               return ret_val;
3465 +
3466 +       do {
3467 +               ret_val = mmc_detect_card(mmc_card_cur);
3468 +               retries--;
3469 +       } while ((retries > 0) && (ret_val != 1));
3470 +
3471 +       argument = mmc_card_cur->RCA << 16;
3472 +       ret_val = mmc_send_cmd(MMC_CMD9, argument, resp);
3473 +       if (ret_val != 1)
3474 +               return ret_val;
3475 +
3476 +       ((unsigned int *) &Card_CSD)[3] = resp[3];
3477 +       ((unsigned int *) &Card_CSD)[2] = resp[2];
3478 +       ((unsigned int *) &Card_CSD)[1] = resp[1];
3479 +       ((unsigned int *) &Card_CSD)[0] = resp[0];
3480 +
3481 +       if (mmc_card_cur->card_type == MMC_CARD)
3482 +               mmc_card_cur->version = Card_CSD.spec_vers;
3483 +
3484 +       trans_speed = Card_CSD.tran_speed;
3485 +
3486 +       ret_val = mmc_send_cmd(MMC_CMD4, MMC_DSR_DEFAULT << 16, resp);
3487 +       if (ret_val != 1)
3488 +               return ret_val;
3489 +
3490 +       trans_unit = trans_speed & MMC_CSD_TRAN_SPEED_UNIT_MASK;
3491 +       trans_fact = trans_speed & MMC_CSD_TRAN_SPEED_FACTOR_MASK;
3492 +
3493 +       if (trans_unit > MMC_CSD_TRAN_SPEED_UNIT_100MHZ)
3494 +               return 0;
3495 +
3496 +       if ((trans_fact < MMC_CSD_TRAN_SPEED_FACTOR_1_0) ||
3497 +           (trans_fact > MMC_CSD_TRAN_SPEED_FACTOR_8_0))
3498 +               return 0;
3499 +
3500 +       trans_unit >>= 0;
3501 +       trans_fact >>= 3;
3502 +
3503 +       trans_clk = mmc_transspeed_val[trans_fact - 1][trans_unit] * 2;
3504 +       ret_val = mmc_clock_config(CLK_MISC, trans_clk);
3505 +
3506 +       if (ret_val != 1)
3507 +               return ret_val;
3508 +
3509 +       argument = mmc_card_cur->RCA << 16;
3510 +       ret_val = mmc_send_cmd(MMC_CMD7_SELECT, argument, resp);
3511 +       if (ret_val != 1)
3512 +               return ret_val;
3513 +
3514 +       /* Configure the block length to 512 bytes */
3515 +       argument = MMCSD_SECTOR_SIZE;
3516 +       ret_val = mmc_send_cmd(MMC_CMD16, argument, resp);
3517 +       if (ret_val != 1)
3518 +               return ret_val;
3519 +
3520 +       /* get the card size in sectors */
3521 +       ret_val = mmc_read_cardsize(mmc_card_cur, &Card_CSD);
3522 +       if (ret_val != 1)
3523 +               return ret_val;
3524 +
3525 +       return 1;
3526 +}
3527 +unsigned long mmc_bread(int dev_num, unsigned long blknr, lbaint_t blkcnt,
3528 +                       void *dst)
3529 +{
3530 +       omap_mmc_read_sect(blknr, (blkcnt * MMCSD_SECTOR_SIZE), &cur_card_data,
3531 +                          (unsigned long *) dst);
3532 +       return 1;
3533 +}
3534 +
3535 +int mmc_init(int verbose)
3536 +{
3537 +       configure_mmc(&cur_card_data);
3538 +
3539 +       mmc_blk_dev.if_type = IF_TYPE_MMC;
3540 +       mmc_blk_dev.part_type = PART_TYPE_DOS;
3541 +       mmc_blk_dev.dev = 0;
3542 +       mmc_blk_dev.lun = 0;
3543 +       mmc_blk_dev.type = 0;
3544 +
3545 +       /* FIXME fill in the correct size (is set to 32MByte) */
3546 +       mmc_blk_dev.blksz = MMCSD_SECTOR_SIZE;
3547 +       mmc_blk_dev.lba = 0x10000;
3548 +       mmc_blk_dev.removable = 0;
3549 +       mmc_blk_dev.block_read = mmc_bread;
3550 +
3551 +       fat_register_device(&mmc_blk_dev, 1);
3552 +       return 0;
3553 +}
3554 +
3555 +int mmc_read(ulong src, uchar *dst, int size)
3556 +{
3557 +       return 0;
3558 +}
3559 +
3560 +int mmc_write(uchar *src, ulong dst, int size)
3561 +{
3562 +       return 0;
3563 +}
3564 +
3565 +int mmc2info(ulong addr)
3566 +{
3567 +       return 0;
3568 +}
3569 diff --git a/cpu/omap3/start.S b/cpu/omap3/start.S
3570 new file mode 100644
3571 index 0000000..98706ad
3572 --- /dev/null
3573 +++ b/cpu/omap3/start.S
3574 @@ -0,0 +1,517 @@
3575 +/*
3576 + *  armboot - Startup Code for OMAP3530/ARM Cortex CPU-core
3577 + *
3578 + *  Copyright (c) 2004 Texas Instruments <r-woodruff2@ti.com>
3579 + *
3580 + *  Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
3581 + *  Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
3582 + *  Copyright (c) 2002 Gary Jennejohn <gj@denx.de>
3583 + *  Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com>
3584 + *  Copyright (c) 2003 Kshitij <kshitij@ti.com>
3585 + *  Copyright (c) 2006-2008 Syed Mohammed Khasim <x0khasim@ti.com>
3586 + *
3587 + * See file CREDITS for list of people who contributed to this
3588 + * project.
3589 + *
3590 + * This program is free software; you can redistribute it and/or
3591 + * modify it under the terms of the GNU General Public License as
3592 + * published by the Free Software Foundation; either version 2 of
3593 + * the License, or (at your option) any later version.
3594 + *
3595 + * This program is distributed in the hope that it will be useful,
3596 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3597 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
3598 + * GNU General Public License for more details.
3599 + *
3600 + * You should have received a copy of the GNU General Public License
3601 + * along with this program; if not, write to the Free Software
3602 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
3603 + * MA 02111-1307 USA
3604 + */
3605 +
3606 +#include <config.h>
3607 +#include <version.h>
3608 +
3609 +.globl _start
3610 +_start: b      reset
3611 +       ldr     pc, _undefined_instruction
3612 +       ldr     pc, _software_interrupt
3613 +       ldr     pc, _prefetch_abort
3614 +       ldr     pc, _data_abort
3615 +       ldr     pc, _not_used
3616 +       ldr     pc, _irq
3617 +       ldr     pc, _fiq
3618 +
3619 +_undefined_instruction: .word undefined_instruction
3620 +_software_interrupt:   .word software_interrupt
3621 +_prefetch_abort:       .word prefetch_abort
3622 +_data_abort:           .word data_abort
3623 +_not_used:             .word not_used
3624 +_irq:                  .word irq
3625 +_fiq:                  .word fiq
3626 +_pad:                  .word 0x12345678 /* now 16*4=64 */
3627 +.global _end_vect
3628 +_end_vect:
3629 +
3630 +       .balignl 16,0xdeadbeef
3631 +/*************************************************************************
3632 + *
3633 + * Startup Code (reset vector)
3634 + *
3635 + * do important init only if we don't start from memory!
3636 + * setup Memory and board specific bits prior to relocation.
3637 + * relocate armboot to ram
3638 + * setup stack
3639 + *
3640 + *************************************************************************/
3641 +
3642 +_TEXT_BASE:
3643 +       .word   TEXT_BASE
3644 +
3645 +.globl _armboot_start
3646 +_armboot_start:
3647 +       .word _start
3648 +
3649 +/*
3650 + * These are defined in the board-specific linker script.
3651 + */
3652 +.globl _bss_start
3653 +_bss_start:
3654 +       .word __bss_start
3655 +
3656 +.globl _bss_end
3657 +_bss_end:
3658 +       .word _end
3659 +
3660 +#ifdef CONFIG_USE_IRQ
3661 +/* IRQ stack memory (calculated at run-time) */
3662 +.globl IRQ_STACK_START
3663 +IRQ_STACK_START:
3664 +       .word   0x0badc0de
3665 +
3666 +/* IRQ stack memory (calculated at run-time) */
3667 +.globl FIQ_STACK_START
3668 +FIQ_STACK_START:
3669 +       .word 0x0badc0de
3670 +#endif
3671 +
3672 +/*
3673 + * the actual reset code
3674 + */
3675 +
3676 +reset:
3677 +       /*
3678 +        * set the cpu to SVC32 mode
3679 +        */
3680 +       mrs     r0,cpsr
3681 +       bic     r0,r0,#0x1f
3682 +       orr     r0,r0,#0xd3
3683 +       msr     cpsr,r0
3684 +
3685 +#if (CONFIG_OMAP34XX)
3686 +       /* Copy vectors to mask ROM indirect addr */
3687 +       adr     r0, _start              @ r0 <- current position of code
3688 +        add     r0, r0, #4             @ skip reset vector
3689 +       mov     r2, #64                 @ r2 <- size to copy
3690 +       add     r2, r0, r2              @ r2 <- source end address
3691 +       mov     r1, #SRAM_OFFSET0       @ build vect addr
3692 +       mov     r3, #SRAM_OFFSET1
3693 +       add     r1, r1, r3
3694 +       mov     r3, #SRAM_OFFSET2
3695 +       add     r1, r1, r3
3696 +next:
3697 +       ldmia   r0!, {r3-r10}           @ copy from source address [r0]
3698 +       stmia   r1!, {r3-r10}           @ copy to   target address [r1]
3699 +       cmp     r0, r2                  @ until source end address [r2]
3700 +       bne     next                    @ loop until equal */
3701 +#if !defined(CFG_NAND_BOOT) && !defined(CFG_ONENAND_BOOT)
3702 +       /* No need to copy/exec the clock code - DPLL adjust already done
3703 +        * in NAND/oneNAND Boot.
3704 +        */
3705 +       bl      cpy_clk_code            @ put dpll adjust code behind vectors
3706 +#endif /* NAND Boot */
3707 +#endif
3708 +       /* the mask ROM code should have PLL and others stable */
3709 +#ifndef CONFIG_SKIP_LOWLEVEL_INIT
3710 +       bl  cpu_init_crit
3711 +#endif
3712 +
3713 +#ifndef CONFIG_SKIP_RELOCATE_UBOOT
3714 +relocate:                              @ relocate U-Boot to RAM
3715 +       adr     r0, _start              @ r0 <- current position of code
3716 +       ldr     r1, _TEXT_BASE          @ test if we run from flash or RAM
3717 +       cmp     r0, r1                  @ don't reloc during debug
3718 +       beq     stack_setup
3719 +
3720 +       ldr     r2, _armboot_start
3721 +       ldr     r3, _bss_start
3722 +       sub     r2, r3, r2              @ r2 <- size of armboot
3723 +       add     r2, r0, r2              @ r2 <- source end address
3724 +
3725 +copy_loop:                              @ copy 32 bytes at a time
3726 +       ldmia   r0!, {r3-r10}           @ copy from source address [r0]
3727 +       stmia   r1!, {r3-r10}           @ copy to   target address [r1]
3728 +       cmp     r0, r2                  @ until source end addreee [r2]
3729 +       ble     copy_loop
3730 +#endif /* CONFIG_SKIP_RELOCATE_UBOOT */
3731 +
3732 +       /* Set up the stack */
3733 +stack_setup:
3734 +       ldr     r0, _TEXT_BASE          @ upper 128 KiB: relocated uboot
3735 +       sub     r0, r0, #CFG_MALLOC_LEN @ malloc area
3736 +       sub     r0, r0, #CFG_GBL_DATA_SIZE @ bdinfo
3737 +#ifdef CONFIG_USE_IRQ
3738 +       sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
3739 +#endif
3740 +       sub     sp, r0, #12             @ leave 3 words for abort-stack
3741 +       and     sp, sp, #~7             @ 8 byte alinged for (ldr/str)d
3742 +
3743 +       /* Clear BSS (if any).  Is below tx (watch load addr - need space)  */
3744 +clear_bss:
3745 +       ldr     r0, _bss_start          @ find start of bss segment
3746 +       ldr     r1, _bss_end            @ stop here
3747 +       mov     r2, #0x00000000         @ clear value
3748 +clbss_l:
3749 +       str     r2, [r0]                @ clear BSS location
3750 +       cmp     r0, r1                  @ are we at the end yet
3751 +       add     r0, r0, #4              @ increment clear index pointer
3752 +       bne     clbss_l                 @ keep clearing till at end
3753 +
3754 +       ldr     pc, _start_armboot      @ jump to C code
3755 +
3756 +_start_armboot: .word start_armboot
3757 +
3758 +
3759 +/*************************************************************************
3760 + *
3761 + * CPU_init_critical registers
3762 + *
3763 + * setup important registers
3764 + * setup memory timing
3765 + *
3766 + *************************************************************************/
3767 +cpu_init_crit:
3768 +       /*
3769 +        * Invalidate L1 I/D
3770 +        */
3771 +        mov    r0, #0                  @ set up for MCR
3772 +        mcr    p15, 0, r0, c8, c7, 0   @ invalidate TLBs
3773 +        mcr    p15, 0, r0, c7, c5, 0   @ invalidate icache
3774 +
3775 +       /*
3776 +        * disable MMU stuff and caches
3777 +        */
3778 +       mrc     p15, 0, r0, c1, c0, 0
3779 +       bic     r0, r0, #0x00002000     @ clear bits 13 (--V-)
3780 +       bic     r0, r0, #0x00000007     @ clear bits 2:0 (-CAM)
3781 +       orr     r0, r0, #0x00000002     @ set bit 1 (--A-) Align
3782 +       orr     r0, r0, #0x00000800     @ set bit 12 (Z---) BTB
3783 +       mcr     p15, 0, r0, c1, c0, 0
3784 +
3785 +       /*
3786 +        * Jump to board specific initialization...
3787 +        * The Mask ROM will have already initialized
3788 +        * basic memory.  Go here to bump up clock rate and handle
3789 +        * wake up conditions.
3790 +        */
3791 +       mov     ip, lr                  @ persevere link reg across call
3792 +       bl      lowlevel_init           @ go setup pll,mux,memory
3793 +       mov     lr, ip                  @ restore link
3794 +       mov     pc, lr                  @ back to my caller
3795 +/*
3796 + *************************************************************************
3797 + *
3798 + * Interrupt handling
3799 + *
3800 + *************************************************************************
3801 + */
3802 +@
3803 +@ IRQ stack frame.
3804 +@
3805 +#define S_FRAME_SIZE   72
3806 +
3807 +#define S_OLD_R0       68
3808 +#define S_PSR          64
3809 +#define S_PC           60
3810 +#define S_LR           56
3811 +#define S_SP           52
3812 +
3813 +#define S_IP           48
3814 +#define S_FP           44
3815 +#define S_R10          40
3816 +#define S_R9           36
3817 +#define S_R8           32
3818 +#define S_R7           28
3819 +#define S_R6           24
3820 +#define S_R5           20
3821 +#define S_R4           16
3822 +#define S_R3           12
3823 +#define S_R2           8
3824 +#define S_R1           4
3825 +#define S_R0           0
3826 +
3827 +#define MODE_SVC 0x13
3828 +#define I_BIT   0x80
3829 +
3830 +/*
3831 + * use bad_save_user_regs for abort/prefetch/undef/swi ...
3832 + * use irq_save_user_regs / irq_restore_user_regs for IRQ/FIQ handling
3833 + */
3834 +
3835 +       .macro  bad_save_user_regs
3836 +       sub     sp, sp, #S_FRAME_SIZE           @ carve out a frame on current
3837 +                                               @  user stack
3838 +       stmia   sp, {r0 - r12}                  @ Save user registers (now in
3839 +                                               @ svc mode) r0-r12
3840 +
3841 +       ldr     r2, _armboot_start
3842 +       sub     r2, r2, #(CFG_MALLOC_LEN)
3843 +       sub     r2, r2, #(CFG_GBL_DATA_SIZE+8)  @ set base 2 words into abort
3844 +                                               @ stack
3845 +       ldmia   r2, {r2 - r3}                   @ get values for "aborted" pc
3846 +                                               @ and cpsr (into parm regs)
3847 +       add     r0, sp, #S_FRAME_SIZE           @ grab pointer to old stack
3848 +
3849 +       add     r5, sp, #S_SP
3850 +       mov     r1, lr
3851 +       stmia   r5, {r0 - r3}                   @ save sp_SVC, lr_SVC, pc, cpsr
3852 +       mov     r0, sp                          @ save current stack into r0
3853 +                                               @ (param register)
3854 +       .endm
3855 +
3856 +       .macro  irq_save_user_regs
3857 +       sub     sp, sp, #S_FRAME_SIZE
3858 +       stmia   sp, {r0 - r12}                  @ Calling r0-r12
3859 +       add     r8, sp, #S_PC                   @ !! R8 NEEDS to be saved !!
3860 +                                               @ a reserved stack spot would
3861 +                                               @ be good.
3862 +       stmdb   r8, {sp, lr}^                   @ Calling SP, LR
3863 +       str     lr, [r8, #0]                    @ Save calling PC
3864 +       mrs     r6, spsr
3865 +       str     r6, [r8, #4]                    @ Save CPSR
3866 +       str     r0, [r8, #8]                    @ Save OLD_R0
3867 +       mov     r0, sp
3868 +       .endm
3869 +
3870 +       .macro  irq_restore_user_regs
3871 +       ldmia   sp, {r0 - lr}^                  @ Calling r0 - lr
3872 +       mov     r0, r0
3873 +       ldr     lr, [sp, #S_PC]                 @ Get PC
3874 +       add     sp, sp, #S_FRAME_SIZE
3875 +       subs    pc, lr, #4                      @ return & move spsr_svc into
3876 +                                               @ cpsr
3877 +       .endm
3878 +
3879 +       .macro get_bad_stack
3880 +       ldr     r13, _armboot_start             @ setup our mode stack (enter
3881 +                                               @ in banked mode)
3882 +       sub     r13, r13, #(CFG_MALLOC_LEN)     @ move past malloc pool
3883 +       sub     r13, r13, #(CFG_GBL_DATA_SIZE+8) @ move to reserved a couple
3884 +                                               @ spots for abort stack
3885 +
3886 +       str     lr, [r13]                       @ save caller lr in position 0
3887 +                                               @ of saved stack
3888 +       mrs     lr, spsr                        @ get the spsr
3889 +       str     lr, [r13, #4]                   @ save spsr in position 1 of
3890 +                                               @ saved stack
3891 +
3892 +       mov     r13, #MODE_SVC                  @ prepare SVC-Mode
3893 +       @ msr   spsr_c, r13
3894 +       msr     spsr, r13                       @ switch modes, make sure
3895 +                                               @ moves will execute
3896 +       mov     lr, pc                          @ capture return pc
3897 +       movs    pc, lr                          @ jump to next instruction &
3898 +                                               @ switch modes.
3899 +       .endm
3900 +
3901 +       .macro get_bad_stack_swi
3902 +       sub     r13, r13, #4                    @ space on current stack for
3903 +                                               @ scratch reg.
3904 +       str     r0, [r13]                       @ save R0's value.
3905 +       ldr     r0, _armboot_start              @ get data regions start
3906 +       sub     r0, r0, #(CFG_MALLOC_LEN)       @ move past malloc pool
3907 +       sub     r0, r0, #(CFG_GBL_DATA_SIZE+8)  @ move past gbl and a couple
3908 +                                               @ spots for abort stack
3909 +       str     lr, [r0]                        @ save caller lr in position 0
3910 +                                               @ of saved stack
3911 +       mrs     r0, spsr                        @ get the spsr
3912 +       str     lr, [r0, #4]                    @ save spsr in position 1 of
3913 +                                               @ saved stack
3914 +       ldr     r0, [r13]                       @ restore r0
3915 +       add     r13, r13, #4                    @ pop stack entry
3916 +       .endm
3917 +
3918 +       .macro get_irq_stack                    @ setup IRQ stack
3919 +       ldr     sp, IRQ_STACK_START
3920 +       .endm
3921 +
3922 +       .macro get_fiq_stack                    @ setup FIQ stack
3923 +       ldr     sp, FIQ_STACK_START
3924 +       .endm
3925 +
3926 +/*
3927 + * exception handlers
3928 + */
3929 +       .align  5
3930 +undefined_instruction:
3931 +       get_bad_stack
3932 +       bad_save_user_regs
3933 +       bl      do_undefined_instruction
3934 +
3935 +       .align  5
3936 +software_interrupt:
3937 +       get_bad_stack_swi
3938 +       bad_save_user_regs
3939 +       bl      do_software_interrupt
3940 +
3941 +       .align  5
3942 +prefetch_abort:
3943 +       get_bad_stack
3944 +       bad_save_user_regs
3945 +       bl      do_prefetch_abort
3946 +
3947 +       .align  5
3948 +data_abort:
3949 +       get_bad_stack
3950 +       bad_save_user_regs
3951 +       bl      do_data_abort
3952 +
3953 +       .align  5
3954 +not_used:
3955 +       get_bad_stack
3956 +       bad_save_user_regs
3957 +       bl      do_not_used
3958 +
3959 +#ifdef CONFIG_USE_IRQ
3960 +
3961 +       .align  5
3962 +irq:
3963 +       get_irq_stack
3964 +       irq_save_user_regs
3965 +       bl      do_irq
3966 +       irq_restore_user_regs
3967 +
3968 +       .align  5
3969 +fiq:
3970 +       get_fiq_stack
3971 +       /* someone ought to write a more effiction fiq_save_user_regs */
3972 +       irq_save_user_regs
3973 +       bl      do_fiq
3974 +       irq_restore_user_regs
3975 +
3976 +#else
3977 +
3978 +       .align  5
3979 +irq:
3980 +       get_bad_stack
3981 +       bad_save_user_regs
3982 +       bl      do_irq
3983 +
3984 +       .align  5
3985 +fiq:
3986 +       get_bad_stack
3987 +       bad_save_user_regs
3988 +       bl      do_fiq
3989 +
3990 +#endif
3991 +       .align 5
3992 +.global arm_cache_flush
3993 +arm_cache_flush:
3994 +       mcr     p15, 0, r1, c7, c5, 0           @ invalidate I cache
3995 +       mov     pc, lr                          @ back to caller
3996 +
3997 +/*
3998 + *     v7_flush_dcache_all()
3999 + *
4000 + *     Flush the whole D-cache.
4001 + *
4002 + *     Corrupted registers: r0-r5, r7, r9-r11
4003 + *
4004 + *     - mm    - mm_struct describing address space
4005 + */
4006 +       .align 5
4007 +.global v7_flush_dcache_all
4008 +v7_flush_dcache_all:
4009 +       stmfd   r13!, {r0-r5, r7, r9-r12,r14}
4010 +
4011 +       mov     r7, r0                          @ take a backup of device type
4012 +       cmp     r0, #0x3                        @ check if the device type is
4013 +                                               @ GP
4014 +       moveq r12, #0x1                         @ set up to invalide L2
4015 +smi:   .word 0x01600070                        @ Call SMI monitor (smieq)
4016 +       cmp     r7, #0x3                        @ compare again in case its
4017 +                                               @ lost
4018 +       beq     finished_inval                  @ if GP device, inval done
4019 +                                               @ above
4020 +
4021 +       mrc     p15, 1, r0, c0, c0, 1           @ read clidr
4022 +       ands    r3, r0, #0x7000000              @ extract loc from clidr
4023 +       mov     r3, r3, lsr #23                 @ left align loc bit field
4024 +       beq     finished_inval                  @ if loc is 0, then no need to
4025 +                                               @ clean
4026 +       mov     r10, #0                         @ start clean at cache level 0
4027 +inval_loop1:
4028 +       add     r2, r10, r10, lsr #1            @ work out 3x current cache
4029 +                                               @ level
4030 +       mov     r1, r0, lsr r2                  @ extract cache type bits from
4031 +                                               @ clidr
4032 +       and     r1, r1, #7                      @ mask of the bits for current
4033 +                                               @ cache only
4034 +       cmp     r1, #2                          @ see what cache we have at
4035 +                                               @ this level
4036 +       blt     skip_inval                      @ skip if no cache, or just
4037 +                                               @ i-cache
4038 +       mcr     p15, 2, r10, c0, c0, 0          @ select current cache level
4039 +                                               @ in cssr
4040 +       isb                                     @ isb to sych the new
4041 +                                               @ cssr&csidr
4042 +       mrc     p15, 1, r1, c0, c0, 0           @ read the new csidr
4043 +       and     r2, r1, #7                      @ extract the length of the
4044 +                                               @ cache lines
4045 +       add     r2, r2, #4                      @ add 4 (line length offset)
4046 +       ldr     r4, =0x3ff
4047 +       ands    r4, r4, r1, lsr #3              @ find maximum number on the
4048 +                                               @ way size
4049 +       clz     r5, r4                          @ find bit position of way
4050 +                                               @ size increment
4051 +       ldr     r7, =0x7fff
4052 +       ands    r7, r7, r1, lsr #13             @ extract max number of the
4053 +                                               @ index size
4054 +inval_loop2:
4055 +       mov     r9, r4                          @ create working copy of max
4056 +                                               @ way size
4057 +inval_loop3:
4058 +       orr     r11, r10, r9, lsl r5            @ factor way and cache number
4059 +                                               @ into r11
4060 +       orr     r11, r11, r7, lsl r2            @ factor index number into r11
4061 +       mcr     p15, 0, r11, c7, c6, 2          @ invalidate by set/way
4062 +       subs    r9, r9, #1                      @ decrement the way
4063 +       bge     inval_loop3
4064 +       subs    r7, r7, #1                      @ decrement the index
4065 +       bge     inval_loop2
4066 +skip_inval:
4067 +       add     r10, r10, #2                    @ increment cache number
4068 +       cmp     r3, r10
4069 +       bgt     inval_loop1
4070 +finished_inval:
4071 +       mov     r10, #0                         @ swith back to cache level 0
4072 +       mcr     p15, 2, r10, c0, c0, 0          @ select current cache level
4073 +                                               @ in cssr
4074 +       isb
4075 +
4076 +       ldmfd   r13!, {r0-r5, r7, r9-r12,pc}
4077 +
4078 +
4079 +       .align  5
4080 +.global reset_cpu
4081 +reset_cpu:
4082 +       ldr     r1, rstctl                      @ get addr for global reset
4083 +                                               @ reg
4084 +       mov     r3, #0x2                        @ full reset pll + mpu
4085 +       str     r3, [r1]                        @ force reset
4086 +       mov     r0, r0
4087 +_loop_forever:
4088 +       b       _loop_forever
4089 +rstctl:
4090 +       .word   PRM_RSTCTRL
4091 +
4092 diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
4093 index 7dab786..7782e9d 100644
4094 --- a/drivers/i2c/omap24xx_i2c.c
4095 +++ b/drivers/i2c/omap24xx_i2c.c
4096 @@ -22,11 +22,13 @@
4097  
4098  #include <common.h>
4099  
4100 -#ifdef CONFIG_DRIVER_OMAP24XX_I2C
4101 +#if defined(CONFIG_DRIVER_OMAP24XX_I2C) || defined(CONFIG_DRIVER_OMAP34XX_I2C)
4102  
4103  #include <asm/arch/i2c.h>
4104  #include <asm/io.h>
4105  
4106 +#define inb(a) __raw_readb(a)
4107 +#define outb(a,v) __raw_writeb(a,v)
4108  #define inw(a) __raw_readw(a)
4109  #define outw(a,v) __raw_writew(a,v)
4110  
4111 @@ -114,7 +116,11 @@ static int i2c_read_byte (u8 devaddr, u8 regoffset, u8 * value)
4112  
4113                 status = wait_for_pin ();
4114                 if (status & I2C_STAT_RRDY) {
4115 -                       *value = inw (I2C_DATA);
4116 +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
4117 +                        *value = inb(I2C_DATA);
4118 +#else
4119 +                        *value = inw(I2C_DATA);
4120 +#endif
4121                         udelay (20000);
4122                 } else {
4123                         i2c_error = 1;
4124 @@ -155,8 +161,23 @@ static int i2c_write_byte (u8 devaddr, u8 regoffset, u8 value)
4125         status = wait_for_pin ();
4126  
4127         if (status & I2C_STAT_XRDY) {
4128 -               /* send out two bytes */
4129 -               outw ((value << 8) + regoffset, I2C_DATA);
4130 +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
4131 +                /* send out 1 byte */
4132 +                outb(regoffset, I2C_DATA);
4133 +                outw(I2C_STAT_XRDY, I2C_STAT);
4134 +                status = wait_for_pin();
4135 +                if ((status & I2C_STAT_XRDY)) {
4136 +                        /* send out next 1 byte */
4137 +                        outb(value, I2C_DATA);
4138 +                        outw(I2C_STAT_XRDY, I2C_STAT);
4139 +                } else {
4140 +                        i2c_error = 1;
4141 +                }
4142 +#else
4143 +                /* send out two bytes */
4144 +                outw ((value << 8) + regoffset, I2C_DATA);
4145 +#endif
4146 +
4147                 /* must have enough delay to allow BB bit to go low */
4148                 udelay (50000);
4149                 if (inw (I2C_STAT) & I2C_STAT_NACK) {
4150 @@ -193,7 +214,11 @@ static void flush_fifo(void)
4151         while(1){
4152                 stat = inw(I2C_STAT);
4153                 if(stat == I2C_STAT_RRDY){
4154 -                       inw(I2C_DATA);
4155 +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
4156 +                        inb(I2C_DATA);
4157 +#else
4158 +                        inw(I2C_DATA);
4159 +#endif
4160                         outw(I2C_STAT_RRDY,I2C_STAT);
4161                         udelay(1000);
4162                 }else
4163 diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
4164 index d1423c1..a75c606 100644
4165 --- a/fs/jffs2/jffs2_1pass.c
4166 +++ b/fs/jffs2/jffs2_1pass.c
4167 @@ -304,7 +304,9 @@ static inline void *get_node_mem_nor(u32 off)
4168   */
4169  static inline void *get_fl_mem(u32 off, u32 size, void *ext_buf)
4170  {
4171 +#if (defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)) || defined(ONFIG_CMD_FLASH)
4172         struct mtdids *id = current_part->dev->id;
4173 +#endif
4174  
4175  #if defined(CONFIG_CMD_FLASH)
4176         if (id->type == MTD_DEV_TYPE_NOR)
4177 @@ -322,7 +324,9 @@ static inline void *get_fl_mem(u32 off, u32 size, void *ext_buf)
4178  
4179  static inline void *get_node_mem(u32 off)
4180  {
4181 -       struct mtdids *id = current_part->dev->id;
4182 +#if (defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)) || defined(ONFIG_CMD_FLASH)
4183 +        struct mtdids *id = current_part->dev->id;
4184 +#endif
4185  
4186  #if defined(CONFIG_CMD_FLASH)
4187         if (id->type == MTD_DEV_TYPE_NOR)
4188 diff --git a/include/asm-arm/arch-omap3/bits.h b/include/asm-arm/arch-omap3/bits.h
4189 new file mode 100644
4190 index 0000000..8522335
4191 --- /dev/null
4192 +++ b/include/asm-arm/arch-omap3/bits.h
4193 @@ -0,0 +1,48 @@
4194 +/* bits.h
4195 + * Copyright (c) 2004 Texas Instruments
4196 + *
4197 + * This package is free software;  you can redistribute it and/or
4198 + * modify it under the terms of the license found in the file
4199 + * named COPYING that should have accompanied this file.
4200 + *
4201 + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
4202 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
4203 + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
4204 + */
4205 +#ifndef __bits_h
4206 +#define __bits_h 1
4207 +
4208 +#define BIT0  (1<<0)
4209 +#define BIT1  (1<<1)
4210 +#define BIT2  (1<<2)
4211 +#define BIT3  (1<<3)
4212 +#define BIT4  (1<<4)
4213 +#define BIT5  (1<<5)
4214 +#define BIT6  (1<<6)
4215 +#define BIT7  (1<<7)
4216 +#define BIT8  (1<<8)
4217 +#define BIT9  (1<<9)
4218 +#define BIT10 (1<<10)
4219 +#define BIT11 (1<<11)
4220 +#define BIT12 (1<<12)
4221 +#define BIT13 (1<<13)
4222 +#define BIT14 (1<<14)
4223 +#define BIT15 (1<<15)
4224 +#define BIT16 (1<<16)
4225 +#define BIT17 (1<<17)
4226 +#define BIT18 (1<<18)
4227 +#define BIT19 (1<<19)
4228 +#define BIT20 (1<<20)
4229 +#define BIT21 (1<<21)
4230 +#define BIT22 (1<<22)
4231 +#define BIT23 (1<<23)
4232 +#define BIT24 (1<<24)
4233 +#define BIT25 (1<<25)
4234 +#define BIT26 (1<<26)
4235 +#define BIT27 (1<<27)
4236 +#define BIT28 (1<<28)
4237 +#define BIT29 (1<<29)
4238 +#define BIT30 (1<<30)
4239 +#define BIT31 (1<<31)
4240 +
4241 +#endif
4242 diff --git a/include/asm-arm/arch-omap3/clocks.h b/include/asm-arm/arch-omap3/clocks.h
4243 new file mode 100644
4244 index 0000000..7cdd58c
4245 --- /dev/null
4246 +++ b/include/asm-arm/arch-omap3/clocks.h
4247 @@ -0,0 +1,62 @@
4248 +/*
4249 + * (C) Copyright 2006-2008
4250 + * Texas Instruments, <www.ti.com>
4251 + * Richard Woodruff <r-woodruff2@ti.com>
4252 + *
4253 + * This program is free software; you can redistribute it and/or
4254 + * modify it under the terms of the GNU General Public License as
4255 + * published by the Free Software Foundation; either version 2 of
4256 + * the License, or (at your option) any later version.
4257 + *
4258 + * This program is distributed in the hope that it will be useful,
4259 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4260 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
4261 + * GNU General Public License for more details.
4262 + *
4263 + * You should have received a copy of the GNU General Public License
4264 + * along with this program; if not, write to the Free Software
4265 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
4266 + * MA 02111-1307 USA
4267 +  */
4268 +#ifndef _CLOCKS_H_
4269 +#define _CLOCKS_H_
4270 +
4271 +#define LDELAY          12000000
4272 +
4273 +#define S12M           12000000
4274 +#define S13M           13000000
4275 +#define S19_2M         19200000
4276 +#define S24M           24000000
4277 +#define S26M           26000000
4278 +#define S38_4M         38400000
4279 +
4280 +#define FCK_IVA2_ON    0x00000001
4281 +#define FCK_CORE1_ON   0x03fffe29
4282 +#define ICK_CORE1_ON   0x3ffffffb
4283 +#define ICK_CORE2_ON   0x0000001f
4284 +#define        FCK_WKUP_ON     0x000000e9
4285 +#define ICK_WKUP_ON    0x0000003f
4286 +#define FCK_DSS_ON     0x00000005
4287 +#define ICK_DSS_ON     0x00000001
4288 +#define FCK_CAM_ON     0x00000001
4289 +#define ICK_CAM_ON     0x00000001
4290 +#define FCK_PER_ON     0x0003ffff
4291 +#define ICK_PER_ON     0x0003ffff
4292 +
4293 +/* Used to index into DPLL parameter tables */
4294 +typedef struct {
4295 +       unsigned int m;
4296 +       unsigned int n;
4297 +       unsigned int fsel;
4298 +       unsigned int m2;
4299 +} dpll_param;
4300 +
4301 +/* Following functions are exported from lowlevel_init.S */
4302 +extern dpll_param *get_mpu_dpll_param(void);
4303 +extern dpll_param *get_iva_dpll_param(void);
4304 +extern dpll_param *get_core_dpll_param(void);
4305 +extern dpll_param *get_per_dpll_param(void);
4306 +
4307 +extern void *_end_vect, *_start;
4308 +
4309 +#endif
4310 diff --git a/include/asm-arm/arch-omap3/clocks_omap3.h b/include/asm-arm/arch-omap3/clocks_omap3.h
4311 new file mode 100644
4312 index 0000000..fdb0c4c
4313 --- /dev/null
4314 +++ b/include/asm-arm/arch-omap3/clocks_omap3.h
4315 @@ -0,0 +1,101 @@
4316 +/*
4317 + * (C) Copyright 2006-2008
4318 + * Texas Instruments, <www.ti.com>
4319 + * Richard Woodruff <r-woodruff2@ti.com>
4320 + *
4321 + * This program is free software; you can redistribute it and/or
4322 + * modify it under the terms of the GNU General Public License as
4323 + * published by the Free Software Foundation; either version 2 of
4324 + * the License, or (at your option) any later version.
4325 + *
4326 + * This program is distributed in the hope that it will be useful,
4327 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4328 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
4329 + * GNU General Public License for more details.
4330 + *
4331 + * You should have received a copy of the GNU General Public License
4332 + * along with this program; if not, write to the Free Software
4333 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
4334 + * MA 02111-1307 USA
4335 +  */
4336 +#ifndef _CLOCKS_OMAP3_H_
4337 +#define _CLOCKS_OMAP3_H_
4338 +
4339 +#define PLL_STOP               1       /* PER & IVA */
4340 +#define PLL_LOW_POWER_BYPASS   5       /* MPU, IVA & CORE */
4341 +#define PLL_FAST_RELOCK_BYPASS 6       /* CORE */
4342 +#define PLL_LOCK               7       /* MPU, IVA, CORE & PER */
4343 +
4344 +/* The following configurations are OPP and SysClk value independant
4345 + * and hence are defined here. All the other DPLL related values are
4346 + * tabulated in lowlevel_init.S.
4347 + */
4348 +
4349 +/* CORE DPLL */
4350 +#  define CORE_M3X2      2     /* 332MHz : CM_CLKSEL1_EMU */
4351 +#  define CORE_SSI_DIV   3     /* 221MHz : CM_CLKSEL_CORE */
4352 +#  define CORE_FUSB_DIV  2     /* 41.5MHz: */
4353 +#  define CORE_L4_DIV    2     /*  83MHz : L4 */
4354 +#  define CORE_L3_DIV    2     /* 166MHz : L3 {DDR} */
4355 +#  define GFX_DIV        2     /*  83MHz : CM_CLKSEL_GFX */
4356 +#  define WKUP_RSM       2     /* 41.5MHz: CM_CLKSEL_WKUP */
4357 +
4358 +/* PER DPLL */
4359 +# define PER_M6X2       3      /* 288MHz: CM_CLKSEL1_EMU */
4360 +# define PER_M5X2       4      /* 216MHz: CM_CLKSEL_CAM */
4361 +# define PER_M4X2       2      /* 432MHz : CM_CLKSEL_DSS-dss1 */
4362 +# define PER_M3X2       16     /* 54MHz : CM_CLKSEL_DSS-tv */
4363 +
4364 +#  define CLSEL1_EMU_VAL ((CORE_M3X2 << 16) | (PER_M6X2 << 24) | (0x0a50))
4365 +
4366 +# define M_12          0xA6
4367 +# define N_12          0x05
4368 +# define FSEL_12       0x07
4369 +# define M2_12         0x01    /* M3 of 2 */
4370 +
4371 +# define M_12_ES1      0x19F
4372 +# define N_12_ES1      0x0E
4373 +# define FSL_12_ES1     0x03
4374 +# define M2_12_ES1      0x1    /* M3 of 2 */
4375 +
4376 +# define M_13           0x14C
4377 +# define N_13           0x0C
4378 +# define FSEL_13       0x03
4379 +# define M2_13         0x01    /* M3 of 2 */
4380 +
4381 +# define M_13_ES1      0x1B2
4382 +# define N_13_ES1      0x10
4383 +# define FSL_13_ES1     0x03
4384 +# define M2_13_ES1     0x01    /* M3 of 2 */
4385 +
4386 +# define M_19p2         0x19F
4387 +# define N_19p2         0x17
4388 +# define FSEL_19p2      0x03
4389 +# define M2_19p2        0x01   /* M3 of 2 */
4390 +
4391 +# define M_19p2_ES1    0x19F
4392 +# define N_19p2_ES1    0x17
4393 +# define FSL_19p2_ES1   0x03
4394 +# define M2_19p2_ES1    0x01   /* M3 of 2 */
4395 +
4396 +# define M_26           0xA6
4397 +# define N_26           0x0C
4398 +# define FSEL_26        0x07
4399 +# define M2_26          0x01   /* M3 of 2 */
4400 +
4401 +# define M_26_ES1      0x1B2
4402 +# define N_26_ES1      0x21
4403 +# define FSL_26_ES1    0x03
4404 +# define M2_26_ES1     0x01    /* M3 of 2 */
4405 +
4406 +# define M_38p4         0x19F
4407 +# define N_38p4         0x2F
4408 +# define FSEL_38p4      0x03
4409 +# define M2_38p4        0x01   /* M3 of 2 */
4410 +
4411 +# define M_38p4_ES1    0x19F
4412 +# define N_38p4_ES1    0x2F
4413 +# define FSL_38p4_ES1   0x03
4414 +# define M2_38p4_ES1    0x01   /* M3 of 2 */
4415 +
4416 +#endif /* endif _CLOCKS_OMAP3_H_ */
4417 diff --git a/include/asm-arm/arch-omap3/cpu.h b/include/asm-arm/arch-omap3/cpu.h
4418 new file mode 100644
4419 index 0000000..d47defb
4420 --- /dev/null
4421 +++ b/include/asm-arm/arch-omap3/cpu.h
4422 @@ -0,0 +1,250 @@
4423 +/*
4424 + * (C) Copyright 2006-2008
4425 + * Texas Instruments, <www.ti.com>
4426 + *
4427 + * See file CREDITS for list of people who contributed to this
4428 + * project.
4429 + *
4430 + * This program is free software; you can redistribute it and/or
4431 + * modify it under the terms of the GNU General Public License as
4432 + * published by the Free Software Foundation; either version 2 of
4433 + * the License, or (at your option) any later version.
4434 + *
4435 + * This program is distributed in the hope that it will be useful,
4436 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4437 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4438 + * GNU General Public License for more details.
4439 + *
4440 + * You should have received a copy of the GNU General Public License
4441 + * along with this program; if not, write to the Free Software
4442 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
4443 + * MA 02111-1307 USA
4444 + *
4445 + */
4446 +
4447 +#ifndef _CPU_H
4448 +#define _CPU_H
4449 +
4450 +/* Register offsets of common modules */
4451 +/* Control */
4452 +#define CONTROL_STATUS                 (OMAP34XX_CTRL_BASE + 0x2F0)
4453 +#define OMAP34XX_MCR                   (OMAP34XX_CTRL_BASE + 0x8C)
4454 +#define CONTROL_SCALABLE_OMAP_STATUS   (OMAP34XX_CTRL_BASE + 0x44C)
4455 +#define CONTROL_SCALABLE_OMAP_OCP      (OMAP34XX_CTRL_BASE + 0x534)
4456 +
4457 +/* Tap Information */
4458 +#define TAP_IDCODE_REG         (OMAP34XX_TAP_BASE+0x204)
4459 +#define PRODUCTION_ID          (OMAP34XX_TAP_BASE+0x208)
4460 +
4461 +/* device type */
4462 +#define DEVICE_MASK            (BIT8|BIT9|BIT10)
4463 +#define TST_DEVICE             0x0
4464 +#define EMU_DEVICE             0x1
4465 +#define HS_DEVICE              0x2
4466 +#define GP_DEVICE              0x3
4467 +
4468 +/* GPMC CS3/cs4/cs6 not avaliable */
4469 +#define GPMC_BASE              (OMAP34XX_GPMC_BASE)
4470 +#define GPMC_SYSCONFIG         (OMAP34XX_GPMC_BASE+0x10)
4471 +#define GPMC_IRQSTATUS         (OMAP34XX_GPMC_BASE+0x18)
4472 +#define GPMC_IRQENABLE         (OMAP34XX_GPMC_BASE+0x1C)
4473 +#define GPMC_TIMEOUT_CONTROL   (OMAP34XX_GPMC_BASE+0x40)
4474 +#define GPMC_CONFIG            (OMAP34XX_GPMC_BASE+0x50)
4475 +#define GPMC_STATUS            (OMAP34XX_GPMC_BASE+0x54)
4476 +
4477 +#define GPMC_CONFIG_CS0                (OMAP34XX_GPMC_BASE+0x60)
4478 +#define GPMC_CONFIG_WIDTH      (0x30)
4479 +
4480 +#define GPMC_CONFIG1           (0x00)
4481 +#define GPMC_CONFIG2           (0x04)
4482 +#define GPMC_CONFIG3           (0x08)
4483 +#define GPMC_CONFIG4           (0x0C)
4484 +#define GPMC_CONFIG5           (0x10)
4485 +#define GPMC_CONFIG6           (0x14)
4486 +#define GPMC_CONFIG7           (0x18)
4487 +#define GPMC_NAND_CMD          (0x1C)
4488 +#define GPMC_NAND_ADR          (0x20)
4489 +#define GPMC_NAND_DAT          (0x24)
4490 +
4491 +#define GPMC_ECC_CONFIG                (0x1F4)
4492 +#define GPMC_ECC_CONTROL       (0x1F8)
4493 +#define GPMC_ECC_SIZE_CONFIG   (0x1FC)
4494 +#define GPMC_ECC1_RESULT       (0x200)
4495 +#define GPMC_ECC2_RESULT       (0x204)
4496 +#define GPMC_ECC3_RESULT       (0x208)
4497 +#define GPMC_ECC4_RESULT       (0x20C)
4498 +#define GPMC_ECC5_RESULT       (0x210)
4499 +#define GPMC_ECC6_RESULT       (0x214)
4500 +#define GPMC_ECC7_RESULT       (0x218)
4501 +#define GPMC_ECC8_RESULT       (0x21C)
4502 +#define GPMC_ECC9_RESULT       (0x220)
4503 +
4504 +/* GPMC Mapping */
4505 +# define FLASH_BASE            0x10000000      /* NOR flash, */
4506 +                                               /* aligned to 256 Meg */
4507 +# define FLASH_BASE_SDPV1      0x04000000      /* NOR flash, */
4508 +                                               /* aligned to 64 Meg */
4509 +# define FLASH_BASE_SDPV2      0x10000000      /* NOR flash, */
4510 +                                               /* aligned to 256 Meg */
4511 +# define DEBUG_BASE            0x08000000      /* debug board */
4512 +# define NAND_BASE             0x30000000      /* NAND addr */
4513 +                                               /* (actual size small port) */
4514 +# define PISMO2_BASE           0x18000000      /* PISMO2 CS1/2 */
4515 +# define ONENAND_MAP           0x20000000      /* OneNand addr */
4516 +                                               /* (actual size small port) */
4517 +
4518 +/* SMS */
4519 +#define SMS_SYSCONFIG          (OMAP34XX_SMS_BASE+0x10)
4520 +#define SMS_RG_ATT0            (OMAP34XX_SMS_BASE+0x48)
4521 +#define SMS_CLASS_ARB0         (OMAP34XX_SMS_BASE+0xD0)
4522 +#define BURSTCOMPLETE_GROUP7   BIT31
4523 +
4524 +/* SDRC */
4525 +#define SDRC_SYSCONFIG         (OMAP34XX_SDRC_BASE+0x10)
4526 +#define SDRC_STATUS            (OMAP34XX_SDRC_BASE+0x14)
4527 +#define SDRC_CS_CFG            (OMAP34XX_SDRC_BASE+0x40)
4528 +#define SDRC_SHARING           (OMAP34XX_SDRC_BASE+0x44)
4529 +#define SDRC_DLLA_CTRL         (OMAP34XX_SDRC_BASE+0x60)
4530 +#define SDRC_DLLA_STATUS       (OMAP34XX_SDRC_BASE+0x64)
4531 +#define SDRC_DLLB_CTRL         (OMAP34XX_SDRC_BASE+0x68)
4532 +#define SDRC_DLLB_STATUS       (OMAP34XX_SDRC_BASE+0x6C)
4533 +#define DLLPHASE               BIT1
4534 +#define LOADDLL                        BIT2
4535 +#define DLL_DELAY_MASK         0xFF00
4536 +#define DLL_NO_FILTER_MASK     (BIT8|BIT9)
4537 +
4538 +#define SDRC_POWER             (OMAP34XX_SDRC_BASE+0x70)
4539 +#define WAKEUPPROC             BIT26
4540 +
4541 +#define SDRC_MCFG_0            (OMAP34XX_SDRC_BASE+0x80)
4542 +#define SDRC_MR_0              (OMAP34XX_SDRC_BASE+0x84)
4543 +#define SDRC_ACTIM_CTRLA_0     (OMAP34XX_SDRC_BASE+0x9C)
4544 +#define SDRC_ACTIM_CTRLB_0     (OMAP34XX_SDRC_BASE+0xA0)
4545 +#define SDRC_ACTIM_CTRLA_1     (OMAP34XX_SDRC_BASE+0xC4)
4546 +#define SDRC_ACTIM_CTRLB_1     (OMAP34XX_SDRC_BASE+0xC8)
4547 +#define SDRC_RFR_CTRL          (OMAP34XX_SDRC_BASE+0xA4)
4548 +#define SDRC_RFR_CTRL          (OMAP34XX_SDRC_BASE+0xA4)
4549 +#define SDRC_MANUAL_0          (OMAP34XX_SDRC_BASE+0xA8)
4550 +#define OMAP34XX_SDRC_CS0      0x80000000
4551 +#define OMAP34XX_SDRC_CS1      0xA0000000
4552 +#define CMD_NOP                        0x0
4553 +#define CMD_PRECHARGE          0x1
4554 +#define CMD_AUTOREFRESH                0x2
4555 +#define CMD_ENTR_PWRDOWN       0x3
4556 +#define CMD_EXIT_PWRDOWN       0x4
4557 +#define CMD_ENTR_SRFRSH                0x5
4558 +#define CMD_CKE_HIGH           0x6
4559 +#define CMD_CKE_LOW            0x7
4560 +#define SOFTRESET              BIT1
4561 +#define SMART_IDLE             (0x2 << 3)
4562 +#define REF_ON_IDLE            (0x1 << 6)
4563 +
4564 +/* timer regs offsets (32 bit regs) */
4565 +#define TIDR                   0x0     /* r */
4566 +#define TIOCP_CFG              0x10    /* rw */
4567 +#define TISTAT                 0x14    /* r */
4568 +#define TISR                   0x18    /* rw */
4569 +#define TIER                   0x1C    /* rw */
4570 +#define TWER                   0x20    /* rw */
4571 +#define TCLR                   0x24    /* rw */
4572 +#define TCRR                   0x28    /* rw */
4573 +#define TLDR                   0x2C    /* rw */
4574 +#define TTGR                   0x30    /* rw */
4575 +#define TWPS                   0x34    /* r */
4576 +#define TMAR                   0x38    /* rw */
4577 +#define TCAR1                  0x3c    /* r */
4578 +#define TSICR                  0x40    /* rw */
4579 +#define TCAR2                  0x44    /* r */
4580 + /* enable sys_clk NO-prescale /1 */
4581 +#define GPT_EN                 ((0<<2)|BIT1|BIT0)
4582 +
4583 +/* Watchdog */
4584 +#define WWPS                   0x34    /* r */
4585 +#define WSPR                   0x48    /* rw */
4586 +#define WD_UNLOCK1             0xAAAA
4587 +#define WD_UNLOCK2             0x5555
4588 +
4589 +/* PRCM */
4590 +#define CM_FCLKEN_IVA2      0x48004000
4591 +#define CM_CLKEN_PLL_IVA2   0x48004004
4592 +#define CM_IDLEST_PLL_IVA2  0x48004024
4593 +#define CM_CLKSEL1_PLL_IVA2 0x48004040
4594 +#define CM_CLKSEL2_PLL_IVA2 0x48004044
4595 +#define CM_CLKEN_PLL_MPU    0x48004904
4596 +#define CM_IDLEST_PLL_MPU   0x48004924
4597 +#define CM_CLKSEL1_PLL_MPU  0x48004940
4598 +#define CM_CLKSEL2_PLL_MPU  0x48004944
4599 +#define CM_FCLKEN1_CORE     0x48004a00
4600 +#define CM_ICLKEN1_CORE     0x48004a10
4601 +#define CM_ICLKEN2_CORE     0x48004a14
4602 +#define CM_CLKSEL_CORE      0x48004a40
4603 +#define CM_FCLKEN_GFX       0x48004b00
4604 +#define CM_ICLKEN_GFX       0x48004b10
4605 +#define CM_CLKSEL_GFX       0x48004b40
4606 +#define CM_FCLKEN_WKUP      0x48004c00
4607 +#define CM_ICLKEN_WKUP      0x48004c10
4608 +#define CM_CLKSEL_WKUP      0x48004c40
4609 +#define CM_IDLEST_WKUP      0x48004c20
4610 +#define CM_CLKEN_PLL        0x48004d00
4611 +#define CM_IDLEST_CKGEN     0x48004d20
4612 +#define CM_CLKSEL1_PLL      0x48004d40
4613 +#define CM_CLKSEL2_PLL      0x48004d44
4614 +#define CM_CLKSEL3_PLL      0x48004d48
4615 +#define CM_FCLKEN_DSS       0x48004e00
4616 +#define CM_ICLKEN_DSS       0x48004e10
4617 +#define CM_CLKSEL_DSS       0x48004e40
4618 +#define CM_FCLKEN_CAM       0x48004f00
4619 +#define CM_ICLKEN_CAM       0x48004f10
4620 +#define CM_CLKSEL_CAM       0x48004F40
4621 +#define CM_FCLKEN_PER       0x48005000
4622 +#define CM_ICLKEN_PER       0x48005010
4623 +#define CM_CLKSEL_PER       0x48005040
4624 +#define CM_CLKSEL1_EMU      0x48005140
4625 +
4626 +#define PRM_CLKSEL           0x48306d40
4627 +#define PRM_RSTCTRL          0x48307250
4628 +#define PRM_CLKSRC_CTRL      0x48307270
4629 +
4630 +/* SMX-APE */
4631 +#define PM_RT_APE_BASE_ADDR_ARM                (SMX_APE_BASE + 0x10000)
4632 +#define PM_GPMC_BASE_ADDR_ARM          (SMX_APE_BASE + 0x12400)
4633 +#define PM_OCM_RAM_BASE_ADDR_ARM       (SMX_APE_BASE + 0x12800)
4634 +#define PM_OCM_ROM_BASE_ADDR_ARM       (SMX_APE_BASE + 0x12C00)
4635 +#define PM_IVA2_BASE_ADDR_ARM          (SMX_APE_BASE + 0x14000)
4636 +
4637 +#define RT_REQ_INFO_PERMISSION_1       (PM_RT_APE_BASE_ADDR_ARM + 0x68)
4638 +#define RT_READ_PERMISSION_0           (PM_RT_APE_BASE_ADDR_ARM + 0x50)
4639 +#define RT_WRITE_PERMISSION_0          (PM_RT_APE_BASE_ADDR_ARM + 0x58)
4640 +#define RT_ADDR_MATCH_1                        (PM_RT_APE_BASE_ADDR_ARM + 0x60)
4641 +
4642 +#define GPMC_REQ_INFO_PERMISSION_0     (PM_GPMC_BASE_ADDR_ARM + 0x48)
4643 +#define GPMC_READ_PERMISSION_0         (PM_GPMC_BASE_ADDR_ARM + 0x50)
4644 +#define GPMC_WRITE_PERMISSION_0                (PM_GPMC_BASE_ADDR_ARM + 0x58)
4645 +
4646 +#define OCM_REQ_INFO_PERMISSION_0      (PM_OCM_RAM_BASE_ADDR_ARM + 0x48)
4647 +#define OCM_READ_PERMISSION_0          (PM_OCM_RAM_BASE_ADDR_ARM + 0x50)
4648 +#define OCM_WRITE_PERMISSION_0         (PM_OCM_RAM_BASE_ADDR_ARM + 0x58)
4649 +#define OCM_ADDR_MATCH_2               (PM_OCM_RAM_BASE_ADDR_ARM + 0x80)
4650 +
4651 +#define IVA2_REQ_INFO_PERMISSION_0     (PM_IVA2_BASE_ADDR_ARM + 0x48)
4652 +#define IVA2_READ_PERMISSION_0         (PM_IVA2_BASE_ADDR_ARM + 0x50)
4653 +#define IVA2_WRITE_PERMISSION_0                (PM_IVA2_BASE_ADDR_ARM + 0x58)
4654 +
4655 +#define IVA2_REQ_INFO_PERMISSION_1     (PM_IVA2_BASE_ADDR_ARM + 0x68)
4656 +#define IVA2_READ_PERMISSION_1         (PM_IVA2_BASE_ADDR_ARM + 0x70)
4657 +#define IVA2_WRITE_PERMISSION_1                (PM_IVA2_BASE_ADDR_ARM + 0x78)
4658 +
4659 +#define IVA2_REQ_INFO_PERMISSION_2     (PM_IVA2_BASE_ADDR_ARM + 0x88)
4660 +#define IVA2_READ_PERMISSION_2         (PM_IVA2_BASE_ADDR_ARM + 0x90)
4661 +#define IVA2_WRITE_PERMISSION_2                (PM_IVA2_BASE_ADDR_ARM + 0x98)
4662 +
4663 +#define IVA2_REQ_INFO_PERMISSION_3     (PM_IVA2_BASE_ADDR_ARM + 0xA8)
4664 +#define IVA2_READ_PERMISSION_3         (PM_IVA2_BASE_ADDR_ARM + 0xB0)
4665 +#define IVA2_WRITE_PERMISSION_3                (PM_IVA2_BASE_ADDR_ARM + 0xB8)
4666 +
4667 +/* I2C base */
4668 +#define I2C_BASE1              (OMAP34XX_CORE_L4_IO_BASE + 0x70000)
4669 +#define I2C_BASE2              (OMAP34XX_CORE_L4_IO_BASE + 0x72000)
4670 +#define I2C_BASE3              (OMAP34XX_CORE_L4_IO_BASE + 0x60000)
4671 +
4672 +#endif /* _CPU_H */
4673 diff --git a/include/asm-arm/arch-omap3/i2c.h b/include/asm-arm/arch-omap3/i2c.h
4674 new file mode 100644
4675 index 0000000..5fb0979
4676 --- /dev/null
4677 +++ b/include/asm-arm/arch-omap3/i2c.h
4678 @@ -0,0 +1,128 @@
4679 +/*
4680 + * (C) Copyright 2004-2008
4681 + * Texas Instruments, <www.ti.com>
4682 + *
4683 + * See file CREDITS for list of people who contributed to this
4684 + * project.
4685 + *
4686 + * This program is free software; you can redistribute it and/or
4687 + * modify it under the terms of the GNU General Public License as
4688 + * published by the Free Software Foundation; either version 2 of
4689 + * the License, or (at your option) any later version.
4690 + *
4691 + * This program is distributed in the hope that it will be useful,
4692 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4693 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4694 + * GNU General Public License for more details.
4695 + *
4696 + * You should have received a copy of the GNU General Public License
4697 + * along with this program; if not, write to the Free Software
4698 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
4699 + * MA 02111-1307 USA
4700 + */
4701 +#ifndef _I2C_H_
4702 +#define _I2C_H_
4703 +
4704 +#define I2C_DEFAULT_BASE I2C_BASE1
4705 +
4706 +#define I2C_REV                 (I2C_DEFAULT_BASE + 0x00)
4707 +#define I2C_IE                  (I2C_DEFAULT_BASE + 0x04)
4708 +#define I2C_STAT                (I2C_DEFAULT_BASE + 0x08)
4709 +#define I2C_IV                  (I2C_DEFAULT_BASE + 0x0c)
4710 +#define I2C_BUF                 (I2C_DEFAULT_BASE + 0x14)
4711 +#define I2C_CNT                 (I2C_DEFAULT_BASE + 0x18)
4712 +#define I2C_DATA                (I2C_DEFAULT_BASE + 0x1c)
4713 +#define I2C_SYSC                (I2C_DEFAULT_BASE + 0x20)
4714 +#define I2C_CON                 (I2C_DEFAULT_BASE + 0x24)
4715 +#define I2C_OA                  (I2C_DEFAULT_BASE + 0x28)
4716 +#define I2C_SA                  (I2C_DEFAULT_BASE + 0x2c)
4717 +#define I2C_PSC                 (I2C_DEFAULT_BASE + 0x30)
4718 +#define I2C_SCLL                (I2C_DEFAULT_BASE + 0x34)
4719 +#define I2C_SCLH                (I2C_DEFAULT_BASE + 0x38)
4720 +#define I2C_SYSTEST             (I2C_DEFAULT_BASE + 0x3c)
4721 +
4722 +/* I2C masks */
4723 +
4724 +/* I2C Interrupt Enable Register (I2C_IE): */
4725 +#define I2C_IE_GC_IE    (1 << 5)
4726 +#define I2C_IE_XRDY_IE  (1 << 4) /* Transmit data ready interrupt enable */
4727 +#define I2C_IE_RRDY_IE  (1 << 3) /* Receive data ready interrupt enable */
4728 +#define I2C_IE_ARDY_IE  (1 << 2) /* Register access ready interrupt enable */
4729 +#define I2C_IE_NACK_IE  (1 << 1) /* No acknowledgment interrupt enable */
4730 +#define I2C_IE_AL_IE    (1 << 0) /* Arbitration lost interrupt enable */
4731 +
4732 +/* I2C Status Register (I2C_STAT): */
4733 +
4734 +#define I2C_STAT_SBD    (1 << 15) /* Single byte data */
4735 +#define I2C_STAT_BB     (1 << 12) /* Bus busy */
4736 +#define I2C_STAT_ROVR   (1 << 11) /* Receive overrun */
4737 +#define I2C_STAT_XUDF   (1 << 10) /* Transmit underflow */
4738 +#define I2C_STAT_AAS    (1 << 9)  /* Address as slave */
4739 +#define I2C_STAT_GC     (1 << 5)
4740 +#define I2C_STAT_XRDY   (1 << 4)  /* Transmit data ready */
4741 +#define I2C_STAT_RRDY   (1 << 3)  /* Receive data ready */
4742 +#define I2C_STAT_ARDY   (1 << 2)  /* Register access ready */
4743 +#define I2C_STAT_NACK   (1 << 1)  /* No acknowledgment interrupt enable */
4744 +#define I2C_STAT_AL     (1 << 0)  /* Arbitration lost interrupt enable */
4745 +
4746 +/* I2C Interrupt Code Register (I2C_INTCODE): */
4747 +
4748 +#define I2C_INTCODE_MASK        7
4749 +#define I2C_INTCODE_NONE        0
4750 +#define I2C_INTCODE_AL          1      /* Arbitration lost */
4751 +#define I2C_INTCODE_NAK         2      /* No acknowledgement/general call */
4752 +#define I2C_INTCODE_ARDY        3      /* Register access ready */
4753 +#define I2C_INTCODE_RRDY        4      /* Rcv data ready */
4754 +#define I2C_INTCODE_XRDY        5      /* Xmit data ready */
4755 +
4756 +/* I2C Buffer Configuration Register (I2C_BUF): */
4757 +
4758 +#define I2C_BUF_RDMA_EN         (1 << 15) /* Receive DMA channel enable */
4759 +#define I2C_BUF_XDMA_EN         (1 << 7)  /* Transmit DMA channel enable */
4760 +
4761 +/* I2C Configuration Register (I2C_CON): */
4762 +
4763 +#define I2C_CON_EN      (1 << 15)  /* I2C module enable */
4764 +#define I2C_CON_BE      (1 << 14)  /* Big endian mode */
4765 +#define I2C_CON_STB     (1 << 11)  /* Start byte mode (master mode only) */
4766 +#define I2C_CON_MST     (1 << 10)  /* Master/slave mode */
4767 +#define I2C_CON_TRX     (1 << 9)   /* Transmitter/receiver mode /*
4768 +                                  /* (master mode only) */
4769 +#define I2C_CON_XA      (1 << 8)   /* Expand address */
4770 +#define I2C_CON_STP     (1 << 1)   /* Stop condition (master mode only) */
4771 +#define I2C_CON_STT     (1 << 0)   /* Start condition (master mode only) */
4772 +
4773 +/* I2C System Test Register (I2C_SYSTEST): */
4774 +
4775 +#define I2C_SYSTEST_ST_EN       (1 << 15) /* System test enable */
4776 +#define I2C_SYSTEST_FREE        (1 << 14) /* Free running mode, on brkpoint) */
4777 +#define I2C_SYSTEST_TMODE_MASK  (3 << 12) /* Test mode select */
4778 +#define I2C_SYSTEST_TMODE_SHIFT (12)     /* Test mode select */
4779 +#define I2C_SYSTEST_SCL_I       (1 << 3)  /* SCL line sense input value */
4780 +#define I2C_SYSTEST_SCL_O       (1 << 2)  /* SCL line drive output value */
4781 +#define I2C_SYSTEST_SDA_I       (1 << 1)  /* SDA line sense input value */
4782 +#define I2C_SYSTEST_SDA_O       (1 << 0)  /* SDA line drive output value */
4783 +
4784 +#define I2C_SCLL_SCLL        (0)
4785 +#define I2C_SCLL_SCLL_M      (0xFF)
4786 +#define I2C_SCLL_HSSCLL      (8)
4787 +#define I2C_SCLH_HSSCLL_M    (0xFF)
4788 +#define I2C_SCLH_SCLH        (0)
4789 +#define I2C_SCLH_SCLH_M      (0xFF)
4790 +#define I2C_SCLH_HSSCLH      (8)
4791 +#define I2C_SCLH_HSSCLH_M    (0xFF)
4792 +
4793 +#define OMAP_I2C_STANDARD    100
4794 +#define OMAP_I2C_FAST_MODE   400
4795 +#define OMAP_I2C_HIGH_SPEED  3400
4796 +
4797 +#define SYSTEM_CLOCK_12      12000
4798 +#define SYSTEM_CLOCK_13      13000
4799 +#define SYSTEM_CLOCK_192     19200
4800 +#define SYSTEM_CLOCK_96      96000
4801 +
4802 +#define I2C_IP_CLK SYSTEM_CLOCK_96
4803 +#define I2C_PSC_MAX          (0x0f)
4804 +#define I2C_PSC_MIN          (0x00)
4805 +
4806 +#endif /* _I2C_H_ */
4807 diff --git a/include/asm-arm/arch-omap3/mem.h b/include/asm-arm/arch-omap3/mem.h
4808 new file mode 100644
4809 index 0000000..2c5cc51
4810 --- /dev/null
4811 +++ b/include/asm-arm/arch-omap3/mem.h
4812 @@ -0,0 +1,220 @@
4813 +/*
4814 + * (C) Copyright 2006-2008
4815 + * Texas Instruments, <www.ti.com>
4816 + * Richard Woodruff <r-woodruff2@ti.com>
4817 + *
4818 + * See file CREDITS for list of people who contributed to this
4819 + * project.
4820 + *
4821 + * This program is free software; you can redistribute it and/or
4822 + * modify it under the terms of the GNU General Public License as
4823 + * published by the Free Software Foundation; either version 2 of
4824 + * the License, or (at your option) any later version.
4825 + *
4826 + * This program is distributed in the hope that it will be useful,
4827 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4828 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4829 + * GNU General Public License for more details.
4830 + *
4831 + * You should have received a copy of the GNU General Public License
4832 + * along with this program; if not, write to the Free Software
4833 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
4834 + * MA 02111-1307 USA
4835 + */
4836 +
4837 +#ifndef _MEM_H_
4838 +#define _MEM_H_
4839 +
4840 +#define SDRC_CS0_OSET    0x0
4841 +#define SDRC_CS1_OSET    0x30 /* mirror CS1 regs appear offset 0x30 from CS0 */
4842 +
4843 +#ifndef __ASSEMBLY__
4844 +
4845 +typedef enum {
4846 +       STACKED = 0,
4847 +       IP_DDR = 1,
4848 +       COMBO_DDR = 2,
4849 +       IP_SDR = 3,
4850 +} mem_t;
4851 +
4852 +#endif /* __ASSEMBLY__ */
4853 +
4854 +#define EARLY_INIT 1
4855 +
4856 +/* Slower full frequency range default timings for x32 operation*/
4857 +#define SDP_SDRC_SHARING               0x00000100
4858 +#define SDP_SDRC_MR_0_SDR              0x00000031
4859 +
4860 +/* optimized timings good for current shipping parts */
4861 +#define SDP_3430_SDRC_RFR_CTRL_165MHz   0x0004e201  /* 7.8us/6ns - 50=0x4e2 */
4862 +
4863 +#define DLL_OFFSET              0
4864 +#define DLL_WRITEDDRCLKX2DIS    1
4865 +#define DLL_ENADLL              1
4866 +#define DLL_LOCKDLL             0
4867 +#define DLL_DLLPHASE_72         0
4868 +#define DLL_DLLPHASE_90         1
4869 +
4870 +/* rkw - need to find of 90/72 degree recommendation for speed like before */
4871 +#define SDP_SDRC_DLLAB_CTRL ((DLL_ENADLL << 3) | \
4872 +    (DLL_LOCKDLL << 2) | (DLL_DLLPHASE_90 << 1))
4873 +
4874 +/* Infineon part of 3430SDP (165MHz optimized) 6.06ns
4875 + *   ACTIMA
4876 + *     TDAL = Twr/Tck + Trp/tck = 15/6 + 18/6 = 2.5 + 3 = 5.5 -> 6
4877 + *     TDPL (Twr) = 15/6       = 2.5 -> 3
4878 + *     TRRD = 12/6     = 2
4879 + *     TRCD = 18/6     = 3
4880 + *     TRP = 18/6      = 3
4881 + *     TRAS = 42/6     = 7
4882 + *     TRC = 60/6      = 10
4883 + *     TRFC = 72/6     = 12
4884 + *   ACTIMB
4885 + *     TCKE = 2
4886 + *     XSR = 120/6 = 20
4887 + */
4888 +#define TDAL_165   6
4889 +#define TDPL_165   3
4890 +#define TRRD_165   2
4891 +#define TRCD_165   3
4892 +#define TRP_165    3
4893 +#define TRAS_165   7
4894 +#define TRC_165   10
4895 +#define TRFC_165  12
4896 +#define V_ACTIMA_165 ((TRFC_165 << 27) | (TRC_165 << 22) | (TRAS_165 << 18) \
4897 +               | (TRP_165 << 15) | (TRCD_165 << 12) | (TRRD_165 << 9) | \
4898 +               (TDPL_165 << 6) | (TDAL_165))
4899 +
4900 +#define TWTR_165   1
4901 +#define TCKE_165   2
4902 +#define TXP_165    2
4903 +#define XSR_165    20
4904 +#define V_ACTIMB_165 (((TCKE_165 << 12) | (XSR_165 << 0)) |    \
4905 +                       (TXP_165 << 8) | (TWTR_165 << 16))
4906 +
4907 +# define SDP_SDRC_ACTIM_CTRLA_0     V_ACTIMA_165
4908 +# define SDP_SDRC_ACTIM_CTRLB_0     V_ACTIMB_165
4909 +# define SDP_SDRC_RFR_CTRL          SDP_3430_SDRC_RFR_CTRL_165MHz
4910 +
4911 +/*
4912 + * GPMC settings -
4913 + * Definitions is as per the following format
4914 + * # define <PART>_GPMC_CONFIG<x> <value>
4915 + * Where:
4916 + * PART is the part name e.g. STNOR - Intel Strata Flash
4917 + * x is GPMC config registers from 1 to 6 (there will be 6 macros)
4918 + * Value is corresponding value
4919 + *
4920 + * For every valid PRCM configuration there should be only one definition of
4921 + * the same. if values are independent of the board, this definition will be
4922 + * present in this file if values are dependent on the board, then this should
4923 + * go into corresponding mem-boardName.h file
4924 + *
4925 + * Currently valid part Names are (PART):
4926 + * STNOR - Intel Strata Flash
4927 + * SMNAND - Samsung NAND
4928 + * MPDB - H4 MPDB board
4929 + * SBNOR - Sibley NOR
4930 + * MNAND - Micron Large page x16 NAND
4931 + * ONNAND - Samsung One NAND
4932 + *
4933 + * include/configs/file.h contains the defn - for all CS we are interested
4934 + * #define OMAP34XX_GPMC_CSx PART
4935 + * #define OMAP34XX_GPMC_CSx_SIZE Size
4936 + * #define OMAP34XX_GPMC_CSx_MAP Map
4937 + * Where:
4938 + * x - CS number
4939 + * PART - Part Name as defined above
4940 + * SIZE - how big is the mapping to be
4941 + *   GPMC_SIZE_128M - 0x8
4942 + *   GPMC_SIZE_64M  - 0xC
4943 + *   GPMC_SIZE_32M  - 0xE
4944 + *   GPMC_SIZE_16M  - 0xF
4945 + * MAP  - Map this CS to which address(GPMC address space)- Absolute address
4946 + *   >>24 before being used.
4947 + */
4948 +#define GPMC_SIZE_128M  0x8
4949 +#define GPMC_SIZE_64M   0xC
4950 +#define GPMC_SIZE_32M   0xE
4951 +#define GPMC_SIZE_16M   0xF
4952 +
4953 +# define SMNAND_GPMC_CONFIG1 0x00000800
4954 +# define SMNAND_GPMC_CONFIG2 0x00141400
4955 +# define SMNAND_GPMC_CONFIG3 0x00141400
4956 +# define SMNAND_GPMC_CONFIG4 0x0F010F01
4957 +# define SMNAND_GPMC_CONFIG5 0x010C1414
4958 +# define SMNAND_GPMC_CONFIG6 0x1F0F0A80
4959 +# define SMNAND_GPMC_CONFIG7 0x00000C44
4960 +
4961 +# define M_NAND_GPMC_CONFIG1 0x00001800
4962 +# define M_NAND_GPMC_CONFIG2 0x00141400
4963 +# define M_NAND_GPMC_CONFIG3 0x00141400
4964 +# define M_NAND_GPMC_CONFIG4 0x0F010F01
4965 +# define M_NAND_GPMC_CONFIG5 0x010C1414
4966 +# define M_NAND_GPMC_CONFIG6 0x1f0f0A80
4967 +# define M_NAND_GPMC_CONFIG7 0x00000C44
4968 +
4969 +# define STNOR_GPMC_CONFIG1  0x3
4970 +# define STNOR_GPMC_CONFIG2  0x00151501
4971 +# define STNOR_GPMC_CONFIG3  0x00060602
4972 +# define STNOR_GPMC_CONFIG4  0x11091109
4973 +# define STNOR_GPMC_CONFIG5  0x01141F1F
4974 +# define STNOR_GPMC_CONFIG6  0x000004c4
4975 +
4976 +# define SIBNOR_GPMC_CONFIG1  0x1200
4977 +# define SIBNOR_GPMC_CONFIG2  0x001f1f00
4978 +# define SIBNOR_GPMC_CONFIG3  0x00080802
4979 +# define SIBNOR_GPMC_CONFIG4  0x1C091C09
4980 +# define SIBNOR_GPMC_CONFIG5  0x01131F1F
4981 +# define SIBNOR_GPMC_CONFIG6  0x1F0F03C2
4982 +
4983 +# define SDPV2_MPDB_GPMC_CONFIG1  0x00611200
4984 +# define SDPV2_MPDB_GPMC_CONFIG2  0x001F1F01
4985 +# define SDPV2_MPDB_GPMC_CONFIG3  0x00080803
4986 +# define SDPV2_MPDB_GPMC_CONFIG4  0x1D091D09
4987 +# define SDPV2_MPDB_GPMC_CONFIG5  0x041D1F1F
4988 +# define SDPV2_MPDB_GPMC_CONFIG6  0x1D0904C4
4989 +
4990 +# define MPDB_GPMC_CONFIG1  0x00011000
4991 +# define MPDB_GPMC_CONFIG2  0x001f1f01
4992 +# define MPDB_GPMC_CONFIG3  0x00080803
4993 +# define MPDB_GPMC_CONFIG4  0x1c0b1c0a
4994 +# define MPDB_GPMC_CONFIG5  0x041f1F1F
4995 +# define MPDB_GPMC_CONFIG6  0x1F0F04C4
4996 +
4997 +# define P2_GPMC_CONFIG1  0x0
4998 +# define P2_GPMC_CONFIG2  0x0
4999 +# define P2_GPMC_CONFIG3  0x0
5000 +# define P2_GPMC_CONFIG4  0x0
5001 +# define P2_GPMC_CONFIG5  0x0
5002 +# define P2_GPMC_CONFIG6  0x0
5003 +
5004 +# define ONENAND_GPMC_CONFIG1 0x00001200
5005 +# define ONENAND_GPMC_CONFIG2 0x000F0F01
5006 +# define ONENAND_GPMC_CONFIG3 0x00030301
5007 +# define ONENAND_GPMC_CONFIG4 0x0F040F04
5008 +# define ONENAND_GPMC_CONFIG5 0x010F1010
5009 +# define ONENAND_GPMC_CONFIG6 0x1F060000
5010 +
5011 +/* max number of GPMC Chip Selects */
5012 +#define GPMC_MAX_CS    8
5013 +/* max number of GPMC regs */
5014 +#define GPMC_MAX_REG   7
5015 +
5016 +#define PISMO1_NOR     1
5017 +#define PISMO1_NAND    2
5018 +#define PISMO2_CS0     3
5019 +#define PISMO2_CS1     4
5020 +#define PISMO1_ONENAND 5
5021 +#define DBG_MPDB       6
5022 +#define PISMO2_NAND_CS0 7
5023 +#define PISMO2_NAND_CS1 8
5024 +
5025 +/* make it readable for the gpmc_init */
5026 +#define PISMO1_NOR_BASE                FLASH_BASE
5027 +#define PISMO1_NAND_BASE       NAND_BASE
5028 +#define PISMO2_CS0_BASE                PISMO2_MAP1
5029 +#define PISMO1_ONEN_BASE       ONENAND_MAP
5030 +#define DBG_MPDB_BASE          DEBUG_BASE
5031 +
5032 +#endif /* endif _MEM_H_ */
5033 diff --git a/include/asm-arm/arch-omap3/mmc.h b/include/asm-arm/arch-omap3/mmc.h
5034 new file mode 100644
5035 index 0000000..8631aae
5036 --- /dev/null
5037 +++ b/include/asm-arm/arch-omap3/mmc.h
5038 @@ -0,0 +1,235 @@
5039 +/*
5040 + * (C) Copyright 2008
5041 + * Texas Instruments, <www.ti.com>
5042 + * Syed Mohammed Khasim <khasim@ti.com>
5043 + *
5044 + * See file CREDITS for list of people who contributed to this
5045 + * project.
5046 + *
5047 + * This program is free software; you can redistribute it and/or
5048 + * modify it under the terms of the GNU General Public License as
5049 + * published by the Free Software Foundation's version 2 of
5050 + * the License.
5051 + *
5052 + * This program is distributed in the hope that it will be useful,
5053 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5054 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5055 + * GNU General Public License for more details.
5056 + *
5057 + * You should have received a copy of the GNU General Public License
5058 + * along with this program; if not, write to the Free Software
5059 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
5060 + * MA 02111-1307 USA
5061 + */
5062 +
5063 +#ifndef MMC_H
5064 +#define MMC_H
5065 +
5066 +#include "mmc_host_def.h"
5067 +
5068 +/* Responses */
5069 +#define RSP_TYPE_NONE    (RSP_TYPE_NORSP   | CCCE_NOCHECK | CICE_NOCHECK)
5070 +#define RSP_TYPE_R1      (RSP_TYPE_LGHT48  | CCCE_CHECK   | CICE_CHECK)
5071 +#define RSP_TYPE_R1B     (RSP_TYPE_LGHT48B | CCCE_CHECK   | CICE_CHECK)
5072 +#define RSP_TYPE_R2      (RSP_TYPE_LGHT136 | CCCE_CHECK   | CICE_NOCHECK)
5073 +#define RSP_TYPE_R3      (RSP_TYPE_LGHT48  | CCCE_NOCHECK | CICE_NOCHECK)
5074 +#define RSP_TYPE_R4      (RSP_TYPE_LGHT48  | CCCE_NOCHECK | CICE_NOCHECK)
5075 +#define RSP_TYPE_R5      (RSP_TYPE_LGHT48  | CCCE_CHECK   | CICE_CHECK)
5076 +#define RSP_TYPE_R6      (RSP_TYPE_LGHT48  | CCCE_CHECK   | CICE_CHECK)
5077 +#define RSP_TYPE_R7      (RSP_TYPE_LGHT48  | CCCE_CHECK   | CICE_CHECK)
5078 +
5079 +/* All supported commands */
5080 +#define MMC_CMD0          (INDEX(0)  | RSP_TYPE_NONE | DP_NO_DATA | DDIR_WRITE)
5081 +#define MMC_CMD1          (INDEX(1)  | RSP_TYPE_R3   | DP_NO_DATA | DDIR_WRITE)
5082 +#define MMC_CMD2          (INDEX(2)  | RSP_TYPE_R2   | DP_NO_DATA | DDIR_WRITE)
5083 +#define MMC_CMD3          (INDEX(3)  | RSP_TYPE_R1   | DP_NO_DATA | DDIR_WRITE)
5084 +#define MMC_SDCMD3        (INDEX(3)  | RSP_TYPE_R6   | DP_NO_DATA | DDIR_WRITE)
5085 +#define MMC_CMD4          (INDEX(4)  | RSP_TYPE_NONE | DP_NO_DATA | DDIR_WRITE)
5086 +#define MMC_CMD6          (INDEX(6)  | RSP_TYPE_R1B  | DP_NO_DATA | DDIR_WRITE)
5087 +#define MMC_CMD7_SELECT   (INDEX(7)  | RSP_TYPE_R1B  | DP_NO_DATA | DDIR_WRITE)
5088 +#define MMC_CMD7_DESELECT (INDEX(7)  | RSP_TYPE_NONE | DP_NO_DATA | DDIR_WRITE)
5089 +#define MMC_CMD8          (INDEX(8)  | RSP_TYPE_R1   | DP_DATA    | DDIR_READ)
5090 +#define MMC_SDCMD8        (INDEX(8)  | RSP_TYPE_R7   | DP_NO_DATA | DDIR_WRITE)
5091 +#define MMC_CMD9          (INDEX(9)  | RSP_TYPE_R2   | DP_NO_DATA | DDIR_WRITE)
5092 +#define MMC_CMD12         (INDEX(12) | RSP_TYPE_R1B  | DP_NO_DATA | DDIR_WRITE)
5093 +#define MMC_CMD13         (INDEX(13) | RSP_TYPE_R1   | DP_NO_DATA | DDIR_WRITE)
5094 +#define MMC_CMD15         (INDEX(15) | RSP_TYPE_NONE | DP_NO_DATA | DDIR_WRITE)
5095 +#define MMC_CMD16         (INDEX(16) | RSP_TYPE_R1   | DP_NO_DATA | DDIR_WRITE)
5096 +#define MMC_CMD17         (INDEX(17) | RSP_TYPE_R1   | DP_DATA    | DDIR_READ)
5097 +#define MMC_CMD24         (INDEX(24) | RSP_TYPE_R1   | DP_DATA    | DDIR_WRITE)
5098 +#define MMC_ACMD6         (INDEX(6)  | RSP_TYPE_R1   | DP_NO_DATA | DDIR_WRITE)
5099 +#define MMC_ACMD41        (INDEX(41) | RSP_TYPE_R3   | DP_NO_DATA | DDIR_WRITE)
5100 +#define MMC_ACMD51        (INDEX(51) | RSP_TYPE_R1   | DP_DATA    | DDIR_READ)
5101 +#define MMC_CMD55         (INDEX(55) | RSP_TYPE_R1   | DP_NO_DATA | DDIR_WRITE)
5102 +
5103 +#define MMC_AC_CMD_RCA_MASK     (unsigned int)(0xFFFF << 16)
5104 +#define MMC_BC_CMD_DSR_MASK     (unsigned int)(0xFFFF << 16)
5105 +#define MMC_DSR_DEFAULT         (0x0404)
5106 +#define SD_CMD8_CHECK_PATTERN  (0xAA)
5107 +#define SD_CMD8_2_7_3_6_V_RANGE        (0x01 << 8)
5108 +
5109 +/* Clock Configurations and Macros */
5110 +
5111 +#define MMC_CLOCK_REFERENCE            (96)
5112 +#define MMC_RELATIVE_CARD_ADDRESS      (0x1234)
5113 +#define MMC_INIT_SEQ_CLK               (MMC_CLOCK_REFERENCE * 1000 / 80)
5114 +#define MMC_400kHz_CLK                 (MMC_CLOCK_REFERENCE * 1000 / 400)
5115 +#define CLKDR(r, f, u)                 ((((r)*100) / ((f)*(u))) + 1)
5116 +#define CLKD(f, u)                     (CLKDR(MMC_CLOCK_REFERENCE, f, u))
5117 +
5118 +#define MMC_OCR_REG_ACCESS_MODE_MASK                   (0x3 << 29)
5119 +#define MMC_OCR_REG_ACCESS_MODE_BYTE                   (0x0 << 29)
5120 +#define MMC_OCR_REG_ACCESS_MODE_SECTOR                 (0x2 << 29)
5121 +
5122 +#define MMC_OCR_REG_HOST_CAPACITY_SUPPORT_MASK         (0x1 << 30)
5123 +#define MMC_OCR_REG_HOST_CAPACITY_SUPPORT_BYTE         (0x0 << 30)
5124 +#define MMC_OCR_REG_HOST_CAPACITY_SUPPORT_SECTOR       (0x1 << 30)
5125 +
5126 +#define MMC_SD2_CSD_C_SIZE_LSB_MASK         (0xFFFF)
5127 +#define MMC_SD2_CSD_C_SIZE_MSB_MASK         (0x003F)
5128 +#define MMC_SD2_CSD_C_SIZE_MSB_OFFSET       (16)
5129 +#define MMC_CSD_C_SIZE_LSB_MASK             (0x0003)
5130 +#define MMC_CSD_C_SIZE_MSB_MASK             (0x03FF)
5131 +#define MMC_CSD_C_SIZE_MSB_OFFSET           (2)
5132 +
5133 +#define MMC_CSD_TRAN_SPEED_UNIT_MASK        (0x07 << 0)
5134 +#define MMC_CSD_TRAN_SPEED_FACTOR_MASK      (0x0F << 3)
5135 +#define MMC_CSD_TRAN_SPEED_UNIT_100MHZ      (0x3 << 0)
5136 +#define MMC_CSD_TRAN_SPEED_FACTOR_1_0       (0x01 << 3)
5137 +#define MMC_CSD_TRAN_SPEED_FACTOR_8_0       (0x0F << 3)
5138 +
5139 +typedef struct {
5140 +       unsigned not_used:1;
5141 +       unsigned crc:7;
5142 +       unsigned ecc:2;
5143 +       unsigned file_format:2;
5144 +       unsigned tmp_write_protect:1;
5145 +       unsigned perm_write_protect:1;
5146 +       unsigned copy:1;
5147 +       unsigned file_format_grp:1;
5148 +       unsigned content_prot_app:1;
5149 +       unsigned reserved_1:4;
5150 +       unsigned write_bl_partial:1;
5151 +       unsigned write_bl_len:4;
5152 +       unsigned r2w_factor:3;
5153 +       unsigned default_ecc:2;
5154 +       unsigned wp_grp_enable:1;
5155 +       unsigned wp_grp_size:5;
5156 +       unsigned erase_grp_mult:5;
5157 +       unsigned erase_grp_size:5;
5158 +       unsigned c_size_mult:3;
5159 +       unsigned vdd_w_curr_max:3;
5160 +       unsigned vdd_w_curr_min:3;
5161 +       unsigned vdd_r_curr_max:3;
5162 +       unsigned vdd_r_curr_min:3;
5163 +       unsigned c_size_lsb:2;
5164 +       unsigned c_size_msb:10;
5165 +       unsigned reserved_2:2;
5166 +       unsigned dsr_imp:1;
5167 +       unsigned read_blk_misalign:1;
5168 +       unsigned write_blk_misalign:1;
5169 +       unsigned read_bl_partial:1;
5170 +       unsigned read_bl_len:4;
5171 +       unsigned ccc:12;
5172 +       unsigned tran_speed:8;
5173 +       unsigned nsac:8;
5174 +       unsigned taac:8;
5175 +       unsigned reserved_3:2;
5176 +       unsigned spec_vers:4;
5177 +       unsigned csd_structure:2;
5178 +} mmc_csd_reg_t;
5179 +
5180 +/* csd for sd2.0 */
5181 +typedef struct {
5182 +       unsigned not_used:1;
5183 +       unsigned crc:7;
5184 +       unsigned reserved_1:2;
5185 +       unsigned file_format:2;
5186 +       unsigned tmp_write_protect:1;
5187 +       unsigned perm_write_protect:1;
5188 +       unsigned copy:1;
5189 +       unsigned file_format_grp:1;
5190 +       unsigned reserved_2:5;
5191 +       unsigned write_bl_partial:1;
5192 +       unsigned write_bl_len:4;
5193 +       unsigned r2w_factor:3;
5194 +       unsigned reserved_3:2;
5195 +       unsigned wp_grp_enable:1;
5196 +       unsigned wp_grp_size:7;
5197 +       unsigned sector_size:7;
5198 +       unsigned erase_blk_len:1;
5199 +       unsigned reserved_4:1;
5200 +       unsigned c_size_lsb:16;
5201 +       unsigned c_size_msb:6;
5202 +       unsigned reserved_5:6;
5203 +       unsigned dsr_imp:1;
5204 +       unsigned read_blk_misalign:1;
5205 +       unsigned write_blk_misalign:1;
5206 +       unsigned read_bl_partial:1;
5207 +       unsigned read_bl_len:4;
5208 +       unsigned ccc:12;
5209 +       unsigned tran_speed:8;
5210 +       unsigned nsac:8;
5211 +       unsigned taac:8;
5212 +       unsigned reserved_6:6;
5213 +       unsigned csd_structure:2;
5214 +} mmc_sd2_csd_reg_t;
5215 +
5216 +/* extended csd - 512 bytes long */
5217 +typedef struct {
5218 +       unsigned char reserved_1[181];
5219 +       unsigned char erasedmemorycontent;
5220 +       unsigned char reserved_2;
5221 +       unsigned char buswidthmode;
5222 +       unsigned char reserved_3;
5223 +       unsigned char highspeedinterfacetiming;
5224 +       unsigned char reserved_4;
5225 +       unsigned char powerclass;
5226 +       unsigned char reserved_5;
5227 +       unsigned char commandsetrevision;
5228 +       unsigned char reserved_6;
5229 +       unsigned char commandset;
5230 +       unsigned char extendedcsdrevision;
5231 +       unsigned char reserved_7;
5232 +       unsigned char csdstructureversion;
5233 +       unsigned char reserved_8;
5234 +       unsigned char cardtype;
5235 +       unsigned char reserved_9[3];
5236 +       unsigned char powerclass_52mhz_1_95v;
5237 +       unsigned char powerclass_26mhz_1_95v;
5238 +       unsigned char powerclass_52mhz_3_6v;
5239 +       unsigned char powerclass_26mhz_3_6v;
5240 +       unsigned char reserved_10;
5241 +       unsigned char minreadperf_4b_26mhz;
5242 +       unsigned char minwriteperf_4b_26mhz;
5243 +       unsigned char minreadperf_8b_26mhz_4b_52mhz;
5244 +       unsigned char minwriteperf_8b_26mhz_4b_52mhz;
5245 +       unsigned char minreadperf_8b_52mhz;
5246 +       unsigned char minwriteperf_8b_52mhz;
5247 +       unsigned char reserved_11;
5248 +       unsigned int sectorcount;
5249 +       unsigned char reserved_12[288];
5250 +       unsigned char supportedcommandsets;
5251 +       unsigned char reserved_13[7];
5252 +} mmc_extended_csd_reg_t;
5253 +
5254 +/* mmc sd responce */
5255 +typedef struct {
5256 +       unsigned int ocr;
5257 +} mmc_resp_r3;
5258 +
5259 +typedef struct {
5260 +       unsigned short cardstatus;
5261 +       unsigned short newpublishedrca;
5262 +} mmc_resp_r6;
5263 +
5264 +extern mmc_card_data mmc_dev;
5265 +
5266 +unsigned char mmc_lowlevel_init(void);
5267 +unsigned char mmc_send_command(unsigned int cmd, unsigned int arg,
5268 +                              unsigned int *response);
5269 +unsigned char mmc_setup_clock(unsigned int iclk, unsigned short clkd);
5270 +unsigned char mmc_set_opendrain(unsigned char state);
5271 +unsigned char mmc_read_data(unsigned int *output_buf);
5272 +
5273 +#endif /* MMC_H */
5274 diff --git a/include/asm-arm/arch-omap3/mmc_host_def.h b/include/asm-arm/arch-omap3/mmc_host_def.h
5275 new file mode 100644
5276 index 0000000..37aaa08
5277 --- /dev/null
5278 +++ b/include/asm-arm/arch-omap3/mmc_host_def.h
5279 @@ -0,0 +1,166 @@
5280 +/*
5281 + * (C) Copyright 2008
5282 + * Texas Instruments, <www.ti.com>
5283 + * Syed Mohammed Khasim <khasim@ti.com>
5284 + *
5285 + * See file CREDITS for list of people who contributed to this
5286 + * project.
5287 + *
5288 + * This program is free software; you can redistribute it and/or
5289 + * modify it under the terms of the GNU General Public License as
5290 + * published by the Free Software Foundation's version 2 of
5291 + * the License.
5292 + *
5293 + * This program is distributed in the hope that it will be useful,
5294 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5295 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5296 + * GNU General Public License for more details.
5297 + *
5298 + * You should have received a copy of the GNU General Public License
5299 + * along with this program; if not, write to the Free Software
5300 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
5301 + * MA 02111-1307 USA
5302 + */
5303 +
5304 +#ifndef MMC_HOST_DEF_H
5305 +#define MMC_HOST_DEF_H
5306 +
5307 +/*
5308 + * OMAP HSMMC register definitions
5309 + */
5310 +#define OMAP_HSMMC_SYSCONFIG           (*(unsigned int *) 0x4809C010)
5311 +#define OMAP_HSMMC_SYSSTATUS           (*(unsigned int *) 0x4809C014)
5312 +#define OMAP_HSMMC_CON                 (*(unsigned int *) 0x4809C02C)
5313 +#define OMAP_HSMMC_BLK                 (*(unsigned int *) 0x4809C104)
5314 +#define OMAP_HSMMC_ARG                 (*(unsigned int *) 0x4809C108)
5315 +#define OMAP_HSMMC_CMD                 (*(unsigned int *) 0x4809C10C)
5316 +#define OMAP_HSMMC_RSP10               (*(unsigned int *) 0x4809C110)
5317 +#define OMAP_HSMMC_RSP32               (*(unsigned int *) 0x4809C114)
5318 +#define OMAP_HSMMC_RSP54               (*(unsigned int *) 0x4809C118)
5319 +#define OMAP_HSMMC_RSP76               (*(unsigned int *) 0x4809C11C)
5320 +#define OMAP_HSMMC_DATA                        (*(unsigned int *) 0x4809C120)
5321 +#define OMAP_HSMMC_PSTATE              (*(unsigned int *) 0x4809C124)
5322 +#define OMAP_HSMMC_HCTL                        (*(unsigned int *) 0x4809C128)
5323 +#define OMAP_HSMMC_SYSCTL              (*(unsigned int *) 0x4809C12C)
5324 +#define OMAP_HSMMC_STAT                        (*(unsigned int *) 0x4809C130)
5325 +#define OMAP_HSMMC_IE                  (*(unsigned int *) 0x4809C134)
5326 +#define OMAP_HSMMC_CAPA                        (*(unsigned int *) 0x4809C140)
5327 +
5328 +/* T2 Register definitions */
5329 +#define CONTROL_DEV_CONF0              (*(unsigned int *) 0x48002274)
5330 +#define CONTROL_PBIAS_LITE             (*(unsigned int *) 0x48002520)
5331 +
5332 +/*
5333 + * OMAP HS MMC Bit definitions
5334 + */
5335 +#define MMC_SOFTRESET                  (0x1 << 1)
5336 +#define RESETDONE                      (0x1 << 0)
5337 +#define NOOPENDRAIN                    (0x0 << 0)
5338 +#define OPENDRAIN                      (0x1 << 0)
5339 +#define OD                             (0x1 << 0)
5340 +#define INIT_NOINIT                    (0x0 << 1)
5341 +#define INIT_INITSTREAM                        (0x1 << 1)
5342 +#define HR_NOHOSTRESP                  (0x0 << 2)
5343 +#define STR_BLOCK                      (0x0 << 3)
5344 +#define MODE_FUNC                      (0x0 << 4)
5345 +#define DW8_1_4BITMODE                         (0x0 << 5)
5346 +#define MIT_CTO                                (0x0 << 6)
5347 +#define CDP_ACTIVEHIGH                 (0x0 << 7)
5348 +#define WPP_ACTIVEHIGH                         (0x0 << 8)
5349 +#define RESERVED_MASK                  (0x3 << 9)
5350 +#define CTPL_MMC_SD                    (0x0 << 11)
5351 +#define BLEN_512BYTESLEN               (0x200 << 0)
5352 +#define NBLK_STPCNT                    (0x0 << 16)
5353 +#define DE_DISABLE                     (0x0 << 0)
5354 +#define BCE_DISABLE                    (0x0 << 1)
5355 +#define ACEN_DISABLE                   (0x0 << 2)
5356 +#define DDIR_OFFSET                    (4)
5357 +#define DDIR_MASK                      (0x1 << 4)
5358 +#define DDIR_WRITE                     (0x0 << 4)
5359 +#define DDIR_READ                      (0x1 << 4)
5360 +#define MSBS_SGLEBLK                   (0x0 << 5)
5361 +#define RSP_TYPE_OFFSET                        (16)
5362 +#define RSP_TYPE_MASK                  (0x3 << 16)
5363 +#define RSP_TYPE_NORSP                 (0x0 << 16)
5364 +#define RSP_TYPE_LGHT136               (0x1 << 16)
5365 +#define RSP_TYPE_LGHT48                        (0x2 << 16)
5366 +#define RSP_TYPE_LGHT48B               (0x3 << 16)
5367 +#define CCCE_NOCHECK                   (0x0 << 19)
5368 +#define CCCE_CHECK                     (0x1 << 19)
5369 +#define CICE_NOCHECK                   (0x0 << 20)
5370 +#define CICE_CHECK                     (0x1 << 20)
5371 +#define DP_OFFSET                      (21)
5372 +#define DP_MASK                                (0x1 << 21)
5373 +#define DP_NO_DATA                     (0x0 << 21)
5374 +#define DP_DATA                                (0x1 << 21)
5375 +#define CMD_TYPE_NORMAL                        (0x0 << 22)
5376 +#define INDEX_OFFSET                   (24)
5377 +#define INDEX_MASK                     (0x3f << 24)
5378 +#define INDEX(i)                       (i << 24)
5379 +#define DATI_MASK                      (0x1 << 1)
5380 +#define DATI_CMDDIS                    (0x1 << 1)
5381 +#define DTW_1_BITMODE                  (0x0 << 1)
5382 +#define DTW_4_BITMODE                  (0x1 << 1)
5383 +#define SDBP_PWROFF                    (0x0 << 8)
5384 +#define SDBP_PWRON                     (0x1 << 8)
5385 +#define SDVS_1V8                       (0x5 << 9)
5386 +#define SDVS_3V0                       (0x6 << 9)
5387 +#define ICE_MASK                       (0x1 << 0)
5388 +#define ICE_STOP                       (0x0 << 0)
5389 +#define ICS_MASK                       (0x1 << 1)
5390 +#define ICS_NOTREADY                   (0x0 << 1)
5391 +#define ICE_OSCILLATE                  (0x1 << 0)
5392 +#define CEN_MASK                       (0x1 << 2)
5393 +#define CEN_DISABLE                    (0x0 << 2)
5394 +#define CEN_ENABLE                     (0x1 << 2)
5395 +#define CLKD_OFFSET                    (6)
5396 +#define CLKD_MASK                      (0x3FF << 6)
5397 +#define DTO_MASK                       (0xF << 16)
5398 +#define DTO_15THDTO                    (0xE << 16)
5399 +#define SOFTRESETALL                   (0x1 << 24)
5400 +#define CC_MASK                                (0x1 << 0)
5401 +#define TC_MASK                                (0x1 << 1)
5402 +#define BWR_MASK                       (0x1 << 4)
5403 +#define BRR_MASK                       (0x1 << 5)
5404 +#define ERRI_MASK                      (0x1 << 15)
5405 +#define IE_CC                          (0x01 << 0)
5406 +#define IE_TC                          (0x01 << 1)
5407 +#define IE_BWR                         (0x01 << 4)
5408 +#define IE_BRR                         (0x01 << 5)
5409 +#define IE_CTO                         (0x01 << 16)
5410 +#define IE_CCRC                                (0x01 << 17)
5411 +#define IE_CEB                         (0x01 << 18)
5412 +#define IE_CIE                         (0x01 << 19)
5413 +#define IE_DTO                         (0x01 << 20)
5414 +#define IE_DCRC                                (0x01 << 21)
5415 +#define IE_DEB                         (0x01 << 22)
5416 +#define IE_CERR                                (0x01 << 28)
5417 +#define IE_BADA                                (0x01 << 29)
5418 +
5419 +#define VS30_3V0SUP                    (1 << 25)
5420 +#define VS18_1V8SUP                    (1 << 26)
5421 +
5422 +/* Driver definitions */
5423 +#define MMCSD_SECTOR_SIZE              (512)
5424 +#define MMC_CARD                       0
5425 +#define SD_CARD                                1
5426 +#define BYTE_MODE                      0
5427 +#define SECTOR_MODE                    1
5428 +#define CLK_INITSEQ                    0
5429 +#define CLK_400KHZ                     1
5430 +#define CLK_MISC                       2
5431 +
5432 +typedef struct {
5433 +       unsigned int card_type;
5434 +       unsigned int version;
5435 +       unsigned int mode;
5436 +       unsigned int size;
5437 +       unsigned int RCA;
5438 +} mmc_card_data;
5439 +
5440 +#define mmc_reg_out(addr, mask, val)\
5441 +       (addr) = (((addr)) & (~(mask))) | ((val) & (mask));
5442 +#define mmc_reg_out(addr, mask, val)\
5443 +       (addr) = (((addr)) & (~(mask))) | ((val) & (mask));
5444 +
5445 +#endif /* MMC_HOST_DEF_H */
5446 diff --git a/include/asm-arm/arch-omap3/mux.h b/include/asm-arm/arch-omap3/mux.h
5447 new file mode 100644
5448 index 0000000..ec4aeb0
5449 --- /dev/null
5450 +++ b/include/asm-arm/arch-omap3/mux.h
5451 @@ -0,0 +1,757 @@
5452 +/*
5453 + * (C) Copyright 2006-2008
5454 + * Texas Instruments, <www.ti.com>
5455 + * Syed Mohammed Khasim <x0khasim@ti.com>
5456 + *
5457 + * This program is free software; you can redistribute it and/or
5458 + * modify it under the terms of the GNU General Public License as
5459 + * published by the Free Software Foundation; either version 2 of
5460 + * the License, or (at your option) any later version.
5461 + *
5462 + * This program is distributed in the hope that it will be useful,
5463 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5464 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5465 + * GNU General Public License for more details.
5466 + *
5467 + * You should have received a copy of the GNU General Public License
5468 + * along with this program; if not, write to the Free Software
5469 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
5470 + * MA 02111-1307 USA
5471 + */
5472 +#ifndef _MUX_H_
5473 +#define _MUX_H_
5474 +
5475 +/*
5476 + * IEN  - Input Enable
5477 + * IDIS - Input Disable
5478 + * PTD  - Pull type Down
5479 + * PTU  - Pull type Up
5480 + * DIS  - Pull type selection is inactive
5481 + * EN   - Pull type selection is active
5482 + * M0   - Mode 0
5483 + */
5484 +
5485 +#define  IEN   (1 << 8)
5486 +
5487 +#define  IDIS  (0 << 8)
5488 +#define  PTU   (1 << 4)
5489 +#define  PTD   (0 << 4)
5490 +#define  EN            (1 << 3)
5491 +#define  DIS   (0 << 3)
5492 +
5493 +#define  M0    0
5494 +#define  M1    1
5495 +#define  M2    2
5496 +#define  M3    3
5497 +#define  M4    4
5498 +#define  M5    5
5499 +#define  M6    6
5500 +#define  M7    7
5501 +
5502 +/*
5503 + * To get the actual address the offset has to added
5504 + * with OMAP34XX_CTRL_BASE to get the actual address
5505 + */
5506 +
5507 + /*SDRC*/
5508 +#define  CONTROL_PADCONF_SDRC_D0             0x0030
5509 +#define  CONTROL_PADCONF_SDRC_D1             0x0032
5510 +#define  CONTROL_PADCONF_SDRC_D2             0x0034
5511 +#define  CONTROL_PADCONF_SDRC_D3             0x0036
5512 +#define  CONTROL_PADCONF_SDRC_D4             0x0038
5513 +#define  CONTROL_PADCONF_SDRC_D5             0x003A
5514 +#define  CONTROL_PADCONF_SDRC_D6             0x003C
5515 +#define  CONTROL_PADCONF_SDRC_D7             0x003E
5516 +#define  CONTROL_PADCONF_SDRC_D8             0x0040
5517 +#define  CONTROL_PADCONF_SDRC_D9             0x0042
5518 +#define  CONTROL_PADCONF_SDRC_D10            0x0044
5519 +#define  CONTROL_PADCONF_SDRC_D11            0x0046
5520 +#define  CONTROL_PADCONF_SDRC_D12            0x0048
5521 +#define  CONTROL_PADCONF_SDRC_D13            0x004A
5522 +#define  CONTROL_PADCONF_SDRC_D14            0x004C
5523 +#define  CONTROL_PADCONF_SDRC_D15            0x004E
5524 +#define  CONTROL_PADCONF_SDRC_D16            0x0050
5525 +#define  CONTROL_PADCONF_SDRC_D17            0x0052
5526 +#define  CONTROL_PADCONF_SDRC_D18            0x0054
5527 +#define  CONTROL_PADCONF_SDRC_D19            0x0056
5528 +#define  CONTROL_PADCONF_SDRC_D20            0x0058
5529 +#define  CONTROL_PADCONF_SDRC_D21            0x005A
5530 +#define  CONTROL_PADCONF_SDRC_D22            0x005C
5531 +#define  CONTROL_PADCONF_SDRC_D23            0x005E
5532 +#define  CONTROL_PADCONF_SDRC_D24            0x0060
5533 +#define  CONTROL_PADCONF_SDRC_D25            0x0062
5534 +#define  CONTROL_PADCONF_SDRC_D26            0x0064
5535 +#define  CONTROL_PADCONF_SDRC_D27            0x0066
5536 +#define  CONTROL_PADCONF_SDRC_D28            0x0068
5537 +#define  CONTROL_PADCONF_SDRC_D29            0x006A
5538 +#define  CONTROL_PADCONF_SDRC_D30            0x006C
5539 +#define  CONTROL_PADCONF_SDRC_D31            0x006E
5540 +#define  CONTROL_PADCONF_SDRC_CLK            0x0070
5541 +#define  CONTROL_PADCONF_SDRC_DQS0           0x0072
5542 +#define  CONTROL_PADCONF_SDRC_DQS1           0x0074
5543 +#define  CONTROL_PADCONF_SDRC_DQS2           0x0076
5544 +#define  CONTROL_PADCONF_SDRC_DQS3           0x0078
5545 +     /*GPMC*/
5546 +#define  CONTROL_PADCONF_GPMC_A1             0x007A
5547 +#define  CONTROL_PADCONF_GPMC_A2             0x007C
5548 +#define  CONTROL_PADCONF_GPMC_A3             0x007E
5549 +#define  CONTROL_PADCONF_GPMC_A4             0x0080
5550 +#define  CONTROL_PADCONF_GPMC_A5             0x0082
5551 +#define  CONTROL_PADCONF_GPMC_A6             0x0084
5552 +#define  CONTROL_PADCONF_GPMC_A7             0x0086
5553 +#define  CONTROL_PADCONF_GPMC_A8             0x0088
5554 +#define  CONTROL_PADCONF_GPMC_A9             0x008A
5555 +#define  CONTROL_PADCONF_GPMC_A10            0x008C
5556 +#define  CONTROL_PADCONF_GPMC_D0             0x008E
5557 +#define  CONTROL_PADCONF_GPMC_D1             0x0090
5558 +#define  CONTROL_PADCONF_GPMC_D2             0x0092
5559 +#define  CONTROL_PADCONF_GPMC_D3             0x0094
5560 +#define  CONTROL_PADCONF_GPMC_D4             0x0096
5561 +#define  CONTROL_PADCONF_GPMC_D5             0x0098
5562 +#define  CONTROL_PADCONF_GPMC_D6             0x009A
5563 +#define  CONTROL_PADCONF_GPMC_D7             0x009C
5564 +#define  CONTROL_PADCONF_GPMC_D8             0x009E
5565 +#define  CONTROL_PADCONF_GPMC_D9             0x00A0
5566 +#define  CONTROL_PADCONF_GPMC_D10            0x00A2
5567 +#define  CONTROL_PADCONF_GPMC_D11            0x00A4
5568 +#define  CONTROL_PADCONF_GPMC_D12            0x00A6
5569 +#define  CONTROL_PADCONF_GPMC_D13            0x00A8
5570 +#define  CONTROL_PADCONF_GPMC_D14            0x00AA
5571 +#define  CONTROL_PADCONF_GPMC_D15            0x00AC
5572 +#define  CONTROL_PADCONF_GPMC_nCS0           0x00AE
5573 +#define  CONTROL_PADCONF_GPMC_nCS1           0x00B0
5574 +#define  CONTROL_PADCONF_GPMC_nCS2           0x00B2
5575 +#define  CONTROL_PADCONF_GPMC_nCS3           0x00B4
5576 +#define  CONTROL_PADCONF_GPMC_nCS4           0x00B6
5577 +#define  CONTROL_PADCONF_GPMC_nCS5           0x00B8
5578 +#define  CONTROL_PADCONF_GPMC_nCS6           0x00BA
5579 +#define  CONTROL_PADCONF_GPMC_nCS7           0x00BC
5580 +#define  CONTROL_PADCONF_GPMC_CLK            0x00BE
5581 +#define  CONTROL_PADCONF_GPMC_nADV_ALE       0x00C0
5582 +#define  CONTROL_PADCONF_GPMC_nOE            0x00C2
5583 +#define  CONTROL_PADCONF_GPMC_nWE            0x00C4
5584 +#define  CONTROL_PADCONF_GPMC_nBE0_CLE       0x00C6
5585 +#define  CONTROL_PADCONF_GPMC_nBE1           0x00C8
5586 +#define  CONTROL_PADCONF_GPMC_nWP            0x00CA
5587 +#define  CONTROL_PADCONF_GPMC_WAIT0          0x00CC
5588 +#define  CONTROL_PADCONF_GPMC_WAIT1          0x00CE
5589 +#define  CONTROL_PADCONF_GPMC_WAIT2          0x00D0
5590 +#define  CONTROL_PADCONF_GPMC_WAIT3          0x00D2
5591 +     /*DSS*/
5592 +#define  CONTROL_PADCONF_DSS_PCLK            0x00D4
5593 +#define  CONTROL_PADCONF_DSS_HSYNC           0x00D6
5594 +#define  CONTROL_PADCONF_DSS_VSYNC           0x00D8
5595 +#define  CONTROL_PADCONF_DSS_ACBIAS          0x00DA
5596 +#define  CONTROL_PADCONF_DSS_DATA0           0x00DC
5597 +#define  CONTROL_PADCONF_DSS_DATA1           0x00DE
5598 +#define  CONTROL_PADCONF_DSS_DATA2           0x00E0
5599 +#define  CONTROL_PADCONF_DSS_DATA3           0x00E2
5600 +#define  CONTROL_PADCONF_DSS_DATA4           0x00E4
5601 +#define  CONTROL_PADCONF_DSS_DATA5           0x00E6
5602 +#define  CONTROL_PADCONF_DSS_DATA6           0x00E8
5603 +#define  CONTROL_PADCONF_DSS_DATA7           0x00EA
5604 +#define  CONTROL_PADCONF_DSS_DATA8           0x00EC
5605 +#define  CONTROL_PADCONF_DSS_DATA9           0x00EE
5606 +#define  CONTROL_PADCONF_DSS_DATA10          0x00F0
5607 +#define  CONTROL_PADCONF_DSS_DATA11          0x00F2
5608 +#define  CONTROL_PADCONF_DSS_DATA12          0x00F4
5609 +#define  CONTROL_PADCONF_DSS_DATA13          0x00F6
5610 +#define  CONTROL_PADCONF_DSS_DATA14          0x00F8
5611 +#define  CONTROL_PADCONF_DSS_DATA15          0x00FA
5612 +#define  CONTROL_PADCONF_DSS_DATA16          0x00FC
5613 +#define  CONTROL_PADCONF_DSS_DATA17          0x00FE
5614 +#define  CONTROL_PADCONF_DSS_DATA18          0x0100
5615 +#define  CONTROL_PADCONF_DSS_DATA19          0x0102
5616 +#define  CONTROL_PADCONF_DSS_DATA20          0x0104
5617 +#define  CONTROL_PADCONF_DSS_DATA21          0x0106
5618 +#define  CONTROL_PADCONF_DSS_DATA22          0x0108
5619 +#define  CONTROL_PADCONF_DSS_DATA23          0x010A
5620 +     /*CAMERA*/
5621 +#define  CONTROL_PADCONF_CAM_HS              0x010C
5622 +#define  CONTROL_PADCONF_CAM_VS              0x010E
5623 +#define  CONTROL_PADCONF_CAM_XCLKA           0x0110
5624 +#define  CONTROL_PADCONF_CAM_PCLK            0x0112
5625 +#define  CONTROL_PADCONF_CAM_FLD             0x0114
5626 +#define  CONTROL_PADCONF_CAM_D0              0x0116
5627 +#define  CONTROL_PADCONF_CAM_D1              0x0118
5628 +#define  CONTROL_PADCONF_CAM_D2              0x011A
5629 +#define  CONTROL_PADCONF_CAM_D3              0x011C
5630 +#define  CONTROL_PADCONF_CAM_D4              0x011E
5631 +#define  CONTROL_PADCONF_CAM_D5              0x0120
5632 +#define  CONTROL_PADCONF_CAM_D6              0x0122
5633 +#define  CONTROL_PADCONF_CAM_D7              0x0124
5634 +#define  CONTROL_PADCONF_CAM_D8              0x0126
5635 +#define  CONTROL_PADCONF_CAM_D9              0x0128
5636 +#define  CONTROL_PADCONF_CAM_D10             0x012A
5637 +#define  CONTROL_PADCONF_CAM_D11             0x012C
5638 +#define  CONTROL_PADCONF_CAM_XCLKB           0x012E
5639 +#define  CONTROL_PADCONF_CAM_WEN             0x0130
5640 +#define  CONTROL_PADCONF_CAM_STROBE          0x0132
5641 +#define  CONTROL_PADCONF_CSI2_DX0            0x0134
5642 +#define  CONTROL_PADCONF_CSI2_DY0            0x0136
5643 +#define  CONTROL_PADCONF_CSI2_DX1            0x0138
5644 +#define  CONTROL_PADCONF_CSI2_DY1            0x013A
5645 +/*Audio Interface */
5646 +#define  CONTROL_PADCONF_McBSP2_FSX          0x013C
5647 +#define  CONTROL_PADCONF_McBSP2_CLKX         0x013E
5648 +#define  CONTROL_PADCONF_McBSP2_DR           0x0140
5649 +#define  CONTROL_PADCONF_McBSP2_DX           0x0142
5650 +#define  CONTROL_PADCONF_MMC1_CLK            0x0144
5651 +#define  CONTROL_PADCONF_MMC1_CMD            0x0146
5652 +#define  CONTROL_PADCONF_MMC1_DAT0           0x0148
5653 +#define  CONTROL_PADCONF_MMC1_DAT1           0x014A
5654 +#define  CONTROL_PADCONF_MMC1_DAT2           0x014C
5655 +#define  CONTROL_PADCONF_MMC1_DAT3           0x014E
5656 +#define  CONTROL_PADCONF_MMC1_DAT4           0x0150
5657 +#define  CONTROL_PADCONF_MMC1_DAT5           0x0152
5658 +#define  CONTROL_PADCONF_MMC1_DAT6           0x0154
5659 +#define  CONTROL_PADCONF_MMC1_DAT7           0x0156
5660 +/*Wireless LAN */
5661 +#define  CONTROL_PADCONF_MMC2_CLK            0x0158
5662 +#define  CONTROL_PADCONF_MMC2_CMD            0x015A
5663 +#define  CONTROL_PADCONF_MMC2_DAT0           0x015C
5664 +#define  CONTROL_PADCONF_MMC2_DAT1           0x015E
5665 +#define  CONTROL_PADCONF_MMC2_DAT2           0x0160
5666 +#define  CONTROL_PADCONF_MMC2_DAT3           0x0162
5667 +#define  CONTROL_PADCONF_MMC2_DAT4           0x0164
5668 +#define  CONTROL_PADCONF_MMC2_DAT5           0x0166
5669 +#define  CONTROL_PADCONF_MMC2_DAT6           0x0168
5670 +#define  CONTROL_PADCONF_MMC2_DAT7           0x016A
5671 +/*Bluetooth*/
5672 +#define  CONTROL_PADCONF_McBSP3_DX           0x016C
5673 +#define  CONTROL_PADCONF_McBSP3_DR           0x016E
5674 +#define  CONTROL_PADCONF_McBSP3_CLKX         0x0170
5675 +#define  CONTROL_PADCONF_McBSP3_FSX          0x0172
5676 +#define  CONTROL_PADCONF_UART2_CTS           0x0174
5677 +#define  CONTROL_PADCONF_UART2_RTS           0x0176
5678 +#define  CONTROL_PADCONF_UART2_TX            0x0178
5679 +#define  CONTROL_PADCONF_UART2_RX            0x017A
5680 +/*Modem Interface */
5681 +#define  CONTROL_PADCONF_UART1_TX            0x017C
5682 +#define  CONTROL_PADCONF_UART1_RTS           0x017E
5683 +#define  CONTROL_PADCONF_UART1_CTS           0x0180
5684 +#define  CONTROL_PADCONF_UART1_RX            0x0182
5685 +#define  CONTROL_PADCONF_McBSP4_CLKX         0x0184
5686 +#define  CONTROL_PADCONF_McBSP4_DR           0x0186
5687 +#define  CONTROL_PADCONF_McBSP4_DX           0x0188
5688 +#define  CONTROL_PADCONF_McBSP4_FSX          0x018A
5689 +#define  CONTROL_PADCONF_McBSP1_CLKR         0x018C
5690 +#define  CONTROL_PADCONF_McBSP1_FSR          0x018E
5691 +#define  CONTROL_PADCONF_McBSP1_DX           0x0190
5692 +#define  CONTROL_PADCONF_McBSP1_DR           0x0192
5693 +#define  CONTROL_PADCONF_McBSP_CLKS          0x0194
5694 +#define  CONTROL_PADCONF_McBSP1_FSX          0x0196
5695 +#define  CONTROL_PADCONF_McBSP1_CLKX         0x0198
5696 +/*Serial Interface*/
5697 +#define  CONTROL_PADCONF_UART3_CTS_RCTX      0x019A
5698 +#define  CONTROL_PADCONF_UART3_RTS_SD        0x019C
5699 +#define  CONTROL_PADCONF_UART3_RX_IRRX       0x019E
5700 +#define  CONTROL_PADCONF_UART3_TX_IRTX       0x01A0
5701 +#define  CONTROL_PADCONF_HSUSB0_CLK          0x01A2
5702 +#define  CONTROL_PADCONF_HSUSB0_STP          0x01A4
5703 +#define  CONTROL_PADCONF_HSUSB0_DIR          0x01A6
5704 +#define  CONTROL_PADCONF_HSUSB0_NXT          0x01A8
5705 +#define  CONTROL_PADCONF_HSUSB0_DATA0        0x01AA
5706 +#define  CONTROL_PADCONF_HSUSB0_DATA1        0x01AC
5707 +#define  CONTROL_PADCONF_HSUSB0_DATA2        0x01AE
5708 +#define  CONTROL_PADCONF_HSUSB0_DATA3        0x01B0
5709 +#define  CONTROL_PADCONF_HSUSB0_DATA4        0x01B2
5710 +#define  CONTROL_PADCONF_HSUSB0_DATA5        0x01B4
5711 +#define  CONTROL_PADCONF_HSUSB0_DATA6        0x01B6
5712 +#define  CONTROL_PADCONF_HSUSB0_DATA7        0x01B8
5713 +#define  CONTROL_PADCONF_I2C1_SCL            0x01BA
5714 +#define  CONTROL_PADCONF_I2C1_SDA            0x01BC
5715 +#define  CONTROL_PADCONF_I2C2_SCL            0x01BE
5716 +#define  CONTROL_PADCONF_I2C2_SDA            0x01C0
5717 +#define  CONTROL_PADCONF_I2C3_SCL            0x01C2
5718 +#define  CONTROL_PADCONF_I2C3_SDA            0x01C4
5719 +#define  CONTROL_PADCONF_I2C4_SCL            0x0A00
5720 +#define  CONTROL_PADCONF_I2C4_SDA            0x0A02
5721 +#define  CONTROL_PADCONF_HDQ_SIO             0x01C6
5722 +#define  CONTROL_PADCONF_McSPI1_CLK          0x01C8
5723 +#define  CONTROL_PADCONF_McSPI1_SIMO         0x01CA
5724 +#define  CONTROL_PADCONF_McSPI1_SOMI         0x01CC
5725 +#define  CONTROL_PADCONF_McSPI1_CS0          0x01CE
5726 +#define  CONTROL_PADCONF_McSPI1_CS1          0x01D0
5727 +#define  CONTROL_PADCONF_McSPI1_CS2          0x01D2
5728 +#define  CONTROL_PADCONF_McSPI1_CS3          0x01D4
5729 +#define  CONTROL_PADCONF_McSPI2_CLK          0x01D6
5730 +#define  CONTROL_PADCONF_McSPI2_SIMO         0x01D8
5731 +#define  CONTROL_PADCONF_McSPI2_SOMI         0x01DA
5732 +#define  CONTROL_PADCONF_McSPI2_CS0          0x01DC
5733 +#define  CONTROL_PADCONF_McSPI2_CS1          0x01DE
5734 +/*Control and debug */
5735 +#define  CONTROL_PADCONF_SYS_32K             0x0A04
5736 +#define  CONTROL_PADCONF_SYS_CLKREQ          0x0A06
5737 +#define  CONTROL_PADCONF_SYS_nIRQ            0x01E0
5738 +#define  CONTROL_PADCONF_SYS_BOOT0           0x0A0A
5739 +#define  CONTROL_PADCONF_SYS_BOOT1           0x0A0C
5740 +#define  CONTROL_PADCONF_SYS_BOOT2           0x0A0E
5741 +#define  CONTROL_PADCONF_SYS_BOOT3           0x0A10
5742 +#define  CONTROL_PADCONF_SYS_BOOT4           0x0A12
5743 +#define  CONTROL_PADCONF_SYS_BOOT5           0x0A14
5744 +#define  CONTROL_PADCONF_SYS_BOOT6           0x0A16
5745 +#define  CONTROL_PADCONF_SYS_OFF_MODE        0x0A18
5746 +#define  CONTROL_PADCONF_SYS_CLKOUT1         0x0A1A
5747 +#define  CONTROL_PADCONF_SYS_CLKOUT2         0x01E2
5748 +#define  CONTROL_PADCONF_JTAG_nTRST          0x0A1C
5749 +#define  CONTROL_PADCONF_JTAG_TCK            0x0A1E
5750 +#define  CONTROL_PADCONF_JTAG_TMS            0x0A20
5751 +#define  CONTROL_PADCONF_JTAG_TDI            0x0A22
5752 +#define  CONTROL_PADCONF_JTAG_EMU0           0x0A24
5753 +#define  CONTROL_PADCONF_JTAG_EMU1           0x0A26
5754 +#define  CONTROL_PADCONF_ETK_CLK             0x0A28
5755 +#define  CONTROL_PADCONF_ETK_CTL             0x0A2A
5756 +#define  CONTROL_PADCONF_ETK_D0              0x0A2C
5757 +#define  CONTROL_PADCONF_ETK_D1              0x0A2E
5758 +#define  CONTROL_PADCONF_ETK_D2              0x0A30
5759 +#define  CONTROL_PADCONF_ETK_D3              0x0A32
5760 +#define  CONTROL_PADCONF_ETK_D4              0x0A34
5761 +#define  CONTROL_PADCONF_ETK_D5              0x0A36
5762 +#define  CONTROL_PADCONF_ETK_D6              0x0A38
5763 +#define  CONTROL_PADCONF_ETK_D7              0x0A3A
5764 +#define  CONTROL_PADCONF_ETK_D8              0x0A3C
5765 +#define  CONTROL_PADCONF_ETK_D9              0x0A3E
5766 +#define  CONTROL_PADCONF_ETK_D10             0x0A40
5767 +#define  CONTROL_PADCONF_ETK_D11             0x0A42
5768 +#define  CONTROL_PADCONF_ETK_D12             0x0A44
5769 +#define  CONTROL_PADCONF_ETK_D13             0x0A46
5770 +#define  CONTROL_PADCONF_ETK_D14             0x0A48
5771 +#define  CONTROL_PADCONF_ETK_D15             0x0A4A
5772 +#define  CONTROL_PADCONF_ETK_CLK_ES2         0x05D8
5773 +#define  CONTROL_PADCONF_ETK_CTL_ES2         0x05DA
5774 +#define  CONTROL_PADCONF_ETK_D0_ES2          0x05DC
5775 +#define  CONTROL_PADCONF_ETK_D1_ES2          0x05DE
5776 +#define  CONTROL_PADCONF_ETK_D2_ES2          0x05E0
5777 +#define  CONTROL_PADCONF_ETK_D3_ES2          0x05E2
5778 +#define  CONTROL_PADCONF_ETK_D4_ES2          0x05E4
5779 +#define  CONTROL_PADCONF_ETK_D5_ES2          0x05E6
5780 +#define  CONTROL_PADCONF_ETK_D6_ES2          0x05E8
5781 +#define  CONTROL_PADCONF_ETK_D7_ES2          0x05EA
5782 +#define  CONTROL_PADCONF_ETK_D8_ES2          0x05EC
5783 +#define  CONTROL_PADCONF_ETK_D9_ES2          0x05EE
5784 +#define  CONTROL_PADCONF_ETK_D10_ES2         0x05F0
5785 +#define  CONTROL_PADCONF_ETK_D11_ES2         0x05F2
5786 +#define  CONTROL_PADCONF_ETK_D12_ES2         0x05F4
5787 +#define  CONTROL_PADCONF_ETK_D13_ES2         0x05F6
5788 +#define  CONTROL_PADCONF_ETK_D14_ES2         0x05F8
5789 +#define  CONTROL_PADCONF_ETK_D15_ES2         0x05FA
5790 +/*Die to Die */
5791 +#define  CONTROL_PADCONF_d2d_mcad0           0x01E4
5792 +#define  CONTROL_PADCONF_d2d_mcad1           0x01E6
5793 +#define  CONTROL_PADCONF_d2d_mcad2           0x01E8
5794 +#define  CONTROL_PADCONF_d2d_mcad3           0x01EA
5795 +#define  CONTROL_PADCONF_d2d_mcad4           0x01EC
5796 +#define  CONTROL_PADCONF_d2d_mcad5           0x01EE
5797 +#define  CONTROL_PADCONF_d2d_mcad6           0x01F0
5798 +#define  CONTROL_PADCONF_d2d_mcad7           0x01F2
5799 +#define  CONTROL_PADCONF_d2d_mcad8           0x01F4
5800 +#define  CONTROL_PADCONF_d2d_mcad9           0x01F6
5801 +#define  CONTROL_PADCONF_d2d_mcad10          0x01F8
5802 +#define  CONTROL_PADCONF_d2d_mcad11          0x01FA
5803 +#define  CONTROL_PADCONF_d2d_mcad12          0x01FC
5804 +#define  CONTROL_PADCONF_d2d_mcad13          0x01FE
5805 +#define  CONTROL_PADCONF_d2d_mcad14          0x0200
5806 +#define  CONTROL_PADCONF_d2d_mcad15          0x0202
5807 +#define  CONTROL_PADCONF_d2d_mcad16          0x0204
5808 +#define  CONTROL_PADCONF_d2d_mcad17          0x0206
5809 +#define  CONTROL_PADCONF_d2d_mcad18          0x0208
5810 +#define  CONTROL_PADCONF_d2d_mcad19          0x020A
5811 +#define  CONTROL_PADCONF_d2d_mcad20          0x020C
5812 +#define  CONTROL_PADCONF_d2d_mcad21          0x020E
5813 +#define  CONTROL_PADCONF_d2d_mcad22          0x0210
5814 +#define  CONTROL_PADCONF_d2d_mcad23          0x0212
5815 +#define  CONTROL_PADCONF_d2d_mcad24          0x0214
5816 +#define  CONTROL_PADCONF_d2d_mcad25          0x0216
5817 +#define  CONTROL_PADCONF_d2d_mcad26          0x0218
5818 +#define  CONTROL_PADCONF_d2d_mcad27          0x021A
5819 +#define  CONTROL_PADCONF_d2d_mcad28          0x021C
5820 +#define  CONTROL_PADCONF_d2d_mcad29          0x021E
5821 +#define  CONTROL_PADCONF_d2d_mcad30          0x0220
5822 +#define  CONTROL_PADCONF_d2d_mcad31          0x0222
5823 +#define  CONTROL_PADCONF_d2d_mcad32          0x0224
5824 +#define  CONTROL_PADCONF_d2d_mcad33          0x0226
5825 +#define  CONTROL_PADCONF_d2d_mcad34          0x0228
5826 +#define  CONTROL_PADCONF_d2d_mcad35          0x022A
5827 +#define  CONTROL_PADCONF_d2d_mcad36          0x022C
5828 +#define  CONTROL_PADCONF_d2d_clk26mi         0x022E
5829 +#define  CONTROL_PADCONF_d2d_nrespwron       0x0230
5830 +#define  CONTROL_PADCONF_d2d_nreswarm        0x0232
5831 +#define  CONTROL_PADCONF_d2d_arm9nirq        0x0234
5832 +#define  CONTROL_PADCONF_d2d_uma2p6fiq       0x0236
5833 +#define  CONTROL_PADCONF_d2d_spint           0x0238
5834 +#define  CONTROL_PADCONF_d2d_frint           0x023A
5835 +#define  CONTROL_PADCONF_d2d_dmareq0         0x023C
5836 +#define  CONTROL_PADCONF_d2d_dmareq1         0x023E
5837 +#define  CONTROL_PADCONF_d2d_dmareq2         0x0240
5838 +#define  CONTROL_PADCONF_d2d_dmareq3         0x0242
5839 +#define  CONTROL_PADCONF_d2d_n3gtrst         0x0244
5840 +#define  CONTROL_PADCONF_d2d_n3gtdi          0x0246
5841 +#define  CONTROL_PADCONF_d2d_n3gtdo          0x0248
5842 +#define  CONTROL_PADCONF_d2d_n3gtms          0x024A
5843 +#define  CONTROL_PADCONF_d2d_n3gtck          0x024C
5844 +#define  CONTROL_PADCONF_d2d_n3grtck         0x024E
5845 +#define  CONTROL_PADCONF_d2d_mstdby          0x0250
5846 +#define  CONTROL_PADCONF_d2d_swakeup         0x0A4C
5847 +#define  CONTROL_PADCONF_d2d_idlereq         0x0252
5848 +#define  CONTROL_PADCONF_d2d_idleack         0x0254
5849 +#define  CONTROL_PADCONF_d2d_mwrite          0x0256
5850 +#define  CONTROL_PADCONF_d2d_swrite          0x0258
5851 +#define  CONTROL_PADCONF_d2d_mread           0x025A
5852 +#define  CONTROL_PADCONF_d2d_sread           0x025C
5853 +#define  CONTROL_PADCONF_d2d_mbusflag        0x025E
5854 +#define  CONTROL_PADCONF_d2d_sbusflag        0x0260
5855 +#define  CONTROL_PADCONF_sdrc_cke0          0x0262
5856 +#define  CONTROL_PADCONF_sdrc_cke1          0x0264
5857 +
5858 +#define        MUX_VAL(OFFSET,VALUE)\
5859 +               __raw_writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
5860 +
5861 +#define                CP(x)   (CONTROL_PADCONF_##x)
5862 +
5863 +/*
5864 + * IEN  - Input Enable
5865 + * IDIS - Input Disable
5866 + * PTD  - Pull type Down
5867 + * PTU  - Pull type Up
5868 + * DIS  - Pull type selection is inactive
5869 + * EN   - Pull type selection is active
5870 + * M0   - Mode 0
5871 + * The commented string gives the final mux configuration for that pin
5872 + */
5873 +#define MUX_DEFAULT_ES2() \
5874 +       /*SDRC*/\
5875 +       MUX_VAL(CP(SDRC_D0),        (IEN  | PTD | DIS | M0)) /*SDRC_D0*/\
5876 +       MUX_VAL(CP(SDRC_D1),        (IEN  | PTD | DIS | M0)) /*SDRC_D1*/\
5877 +       MUX_VAL(CP(SDRC_D2),        (IEN  | PTD | DIS | M0)) /*SDRC_D2*/\
5878 +       MUX_VAL(CP(SDRC_D3),        (IEN  | PTD | DIS | M0)) /*SDRC_D3*/\
5879 +       MUX_VAL(CP(SDRC_D4),        (IEN  | PTD | DIS | M0)) /*SDRC_D4*/\
5880 +       MUX_VAL(CP(SDRC_D5),        (IEN  | PTD | DIS | M0)) /*SDRC_D5*/\
5881 +       MUX_VAL(CP(SDRC_D6),        (IEN  | PTD | DIS | M0)) /*SDRC_D6*/\
5882 +       MUX_VAL(CP(SDRC_D7),        (IEN  | PTD | DIS | M0)) /*SDRC_D7*/\
5883 +       MUX_VAL(CP(SDRC_D8),        (IEN  | PTD | DIS | M0)) /*SDRC_D8*/\
5884 +       MUX_VAL(CP(SDRC_D9),        (IEN  | PTD | DIS | M0)) /*SDRC_D9*/\
5885 +       MUX_VAL(CP(SDRC_D10),       (IEN  | PTD | DIS | M0)) /*SDRC_D10*/\
5886 +       MUX_VAL(CP(SDRC_D11),       (IEN  | PTD | DIS | M0)) /*SDRC_D11*/\
5887 +       MUX_VAL(CP(SDRC_D12),       (IEN  | PTD | DIS | M0)) /*SDRC_D12*/\
5888 +       MUX_VAL(CP(SDRC_D13),       (IEN  | PTD | DIS | M0)) /*SDRC_D13*/\
5889 +       MUX_VAL(CP(SDRC_D14),       (IEN  | PTD | DIS | M0)) /*SDRC_D14*/\
5890 +       MUX_VAL(CP(SDRC_D15),       (IEN  | PTD | DIS | M0)) /*SDRC_D15*/\
5891 +       MUX_VAL(CP(SDRC_D16),       (IEN  | PTD | DIS | M0)) /*SDRC_D16*/\
5892 +       MUX_VAL(CP(SDRC_D17),       (IEN  | PTD | DIS | M0)) /*SDRC_D17*/\
5893 +       MUX_VAL(CP(SDRC_D18),       (IEN  | PTD | DIS | M0)) /*SDRC_D18*/\
5894 +       MUX_VAL(CP(SDRC_D19),       (IEN  | PTD | DIS | M0)) /*SDRC_D19*/\
5895 +       MUX_VAL(CP(SDRC_D20),       (IEN  | PTD | DIS | M0)) /*SDRC_D20*/\
5896 +       MUX_VAL(CP(SDRC_D21),       (IEN  | PTD | DIS | M0)) /*SDRC_D21*/\
5897 +       MUX_VAL(CP(SDRC_D22),       (IEN  | PTD | DIS | M0)) /*SDRC_D22*/\
5898 +       MUX_VAL(CP(SDRC_D23),       (IEN  | PTD | DIS | M0)) /*SDRC_D23*/\
5899 +       MUX_VAL(CP(SDRC_D24),       (IEN  | PTD | DIS | M0)) /*SDRC_D24*/\
5900 +       MUX_VAL(CP(SDRC_D25),       (IEN  | PTD | DIS | M0)) /*SDRC_D25*/\
5901 +       MUX_VAL(CP(SDRC_D26),       (IEN  | PTD | DIS | M0)) /*SDRC_D26*/\
5902 +       MUX_VAL(CP(SDRC_D27),       (IEN  | PTD | DIS | M0)) /*SDRC_D27*/\
5903 +       MUX_VAL(CP(SDRC_D28),       (IEN  | PTD | DIS | M0)) /*SDRC_D28*/\
5904 +       MUX_VAL(CP(SDRC_D29),       (IEN  | PTD | DIS | M0)) /*SDRC_D29*/\
5905 +       MUX_VAL(CP(SDRC_D30),       (IEN  | PTD | DIS | M0)) /*SDRC_D30*/\
5906 +       MUX_VAL(CP(SDRC_D31),       (IEN  | PTD | DIS | M0)) /*SDRC_D31*/\
5907 +       MUX_VAL(CP(SDRC_CLK),       (IEN  | PTD | DIS | M0)) /*SDRC_CLK*/\
5908 +       MUX_VAL(CP(SDRC_DQS0),      (IEN  | PTD | DIS | M0)) /*SDRC_DQS0*/\
5909 +       MUX_VAL(CP(SDRC_DQS1),      (IEN  | PTD | DIS | M0)) /*SDRC_DQS1*/\
5910 +       MUX_VAL(CP(SDRC_DQS2),      (IEN  | PTD | DIS | M0)) /*SDRC_DQS2*/\
5911 +       MUX_VAL(CP(SDRC_DQS3),      (IEN  | PTD | DIS | M0)) /*SDRC_DQS3*/\
5912 +       /*GPMC*/\
5913 +       MUX_VAL(CP(GPMC_A1),        (IDIS | PTD | DIS | M0)) /*GPMC_A1*/\
5914 +       MUX_VAL(CP(GPMC_A2),        (IDIS | PTD | DIS | M0)) /*GPMC_A2*/\
5915 +       MUX_VAL(CP(GPMC_A3),        (IDIS | PTD | DIS | M0)) /*GPMC_A3*/\
5916 +       MUX_VAL(CP(GPMC_A4),        (IDIS | PTD | DIS | M0)) /*GPMC_A4*/\
5917 +       MUX_VAL(CP(GPMC_A5),        (IDIS | PTD | DIS | M0)) /*GPMC_A5*/\
5918 +       MUX_VAL(CP(GPMC_A6),        (IDIS | PTD | DIS | M0)) /*GPMC_A6*/\
5919 +       MUX_VAL(CP(GPMC_A7),        (IDIS | PTD | DIS | M0)) /*GPMC_A7*/\
5920 +       MUX_VAL(CP(GPMC_A8),        (IDIS | PTD | DIS | M0)) /*GPMC_A8*/\
5921 +       MUX_VAL(CP(GPMC_A9),        (IDIS | PTD | DIS | M0)) /*GPMC_A9*/\
5922 +       MUX_VAL(CP(GPMC_A10),       (IDIS | PTD | DIS | M0)) /*GPMC_A10*/\
5923 +       MUX_VAL(CP(GPMC_D0),        (IEN  | PTD | DIS | M0)) /*GPMC_D0*/\
5924 +       MUX_VAL(CP(GPMC_D1),        (IEN  | PTD | DIS | M0)) /*GPMC_D1*/\
5925 +       MUX_VAL(CP(GPMC_D2),        (IEN  | PTD | DIS | M0)) /*GPMC_D2*/\
5926 +       MUX_VAL(CP(GPMC_D3),        (IEN  | PTD | DIS | M0)) /*GPMC_D3*/\
5927 +       MUX_VAL(CP(GPMC_D4),        (IEN  | PTD | DIS | M0)) /*GPMC_D4*/\
5928 +       MUX_VAL(CP(GPMC_D5),        (IEN  | PTD | DIS | M0)) /*GPMC_D5*/\
5929 +       MUX_VAL(CP(GPMC_D6),        (IEN  | PTD | DIS | M0)) /*GPMC_D6*/\
5930 +       MUX_VAL(CP(GPMC_D7),        (IEN  | PTD | DIS | M0)) /*GPMC_D7*/\
5931 +       MUX_VAL(CP(GPMC_D8),        (IEN  | PTD | DIS | M0)) /*GPMC_D8*/\
5932 +       MUX_VAL(CP(GPMC_D9),        (IEN  | PTD | DIS | M0)) /*GPMC_D9*/\
5933 +       MUX_VAL(CP(GPMC_D10),       (IEN  | PTD | DIS | M0)) /*GPMC_D10*/\
5934 +       MUX_VAL(CP(GPMC_D11),       (IEN  | PTD | DIS | M0)) /*GPMC_D11*/\
5935 +       MUX_VAL(CP(GPMC_D12),       (IEN  | PTD | DIS | M0)) /*GPMC_D12*/\
5936 +       MUX_VAL(CP(GPMC_D13),       (IEN  | PTD | DIS | M0)) /*GPMC_D13*/\
5937 +       MUX_VAL(CP(GPMC_D14),       (IEN  | PTD | DIS | M0)) /*GPMC_D14*/\
5938 +       MUX_VAL(CP(GPMC_D15),       (IEN  | PTD | DIS | M0)) /*GPMC_D15*/\
5939 +       MUX_VAL(CP(GPMC_nCS0),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS0*/\
5940 +       MUX_VAL(CP(GPMC_nCS1),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS1*/\
5941 +       MUX_VAL(CP(GPMC_nCS2),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS2*/\
5942 +       MUX_VAL(CP(GPMC_nCS3),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS3*/\
5943 +       /* For Beagle Rev 2 boards*/\
5944 +       MUX_VAL(CP(GPMC_nCS4),      (IDIS | PTU | EN  | M0))\
5945 +       MUX_VAL(CP(GPMC_nCS5),      (IDIS | PTD | DIS | M0))\
5946 +       MUX_VAL(CP(GPMC_nCS6),      (IEN  | PTD | DIS | M1))\
5947 +       MUX_VAL(CP(GPMC_nCS7),      (IEN  | PTU | EN  | M1))\
5948 +       MUX_VAL(CP(GPMC_nBE1),      (IEN  | PTD | DIS | M0))\
5949 +       MUX_VAL(CP(GPMC_WAIT2),     (IEN  | PTU | EN  | M0))\
5950 +       MUX_VAL(CP(GPMC_WAIT3),     (IEN  | PTU | EN  | M0))\
5951 +       /* till here */                                                 \
5952 +       MUX_VAL(CP(GPMC_CLK),       (IDIS | PTD | DIS | M0)) /*GPMC_CLK*/\
5953 +       MUX_VAL(CP(GPMC_nADV_ALE),  (IDIS | PTD | DIS | M0)) /*GPMC_nADV_ALE*/\
5954 +       MUX_VAL(CP(GPMC_nOE),       (IDIS | PTD | DIS | M0)) /*GPMC_nOE*/\
5955 +       MUX_VAL(CP(GPMC_nWE),       (IDIS | PTD | DIS | M0)) /*GPMC_nWE*/\
5956 +       MUX_VAL(CP(GPMC_nBE0_CLE),  (IDIS | PTD | DIS | M0)) /*GPMC_nBE0_CLE*/\
5957 +       MUX_VAL(CP(GPMC_nWP),       (IEN  | PTD | DIS | M0)) /*GPMC_nWP*/\
5958 +       MUX_VAL(CP(GPMC_WAIT0),     (IEN  | PTU | EN  | M0)) /*GPMC_WAIT0*/\
5959 +       MUX_VAL(CP(GPMC_WAIT1),     (IEN  | PTU | EN  | M0)) /*GPMC_WAIT1*/\
5960 +       /*DSS*/\
5961 +       MUX_VAL(CP(DSS_PCLK),       (IDIS | PTD | DIS | M0)) /*DSS_PCLK*/\
5962 +       MUX_VAL(CP(DSS_HSYNC),      (IDIS | PTD | DIS | M0)) /*DSS_HSYNC*/\
5963 +       MUX_VAL(CP(DSS_VSYNC),      (IDIS | PTD | DIS | M0)) /*DSS_VSYNC*/\
5964 +       MUX_VAL(CP(DSS_ACBIAS),     (IDIS | PTD | DIS | M0)) /*DSS_ACBIAS*/\
5965 +       MUX_VAL(CP(DSS_DATA0),      (IDIS | PTD | DIS | M0)) /*DSS_DATA0*/\
5966 +       MUX_VAL(CP(DSS_DATA1),      (IDIS | PTD | DIS | M0)) /*DSS_DATA1*/\
5967 +       MUX_VAL(CP(DSS_DATA2),      (IDIS | PTD | DIS | M0)) /*DSS_DATA2*/\
5968 +       MUX_VAL(CP(DSS_DATA3),      (IDIS | PTD | DIS | M0)) /*DSS_DATA3*/\
5969 +       MUX_VAL(CP(DSS_DATA4),      (IDIS | PTD | DIS | M0)) /*DSS_DATA4*/\
5970 +       MUX_VAL(CP(DSS_DATA5),      (IDIS | PTD | DIS | M0)) /*DSS_DATA5*/\
5971 +       MUX_VAL(CP(DSS_DATA6),      (IDIS | PTD | DIS | M0)) /*DSS_DATA6*/\
5972 +       MUX_VAL(CP(DSS_DATA7),      (IDIS | PTD | DIS | M0)) /*DSS_DATA7*/\
5973 +       MUX_VAL(CP(DSS_DATA8),      (IDIS | PTD | DIS | M0)) /*DSS_DATA8*/\
5974 +       MUX_VAL(CP(DSS_DATA9),      (IDIS | PTD | DIS | M0)) /*DSS_DATA9*/\
5975 +       MUX_VAL(CP(DSS_DATA10),     (IDIS | PTD | DIS | M0)) /*DSS_DATA10*/\
5976 +       MUX_VAL(CP(DSS_DATA11),     (IDIS | PTD | DIS | M0)) /*DSS_DATA11*/\
5977 +       MUX_VAL(CP(DSS_DATA12),     (IDIS | PTD | DIS | M0)) /*DSS_DATA12*/\
5978 +       MUX_VAL(CP(DSS_DATA13),     (IDIS | PTD | DIS | M0)) /*DSS_DATA13*/\
5979 +       MUX_VAL(CP(DSS_DATA14),     (IDIS | PTD | DIS | M0)) /*DSS_DATA14*/\
5980 +       MUX_VAL(CP(DSS_DATA15),     (IDIS | PTD | DIS | M0)) /*DSS_DATA15*/\
5981 +       MUX_VAL(CP(DSS_DATA16),     (IDIS | PTD | DIS | M0)) /*DSS_DATA16*/\
5982 +       MUX_VAL(CP(DSS_DATA17),     (IDIS | PTD | DIS | M0)) /*DSS_DATA17*/\
5983 +       MUX_VAL(CP(DSS_DATA18),     (IDIS | PTD | DIS | M0)) /*DSS_DATA18*/\
5984 +       MUX_VAL(CP(DSS_DATA19),     (IDIS | PTD | DIS | M0)) /*DSS_DATA19*/\
5985 +       MUX_VAL(CP(DSS_DATA20),     (IDIS | PTD | DIS | M0)) /*DSS_DATA20*/\
5986 +       MUX_VAL(CP(DSS_DATA21),     (IDIS | PTD | DIS | M0)) /*DSS_DATA21*/\
5987 +       MUX_VAL(CP(DSS_DATA22),     (IDIS | PTD | DIS | M0)) /*DSS_DATA22*/\
5988 +       MUX_VAL(CP(DSS_DATA23),     (IDIS | PTD | DIS | M0)) /*DSS_DATA23*/\
5989 +       /*CAMERA*/\
5990 +       MUX_VAL(CP(CAM_HS),         (IEN  | PTU | EN  | M0)) /*CAM_HS */\
5991 +       MUX_VAL(CP(CAM_VS),         (IEN  | PTU | EN  | M0)) /*CAM_VS */\
5992 +       MUX_VAL(CP(CAM_XCLKA),      (IDIS | PTD | DIS | M0)) /*CAM_XCLKA*/\
5993 +       MUX_VAL(CP(CAM_PCLK),       (IEN  | PTU | EN  | M0)) /*CAM_PCLK*/\
5994 +       MUX_VAL(CP(CAM_FLD),        (IDIS | PTD | DIS | M4)) /*GPIO_98*/\
5995 +                                                            /* - CAM_RESET*/\
5996 +       MUX_VAL(CP(CAM_D0),         (IEN  | PTD | DIS | M0)) /*CAM_D0*/\
5997 +       MUX_VAL(CP(CAM_D1),         (IEN  | PTD | DIS | M0)) /*CAM_D1*/\
5998 +       MUX_VAL(CP(CAM_D2),         (IEN  | PTD | DIS | M0)) /*CAM_D2*/\
5999 +       MUX_VAL(CP(CAM_D3),         (IEN  | PTD | DIS | M0)) /*CAM_D3*/\
6000 +       MUX_VAL(CP(CAM_D4),         (IEN  | PTD | DIS | M0)) /*CAM_D4*/\
6001 +       MUX_VAL(CP(CAM_D5),         (IEN  | PTD | DIS | M0)) /*CAM_D5*/\
6002 +       MUX_VAL(CP(CAM_D6),         (IEN  | PTD | DIS | M0)) /*CAM_D6*/\
6003 +       MUX_VAL(CP(CAM_D7),         (IEN  | PTD | DIS | M0)) /*CAM_D7*/\
6004 +       MUX_VAL(CP(CAM_D8),         (IEN  | PTD | DIS | M0)) /*CAM_D8*/\
6005 +       MUX_VAL(CP(CAM_D9),         (IEN  | PTD | DIS | M0)) /*CAM_D9*/\
6006 +       MUX_VAL(CP(CAM_D10),        (IEN  | PTD | DIS | M0)) /*CAM_D10*/\
6007 +       MUX_VAL(CP(CAM_D11),        (IEN  | PTD | DIS | M0)) /*CAM_D11*/\
6008 +       MUX_VAL(CP(CAM_XCLKB),      (IDIS | PTD | DIS | M0)) /*CAM_XCLKB*/\
6009 +       MUX_VAL(CP(CAM_WEN),        (IEN  | PTD | DIS | M4)) /*GPIO_167*/\
6010 +       MUX_VAL(CP(CAM_STROBE),     (IDIS | PTD | DIS | M0)) /*CAM_STROBE*/\
6011 +       MUX_VAL(CP(CSI2_DX0),       (IEN  | PTD | DIS | M0)) /*CSI2_DX0*/\
6012 +       MUX_VAL(CP(CSI2_DY0),       (IEN  | PTD | DIS | M0)) /*CSI2_DY0*/\
6013 +       MUX_VAL(CP(CSI2_DX1),       (IEN  | PTD | DIS | M0)) /*CSI2_DX1*/\
6014 +       MUX_VAL(CP(CSI2_DY1),       (IEN  | PTD | DIS | M0)) /*CSI2_DY1*/\
6015 +       /*Audio Interface */\
6016 +       MUX_VAL(CP(McBSP2_FSX),     (IEN  | PTD | DIS | M0)) /*McBSP2_FSX*/\
6017 +       MUX_VAL(CP(McBSP2_CLKX),    (IEN  | PTD | DIS | M0)) /*McBSP2_CLKX*/\
6018 +       MUX_VAL(CP(McBSP2_DR),      (IEN  | PTD | DIS | M0)) /*McBSP2_DR*/\
6019 +       MUX_VAL(CP(McBSP2_DX),      (IDIS | PTD | DIS | M0)) /*McBSP2_DX*/\
6020 +       /*Expansion card  */\
6021 +       MUX_VAL(CP(MMC1_CLK),       (IDIS | PTU | EN  | M0)) /*MMC1_CLK*/\
6022 +       MUX_VAL(CP(MMC1_CMD),       (IEN  | PTU | EN  | M0)) /*MMC1_CMD*/\
6023 +       MUX_VAL(CP(MMC1_DAT0),      (IEN  | PTU | EN  | M0)) /*MMC1_DAT0*/\
6024 +       MUX_VAL(CP(MMC1_DAT1),      (IEN  | PTU | EN  | M0)) /*MMC1_DAT1*/\
6025 +       MUX_VAL(CP(MMC1_DAT2),      (IEN  | PTU | EN  | M0)) /*MMC1_DAT2*/\
6026 +       MUX_VAL(CP(MMC1_DAT3),      (IEN  | PTU | EN  | M0)) /*MMC1_DAT3*/\
6027 +       MUX_VAL(CP(MMC1_DAT4),      (IEN  | PTU | EN  | M0)) /*MMC1_DAT4*/\
6028 +       MUX_VAL(CP(MMC1_DAT5),      (IEN  | PTU | EN  | M0)) /*MMC1_DAT5*/\
6029 +       MUX_VAL(CP(MMC1_DAT6),      (IEN  | PTU | EN  | M0)) /*MMC1_DAT6*/\
6030 +       MUX_VAL(CP(MMC1_DAT7),      (IEN  | PTU | EN  | M0)) /*MMC1_DAT7*/\
6031 +       /*Wireless LAN */\
6032 +       MUX_VAL(CP(MMC2_CLK),       (IEN  | PTU | EN  | M4)) /*GPIO_130*/\
6033 +       MUX_VAL(CP(MMC2_CMD),       (IEN  | PTU | EN  | M4)) /*GPIO_131*/\
6034 +       MUX_VAL(CP(MMC2_DAT0),      (IEN  | PTU | EN  | M4)) /*GPIO_132*/\
6035 +       MUX_VAL(CP(MMC2_DAT1),      (IEN  | PTU | EN  | M4)) /*GPIO_133*/\
6036 +       MUX_VAL(CP(MMC2_DAT2),      (IEN  | PTU | EN  | M4)) /*GPIO_134*/\
6037 +       MUX_VAL(CP(MMC2_DAT3),      (IEN  | PTU | EN  | M4)) /*GPIO_135*/\
6038 +       MUX_VAL(CP(MMC2_DAT4),      (IEN  | PTU | EN  | M4)) /*GPIO_136*/\
6039 +       MUX_VAL(CP(MMC2_DAT5),      (IEN  | PTU | EN  | M4)) /*GPIO_137*/\
6040 +       MUX_VAL(CP(MMC2_DAT6),      (IEN  | PTU | EN  | M4)) /*GPIO_138*/\
6041 +       MUX_VAL(CP(MMC2_DAT7),      (IEN  | PTU | EN  | M4)) /*GPIO_139*/\
6042 +       /*Bluetooth*/\
6043 +       MUX_VAL(CP(McBSP3_DX),      (IDIS | PTD | DIS | M4)) /*GPIO_140*/\
6044 +       MUX_VAL(CP(McBSP3_DR),      (IDIS | PTD | DIS | M4)) /*GPIO_142*/\
6045 +       MUX_VAL(CP(McBSP3_CLKX),    (IDIS | PTD | DIS | M4)) /*GPIO_141*/\
6046 +       MUX_VAL(CP(McBSP3_FSX),     (IDIS | PTD | DIS | M4)) /*GPIO_143*/\
6047 +       MUX_VAL(CP(UART2_CTS),      (IEN  | PTU | EN  | M0)) /*UART2_CTS*/\
6048 +       MUX_VAL(CP(UART2_RTS),      (IDIS | PTD | DIS | M0)) /*UART2_RTS*/\
6049 +       MUX_VAL(CP(UART2_TX),       (IDIS | PTD | DIS | M0)) /*UART2_TX*/\
6050 +       MUX_VAL(CP(UART2_RX),       (IEN  | PTD | DIS | M0)) /*UART2_RX*/\
6051 +       /*Modem Interface */\
6052 +       MUX_VAL(CP(UART1_TX),       (IDIS | PTD | DIS | M0)) /*UART1_TX*/\
6053 +       MUX_VAL(CP(UART1_RTS),      (IDIS | PTD | DIS | M4)) /*GPIO_149*/ \
6054 +       MUX_VAL(CP(UART1_CTS),      (IDIS | PTD | DIS | M4)) /*GPIO_150*/ \
6055 +       MUX_VAL(CP(UART1_RX),       (IEN  | PTD | DIS | M0)) /*UART1_RX*/\
6056 +       MUX_VAL(CP(McBSP4_CLKX),    (IEN  | PTD | DIS | M1)) /*SSI1_DAT_RX*/\
6057 +       MUX_VAL(CP(McBSP4_DR),      (IEN  | PTD | DIS | M1)) /*SSI1_FLAG_RX*/\
6058 +       MUX_VAL(CP(McBSP4_DX),      (IEN  | PTD | DIS | M1)) /*SSI1_RDY_RX*/\
6059 +       MUX_VAL(CP(McBSP4_FSX),     (IEN  | PTD | DIS | M1)) /*SSI1_WAKE*/\
6060 +       MUX_VAL(CP(McBSP1_CLKR),    (IDIS | PTD | DIS | M4)) /*GPIO_156*/\
6061 +       MUX_VAL(CP(McBSP1_FSR),     (IDIS | PTU | EN  | M4)) /*GPIO_157*/\
6062 +                                                            /* - BT_WAKEUP*/\
6063 +       MUX_VAL(CP(McBSP1_DX),      (IDIS | PTD | DIS | M4)) /*GPIO_158*/\
6064 +       MUX_VAL(CP(McBSP1_DR),      (IDIS | PTD | DIS | M4)) /*GPIO_159*/\
6065 +       MUX_VAL(CP(McBSP_CLKS),     (IEN  | PTU | DIS | M0)) /*McBSP_CLKS*/\
6066 +       MUX_VAL(CP(McBSP1_FSX),     (IDIS | PTD | DIS | M4)) /*GPIO_161*/\
6067 +       MUX_VAL(CP(McBSP1_CLKX),    (IDIS | PTD | DIS | M4)) /*GPIO_162*/\
6068 +       /*Serial Interface*/\
6069 +       MUX_VAL(CP(UART3_CTS_RCTX), (IEN  | PTD | EN  | M0)) /*UART3_CTS_*/\
6070 +                                                            /* RCTX*/\
6071 +       MUX_VAL(CP(UART3_RTS_SD),   (IDIS | PTD | DIS | M0)) /*UART3_RTS_SD */\
6072 +       MUX_VAL(CP(UART3_RX_IRRX),  (IEN  | PTD | DIS | M0)) /*UART3_RX_IRRX*/\
6073 +       MUX_VAL(CP(UART3_TX_IRTX),  (IDIS | PTD | DIS | M0)) /*UART3_TX_IRTX*/\
6074 +       MUX_VAL(CP(HSUSB0_CLK),     (IEN  | PTD | DIS | M0)) /*HSUSB0_CLK*/\
6075 +       MUX_VAL(CP(HSUSB0_STP),     (IDIS | PTU | EN  | M0)) /*HSUSB0_STP*/\
6076 +       MUX_VAL(CP(HSUSB0_DIR),     (IEN  | PTD | DIS | M0)) /*HSUSB0_DIR*/\
6077 +       MUX_VAL(CP(HSUSB0_NXT),     (IEN  | PTD | DIS | M0)) /*HSUSB0_NXT*/\
6078 +       MUX_VAL(CP(HSUSB0_DATA0),   (IEN  | PTD | DIS | M0)) /*HSUSB0_DATA0*/\
6079 +       MUX_VAL(CP(HSUSB0_DATA1),   (IEN  | PTD | DIS | M0)) /*HSUSB0_DATA1*/\
6080 +       MUX_VAL(CP(HSUSB0_DATA2),   (IEN  | PTD | DIS | M0)) /*HSUSB0_DATA2*/\
6081 +       MUX_VAL(CP(HSUSB0_DATA3),   (IEN  | PTD | DIS | M0)) /*HSUSB0_DATA3*/\
6082 +       MUX_VAL(CP(HSUSB0_DATA4),   (IEN  | PTD | DIS | M0)) /*HSUSB0_DATA4*/\
6083 +       MUX_VAL(CP(HSUSB0_DATA5),   (IEN  | PTD | DIS | M0)) /*HSUSB0_DATA5*/\
6084 +       MUX_VAL(CP(HSUSB0_DATA6),   (IEN  | PTD | DIS | M0)) /*HSUSB0_DATA6*/\
6085 +       MUX_VAL(CP(HSUSB0_DATA7),   (IEN  | PTD | DIS | M0)) /*HSUSB0_DATA7*/\
6086 +       MUX_VAL(CP(I2C1_SCL),       (IEN  | PTU | EN  | M0)) /*I2C1_SCL*/\
6087 +       MUX_VAL(CP(I2C1_SDA),       (IEN  | PTU | EN  | M0)) /*I2C1_SDA*/\
6088 +       MUX_VAL(CP(I2C2_SCL),       (IEN  | PTU | EN  | M0)) /*I2C2_SCL*/\
6089 +       MUX_VAL(CP(I2C2_SDA),       (IEN  | PTU | EN  | M0)) /*I2C2_SDA*/\
6090 +       MUX_VAL(CP(I2C3_SCL),       (IEN  | PTU | EN  | M0)) /*I2C3_SCL*/\
6091 +       MUX_VAL(CP(I2C3_SDA),       (IEN  | PTU | EN  | M0)) /*I2C3_SDA*/\
6092 +       MUX_VAL(CP(I2C4_SCL),       (IEN  | PTU | EN  | M0)) /*I2C4_SCL*/\
6093 +       MUX_VAL(CP(I2C4_SDA),       (IEN  | PTU | EN  | M0)) /*I2C4_SDA*/\
6094 +       MUX_VAL(CP(HDQ_SIO),        (IDIS | PTU | EN  | M4)) /*HDQ_SIO*/\
6095 +       MUX_VAL(CP(McSPI1_CLK),     (IEN  | PTD | DIS | M0)) /*McSPI1_CLK*/\
6096 +       MUX_VAL(CP(McSPI1_SIMO),    (IEN  | PTD | DIS | M0)) /*McSPI1_SIMO  */\
6097 +       MUX_VAL(CP(McSPI1_SOMI),    (IEN  | PTD | DIS | M0)) /*McSPI1_SOMI  */\
6098 +       MUX_VAL(CP(McSPI1_CS0),     (IEN  | PTD | EN  | M0)) /*McSPI1_CS0*/\
6099 +       MUX_VAL(CP(McSPI1_CS1),     (IDIS | PTD | EN  | M0)) /*McSPI1_CS1*/\
6100 +       MUX_VAL(CP(McSPI1_CS2),     (IDIS | PTD | DIS | M4)) /*GPIO_176*/\
6101 +                                                            /* - NOR_DPD*/\
6102 +       MUX_VAL(CP(McSPI1_CS3),     (IEN  | PTD | EN  | M0)) /*McSPI1_CS3*/\
6103 +       MUX_VAL(CP(McSPI2_CLK),     (IEN  | PTD | DIS | M0)) /*McSPI2_CLK*/\
6104 +       MUX_VAL(CP(McSPI2_SIMO),    (IEN  | PTD | DIS | M0)) /*McSPI2_SIMO*/\
6105 +       MUX_VAL(CP(McSPI2_SOMI),    (IEN  | PTD | DIS | M0)) /*McSPI2_SOMI*/\
6106 +       MUX_VAL(CP(McSPI2_CS0),     (IEN  | PTD | EN  | M0)) /*McSPI2_CS0*/\
6107 +       MUX_VAL(CP(McSPI2_CS1),     (IEN  | PTD | EN  | M0)) /*McSPI2_CS1*/\
6108 +       /*Control and debug */\
6109 +       MUX_VAL(CP(SYS_32K),        (IEN  | PTD | DIS | M0)) /*SYS_32K*/\
6110 +       MUX_VAL(CP(SYS_CLKREQ),     (IEN  | PTD | DIS | M0)) /*SYS_CLKREQ*/\
6111 +       MUX_VAL(CP(SYS_nIRQ),       (IEN  | PTU | EN  | M0)) /*SYS_nIRQ*/\
6112 +       MUX_VAL(CP(SYS_BOOT0),      (IEN  | PTD | DIS | M4)) /*GPIO_2*/\
6113 +                                                            /* - PEN_IRQ */\
6114 +       MUX_VAL(CP(SYS_BOOT1),      (IEN  | PTD | DIS | M4)) /*GPIO_3 */\
6115 +       MUX_VAL(CP(SYS_BOOT2),      (IEN  | PTD | DIS | M4)) /*GPIO_4*/\
6116 +                                                            /* - MMC1_WP */\
6117 +       MUX_VAL(CP(SYS_BOOT3),      (IEN  | PTD | DIS | M4)) /*GPIO_5*/\
6118 +                                                            /* - LCD_ENVDD*/\
6119 +       MUX_VAL(CP(SYS_BOOT4),      (IEN  | PTD | DIS | M4)) /*GPIO_6*/\
6120 +                                                            /* - LAN_INTR0*/\
6121 +       MUX_VAL(CP(SYS_BOOT5),      (IEN  | PTD | DIS | M4)) /*GPIO_7*/\
6122 +                                                            /* - MMC2_WP*/\
6123 +       MUX_VAL(CP(SYS_BOOT6),      (IDIS  | PTD | DIS | M4)) /*GPIO_8*/\
6124 +                                                            /* - LCD_ENBKL*/\
6125 +       MUX_VAL(CP(SYS_OFF_MODE),   (IEN  | PTD | DIS | M0)) /*SYS_OFF_MODE*/\
6126 +       MUX_VAL(CP(SYS_CLKOUT1),    (IEN  | PTD | DIS | M0)) /*SYS_CLKOUT1*/\
6127 +       MUX_VAL(CP(SYS_CLKOUT2),    (IEN  | PTU | EN  | M4)) /*GPIO_186*/\
6128 +       MUX_VAL(CP(ETK_CLK_ES2),    (IDIS | PTU | EN  | M3)) /*HSUSB1_STP*/\
6129 +       MUX_VAL(CP(ETK_CTL_ES2),    (IDIS | PTD | DIS | M3)) /*HSUSB1_CLK*/\
6130 +       MUX_VAL(CP(ETK_D0_ES2),     (IEN  | PTD | DIS | M3)) /*HSUSB1_DATA0*/\
6131 +       MUX_VAL(CP(ETK_D1_ES2),     (IEN  | PTD | DIS | M3)) /*HSUSB1_DATA1*/\
6132 +       MUX_VAL(CP(ETK_D2_ES2),     (IEN  | PTD | DIS | M3)) /*HSUSB1_DATA2*/\
6133 +       MUX_VAL(CP(ETK_D3_ES2),     (IEN  | PTD | DIS | M3)) /*HSUSB1_DATA7*/\
6134 +       MUX_VAL(CP(ETK_D4_ES2),     (IEN  | PTD | DIS | M3)) /*HSUSB1_DATA4*/\
6135 +       MUX_VAL(CP(ETK_D5_ES2),     (IEN  | PTD | DIS | M3)) /*HSUSB1_DATA5*/\
6136 +       MUX_VAL(CP(ETK_D6_ES2),     (IEN  | PTD | DIS | M3)) /*HSUSB1_DATA6*/\
6137 +       MUX_VAL(CP(ETK_D7_ES2),     (IEN  | PTD | DIS | M3)) /*HSUSB1_DATA3*/\
6138 +       MUX_VAL(CP(ETK_D8_ES2),     (IEN  | PTD | DIS | M3)) /*HSUSB1_DIR*/\
6139 +       MUX_VAL(CP(ETK_D9_ES2),     (IEN  | PTD | DIS | M3)) /*HSUSB1_NXT*/\
6140 +       MUX_VAL(CP(ETK_D10_ES2),    (IDIS | PTU | EN  | M4)) /*GPIO_24*/\
6141 +       MUX_VAL(CP(ETK_D15),        (IEN  | PTU | EN  | M4)) /*GPIO_29*/\
6142 +       MUX_VAL(CP(d2d_mcad1),      (IEN  | PTD | EN  | M0)) /*d2d_mcad1*/\
6143 +       MUX_VAL(CP(d2d_mcad2),      (IEN  | PTD | EN  | M0)) /*d2d_mcad2*/\
6144 +       MUX_VAL(CP(d2d_mcad3),      (IEN  | PTD | EN  | M0)) /*d2d_mcad3*/\
6145 +       MUX_VAL(CP(d2d_mcad4),      (IEN  | PTD | EN  | M0)) /*d2d_mcad4*/\
6146 +       MUX_VAL(CP(d2d_mcad5),      (IEN  | PTD | EN  | M0)) /*d2d_mcad5*/\
6147 +       MUX_VAL(CP(d2d_mcad6),      (IEN  | PTD | EN  | M0)) /*d2d_mcad6*/\
6148 +       MUX_VAL(CP(d2d_mcad7),      (IEN  | PTD | EN  | M0)) /*d2d_mcad7*/\
6149 +       MUX_VAL(CP(d2d_mcad8),      (IEN  | PTD | EN  | M0)) /*d2d_mcad8*/\
6150 +       MUX_VAL(CP(d2d_mcad9),      (IEN  | PTD | EN  | M0)) /*d2d_mcad9*/\
6151 +       MUX_VAL(CP(d2d_mcad10),     (IEN  | PTD | EN  | M0)) /*d2d_mcad10*/\
6152 +       MUX_VAL(CP(d2d_mcad11),     (IEN  | PTD | EN  | M0)) /*d2d_mcad11*/\
6153 +       MUX_VAL(CP(d2d_mcad12),     (IEN  | PTD | EN  | M0)) /*d2d_mcad12*/\
6154 +       MUX_VAL(CP(d2d_mcad13),     (IEN  | PTD | EN  | M0)) /*d2d_mcad13*/\
6155 +       MUX_VAL(CP(d2d_mcad14),     (IEN  | PTD | EN  | M0)) /*d2d_mcad14*/\
6156 +       MUX_VAL(CP(d2d_mcad15),     (IEN  | PTD | EN  | M0)) /*d2d_mcad15*/\
6157 +       MUX_VAL(CP(d2d_mcad16),     (IEN  | PTD | EN  | M0)) /*d2d_mcad16*/\
6158 +       MUX_VAL(CP(d2d_mcad17),     (IEN  | PTD | EN  | M0)) /*d2d_mcad17*/\
6159 +       MUX_VAL(CP(d2d_mcad18),     (IEN  | PTD | EN  | M0)) /*d2d_mcad18*/\
6160 +       MUX_VAL(CP(d2d_mcad19),     (IEN  | PTD | EN  | M0)) /*d2d_mcad19*/\
6161 +       MUX_VAL(CP(d2d_mcad20),     (IEN  | PTD | EN  | M0)) /*d2d_mcad20*/\
6162 +       MUX_VAL(CP(d2d_mcad21),     (IEN  | PTD | EN  | M0)) /*d2d_mcad21*/\
6163 +       MUX_VAL(CP(d2d_mcad22),     (IEN  | PTD | EN  | M0)) /*d2d_mcad22*/\
6164 +       MUX_VAL(CP(d2d_mcad23),     (IEN  | PTD | EN  | M0)) /*d2d_mcad23*/\
6165 +       MUX_VAL(CP(d2d_mcad24),     (IEN  | PTD | EN  | M0)) /*d2d_mcad24*/\
6166 +       MUX_VAL(CP(d2d_mcad25),     (IEN  | PTD | EN  | M0)) /*d2d_mcad25*/\
6167 +       MUX_VAL(CP(d2d_mcad26),     (IEN  | PTD | EN  | M0)) /*d2d_mcad26*/\
6168 +       MUX_VAL(CP(d2d_mcad27),     (IEN  | PTD | EN  | M0)) /*d2d_mcad27*/\
6169 +       MUX_VAL(CP(d2d_mcad28),     (IEN  | PTD | EN  | M0)) /*d2d_mcad28*/\
6170 +       MUX_VAL(CP(d2d_mcad29),     (IEN  | PTD | EN  | M0)) /*d2d_mcad29*/\
6171 +       MUX_VAL(CP(d2d_mcad30),     (IEN  | PTD | EN  | M0)) /*d2d_mcad30*/\
6172 +       MUX_VAL(CP(d2d_mcad31),     (IEN  | PTD | EN  | M0)) /*d2d_mcad31*/\
6173 +       MUX_VAL(CP(d2d_mcad32),     (IEN  | PTD | EN  | M0)) /*d2d_mcad32*/\
6174 +       MUX_VAL(CP(d2d_mcad33),     (IEN  | PTD | EN  | M0)) /*d2d_mcad33*/\
6175 +       MUX_VAL(CP(d2d_mcad34),     (IEN  | PTD | EN  | M0)) /*d2d_mcad34*/\
6176 +       MUX_VAL(CP(d2d_mcad35),     (IEN  | PTD | EN  | M0)) /*d2d_mcad35*/\
6177 +       MUX_VAL(CP(d2d_mcad36),     (IEN  | PTD | EN  | M0)) /*d2d_mcad36*/\
6178 +       MUX_VAL(CP(d2d_clk26mi),    (IEN  | PTD | DIS | M0)) /*d2d_clk26mi*/\
6179 +       MUX_VAL(CP(d2d_nrespwron),  (IEN  | PTD | EN  | M0)) /*d2d_nrespwron*/\
6180 +       MUX_VAL(CP(d2d_nreswarm),   (IEN  | PTU | EN  | M0)) /*d2d_nreswarm */\
6181 +       MUX_VAL(CP(d2d_arm9nirq),   (IEN  | PTD | DIS | M0)) /*d2d_arm9nirq */\
6182 +       MUX_VAL(CP(d2d_uma2p6fiq),  (IEN  | PTD | DIS | M0)) /*d2d_uma2p6fiq*/\
6183 +       MUX_VAL(CP(d2d_spint),      (IEN  | PTD | EN  | M0)) /*d2d_spint*/\
6184 +       MUX_VAL(CP(d2d_frint),      (IEN  | PTD | EN  | M0)) /*d2d_frint*/\
6185 +       MUX_VAL(CP(d2d_dmareq0),    (IEN  | PTD | DIS | M0)) /*d2d_dmareq0*/\
6186 +       MUX_VAL(CP(d2d_dmareq1),    (IEN  | PTD | DIS | M0)) /*d2d_dmareq1*/\
6187 +       MUX_VAL(CP(d2d_dmareq2),    (IEN  | PTD | DIS | M0)) /*d2d_dmareq2*/\
6188 +       MUX_VAL(CP(d2d_dmareq3),    (IEN  | PTD | DIS | M0)) /*d2d_dmareq3*/\
6189 +       MUX_VAL(CP(d2d_n3gtrst),    (IEN  | PTD | DIS | M0)) /*d2d_n3gtrst*/\
6190 +       MUX_VAL(CP(d2d_n3gtdi),     (IEN  | PTD | DIS | M0)) /*d2d_n3gtdi*/\
6191 +       MUX_VAL(CP(d2d_n3gtdo),     (IEN  | PTD | DIS | M0)) /*d2d_n3gtdo*/\
6192 +       MUX_VAL(CP(d2d_n3gtms),     (IEN  | PTD | DIS | M0)) /*d2d_n3gtms*/\
6193 +       MUX_VAL(CP(d2d_n3gtck),     (IEN  | PTD | DIS | M0)) /*d2d_n3gtck*/\
6194 +       MUX_VAL(CP(d2d_n3grtck),    (IEN  | PTD | DIS | M0)) /*d2d_n3grtck*/\
6195 +       MUX_VAL(CP(d2d_mstdby),     (IEN  | PTU | EN  | M0)) /*d2d_mstdby*/\
6196 +       MUX_VAL(CP(d2d_swakeup),    (IEN  | PTD | EN  | M0)) /*d2d_swakeup*/\
6197 +       MUX_VAL(CP(d2d_idlereq),    (IEN  | PTD | DIS | M0)) /*d2d_idlereq*/\
6198 +       MUX_VAL(CP(d2d_idleack),    (IEN  | PTU | EN  | M0)) /*d2d_idleack*/\
6199 +       MUX_VAL(CP(d2d_mwrite),     (IEN  | PTD | DIS | M0)) /*d2d_mwrite*/\
6200 +       MUX_VAL(CP(d2d_swrite),     (IEN  | PTD | DIS | M0)) /*d2d_swrite*/\
6201 +       MUX_VAL(CP(d2d_mread),      (IEN  | PTD | DIS | M0)) /*d2d_mread*/\
6202 +       MUX_VAL(CP(d2d_sread),      (IEN  | PTD | DIS | M0)) /*d2d_sread*/\
6203 +       MUX_VAL(CP(d2d_mbusflag),   (IEN  | PTD | DIS | M0)) /*d2d_mbusflag*/\
6204 +       MUX_VAL(CP(d2d_sbusflag),   (IEN  | PTD | DIS | M0)) /*d2d_sbusflag*/\
6205 +       MUX_VAL(CP(sdrc_cke0),      (IDIS | PTU | EN  | M0)) /*sdrc_cke0*/\
6206 +       MUX_VAL(CP(sdrc_cke1),      (IDIS | PTD | DIS | M7)) /*sdrc_cke1*/\
6207 +                                                            /* - not used */
6208 +#endif
6209 diff --git a/include/asm-arm/arch-omap3/omap3.h b/include/asm-arm/arch-omap3/omap3.h
6210 new file mode 100644
6211 index 0000000..095bb29
6212 --- /dev/null
6213 +++ b/include/asm-arm/arch-omap3/omap3.h
6214 @@ -0,0 +1,131 @@
6215 +/*
6216 + * (C) Copyright 2006-2008
6217 + * Texas Instruments, <www.ti.com>
6218 + * Richard Woodruff <r-woodruff2@ti.com>
6219 + * Syed Mohammed Khasim <x0khasim@ti.com>
6220 + *
6221 + * See file CREDITS for list of people who contributed to this
6222 + * project.
6223 + *
6224 + * This program is free software; you can redistribute it and/or
6225 + * modify it under the terms of the GNU General Public License as
6226 + * published by the Free Software Foundation; either version 2 of
6227 + * the License, or (at your option) any later version.
6228 + *
6229 + * This program is distributed in the hope that it will be useful,
6230 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6231 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6232 + * GNU General Public License for more details.
6233 + *
6234 + * You should have received a copy of the GNU General Public License
6235 + * along with this program; if not, write to the Free Software
6236 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
6237 + * MA 02111-1307 USA
6238 + */
6239 +
6240 +#ifndef _OMAP3_H_
6241 +#define _OMAP3_H_
6242 +
6243 +/* Stuff on L3 Interconnect */
6244 +#define SMX_APE_BASE                   0x68000000
6245 +
6246 +/* GPMC */
6247 +#define OMAP34XX_GPMC_BASE             (0x6E000000)
6248 +
6249 +/* SMS */
6250 +#define OMAP34XX_SMS_BASE              0x6C000000
6251 +
6252 +/* SDRC */
6253 +#define OMAP34XX_SDRC_BASE             0x6D000000
6254 +
6255 +/*
6256 + * L4 Peripherals - L4 Wakeup and L4 Core now
6257 + */
6258 +#define OMAP34XX_CORE_L4_IO_BASE       0x48000000
6259 +#define OMAP34XX_WAKEUP_L4_IO_BASE     0x48300000
6260 +#define OMAP34XX_L4_PER                        0x49000000
6261 +#define OMAP34XX_L4_IO_BASE            OMAP34XX_CORE_L4_IO_BASE
6262 +
6263 +/* CONTROL */
6264 +#define OMAP34XX_CTRL_BASE             (OMAP34XX_L4_IO_BASE+0x2000)
6265 +
6266 +/* UART */
6267 +#define OMAP34XX_UART1                 (OMAP34XX_L4_IO_BASE+0x6a000)
6268 +#define OMAP34XX_UART2                 (OMAP34XX_L4_IO_BASE+0x6c000)
6269 +#define OMAP34XX_UART3                 (OMAP34XX_L4_PER+0x20000)
6270 +
6271 +/* General Purpose Timers */
6272 +#define OMAP34XX_GPT1                  0x48318000
6273 +#define OMAP34XX_GPT2                  0x49032000
6274 +#define OMAP34XX_GPT3                  0x49034000
6275 +#define OMAP34XX_GPT4                  0x49036000
6276 +#define OMAP34XX_GPT5                  0x49038000
6277 +#define OMAP34XX_GPT6                  0x4903A000
6278 +#define OMAP34XX_GPT7                  0x4903C000
6279 +#define OMAP34XX_GPT8                  0x4903E000
6280 +#define OMAP34XX_GPT9                  0x49040000
6281 +#define OMAP34XX_GPT10                 0x48086000
6282 +#define OMAP34XX_GPT11                 0x48088000
6283 +#define OMAP34XX_GPT12                 0x48304000
6284 +
6285 +/* WatchDog Timers (1 secure, 3 GP) */
6286 +#define WD1_BASE                       (0x4830C000)
6287 +#define WD2_BASE                       (0x48314000)
6288 +#define WD3_BASE                       (0x49030000)
6289 +
6290 +/* 32KTIMER */
6291 +#define SYNC_32KTIMER_BASE             (0x48320000)
6292 +#define S32K_CR                                (SYNC_32KTIMER_BASE+0x10)
6293 +
6294 +/* omap3 GPIO registers */
6295 +#define OMAP34XX_GPIO1_BASE            0x48310000
6296 +#define OMAP34XX_GPIO2_BASE            0x49050000
6297 +#define OMAP34XX_GPIO3_BASE            0x49052000
6298 +#define OMAP34XX_GPIO4_BASE            0x49054000
6299 +#define OMAP34XX_GPIO5_BASE            0x49056000
6300 +#define OMAP34XX_GPIO6_BASE            0x49058000
6301 +
6302 +/* base address for indirect vectors (internal boot mode) */
6303 +#define SRAM_OFFSET0                   0x40000000
6304 +#define SRAM_OFFSET1                   0x00200000
6305 +#define SRAM_OFFSET2                   0x0000F800
6306 +#define SRAM_VECT_CODE                 (SRAM_OFFSET0|SRAM_OFFSET1|\
6307 +                                        SRAM_OFFSET2)
6308 +
6309 +#define LOW_LEVEL_SRAM_STACK           0x4020FFFC
6310 +
6311 +#define DEBUG_LED1                     149     /* gpio */
6312 +#define DEBUG_LED2                     150     /* gpio */
6313 +
6314 +#define XDR_POP                5       /* package on package part */
6315 +#define SDR_DISCRETE   4       /* 128M memory SDR module */
6316 +#define DDR_STACKED    3       /* stacked part on 2422 */
6317 +#define DDR_COMBO      2       /* combo part on cpu daughter card */
6318 +#define DDR_DISCRETE   1       /* 2x16 parts on daughter card */
6319 +
6320 +#define DDR_100                100     /* type found on most mem d-boards */
6321 +#define DDR_111                111     /* some combo parts */
6322 +#define DDR_133                133     /* most combo, some mem d-boards */
6323 +#define DDR_165                165     /* future parts */
6324 +
6325 +#define CPU_3430       0x3430
6326 +
6327 +/* 343x real hardware:
6328 + *  ES1     = rev 0
6329 + */
6330 +
6331 +/* 343x code defines:
6332 + * ES1     = 0+1 = 1
6333 + * ES1     = 1+1 = 1
6334 + */
6335 +#define CPU_3430_ES1           1
6336 +#define CPU_3430_ES2           2
6337 +
6338 +#define WIDTH_8BIT             0x0000
6339 +#define WIDTH_16BIT            0x1000  /* bit pos for 16 bit in gpmc */
6340 +
6341 +/* SDP definitions according to FPGA Rev. Is this OK?? */
6342 +#define SDP_3430_V1            0x1
6343 +#define SDP_3430_V2            0x2
6344 +
6345 +#endif
6346 diff --git a/include/asm-arm/arch-omap3/sys_proto.h b/include/asm-arm/arch-omap3/sys_proto.h
6347 new file mode 100644
6348 index 0000000..271b554
6349 --- /dev/null
6350 +++ b/include/asm-arm/arch-omap3/sys_proto.h
6351 @@ -0,0 +1,64 @@
6352 +/*
6353 + * (C) Copyright 2004-2008
6354 + * Texas Instruments, <www.ti.com>
6355 + * Richard Woodruff <r-woodruff2@ti.com>
6356 + *
6357 + * This program is free software; you can redistribute it and/or
6358 + * modify it under the terms of the GNU General Public License as
6359 + * published by the Free Software Foundation; either version 2 of
6360 + * the License, or (at your option) any later version.
6361 + *
6362 + * This program is distributed in the hope that it will be useful,
6363 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6364 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE.  See the
6365 + * GNU General Public License for more details.
6366 + *
6367 + * You should have received a copy of the GNU General Public License
6368 + * along with this program; if not, write to the Free Software
6369 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
6370 + * MA 02111-1307 USA
6371 +  */
6372 +#ifndef _SYS_PROTO_H_
6373 +#define _SYS_PROTO_H_
6374 +
6375 +void prcm_init(void);
6376 +void per_clocks_enable(void);
6377 +
6378 +void memif_init(void);
6379 +void sdrc_init(void);
6380 +void do_sdrc_init(u32, u32);
6381 +void gpmc_init(void);
6382 +
6383 +void watchdog_init(void);
6384 +void set_muxconf_regs(void);
6385 +
6386 +u32 get_cpu_type(void);
6387 +u32 get_cpu_rev(void);
6388 +u32 get_mem_type(void);
6389 +u32 get_sysboot_value(void);
6390 +u32 get_gpmc0_base(void);
6391 +u32 is_gpmc_muxed(void);
6392 +u32 get_gpmc0_type(void);
6393 +u32 get_gpmc0_width(void);
6394 +u32 get_board_type(void);
6395 +void display_board_info(u32);
6396 +u32 get_sdr_cs_size(u32 offset);
6397 +u32 running_in_sdram(void);
6398 +u32 running_in_sram(void);
6399 +u32 running_in_flash(void);
6400 +u32 running_from_internal_boot(void);
6401 +u32 get_device_type(void);
6402 +void l2cache_enable(void);
6403 +void secureworld_exit(void);
6404 +void setup_auxcr(void);
6405 +void try_unlock_memory(void);
6406 +u32 get_boot_type(void);
6407 +void audio_init(void);
6408 +void dss_init(void);
6409 +void arm_cache_flush(void);
6410 +void v7_flush_dcache_all(u32);
6411 +void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value);
6412 +u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound);
6413 +void sdelay(unsigned long loops);
6414 +
6415 +#endif
6416 diff --git a/include/configs/omap3530beagle.h b/include/configs/omap3530beagle.h
6417 new file mode 100644
6418 index 0000000..20efbf3
6419 --- /dev/null
6420 +++ b/include/configs/omap3530beagle.h
6421 @@ -0,0 +1,292 @@
6422 +/*
6423 + * (C) Copyright 2006-2008
6424 + * Texas Instruments.
6425 + * Richard Woodruff <r-woodruff2@ti.com>
6426 + * Syed Mohammed Khasim <x0khasim@ti.com>
6427 + *
6428 + * Configuration settings for the TI OMAP3530 Beagle board.
6429 + *
6430 + * See file CREDITS for list of people who contributed to this
6431 + * project.
6432 + *
6433 + * This program is free software; you can redistribute it and/or
6434 + * modify it under the terms of the GNU General Public License as
6435 + * published by the Free Software Foundation; either version 2 of
6436 + * the License, or (at your option) any later version.
6437 + *
6438 + * This program is distributed in the hope that it will be useful,
6439 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6440 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
6441 + * GNU General Public License for more details.
6442 + *
6443 + * You should have received a copy of the GNU General Public License
6444 + * along with this program; if not, write to the Free Software
6445 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
6446 + * MA 02111-1307 USA
6447 + */
6448 +
6449 +#ifndef __CONFIG_H
6450 +#define __CONFIG_H
6451 +#include <asm/sizes.h>
6452 +
6453 +/*
6454 + * High Level Configuration Options
6455 + */
6456 +#define CONFIG_ARMCORTEXA8     1       /* This is an ARM V7 CPU core */
6457 +#define CONFIG_OMAP            1       /* in a TI OMAP core */
6458 +#define CONFIG_OMAP34XX                1       /* which is a 34XX */
6459 +#define CONFIG_OMAP3430                1       /* which is in a 3430 */
6460 +#define CONFIG_OMAP3_BEAGLE    1       /* working with BEAGLE */
6461 +#define CONFIG_DOS_PARTITION   1
6462 +
6463 +#include <asm/arch/cpu.h>      /* get chip and board defs */
6464 +#include <asm/arch/omap3.h>
6465 +
6466 +/* Clock Defines */
6467 +#define V_OSCK                   26000000      /* Clock output from T2 */
6468 +#define V_SCLK                   (V_OSCK >> 1)
6469 +
6470 +#undef CONFIG_USE_IRQ          /* no support for IRQs */
6471 +#define CONFIG_MISC_INIT_R
6472 +
6473 +#define CONFIG_CMDLINE_TAG       1     /* enable passing of ATAGs */
6474 +#define CONFIG_SETUP_MEMORY_TAGS 1
6475 +#define CONFIG_INITRD_TAG        1
6476 +#define CONFIG_REVISION_TAG      1
6477 +
6478 +/*
6479 + * Size of malloc() pool
6480 + */
6481 +#define CFG_ENV_SIZE             SZ_128K /* Total Size Environment Sector */
6482 +#define CFG_MALLOC_LEN           (CFG_ENV_SIZE + SZ_128K)
6483 +#define CFG_GBL_DATA_SIZE        128    /* bytes reserved for initial data */
6484 +
6485 +/*
6486 + * Hardware drivers
6487 + */
6488 +
6489 +/*
6490 + * NS16550 Configuration
6491 + */
6492 +#define V_NS16550_CLK            (48000000)    /* 48MHz (APLL96/2) */
6493 +
6494 +#define CFG_NS16550
6495 +#define CFG_NS16550_SERIAL
6496 +#define CFG_NS16550_REG_SIZE     (-4)
6497 +#define CFG_NS16550_CLK          V_NS16550_CLK
6498 +
6499 +/*
6500 + * select serial console configuration
6501 + */
6502 +#define CONFIG_CONS_INDEX        3
6503 +#define CFG_NS16550_COM3         OMAP34XX_UART3
6504 +#define CONFIG_SERIAL3           3     /* UART3 on Beagle Rev 2 */
6505 +
6506 +/* allow to overwrite serial and ethaddr */
6507 +#define CONFIG_ENV_OVERWRITE
6508 +#define CONFIG_BAUDRATE          115200
6509 +#define CFG_BAUDRATE_TABLE       {4800, 9600, 19200, 38400, 57600, 115200}
6510 +#define CONFIG_MMC             1
6511 +#define CFG_MMC_BASE           0xF0000000
6512 +#define CONFIG_DOS_PARTITION   1
6513 +
6514 +/* commands to include */
6515 +
6516 +#define CONFIG_CMD_EXT2                /* EXT2 Support                 */
6517 +#define CONFIG_CMD_FAT         /* FAT support                  */
6518 +#define CONFIG_CMD_JFFS2       /* JFFS2 Support                */
6519 +
6520 +#define CONFIG_CMD_I2C         /* I2C serial bus support       */
6521 +#define CONFIG_CMD_MMC         /* MMC support                  */
6522 +#define CONFIG_CMD_NAND                /* NAND support                 */
6523 +
6524 +#define CONFIG_CMD_AUTOSCRIPT  /* autoscript support           */
6525 +#define CONFIG_CMD_BDI         /* bdinfo                       */
6526 +#define CONFIG_CMD_BOOTD       /* bootd                        */
6527 +#define CONFIG_CMD_CONSOLE     /* coninfo                      */
6528 +#define CONFIG_CMD_ECHO                /* echo arguments               */
6529 +#define CONFIG_CMD_ENV         /* saveenv                      */
6530 +#define CONFIG_CMD_ITEST       /* Integer (and string) test    */
6531 +#define CONFIG_CMD_LOADB       /* loadb                        */
6532 +#define CONFIG_CMD_MEMORY      /* md mm nm mw cp cmp crc base loop mtest */
6533 +#define CONFIG_CMD_MISC                /* misc functions like sleep etc*/
6534 +#define CONFIG_CMD_RUN         /* run command in env variable  */
6535 +
6536 +#define CFG_NO_FLASH
6537 +#define CFG_I2C_SPEED            100
6538 +#define CFG_I2C_SLAVE            1
6539 +#define CFG_I2C_BUS              0
6540 +#define CFG_I2C_BUS_SELECT       1
6541 +#define CONFIG_DRIVER_OMAP34XX_I2C 1
6542 +
6543 +/*
6544 + *  Board NAND Info.
6545 + */
6546 +#define CFG_NAND_ADDR NAND_BASE        /* physical address to access nand */
6547 +#define CFG_NAND_BASE NAND_BASE        /* physical address to access nand at CS0 */
6548 +#define CFG_NAND_WIDTH_16
6549 +
6550 +#define CFG_MAX_NAND_DEVICE      1     /* Max number of NAND devices */
6551 +#define SECTORSIZE               512
6552 +
6553 +#define NAND_ALLOW_ERASE_ALL
6554 +#define ADDR_COLUMN              1
6555 +#define ADDR_PAGE                2
6556 +#define ADDR_COLUMN_PAGE         3
6557 +
6558 +#define NAND_ChipID_UNKNOWN      0x00
6559 +#define NAND_MAX_FLOORS          1
6560 +#define NAND_MAX_CHIPS           1
6561 +#define NAND_NO_RB               1
6562 +#define CFG_NAND_WP
6563 +
6564 +#define CONFIG_JFFS2_NAND
6565 +/* nand device jffs2 lives on */
6566 +#define CONFIG_JFFS2_DEV               "nand0"
6567 +/* start of jffs2 partition */
6568 +#define CONFIG_JFFS2_PART_OFFSET       0x680000
6569 +#define CONFIG_JFFS2_PART_SIZE         0xf980000       /* size of jffs2 partition */
6570 +
6571 +/* Environment information */
6572 +#define CONFIG_BOOTDELAY         10
6573 +
6574 +#define CONFIG_BOOTCOMMAND "nand read 80200000 280000 400000 ; bootm 80200000"
6575 +
6576 +#define CONFIG_BOOTARGS "setenv bootargs console=ttyS2,115200n8 noinitrd root=/dev/mtdblock4 rw rootfstype=jffs2"
6577 +
6578 +#define CONFIG_NETMASK           255.255.254.0
6579 +#define CONFIG_IPADDR            128.247.77.90
6580 +#define CONFIG_SERVERIP          128.247.77.158
6581 +#define CONFIG_BOOTFILE          "uImage"
6582 +#define CONFIG_AUTO_COMPLETE     1
6583 +/*
6584 + * Miscellaneous configurable options
6585 + */
6586 +#define V_PROMPT                 "OMAP3 beagleboard.org # "
6587 +
6588 +#define CFG_LONGHELP           /* undef to save memory */
6589 +#define CFG_PROMPT               V_PROMPT
6590 +#define CFG_CBSIZE               256   /* Console I/O Buffer Size */
6591 +/* Print Buffer Size */
6592 +#define CFG_PBSIZE               (CFG_CBSIZE+sizeof(CFG_PROMPT)+16)
6593 +#define CFG_MAXARGS              16    /* max number of command args */
6594 +#define CFG_BARGSIZE             CFG_CBSIZE    /* Boot Argument Buffer Size */
6595 +
6596 +#define CFG_MEMTEST_START        (OMAP34XX_SDRC_CS0)   /* memtest works on */
6597 +#define CFG_MEMTEST_END          (OMAP34XX_SDRC_CS0+0x01F00000) /* 31MB */
6598 +
6599 +#undef CFG_CLKS_IN_HZ          /* everything, incl board info, in Hz */
6600 +
6601 +#define CFG_LOAD_ADDR            (OMAP34XX_SDRC_CS0) /* default load address */
6602 +
6603 +/* 2430 has 12 GP timers, they can be driven by the SysClk (12/13/19.2) or by
6604 + * 32KHz clk, or from external sig. This rate is divided by a local divisor.
6605 + */
6606 +#define V_PVT                    7
6607 +
6608 +#define CFG_TIMERBASE            OMAP34XX_GPT2
6609 +#define CFG_PVT                  V_PVT /* 2^(pvt+1) */
6610 +#define CFG_HZ                   ((V_SCLK)/(2 << CFG_PVT))
6611 +
6612 +/*-----------------------------------------------------------------------
6613 + * Stack sizes
6614 + *
6615 + * The stack sizes are set up in start.S using the settings below
6616 + */
6617 +#define CONFIG_STACKSIZE       SZ_128K /* regular stack */
6618 +#ifdef CONFIG_USE_IRQ
6619 +#define CONFIG_STACKSIZE_IRQ   SZ_4K   /* IRQ stack */
6620 +#define CONFIG_STACKSIZE_FIQ   SZ_4K   /* FIQ stack */
6621 +#endif
6622 +
6623 +/*-----------------------------------------------------------------------
6624 + * Physical Memory Map
6625 + */
6626 +#define CONFIG_NR_DRAM_BANKS   2       /* CS1 may or may not be populated */
6627 +#define PHYS_SDRAM_1           OMAP34XX_SDRC_CS0
6628 +#define PHYS_SDRAM_1_SIZE      SZ_32M  /* at least 32 meg */
6629 +#define PHYS_SDRAM_2           OMAP34XX_SDRC_CS1
6630 +
6631 +/* SDRAM Bank Allocation method */
6632 +#define SDRC_R_B_C             1
6633 +
6634 +/*-----------------------------------------------------------------------
6635 + * FLASH and environment organization
6636 + */
6637 +
6638 +/* **** PISMO SUPPORT *** */
6639 +
6640 +/* Configure the PISMO */
6641 +#define PISMO1_NOR_SIZE_SDPV2  GPMC_SIZE_128M
6642 +#define PISMO1_NOR_SIZE                GPMC_SIZE_64M
6643 +
6644 +#define PISMO1_NAND_SIZE       GPMC_SIZE_128M
6645 +#define PISMO1_ONEN_SIZE       GPMC_SIZE_128M
6646 +#define DBG_MPDB_SIZE          GPMC_SIZE_16M
6647 +#define PISMO2_SIZE            0
6648 +
6649 +#define CFG_MAX_FLASH_SECT     (520)   /* max number of sectors on one chip */
6650 +#define CFG_MAX_FLASH_BANKS      2     /* max number of flash banks */
6651 +#define CFG_MONITOR_LEN                SZ_256K /* Reserve 2 sectors */
6652 +
6653 +#define PHYS_FLASH_SIZE_SDPV2  SZ_128M
6654 +#define PHYS_FLASH_SIZE                SZ_32M
6655 +
6656 +#define CFG_FLASH_BASE         boot_flash_base
6657 +#define PHYS_FLASH_SECT_SIZE   boot_flash_sec
6658 +/* Dummy declaration of flash banks to get compilation right */
6659 +#define CFG_FLASH_BANKS_LIST   {0, 0}
6660 +
6661 +#define CFG_MONITOR_BASE       CFG_FLASH_BASE  /* Monitor at start of flash */
6662 +#define CFG_ONENAND_BASE       ONENAND_MAP
6663 +
6664 +#define CFG_ENV_IS_IN_NAND     1
6665 +#define ONENAND_ENV_OFFSET     0x260000        /* environment starts here  */
6666 +#define SMNAND_ENV_OFFSET      0x260000        /* environment starts here  */
6667 +
6668 +#define CFG_ENV_SECT_SIZE      boot_flash_sec
6669 +#define CFG_ENV_OFFSET         boot_flash_off
6670 +#define CFG_ENV_ADDR           SMNAND_ENV_OFFSET
6671 +
6672 +/*-----------------------------------------------------------------------
6673 + * CFI FLASH driver setup
6674 + */
6675 +/* timeout values are in ticks */
6676 +#define CFG_FLASH_ERASE_TOUT   (100*CFG_HZ)    /* Timeout for Flash Erase */
6677 +#define CFG_FLASH_WRITE_TOUT   (100*CFG_HZ)    /* Timeout for Flash Write */
6678 +
6679 +/* Flash banks JFFS2 should use */
6680 +#define CFG_MAX_MTD_BANKS      (CFG_MAX_FLASH_BANKS+CFG_MAX_NAND_DEVICE)
6681 +#define CFG_JFFS2_MEM_NAND
6682 +#define CFG_JFFS2_FIRST_BANK   CFG_MAX_FLASH_BANKS     /* use flash_info[2] */
6683 +#define CFG_JFFS2_NUM_BANKS    1
6684 +
6685 +#define ENV_IS_VARIABLE                1
6686 +
6687 +#ifndef __ASSEMBLY__
6688 +extern unsigned int nand_cs_base;
6689 +extern unsigned int boot_flash_base;
6690 +extern volatile unsigned int boot_flash_env_addr;
6691 +extern unsigned int boot_flash_off;
6692 +extern unsigned int boot_flash_sec;
6693 +extern unsigned int boot_flash_type;
6694 +#endif
6695 +
6696 +
6697 +#define WRITE_NAND_COMMAND(d, adr)\
6698 +                      __raw_writew(d, (nand_cs_base + GPMC_NAND_CMD))
6699 +#define WRITE_NAND_ADDRESS(d, adr)\
6700 +                      __raw_writew(d, (nand_cs_base + GPMC_NAND_ADR))
6701 +#define WRITE_NAND(d, adr) __raw_writew(d, (nand_cs_base + GPMC_NAND_DAT))
6702 +#define READ_NAND(adr) __raw_readw((nand_cs_base + GPMC_NAND_DAT))
6703 +
6704 +/* Other NAND Access APIs */
6705 +#define NAND_WP_OFF()\
6706 +               do {*(volatile u32 *)(GPMC_CONFIG) |= 0x00000010; } while (0)
6707 +#define NAND_WP_ON()\
6708 +               do {*(volatile u32 *)(GPMC_CONFIG) &= ~0x00000010; } while (0)
6709 +#define NAND_DISABLE_CE(nand)
6710 +#define NAND_ENABLE_CE(nand)
6711 +#define NAND_WAIT_READY(nand)  udelay(10)
6712 +
6713 +#endif                         /* __CONFIG_H */