Add support for Embest SBC2440-II Board 6/7
Subsystems (5)
This patch adds support for the s3c2440 cpu to the MTD NAND driver. The changes were based heavily on the Linux-2.6.30 s3c2410 MTD NAND driver which also supports the s3c2440 cpu. I've tested these changes on an s3c2440 cpu (on the Embest SBC2440-II Board) but not on an s3c2410 cpu as none of the u-boot s3c2410 boards use the MTD NAND driver and anyway, I don't have an s3c2410 board. I have, however, checked that it builds OK for an s3c2410 cpu.
This patch assume the following patches have already been applied:
- [PATCH-ARM] Bug-fix in drivers mtd nand Makefile, sent 18/06/2009
- [PATCH-ARM] CONFIG_SYS_HZ fix for ARM920T S3C24X0 Boards, sent 21/06/2009
The patch was tested by running MAKEALL for all ARM9 targets and checking that no new warnings or errors were introduced.
--- drivers/mtd/nand/s3c2410_nand.c | 134 +++++++++++++++++++++------------------ 1 files changed, 73 insertions(+), 61 deletions(-)
drivers/mtd/nand/s3c2410_nand.c +73 -61
@@ -2,6 +2,10 @@* (C) Copyright 2006 OpenMoko, Inc. * Author: Harald Welte <[email protected]> * +* Modified to add S3C2440 support by +* (C) Copyright 2009 +* Kevin Morfitt, Fearnside Systems Ltd, <[email protected]> +* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of
@@ -21,48 +25,53 @@#include <common.h> #include <nand.h> +#include <linux/mtd/nand_ecc.h> #include <s3c24x0_cpu.h> #include <asm/io.h> -#define S3C2410_NFCONF_EN (1<<15) -#define S3C2410_NFCONF_512BYTE (1<<14) -#define S3C2410_NFCONF_4STEP (1<<13) -#define S3C2410_NFCONF_INITECC (1<<12) -#define S3C2410_NFCONF_nFCE (1<<11) -#define S3C2410_NFCONF_TACLS (x) ((x)<<8) -#define S3C2410_NFCONF_TWRPH0 (x) ((x)<<4) -#define S3C2410_NFCONF_TWRPH1 (x) ((x)<<0) +#if defined(CONFIG_S3C2410_NAND_HWECC ) && defined(CONFIG_SYS_NAND_LARGEPAGE ) +/* new oob placement block for use with hardware ecc generation +*/ +static struct nand_ecclayout nand_hw_eccoob = { + .eccbytes =3 , + .eccpos = {0 ,1 ,2 }, + .oobfree = { {8 ,8 } } +}; +#endif -#define S3C2410_ADDR_NALE 4 -#define S3C2410_ADDR_NCLE 8 +static void s3c2410_nand_select_chip (struct mtd_info *mtd,int chip) +{ +struct s3c2410_nand *nand =S3C2410_GetBase_NAND (); +unsigned long reg =readl (&nand->S3C24X0_NAND_CTRL_REG); + +if (chip ==-1 ) { +debugX (1 ,"Negating nFCE\n" ); + reg |= S3C24X0_NAND_nFCE_BIT; + }else { +debugX (1 ,"Asserting nFCE\n" ); + reg &= ~S3C24X0_NAND_nFCE_BIT; + } +writel (reg, &nand->S3C24X0_NAND_CTRL_REG); +}static void s3c2410_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *chip = mtd->priv;struct s3c2410_nand *nand =S3C2410_GetBase_NAND ();debugX (1 ,"hwcontrol(): 0x%02x 0x%02x\n" , cmd, ctrl); -if (ctrl &NAND_CTRL_CHANGE ) { -ulong IO_ADDR_W = (ulong )nand; - -if (!(ctrl &NAND_CLE )) -IO_ADDR_W |=S3C2410_ADDR_NCLE ; -if (!(ctrl &NAND_ALE )) -IO_ADDR_W |=S3C2410_ADDR_NALE ; - - chip->IO_ADDR_W = (void *)IO_ADDR_W ; +if (cmd ==NAND_CMD_NONE ) +return ; -if (ctrl &NAND_NCE ) -writel (readl (&nand->NFCONF) & ~S3C2410_NFCONF_nFCE, - &nand->NFCONF); -else -writel (readl (&nand->NFCONF) | S3C2410_NFCONF_nFCE, - &nand->NFCONF); +if (ctrl &NAND_CLE ) { +debugX (1 ,"NFCMD = 0x%08X\n" , cmd); +writel (cmd, &nand->NFCMD); } -if (cmd !=NAND_CMD_NONE ) -writeb (cmd, chip->IO_ADDR_W); +if (ctrl &NAND_ALE ) { +debugX (1 ,"NFADDR = 0x%08X\n" , cmd); +writel (cmd, &nand->NFADDR); + } }static int s3c2410_dev_ready (struct mtd_info *mtd)
@@ -76,39 +85,32 @@ static int s3c2410_dev_ready(struct mtd_info *mtd)void s3c2410_nand_enable_hwecc (struct mtd_info *mtd,int mode) {struct s3c2410_nand *nand =S3C2410_GetBase_NAND (); +unsigned long reg =readl (&nand->S3C24X0_NAND_CTRL_REG); +debugX (1 ,"s3c2410_nand_enable_hwecc(%p, %d)\n" , mtd, mode); -writel (readl (&nand->NFCONF) |S3C2410_NFCONF_INITECC , &nand->NFCONF); + reg |=S3C24X0_NAND_INITECC_BIT ; +writel (reg, &nand->S3C24X0_NAND_CTRL_REG); }static int s3c2410_nand_calculate_ecc (struct mtd_info *mtd,const u_char *dat,u_char *ecc_code) { - ecc_code[0 ] =NFECC0 ; - ecc_code[1 ] =NFECC1 ; - ecc_code[2 ] =NFECC2 ; +struct s3c2410_nand *nand =S3C2410_GetBase_NAND (); +unsigned long ecc =readl (&nand->S3C24X0_NAND_ECC_REG); + + ecc_code[0 ] = ecc; + ecc_code[1 ] = ecc >>8 ; + ecc_code[2 ] = ecc >>16 ;debugX (1 ,"s3c2410_nand_calculate_hwecc(%p,): 0x%02x 0x%02x 0x%02x\n" , - mtd , ecc_code[0 ], ecc_code[1 ], ecc_code[2 ]); + mtd, ecc_code[0 ], ecc_code[1 ], ecc_code[2 ]);return 0 ; } - -static int s3c2410_nand_correct_data (struct mtd_info *mtd,u_char *dat, -u_char *read_ecc,u_char *calc_ecc) -{ -if (read_ecc[0 ] == calc_ecc[0 ] && - read_ecc[1 ] == calc_ecc[1 ] && - read_ecc[2 ] == calc_ecc[2 ]) -return 0 ; - -printf ("s3c2410_nand_correct_data: not implemented\n" ); -return -1 ; -}#endif int board_nand_init (struct nand_chip *nand) { -u_int32_t cfg; -u_int8_t tacls, twrph0, twrph1; +unsigned long reg;struct s3c24x0_clock_power *clk_power =S3C24X0_GetBase_CLOCK_POWER ();struct s3c2410_nand *nand_reg =S3C2410_GetBase_NAND ();
@@ -117,15 +119,12 @@ int board_nand_init(struct nand_chip *nand)writel (readl (&clk_power->CLKCON) | (1 <<4 ), &clk_power->CLKCON);/* initialize hardware */ - twrph0 =3 ; - twrph1 =0 ; - tacls =0 ; - - cfg =S3C2410_NFCONF_EN ; - cfg |=S3C2410_NFCONF_TACLS (tacls -1 ); - cfg |=S3C2410_NFCONF_TWRPH0 (twrph0 -1 ); - cfg |=S3C2410_NFCONF_TWRPH1 (twrph1 -1 ); -writel (cfg, &nand_reg->NFCONF); + reg =S3C24X0_NAND_TACLS_BITS (CONFIG_SYS_NAND_TACLS ); + reg |=S3C24X0_NAND_TWRPH0_BITS (CONFIG_SYS_NAND_TWRPH0 ); + reg |=S3C24X0_NAND_TWRPH1_BITS (CONFIG_SYS_NAND_TWRPH1 ); +writel (reg, &nand_reg->S3C24X0_NAND_TIMING_REG); + reg =S3C24X0_NAND_EN_BIT | S3C24X0_NAND_nFCE_BIT; +writel (reg, &nand_reg->S3C24X0_NAND_CTRL_REG);/* initialize nand_chip data structure */ nand->IO_ADDR_R = nand->IO_ADDR_W = (void *)&nand_reg->NFDATA;
@@ -133,16 +132,29 @@ int board_nand_init(struct nand_chip *nand)/* read_buf and write_buf are default */ /* read_byte and write_byte are default */ + nand->select_chip = s3c2410_nand_select_chip; + nand->chip_delay =50 ; +/* hwcontrol always must be implemented */ nand->cmd_ctrl = s3c2410_hwcontrol; - nand->dev_ready = s3c2410_dev_ready;#ifdef CONFIG_S3C2410_NAND_HWECC - nand->ecc.hwctl = s3c2410_nand_enable_hwecc; - nand->ecc.calculate = s3c2410_nand_calculate_ecc; - nand->ecc.correct = s3c2410_nand_correct_data; - nand->ecc.mode =NAND_ECC_HW3_512 ; + nand->ecc.correct = nand_correct_data; + nand->ecc.hwctl = s3c2410_nand_enable_hwecc; + nand->ecc.calculate = s3c2410_nand_calculate_ecc; + nand->ecc.mode =NAND_ECC_HW ; +/* change the behaviour depending on whether we are using +* the large or small page nand device */ +#ifdef CONFIG_SYS_NAND_LARGEPAGE + nand->ecc.size =512 ; + nand->ecc.bytes =3 ; + nand->ecc.layout = &nand_hw_eccoob; +#else + nand->ecc.size =256 ; + nand->ecc.bytes =3 ; +#endif +debugX (2 ,"ecc: size: %d bytes: %d\n" , nand->ecc.size, nand->ecc.bytes);#else nand->ecc.mode =NAND_ECC_SOFT ;#endif
Signature · 1 line
1.6.0.6
[U-Boot] [PATCH-ARM] Add support for Embest SBC2440-II Board 7/7
This patch adds support for the Embest SBC2440-II Board.
The patch was tested by:
- running MAKEALL for all ARM9 targets and checking that no new warnings or errors were introduced
- programming it into NOR flash of an Embest SBC2440-II Board, loading kernel and root file system images via ftp, programming them into NAND flash and checking that u-boot successfully starts the kernel at re-boot
--- MAINTAINERS | 4 + MAKEALL | 1 + Makefile | 3 + board/embest/sbc2440ii/Makefile | 55 +++++++ board/embest/sbc2440ii/config.mk | 25 ++++ board/embest/sbc2440ii/lowlevel_init.S | 219 ++++++++++++++++++++++++++++ board/embest/sbc2440ii/sbc2440ii.c | 109 ++++++++++++++ cpu/arm920t/s3c24x0/timer.c | 1 + include/configs/sbc2440ii.h | 247 ++++++++++++++++++++++++++++++++ 9 files changed, 664 insertions(+), 0 deletions(-) create mode 100644 board/embest/sbc2440ii/Makefile create mode 100644 board/embest/sbc2440ii/config.mk create mode 100644 board/embest/sbc2440ii/lowlevel_init.S create mode 100644 board/embest/sbc2440ii/sbc2440ii.c create mode 100644 include/configs/sbc2440ii.h
MAINTAINERS +4 -0
@@ -578,6 +578,10 @@ Nishanth Menon <[email protected]> omap3_zoom1 ARM CORTEX-A8 (OMAP3xx SoC) +Kevin Morfitt <[email protected]> + + sbc2440ii ARM920T + David M?ller <[email protected]> smdk2410 ARM920T
MAKEALL +1 -0
@@ -519,6 +519,7 @@ LIST_ARM9=" \ omap5912osk \ omap730p2 \ sbc2410x \ + sbc2440ii \ scb9328 \ smdk2400 \ smdk2410 \
Makefile +3 -0
@@ -2898,6 +2898,9 @@ omap730p2_cs3boot_config : unconfig sbc2410x_config: unconfig @$(MKCONFIG) $(@:_config=) arm arm920t sbc2410x NULL s3c24x0 +sbc2440ii_config: unconfig + @$(MKCONFIG) $(@:_config=) arm arm920t sbc2440ii embest s3c24x0 + scb9328_config : unconfig @$(MKCONFIG) $(@:_config=) arm arm920t scb9328 NULL imx
board/embest/sbc2440ii/Makefile new file +55 -0
55 lines not on this page · raw message
board/embest/sbc2440ii/config.mk new file +25 -0
@@ -0,0 +1,25 @@ +# +# (C) Copyright 2002 +# Gary Jennejohn, DENX Software Engineering, <[email protected]> +# David Mueller, ELSOFT AG, <[email protected]> +# +# SAMSUNG SMDK2410 board with S3C2410X (ARM920T) cpu +# +# see http://www.samsung.com/ for more information on SAMSUNG +# +# Modified for EMBEST SBC2440-II board with S3C2440 (ARM920T) cpu by: +# (C) Copyright 2009 +# Kevin Morfitt, Fearnside Systems Ltd, <[email protected]> + +# +# SBC2440-II has 1 bank of 64 MB DRAM +# +# 3000'0000 to 3800'0000 +# +# Linux-Kernel is expected to be at 3000'8000, entry 3000'8000 +# +# we load ourself to 33F8'0000 +# +# download area is 3000'0000 + +TEXT_BASE = 0x33F80000
board/embest/sbc2440ii/lowlevel_init.S new file +219 -0
219 lines not on this page · raw message
board/embest/sbc2440ii/sbc2440ii.c new file +109 -0
109 lines not on this page · raw message
cpu/arm920t/s3c24x0/timer.c +1 -0
@@ -187,6 +187,7 @@ ulong get_tbclk(void) tbclk = timer_load_val *100 ;#elif defined(CONFIG_SBC2410X ) || \ defined(CONFIG_SMDK2410 ) || \ + defined(CONFIG_SBC2440II ) || \ defined(CONFIG_VCMA9 ) tbclk =CONFIG_SYS_HZ ;#else
include/configs/sbc2440ii.h new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
1.6.0.6
[U-Boot] [PATCH-ARM] Add support for Embest SBC2440-II Board 7/7
Quoted 161 lines
+ * Modified for the Samsung SMDK2410 by
+ * (C) Copyright 2002
+ * David Mueller, ELSOFT AG, <[email protected]>
+ *
+ * Modified for the friendly-arm SBC-2410X by
+ * (C) Copyright 2005
+ * JinHua Luo, GuangDong Linux Center, <[email protected]>
+ *
+ * Modified for the Embest SBC2440-II by
+ * (C) Copyright 2009
+ * Kevin Morfitt, Fearnside Systems Ltd, <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */board/embest/sbc2440ii/lowlevel_init.S new file +131
-0+ +#include <config.h> +#include <version.h> + +/* + * Taken from linux/arch/arm/boot/compressed/head-s3c2410.S + * + * Copyright (C) 2002 Samsung Electronics SW.LEE <[email protected]> + */ + +#define BWSCON 0x48000000 + +#define DW8 (0x0) +#define DW16 (0x1) +#define DW32 (0x2) +#define WAIT (0x1 << 2) +#define UBLB (0x1 << 3) + +#define B1_BWSCON (DW16) +#define B2_BWSCON (DW16) +#define B3_BWSCON (DW16 + WAIT + UBLB) +#define B4_BWSCON (DW16) +#define B5_BWSCON (DW16) +#define B6_BWSCON (DW32) +#define B7_BWSCON (DW32) +#define BWSCON_VAL ((B1_BWSCON << 4) + (B2_BWSCON << 8) + \ + (B3_BWSCON << 12) + (B4_BWSCON << 16) + \ + (B5_BWSCON << 20) + (B6_BWSCON << 24) + \ + (B7_BWSCON << 28)) + +#define B0_TACS 0x0 +#define B0_TCOS 0x0 +#define B0_TACC 0x7 +#define B0_TCOH 0x0 +#define B0_TAH 0x0 +#define B0_TACP 0x0 +#define B0_PMC 0x0 +#define BANKCON0_VAL ((B0_TACS << 13) + (B0_TCOS << 11) + (B0_TACC << 8) + \ + (B0_TCOH << 6) + (B0_TAH << 4) + (B0_TACP << 2) + \ + B0_PMC) + +#define B1_TACS 0x0 +#define B1_TCOS 0x0 +#define B1_TACC 0x7 +#define B1_TCOH 0x0 +#define B1_TAH 0x0 +#define B1_TACP 0x0 +#define B1_PMC 0x0 +#define BANKCON1_VAL ((B1_TACS << 13) + (B1_TCOS << 11) + (B1_TACC << 8) + \ + (B1_TCOH << 6) + (B1_TAH << 4) + (B1_TACP << 2) + \ + B1_PMC) + +#define B2_TACS 0x0 +#define B2_TCOS 0x0 +#define B2_TACC 0x7 +#define B2_TCOH 0x0 +#define B2_TAH 0x0 +#define B2_TACP 0x0 +#define B2_PMC 0x0 +#define BANKCON2_VAL ((B2_TACS << 13) + (B2_TCOS << 11) + (B2_TACC << 8) + \ + (B2_TCOH << 6) + (B2_TAH << 4) + (B2_TACP << 2) + \ + B2_PMC) + +#define B3_TACS 0x0 /* 0clk */ +#define B3_TCOS 0x3 /* 4clk */ +#define B3_TACC 0x7 /* 14clk */ +#define B3_TCOH 0x1 /* 1clk */ +#define B3_TAH 0x3 /* 4clk */ +#define B3_TACP 0x3 /* 6clk */ +#define B3_PMC 0x0 /* 16data */ +#define BANKCON3_VAL ((B3_TACS << 13) + (B3_TCOS << 11) + (B3_TACC << 8) + \ + (B3_TCOH << 6) + (B3_TAH << 4) + (B3_TACP << 2) + \ + B3_PMC) + +#define B4_TACS 0x0 +#define B4_TCOS 0x0 +#define B4_TACC 0x7 +#define B4_TCOH 0x0 +#define B4_TAH 0x0 +#define B4_TACP 0x0 +#define B4_PMC 0x0 +#define BANKCON4_VAL ((B4_TACS << 13) + (B4_TCOS << 11) + (B4_TACC << 8) + \ + (B4_TCOH << 6) + (B4_TAH << 4) + (B4_TACP << 2) + \ + B4_PMC) + +#define B5_TACS 0x0 +#define B5_TCOS 0x0 +#define B5_TACC 0x7 +#define B5_TCOH 0x0 +#define B5_TAH 0x0 +#define B5_TACP 0x0 +#define B5_PMC 0x0 +#define BANKCON5_VAL ((B5_TACS << 13) + (B5_TCOS << 11) + (B5_TACC << 8) + \ + (B5_TCOH << 6) + (B5_TAH << 4) + (B5_TACP << 2) + \ + B5_PMC) + +#define B6_MT 0x3 /* SDRAM */ +#define B6_TRCD 0x2 +#define B6_SCAN 0x1 /* 9bit */ +#define BANKCON6_VAL ((B6_MT << 15) + (B6_TRCD << 2) + B6_SCAN) + +#define B7_MT 0x3 /* SDRAM */ +#define B7_TRCD 0x2 /* 4clk */ +#define B7_SCAN 0x1 /* 9bit */ +#define BANKCON7_VAL ((B7_MT << 15) + (B7_TRCD << 2) + B7_SCAN) + +/* REFRESH parameter */ +#define REFEN 0x1 /* Refresh enable */ +#define TREFMD 0x0 /* CBR(CAS before RAS)/Auto refresh */ +#define TRP 0x0 /* 2clk */ +#define TRC 0x3 /* 7clk */ +#define TCHR 0x2 /* 3clk */ +#define REFCNT 1259 +#define REFRESH_VAL ((REFEN << 23) + (TREFMD << 22) + (TRP << 20) + \ + (TRC << 18) + (TCHR << 16) + REFCNT) + +/* BANKSIZE parameter */ +#define BURST_EN 1 /* Enable burst mode */ +#define SCKE_EN 1 /* Enable SDRAM power-down mode */ +#define SCLK_EN 1 /* SCLK is active only during the access */ +#define BK67MAP 2 /* 128M/128M */ +#define BANKSIZE_VAL ((BURST_EN << 7) + (SCKE_EN << 5) + \ + (SCLK_EN << 4) + BK67MAP) + +/* MRSRB6 parameter */ +#define WBL6 0 /* Burst */ +#define TM6 0 /* Modem register set */ +#define CL6 3 /* Latency is 3 clocks */ +#define BT6 0 /* Sequential */ +#define BL6 0 +#define MRSRB6_VAL ((WBL6 << 9) + (TM6 << 7) + (CL6 << 4) + \
board/embest/sbc2440ii/lowlevel_init.S line 177
Quoted 10 lines
board/embest/sbc2440ii/lowlevel_init.S new file +10
-0+ (BT6 << 3) + BL6) + +/* MRSRB7 parameter */ +#define WBL7 0 /* Burst */ +#define TM7 0 /* Modem register set */ +#define CL7 3 /* Latency is 3 clocks */ +#define BT7 0 /* Sequential */ +#define BL7 0 +#define MRSRB7_VAL ((WBL7 << 9) + (TM7 << 7) + (CL7 << 4) + \ + (BT7 << 3) + BL7)
please clean this define
please make then more generic
by moving soc macro to a propoper header and board config to board config header
Best Regards,
J.