1 //==========================================================================
5 // HAL misc board support code for the board
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license/
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //========================================================================*/
42 #include <pkgconf/hal.h>
43 #include <pkgconf/system.h>
45 #include CYGBLD_HAL_PLATFORM_H
47 #include <cyg/infra/cyg_type.h> // base types
48 #include <cyg/infra/cyg_trac.h> // tracing macros
49 #include <cyg/infra/cyg_ass.h> // assertion macros
51 #include <cyg/hal/hal_io.h> // IO macros
52 #include <cyg/hal/hal_arch.h> // Register state info
53 #include <cyg/hal/hal_diag.h>
54 #include <cyg/hal/hal_intr.h> // Interrupt names
55 #include <cyg/hal/hal_cache.h>
56 #include <cyg/hal/hal_soc.h> // Hardware definitions
57 #include <cyg/hal/fsl_board.h> // Platform specifics
58 #include <cyg/infra/diag.h> // diag_printf
60 // All the MM table layout is here:
61 #include <cyg/hal/hal_mm.h>
63 externC void* memset(void *, int, size_t);
64 unsigned int cpld_base_addr;
66 void hal_mmu_init(void)
68 unsigned long ttb_base = RAM_BANK0_BASE + 0x4000;
72 * Set the TTB register
74 asm volatile ("mcr p15,0,%0,c2,c0,0" : : "r"(ttb_base) /*:*/);
77 * Set the Domain Access Control Register
79 i = ARM_ACCESS_DACR_DEFAULT;
80 asm volatile ("mcr p15,0,%0,c3,c0,0" : : "r"(i) /*:*/);
83 * First clear all TT entries - ie Set them to Faulting
85 memset((void *)ttb_base, 0, ARM_FIRST_LEVEL_PAGE_TABLE_SIZE);
87 /* Actual Virtual Size Attributes Function */
88 /* Base Base MB cached? buffered? access permissions */
89 /* xxx00000 xxx00000 */
90 X_ARM_MMU_SECTION(0x000, 0x200, 0x1, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* ROM */
91 X_ARM_MMU_SECTION(0x1FF, 0x1FF, 0x001, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* IRAM */
92 X_ARM_MMU_SECTION(0x300, 0x300, 0x100, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* GPU */
93 X_ARM_MMU_SECTION(0x400, 0x400, 0x200, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* IPUv3D */
94 X_ARM_MMU_SECTION(0x600, 0x600, 0x300, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* periperals */
95 X_ARM_MMU_SECTION(0x900, 0x000, 0x1FF, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */
96 X_ARM_MMU_SECTION(0x900, 0x900, 0x200, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */
97 X_ARM_MMU_SECTION(0xB00, 0xB00, 0x10, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* CS0 EIM control*/
98 X_ARM_MMU_SECTION(0xCC0, 0xCC0, 0x040, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* CS4/5/NAND Flash buffer */
101 #include <cyg/io/imx_spi.h>
102 struct spi_v2_3_reg spi_pmic_reg;
104 struct imx_spi_dev imx_spi_pmic = {
105 base : CSPI1_BASE_ADDR,
107 ss_pol : IMX_SPI_ACTIVE_HIGH,
108 ss : 0, // slave select 0
113 struct spi_v2_3_reg spi_nor_reg;
115 struct imx_spi_dev imx_spi_nor = {
116 base : CSPI1_BASE_ADDR,
118 ss_pol : IMX_SPI_ACTIVE_LOW,
119 ss : 1, // slave select 1
125 imx_spi_init_func_t *spi_nor_init;
126 imx_spi_xfer_func_t *spi_nor_xfer;
128 imx_spi_init_func_t *spi_pmic_init;
129 imx_spi_xfer_func_t *spi_pmic_xfer;
132 // Platform specific initialization
135 void plf_hardware_init(void)
138 unsigned long weim_base;
141 weim_base = WEIM_BASE_ADDR;
142 writel(0x00410089, weim_base + CSGCR1);
143 writel(0x00000002, weim_base + CSGCR2);
144 // RWSC=50, RADVA=2, RADVN=6, OEA=0, OEN=0, RCSA=0, RCSN=0
145 writel(0x32260000, weim_base + CSRCR1);
147 writel(0x00000000, weim_base + CSRCR2);
148 // WAL=0, WBED=1, WWSC=50, WADVA=2, WADVN=6, WEA=0, WEN=0, WCSA=0, WCSN=0
149 writel(0x72080F00, weim_base + CSWCR1);
151 /* Disable IPU and HSC dividers */
152 writel(0x60000, CCM_BASE_ADDR + CLKCTL_CCDR);
153 /* Change the DDR divider to run at 166MHz on CPU 2 */
154 reg = readl(CCM_BASE_ADDR + CLKCTL_CBCDR);
155 reg = (reg & (~0x70000)) | 0x30000;
156 writel(reg, CCM_BASE_ADDR + CLKCTL_CBCDR);
157 /* make sure divider effective */
158 while (readl(CCM_BASE_ADDR + CLKCTL_CDHIPR) != 0);
159 writel(0x0, CCM_BASE_ADDR + CLKCTL_CCDR);
163 writel(0x0, IOMUXC_BASE_ADDR + 0x234);
164 writel(0x1C5, IOMUXC_BASE_ADDR + 0x6E4);
167 writel(0x0, IOMUXC_BASE_ADDR + 0x238);
168 writel(0x1C5, IOMUXC_BASE_ADDR + 0x6E8);
171 writel(0x0, IOMUXC_BASE_ADDR + 0x23C);
172 writel(0x1C4, IOMUXC_BASE_ADDR + 0x6EC);
175 writel(0x0, IOMUXC_BASE_ADDR + 0x240);
176 writel(0x1C4, IOMUXC_BASE_ADDR + 0x6F0);
178 // enable GPIO1_9 for CLKO and GPIO1_8 for CLKO2
179 writel(0x00000004, 0x73fa83F4);
180 writel(0x00000004, 0x73fa83F0);
181 // enable ARM clock div by 8
182 writel(0x010900F0, CCM_BASE_ADDR + CLKCTL_CCOSR);
184 // now turn on the LCD backlight
185 reg = readl(0x73f84004);
186 writel(reg | 0x4, 0x73f84004);
187 reg = readl(0x73f84000);
188 writel(reg | 0x4, 0x73f84000);
190 // now turn on the LCD
191 // Set NANDF_CS7 pin to be GPIO output and set it to 1
192 writel(0x3, 0x73fa8158);
193 reg = readl(0x73f8c004);
194 writel(reg | 0x800000, 0x73f8c004);
195 reg = readl(0x73f8c000);
196 writel(reg | 0x800000, 0x73f8c000);
198 spi_nor_init = (imx_spi_init_func_t *)imx_spi_init_v2_3;
199 spi_nor_xfer = (imx_spi_xfer_func_t *)imx_spi_xfer_v2_3;
201 spi_pmic_init = (imx_spi_init_func_t *)imx_spi_init_v2_3;
202 spi_pmic_xfer = (imx_spi_xfer_func_t *)imx_spi_xfer_v2_3;
205 static void rocky_lan_reset(void)
209 /* Issue a reset to the LAN chip */
210 reg = readl(GPIO2_BASE_ADDR + 0x0);
211 reg |= 0x20000000 ; // write a 1 on the reset line
212 writel(reg, GPIO2_BASE_ADDR + 0x0);
214 reg = readl(GPIO2_BASE_ADDR + 0x4);
215 reg |= 0x20000000; // configure GPIO lines as output
216 writel(reg, GPIO2_BASE_ADDR + 0x4);
220 reg = readl(GPIO2_BASE_ADDR + 0x0);
221 reg &= ~0x20000000; // write a 0 on the reset line
222 writel(reg, GPIO2_BASE_ADDR + 0x0);
226 reg = readl(GPIO2_BASE_ADDR + 0x0);
227 reg |= 0x20000000 ; // write a 1 on the reset line
228 writel(reg, GPIO2_BASE_ADDR + 0x0);
231 void mxc_ata_iomux_setup(void)
233 // config NANDF_WE_B pad for pata instance DIOW port
234 // config_pad_mode(NANDF_WE_B, ALT1);
235 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_WE_B);
236 // CONSTANT SETTINGS:
237 // test_ts to Disabled
238 // dse test to regular
239 // strength mode to NA (Different from Module Level value: 4_level)
240 // DDR / CMOS Input Mode to NA
241 // Pull / Keep Select to Pull (Different from Module Level value: NA)
242 // Pull Up / Down Config. to NA (CFG in SoC Level however NA in Module Level)
243 // Open Drain Enable to Disabled
245 // CONFIGURED SETTINGS:
246 // low/high output voltage to CFG(High)
247 // Hyst. Enable to Disabled
248 // Pull / Keep Enable to Disabled
249 // Drive Strength to CFG(High)
250 // config_pad_settings(NANDF_WE_B, 0x2004);
251 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_WE_B);
253 // config NANDF_RE_B pad for pata instance DIOR port
254 // config_pad_mode(NANDF_RE_B, ALT1);
255 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_RE_B);
256 // CONSTANT SETTINGS:
257 // test_ts to Disabled
258 // dse test to regular
259 // strength mode to NA (Different from Module Level value: 4_level)
260 // DDR / CMOS Input Mode to NA
261 // Pull / Keep Select to Pull (Different from Module Level value: NA)
262 // Pull Up / Down Config. to NA (CFG in SoC Level however NA in Module Level)
263 // Open Drain Enable to Disabled
265 // CONFIGURED SETTINGS:
266 // low/high output voltage to CFG(High)
267 // Hyst. Enable to Disabled
268 // Pull / Keep Enable to Disabled
269 // Drive Strength to CFG(High)
270 // config_pad_settings(NANDF_RE_B, 0x2004);
271 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_RE_B);
273 // config NANDF_CLE pad for pata instance PATA_RESET_B port
274 // config_pad_mode(NANDF_CLE, ALT1);
275 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_CLE);
276 // CONSTANT SETTINGS:
277 // test_ts to Disabled
278 // dse test to regular
279 // strength mode to NA (Different from Module Level value: 4_level)
280 // DDR / CMOS Input Mode to NA
281 // Hyst. Enable to Disabled
282 // Pull / Keep Select to Keep (Different from Module Level value: NA)
283 // Pull Up / Down Config. to 100Kohm PU (Different from Module Level value: NA)
284 // Open Drain Enable to Disabled
286 // CONFIGURED SETTINGS:
287 // low/high output voltage to CFG(High)
288 // Pull / Keep Enable to Disabled
289 // Drive Strength to CFG(High)
290 // config_pad_settings(NANDF_CLE, 0x2004);
291 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_CLE);
293 // config NANDF_WP_B pad for pata instance DMACK port
294 // config_pad_mode(NANDF_WP_B, ALT1);
295 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_WP_B);
296 // CONSTANT SETTINGS:
297 // test_ts to Disabled
298 // dse test to regular
299 // strength mode to NA (Different from Module Level value: 4_level)
300 // DDR / CMOS Input Mode to NA
301 // Pull / Keep Select to Pull (Different from Module Level value: NA)
302 // Pull Up / Down Config. to NA (CFG in SoC Level however NA in Module Level)
303 // Open Drain Enable to Disabled
305 // CONFIGURED SETTINGS:
306 // low/high output voltage to CFG(High)
307 // Hyst. Enable to Disabled
308 // Pull / Keep Enable to Disabled
309 // Drive Strength to CFG(High)
310 // config_pad_settings(NANDF_WP_B, 0x2004);
311 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_WP_B);
313 // config NANDF_RB0 pad for pata instance DMARQ port
314 // config_pad_mode(NANDF_RB0, 0x1);
315 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_RB0);
316 // CONSTANT SETTINGS:
317 // test_ts to Disabled
318 // dse test to regular
319 // strength mode to NA (Different from Module Level value: 4_level)
320 // DDR / CMOS Input Mode to NA
321 // Open Drain Enable to Disabled (Different from Module Level value: NA)
322 // Drive Strength to NA (CFG in SoC Level however NA in Module Level)
324 // CONFIGURED SETTINGS:
325 // low/high output voltage to CFG(High)
326 // Hyst. Enable to Disabled
327 // Pull / Keep Enable to CFG(Enabled)
328 // Pull / Keep Select to Pull
329 // Pull Up / Down Config. to CFG(360Kohm PD)
330 // config_pad_settings(NANDF_RB0, 0x20c0);
331 writel(0xC0, IOMUXC_SW_PAD_CTL_PAD_NANDF_RB0);
333 // config NANDF_RB1 pad for pata instance IORDY port
334 // config_pad_mode(NANDF_RB1, 0x1);
335 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_RB1);
336 // CONSTANT SETTINGS:
337 // test_ts to Disabled
338 // dse test to regular
339 // strength mode to NA (Different from Module Level value: 4_level)
340 // DDR / CMOS Input Mode to NA
341 // Open Drain Enable to NA (CFG in SoC Level however NA in Module Level)
342 // Drive Strength to NA (CFG in SoC Level however NA in Module Level)
344 // CONFIGURED SETTINGS:
345 // low/high output voltage to CFG(High)
346 // Hyst. Enable to Disabled
347 // Pull / Keep Enable to CFG(Enabled)
348 // Pull / Keep Select to Pull
349 // Pull Up / Down Config. to 100Kohm PU
350 // config_pad_settings(NANDF_RB1, 0x20e0);
351 writel(0xD0, IOMUXC_SW_PAD_CTL_PAD_NANDF_RB1);
353 // config NANDF_RB5 pad for pata instance INTRQ port
354 // config_pad_mode(NANDF_RB5, 0x1);
355 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_RB5);
356 // CONSTANT SETTINGS:
357 // test_ts to Disabled
358 // dse test to regular
359 // strength mode to NA (Different from Module Level value: 4_level)
360 // DDR / CMOS Input Mode to NA
361 // Pull Up / Down Config. to 100Kohm PU
362 // Open Drain Enable to Disabled (Different from Module Level value: NA)
363 // Drive Strength to NA (CFG in SoC Level however NA in Module Level)
365 // CONFIGURED SETTINGS:
366 // low/high output voltage to CFG(High)
367 // Hyst. Enable to Disabled
368 // Pull / Keep Enable to CFG(Enabled)
369 // Pull / Keep Select to Pull
370 // config_pad_settings(NANDF_RB5, 0x20c0);
371 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_RB5);
373 // config NANDF_CS2 pad for pata instance CS_0 port
374 // config_pad_mode(NANDF_CS2, 0x1);
375 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_CS2);
376 // CONSTANT SETTINGS:
377 // test_ts to Disabled
378 // dse test to regular
379 // strength mode to NA (Different from Module Level value: 4_level)
380 // DDR / CMOS Input Mode to NA
381 // Pull / Keep Select to NA (CFG in SoC Level however NA in Module Level)
382 // Pull Up / Down Config. to NA (CFG in SoC Level however NA in Module Level)
384 // CONFIGURED SETTINGS:
385 // low/high output voltage to CFG(High)
386 // Hyst. Enable to Disabled
387 // Pull / Keep Enable to Disabled
388 // Open Drain Enable to Disabled
389 // Drive Strength to CFG(High)
390 // config_pad_settings(NANDF_CS2, 0x2004);
391 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_CS2);
393 // config NANDF_CS3 pad for pata instance CS_1 port
394 // config_pad_mode(NANDF_CS3, 0x1);
395 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_CS3);
396 // CONSTANT SETTINGS:
397 // test_ts to Disabled
398 // dse test to regular
399 // strength mode to NA (Different from Module Level value: 4_level)
400 // DDR / CMOS Input Mode to NA
401 // Pull / Keep Select to NA (CFG in SoC Level however NA in Module Level)
402 // Pull Up / Down Config. to NA (CFG in SoC Level however NA in Module Level)
404 // CONFIGURED SETTINGS:
405 // low/high output voltage to CFG(High)
406 // Hyst. Enable to Disabled
407 // Pull / Keep Enable to Disabled
408 // Open Drain Enable to Disabled
409 // Drive Strength to CFG(High)
410 // config_pad_settings(NANDF_CS3, 0x2004);
411 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_CS3);
413 // config NANDF_CS4 pad for pata instance DA_0 port
414 // config_pad_mode(NANDF_CS4, 0x1);
415 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_CS4);
416 // CONSTANT SETTINGS:
417 // test_ts to Disabled
418 // dse test to regular
419 // strength mode to NA (Different from Module Level value: 4_level)
420 // DDR / CMOS Input Mode to NA
421 // Pull / Keep Select to NA (CFG in SoC Level however NA in Module Level)
422 // Pull Up / Down Config. to NA (CFG in SoC Level however NA in Module Level)
423 // Open Drain Enable to Disabled
425 // CONFIGURED SETTINGS:
426 // low/high output voltage to CFG(High)
427 // Hyst. Enable to Disabled
428 // Pull / Keep Enable to Disabled
429 // Drive Strength to CFG(High)
430 // config_pad_settings(NANDF_CS4, 0x2004);
431 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_CS4);
433 // config NANDF_CS5 pad for pata instance DA_1 port
434 // config_pad_mode(NANDF_CS5, 0x1);
435 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_CS5);
436 // CONSTANT SETTINGS:
437 // test_ts to Disabled
438 // dse test to regular
439 // strength mode to NA (Different from Module Level value: 4_level)
440 // DDR / CMOS Input Mode to NA
441 // Pull / Keep Select to NA (CFG in SoC Level however NA in Module Level)
442 // Pull Up / Down Config. to NA (CFG in SoC Level however NA in Module Level)
443 // Open Drain Enable to Disabled
445 // CONFIGURED SETTINGS:
446 // low/high output voltage to CFG(High)
447 // Hyst. Enable to Disabled
448 // Pull / Keep Enable to Disabled
449 // Drive Strength to CFG(High)
450 // config_pad_settings(NANDF_CS5, 0x2004);
451 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_CS5);
453 // config NANDF_CS6 pad for pata instance DA_2 port
454 // config_pad_mode(NANDF_CS6, 0x1);
455 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_CS6);
456 // CONSTANT SETTINGS:
457 // test_ts to Disabled
458 // dse test to regular
459 // strength mode to NA (Different from Module Level value: 4_level)
460 // DDR / CMOS Input Mode to NA
461 // Pull / Keep Select to Pull (Different from Module Level value: NA)
462 // Pull Up / Down Config. to NA (CFG in SoC Level however NA in Module Level)
463 // Open Drain Enable to Disabled
465 // CONFIGURED SETTINGS:
466 // low/high output voltage to CFG(High)
467 // Hyst. Enable to Disabled
468 // Pull / Keep Enable to Disabled
469 // Drive Strength to CFG(High)
470 // config_pad_settings(NANDF_CS6, 0x2004);
471 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_CS6);
473 // config NANDF_D15 pad for pata instance PATA_DATA[15] port
474 // config_pad_mode(NANDF_D15, 0x1);
475 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D15);
476 // CONSTANT SETTINGS:
477 // test_ts to Disabled
478 // dse test to regular
479 // strength mode to NA (Different from Module Level value: 4_level)
480 // DDR / CMOS Input Mode to NA
481 // Open Drain Enable to Disabled
483 // CONFIGURED SETTINGS:
484 // low/high output voltage to CFG(High)
485 // Hyst. Enable to Disabled
486 // Pull / Keep Enable to CFG(Enabled)
487 // Pull / Keep Select to Pull
488 // Pull Up / Down Config. to 100Kohm PU
489 // Drive Strength to CFG(High)
490 // config_pad_settings(NANDF_D15, 0x2004);
491 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D15);
493 // config NANDF_D14 pad for pata instance PATA_DATA[14] port
494 // config_pad_mode(NANDF_D14, 0x1);
495 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D14);
496 // CONSTANT SETTINGS:
497 // test_ts to Disabled
498 // dse test to regular
499 // strength mode to NA (Different from Module Level value: 4_level)
500 // DDR / CMOS Input Mode to NA
501 // Open Drain Enable to Disabled
503 // CONFIGURED SETTINGS:
504 // low/high output voltage to CFG(High)
505 // Hyst. Enable to Disabled
506 // Pull / Keep Enable to CFG(Enabled)
507 // Pull / Keep Select to Pull
508 // Pull Up / Down Config. to 100Kohm PU
509 // Drive Strength to CFG(High)
510 // config_pad_settings(NANDF_D14, 0x2004);
511 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D14);
513 // config NANDF_D13 pad for pata instance PATA_DATA[13] port
514 // config_pad_mode(NANDF_D13, 0x1);
515 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D13);
516 // CONSTANT SETTINGS:
517 // test_ts to Disabled
518 // dse test to regular
519 // strength mode to NA (Different from Module Level value: 4_level)
520 // DDR / CMOS Input Mode to NA
521 // Open Drain Enable to Disabled
523 // CONFIGURED SETTINGS:
524 // low/high output voltage to CFG(High)
525 // Hyst. Enable to Disabled
526 // Pull / Keep Enable to CFG(Enabled)
527 // Pull / Keep Select to Pull
528 // Pull Up / Down Config. to 100Kohm PU
529 // Drive Strength to CFG(High)
530 // config_pad_settings(NANDF_D13, 0x2004);
531 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D13);
533 // config NANDF_D12 pad for pata instance PATA_DATA[12] port
534 // config_pad_mode(NANDF_D12, 0x1);
535 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D12);
536 // CONSTANT SETTINGS:
537 // test_ts to Disabled
538 // dse test to regular
539 // strength mode to NA (Different from Module Level value: 4_level)
540 // DDR / CMOS Input Mode to NA
541 // Open Drain Enable to Disabled
543 // CONFIGURED SETTINGS:
544 // low/high output voltage to CFG(High)
545 // Hyst. Enable to Disabled
546 // Pull / Keep Enable to CFG(Enabled)
547 // Pull / Keep Select to Pull
548 // Pull Up / Down Config. to 100Kohm PU
549 // Drive Strength to CFG(High)
550 // config_pad_settings(NANDF_D12, 0x2004);
551 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D12);
553 // config NANDF_D11 pad for pata instance PATA_DATA[11] port
554 // config_pad_mode(NANDF_D11, 0x1);
555 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D11);
556 // CONSTANT SETTINGS:
557 // test_ts to Disabled
558 // dse test to regular
559 // strength mode to NA (Different from Module Level value: 4_level)
560 // DDR / CMOS Input Mode to NA
561 // Open Drain Enable to Disabled
563 // CONFIGURED SETTINGS:
564 // low/high output voltage to CFG(High)
565 // Hyst. Enable to Disabled
566 // Pull / Keep Enable to CFG(Enabled)
567 // Pull / Keep Select to Pull
568 // Pull Up / Down Config. to 100Kohm PU
569 // Drive Strength to CFG(High)
570 // config_pad_settings(NANDF_D11, 0x2004);
571 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D11);
573 // config NANDF_D10 pad for pata instance PATA_DATA[10] port
574 // config_pad_mode(NANDF_D10, 0x1);
575 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D10);
576 // CONSTANT SETTINGS:
577 // test_ts to Disabled
578 // dse test to regular
579 // strength mode to NA (Different from Module Level value: 4_level)
580 // DDR / CMOS Input Mode to NA
581 // Open Drain Enable to Disabled
583 // CONFIGURED SETTINGS:
584 // low/high output voltage to CFG(High)
585 // Hyst. Enable to Disabled
586 // Pull / Keep Enable to CFG(Enabled)
587 // Pull / Keep Select to Pull
588 // Pull Up / Down Config. to 100Kohm PU
589 // Drive Strength to CFG(High)
590 // config_pad_settings(NANDF_D10, 0x2004);
591 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D10);
593 // config NANDF_D9 pad for pata instance PATA_DATA[9] port
594 // config_pad_mode(NANDF_D9, 0x1);
595 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D9);
596 // CONSTANT SETTINGS:
597 // test_ts to Disabled
598 // dse test to regular
599 // strength mode to NA (Different from Module Level value: 4_level)
600 // DDR / CMOS Input Mode to NA
601 // Open Drain Enable to Disabled
603 // CONFIGURED SETTINGS:
604 // low/high output voltage to CFG(High)
605 // Hyst. Enable to Disabled
606 // Pull / Keep Enable to CFG(Enabled)
607 // Pull / Keep Select to Pull
608 // Pull Up / Down Config. to 100Kohm PU
609 // Drive Strength to CFG(High)
610 // config_pad_settings(NANDF_D9, 0x2004);
611 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D9);
613 // config NANDF_D8 pad for pata instance PATA_DATA[8] port
614 // config_pad_mode(NANDF_D8, 0x1);
615 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D8);
616 // CONSTANT SETTINGS:
617 // test_ts to Disabled
618 // dse test to regular
619 // strength mode to NA (Different from Module Level value: 4_level)
620 // DDR / CMOS Input Mode to NA
621 // Open Drain Enable to Disabled
623 // CONFIGURED SETTINGS:
624 // low/high output voltage to CFG(High)
625 // Hyst. Enable to Disabled
626 // Pull / Keep Enable to CFG(Enabled)
627 // Pull / Keep Select to Pull
628 // Pull Up / Down Config. to 100Kohm PU
629 // Drive Strength to CFG(High)
630 // config_pad_settings(NANDF_D8, 0x2004);
631 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D8);
633 // config NANDF_D7 pad for pata instance PATA_DATA[7] port
634 // config_pad_mode(NANDF_D7, 0x1);
635 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D7);
636 // CONSTANT SETTINGS:
637 // test_ts to Disabled
638 // dse test to regular
639 // strength mode to NA (Different from Module Level value: 4_level)
640 // DDR / CMOS Input Mode to NA
641 // Pull Up / Down Config. to 100Kohm PU
642 // Open Drain Enable to Disabled
644 // CONFIGURED SETTINGS:
645 // low/high output voltage to CFG(High)
646 // Hyst. Enable to Disabled
647 // Pull / Keep Enable to CFG(Enabled)
648 // Pull / Keep Select to Pull
649 // Drive Strength to CFG(High)
650 // config_pad_settings(NANDF_D7, 0x2004);
651 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D7);
653 // config NANDF_D6 pad for pata instance PATA_DATA[6] port
654 // config_pad_mode(NANDF_D6, 0x1);
655 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D6);
656 // CONSTANT SETTINGS:
657 // test_ts to Disabled
658 // dse test to regular
659 // strength mode to NA (Different from Module Level value: 4_level)
660 // DDR / CMOS Input Mode to NA
661 // Pull Up / Down Config. to 100Kohm PU
663 // CONFIGURED SETTINGS:
664 // low/high output voltage to CFG(High)
665 // Hyst. Enable to Disabled
666 // Pull / Keep Enable to CFG(Enabled)
667 // Pull / Keep Select to Pull
668 // Open Drain Enable to Disabled
669 // Drive Strength to CFG(High)
670 // config_pad_settings(NANDF_D6, 0x2004);
671 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D6);
673 // config NANDF_D5 pad for pata instance PATA_DATA[5] port
674 // config_pad_mode(NANDF_D5, 0x1);
675 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D5);
676 // CONSTANT SETTINGS:
677 // test_ts to Disabled
678 // dse test to regular
679 // strength mode to NA (Different from Module Level value: 4_level)
680 // DDR / CMOS Input Mode to NA
681 // Pull Up / Down Config. to 100Kohm PU
682 // Open Drain Enable to Disabled
684 // CONFIGURED SETTINGS:
685 // low/high output voltage to CFG(High)
686 // Hyst. Enable to Disabled
687 // Pull / Keep Enable to CFG(Enabled)
688 // Pull / Keep Select to Pull
689 // Drive Strength to CFG(High)
690 // config_pad_settings(NANDF_D5, 0x2004);
691 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D5);
693 // config NANDF_D4 pad for pata instance PATA_DATA[4] port
694 // config_pad_mode(NANDF_D4, 0x1);
695 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D4);
696 // CONSTANT SETTINGS:
697 // test_ts to Disabled
698 // dse test to regular
699 // strength mode to NA (Different from Module Level value: 4_level)
700 // DDR / CMOS Input Mode to NA
701 // Pull Up / Down Config. to 100Kohm PU
702 // Open Drain Enable to Disabled
704 // CONFIGURED SETTINGS:
705 // low/high output voltage to CFG(High)
706 // Hyst. Enable to Disabled
707 // Pull / Keep Enable to CFG(Enabled)
708 // Pull / Keep Select to Pull
709 // Drive Strength to CFG(High)
710 // config_pad_settings(NANDF_D4, 0x2004);
711 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D4);
713 // config NANDF_D3 pad for pata instance PATA_DATA[3] port
714 // config_pad_mode(NANDF_D3, 0x1);
715 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D3);
716 // CONSTANT SETTINGS:
717 // test_ts to Disabled
718 // dse test to regular
719 // strength mode to NA (Different from Module Level value: 4_level)
720 // DDR / CMOS Input Mode to NA
721 // Open Drain Enable to Disabled
723 // CONFIGURED SETTINGS:
724 // low/high output voltage to CFG(High)
725 // Hyst. Enable to Disabled
726 // Pull / Keep Enable to CFG(Enabled)
727 // Pull / Keep Select to Pull
728 // Pull Up / Down Config. to 100Kohm PU
729 // Drive Strength to CFG(High)
730 // config_pad_settings(NANDF_D3, 0x2004);
731 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D3);
733 // config NANDF_D2 pad for pata instance PATA_DATA[2] port
734 // config_pad_mode(NANDF_D2, 0x1);
735 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D2);
736 // CONSTANT SETTINGS:
737 // test_ts to Disabled
738 // dse test to regular
739 // strength mode to NA (Different from Module Level value: 4_level)
740 // DDR / CMOS Input Mode to NA
741 // Open Drain Enable to Disabled
743 // CONFIGURED SETTINGS:
744 // low/high output voltage to CFG(High)
745 // Hyst. Enable to Disabled
746 // Pull / Keep Enable to CFG(Enabled)
747 // Pull / Keep Select to Pull
748 // Pull Up / Down Config. to 100Kohm PU
749 // Drive Strength to CFG(High)
750 // config_pad_settings(NANDF_D2, 0x2004);
751 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D2);
753 // config NANDF_D1 pad for pata instance PATA_DATA[1] port
754 // config_pad_mode(NANDF_D1, 0x1);
755 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D1);
756 // CONSTANT SETTINGS:
757 // test_ts to Disabled
758 // dse test to regular
759 // strength mode to NA (Different from Module Level value: 4_level)
760 // DDR / CMOS Input Mode to NA
761 // Open Drain Enable to Disabled
763 // CONFIGURED SETTINGS:
764 // low/high output voltage to CFG(High)
765 // Hyst. Enable to Disabled
766 // Pull / Keep Enable to CFG(Enabled)
767 // Pull / Keep Select to Pull
768 // Pull Up / Down Config. to 100Kohm PU
769 // Drive Strength to CFG(High)
770 // config_pad_settings(NANDF_D1, 0x2004);
771 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D1);
773 // config NANDF_D0 pad for pata instance PATA_DATA[0] port
774 // config_pad_mode(NANDF_D0, 0x1);
775 writel(0x1, IOMUXC_SW_MUX_CTL_PAD_NANDF_D0);
776 // CONSTANT SETTINGS:
777 // test_ts to Disabled
778 // dse test to regular
779 // strength mode to NA (Different from Module Level value: 4_level)
780 // DDR / CMOS Input Mode to NA
781 // Open Drain Enable to Disabled
783 // CONFIGURED SETTINGS:
784 // low/high output voltage to CFG(High)
785 // Hyst. Enable to Disabled
786 // Pull / Keep Enable to CFG(Enabled)
787 // Pull / Keep Select to Pull
788 // Pull Up / Down Config. to 100Kohm PU
789 // Drive Strength to CFG(High)
790 // config_pad_settings(NANDF_D0, 0x2004);
791 writel(0x2004, IOMUXC_SW_PAD_CTL_PAD_NANDF_D0);
794 void mxc_i2c_init(unsigned int module_base)
798 switch (module_base) {
802 writel(0x13, IOMUXC_BASE_ADDR + 0x0278);
803 writel(0x13, IOMUXC_BASE_ADDR + 0x027C);
805 writel(0x1, IOMUXC_BASE_ADDR + 0x0A08);
806 writel(0x1, IOMUXC_BASE_ADDR + 0x0A0C);
808 writel(0x1ED, IOMUXC_BASE_ADDR + 0x0728);
809 writel(0x1ED, IOMUXC_BASE_ADDR + 0x072C);
813 diag_printf("Invalid I2C base: 0x%x\n", module_base);
819 void mxc_mmc_init(unsigned int base_address)
821 switch(base_address) {
822 case MMC_SDHC1_BASE_ADDR:
823 //diag_printf("Configure IOMUX of ESDHC1 on i.MX51\n");
824 /* SD1 CMD, SION bit */
825 writel(0x10, IOMUXC_BASE_ADDR + 0x39c);
828 writel(0x1, IOMUXC_BASE_ADDR + 0x3c4);
830 writel(0x1, IOMUXC_BASE_ADDR + 0x3c8);
832 writel(0x1, IOMUXC_BASE_ADDR + 0x3cc);
834 writel(0x1, IOMUXC_BASE_ADDR + 0x3d0);
837 /* SD1 CD, as gpio1_0 */
838 writel(0x01, IOMUXC_BASE_ADDR + 0x3b4);
839 /* Configure SW PAD */
841 writel(0x20d4, IOMUXC_BASE_ADDR + 0x868);
843 writel(0x20d4, IOMUXC_BASE_ADDR + 0x86c);
845 writel(0x20d4, IOMUXC_BASE_ADDR + 0x870);
847 writel(0x20d4, IOMUXC_BASE_ADDR + 0x874);
849 writel(0x20d4, IOMUXC_BASE_ADDR + 0x878);
851 writel(0x20d4, IOMUXC_BASE_ADDR + 0x87c);
852 /* SD1 CD as gpio1_0 */
853 writel(0x1e2, IOMUXC_BASE_ADDR + 0x880);
860 #include CYGHWR_MEMORY_LAYOUT_H
862 typedef void code_fun(void);
864 void board_program_new_stack(void *func)
866 register CYG_ADDRESS stack_ptr asm("sp");
867 register CYG_ADDRESS old_stack asm("r4");
868 register code_fun *new_func asm("r0");
869 old_stack = stack_ptr;
870 stack_ptr = CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE - sizeof(CYG_ADDRESS);
871 new_func = (code_fun*)func;
873 stack_ptr = old_stack;
876 void increase_core_voltage(bool i)
880 val = pmic_reg(24, 0, 0);
883 /* Set core voltage to 1.175V */
884 val = val & (~0x1F) | 0x17;
886 /* Set core voltage to 1.05V */
887 val = val & (~0x1F) | 0x12;
890 pmic_reg(24, val, 1);
893 extern unsigned int pmic_reg(unsigned int reg, unsigned int val, unsigned int write);
894 static void rocky_power_init(void)
898 /* power up the system first */
899 pmic_reg(34, 0x00200000, 1);
901 if (pll_clock(PLL1) > 800000000) {
902 /* Set core voltage to 1.175V */
903 val = pmic_reg(24, 0, 0);
904 val = val & (~0x1F) | 0x17;
905 pmic_reg(24, val, 1);
908 /* Set VDIG to 1.65V, VGEN3 to 1.8V, VCAM to 2.5V */
909 val = pmic_reg(30, 0, 0);
912 pmic_reg(30, val, 1);
914 /* Set VVIDEO to 2.775V, VAUDIO to 2.775V, VSD to 3.15V */
915 val = pmic_reg(31, 0, 0);
918 pmic_reg(31, val, 1);
920 /* Configure VGEN3 and VCAM regulators to use external PNP */
922 pmic_reg(33, val, 1);
925 /* Enable VGEN1 regulator */
926 val = pmic_reg(32, val, 0);
928 pmic_reg(32, val, 1);
930 /* Enable VGEN3, VCAM, VAUDIO, VVIDEO, VSD regulators */
932 pmic_reg(33, val, 1);
935 val = pmic_reg(29, val, 0);
937 pmic_reg(29, val, 1);
939 /* SW2 to 1.25V (VCC - MX51 Peripheral core) */
940 val = pmic_reg(25, val, 0);
943 pmic_reg(25, val, 1);
950 RedBoot_init(rocky_power_init, RedBoot_INIT_PRIO(900));
952 void io_cfg_spi(struct imx_spi_dev *dev)
955 case CSPI1_BASE_ADDR:
956 // 000: Select mux mode: ALT0 mux port: MOSI of instance: ecspi1
957 writel(0x0, IOMUXC_BASE_ADDR + 0x21C);
958 writel(0x105, IOMUXC_BASE_ADDR + 0x6CC);
960 // 000: Select mux mode: ALT0 mux port: MISO of instance: ecspi1.
961 writel(0x0, IOMUXC_BASE_ADDR + 0x220);
962 writel(0x105, IOMUXC_BASE_ADDR + 0x6D0);
964 // de-select SS1 of instance: ecspi1.
965 writel(0x3, IOMUXC_BASE_ADDR + 0x228);
966 writel(0x85, IOMUXC_BASE_ADDR + 0x6D8);
967 // 000: Select mux mode: ALT0 mux port: SS0 of instance: ecspi1.
968 writel(0x0, IOMUXC_BASE_ADDR + 0x224);
969 writel(0x185, IOMUXC_BASE_ADDR + 0x6D4);
970 } else if (dev->ss == 1) {
971 // de-select SS0 of instance: ecspi1.
972 writel(0x3, IOMUXC_BASE_ADDR + 0x224);
973 writel(0x85, IOMUXC_BASE_ADDR + 0x6D4);
974 // 000: Select mux mode: ALT0 mux port: SS1 of instance: ecspi1.
975 writel(0x0, IOMUXC_BASE_ADDR + 0x228);
976 writel(0x105, IOMUXC_BASE_ADDR + 0x6D8);
978 // 000: Select mux mode: ALT0 mux port: RDY of instance: ecspi1.
979 writel(0x0, IOMUXC_BASE_ADDR + 0x22C);
980 writel(0x180, IOMUXC_BASE_ADDR + 0x6DC);
982 // 000: Select mux mode: ALT0 mux port: SCLK of instance: ecspi1.
983 writel(0x0, IOMUXC_BASE_ADDR + 0x230);
984 writel(0x105, IOMUXC_BASE_ADDR + 0x6E0);
986 case CSPI2_BASE_ADDR: