Skip to contentSkip to conversation

S3C24XX: Add support to MINI2416 board

PATCH Superseded José Miguel Gonçalves 2 participants 17 messages Sep 18, 2012

Subsystems (6)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover S3C24XX: Add support to MINI2416 board

Support for the MINI2416 board based on a Samsung's S3C2416 SoC with 64MB DDR2 SDRAM, 256MB NAND Flash, a LAN9220 Ethernet Controller and a WM8731 Audio CODEC.

Changes for v2:
- Coding style cleanup
- Removed new serial and rtc drivers
- Use of in-tree serial and rtc drivers

Changes for v3:
- Rebased on new SPL framework:
http://github.com/trini/u-boot WIP/spl-improvements
- Removed patch "ARM: fix relocation on ARM926EJS"
- Add patch to configure printf() inclusion on SPL
- Changed new binary target name from u-boot-ubl.bin to u-boot-pad.bin
- Removed magic numbers
- Checkpatch clean except:
- False positive:
ERROR: spaces required around that ':' (ctx:VxV) #692: FILE: include/configs/mini2416.h:165:
+#define CONFIG_ETHADDR FE:11:22:33:44:55
- Following preexistent coding style:
WARNING: please, no spaces at the start of a line #1716: FILE: include/common.h:631:
+ defined(CONFIG_S3C24XX) || \$

Jos? Miguel Gon?alves (11):
Add configuration option to select printf() inclusion on SPL
S3C24XX: Add core support for Samsung's S3C24XX SoCs
serial: Add support to 4 ports in serial_s3c24x0
serial: Use a more precise baud rate generation for serial_s3c24x0
serial: Remove unnecessary delay in serial_s3c24x0
rtc: Improve rtc_get() on s3c24x0_rtc
rtc: Fix rtc_reset() on s3c24x0_rtc
rtc: Don't allow setting unsuported years on s3c24x0_rtc
S3C24XX: Add NAND Flash driver
Add u-boot-pad.bin target to the Makefile
S3C24XX: Add support to MINI2416 board

 MAINTAINERS                                     |    4 +
 Makefile                                        |   11 +-
 README                                          |    3 +
 arch/arm/cpu/arm926ejs/s3c24xx/Makefile         |   56 +++
 arch/arm/cpu/arm926ejs/s3c24xx/cpu.c            |   57 +++
 arch/arm/cpu/arm926ejs/s3c24xx/cpu_info.c       |   57 +++
 arch/arm/cpu/arm926ejs/s3c24xx/s3c2412_speed.c  |  114 +++++
 arch/arm/cpu/arm926ejs/s3c24xx/s3c2416_speed.c  |  116 +++++
 arch/arm/cpu/arm926ejs/s3c24xx/timer.c          |  152 ++++++
 arch/arm/include/asm/arch-s3c24xx/s3c2412.h     |  130 +++++
 arch/arm/include/asm/arch-s3c24xx/s3c2416.h     |  183 +++++++
 arch/arm/include/asm/arch-s3c24xx/s3c24x0_cpu.h |   41 ++
 arch/arm/include/asm/arch-s3c24xx/s3c24xx.h     |  615 +++++++++++++++++++++++
 arch/arm/include/asm/arch-s3c24xx/s3c24xx_cpu.h |   30 ++
 arch/arm/include/asm/arch-s3c24xx/spl.h         |   29 ++
 board/boardcon/mini2416/Makefile                |   47 ++
 board/boardcon/mini2416/config.mk               |    4 +
 board/boardcon/mini2416/mini2416.c              |  104 ++++
 board/boardcon/mini2416/mini2416_spl.c          |  203 ++++++++
 board/boardcon/mini2416/u-boot-spl.lds          |   63 +++
 boards.cfg                                      |    1 +
 drivers/mtd/nand/Makefile                       |    1 +
 drivers/mtd/nand/s3c24xx_nand.c                 |  246 +++++++++
 drivers/rtc/s3c24x0_rtc.c                       |   30 +-
 drivers/serial/serial_s3c24x0.c                 |   52 +-
 include/common.h                                |   12 +
 include/configs/VCMA9.h                         |    2 +-
 include/configs/mini2416.h                      |  202 ++++++++
 include/configs/smdk2410.h                      |    2 +-
 29 files changed, 2540 insertions(+), 27 deletions(-)
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/Makefile
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/cpu.c
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/cpu_info.c
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/s3c2412_speed.c
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/s3c2416_speed.c
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/timer.c
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/s3c2412.h
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/s3c2416.h
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/s3c24x0_cpu.h
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/s3c24xx.h
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/s3c24xx_cpu.h
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/spl.h
 create mode 100644 board/boardcon/mini2416/Makefile
 create mode 100644 board/boardcon/mini2416/config.mk
 create mode 100644 board/boardcon/mini2416/mini2416.c
 create mode 100644 board/boardcon/mini2416/mini2416_spl.c
 create mode 100644 board/boardcon/mini2416/u-boot-spl.lds
 create mode 100644 drivers/mtd/nand/s3c24xx_nand.c
 create mode 100644 include/configs/mini2416.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/11 Add configuration option to select printf() inclusion on SPL

The printf() implementation needs 4~5KB of storage space which may not be available when building an SPL for SoCs with scarce internal RAM (8KB or less). This patch adds a new option, CONFIG_SPL_PRINTF_SUPPORT, to deal with this.

---
Changes for v3:
- new patch

---
 README           |    3 +++
 include/common.h |   11 +++++++++++
 2 files changed, 14 insertions(+)
README +3 -0
index 016d8bc..988812c 100644
@@ -2576,6 +2576,9 @@ FIT uImage format:
 		CONFIG_SPL_LIBCOMMON_SUPPORT
 		Support for common/libcommon.o in SPL binary
 
+		CONFIG_SPL_PRINTF_SUPPORT
+		Enable printf() support in common/libcommon.o
+
 		CONFIG_SPL_LIBDISK_SUPPORT
 		Support for disk/libdisk.o in SPL binary
 
include/common.h +11 -0
index 55025c0..c10d745 100644
@@ -805,9 +805,20 @@ int	tstc(void);
 /* stdout */
 void	putc(const char c);
 void	puts(const char *s);
+/*
+ * The printf() implementation needs 4~5KB of storage space which may not be
+ * available when building an SPL for SoCs with scarce internal RAM
+ * (8KB or less). To force printf() inclusion on an SPL we must define
+ * CONFIG_SPL_LIBCOMMON_SUPPORT and CONFIG_SPL_PRINTF_SUPPORT.
+ */
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_PRINTF_SUPPORT)
 int	printf(const char *fmt, ...)
 		__attribute__ ((format (__printf__, 1, 2)));
 int	vprintf(const char *fmt, va_list args);
+#else
+#define printf(fmt...) do {} while (0)
+#define vprintf(fmt, args) do {} while (0)
+#endif
 
 /* stderr */
 #define eputc(c)		fputc(stderr, c)
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 2/11 S3C24XX: Add core support for Samsung's S3C24XX SoCs

In reply to José Miguel Gonçalves

This patch adds the support for Samsung's S3C24XX SoCs that have an ARM926EJS core. Currently it supports S3C2412, S3C2413, S3C2416 and S3C2450.
Tested on an S3C2416 platform.

---
Changes for v2:
- Added register bit macros to avoid magic numbers
- Removed volatile attribute from register structs
- Added s3c24x0_cpu.h to be able to use drivers from s3c24x0 family
- Fixed EPLL computation in get_PLLCLK for S3C2416
- Added display of UCLK in print_cpu_info
- Use of clrsetbits_le32()

Changes for v3:
- Add __noreturn attribute to reset_cpu()
- Removed magic numbers
- Add arch/arm/include/asm/arch-s3c24xx/spl.h for new SPL framework

---
 arch/arm/cpu/arm926ejs/s3c24xx/Makefile         |   56 +++
 arch/arm/cpu/arm926ejs/s3c24xx/cpu.c            |   57 +++
 arch/arm/cpu/arm926ejs/s3c24xx/cpu_info.c       |   57 +++
 arch/arm/cpu/arm926ejs/s3c24xx/s3c2412_speed.c  |  114 +++++
 arch/arm/cpu/arm926ejs/s3c24xx/s3c2416_speed.c  |  116 +++++
 arch/arm/cpu/arm926ejs/s3c24xx/timer.c          |  152 ++++++
 arch/arm/include/asm/arch-s3c24xx/s3c2412.h     |  130 +++++
 arch/arm/include/asm/arch-s3c24xx/s3c2416.h     |  183 +++++++
 arch/arm/include/asm/arch-s3c24xx/s3c24x0_cpu.h |   41 ++
 arch/arm/include/asm/arch-s3c24xx/s3c24xx.h     |  615 +++++++++++++++++++++++
 arch/arm/include/asm/arch-s3c24xx/s3c24xx_cpu.h |   30 ++
 arch/arm/include/asm/arch-s3c24xx/spl.h         |   29 ++
 include/common.h                                |    1 +
 13 files changed, 1581 insertions(+)
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/Makefile
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/cpu.c
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/cpu_info.c
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/s3c2412_speed.c
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/s3c2416_speed.c
 create mode 100644 arch/arm/cpu/arm926ejs/s3c24xx/timer.c
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/s3c2412.h
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/s3c2416.h
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/s3c24x0_cpu.h
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/s3c24xx.h
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/s3c24xx_cpu.h
 create mode 100644 arch/arm/include/asm/arch-s3c24xx/spl.h
arch/arm/cpu/arm926ejs/s3c24xx/Makefile new file +56 -0
new file mode 100644
index 0000000..d7f5e0d
@@ -0,0 +1,56 @@
+#
+# (C) Copyright 2012 INOV - INESC Inovacao
+# Jose Goncalves <[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
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(SOC).o
+
+ifndef CONFIG_SPL_BUILD
+COBJS-$(CONFIG_DISPLAY_CPUINFO)	+= cpu_info.o
+endif
+
+ifeq ($(filter y,$(CONFIG_S3C2412) $(CONFIG_S3C2413)),y)
+COBJS-y	+= s3c2412_speed.o
+else
+COBJS-y	+= s3c2416_speed.o
+endif
+
+COBJS-y	+= cpu.o
+COBJS-y	+= timer.o
+
+SRCS	:= $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/arm/cpu/arm926ejs/s3c24xx/cpu.c new file +57 -0

57 lines not on this page · raw message

arch/arm/cpu/arm926ejs/s3c24xx/cpu_info.c new file +57 -0

57 lines not on this page · raw message

arch/arm/cpu/arm926ejs/s3c24xx/s3c2412_speed.c new file +114 -0

114 lines not on this page · raw message

arch/arm/cpu/arm926ejs/s3c24xx/s3c2416_speed.c new file +116 -0

116 lines not on this page · raw message

arch/arm/cpu/arm926ejs/s3c24xx/timer.c new file +152 -0

152 lines not on this page · raw message

arch/arm/include/asm/arch-s3c24xx/s3c2412.h new file +130 -0

130 lines not on this page · raw message

arch/arm/include/asm/arch-s3c24xx/s3c2416.h new file +183 -0

183 lines not on this page · raw message

arch/arm/include/asm/arch-s3c24xx/s3c24x0_cpu.h new file +41 -0

41 lines not on this page · raw message

arch/arm/include/asm/arch-s3c24xx/s3c24xx.h new file +615 -0

615 lines not on this page · raw message

arch/arm/include/asm/arch-s3c24xx/s3c24xx_cpu.h new file +30 -0
new file mode 100644
index 0000000..59ccfd4
@@ -0,0 +1,30 @@
+/*
+ * (C) Copyright 2012 INOV - INESC Inovacao
+ * Jose Goncalves <[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
+ */
+
+#if defined(CONFIG_S3C2412) || defined(CONFIG_S3C2413)
+#include <asm/arch/s3c2412.h>
+#elif defined(CONFIG_S3C2416) || defined(CONFIG_S3C2450)
+#include <asm/arch/s3c2416.h>
+#else
+#error Please define the S3C24XX SoC type
+#endif
arch/arm/include/asm/arch-s3c24xx/spl.h new file +29 -0
new file mode 100644
index 0000000..2741fe7
@@ -0,0 +1,29 @@
+/*
+ * (C) Copyright 2012 INOV - INESC Inovacao
+ * Jose Goncalves <[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
+ */
+#ifndef	_ASM_ARCH_SPL_H_
+#define	_ASM_SPL_H_
+
+#define BOOT_DEVICE_NAND	1
+#define BOOT_DEVICE_MMC1	2
+
+#endif
include/common.h +1 -0
index c10d745..b63e814 100644
@@ -628,6 +628,7 @@ ulong	get_OPB_freq (void);
 ulong	get_PCI_freq (void);
 #endif
 #if defined(CONFIG_S3C24X0) || \
+    defined(CONFIG_S3C24XX) || \
     defined(CONFIG_LH7A40X) || \
     defined(CONFIG_S3C6400) || \
     defined(CONFIG_EP93XX)
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v3 3/11 serial: Add support to 4 ports in serial_s3c24x0

In reply to José Miguel Gonçalves

S3C2416 and S3C2450 have 4 UARTs insted of 3 found on older chips. This patch adds support to the additional UART port and changes the mapping between CONFIG_SERIAL? and S3C24X0_UART? in order they have a direct correspondence.

---
Changes for v2:
- New patch

Changes for v3:
- None

---
 drivers/serial/serial_s3c24x0.c |   25 ++++++++++++++++++-------
 include/configs/VCMA9.h         |    2 +-
 include/configs/smdk2410.h      |    2 +-
 3 files changed, 20 insertions(+), 9 deletions(-)
drivers/serial/serial_s3c24x0.c +18 -7
index 12bcdd3..280cd2d 100644
@@ -2,6 +2,9 @@
  * (C) Copyright 2002
  * Gary Jennejohn, DENX Software Engineering, <[email protected]>
  *
+ * (C) Copyright 2012 INOV - INESC Inovacao
+ * Jose Goncalves <[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 the License, or
@@ -24,17 +27,20 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_SERIAL1
+#if defined(CONFIG_SERIAL0)
 #define UART_NR	S3C24X0_UART0
 
-#elif defined(CONFIG_SERIAL2)
+#elif defined(CONFIG_SERIAL1)
 #define UART_NR	S3C24X0_UART1
 
-#elif defined(CONFIG_SERIAL3)
+#elif defined(CONFIG_SERIAL2)
 #define UART_NR	S3C24X0_UART2
 
+#elif defined(CONFIG_SERIAL3)
+#define UART_NR	S3C24X0_UART3
+
 #else
-#error "Bad: you didn't configure serial ..."
+#error "You didn't configure serial."
 #endif
 
 #include <asm/io.h>
@@ -310,15 +316,20 @@ INIT_S3C_SERIAL_STRUCTURE(1, "s3ser1");
 DECLARE_S3C_SERIAL_FUNCTIONS(2);
 struct serial_device s3c24xx_serial2_device =
 INIT_S3C_SERIAL_STRUCTURE(2, "s3ser2");
+DECLARE_S3C_SERIAL_FUNCTIONS(3);
+struct serial_device s3c24xx_serial3_device =
+INIT_S3C_SERIAL_STRUCTURE(3, "s3ser3");
 
 __weak struct serial_device *default_serial_console(void)
 {
-#if defined(CONFIG_SERIAL1)
+#if defined(CONFIG_SERIAL0)
 	return &s3c24xx_serial0_device;
-#elif defined(CONFIG_SERIAL2)
+#elif defined(CONFIG_SERIAL1)
 	return &s3c24xx_serial1_device;
-#elif defined(CONFIG_SERIAL3)
+#elif defined(CONFIG_SERIAL2)
 	return &s3c24xx_serial2_device;
+#elif defined(CONFIG_SERIAL3)
+	return &s3c24xx_serial3_device;
 #else
 #error "CONFIG_SERIAL? missing."
 #endif
include/configs/VCMA9.h +1 -1
index 6ad4a6b..82db58f 100644
@@ -122,7 +122,7 @@
  * select serial console configuration
  */
 #define CONFIG_S3C24X0_SERIAL
-#define CONFIG_SERIAL1		1	/* we use SERIAL 1 on VCMA9 */
+#define CONFIG_SERIAL0		1	/* we use SERIAL 0 on VCMA9 */
 
 /* USB support (currently only works with D-cache off) */
 #define CONFIG_USB_OHCI
include/configs/smdk2410.h +1 -1
index 8792c85..ea05f16 100644
@@ -62,7 +62,7 @@
  * select serial console configuration
  */
 #define CONFIG_S3C24X0_SERIAL
-#define CONFIG_SERIAL1		1	/* we use SERIAL 1 on SMDK2410 */
+#define CONFIG_SERIAL0		1	/* we use SERIAL 0 on SMDK2410 */
 
 /************************************************************
  * USB support (currently only works with D-cache off)
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v3 4/11 serial: Use a more precise baud rate generation for serial_s3c24x0

In reply to José Miguel Gonçalves

The values stored in the baud rate divisor register (UBRDIVn) and dividing slot register (UDIVSLOTn), are used to determine the serial baudrate. Previously only UBRDIVn was set. This patch initializes also UDIVSLOTn which allows to obtain a more precise baudrate.

---
Changes for v2:
- New patch

Changes for v3:
- Verbose patch description

---
 drivers/serial/serial_s3c24x0.c |   24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/serial/serial_s3c24x0.c +20 -4
index 280cd2d..c9bc121 100644
@@ -92,16 +92,32 @@ DECLARE_GLOBAL_DATA_PTR;
 static int hwflow;
 #endif
 
+/*
+ * The values stored in the baud rate divisor register (UBRDIVn) and dividing
+ * slot register (UDIVSLOTn), are used to determine the serial Tx/Rx clock rate
+ * (baud rate) as follows:
+ *     DIV_VAL = UBRDIVn + (num of 1?s in UDIVSLOTn) / 16
+ * Using UDIVSLOT, which is the factor of floating point divisor, you can make
+ * more accurate baud rate. Section 2.1.10 of the S3C2416 User's Manual suggests
+ * using the constants on the following table.
+ */
+static const int udivslot[] = {
+	0x0000, 0x0080, 0x0808, 0x0888, 0x2222, 0x4924, 0x4A52, 0x54AA,
+	0x5555, 0xD555, 0xD5D5, 0xDDD5, 0xDDDD, 0xDFDD, 0xDFDF, 0xFFDF,
+};
+
 void _serial_setbrg(const int dev_index)
 {
 	struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
-	unsigned int reg = 0;
+	u32 pclk;
+	u32 baudrate;
 	int i;
 
-	/* value is calculated so : (int)(PCLK/16./baudrate) -1 */
-	reg = get_PCLK() / (16 * gd->baudrate) - 1;
+	pclk = get_PCLK();
+	baudrate = gd->baudrate;
 
-	writel(reg, &uart->ubrdiv);
+	writel((pclk / baudrate / 16) - 1, &uart->ubrdiv);
+	writel(udivslot[(pclk / baudrate) % 16], &uart->udivslot);
 	for (i = 0; i < 100; i++)
 		/* Delay */ ;
 }
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v3 5/11 serial: Remove unnecessary delay in serial_s3c24x0

In reply to José Miguel Gonçalves

The loop used to make a delay after baudrate setting is not necessary. Moreover it is removed by the GCC optimizer (at least with GCC 4.6).

---
Changes for v2:
- New patch

Changes for v3:
- None

---
 drivers/serial/serial_s3c24x0.c |    3 ---
 1 file changed, 3 deletions(-)
drivers/serial/serial_s3c24x0.c +0 -3
index c9bc121..ec5d1cb 100644
@@ -111,15 +111,12 @@ void _serial_setbrg(const int dev_index)
 	struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
 	u32 pclk;
 	u32 baudrate;
-	int i;
 
 	pclk = get_PCLK();
 	baudrate = gd->baudrate;
 
 	writel((pclk / baudrate / 16) - 1, &uart->ubrdiv);
 	writel(udivslot[(pclk / baudrate) % 16], &uart->udivslot);
-	for (i = 0; i < 100; i++)
-		/* Delay */ ;
 }
 
 #if defined(CONFIG_SERIAL_MULTI)
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v3 6/11 rtc: Improve rtc_get() on s3c24x0_rtc

In reply to José Miguel Gonçalves

A better approach to avoid reading the RTC during updates, as sugested in the S3C2416 User's Manual.

---
Changes for v2:
- New patch

Changes for v3:
- Removed unneeded parenthesis

---
 drivers/rtc/s3c24x0_rtc.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/rtc/s3c24x0_rtc.c +8 -2
index c16ff2e..b31dc53 100644
@@ -65,20 +65,26 @@ int rtc_get(struct rtc_time *tmp)
 	uchar sec, min, hour, mday, wday, mon, year;
 	__maybe_unused uchar a_sec, a_min, a_hour, a_date,
 			     a_mon, a_year, a_armed;
+	int have_retried = 0;
 
 	/* enable access to RTC registers */
 	SetRTC_Access(RTC_ENABLE);
 
 	/* read RTC registers */
 	do {
-		sec  = readb(&rtc->bcdsec);
 		min  = readb(&rtc->bcdmin);
 		hour = readb(&rtc->bcdhour);
 		mday = readb(&rtc->bcddate);
 		wday = readb(&rtc->bcdday);
 		mon  = readb(&rtc->bcdmon);
 		year = readb(&rtc->bcdyear);
-	} while (sec != readb(&rtc->bcdsec));
+		sec  = readb(&rtc->bcdsec);
+		/*
+		 * The only way to work out whether the RTC was mid-update
+		 * when we read it is to check the seconds counter.
+		 * If it's zero, then we re-try the entire read.
+		 */
+	} while (sec == 0 && !have_retried++);
 
 	/* read ALARM registers */
 	a_sec   = readb(&rtc->almsec);
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v3 7/11 rtc: Fix rtc_reset() on s3c24x0_rtc

In reply to José Miguel Gonçalves

rtc_reset() must set the RTC date to the UNIX Epoch.

---
Changes for v2:
- New patch

Changes for v3:
- None

---
 drivers/rtc/s3c24x0_rtc.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/rtc/s3c24x0_rtc.c +11 -4
index b31dc53..3fd5cec 100644
@@ -167,10 +167,17 @@ int rtc_set(struct rtc_time *tmp)
 
 void rtc_reset(void)
 {
-	struct s3c24x0_rtc *rtc = s3c24x0_get_base_rtc();
-
-	writeb((readb(&rtc->rtccon) & ~0x06) | 0x08, &rtc->rtccon);
-	writeb(readb(&rtc->rtccon) & ~(0x08 | 0x01), &rtc->rtccon);
+	static struct rtc_time tmp = {
+		.tm_year = 1970,
+		.tm_mon = 1,
+		.tm_mday = 1,
+		.tm_wday = 4,
+		.tm_hour = 0,
+		.tm_min = 0,
+		.tm_sec = 0,
+	};
+
+	rtc_set(&tmp);
 }
 
 #endif
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v3 8/11 rtc: Don't allow setting unsuported years on s3c24x0_rtc

In reply to José Miguel Gonçalves

This RTC only supports a 100 years range so rtc_set() should not allow setting years bellow 1970 or above 2069.

---
Changes for v2:
- New patch

Changes for v3:
- None

---
 drivers/rtc/s3c24x0_rtc.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/rtc/s3c24x0_rtc.c +5 -0
index 3fd5cec..bcd6d44 100644
@@ -139,6 +139,11 @@ int rtc_set(struct rtc_time *tmp)
 	       tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
 	       tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
 #endif
+	if (tmp->tm_year < 1970 || tmp->tm_year > 2069) {
+		puts("ERROR: year should be between 1970 and 2069!\n");
+		return -1;
+	}
+
 	year = bin2bcd(tmp->tm_year % 100);
 	mon  = bin2bcd(tmp->tm_mon);
 	wday = bin2bcd(tmp->tm_wday);
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v3 9/11 S3C24XX: Add NAND Flash driver

