Skip to contentSkip to conversation

Add support for the Embest SBC2440-II Board

PATCH New kevin.morfitt at fearnside-systems.co.uk 4 participants 12 messages Jun 19, 2009 – Jun 23, 2009

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

This is the first of two patches that will add support for the Embest SBC2440-II Board. This one adds generic support for the S3C2440 CPU. Tested by running MAKEALL for ARM9 boards - no new warnings or errors were found.

This patch set assumes that the following patches have already been applied:

- Clean-up of ARM920T S3C24x0 code, submitted on 5th June
- Clean-up of ARM920T S3C24x0 drivers code, submitted on 5th June
- Bug-fix in drivers mtd nand Makefile, submitted on 18th June

---
 common/serial.c                 |    4 +-
 cpu/arm920t/s3c24x0/speed.c     |   38 ++++++-
 cpu/arm920t/s3c24x0/timer.c     |    8 +-
 cpu/arm920t/s3c24x0/usb.c       |    9 +-
 cpu/arm920t/start.S             |   29 ++++-
 drivers/i2c/s3c24x0_i2c.c       |   12 +-
 drivers/mtd/nand/Makefile       |    1 +
 drivers/mtd/nand/s3c2410_nand.c |    8 +-
 drivers/mtd/nand/s3c2440_nand.c |  241 +++++++++++++++++++++++++++++++++++++++
 drivers/rtc/s3c24x0_rtc.c       |    2 +
 drivers/serial/serial_s3c24x0.c |    2 +
 include/common.h                |    3 +-
 include/s3c2440.h               |  232 +++++++++++++++++++++++++++++++++++++
 include/s3c24x0.h               |  186 +++++++++++++++++++++++++++++-
 14 files changed, 745 insertions(+), 30 deletions(-)
 create mode 100644 drivers/mtd/nand/s3c2440_nand.c
 create mode 100644 include/s3c2440.h
common/serial.c +2 -2
index dd80e7c..6548b8b 100644
@@ -58,7 +58,7 @@ struct serial_device *__default_serial_console (void)
 #else
 		return &serial0_device;
 #endif
-#elif defined(CONFIG_S3C2410)
+#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 #if defined(CONFIG_SERIAL1)
 	return &s3c24xx_serial0_device;
 #elif defined(CONFIG_SERIAL2)
@@ -133,7 +133,7 @@ void serial_initialize (void)
 #if defined (CONFIG_STUART)
 	serial_register(&serial_stuart_device);
 #endif
-#if defined(CONFIG_S3C2410)
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 	serial_register(&s3c24xx_serial0_device);
 	serial_register(&s3c24xx_serial1_device);
 	serial_register(&s3c24xx_serial2_device);
cpu/arm920t/s3c24x0/speed.c +35 -3
index 3d7c8cf..b8b183e 100644
@@ -30,7 +30,8 @@
  */
 
 #include <common.h>
-#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
+#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || \
+    defined(CONFIG_S3C2440) || defined(CONFIG_TRAB)
 
 #include <asm/io.h>
 
@@ -38,6 +39,8 @@
 #include <s3c2400.h>
 #elif defined(CONFIG_S3C2410)
 #include <s3c2410.h>
+#elif defined(CONFIG_S3C2440)
+#include <s3c2440.h>
 #endif
 
 #define MPLL 0
@@ -69,6 +72,11 @@ static ulong get_PLLCLK(int pllreg)
 	p = ((r & 0x003F0) >> 4) + 2;
 	s = r & 0x3;
 
+#ifdef CONFIG_S3C2440
+	if (pllreg == MPLL)
+		return (2 * CONFIG_SYS_CLK_FREQ * m) / (p << s);
+	else
+#endif
 	return (CONFIG_SYS_CLK_FREQ * m) / (p << s);
 }
 
@@ -83,7 +91,23 @@ ulong get_HCLK(void)
 {
 	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
 
+#ifdef CONFIG_S3C2440
+	switch (clk_power->CLKDIVN & 0x6) {
+	default:
+	case 0:
+		return get_FCLK();
+	case 2:
+		return get_FCLK() / 2;
+	case 4:
+		return (readl(&clk_power->CAMDIVN) & (1 << 9)) ?
+			get_FCLK() / 8 : get_FCLK() / 4;
+	case 6:
+		return (readl(&clk_power->CAMDIVN) & (1 << 8)) ?
+			get_FCLK() / 6 : get_FCLK() / 3;
+	}
+#else
 	return (readl(&clk_power->CLKDIVN) & 2) ? get_FCLK() / 2 : get_FCLK();
+#endif
 }
 
 /* return PCLK frequency */
@@ -97,9 +121,17 @@ ulong get_PCLK(void)
 /* return UCLK frequency */
 ulong get_UCLK(void)
 {
+#ifdef CONFIG_S3C2440
+	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
+
+	return (readl(&clk_power->CLKDIVN) & (1 << 3)) ?
+		get_PLLCLK(UPLL) / 2 : get_PLLCLK(UPLL);
+#else
 	return get_PLLCLK(UPLL);
+#endif
 }
 
 #endif /* defined(CONFIG_S3C2400) ||
-			  defined (CONFIG_S3C2410) ||
-			  defined (CONFIG_TRAB) */
+	  defined (CONFIG_S3C2410) ||
+	  defined (CONFIG_S3C2440) ||
+	  defined (CONFIG_TRAB) */
cpu/arm920t/s3c24x0/timer.c +6 -2
index a5a784c..0f6b580 100644
@@ -32,6 +32,7 @@
 #include <common.h>
 #if defined(CONFIG_S3C2400)  || \
     defined(CONFIG_S3C2410)  || \
+    defined(CONFIG_S3C2440)  || \
     defined(CONFIG_TRAB)
 
 #include <asm/io.h>
@@ -40,6 +41,8 @@
 #include <s3c2400.h>
 #elif defined(CONFIG_S3C2410)
 #include <s3c2410.h>
+#elif defined(CONFIG_S3C2440)
+#include <s3c2440.h>
 #endif
 
 int timer_load_val = 0;
@@ -230,5 +233,6 @@ void s3c2410_irq(void)
 #endif /* USE_IRQ */
 
 #endif /* defined(CONFIG_S3C2400)  ||
-			  defined (CONFIG_S3C2410) ||
-			  defined (CONFIG_TRAB) */
+	  defined (CONFIG_S3C2410) ||
+	  defined(CONFIG_S3C2440)  || \
+	  defined (CONFIG_TRAB) */
cpu/arm920t/s3c24x0/usb.c +7 -2
index c2d2f70..b05520d 100644
@@ -24,12 +24,16 @@
 #include <common.h>
 
 #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
-# if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
+# if defined(CONFIG_S3C2400) || \
+     defined(CONFIG_S3C2410) || \
+     defined(CONFIG_S3C2440)
 
 #if defined(CONFIG_S3C2400)
 # include <s3c2400.h>
 #elif defined(CONFIG_S3C2410)
 # include <s3c2410.h>
+#elif defined(CONFIG_S3C2440)
+# include <s3c2440.h>
 #endif
 
 #include <asm/io.h>
@@ -70,5 +74,6 @@ int usb_cpu_init_fail(void)
 	return 0;
 }
 
-# endif	/* defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) */
+# endif	/* defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) ||
+	   defined(CONFIG_S3C2440))*/
 #endif /* defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */
cpu/arm920t/start.S +23 -6
index 810d402..5f7aa33 100644
@@ -132,8 +132,9 @@ copyex:
 	bne	copyex
 #endif
 
-#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
-	/* turn off the watchdog */
+#if defined(CONFIG_S3C2400) || \
+    defined(CONFIG_S3C2410) || \
+    defined(CONFIG_S3C2440)
 
 # if defined(CONFIG_S3C2400)
 #  define pWTCON	0x15300000
@@ -146,6 +147,15 @@ copyex:
 #  define CLKDIVN	0x4C000014	/* clock divisor register */
 # endif
 
+# if defined(CONFIG_S3C2440)
+#  define INTSMASK  0xffff
+#  define CLKDIVVAL 0x5
+#else
+#  define INTSMASK  0x3ff
+#  define CLKDIVVAL 0x3
+# endif
+
+	/* turn off the watchdog */
 	ldr	r0, =pWTCON
 	mov	r1, #0x0
 	str	r1, [r0]
@@ -156,8 +166,8 @@ copyex:
 	mov	r1, #0xffffffff
 	ldr	r0, =INTMSK
 	str	r1, [r0]
-# if defined(CONFIG_S3C2410)
-	ldr	r1, =0x3ff
+# if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
+	ldr	r1, =INTSMASK
 	ldr	r0, =INTSUBMSK
 	str	r1, [r0]
 # endif
@@ -165,9 +175,16 @@ copyex:
 	/* FCLK:HCLK:PCLK = 1:2:4 */
 	/* default FCLK is 120 MHz ! */
 	ldr	r0, =CLKDIVN
-	mov	r1, #3
+	mov	r1, #CLKDIVVAL
 	str	r1, [r0]
-#endif	/* CONFIG_S3C2400 || CONFIG_S3C2410 */
+
+#ifdef CONFIG_S3C2440
+	/* Set asynchronous bus mode */
+	mrc	p15, 0, r1, c1, c0, 0   /* read ctrl register */
+	orr	r1, r1, #0xc0000000     /* Asynchronous */
+	mcr	p15, 0, r1, c1, c0, 0   /* write ctrl register */
+#endif  /* CONFIG_S3C2440 */
+#endif  /* CONFIG_S3C2400 || CONFIG_S3C2410 || CONFIG_S3C2440 */
 
 	/*
 	 * we do sys-critical inits only at reboot,
drivers/i2c/s3c24x0_i2c.c +7 -5
index 33cd3d4..f0647fb 100644
@@ -31,6 +31,8 @@
 #include <s3c2400.h>
 #elif defined(CONFIG_S3C2410)
 #include <s3c2410.h>
+#elif defined(CONFIG_S3C2440)
+#include <s3c2440.h>
 #endif
 
 #include <asm/io.h>
@@ -61,7 +63,7 @@ static int GetI2CSDA(void)
 {
 	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 	return (readl(&gpio->GPEDAT) & 0x8000) >> 15;
 #endif
 #ifdef CONFIG_S3C2400
@@ -80,7 +82,7 @@ static void SetI2CSCL(int x)
 {
 	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
 
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 	writel((readl(&gpio->GPEDAT) & ~0x4000) | (x & 1) << 14, &gpio->GPEDAT);
 #endif
 #ifdef CONFIG_S3C2400
@@ -132,7 +134,7 @@ void i2c_init(int speed, int slaveadd)
 	}
 
 	if ((readl(&i2c->IICSTAT) & I2CSTAT_BSY) || GetI2CSDA() == 0) {
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 		ulong old_gpecon = readl(&gpio->GPECON);
 #endif
 #ifdef CONFIG_S3C2400
@@ -141,7 +143,7 @@ void i2c_init(int speed, int slaveadd)
 		/* bus still busy probably by (most) previously interrupted
 		   transfer */
 
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 		/* set I2CSDA and I2CSCL (GPE15, GPE14) to GPIO */
 		writel((readl(&gpio->GPECON) & ~0xF0000000) | 0x10000000,
 		       &gpio->GPECON);
@@ -167,7 +169,7 @@ void i2c_init(int speed, int slaveadd)
 		udelay(1000);
 
 		/* restore pin functions */
-#ifdef CONFIG_S3C2410
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 		writel(old_gpecon, &gpio->GPECON);
 #endif
 #ifdef CONFIG_S3C2400
drivers/mtd/nand/Makefile +1 -0
index 7dfbeb5..e8740fc 100644
@@ -43,6 +43,7 @@ COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o
 COBJS-$(CONFIG_NAND_MPC5121_NFC) += mpc5121_nfc.o
 COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o
+COBJS-$(CONFIG_NAND_S3C2440) += s3c2440_nand.o
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
 endif
drivers/mtd/nand/s3c2410_nand.c +4 -4
index 60bfd10..b93787c 100644
@@ -36,7 +36,7 @@
 static void s3c2410_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
 	struct nand_chip *chip = mtd->priv;
-	S3C24X0_NAND * const nand = S3C24X0_GetBase_NAND();
+	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
 
 	debugX(1, "hwcontrol(): 0x%02x 0x%02x\n", cmd, ctrl);
 
@@ -64,7 +64,7 @@ static void s3c2410_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 
 static int s3c2410_dev_ready(struct mtd_info *mtd)
 {
-	S3C24X0_NAND * const nand = S3C24X0_GetBase_NAND();
+	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
 
 	debugX(1, "dev_ready\n");
 	return readl(&nand->NFSTAT) & 0x01;
@@ -82,7 +82,7 @@ void s3c2410_nand_enable_hwecc(struct mtd_info *mtd, int mode)
 static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
 				      u_char *ecc_code)
 {
-	S3C24X0_NAND * const nand = S3C24X0_GetBase_NAND();
+	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
 	unsigned long ecc = readl(&nand->NFECC);
 
 	ecc_code[0] = ecc;
@@ -112,7 +112,7 @@ int board_nand_init(struct nand_chip *nand)
 	u_int32_t cfg;
 	u_int8_t tacls, twrph0, twrph1;
 	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
-	S3C24X0_NAND * const nand_reg = S3C24X0_GetBase_NAND();
+	S3C2410_NAND * const nand_reg = S3C2410_GetBase_NAND();
 
 	debugX(1, "board_nand_init()\n");
 
drivers/mtd/nand/s3c2440_nand.c new file +241 -0

241 lines not on this page · raw message

drivers/rtc/s3c24x0_rtc.c +2 -0
index f8e1111..9cdceae 100644
@@ -34,6 +34,8 @@
 #include <s3c2400.h>
 #elif defined(CONFIG_S3C2410)
 #include <s3c2410.h>
+#elif defined(CONFIG_S3C2440)
+#include <s3c2440.h>
 #endif
 
 #include <rtc.h>
drivers/serial/serial_s3c24x0.c +2 -0
index af77db8..f883c7d 100644
@@ -23,6 +23,8 @@
 #include <s3c2400.h>
 #elif defined(CONFIG_S3C2410)
 #include <s3c2410.h>
+#elif defined(CONFIG_S3C2440)
+#include <s3c2440.h>
 #endif
 
 DECLARE_GLOBAL_DATA_PTR;
include/common.h +2 -1
index ff4f821..a48c60e 100644
@@ -492,7 +492,8 @@ ulong	get_OPB_freq (void);
 ulong	get_PCI_freq (void);
 #endif
 #if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || \
-	defined(CONFIG_LH7A40X) || defined(CONFIG_S3C6400)
+    defined(CONFIG_LH7A40X) || defined(CONFIG_S3C6400) || \
+    defined(CONFIG_S3C2440)
 void	s3c2410_irq(void);
 #define ARM920_IRQ_CALLBACK s3c2410_irq
 ulong	get_FCLK (void);
include/s3c2440.h new file +232 -0

232 lines not on this page · raw message

include/s3c24x0.h +181 -5

247 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#1 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

Dear "kevin.morfitt at fearnside-systems.co.uk",

Quoted 11 lines · In message <[email protected]> you wrote:

This is the first of two patches that will add support for the Embest SBC2440-II Board. This one adds generic support for the S3C2440 CPU. Tested by running MAKEALL for ARM9 boards - no new warnings or errors were found.

This patch set assumes that the following patches have already been applied:

- Clean-up of ARM920T S3C24x0 code, submitted on 5th June
- Clean-up of ARM920T S3C24x0 drivers code, submitted on 5th June
- Bug-fix in drivers mtd nand Makefile, submitted on 18th June

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Monday is an awful way to spend one seventh of your life.
#2 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

In reply to kevin.morfitt at fearnside-systems.co.uk
Quoted 21 lines · kevin.morfitt at fearnside-systems.co.uk

This is the first of two patches that will add support for the Embest SBC2440-II Board. This one adds generic support for the S3C2440 CPU. Tested by running MAKEALL for ARM9 boards - no new warnings or errors were found.

This patch set assumes that the following patches have already been applied:

- Clean-up of ARM920T S3C24x0 code, submitted on 5th June
- Clean-up of ARM920T S3C24x0 drivers code, submitted on 5th June
- Bug-fix in drivers mtd nand Makefile, submitted on 18th June

---
 common/serial.c                 |    4 +-
 cpu/arm920t/s3c24x0/speed.c     |   38 ++++++-
 cpu/arm920t/s3c24x0/timer.c     |    8 +-
 cpu/arm920t/s3c24x0/usb.c       |    9 +-
 cpu/arm920t/start.S             |   29 ++++-
 drivers/i2c/s3c24x0_i2c.c       |   12 +-
 drivers/mtd/nand/Makefile       |    1 +
 drivers/mtd/nand/s3c2410_nand.c |    8 +-
 drivers/mtd/nand/s3c2440_nand.c |  241 +++++++++++++++++++++++++++++++++++++++
Quoted 8 lines
 drivers/rtc/s3c24x0_rtc.c       |    2 +
 drivers/serial/serial_s3c24x0.c |    2 +
 include/common.h                |    3 +-
 include/s3c2440.h               |  232 +++++++++++++++++++++++++++++++++++++
 include/s3c24x0.h               |  186 +++++++++++++++++++++++++++++-
 14 files changed, 745 insertions(+), 30 deletions(-)
 create mode 100644 drivers/mtd/nand/s3c2440_nand.c
 create mode 100644 include/s3c2440.h

first general comment

Please split this patch as something like this
patch 1 add the s3c24x0 support
patch 2 add the nand
patch 3 your boards

common/serial.c struct serial_device *__default_serial_console (void) · line 61

Quoted 11 lines
common/serial.c +1 -1
index dd80e7c..6548b8b 100644
@@ -58,7 +58,7 @@ struct serial_device *__default_serial_console (void)
 #else
 		return &serial0_device;
 #endif
-#elif defined(CONFIG_S3C2410)
+#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)

if it's really s3c24x0 please use a correspondig macro IIRC yes

common/serial.c void serial_initialize (void) · line 136

Quoted 9 lines
common/serial.c +1 -1
 #if defined(CONFIG_SERIAL1)
 	return &s3c24xx_serial0_device;
 #elif defined(CONFIG_SERIAL2)
@@ -133,7 +133,7 @@ void serial_initialize (void)
 #if defined (CONFIG_STUART)
 	serial_register(&serial_stuart_device);
 #endif
-#if defined(CONFIG_S3C2410)
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)

