1 From 0329cf7965956a5a7044827e0ce88ae8d5150e54 Mon Sep 17 00:00:00 2001
2 From: Xiangfu <xiangfu@openmobilefree.net>
3 Date: Fri, 12 Oct 2012 09:46:58 +0800
4 Subject: [PATCH 1/6] qi_lb60: add nand spl support
6 The JZ4740 CPU can load 8KB from two different addresses:
7 1. the normal area up to 8KB starting from NAND flash address 0x00000000
8 2. the backup area up to 8KB starting from NAND flash address 0x00002000
10 Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
13 arch/mips/cpu/xburst/Makefile | 7 +-
14 arch/mips/cpu/xburst/cpu.c | 4 +
15 arch/mips/cpu/xburst/jz4740.c | 82 +++++++----------
16 arch/mips/cpu/xburst/spl/Makefile | 47 ++++++++++
17 arch/mips/cpu/xburst/spl/start.S | 63 +++++++++++++
18 board/qi/qi_lb60/Makefile | 4 +
19 board/qi/qi_lb60/qi_lb60-spl.c | 30 +++++++
20 board/qi/qi_lb60/qi_lb60.c | 8 +-
21 board/qi/qi_lb60/u-boot-spl.lds | 61 +++++++++++++
22 drivers/mtd/nand/jz4740_nand.c | 39 ++++++++-
23 include/configs/qi_lb60.h | 175 ++++++++++++++++++-------------------
24 12 files changed, 386 insertions(+), 146 deletions(-)
25 create mode 100644 arch/mips/cpu/xburst/spl/Makefile
26 create mode 100644 arch/mips/cpu/xburst/spl/start.S
27 create mode 100644 board/qi/qi_lb60/qi_lb60-spl.c
28 create mode 100644 board/qi/qi_lb60/u-boot-spl.lds
30 diff --git a/Makefile b/Makefile
31 index 34d9075..a22778e 100644
34 @@ -393,6 +393,10 @@ ALL-y += $(obj)u-boot-nodtb-tegra.bin
39 +ALL-y += $(obj)u-boot-xburst.bin
42 all: $(ALL-y) $(SUBDIR_EXAMPLES)
44 $(obj)u-boot.dtb: $(obj)u-boot
45 @@ -506,6 +510,14 @@ $(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
50 +$(obj)u-boot-xburst.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
51 + dd if=$(obj)spl/u-boot-spl.bin of=$(obj)spl/u-boot-pad.bin conv=sync bs=8192 count=1
52 + dd if=$(obj)spl/u-boot-spl.bin of=$(obj)spl/u-boot-pad.bin conv=sync,notrunc oflag=append bs=8192 count=1
53 + tr '\0' '\377' < /dev/zero | dd of=$(obj)spl/u-boot-pad.bin conv=sync,notrunc oflag=append bs=16384 count=1
54 + cat $(obj)spl/u-boot-pad.bin u-boot.bin > $@
57 ifeq ($(CONFIG_SANDBOX),y)
59 cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
60 diff --git a/arch/mips/cpu/xburst/Makefile b/arch/mips/cpu/xburst/Makefile
61 index b1f2ae4..ec35e55 100644
62 --- a/arch/mips/cpu/xburst/Makefile
63 +++ b/arch/mips/cpu/xburst/Makefile
64 @@ -24,9 +24,12 @@ include $(TOPDIR)/config.mk
66 LIB = $(obj)lib$(CPU).o
68 +COBJS-y = cpu.o jz_serial.o
70 +ifneq ($(CONFIG_SPL_BUILD),y)
73 -COBJS-y = cpu.o timer.o jz_serial.o
77 COBJS-$(CONFIG_JZ4740) += jz4740.o
79 diff --git a/arch/mips/cpu/xburst/cpu.c b/arch/mips/cpu/xburst/cpu.c
80 index ddcbfaa..1432838 100644
81 --- a/arch/mips/cpu/xburst/cpu.c
82 +++ b/arch/mips/cpu/xburst/cpu.c
85 : "i" (op), "R" (*(unsigned char *)(addr)))
87 +#ifndef CONFIG_SPL_BUILD
89 void __attribute__((weak)) _machine_restart(void)
91 struct jz4740_wdt *wdt = (struct jz4740_wdt *)JZ4740_WDT_BASE;
92 @@ -109,6 +111,8 @@ void invalidate_dcache_range(ulong start_addr, ulong stop)
93 cache_op(Hit_Invalidate_D, addr);
98 void flush_icache_all(void)
101 diff --git a/arch/mips/cpu/xburst/jz4740.c b/arch/mips/cpu/xburst/jz4740.c
102 index c0b9817..8816aa3 100644
103 --- a/arch/mips/cpu/xburst/jz4740.c
104 +++ b/arch/mips/cpu/xburst/jz4740.c
105 @@ -32,31 +32,19 @@ int disable_interrupts(void)
110 - * PLL output clock = EXTAL * NF / (NR * NO)
111 - * NF = FD + 2, NR = RD + 2
112 - * NO = 1 (if OD = 0), NO = 2 (if OD = 1 or 2), NO = 4 (if OD = 3)
116 struct jz4740_cpm *cpm = (struct jz4740_cpm *)JZ4740_CPM_BASE;
118 - register unsigned int cfcr, plcr1;
120 - 0, 0, 1, 2, 3, 0, 4, 0, 5, 0, 0, 0, 6, 0, 0, 0,
121 - 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0,
124 - int div[5] = {1, 3, 3, 3, 3}; /* divisors of I:S:P:L:M */
126 + register unsigned int cfcr, plcr;
127 + unsigned int nf, pllout2;
129 cfcr = CPM_CPCCR_CLKOEN |
131 - (n2FR[div[0]] << CPM_CPCCR_CDIV_BIT) |
132 - (n2FR[div[1]] << CPM_CPCCR_HDIV_BIT) |
133 - (n2FR[div[2]] << CPM_CPCCR_PDIV_BIT) |
134 - (n2FR[div[3]] << CPM_CPCCR_MDIV_BIT) |
135 - (n2FR[div[4]] << CPM_CPCCR_LDIV_BIT);
136 + (0 << CPM_CPCCR_CDIV_BIT) |
137 + (2 << CPM_CPCCR_HDIV_BIT) |
138 + (2 << CPM_CPCCR_PDIV_BIT) |
139 + (2 << CPM_CPCCR_MDIV_BIT) |
140 + (2 << CPM_CPCCR_LDIV_BIT);
142 pllout2 = (cfcr & CPM_CPCCR_PCS) ?
143 CONFIG_SYS_CPU_SPEED : (CONFIG_SYS_CPU_SPEED / 2);
144 @@ -65,15 +53,18 @@ void pll_init(void)
145 writel(pllout2 / 48000000 - 1, &cpm->uhccdr);
147 nf = CONFIG_SYS_CPU_SPEED * 2 / CONFIG_SYS_EXTAL;
148 - plcr1 = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | /* FD */
149 + plcr = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | /* FD */
150 (0 << CPM_CPPCR_PLLN_BIT) | /* RD=0, NR=2 */
151 (0 << CPM_CPPCR_PLLOD_BIT) | /* OD=0, NO=1 */
152 - (0x20 << CPM_CPPCR_PLLST_BIT) | /* PLL stable time */
153 + (0x32 << CPM_CPPCR_PLLST_BIT) | /* PLL stable time */
154 CPM_CPPCR_PLLEN; /* enable PLL */
157 writel(cfcr, &cpm->cpccr);
158 - writel(plcr1, &cpm->cppcr);
159 + writel(plcr, &cpm->cppcr);
161 + while (!(readl(&cpm->cppcr) & CPM_CPPCR_PLLS))
165 void sdram_init(void)
166 @@ -92,26 +83,12 @@ void sdram_init(void)
167 2 << EMC_DMCR_TCL_BIT /* CAS latency is 3 */
170 - int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
172 cpu_clk = CONFIG_SYS_CPU_SPEED;
173 - mem_clk = cpu_clk * div[__cpm_get_cdiv()] / div[__cpm_get_mdiv()];
174 + mem_clk = 84000000;
176 writel(0, &emc->bcr); /* Disable bus release */
177 writew(0, &emc->rtcsr); /* Disable clock for counting */
179 - /* Fault DMCR value for mode register setting*/
180 -#define SDRAM_ROW0 11
181 -#define SDRAM_COL0 8
182 -#define SDRAM_BANK40 0
184 - dmcr0 = ((SDRAM_ROW0 - 11) << EMC_DMCR_RA_BIT) |
185 - ((SDRAM_COL0 - 8) << EMC_DMCR_CA_BIT) |
186 - (SDRAM_BANK40 << EMC_DMCR_BA_BIT) |
187 - (SDRAM_BW16 << EMC_DMCR_BW_BIT) |
189 - cas_latency_dmcr[((SDRAM_CASL == 3) ? 1 : 0)];
191 /* Basic DMCR value */
192 dmcr = ((SDRAM_ROW - 11) << EMC_DMCR_RA_BIT) |
193 ((SDRAM_COL - 8) << EMC_DMCR_CA_BIT) |
194 @@ -128,31 +105,31 @@ void sdram_init(void)
197 dmcr |= (tmp - 4) << EMC_DMCR_TRAS_BIT;
198 - tmp = SDRAM_RCD / ns;
200 + tmp = SDRAM_RCD / ns;
203 dmcr |= tmp << EMC_DMCR_RCD_BIT;
204 - tmp = SDRAM_TPC / ns;
206 + tmp = SDRAM_TPC / ns;
209 dmcr |= tmp << EMC_DMCR_TPC_BIT;
210 - tmp = SDRAM_TRWL / ns;
212 + tmp = SDRAM_TRWL / ns;
215 dmcr |= tmp << EMC_DMCR_TRWL_BIT;
216 - tmp = (SDRAM_TRAS + SDRAM_TPC) / ns;
218 + tmp = (SDRAM_TRAS + SDRAM_TPC) / ns;
221 dmcr |= ((tmp + 1) >> 1) << EMC_DMCR_TRC_BIT;
223 /* SDRAM mode value */
224 - sdmode = EMC_SDMR_BT_SEQ |
225 - EMC_SDMR_OM_NORMAL |
227 + sdmode = EMC_SDMR_BT_SEQ |
228 + EMC_SDMR_OM_NORMAL |
230 cas_latency_sdmr[((SDRAM_CASL == 3) ? 1 : 0)];
232 /* Stage 1. Precharge all banks by writing SDMR with DMCR.MRSET=0 */
233 @@ -172,8 +149,8 @@ void sdram_init(void)
236 writew(tmp, &emc->rtcor);
238 writew(0, &emc->rtcnt);
239 - /* Divisor is 64, CKO/64 */
240 writew(EMC_RTCSR_CKS_64, &emc->rtcsr);
242 /* Wait for number of auto-refresh cycles */
243 @@ -182,13 +159,17 @@ void sdram_init(void)
246 /* Stage 3. Mode Register Set */
247 + dmcr0 = (11 << EMC_DMCR_RA_BIT) |
248 + (8 << EMC_DMCR_CA_BIT) |
249 + (0 << EMC_DMCR_BA_BIT) |
251 + (SDRAM_BW16 << EMC_DMCR_BW_BIT) |
252 + cas_latency_dmcr[((SDRAM_CASL == 3) ? 1 : 0)];
253 writel(dmcr0 | EMC_DMCR_RFSH | EMC_DMCR_MRSET, &emc->dmcr);
254 writeb(0, JZ4740_EMC_SDMR0 | sdmode);
256 /* Set back to basic DMCR value */
257 writel(dmcr | EMC_DMCR_RFSH | EMC_DMCR_MRSET, &emc->dmcr);
259 - /* everything is ok now */
262 DECLARE_GLOBAL_DATA_PTR;
263 @@ -232,9 +213,10 @@ void rtc_init(void)
264 phys_size_t initdram(int board_type)
266 struct jz4740_emc *emc = (struct jz4740_emc *)JZ4740_EMC_BASE;
268 - u32 rows, cols, dw, banks;
272 + unsigned int rows, cols, dw, banks;
273 + unsigned long size;
275 dmcr = readl(&emc->dmcr);
276 rows = 11 + ((dmcr & EMC_DMCR_RA_MASK) >> EMC_DMCR_RA_BIT);
277 diff --git a/arch/mips/cpu/xburst/spl/Makefile b/arch/mips/cpu/xburst/spl/Makefile
279 index 0000000..f45e8c8
281 +++ b/arch/mips/cpu/xburst/spl/Makefile
284 +# Copyright (C) 2011 Xiangfu Liu <xiangfu@openmobilefree.net>
286 +# See file CREDITS for list of people who contributed to this
289 +# This program is free software; you can redistribute it and/or
290 +# modify it under the terms of the GNU General Public License as
291 +# published by the Free Software Foundation; either version 2 of
292 +# the License, or (at your option) any later version.
294 +# This program is distributed in the hope that it will be useful,
295 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
296 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
297 +# GNU General Public License for more details.
299 +# You should have received a copy of the GNU General Public License
300 +# along with this program; if not, write to the Free Software
301 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
305 +include $(TOPDIR)/config.mk
307 +LIB = $(obj)lib$(CPU).o
313 +SRCS := $(START:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
314 +OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
315 +START := $(addprefix $(obj),$(START))
317 +all: $(obj).depend $(START) $(LIB)
320 + $(call cmd_link_o_target, $(OBJS))
322 +#########################################################################
324 +# defines $(obj).depend target
325 +include $(SRCTREE)/rules.mk
327 +sinclude $(obj).depend
329 +#########################################################################
330 diff --git a/arch/mips/cpu/xburst/spl/start.S b/arch/mips/cpu/xburst/spl/start.S
332 index 0000000..e31c4c8
334 +++ b/arch/mips/cpu/xburst/spl/start.S
337 + * Copyright (c) 2010 Xiangfu Liu <xiangfu@openmobilefree.net>
339 + * See file CREDITS for list of people who contributed to this
342 + * This program is free software; you can redistribute it and/or
343 + * modify it under the terms of the GNU General Public License as
344 + * published by the Free Software Foundation; either version 3 of
345 + * the License, or (at your option) any later version.
347 + * This program is distributed in the hope that it will be useful,
348 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
349 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
350 + * GNU General Public License for more details.
352 + * You should have received a copy of the GNU General Public License
353 + * along with this program; if not, write to the Free Software
354 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
355 + * MA 02111-1307 USA
359 +#include <version.h>
360 +#include <asm/regdef.h>
361 +#include <asm/mipsregs.h>
362 +#include <asm/addrspace.h>
363 +#include <asm/cacheops.h>
365 +#include <asm/jz4740.h>
372 + .word JZ4740_NANDBOOT_CFG /* fetched during NAND Boot */
376 + * CU0=UM=EXL=IE=0, BEV=ERL=1, IP2~7=1
379 + mtc0 t0, CP0_STATUS
382 + * IV=1, use the specical interrupt vector (0x200)
389 + .word _GLOBAL_OFFSET_TABLE_
396 + la t9, nand_spl_boot
399 diff --git a/board/qi/qi_lb60/Makefile b/board/qi/qi_lb60/Makefile
400 index 5dae11b..e399246 100644
401 --- a/board/qi/qi_lb60/Makefile
402 +++ b/board/qi/qi_lb60/Makefile
403 @@ -22,7 +22,11 @@ include $(TOPDIR)/config.mk
405 LIB = $(obj)lib$(BOARD).o
407 +ifeq ($(CONFIG_SPL_BUILD),y)
408 +COBJS := $(BOARD)-spl.o
413 SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
414 OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
415 diff --git a/board/qi/qi_lb60/qi_lb60-spl.c b/board/qi/qi_lb60/qi_lb60-spl.c
417 index 0000000..3fe3fa3
419 +++ b/board/qi/qi_lb60/qi_lb60-spl.c
422 + * Authors: Xiangfu Liu <xiangfu@openmobilefree.cc>
424 + * This program is free software; you can redistribute it and/or
425 + * modify it under the terms of the GNU General Public License
426 + * as published by the Free Software Foundation; either version
427 + * 3 of the License, or (at your option) any later version.
433 +#include <asm/jz4740.h>
435 +void nand_spl_boot(void)
437 + __gpio_as_sdram_16bit_4720();
439 + __gpio_jtag_to_uart0();
448 + puts("\nQi LB60 SPL: Starting U-Boot ...\n");
451 diff --git a/board/qi/qi_lb60/qi_lb60.c b/board/qi/qi_lb60/qi_lb60.c
452 index d975209..3bd4e2f 100644
453 --- a/board/qi/qi_lb60/qi_lb60.c
454 +++ b/board/qi/qi_lb60/qi_lb60.c
457 - * Authors: Xiangfu Liu <xiangfu@sharism.cc>
458 + * Authors: Xiangfu Liu <xiangfu@openmobilefree.net>
460 * This program is free software; you can redistribute it and/or
461 * modify it under the terms of the GNU General Public License
462 @@ -97,8 +97,10 @@ int board_early_init_f(void)
463 /* U-Boot common routines */
466 - printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC, Speed %ld MHz)\n",
467 - gd->cpu_clk / 1000000);
468 + printf("Board: Qi LB60 (Ingenic XBurst Jz4740 SoC)\n");
469 + printf(" CPU: %ld\n", gd->cpu_clk);
470 + printf(" MEM: %ld\n", gd->mem_clk);
471 + printf(" DEV: %ld\n", gd->dev_clk);
475 diff --git a/board/qi/qi_lb60/u-boot-spl.lds b/board/qi/qi_lb60/u-boot-spl.lds
477 index 0000000..930537f
479 +++ b/board/qi/qi_lb60/u-boot-spl.lds
482 + * (C) Copyright 2012 Xiangfu Liu <xiangfu@openmobilefree.net>
484 + * This program is free software; you can redistribute it and/or
485 + * modify it under the terms of the GNU General Public License as
486 + * published by the Free Software Foundation; either version 2 of
487 + * the License, or (at your option) any later version.
489 + * This program is distributed in the hope that it will be useful,
490 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
491 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
492 + * GNU General Public License for more details.
494 + * You should have received a copy of the GNU General Public License
495 + * along with this program; if not, write to the Free Software
496 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
497 + * MA 02111-1307 USA
500 +OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradlittlemips", "elf32-tradlittlemips")
514 + .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
517 + .data : { *(.data) }
520 + .sdata : { *(.sdata) }
529 + __u_boot_cmd_start = .;
530 + .u_boot_cmd : { *(.u_boot_cmd) }
531 + __u_boot_cmd_end = .;
533 + uboot_end_data = .;
534 + num_got_entries = (__got_end - __got_start) >> 2;
537 + .sbss : { *(.sbss) }
541 +ASSERT(uboot_end <= 0x80002000, "NAND bootstrap too big");
542 diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c
543 index 3ec34f3..24a4921 100644
544 --- a/drivers/mtd/nand/jz4740_nand.c
545 +++ b/drivers/mtd/nand/jz4740_nand.c
548 #include <asm/jz4740.h>
550 +#ifdef CONFIG_SPL_BUILD
551 +#define printf(s) puts(s)
553 #define JZ_NAND_DATA_ADDR ((void __iomem *)0xB8000000)
554 #define JZ_NAND_CMD_ADDR (JZ_NAND_DATA_ADDR + 0x8000)
555 #define JZ_NAND_ADDR_ADDR (JZ_NAND_DATA_ADDR + 0x10000)
556 @@ -176,7 +179,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
557 for (k = 0; k < 9; k++)
558 writeb(read_ecc[k], &emc->nfpar[k]);
562 writel(readl(&emc->nfecr) | EMC_NFECR_PRDY, &emc->nfecr);
564 /* Wait for completion */
565 @@ -184,7 +187,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
566 status = readl(&emc->nfints);
567 } while (!(status & EMC_NFINTS_DECF));
571 writel(readl(&emc->nfecr) & ~EMC_NFECR_ECCE, &emc->nfecr);
574 @@ -192,7 +195,7 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
577 if (status & EMC_NFINTS_UNCOR) {
578 - printf("uncorrectable ecc\n");
579 + printf("JZ4740 uncorrectable ECC\n");
583 @@ -230,6 +233,32 @@ static int jz_nand_rs_correct_data(struct mtd_info *mtd, u_char *dat,
587 +#ifdef CONFIG_SPL_BUILD
588 +static void jz_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
591 + struct nand_chip *this = mtd->priv;
593 +#if (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B16R3) || \
594 + (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B16R2)
595 + for (i = 0; i < len; i += 2)
596 + buf[i] = readw(this->IO_ADDR_R);
597 +#elif (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B8R3) || \
598 + (JZ4740_NANDBOOT_CFG == JZ4740_NANDBOOT_B8R2)
599 + for (i = 0; i < len; i++)
600 + buf[i] = readb(this->IO_ADDR_R);
602 + #error JZ4740_NANDBOOT_CFG not defined or wrong
606 +static uint8_t jz_nand_read_byte(struct mtd_info *mtd)
608 + struct nand_chip *this = mtd->priv;
609 + return readb(this->IO_ADDR_R);
614 * Main initialization routine
616 @@ -254,6 +283,10 @@ int board_nand_init(struct nand_chip *nand)
617 nand->ecc.size = CONFIG_SYS_NAND_ECCSIZE;
618 nand->ecc.bytes = CONFIG_SYS_NAND_ECCBYTES;
619 nand->ecc.layout = &qi_lb60_ecclayout_2gb;
620 +#ifdef CONFIG_SPL_BUILD
621 + nand->read_byte = jz_nand_read_byte;
622 + nand->read_buf = jz_nand_read_buf;
624 nand->chip_delay = 50;
625 nand->options = NAND_USE_FLASH_BBT;
627 diff --git a/include/configs/qi_lb60.h b/include/configs/qi_lb60.h
628 index 4bb5bbc..7bff444 100644
629 --- a/include/configs/qi_lb60.h
630 +++ b/include/configs/qi_lb60.h
633 - * Authors: Xiangfu Liu <xiangfu.z@gmail.com>
634 + * Authors: Xiangfu Liu <xiangfu@openmobilefree.net>
636 * This program is free software; you can redistribute it and/or
637 * modify it under the terms of the GNU General Public License
639 #define CONFIG_SYS_LITTLE_ENDIAN
640 #define CONFIG_JZSOC /* Jz SoC */
641 #define CONFIG_JZ4740 /* Jz4740 SoC */
642 -#define CONFIG_NAND_JZ4740
644 #define CONFIG_SYS_CPU_SPEED 336000000 /* CPU clock: 336 MHz */
645 #define CONFIG_SYS_EXTAL 12000000 /* EXTAL freq: 12 MHz */
647 #define CONFIG_SYS_UART_BASE JZ4740_UART0_BASE /* Base of the UART channel */
648 #define CONFIG_BAUDRATE 57600
650 +#define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAUL)
651 +#define CONFIG_BOOTDELAY 0
652 +#define CONFIG_BOOTARGS "mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
653 +#define CONFIG_BOOTCOMMAND "nand read 0x80600000 0x400000 0x280000;bootm"
656 + * Miscellaneous configurable options
658 +#define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
659 +#define CONFIG_SYS_INIT_SP_OFFSET 0x400000
660 +#define CONFIG_SYS_LOAD_ADDR 0x80600000
661 +#define CONFIG_SYS_MEMTEST_START 0x80100000
662 +#define CONFIG_SYS_MEMTEST_END 0x80A00000
663 +#define CONFIG_SYS_TEXT_BASE 0x80100000
664 +#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
666 +#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024)
667 +#define CONFIG_SYS_BOOTPARAMS_LEN (128 * 1024)
669 +#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
670 +#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
672 +#define CONFIG_SYS_LONGHELP
673 +#define CONFIG_SYS_MAXARGS 16
674 +#define CONFIG_SYS_PROMPT "NanoNote# "
676 #define CONFIG_SKIP_LOWLEVEL_INIT
677 #define CONFIG_BOARD_EARLY_INIT_F
678 #define CONFIG_SYS_NO_FLASH
679 #define CONFIG_SYS_FLASH_BASE 0 /* init flash_base as 0 */
680 -#define CONFIG_ENV_OVERWRITE
682 -#define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAUL)
683 -#define CONFIG_BOOTDELAY 0
684 -#define CONFIG_BOOTARGS "mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait"
685 -#define CONFIG_BOOTCOMMAND "nand read 0x80600000 0x400000 0x200000;bootm"
688 - * Command line configuration.
689 + * Command line configuration
691 #define CONFIG_CMD_BOOTD /* bootd */
692 #define CONFIG_CMD_CONSOLE /* coninfo */
693 #define CONFIG_CMD_ECHO /* echo arguments */
695 #define CONFIG_CMD_LOADB /* loadb */
696 #define CONFIG_CMD_LOADS /* loads */
697 #define CONFIG_CMD_MEMORY /* md mm nm mw cp cmp crc base loop mtest */
699 #define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
702 - * Miscellaneous configurable options
704 -#define CONFIG_SYS_MAXARGS 16
705 -#define CONFIG_SYS_LONGHELP
706 -#define CONFIG_SYS_PROMPT "NanoNote# "
707 -#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
708 -#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
710 -#define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024)
711 -#define CONFIG_SYS_BOOTPARAMS_LEN (128 * 1024)
713 -#define CONFIG_SYS_SDRAM_BASE 0x80000000 /* Cached addr */
714 -#define CONFIG_SYS_INIT_SP_OFFSET 0x400000
715 -#define CONFIG_SYS_LOAD_ADDR 0x80600000
716 -#define CONFIG_SYS_MEMTEST_START 0x80100000
717 -#define CONFIG_SYS_MEMTEST_END 0x80800000
721 + * NAND driver configuration
723 -#define CONFIG_ENV_IS_IN_NAND /* use NAND for environment vars */
725 -#define CONFIG_SYS_NAND_5_ADDR_CYCLE
727 - * if board nand flash is 1GB, set to 1
728 - * if board nand flash is 2GB, set to 2
729 - * for change the PAGE_SIZE and BLOCK_SIZE
730 - * will delete when there is no 1GB flash
732 -#define NANONOTE_NAND_SIZE 2
734 -#define CONFIG_SYS_NAND_PAGE_SIZE (2048 * NANONOTE_NAND_SIZE)
735 -#define CONFIG_SYS_NAND_BLOCK_SIZE (256 * NANONOTE_NAND_SIZE << 10)
736 -/* nand bad block was marked at this page in a block, start from 0 */
737 +#define CONFIG_NAND_JZ4740
738 +#define CONFIG_SYS_NAND_PAGE_SIZE 4096
739 +#define CONFIG_SYS_NAND_BLOCK_SIZE (512 << 10)
740 +/* NAND bad block was marked at this page in a block, start from 0 */
741 #define CONFIG_SYS_NAND_BADBLOCK_PAGE 127
742 #define CONFIG_SYS_NAND_PAGE_COUNT 128
743 #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0
744 -/* ECC offset position in oob area, default value is 6 if it isn't defined */
745 -#define CONFIG_SYS_NAND_ECC_POS (6 * NANONOTE_NAND_SIZE)
746 +#define CONFIG_SYS_NAND_ECC_POS 12
747 #define CONFIG_SYS_NAND_ECCSIZE 512
748 #define CONFIG_SYS_NAND_ECCBYTES 9
749 #define CONFIG_SYS_NAND_ECCPOS \
751 #define CONFIG_SYS_ONENAND_BASE CONFIG_SYS_NAND_BASE
752 #define CONFIG_SYS_MAX_NAND_DEVICE 1
753 #define CONFIG_SYS_NAND_SELECT_DEVICE 1 /* nand driver supports mutipl.*/
754 -#define CONFIG_NAND_SPL_TEXT_BASE 0x80000000
757 - * IPL (Initial Program Loader, integrated inside CPU)
758 + * IPL (Initial Program Loader, integrated inside Ingenic Xburst JZ4740 CPU)
759 * Will load first 8k from NAND (SPL) into cache and execute it from there.
761 * SPL (Secondary Program Loader)
762 @@ -130,77 +118,88 @@
764 * This NAND U-Boot (NUB) is a special U-Boot version which can be started
765 * from RAM. Therefore it mustn't (re-)configure the SDRAM controller.
770 + * NAND SPL configuration
773 +#define CONFIG_SPL_LIBGENERIC_SUPPORT
774 +#define CONFIG_SPL_LIBCOMMON_SUPPORT
775 +#define CONFIG_SPL_NAND_LOAD
776 +#define CONFIG_SPL_NAND_SIMPLE
777 +#define CONFIG_SPL_NAND_SUPPORT
778 +#define CONFIG_SPL_TEXT_BASE 0x80000000
779 +#define CONFIG_SPL_START_S_PATH "arch/mips/cpu/xburst/spl"
781 +#define CONFIG_SYS_NAND_5_ADDR_CYCLE
782 +#define CONFIG_SYS_NAND_HW_ECC_OOBFIRST
783 +#define JZ4740_NANDBOOT_CFG JZ4740_NANDBOOT_B8R3
785 #define CONFIG_SYS_NAND_U_BOOT_DST 0x80100000 /* Load NUB to this addr */
786 #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_NAND_U_BOOT_DST
787 -/* Start NUB from this addr*/
788 + /* Start NUB from this addr */
789 +#define CONFIG_SYS_NAND_U_BOOT_OFFS (32 << 10) /* Offset of NUB */
790 +#define CONFIG_SYS_NAND_U_BOOT_SIZE (256 << 10) /* Size of NUB */
793 - * Define the partitioning of the NAND chip (only RAM U-Boot is needed here)
794 + * Environment configuration
796 -#define CONFIG_SYS_NAND_U_BOOT_OFFS (256 << 10) /* Offset to RAM U-Boot image */
797 -#define CONFIG_SYS_NAND_U_BOOT_SIZE (512 << 10) /* Size of RAM U-Boot image */
799 +#define CONFIG_ENV_OVERWRITE
800 +#define CONFIG_ENV_IS_IN_NAND
801 #define CONFIG_ENV_SIZE (4 << 10)
802 #define CONFIG_ENV_OFFSET \
803 (CONFIG_SYS_NAND_BLOCK_SIZE + CONFIG_SYS_NAND_U_BOOT_SIZE)
804 #define CONFIG_ENV_OFFSET_REDUND \
805 (CONFIG_ENV_OFFSET + CONFIG_SYS_NAND_BLOCK_SIZE)
807 -#define CONFIG_SYS_TEXT_BASE 0x80100000
808 -#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
812 + * CPU cache configuration
814 -#define CONFIG_NR_DRAM_BANKS 1
815 +#define CONFIG_SYS_DCACHE_SIZE 16384
816 +#define CONFIG_SYS_ICACHE_SIZE 16384
817 +#define CONFIG_SYS_CACHELINE_SIZE 32
820 - * Cache Configuration
821 + * SDRAM configuration
823 -#define CONFIG_SYS_DCACHE_SIZE 16384
824 -#define CONFIG_SYS_ICACHE_SIZE 16384
825 -#define CONFIG_SYS_CACHELINE_SIZE 32
826 +#define CONFIG_NR_DRAM_BANKS 1
828 +#define SDRAM_BW16 1 /* Data bus width: 0-32bit, 1-16bit */
829 +#define SDRAM_BANK4 1 /* Banks each chip: 0-2bank, 1-4bank */
830 +#define SDRAM_ROW 13 /* Row address: 11 to 13 */
831 +#define SDRAM_COL 9 /* Column address: 8 to 12 */
832 +#define SDRAM_CASL 2 /* CAS latency: 2 or 3 */
833 +#define SDRAM_TRAS 45 /* RAS# Active Time */
834 +#define SDRAM_RCD 20 /* RAS# to CAS# Delay */
835 +#define SDRAM_TPC 20 /* RAS# Precharge Time */
836 +#define SDRAM_TRWL 7 /* Write Latency Time */
837 +#define SDRAM_TREF 15625 /* Refresh period: 8192 cycles/64ms */
841 + * GPIO configuration
843 -#define GPIO_LCD_CS (2 * 32 + 21)
844 -#define GPIO_AMP_EN (3 * 32 + 4)
845 +#define GPIO_LCD_CS (2 * 32 + 21)
846 +#define GPIO_AMP_EN (3 * 32 + 4)
848 -#define GPIO_SDPW_EN (3 * 32 + 2)
849 -#define GPIO_SD_DETECT (3 * 32 + 0)
850 +#define GPIO_SDPW_EN (3 * 32 + 2)
851 +#define GPIO_SD_DETECT (3 * 32 + 0)
853 -#define GPIO_BUZZ_PWM (3 * 32 + 27)
854 -#define GPIO_USB_DETECT (3 * 32 + 28)
855 +#define GPIO_BUZZ_PWM (3 * 32 + 27)
856 +#define GPIO_USB_DETECT (3 * 32 + 28)
858 -#define GPIO_AUDIO_POP (1 * 32 + 29)
859 -#define GPIO_COB_TEST (1 * 32 + 30)
860 +#define GPIO_AUDIO_POP (1 * 32 + 29)
861 +#define GPIO_COB_TEST (1 * 32 + 30)
863 #define GPIO_KEYOUT_BASE (2 * 32 + 10)
864 -#define GPIO_KEYIN_BASE (3 * 32 + 18)
865 -#define GPIO_KEYIN_8 (3 * 32 + 26)
866 +#define GPIO_KEYIN_BASE (3 * 32 + 18)
867 +#define GPIO_KEYIN_8 (3 * 32 + 26)
869 -#define GPIO_SD_CD_N GPIO_SD_DETECT /* SD Card insert detect */
870 +#define GPIO_SD_CD_N GPIO_SD_DETECT /* SD Card insert detect */
871 #define GPIO_SD_VCC_EN_N GPIO_SDPW_EN /* SD Card Power Enable */
873 #define SPEN GPIO_LCD_CS /* LCDCS :Serial command enable */
874 #define SPDA (2 * 32 + 22) /* LCDSCL:Serial command clock input */
875 #define SPCK (2 * 32 + 23) /* LCDSDA:Serial command data input */
877 -/* SDRAM paramters */
878 -#define SDRAM_BW16 1 /* Data bus width: 0-32bit, 1-16bit */
879 -#define SDRAM_BANK4 1 /* Banks each chip: 0-2bank, 1-4bank */
880 -#define SDRAM_ROW 13 /* Row address: 11 to 13 */
881 -#define SDRAM_COL 9 /* Column address: 8 to 12 */
882 -#define SDRAM_CASL 2 /* CAS latency: 2 or 3 */
884 -/* SDRAM Timings, unit: ns */
885 -#define SDRAM_TRAS 45 /* RAS# Active Time */
886 -#define SDRAM_RCD 20 /* RAS# to CAS# Delay */
887 -#define SDRAM_TPC 20 /* RAS# Precharge Time */
888 -#define SDRAM_TRWL 7 /* Write Latency Time */
889 -#define SDRAM_TREF 15625 /* Refresh period: 8192 cycles/64ms */