In reply to José Miguel Gonçalves

NAND Flash driver with HW ECC for the S3C24XX SoCs. Currently it only supports SLC NAND chips.

---
Changes for v2:
- Coding style cleanup
- Use of clrsetbits_le32()
- Use of register bit macros instead of magic numbers

Changes for v3:
- Removed magic numbers
- Removed a macro to declare a void printf()
- Replaced one printf() with a puts()

---
 drivers/mtd/nand/Makefile       |    1 +
 drivers/mtd/nand/s3c24xx_nand.c |  246 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 247 insertions(+)
 create mode 100644 drivers/mtd/nand/s3c24xx_nand.c
drivers/mtd/nand/Makefile +1 -0
index 29dc20e..791ec44 100644
@@ -60,6 +60,7 @@ COBJS-$(CONFIG_NAND_MXS) += mxs_nand.o
 COBJS-$(CONFIG_NAND_NDFC) += ndfc.o
 COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o
+COBJS-$(CONFIG_NAND_S3C24XX) += s3c24xx_nand.o
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
 COBJS-$(CONFIG_NAND_SPEAR) += spr_nand.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
drivers/mtd/nand/s3c24xx_nand.c new file +246 -0

246 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#10 lore raw

PATCH v3 9/11 S3C24XX: Add NAND Flash driver

Quoted 74 lines · Jos? Miguel Gon?alves

NAND Flash driver with HW ECC for the S3C24XX SoCs. Currently it only supports SLC NAND chips.

---
Changes for v2:
- Coding style cleanup
- Use of clrsetbits_le32()
- Use of register bit macros instead of magic numbers

Changes for v3:
- Removed magic numbers
- Removed a macro to declare a void printf()
- Replaced one printf() with a puts()

---
 drivers/mtd/nand/Makefile       |    1 +
 drivers/mtd/nand/s3c24xx_nand.c |  246  
+++++++++++++++++++++++++++++++++++++++
 2 files changed, 247 insertions(+)
 create mode 100644 drivers/mtd/nand/s3c24xx_nand.c
drivers/mtd/nand/Makefile +1 -0
index 29dc20e..791ec44 100644
@@ -60,6 +60,7 @@ COBJS-$(CONFIG_NAND_MXS) += mxs_nand.o
 COBJS-$(CONFIG_NAND_NDFC) += ndfc.o
 COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o
+COBJS-$(CONFIG_NAND_S3C24XX) += s3c24xx_nand.o
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
 COBJS-$(CONFIG_NAND_SPEAR) += spr_nand.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
drivers/mtd/nand/s3c24xx_nand.c new file +34 -0
new file mode 100644
index 0000000..3c13709
@@ -0,0 +1,246 @@
+/*
+ * (C) Copyright 2012 INOV - INESC Inovacao
+ * Jose Goncalves <[email protected]>
+ *
+ * Based on drivers/mtd/nand/s3c64xx.c and U-Boot 1.3.4 from Samsung.
+ * Supports only SLC NAND Flash chips.
+ *
+ * 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
+ */
+
+#include <common.h>
+#include <nand.h>
+#include <asm/io.h>
+#include <asm/errno.h>
+#include <asm/arch/s3c24xx_cpu.h>
+
+#define TACLS_VAL	7	/* CLE & ALE duration setting (0~7) */
+#define	TWRPH0_VAL	7	/* TWRPH0 duration setting  
Quoted 2 lines

(0~7) */
+#define TWRPH1_VAL 7 /* TWRPH1 duration setting (0~7) */

Please use space, not tab, as a word separator (after the second #define).

drivers/mtd/nand/s3c24xx_nand.c line 38

Quoted 3 lines
drivers/mtd/nand/s3c24xx_nand.c new file +3 -0
+
+#define MAX_CHIPS	2
+static int nand_cs[MAX_CHIPS] = { 0, 1 };

This needs explanation (and const). Better would be to use a priv struct, as discussed before.

drivers/mtd/nand/s3c24xx_nand.c line 43

Quoted 4 lines
drivers/mtd/nand/s3c24xx_nand.c new file +4 -0
+static void s3c_nand_select_chip(struct mtd_info *mtd, int chip)
+{
+	struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
+	u_long nfcont;

s/u_long/u32/

Quoted 5 lines
drivers/mtd/nand/s3c24xx_nand.c new file +5 -0
+
+	nfcont = readl(&nand->nfcont);
+
+	switch (chip) {
+	case -1:

drivers/mtd/nand/s3c24xx_nand.c line 58

Quoted 10 lines
drivers/mtd/nand/s3c24xx_nand.c new file +10 -0
+		nfcont |= NFCONT_NCE1 | NFCONT_NCE0;
+		break;
+	case 0:
+		nfcont &= ~NFCONT_NCE0;
+		break;
+	case 1:
+		nfcont &= ~NFCONT_NCE1;
+		break;
+	default:
+		return;

error message on default?

Quoted 20 lines
drivers/mtd/nand/s3c24xx_nand.c new file +9 -0
+	}
+
+	writel(nfcont, &nand->nfcont);
+}
+
+/*
+ * Hardware specific access to control-lines function
+ */
+static void s3c_nand_hwcontrol(struct mtd_info *mtd, int cmd,  

unsigned int ctrl)

drivers/mtd/nand/s3c24xx_nand.c new file +10 -0
+{
+	struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
+	struct nand_chip *this = mtd->priv;
+
+	if (ctrl & NAND_CTRL_CHANGE) {
+		if (ctrl & NAND_CLE)
+			this->IO_ADDR_W = &nand->nfcmmd;
+		else if (ctrl & NAND_ALE)
+			this->IO_ADDR_W = &nand->nfaddr;
+		else

drivers/mtd/nand/s3c24xx_nand.c line 87

Quoted 10 lines
drivers/mtd/nand/s3c24xx_nand.c new file +10 -0
+			this->IO_ADDR_W = &nand->nfdata;
+		if (ctrl & NAND_NCE)
+			s3c_nand_select_chip(mtd, *(int *)this->priv);
+		else
+			s3c_nand_select_chip(mtd, -1);
+	}
+
+	if (cmd != NAND_CMD_NONE)
+		writeb(cmd, this->IO_ADDR_W);
+}

As discussed earlier, do you really need to mess with IO_ADDR_W or can you do it the way ndfc.c does?

I.e.:

static void s3c_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)

{
	struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
	struct nand_chip *this = mtd->priv;

	if (cmd == NAND_CMD_NONE)
		return;

	if (ctrl & NAND_CLE)
		writeb(cmd, &nand->nfcmmd);
	else
		writeb(cmd, &nand->nfaddr);
}
Quoted 41 lines
drivers/mtd/nand/s3c24xx_nand.c new file +18 -0
+/*
+ * Board-specific NAND initialization.
+ */
+int board_nand_init(struct nand_chip *nand)
+{
+	static int chip_n;
+	struct s3c24xx_nand *const nand_reg = s3c24xx_get_base_nand();
+
+	if (chip_n == 0) {
+		/* Extend NAND timings to the maximum */
+		clrsetbits_le32(&nand_reg->nfconf,
+				NFCONF_TACLS_MASK | NFCONF_TWRPH0_MASK |
+				NFCONF_TWRPH1_MASK,
+				NFCONF_TACLS(TACLS_VAL) |
+				NFCONF_TWRPH0(TWRPH0_VAL) |
+				NFCONF_TWRPH1(TWRPH1_VAL));
+
+		/* Disable chip selects and soft lock, enable  

controller */

drivers/mtd/nand/s3c24xx_nand.c new file +2 -0
+		clrsetbits_le32(&nand_reg->nfcont, NFCONT_WP,
+				NFCONT_NCE1 | NFCONT_NCE0 |  

NFCONT_ENABLE);

drivers/mtd/nand/s3c24xx_nand.c new file +19 -0
+	} else if (chip_n >= MAX_CHIPS) {
+		return -ENODEV;
+	}
+
+	nand->IO_ADDR_R = &nand_reg->nfdata;
+	nand->IO_ADDR_W = &nand_reg->nfdata;
+	nand->cmd_ctrl = s3c_nand_hwcontrol;
+	nand->dev_ready = s3c_nand_device_ready;
+	nand->select_chip = s3c_nand_select_chip;
+	nand->options = 0;
+#ifdef CONFIG_SPL_BUILD
+	nand->read_buf = nand_read_buf;
+#endif
+
+#ifdef CONFIG_S3C24XX_NAND_HWECC
+	nand->ecc.hwctl = s3c_nand_enable_hwecc;
+	nand->ecc.calculate = s3c_nand_calculate_ecc;
+	nand->ecc.correct = s3c_nand_correct_data;
+	nand->ecc.mode = NAND_ECC_HW_OOB_FIRST;

drivers/mtd/nand/s3c24xx_nand.c line 246

Quoted 10 lines
drivers/mtd/nand/s3c24xx_nand.c new file +10 -0
+	nand->ecc.size = CONFIG_SYS_NAND_ECCSIZE;
+	nand->ecc.bytes = CONFIG_SYS_NAND_ECCBYTES;
+#else
+	nand->ecc.mode = NAND_ECC_SOFT;
+#endif /* ! CONFIG_S3C24XX_NAND_HWECC */
+
+	nand->priv = nand_cs + chip_n++;
+
+	return 0;
+}