ditto

Quoted 18 lines
common/serial.c +0 -0
 	serial_register(&s3c24xx_serial0_device);
 	serial_register(&s3c24xx_serial1_device);
 	serial_register(&s3c24xx_serial2_device);
cpu/arm920t/s3c24x0/speed.c +2 -1
index 3d7c8cf..b8b183e 100644
@@ -30,7 +30,8 @@
  */
 
 #include <common.h>
-#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
+#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || \
+    defined(CONFIG_S3C2440) || defined(CONFIG_TRAB)
 
 #include <asm/io.h>
 

cpu/arm920t/s3c24x0/speed.c line 44

Quoted 6 lines
cpu/arm920t/s3c24x0/speed.c +2 -0
@@ -38,6 +39,8 @@
 #include <s3c2400.h>
 #elif defined(CONFIG_S3C2410)
 #include <s3c2410.h>
+#elif defined(CONFIG_S3C2440)
+#include <s3c2440.h>
 #endif

please create a cpu.h file to avoid those ifdef

Quoted 44 lines
cpu/arm920t/s3c24x0/speed.c +21 -0
 #define MPLL 0
@@ -69,6 +72,11 @@ static ulong get_PLLCLK(int pllreg)
 	p = ((r & 0x003F0) >> 4) + 2;
 	s = r & 0x3;
 
+#ifdef CONFIG_S3C2440
+	if (pllreg == MPLL)
+		return (2 * CONFIG_SYS_CLK_FREQ * m) / (p << s);
+	else
+#endif
 	return (CONFIG_SYS_CLK_FREQ * m) / (p << s);
 }
 
@@ -83,7 +91,23 @@ ulong get_HCLK(void)
 {
 	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
 
+#ifdef CONFIG_S3C2440
+	switch (clk_power->CLKDIVN & 0x6) {
+	default:
+	case 0:
+		return get_FCLK();
+	case 2:
+		return get_FCLK() / 2;
+	case 4:
+		return (readl(&clk_power->CAMDIVN) & (1 << 9)) ?
+			get_FCLK() / 8 : get_FCLK() / 4;
+	case 6:
+		return (readl(&clk_power->CAMDIVN) & (1 << 8)) ?
+			get_FCLK() / 6 : get_FCLK() / 3;
+	}
+#else
 	return (readl(&clk_power->CLKDIVN) & 2) ? get_FCLK() / 2 : get_FCLK();
+#endif
 }
 
 
cpu/arm920t/start.S +0 -0
index 810d402..5f7aa33 100644

cpu/arm920t/start.S copyex: · line 138

Quoted 9 lines
cpu/arm920t/start.S +3 -2
@@ -132,8 +132,9 @@ copyex:
 	bne	copyex
 #endif
 
-#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
-	/* turn off the watchdog */
+#if defined(CONFIG_S3C2400) || \
+    defined(CONFIG_S3C2410) || \
+    defined(CONFIG_S3C2440)
 

please move this code to cpu/arm920t/s3c24x0/

the start.S need to generic but you can call arch code from it a branch or if not possible a assembly macro

please call it arch_pre_lowlevel_init
tks

Quoted 20 lines
cpu/arm920t/start.S +9 -0
 # if defined(CONFIG_S3C2400)
 #  define pWTCON	0x15300000
@@ -146,6 +147,15 @@ copyex:
 #  define CLKDIVN	0x4C000014	/* clock divisor register */
 # endif
 
+# if defined(CONFIG_S3C2440)
+#  define INTSMASK  0xffff
+#  define CLKDIVVAL 0x5
+#else
+#  define INTSMASK  0x3ff
+#  define CLKDIVVAL 0x3
+# endif
+
+	/* turn off the watchdog */
 	ldr	r0, =pWTCON
 	mov	r1, #0x0
 	str	r1, [r0]
@@ -156,8 +166,8 @@ copyex:

<snip>

cpu/arm920t/start.S

Quoted 12 lines
cpu/arm920t/start.S +12 -0
+
+/* AC97 INTERFACE (see S3C2440 manual chapter 24) */
+typedef struct {
+	S3C24X0_REG32 ACGLBCTRL;
+	S3C24X0_REG32 ACGLBSTAT;
+	S3C24X0_REG32 AC_CODEC_CMD;
+	S3C24X0_REG32 AC_CODEC_STAT;
+	S3C24X0_REG32 AC_PCMADDR;
+	S3C24X0_REG32 AC_MICADDR;
+	S3C24X0_REG32 AC_PCMDATA;
+	S3C24X0_REG32 AC_MICDATA;
+} /*__attribute__((__packed__))*/ S3C2440_AC97;

if no need please remove

Best Regards,
J.

#3 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

Hi Jean-Christophe, comments below:

Also, see note at the end regarding re-structuring of the existing s3c24x0 and
Embest SBC2440-II Board patches.

Quoted 32 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 21 lines · kevin.morfitt at fearnside-systems.co.uk

This is the first of two patches that will add support for the Embest SBC2440-II Board. This one adds generic support for the S3C2440 CPU. Tested by running MAKEALL for ARM9 boards - no new warnings or errors were found.

This patch set assumes that the following patches have already been applied:

- Clean-up of ARM920T S3C24x0 code, submitted on 5th June
- Clean-up of ARM920T S3C24x0 drivers code, submitted on 5th June
- Bug-fix in drivers mtd nand Makefile, submitted on 18th June

---
 common/serial.c                 |    4 +-
 cpu/arm920t/s3c24x0/speed.c     |   38 ++++++-
 cpu/arm920t/s3c24x0/timer.c     |    8 +-
 cpu/arm920t/s3c24x0/usb.c       |    9 +-
 cpu/arm920t/start.S             |   29 ++++-
 drivers/i2c/s3c24x0_i2c.c       |   12 +-
 drivers/mtd/nand/Makefile       |    1 +
 drivers/mtd/nand/s3c2410_nand.c |    8 +-
 drivers/mtd/nand/s3c2440_nand.c |  241 +++++++++++++++++++++++++++++++++++++++
Quoted 9 lines
 drivers/rtc/s3c24x0_rtc.c       |    2 +
 drivers/serial/serial_s3c24x0.c |    2 +
 include/common.h                |    3 +-
 include/s3c2440.h               |  232 +++++++++++++++++++++++++++++++++++++
 include/s3c24x0.h               |  186 +++++++++++++++++++++++++++++-
 14 files changed, 745 insertions(+), 30 deletions(-)
 create mode 100644 drivers/mtd/nand/s3c2440_nand.c
 create mode 100644 include/s3c2440.h
Quoted 7 lines

first general comment

Please split this patch as something like this
patch 1 add the s3c24x0 support
patch 2 add the nand
patch 3 your boards

s3c24x0 refers to the Samsung s3c type of cpu's - s3c2400, s3c2410 and s3c2440.
Support for the s3c2400 and s3c2410 cpu's already exists in the current u-boot
code base in cpu/arm920t/s3c24x0 but there is currently no support for the s3c2440 cpu.

However, the format of the current s3c24x0 code doesn't meet the u-boot coding
style so I've already submitted 2 patches to clean up the current s3c24x0 code
- see reference at the top of this patch to the patches "Clean-up of ARM920T
S3C24x0 code, submitted on 5th June" and "Clean-up of ARM920T S3C24x0 drivers
code, submitted on 5th June".

This patch, 1/2, just adds support for the s3c2440 cpu (including the new s3c2440 NAND driver) to the current s3c24x0 code - it doesn't actually add the
Embest SBC2440-II Board support. Patch 2/2 is the one that adds the support for
the Embest SBC2440-II Board itself.

So, the patches are already structured as you requested.

It's getting a bit complicated because I initially sent a patch to add all of
the Embest SBC2440-II Board changes in one go. Wolfgang and yourself asked me
to create patches to clean up the existing code base first and to add the s3c2440 support separately to the Embest SBC2440-II Board so I now have 4 patches all dependent on one another and it's not too clear how they fit together.

Quoted 4 lines
Quoted 4 lines
common/serial.c +0 -0
index dd80e7c..6548b8b 100644
Quoted 9 lines

common/serial.c struct serial_device *__default_serial_console (void) · line 62

Quoted 7 lines
common/serial.c +1 -1
@@ -58,7 +58,7 @@ struct serial_device *__default_serial_console (void)
 #else
 		return &serial0_device;
 #endif
-#elif defined(CONFIG_S3C2410)
+#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 

if it's really s3c24x0 please use a correspondig macro IIRC yes

Could you explain a bit more about how the macro would work please?

Quoted 29 lines

common/serial.c void serial_initialize (void) · line 137

Quoted 10 lines
common/serial.c +0 -0
 #if defined(CONFIG_SERIAL1)
 	return &s3c24xx_serial0_device;

#elif defined(CONFIG_SERIAL2)

common/serial.c +1 -1
@@ -133,7 +133,7 @@ void serial_initialize (void)
 #if defined (CONFIG_STUART)
 	serial_register(&serial_stuart_device);
 #endif
-#if defined(CONFIG_S3C2410)
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 

ditto

Quoted 17 lines
common/serial.c +0 -0
 	serial_register(&s3c24xx_serial0_device);
 	serial_register(&s3c24xx_serial1_device);
common/serial.c +0 -0
 	serial_register(&s3c24xx_serial2_device);
cpu/arm920t/s3c24x0/speed.c +2 -1
index 3d7c8cf..b8b183e 100644
@@ -30,7 +30,8 @@
  */
 
 #include <common.h>
-#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
+#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || \
+    defined(CONFIG_S3C2440) || defined(CONFIG_TRAB)
 
 #include <asm/io.h>
 
Quoted 10 lines

cpu/arm920t/s3c24x0/speed.c line 45

Quoted 8 lines
cpu/arm920t/s3c24x0/speed.c +2 -0
@@ -38,6 +39,8 @@
 #include <s3c2400.h>
 #elif defined(CONFIG_S3C2410)
 #include <s3c2410.h>
+#elif defined(CONFIG_S3C2440)
+#include <s3c2440.h>
 #endif
 

please create a cpu.h file to avoid those ifdef

OK. There is already an s3c24x0.h header file so I could modify it to include
the correct s3c2400.h, s3c2410.h or s3c2440.h header file.

Quoted 58 lines
Quoted 46 lines
cpu/arm920t/s3c24x0/speed.c +21 -0
 #define MPLL 0
@@ -69,6 +72,11 @@ static ulong get_PLLCLK(int pllreg)
 	p = ((r & 0x003F0) >> 4) + 2;
 	s = r & 0x3;
 
+#ifdef CONFIG_S3C2440
+	if (pllreg == MPLL)
+		return (2 * CONFIG_SYS_CLK_FREQ * m) / (p << s);
+	else
+#endif
 	return (CONFIG_SYS_CLK_FREQ * m) / (p << s);
 }
 
@@ -83,7 +91,23 @@ ulong get_HCLK(void)
 {
 	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
 
+#ifdef CONFIG_S3C2440
+	switch (clk_power->CLKDIVN & 0x6) {
+	default:
+	case 0:
+		return get_FCLK();
+	case 2:
+		return get_FCLK() / 2;
+	case 4:
+		return (readl(&clk_power->CAMDIVN) & (1 << 9)) ?
+			get_FCLK() / 8 : get_FCLK() / 4;
+	case 6:
+		return (readl(&clk_power->CAMDIVN) & (1 << 8)) ?
+			get_FCLK() / 6 : get_FCLK() / 3;
+	}
+#else
 	return (readl(&clk_power->CLKDIVN) & 2) ? get_FCLK() / 2 : get_FCLK();
+#endif
 }
 
 
cpu/arm920t/start.S +0 -0
index 810d402..5f7aa33 100644

cpu/arm920t/start.S copyex: · line 139

Quoted 10 lines
cpu/arm920t/start.S +3 -2
@@ -132,8 +132,9 @@ copyex:
 	bne	copyex
 #endif
 
-#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
-	/* turn off the watchdog */
+#if defined(CONFIG_S3C2400) || \
+    defined(CONFIG_S3C2410) || \
+    defined(CONFIG_S3C2440)
 
 

please move this code to cpu/arm920t/s3c24x0/

Quoted 6 lines

the start.S need to generic but you can call arch code from it a branch or if not possible a assembly macro

please call it arch_pre_lowlevel_init
tks

OK. I can do something similar to the existing arch-specific 'lowlevel_init'
function call.

Quoted 26 lines
Quoted 24 lines
cpu/arm920t/start.S +0 -0
 # if defined(CONFIG_S3C2400)

# define pWTCON 0x15300000

cpu/arm920t/start.S +9 -0
@@ -146,6 +147,15 @@ copyex:
 #  define CLKDIVN	0x4C000014	/* clock divisor register */
 # endif
 
+# if defined(CONFIG_S3C2440)
+#  define INTSMASK  0xffff
+#  define CLKDIVVAL 0x5
+#else
+#  define INTSMASK  0x3ff
+#  define CLKDIVVAL 0x3
+# endif
+
+	/* turn off the watchdog */
 	ldr	r0, =pWTCON
 	mov	r1, #0x0
 	str	r1, [r0]
@@ -156,8 +166,8 @@ copyex:
 

<snip>

Quoted 15 lines

cpu/arm920t/start.S

Quoted 13 lines
cpu/arm920t/start.S +12 -0
+
+/* AC97 INTERFACE (see S3C2440 manual chapter 24) */
+typedef struct {
+	S3C24X0_REG32 ACGLBCTRL;
+	S3C24X0_REG32 ACGLBSTAT;
+	S3C24X0_REG32 AC_CODEC_CMD;
+	S3C24X0_REG32 AC_CODEC_STAT;
+	S3C24X0_REG32 AC_PCMADDR;
+	S3C24X0_REG32 AC_MICADDR;
+	S3C24X0_REG32 AC_PCMDATA;
+	S3C24X0_REG32 AC_MICDATA;
+} /*__attribute__((__packed__))*/ S3C2440_AC97;