Please consider using the new SELF_INIT mechanism.

-Scott

#11 lore raw

PATCH v3 9/11 S3C24XX: Add NAND Flash driver

Quoted 68 lines · Scott Wood
Quoted 67 lines · Jos? Miguel Gon?alves

NAND Flash driver with HW ECC for the S3C24XX SoCs. Currently it only supports SLC NAND chips.

---
Changes for v2:
- Coding style cleanup
- Use of clrsetbits_le32()
- Use of register bit macros instead of magic numbers

Changes for v3:
- Removed magic numbers
- Removed a macro to declare a void printf()
- Replaced one printf() with a puts()

---
 drivers/mtd/nand/Makefile       |    1 +
 drivers/mtd/nand/s3c24xx_nand.c |  246 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 247 insertions(+)
 create mode 100644 drivers/mtd/nand/s3c24xx_nand.c
drivers/mtd/nand/Makefile +1 -0
index 29dc20e..791ec44 100644
@@ -60,6 +60,7 @@ COBJS-$(CONFIG_NAND_MXS) += mxs_nand.o
 COBJS-$(CONFIG_NAND_NDFC) += ndfc.o
 COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o
+COBJS-$(CONFIG_NAND_S3C24XX) += s3c24xx_nand.o
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
 COBJS-$(CONFIG_NAND_SPEAR) += spr_nand.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
drivers/mtd/nand/s3c24xx_nand.c new file +29 -0
new file mode 100644
index 0000000..3c13709
@@ -0,0 +1,246 @@
+/*
+ * (C) Copyright 2012 INOV - INESC Inovacao
+ * Jose Goncalves <[email protected]>
+ *
+ * Based on drivers/mtd/nand/s3c64xx.c and U-Boot 1.3.4 from Samsung.
+ * Supports only SLC NAND Flash chips.
+ *
+ * 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
+ */
+
+#include <common.h>
+#include <nand.h>
+#include <asm/io.h>
Quoted 8 lines

drivers/mtd/nand/s3c24xx_nand.c line 35

Quoted 6 lines
drivers/mtd/nand/s3c24xx_nand.c new file +6 -0
+#include <asm/errno.h>
+#include <asm/arch/s3c24xx_cpu.h>
+
+#define TACLS_VAL    7    /* CLE & ALE duration setting (0~7) */
+#define    TWRPH0_VAL    7    /* TWRPH0 duration setting (0~7) */
+#define TWRPH1_VAL    7    /* TWRPH1 duration setting (0~7) */

Please use space, not tab, as a word separator (after the second #define).

OK.

Quoted 8 lines

drivers/mtd/nand/s3c24xx_nand.c line 38

Quoted 4 lines
drivers/mtd/nand/s3c24xx_nand.c new file +3 -0
+
+#define MAX_CHIPS    2
+static int nand_cs[MAX_CHIPS] = { 0, 1 };

This needs explanation (and const). Better would be to use a priv struct, as discussed before.

Quoted 6 lines

drivers/mtd/nand/s3c24xx_nand.c line 43

Quoted 4 lines
drivers/mtd/nand/s3c24xx_nand.c new file +4 -0
+static void s3c_nand_select_chip(struct mtd_info *mtd, int chip)
+{
+    struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
+    u_long nfcont;

s/u_long/u32/

Didn't catch this...

Quoted 10 lines
Quoted 10 lines
drivers/mtd/nand/s3c24xx_nand.c new file +9 -0
+
+    nfcont = readl(&nand->nfcont);
+
+    switch (chip) {
+    case -1:
+        nfcont |= NFCONT_NCE1 | NFCONT_NCE0;
+        break;
+    case 0:
+        nfcont &= ~NFCONT_NCE0;
Quoted 8 lines

drivers/mtd/nand/s3c24xx_nand.c line 58

Quoted 6 lines
drivers/mtd/nand/s3c24xx_nand.c new file +6 -0
+        break;
+    case 1:
+        nfcont &= ~NFCONT_NCE1;
+        break;
+    default:
+        return;

error message on default?

OK.

Quoted 25 lines
Quoted 25 lines
drivers/mtd/nand/s3c24xx_nand.c new file +24 -0
+    }
+
+    writel(nfcont, &nand->nfcont);
+}
+
+/*
+ * Hardware specific access to control-lines function
+ */
+static void s3c_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
+{
+    struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
+    struct nand_chip *this = mtd->priv;
+
+    if (ctrl & NAND_CTRL_CHANGE) {
+        if (ctrl & NAND_CLE)
+            this->IO_ADDR_W = &nand->nfcmmd;
+        else if (ctrl & NAND_ALE)
+            this->IO_ADDR_W = &nand->nfaddr;
+        else
+            this->IO_ADDR_W = &nand->nfdata;
+        if (ctrl & NAND_NCE)
+            s3c_nand_select_chip(mtd, *(int *)this->priv);
+        else
+            s3c_nand_select_chip(mtd, -1);
Quoted 8 lines

drivers/mtd/nand/s3c24xx_nand.c line 87

Quoted 5 lines
drivers/mtd/nand/s3c24xx_nand.c new file +5 -0
+    }
+
+    if (cmd != NAND_CMD_NONE)
+        writeb(cmd, this->IO_ADDR_W);
+}

As discussed earlier, do you really need to mess with IO_ADDR_W or can you do it the way ndfc.c does?

I will take a look at ndfc.c. Most of this driver was copy-paste from s3c64xx.c driver and an older patched U-Boot sources from Samsung, so I did not make any real code examination after it started to work...

Quoted 60 lines

I.e.:

static void s3c_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)