if no need please remove

OK. The ADC isn't used either so I'll remove that as well.

Wolfgang has also asked me to make the CONFIG_SYS_HZ change in the current s3c2400 and s3c2410 boards before I add support for the s3c2440. I've already
submitted 5 patches as part of the s3c24x0 clean up and Embest SBC2440-II Board
so this would make a 6th and it's getting difficult to track them all.

If you agree, I'd like to withdraw the following patches for now as they all
need changes:

- [U-Boot] [PATCH-ARM] Clean-up of ARM920T S3C24x0 code, submitted on 5th June
- [U-Boot] [PATCH-ARM] Clean-up of ARM920T S3C24x0 drivers code, submitted on
5th June
- [U-Boot] [PATCH-ARM 1/2] Add support for the Embest SBC2440-II Board (ie this
patch)
- [U-Boot] [PATCH-ARM 2/2] Add support for the Embest SBC2440-II Board, submitted on 19th June

I'll create the new CONFIG_SYS_HZ patch and submit it, then make the required
changes to the 4 patches above, then re-submit these 4 together, probably marked 1/4, 2/4, 3/4 and 4/4, all version 2.

However, the following patch doesn't need any changes so I'd like to leave it
out for comment:

- [U-Boot] [PATCH-ARM] Bug-fix in drivers mtd nand Makefile, submitted on 18th
June

Best Regards
Kevin

Quoted 13 lines

Best Regards,
J.

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4173 (20090620) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4174 (20090620) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

#4 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

Quoted 63 lines · kevin.morfitt at fearnside-systems.co.uk

Hi Jean-Christophe, comments below:

Also, see note at the end regarding re-structuring of the existing s3c24x0 and
Embest SBC2440-II Board patches.

Quoted 32 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 21 lines · kevin.morfitt at fearnside-systems.co.uk

This is the first of two patches that will add support for the Embest SBC2440-II Board. This one adds generic support for the S3C2440 CPU. Tested by running MAKEALL for ARM9 boards - no new warnings or errors were found.

This patch set assumes that the following patches have already been applied:

- Clean-up of ARM920T S3C24x0 code, submitted on 5th June
- Clean-up of ARM920T S3C24x0 drivers code, submitted on 5th June
- Bug-fix in drivers mtd nand Makefile, submitted on 18th June

---
 common/serial.c                 |    4 +-
 cpu/arm920t/s3c24x0/speed.c     |   38 ++++++-
 cpu/arm920t/s3c24x0/timer.c     |    8 +-
 cpu/arm920t/s3c24x0/usb.c       |    9 +-
 cpu/arm920t/start.S             |   29 ++++-
 drivers/i2c/s3c24x0_i2c.c       |   12 +-
 drivers/mtd/nand/Makefile       |    1 +
 drivers/mtd/nand/s3c2410_nand.c |    8 +-
 drivers/mtd/nand/s3c2440_nand.c |  241 +++++++++++++++++++++++++++++++++++++++
Quoted 9 lines
 drivers/rtc/s3c24x0_rtc.c       |    2 +
 drivers/serial/serial_s3c24x0.c |    2 +
 include/common.h                |    3 +-
 include/s3c2440.h               |  232 +++++++++++++++++++++++++++++++++++++
 include/s3c24x0.h               |  186 +++++++++++++++++++++++++++++-
 14 files changed, 745 insertions(+), 30 deletions(-)
 create mode 100644 drivers/mtd/nand/s3c2440_nand.c
 create mode 100644 include/s3c2440.h
Quoted 7 lines

first general comment

Please split this patch as something like this
patch 1 add the s3c24x0 support
patch 2 add the nand
patch 3 your boards

s3c24x0 refers to the Samsung s3c type of cpu's - s3c2400, s3c2410 and s3c2440.
Support for the s3c2400 and s3c2410 cpu's already exists in the current u-boot
code base in cpu/arm920t/s3c24x0 but there is currently no support for the s3c2440 cpu.

However, the format of the current s3c24x0 code doesn't meet the u-boot coding
style so I've already submitted 2 patches to clean up the current s3c24x0 code
- see reference at the top of this patch to the patches "Clean-up of ARM920T
S3C24x0 code, submitted on 5th June" and "Clean-up of ARM920T S3C24x0 drivers
code, submitted on 5th June".

Quoted 8 lines

This patch, 1/2, just adds support for the s3c2440 cpu (including the new s3c2440 NAND driver) to the current s3c24x0 code - it doesn't actually add the
Embest SBC2440-II Board support. Patch 2/2 is the one that adds the support for
the Embest SBC2440-II Board itself.

So, the patches are already structured as you requested.

no as you add the nand in this patch
the nand need to be add in a seperate patch, this one need to only add the s3c2440 support and the nand will be handle by Scott the nand Maintainer

Quoted 23 lines

It's getting a bit complicated because I initially sent a patch to add all of
the Embest SBC2440-II Board changes in one go. Wolfgang and yourself asked me
to create patches to clean up the existing code base first and to add the s3c2440 support separately to the Embest SBC2440-II Board so I now have 4 patches all dependent on one another and it's not too clear how they fit together.

Quoted 4 lines
Quoted 4 lines
common/serial.c +0 -0
index dd80e7c..6548b8b 100644
Quoted 9 lines

common/serial.c struct serial_device *__default_serial_console (void) · line 62

Quoted 7 lines
common/serial.c +1 -1
@@ -58,7 +58,7 @@ struct serial_device *__default_serial_console (void)
 #else
 		return &serial0_device;
 #endif
-#elif defined(CONFIG_S3C2410)
+#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 

if it's really s3c24x0 please use a correspondig macro IIRC yes

Quoted 1 line

Could you explain a bit more about how the macro would work please?

CONFIG_SERIAL_S3C24X0 or CONFIG_S3C24X0 as example

Quoted 103 lines
Quoted 29 lines

common/serial.c void serial_initialize (void) · line 137

Quoted 10 lines
common/serial.c +0 -0
 #if defined(CONFIG_SERIAL1)
 	return &s3c24xx_serial0_device;

#elif defined(CONFIG_SERIAL2)

common/serial.c +1 -1
@@ -133,7 +133,7 @@ void serial_initialize (void)
 #if defined (CONFIG_STUART)
 	serial_register(&serial_stuart_device);
 #endif
-#if defined(CONFIG_S3C2410)
+#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
 

ditto

Quoted 17 lines
common/serial.c +0 -0
 	serial_register(&s3c24xx_serial0_device);
 	serial_register(&s3c24xx_serial1_device);
common/serial.c +0 -0
 	serial_register(&s3c24xx_serial2_device);
cpu/arm920t/s3c24x0/speed.c +2 -1
index 3d7c8cf..b8b183e 100644
@@ -30,7 +30,8 @@
  */
 
 #include <common.h>
-#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
+#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || \
+    defined(CONFIG_S3C2440) || defined(CONFIG_TRAB)
 
 #include <asm/io.h>
 
Quoted 10 lines

cpu/arm920t/s3c24x0/speed.c line 45

Quoted 8 lines
cpu/arm920t/s3c24x0/speed.c +2 -0
@@ -38,6 +39,8 @@
 #include <s3c2400.h>
 #elif defined(CONFIG_S3C2410)
 #include <s3c2410.h>
+#elif defined(CONFIG_S3C2440)
+#include <s3c2440.h>
 #endif
 

please create a cpu.h file to avoid those ifdef

OK. There is already an s3c24x0.h header file so I could modify it to include
the correct s3c2400.h, s3c2410.h or s3c2440.h header file.

Quoted 61 lines
Quoted 46 lines
cpu/arm920t/s3c24x0/speed.c +21 -0
 #define MPLL 0