{
    struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
    struct nand_chip *this = mtd->priv;

    if (cmd == NAND_CMD_NONE)
        return;

    if (ctrl & NAND_CLE)
        writeb(cmd, &nand->nfcmmd);
    else
        writeb(cmd, &nand->nfaddr);
}
Quoted 43 lines
drivers/mtd/nand/s3c24xx_nand.c new file +43 -0
+/*
+ * Board-specific NAND initialization.
+ */
+int board_nand_init(struct nand_chip *nand)
+{
+    static int chip_n;
+    struct s3c24xx_nand *const nand_reg = s3c24xx_get_base_nand();
+
+    if (chip_n == 0) {
+        /* Extend NAND timings to the maximum */
+        clrsetbits_le32(&nand_reg->nfconf,
+                NFCONF_TACLS_MASK | NFCONF_TWRPH0_MASK |
+                NFCONF_TWRPH1_MASK,
+                NFCONF_TACLS(TACLS_VAL) |
+                NFCONF_TWRPH0(TWRPH0_VAL) |
+                NFCONF_TWRPH1(TWRPH1_VAL));
+
+        /* Disable chip selects and soft lock, enable controller */
+        clrsetbits_le32(&nand_reg->nfcont, NFCONT_WP,
+                NFCONT_NCE1 | NFCONT_NCE0 | NFCONT_ENABLE);
+    } else if (chip_n >= MAX_CHIPS) {
+        return -ENODEV;
+    }
+
+    nand->IO_ADDR_R = &nand_reg->nfdata;
+    nand->IO_ADDR_W = &nand_reg->nfdata;
+    nand->cmd_ctrl = s3c_nand_hwcontrol;
+    nand->dev_ready = s3c_nand_device_ready;
+    nand->select_chip = s3c_nand_select_chip;
+    nand->options = 0;
+#ifdef CONFIG_SPL_BUILD
+    nand->read_buf = nand_read_buf;
+#endif
+
+#ifdef CONFIG_S3C24XX_NAND_HWECC
+    nand->ecc.hwctl = s3c_nand_enable_hwecc;
+    nand->ecc.calculate = s3c_nand_calculate_ecc;
+    nand->ecc.correct = s3c_nand_correct_data;
+    nand->ecc.mode = NAND_ECC_HW_OOB_FIRST;
+    nand->ecc.size = CONFIG_SYS_NAND_ECCSIZE;
+    nand->ecc.bytes = CONFIG_SYS_NAND_ECCBYTES;
+#else
+    nand->ecc.mode = NAND_ECC_SOFT;
Quoted 9 lines

drivers/mtd/nand/s3c24xx_nand.c line 246

Quoted 6 lines
drivers/mtd/nand/s3c24xx_nand.c new file +6 -0
+#endif /* ! CONFIG_S3C24XX_NAND_HWECC */
+
+    nand->priv = nand_cs + chip_n++;
+
+    return 0;
+}

Please consider using the new SELF_INIT mechanism.

Can you explain and/or point_to_resources for what this means (I'm a U-Boot newbie)...

Best regards,
Jos? Gon?alves

#12 lore raw

PATCH v3 9/11 S3C24XX: Add NAND Flash driver

Quoted 19 lines · Jos? Miguel Gon?alves
Quoted 7 lines · Scott Wood

drivers/mtd/nand/s3c24xx_nand.c line 35

Quoted 3 lines · Jos? Miguel Gon?alves
drivers/mtd/nand/s3c24xx_nand.c new file +3 -0
+#define TACLS_VAL    7    /* CLE & ALE duration setting (0~7) */
+#define    TWRPH0_VAL    7    /* TWRPH0 duration setting (0~7) */
+#define TWRPH1_VAL    7    /* TWRPH1 duration setting (0~7) */

Please use space, not tab, as a word separator (after the second #define).

OK.

Quoted 8 lines

drivers/mtd/nand/s3c24xx_nand.c line 38

Quoted 4 lines
drivers/mtd/nand/s3c24xx_nand.c new file +3 -0
+
+#define MAX_CHIPS    2
+static int nand_cs[MAX_CHIPS] = { 0, 1 };

This needs explanation (and const). Better would be to use a priv struct, as discussed before.

Quoted 8 lines
Quoted 6 lines

drivers/mtd/nand/s3c24xx_nand.c line 43

Quoted 4 lines
drivers/mtd/nand/s3c24xx_nand.c new file +4 -0
+static void s3c_nand_select_chip(struct mtd_info *mtd, int chip)
+{
+    struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
+    u_long nfcont;

s/u_long/u32/

Didn't catch this...

Replace u_long with u32.

Quoted 54 lines
Quoted 15 lines
Quoted 4 lines
drivers/mtd/nand/s3c24xx_nand.c new file +4 -0
+    nfcont = readl(&nand->nfcont);
+
+    switch (chip) {
+    case -1:

drivers/mtd/nand/s3c24xx_nand.c line 58

Quoted 10 lines
drivers/mtd/nand/s3c24xx_nand.c new file +10 -0
+        nfcont |= NFCONT_NCE1 | NFCONT_NCE0;
+        break;
+    case 0:
+        nfcont &= ~NFCONT_NCE0;
+        break;
+    case 1:
+        nfcont &= ~NFCONT_NCE1;
+        break;
+    default:
+        return;
Quoted 1 line

error message on default?

OK.

Quoted 26 lines
Quoted 26 lines
drivers/mtd/nand/s3c24xx_nand.c new file +9 -0
+    }
+
+    writel(nfcont, &nand->nfcont);
+}
+
+/*
+ * Hardware specific access to control-lines function
+ */
+static void s3c_nand_hwcontrol(struct mtd_info *mtd, int cmd,  

unsigned int ctrl)

drivers/mtd/nand/s3c24xx_nand.c new file +15 -0
+{
+    struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
+    struct nand_chip *this = mtd->priv;
+
+    if (ctrl & NAND_CTRL_CHANGE) {
+        if (ctrl & NAND_CLE)
+            this->IO_ADDR_W = &nand->nfcmmd;
+        else if (ctrl & NAND_ALE)
+            this->IO_ADDR_W = &nand->nfaddr;
+        else
+            this->IO_ADDR_W = &nand->nfdata;
+        if (ctrl & NAND_NCE)
+            s3c_nand_select_chip(mtd, *(int *)this->priv);
+        else
+            s3c_nand_select_chip(mtd, -1);
Quoted 8 lines

drivers/mtd/nand/s3c24xx_nand.c line 87

Quoted 5 lines
drivers/mtd/nand/s3c24xx_nand.c new file +5 -0
+    }
+
+    if (cmd != NAND_CMD_NONE)
+        writeb(cmd, this->IO_ADDR_W);
+}

As discussed earlier, do you really need to mess with IO_ADDR_W or can you do it the way ndfc.c does?

Quoted 1 line

I will take a look at ndfc.c.

Most of this driver was copy-paste from s3c64xx.c driver and an older patched U-Boot sources from Samsung, so I did not make any real code examination after it started to work...

Quoted 10 lines
Quoted 10 lines

I.e.:

static void s3c_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)

{
    struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
    struct nand_chip *this = mtd->priv;
Quoted 8 lines
Quoted 8 lines
    if (cmd == NAND_CMD_NONE)
        return;

    if (ctrl & NAND_CLE)
        writeb(cmd, &nand->nfcmmd);
    else
        writeb(cmd, &nand->nfaddr);
}

Oh sorry -- the above is missing the NCE part. Before the NAND_CMD_NONE check insert:

if (ctrl & NAND_CTRL_CHANGE) {
if (ctrl & NAND_NCE)
s3c_nand_select_chip(mtd, *(const int

*)this->priv);
		else
			s3c_nand_select_chip(mtd, -1);
	}
Quoted 54 lines
Quoted 44 lines
Quoted 44 lines
drivers/mtd/nand/s3c24xx_nand.c new file +43 -0
+/*
+ * Board-specific NAND initialization.
+ */
+int board_nand_init(struct nand_chip *nand)
+{
+    static int chip_n;
+    struct s3c24xx_nand *const nand_reg = s3c24xx_get_base_nand();
+
+    if (chip_n == 0) {
+        /* Extend NAND timings to the maximum */
+        clrsetbits_le32(&nand_reg->nfconf,
+                NFCONF_TACLS_MASK | NFCONF_TWRPH0_MASK |
+                NFCONF_TWRPH1_MASK,
+                NFCONF_TACLS(TACLS_VAL) |
+                NFCONF_TWRPH0(TWRPH0_VAL) |
+                NFCONF_TWRPH1(TWRPH1_VAL));
+
+        /* Disable chip selects and soft lock, enable controller */
+        clrsetbits_le32(&nand_reg->nfcont, NFCONT_WP,
+                NFCONT_NCE1 | NFCONT_NCE0 | NFCONT_ENABLE);
+    } else if (chip_n >= MAX_CHIPS) {
+        return -ENODEV;
+    }
+
+    nand->IO_ADDR_R = &nand_reg->nfdata;
+    nand->IO_ADDR_W = &nand_reg->nfdata;
+    nand->cmd_ctrl = s3c_nand_hwcontrol;
+    nand->dev_ready = s3c_nand_device_ready;
+    nand->select_chip = s3c_nand_select_chip;
+    nand->options = 0;
+#ifdef CONFIG_SPL_BUILD
+    nand->read_buf = nand_read_buf;
+#endif
+
+#ifdef CONFIG_S3C24XX_NAND_HWECC
+    nand->ecc.hwctl = s3c_nand_enable_hwecc;
+    nand->ecc.calculate = s3c_nand_calculate_ecc;
+    nand->ecc.correct = s3c_nand_correct_data;
+    nand->ecc.mode = NAND_ECC_HW_OOB_FIRST;
+    nand->ecc.size = CONFIG_SYS_NAND_ECCSIZE;
+    nand->ecc.bytes = CONFIG_SYS_NAND_ECCBYTES;
+#else
+    nand->ecc.mode = NAND_ECC_SOFT;
Quoted 9 lines

drivers/mtd/nand/s3c24xx_nand.c line 246

Quoted 6 lines
drivers/mtd/nand/s3c24xx_nand.c new file +6 -0
+#endif /* ! CONFIG_S3C24XX_NAND_HWECC */
+
+    nand->priv = nand_cs + chip_n++;
+
+    return 0;
+}

Please consider using the new SELF_INIT mechanism.

Quoted 2 lines

Can you explain and/or point_to_resources for what this means (I'm a U-Boot newbie)...

See CONFIG_SYS_NAND_SELF_INIT in doc/README.nand

I'd like the old way to be removed at some point.

-Scott

#13 lore raw

PATCH v3 9/11 S3C24XX: Add NAND Flash driver

Quoted 26 lines · Scott Wood
Quoted 25 lines · Jos? Miguel Gon?alves
Quoted 6 lines · Scott Wood

drivers/mtd/nand/s3c24xx_nand.c line 35

Quoted 3 lines · Jos? Miguel Gon?alves
drivers/mtd/nand/s3c24xx_nand.c new file +3 -0
+#define TACLS_VAL    7    /* CLE & ALE duration setting (0~7) */
+#define    TWRPH0_VAL    7    /* TWRPH0 duration setting (0~7) */
+#define TWRPH1_VAL    7    /* TWRPH1 duration setting (0~7) */

Please use space, not tab, as a word separator (after the second #define).

OK.

Quoted 14 lines

drivers/mtd/nand/s3c24xx_nand.c line 38

Quoted 4 lines
drivers/mtd/nand/s3c24xx_nand.c new file +3 -0
+
+#define MAX_CHIPS    2
+static int nand_cs[MAX_CHIPS] = { 0, 1 };

This needs explanation (and const). Better would be to use a priv struct, as discussed before.

drivers/mtd/nand/s3c24xx_nand.c line 43

Quoted 4 lines
drivers/mtd/nand/s3c24xx_nand.c new file +4 -0
+static void s3c_nand_select_chip(struct mtd_info *mtd, int chip)
+{
+    struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
+    u_long nfcont;

s/u_long/u32/

Quoted 3 lines
Quoted 1 line

Didn't catch this...

Replace u_long with u32.

OK (didn't expected a regex expression in that context...)

Quoted 146 lines
Quoted 55 lines
Quoted 16 lines
Quoted 5 lines
drivers/mtd/nand/s3c24xx_nand.c new file +4 -0
+    nfcont = readl(&nand->nfcont);
+
+    switch (chip) {
+    case -1:

drivers/mtd/nand/s3c24xx_nand.c line 58

Quoted 10 lines
drivers/mtd/nand/s3c24xx_nand.c new file +10 -0
+        nfcont |= NFCONT_NCE1 | NFCONT_NCE0;
+        break;
+    case 0:
+        nfcont &= ~NFCONT_NCE0;
+        break;
+    case 1:
+        nfcont &= ~NFCONT_NCE1;
+        break;
+    default:
+        return;
Quoted 1 line

error message on default?

OK.

Quoted 26 lines
Quoted 26 lines
drivers/mtd/nand/s3c24xx_nand.c new file +9 -0
+    }
+
+    writel(nfcont, &nand->nfcont);
+}
+
+/*
+ * Hardware specific access to control-lines function
+ */
+static void s3c_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int 

ctrl)

drivers/mtd/nand/s3c24xx_nand.c new file +15 -0
+{
+    struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
+    struct nand_chip *this = mtd->priv;
+
+    if (ctrl & NAND_CTRL_CHANGE) {
+        if (ctrl & NAND_CLE)
+            this->IO_ADDR_W = &nand->nfcmmd;
+        else if (ctrl & NAND_ALE)
+            this->IO_ADDR_W = &nand->nfaddr;
+        else
+            this->IO_ADDR_W = &nand->nfdata;
+        if (ctrl & NAND_NCE)
+            s3c_nand_select_chip(mtd, *(int *)this->priv);
+        else
+            s3c_nand_select_chip(mtd, -1);
Quoted 8 lines

drivers/mtd/nand/s3c24xx_nand.c line 87

Quoted 5 lines
drivers/mtd/nand/s3c24xx_nand.c new file +5 -0
+    }
+
+    if (cmd != NAND_CMD_NONE)
+        writeb(cmd, this->IO_ADDR_W);
+}

As discussed earlier, do you really need to mess with IO_ADDR_W or can you do it the way ndfc.c does?

Quoted 1 line

I will take a look at ndfc.c.

Most of this driver was copy-paste from s3c64xx.c driver and an older patched U-Boot sources from Samsung, so I did not make any real code examination after it started to work...

Quoted 9 lines
Quoted 9 lines

I.e.:

static void s3c_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)

{
    struct s3c24xx_nand *const nand = s3c24xx_get_base_nand();
    struct nand_chip *this = mtd->priv;
Quoted 8 lines
Quoted 8 lines
    if (cmd == NAND_CMD_NONE)
        return;

    if (ctrl & NAND_CLE)
        writeb(cmd, &nand->nfcmmd);
    else
        writeb(cmd, &nand->nfaddr);
}

Oh sorry -- the above is missing the NCE part. Before the NAND_CMD_NONE check insert:

    if (ctrl & NAND_CTRL_CHANGE) {
        if (ctrl & NAND_NCE)
            s3c_nand_select_chip(mtd, *(const int *)this->priv);
        else
            s3c_nand_select_chip(mtd, -1);
    }
Quoted 54 lines
Quoted 53 lines
Quoted 40 lines
drivers/mtd/nand/s3c24xx_nand.c new file +39 -0
+/*
+ * Board-specific NAND initialization.
+ */
+int board_nand_init(struct nand_chip *nand)
+{
+    static int chip_n;
+    struct s3c24xx_nand *const nand_reg = s3c24xx_get_base_nand();
+
+    if (chip_n == 0) {
+        /* Extend NAND timings to the maximum */
+        clrsetbits_le32(&nand_reg->nfconf,
+                NFCONF_TACLS_MASK | NFCONF_TWRPH0_MASK |
+                NFCONF_TWRPH1_MASK,
+                NFCONF_TACLS(TACLS_VAL) |
+                NFCONF_TWRPH0(TWRPH0_VAL) |
+                NFCONF_TWRPH1(TWRPH1_VAL));
+
+        /* Disable chip selects and soft lock, enable controller */
+        clrsetbits_le32(&nand_reg->nfcont, NFCONT_WP,
+                NFCONT_NCE1 | NFCONT_NCE0 | NFCONT_ENABLE);
+    } else if (chip_n >= MAX_CHIPS) {
+        return -ENODEV;
+    }
+
+    nand->IO_ADDR_R = &nand_reg->nfdata;
+    nand->IO_ADDR_W = &nand_reg->nfdata;
+    nand->cmd_ctrl = s3c_nand_hwcontrol;
+    nand->dev_ready = s3c_nand_device_ready;
+    nand->select_chip = s3c_nand_select_chip;
+    nand->options = 0;
+#ifdef CONFIG_SPL_BUILD
+    nand->read_buf = nand_read_buf;
+#endif
+
+#ifdef CONFIG_S3C24XX_NAND_HWECC
+    nand->ecc.hwctl = s3c_nand_enable_hwecc;
+    nand->ecc.calculate = s3c_nand_calculate_ecc;
+    nand->ecc.correct = s3c_nand_correct_data;
+    nand->ecc.mode = NAND_ECC_HW_OOB_FIRST;

drivers/mtd/nand/s3c24xx_nand.c line 246

Quoted 10 lines
drivers/mtd/nand/s3c24xx_nand.c new file +10 -0
+    nand->ecc.size = CONFIG_SYS_NAND_ECCSIZE;
+    nand->ecc.bytes = CONFIG_SYS_NAND_ECCBYTES;
+#else
+    nand->ecc.mode = NAND_ECC_SOFT;
+#endif /* ! CONFIG_S3C24XX_NAND_HWECC */
+
+    nand->priv = nand_cs + chip_n++;
+
+    return 0;
+}

Please consider using the new SELF_INIT mechanism.

Quoted 6 lines
Quoted 2 lines

Can you explain and/or point_to_resources for what this means (I'm a U-Boot newbie)...

See CONFIG_SYS_NAND_SELF_INIT in doc/README.nand

I'd like the old way to be removed at some point.

From what I've seen there is an incompatibility between the SPL simple nand
driver and the SELF_INIT mechanism.
The nand_init() function in drivers/mtd/nand/nand_spl_simple.c calls board_nand_init() with a pointer to a struct nand_chip as an argument (the old way). This needs to be changed to be able to use that SPL driver. Can you give me an hint on the proper way to handle this?

Best regards,
Jos? Gon?alves

#14 lore raw

PATCH v3 9/11 S3C24XX: Add NAND Flash driver

Quoted 11 lines · Jos? Miguel Gon?alves
Quoted 10 lines · Scott Wood
Quoted 6 lines · Jos? Miguel Gon?alves
Quoted 2 lines · Scott Wood

Please consider using the new SELF_INIT mechanism.

Can you explain and/or point_to_resources for what this means (I'm a U-Boot newbie)...

See CONFIG_SYS_NAND_SELF_INIT in doc/README.nand

Quoted 8 lines
Quoted 1 line

I'd like the old way to be removed at some point.

From what I've seen there is an incompatibility between the SPL simple nand driver and the SELF_INIT mechanism.
The nand_init() function in drivers/mtd/nand/nand_spl_simple.c calls board_nand_init() with a pointer to a struct nand_chip as an argument (the old way). This needs to be changed to be able to use that SPL driver. Can you give me an hint on the proper way to handle this?

Hmm... yes, this will need some work. Go ahead and leave it for now.

-Scott

#15 lore raw

PATCH v3 10/11 Add u-boot-pad.bin target to the Makefile

In reply to José Miguel Gonçalves

Samsung's S3C24XX SoCs need this in order to generate a binary image with a padded SPL concatenated with U-Boot.

---
Changes for v2:
- None

Changes for v3:
- Changed new binary target name from u-boot-ubl.bin to u-boot-pad.bin

---
 Makefile |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
Makefile +6 -5
index 8738d55..86dedca 100644
@@ -433,14 +433,15 @@ $(obj)u-boot.sha1:	$(obj)u-boot.bin
 $(obj)u-boot.dis:	$(obj)u-boot
 		$(OBJDUMP) -d $< > $@
 
-$(obj)u-boot.ubl:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
+$(obj)u-boot-pad.bin:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
 		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
-		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $(obj)u-boot-ubl.bin
-		$(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
-		-e $(CONFIG_SYS_TEXT_BASE) -d $(obj)u-boot-ubl.bin $(obj)u-boot.ubl
-		rm $(obj)u-boot-ubl.bin
+		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $(obj)u-boot-pad.bin
 		rm $(obj)spl/u-boot-spl-pad.bin
 
+$(obj)u-boot.ubl:       $(obj)spl/u-boot-pad.bin
+		$(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
+		-e $(CONFIG_SYS_TEXT_BASE) -d $(obj)u-boot-pad.bin $(obj)u-boot.ubl
+
 $(obj)u-boot.ais:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
 		$(obj)tools/mkimage -s -n /dev/null -T aisimage \
 			-e $(CONFIG_SPL_TEXT_BASE) \
Signature · 1 line
1.7.9.5
#16 lore raw

PATCH v3 11/11 S3C24XX: Add support to MINI2416 board

In reply to José Miguel Gonçalves

The MINI2416 board is based on a Samsung's S3C2416 SoC and has 64MB DDR2 SDRAM, 256MB NAND Flash, a LAN9220 Ethernet Controller and a WM8731 Audio CODEC. This U-Boot port was implemented and tested on a unit bought to Boardcon
(http://www.armdesigner.com/) but there are some other chinese providers that can supply it with a selectable NAND chip from 128MB to 1GB.

---
Changes for v2:
- Coding style cleanup
- Use of Use of clrbits_le32(), setbits_le32() and clrsetbits_le32()
- Use of register bit macros instead of magic numbers
- Use of serial and rtc drivers implemented for s3c24x0

Changes for v3:
- Changed target name from u-boot-ubl.bin to u-boot-pad.bin
- Removed magic numbers
- Changes to support new SPL framework

---
 MAINTAINERS                            |    4 +
 board/boardcon/mini2416/Makefile       |   47 ++++++++
 board/boardcon/mini2416/config.mk      |    4 +
 board/boardcon/mini2416/mini2416.c     |  104 ++++++++++++++++
 board/boardcon/mini2416/mini2416_spl.c |  202 ++++++++++++++++++++++++++++++++
 board/boardcon/mini2416/u-boot-spl.lds |   63 ++++++++++
 boards.cfg                             |    1 +
 include/configs/mini2416.h             |  202 +++++++++++++++++++++++++++++++
 8 files changed, 627 insertions(+)
 create mode 100644 board/boardcon/mini2416/Makefile
 create mode 100644 board/boardcon/mini2416/config.mk
 create mode 100644 board/boardcon/mini2416/mini2416.c
 create mode 100644 board/boardcon/mini2416/mini2416_spl.c
 create mode 100644 board/boardcon/mini2416/u-boot-spl.lds
 create mode 100644 include/configs/mini2416.h
MAINTAINERS +4 -0
index c5a6f2f..80ad29e 100644
@@ -653,6 +653,10 @@ Fabio Estevam <[email protected]>
 	mx53ard		i.MX53
 	mx53smd		i.MX53
 
+Jos? Gon?alves <[email protected]>
+
+	mini2416	ARM926EJS (S3C2416 SoC)
+
 Daniel Gorsulowski <[email protected]>
 
 	meesc		ARM926EJS (AT91SAM9263 SoC)
board/boardcon/mini2416/Makefile new file +47 -0

47 lines not on this page · raw message

board/boardcon/mini2416/config.mk new file +4 -0
new file mode 100644
index 0000000..ff08568
@@ -0,0 +1,4 @@
+PAD_TO	:= 0x2000
+ifndef CONFIG_SPL_BUILD
+ALL-y += $(obj)u-boot-pad.bin
+endif
board/boardcon/mini2416/mini2416.c new file +104 -0

104 lines not on this page · raw message

board/boardcon/mini2416/mini2416_spl.c new file +202 -0

202 lines not on this page · raw message

board/boardcon/mini2416/u-boot-spl.lds new file +63 -0

63 lines not on this page · raw message

boards.cfg +1 -0
index fdb84ad..823d5e6 100644
@@ -185,6 +185,7 @@ omap730p2_cs0boot	     arm         arm926ejs   omap730p2		 ti             omap
 omap730p2_cs3boot	     arm         arm926ejs   omap730p2		 ti             omap        omap730p2:CS3_BOOT
 edminiv2                     arm         arm926ejs   -                   LaCie          orion5x
 dkb			     arm         arm926ejs   -                   Marvell        pantheon
+mini2416                     arm         arm926ejs   mini2416            boardcon       s3c24xx
 spear300                     arm         arm926ejs   spear300            spear          spear       spear3xx_evb:spear300
 spear300_nand                arm         arm926ejs   spear300            spear          spear       spear3xx_evb:spear300,nand
 spear300_usbtty              arm         arm926ejs   spear300            spear          spear       spear3xx_evb:spear300,usbtty
include/configs/mini2416.h new file +202 -0

202 lines not on this page · raw message

Signature · 1 line
1.7.9.5