@@ -69,6 +72,11 @@ static ulong get_PLLCLK(int pllreg)
 	p = ((r & 0x003F0) >> 4) + 2;
 	s = r & 0x3;
 
+#ifdef CONFIG_S3C2440
+	if (pllreg == MPLL)
+		return (2 * CONFIG_SYS_CLK_FREQ * m) / (p << s);
+	else
+#endif
 	return (CONFIG_SYS_CLK_FREQ * m) / (p << s);
 }
 
@@ -83,7 +91,23 @@ ulong get_HCLK(void)
 {
 	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
 
+#ifdef CONFIG_S3C2440
+	switch (clk_power->CLKDIVN & 0x6) {
+	default:
+	case 0:
+		return get_FCLK();
+	case 2:
+		return get_FCLK() / 2;
+	case 4:
+		return (readl(&clk_power->CAMDIVN) & (1 << 9)) ?
+			get_FCLK() / 8 : get_FCLK() / 4;
+	case 6:
+		return (readl(&clk_power->CAMDIVN) & (1 << 8)) ?
+			get_FCLK() / 6 : get_FCLK() / 3;
+	}
+#else
 	return (readl(&clk_power->CLKDIVN) & 2) ? get_FCLK() / 2 : get_FCLK();
+#endif
 }
 
 
cpu/arm920t/start.S +0 -0
index 810d402..5f7aa33 100644

cpu/arm920t/start.S copyex: · line 139

Quoted 10 lines
cpu/arm920t/start.S +3 -2
@@ -132,8 +132,9 @@ copyex:
 	bne	copyex
 #endif
 
-#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
-	/* turn off the watchdog */
+#if defined(CONFIG_S3C2400) || \
+    defined(CONFIG_S3C2410) || \
+    defined(CONFIG_S3C2440)
 
 

please move this code to cpu/arm920t/s3c24x0/

the start.S need to generic but you can call arch code from it a branch or if not possible a assembly macro

Quoted 6 lines
Quoted 3 lines

please call it arch_pre_lowlevel_init
tks

OK. I can do something similar to the existing arch-specific 'lowlevel_init'
function call.

please do this in 2 steps
first you move the code patch 1
and the you add the s3c2440 (this patch)

Quoted 41 lines
Quoted 26 lines
Quoted 24 lines
cpu/arm920t/start.S +0 -0
 # if defined(CONFIG_S3C2400)

# define pWTCON 0x15300000

cpu/arm920t/start.S +9 -0
@@ -146,6 +147,15 @@ copyex:
 #  define CLKDIVN	0x4C000014	/* clock divisor register */
 # endif
 
+# if defined(CONFIG_S3C2440)
+#  define INTSMASK  0xffff
+#  define CLKDIVVAL 0x5
+#else
+#  define INTSMASK  0x3ff
+#  define CLKDIVVAL 0x3
+# endif
+
+	/* turn off the watchdog */
 	ldr	r0, =pWTCON
 	mov	r1, #0x0
 	str	r1, [r0]
@@ -156,8 +166,8 @@ copyex:
 

<snip>

Quoted 15 lines

cpu/arm920t/start.S

Quoted 13 lines
cpu/arm920t/start.S +12 -0
+
+/* AC97 INTERFACE (see S3C2440 manual chapter 24) */
+typedef struct {
+	S3C24X0_REG32 ACGLBCTRL;
+	S3C24X0_REG32 ACGLBSTAT;
+	S3C24X0_REG32 AC_CODEC_CMD;
+	S3C24X0_REG32 AC_CODEC_STAT;
+	S3C24X0_REG32 AC_PCMADDR;
+	S3C24X0_REG32 AC_MICADDR;
+	S3C24X0_REG32 AC_PCMDATA;
+	S3C24X0_REG32 AC_MICDATA;
+} /*__attribute__((__packed__))*/ S3C2440_AC97;

if no need please remove

Quoted 1 line

OK. The ADC isn't used either so I'll remove that as well.

ok but I've in mind the dead code /* */

Quoted 7 lines

Wolfgang has also asked me to make the CONFIG_SYS_HZ change in the current s3c2400 and s3c2410 boards before I add support for the s3c2440. I've already
submitted 5 patches as part of the s3c24x0 clean up and Embest SBC2440-II Board
so this would make a 6th and it's getting difficult to track them all.

no just thread all of them

Quoted 10 lines

If you agree, I'd like to withdraw the following patches for now as they all
need changes:

- [U-Boot] [PATCH-ARM] Clean-up of ARM920T S3C24x0 code, submitted on 5th June
- [U-Boot] [PATCH-ARM] Clean-up of ARM920T S3C24x0 drivers code, submitted on
5th June

patch 3
move the start.S code

Quoted 3 lines

- [U-Boot] [PATCH-ARM 1/2] Add support for the Embest SBC2440-II Board (ie this
patch)

patch 5
add the nand

Quoted 8 lines

- [U-Boot] [PATCH-ARM 2/2] Add support for the Embest SBC2440-II Board, submitted on 19th June

I'll create the new CONFIG_SYS_HZ patch and submit it, then make the required
changes to the 4 patches above, then re-submit these 4 together, probably marked 1/4, 2/4, 3/4 and 4/4, all version 2.

Quoted 6 lines

However, the following patch doesn't need any changes so I'd like to leave it
out for comment:

- [U-Boot] [PATCH-ARM] Bug-fix in drivers mtd nand Makefile, submitted on 18th

This will be handle by Scott with the nand patch

Best Regards,
J.

#5 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 6 lines · kevin.morfitt at fearnside-systems.co.uk

Hi Jean-Christophe, comments below:

Also, see note at the end regarding re-structuring of the existing s3c24x0 and
Embest SBC2440-II Board patches.

<snip>

Quoted 7 lines
Quoted 6 lines

Wolfgang has also asked me to make the CONFIG_SYS_HZ change in the current s3c2400 and s3c2410 boards before I add support for the s3c2440. I've already
submitted 5 patches as part of the s3c24x0 clean up and Embest SBC2440-II Board
so this would make a 6th and it's getting difficult to track them all.

no just thread all of them

when you say 'thread all of them' do you mean send them separately but numbered in the Subject field like 1/5, 2/5 etc?

Quoted 9 lines
Quoted 9 lines

If you agree, I'd like to withdraw the following patches for now as they all
need changes:

- [U-Boot] [PATCH-ARM] Clean-up of ARM920T S3C24x0 code, submitted on 5th June
- [U-Boot] [PATCH-ARM] Clean-up of ARM920T S3C24x0 drivers code, submitted on
5th June

The patch above does a code style clean-up of the s3c24x0 drivers code. This includes the mtd nand s3c2410 driver. Do I need to put the mtd nand s3c2410 driver clean-up in a separate patch or can I leave it in the same patch but just include something like PATCH-ARM,MTD-NAND in the Subject field?

Quoted 23 lines

patch 3
move the start.S code

Quoted 3 lines

- [U-Boot] [PATCH-ARM 1/2] Add support for the Embest SBC2440-II Board (ie this
patch)

patch 5
add the nand

Quoted 8 lines

- [U-Boot] [PATCH-ARM 2/2] Add support for the Embest SBC2440-II Board, submitted on 19th June

I'll create the new CONFIG_SYS_HZ patch and submit it, then make the required
changes to the 4 patches above, then re-submit these 4 together, probably marked 1/4, 2/4, 3/4 and 4/4, all version 2.

Quoted 6 lines

However, the following patch doesn't need any changes so I'd like to leave it
out for comment:

- [U-Boot] [PATCH-ARM] Bug-fix in drivers mtd nand Makefile, submitted on 18th

This will be handle by Scott with the nand patch

Quoted 9 lines

Best Regards,
J.

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4174 (20090620) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4174 (20090620) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

#6 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD

no as you add the nand in this patch
the nand need to be add in a seperate patch, this one need to only add the s3c2440 support and the nand will be handle by Scott the nand Maintainer

If a NAND patch is sandwiched in the middle of other patches that need to go via an arch tree, and depends on some of those patches, I'd rather ack the NAND bits to go through the arch tree rather than try to merge everything separately while still maintaining dependencies. In that case, keeping the NAND bits in a separate patch is nice, but not mandatory IMHO.

I'll look at that patch soon.

-Scott

#7 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

Quoted 6 lines · Scott Wood
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD

no as you add the nand in this patch
the nand need to be add in a seperate patch, this one need to only add the s3c2440 support and the nand will be handle by Scott the nand Maintainer

Quoted 7 lines

If a NAND patch is sandwiched in the middle of other patches that need to go via an arch tree, and depends on some of those patches, I'd rather ack the NAND bits to go through the arch tree rather than try to merge everything separately while still maintaining dependencies. In that case, keeping the NAND bits in a separate patch is nice, but not mandatory IMHO.

Thanks, leaving the NAND changes in the arch-specific patch would be simpler for me. I have to make some changes to the SBC2440 patch anyway so I'll make sure I cc you when I re-send it.

Quoted 4 lines

I'll look at that patch soon.

-Scott

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4179 (20090622) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

#8 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

In reply to Scott Wood
Quoted 6 lines · Scott Wood
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD

no as you add the nand in this patch
the nand need to be add in a seperate patch, this one need to only add the s3c2440 support and the nand will be handle by Scott the nand Maintainer

Quoted 6 lines

If a NAND patch is sandwiched in the middle of other patches that need to go via an arch tree, and depends on some of those patches, I'd rather ack the NAND bits to go through the arch tree rather than try to merge everything separately while still maintaining dependencies. In that case, keeping the NAND bits in a separate patch is nice, but not mandatory IMHO.

To simplify bisect and merge I prefer to have the nand adding in an other patch

Best Regards,
J.

#9 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

In reply to kevin.morfitt at fearnside-systems.co.uk

drivers/mtd/nand/s3c2410_nand.c line 39

Quoted 10 lines · Keven Morfitt
drivers/mtd/nand/s3c2410_nand.c +1 -1
index 60bfd10..b93787c 100644
@@ -36,7 +36,7 @@
 static void s3c2410_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
 	struct nand_chip *chip = mtd->priv;
-	S3C24X0_NAND * const nand = S3C24X0_GetBase_NAND();
+	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

This isn't new to this patch, but please don't make type names look like preprocessor macros (i.e. not ALL CAPS). Also, no space after * when it means pointer and not multiply.

Is there any particular reason to declare the pointer itself as const? It's just a local variable.

drivers/mtd/nand/s3c2410_nand.c

Quoted 8 lines
drivers/mtd/nand/s3c2410_nand.c +8 -0
+#ifdef CONFIG_S3C2440_NAND_HWECC
+/* 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} }
+};

Any reason why bytes 3, 4, 6, and 7 aren't free?

drivers/mtd/nand/s3c2410_nand.c

Quoted 12 lines
drivers/mtd/nand/s3c2410_nand.c +12 -0
+static int s3c2440_dev_ready(struct mtd_info *mtd)
+{
+	S3C2440_NAND * const nand = S3C2440_GetBase_NAND();
+
+	debugX(1, "dev_ready\n");
+	return readl(&nand->NFSTAT) & 0x01;
+}
+
+#ifdef CONFIG_S3C2440_NAND_HWECC
+void s3c2440_nand_enable_hwecc(struct mtd_info *mtd, int mode)
+{
+	S3C2440_UART * const nand = S3C2440_GetBase_NAND();

UART?

Quoted 41 lines
drivers/mtd/nand/s3c2410_nand.c +41 -0
+static int s3c2440_nand_correct_data(struct mtd_info *mtd, u_char *dat,
+				     u_char *read_ecc, u_char *calc_ecc)
+{
+	unsigned int diff0, diff1, diff2;
+	unsigned int bit, byte;
+
+	debugX(2, "s3c2440_nand_correct_data:\n");
+
+	diff0 = read_ecc[0] ^ calc_ecc[0];
+	diff1 = read_ecc[1] ^ calc_ecc[1];
+	diff2 = read_ecc[2] ^ calc_ecc[2];
+
+	debugX(3, "rd %02x%02x%02x calc %02x%02x%02x diff %02x%02x%02x\n",
+		read_ecc[0], read_ecc[1], read_ecc[2],
+		calc_ecc[0], calc_ecc[1], calc_ecc[2],
+		diff0, diff1, diff2);
+
+	if (diff0 == 0 && diff1 == 0 && diff2 == 0)
+		return 0;	/* ECC is ok */
+
+	/* Can we correct this ECC (ie, one row and column change).
+	 * Note, this is similar to the 256 error code on smartmedia */
+
+	if (((diff0 ^ (diff0 >> 1)) & 0x55) == 0x55 &&
+	    ((diff1 ^ (diff1 >> 1)) & 0x55) == 0x55 &&
+	    ((diff2 ^ (diff2 >> 1)) & 0x55) == 0x55) {
+		/* calculate the bit position of the error */
+		bit  = ((diff2 >> 3) & 1) |
+		       ((diff2 >> 4) & 2) |
+		       ((diff2 >> 5) & 4);
+
+		/* calculate the byte position of the error */
+		byte = ((diff2 << 7) & 0x100) |
+		       ((diff1 << 0) & 0x80)  |
+		       ((diff1 << 1) & 0x40)  |
+		       ((diff1 << 2) & 0x20)  |
+		       ((diff1 << 3) & 0x10)  |
+		       ((diff0 >> 4) & 0x08)  |
+		       ((diff0 >> 3) & 0x04)  |
+		       ((diff0 >> 2) & 0x02)  |
+		       ((diff0 >> 1) & 0x01);

drivers/mtd/nand/s3c2410_nand.c

Quoted 10 lines
drivers/mtd/nand/s3c2410_nand.c +10 -0
+
+		debugX(2, "correcting error bit %d, byte %d\n", bit, byte);
+
+		dat[byte] ^= (1 << bit);
+		return 1;
+	}
+
+	debugX(2, "Failed to correct ECC error\n");
+	return -1;
+}

Hmm, this looks very similar to the generic correct_data, except that it uses a 512-byte block (and is missing the final countbits check -- not sure what that's for, perhaps a single bit error in the ECC itself?).

Perhaps it should be factored out into the generic code?

Quoted 4 lines
drivers/mtd/nand/s3c2410_nand.c +4 -0
+int board_nand_init(struct nand_chip *nand)
+{
+	u_int32_t cfg;
+	u_int8_t tacls, twrph0, twrph1;

drivers/mtd/nand/s3c2410_nand.c

Quoted 10 lines
drivers/mtd/nand/s3c2410_nand.c +10 -0
+	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
+	S3C2440_NAND * const nand_reg = S3C2440_GetBase_NAND();
+
+	debugX(1, "board_nand_init()\n");
+
+	writel(readl(&clk_power->CLKCON) | (1 << 4),
+	       &clk_power->CLKCON);
+
+	/* initialize hardware */
+	twrph0 = 3; twrph1 = 1; tacls = 0;

Put each statement on its own line. Do these really need to be held in local variables rather than just passing them directly to these macros:

drivers/mtd/nand/s3c2410_nand.c

Quoted 3 lines
drivers/mtd/nand/s3c2410_nand.c +3 -0
+	cfg = S3C2440_NFCONF_TACLS(tacls);
+	cfg |= S3C2440_NFCONF_TWRPH0(twrph0);
+	cfg |= S3C2440_NFCONF_TWRPH1(twrph1);

...which include the same name, so it doesn't have any descriptive value?

Should the values come from the board config file?

-Scott

#10 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

Quoted 16 lines · Scott Wood

drivers/mtd/nand/s3c2410_nand.c line 39

Quoted 10 lines · Keven Morfitt
drivers/mtd/nand/s3c2410_nand.c +1 -1
index 60bfd10..b93787c 100644
@@ -36,7 +36,7 @@
 static void s3c2410_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
 	struct nand_chip *chip = mtd->priv;
-	S3C24X0_NAND * const nand = S3C24X0_GetBase_NAND();
+	S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

This isn't new to this patch, but please don't make type names look like preprocessor macros (i.e. not ALL CAPS). Also, no space after * when it means pointer and not multiply.

Quoted 3 lines

Is there any particular reason to declare the pointer itself as const? It's just a local variable.

These type names (and the 'const') are in the existing s3c24x0 code so I just made my new code follow the same style and Lindent and checkpatch didn't complain. The u-boot coding style guidelines say we should use the Linux coding style and this says that 'mixed case names are frowned upon' and 'It's a _mistake_ to use typedef for structures' so it doesn't meet the coding style, at least for the use of typedef if not for the upper case names. I'll change it throughout the s3c24x0 code.

Quoted 11 lines

drivers/mtd/nand/s3c2410_nand.c

Quoted 8 lines
drivers/mtd/nand/s3c2410_nand.c +8 -0
+#ifdef CONFIG_S3C2440_NAND_HWECC
+/* 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} }
+};

Any reason why bytes 3, 4, 6, and 7 aren't free?

I ported this from the Linux s3c2410 NAND driver (which covers s3c2440 as well as s3c2410). It worked when I tested it (after I enabled hardware ECC and fixed the problem below), but I don't know enough about how mtd hardware ecc works to understand why it was done this way in the Linux kernel. A comment in the kernel code says that nand_ecclayout is 'Exported to userspace for diagnosis and to allow creation of raw images' so it's likely I haven't tested this bit as all I did was check that NAND read/write worked. I'll have a look at it in more detail.

Quoted 6 lines
Quoted 6 lines
drivers/mtd/nand/s3c2410_nand.c +6 -0
+static int s3c2440_dev_ready(struct mtd_info *mtd)
+{
+	S3C2440_NAND * const nand = S3C2440_GetBase_NAND();
+
+	debugX(1, "dev_ready\n");
+	return readl(&nand->NFSTAT) & 0x01;
Quoted 9 lines

drivers/mtd/nand/s3c2410_nand.c

Quoted 6 lines
drivers/mtd/nand/s3c2410_nand.c +6 -0
+}
+
+#ifdef CONFIG_S3C2440_NAND_HWECC
+void s3c2440_nand_enable_hwecc(struct mtd_info *mtd, int mode)
+{
+	S3C2440_UART * const nand = S3C2440_GetBase_NAND();

UART?

Thanks, I should obviously be more careful with cut and paste! I also forgot to test the patch with hardware ECC enabled.

Quoted 56 lines
Quoted 41 lines
drivers/mtd/nand/s3c2410_nand.c +41 -0
+static int s3c2440_nand_correct_data(struct mtd_info *mtd, u_char *dat,
+				     u_char *read_ecc, u_char *calc_ecc)
+{
+	unsigned int diff0, diff1, diff2;
+	unsigned int bit, byte;
+
+	debugX(2, "s3c2440_nand_correct_data:\n");
+
+	diff0 = read_ecc[0] ^ calc_ecc[0];
+	diff1 = read_ecc[1] ^ calc_ecc[1];
+	diff2 = read_ecc[2] ^ calc_ecc[2];
+
+	debugX(3, "rd %02x%02x%02x calc %02x%02x%02x diff %02x%02x%02x\n",
+		read_ecc[0], read_ecc[1], read_ecc[2],
+		calc_ecc[0], calc_ecc[1], calc_ecc[2],
+		diff0, diff1, diff2);
+
+	if (diff0 == 0 && diff1 == 0 && diff2 == 0)
+		return 0;	/* ECC is ok */
+
+	/* Can we correct this ECC (ie, one row and column change).
+	 * Note, this is similar to the 256 error code on smartmedia */
+
+	if (((diff0 ^ (diff0 >> 1)) & 0x55) == 0x55 &&
+	    ((diff1 ^ (diff1 >> 1)) & 0x55) == 0x55 &&
+	    ((diff2 ^ (diff2 >> 1)) & 0x55) == 0x55) {
+		/* calculate the bit position of the error */
+		bit  = ((diff2 >> 3) & 1) |
+		       ((diff2 >> 4) & 2) |
+		       ((diff2 >> 5) & 4);
+
+		/* calculate the byte position of the error */
+		byte = ((diff2 << 7) & 0x100) |
+		       ((diff1 << 0) & 0x80)  |
+		       ((diff1 << 1) & 0x40)  |
+		       ((diff1 << 2) & 0x20)  |
+		       ((diff1 << 3) & 0x10)  |
+		       ((diff0 >> 4) & 0x08)  |
+		       ((diff0 >> 3) & 0x04)  |
+		       ((diff0 >> 2) & 0x02)  |
+		       ((diff0 >> 1) & 0x01);

drivers/mtd/nand/s3c2410_nand.c

Quoted 10 lines
drivers/mtd/nand/s3c2410_nand.c +10 -0
+
+		debugX(2, "correcting error bit %d, byte %d\n", bit, byte);
+
+		dat[byte] ^= (1 << bit);
+		return 1;
+	}
+
+	debugX(2, "Failed to correct ECC error\n");
+	return -1;
+}

Hmm, this looks very similar to the generic correct_data, except that it uses a 512-byte block (and is missing the final countbits check -- not sure what that's for, perhaps a single bit error in the ECC itself?).

Quoted 2 lines

Perhaps it should be factored out into the generic code?

I'll have a look at doing that. I obviously need to look at it in more detail.

Quoted 18 lines
Quoted 4 lines
drivers/mtd/nand/s3c2410_nand.c +4 -0
+int board_nand_init(struct nand_chip *nand)
+{
+	u_int32_t cfg;
+	u_int8_t tacls, twrph0, twrph1;

drivers/mtd/nand/s3c2410_nand.c

Quoted 10 lines
drivers/mtd/nand/s3c2410_nand.c +10 -0
+	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
+	S3C2440_NAND * const nand_reg = S3C2440_GetBase_NAND();
+
+	debugX(1, "board_nand_init()\n");
+
+	writel(readl(&clk_power->CLKCON) | (1 << 4),
+	       &clk_power->CLKCON);
+
+	/* initialize hardware */
+	twrph0 = 3; twrph1 = 1; tacls = 0;

Put each statement on its own line. Do these really need to be held in local variables rather than just passing them directly to these macros:

Quoted 6 lines

drivers/mtd/nand/s3c2410_nand.c

Quoted 3 lines
drivers/mtd/nand/s3c2410_nand.c +3 -0
+	cfg = S3C2440_NFCONF_TACLS(tacls);
+	cfg |= S3C2440_NFCONF_TWRPH0(twrph0);
+	cfg |= S3C2440_NFCONF_TWRPH1(twrph1);

...which include the same name, so it doesn't have any descriptive value?

Again, this comes from the existing s3c24x0 code so I'll change it throughout.

Quoted 2 lines

Should the values come from the board config file?

Yes. I'll add these to the board config file.

Thanks
Kevin

Quoted 2 lines

-Scott

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4179 (20090622) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

#11 lore raw

PATCH 1/2 Add support for the Embest SBC2440-II Board

Quoted 5 lines · kevin.morfitt at fearnside-systems.co.uk

These type names (and the 'const') are in the existing s3c24x0 code so I just made my new code follow the same style and Lindent and checkpatch didn't complain. The u-boot coding style guidelines say we should use the Linux coding style and this says that 'mixed case names are frowned upon' and 'It's a _mistake_ to use typedef for structures'

I love it when someone justifies their opinion by asserting that the alternative is "a _mistake_". :-)

Quoted 3 lines

so it doesn't meet
the coding style, at least for the use of typedef if not for the upper case names.

Upper case names are for macros in the Linux/u-boot code style.

Quoted 8 lines

I ported this from the Linux s3c2410 NAND driver (which covers s3c2440 as well as s3c2410). It worked when I tested it (after I enabled hardware ECC and fixed the problem below), but I don't know enough about how mtd hardware ecc works to understand why it was done this way in the Linux kernel. A comment in the kernel code says that nand_ecclayout is 'Exported to userspace for diagnosis and to allow creation of raw images' so it's likely I haven't tested this bit as all I did was check that NAND read/write worked. I'll have a look at it in more detail.

It's relevant for things like JFFS2, which use the free area for their own markers. It looks like 8 bytes is enough for that, though -- and being in sync with Linux is the most important. It may also be useful to reserve some bytes for alterate ECC schemes.

-Scott