mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM/Samsung: more clean up...
@ 2012-07-20 19:29 Juergen Beisert
  2012-07-20 19:29 ` [PATCH 1/9] ARM/Samsung: List only really supported S3C24xx SoCs Juergen Beisert
                   ` (9 more replies)
  0 siblings, 10 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-20 19:29 UTC (permalink / raw)
  To: barebox

...in preparation to add the S3C6410 SoC support.

Mostly simplifying the Samsung serial driver and some more cosmetic.

Comments are welcome.

Regards,
Juergen

The following changes since commit b47220d7f70df9191fc456dbcaeaa6ead72c6c02:

  NAND/Samsung: remove a leftover from architeture clean ups (2012-07-20 08:41:35 +0200)

are available in the git repository at:

  git://git.pengutronix.de/git/jbe/barebox.git master_samsung_clean_up

for you to fetch changes up to fc361ff7de449f9bb8a7653a5705621320d84560:

  Samsung/serial: make the clock source configureable (2012-07-20 21:16:02 +0200)

----------------------------------------------------------------
Juergen Beisert (9):
      ARM/Samsung: List only really supported S3C24xx SoCs
      ARM/Samsung: follow the name style of the other source files in this directory
      Samsung/serial: remove more ugly ifdef lines
      Samsung/serial: make the code more readable
      Samsung/serial: there is no need to ifdef these register defines
      Samsung/serial: there is no need to ifdef the slot table
      Samsung/serial: move the decision about an improved UART into Kconfig
      Samsung/serial: unify UCON register settings
      Samsung/serial: make the clock source configureable

 arch/arm/Kconfig                                   |    2 +-
 arch/arm/mach-samsung/Kconfig                      |    5 ++
 arch/arm/mach-samsung/Makefile                     |    3 +-
 .../{s3c24xx-clocks.c => clocks-s3c24xx.c}         |    0
 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h  |    5 +-
 drivers/serial/serial_s3c.c                        |   71 +++++++++++---------
 6 files changed, 48 insertions(+), 38 deletions(-)
 rename arch/arm/mach-samsung/{s3c24xx-clocks.c => clocks-s3c24xx.c} (100%)


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/9] ARM/Samsung: List only really supported S3C24xx SoCs
  2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
@ 2012-07-20 19:29 ` Juergen Beisert
  2012-07-20 19:29 ` [PATCH 2/9] ARM/Samsung: follow the name style of the other source files in this directory Juergen Beisert
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-20 19:29 UTC (permalink / raw)
  To: barebox

The other SoCs differs in many ways from the currently supported S3C2410 and
S3C2440, so remove them.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 arch/arm/Kconfig |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index af4cb59..2dbac66 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -68,7 +68,7 @@ config ARCH_PXA
 	select GENERIC_GPIO
 
 config ARCH_S3C24xx
-	bool "Samsung S3C2410, S3C2412, S3C2413, S3C2440, S3C2442, S3C2443"
+	bool "Samsung S3C2410, S3C2440"
 	select ARCH_SAMSUNG
 	select CPU_ARM920T
 	select GENERIC_GPIO
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 2/9] ARM/Samsung: follow the name style of the other source files in this directory
  2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
  2012-07-20 19:29 ` [PATCH 1/9] ARM/Samsung: List only really supported S3C24xx SoCs Juergen Beisert
@ 2012-07-20 19:29 ` Juergen Beisert
  2012-07-20 19:29 ` [PATCH 3/9] Samsung/serial: remove more ugly ifdef lines Juergen Beisert
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-20 19:29 UTC (permalink / raw)
  To: barebox

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 arch/arm/mach-samsung/Makefile                               |    3 +--
 arch/arm/mach-samsung/{s3c24xx-clocks.c => clocks-s3c24xx.c} |    0
 2 files changed, 1 insertion(+), 2 deletions(-)
 rename arch/arm/mach-samsung/{s3c24xx-clocks.c => clocks-s3c24xx.c} (100%)

diff --git a/arch/arm/mach-samsung/Makefile b/arch/arm/mach-samsung/Makefile
index d7344c8..40180d7 100644
--- a/arch/arm/mach-samsung/Makefile
+++ b/arch/arm/mach-samsung/Makefile
@@ -1,6 +1,5 @@
 obj-y += s3c-timer.o generic.o
 obj-lowlevel-$(CONFIG_ARCH_S3C24xx) += lowlevel-s3c24x0.o
 obj-lowlevel-$(CONFIG_ARCH_S5PCxx) += lowlevel-s5pcxx.o
-obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o s3c24xx-clocks.o mem-s3c24x0.o
-obj-$(CONFIG_ARCH_S5PCxx) += gpio-s5pcxx.o clocks-s5pcxx.o
+obj-$(CONFIG_ARCH_S3C24xx) += gpio-s3c24x0.o clocks-s3c24xx.o mem-s3c24x0.o
 obj-$(CONFIG_S3C_LOWLEVEL_INIT) += $(obj-lowlevel-y)
diff --git a/arch/arm/mach-samsung/s3c24xx-clocks.c b/arch/arm/mach-samsung/clocks-s3c24xx.c
similarity index 100%
rename from arch/arm/mach-samsung/s3c24xx-clocks.c
rename to arch/arm/mach-samsung/clocks-s3c24xx.c
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 3/9] Samsung/serial: remove more ugly ifdef lines
  2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
  2012-07-20 19:29 ` [PATCH 1/9] ARM/Samsung: List only really supported S3C24xx SoCs Juergen Beisert
  2012-07-20 19:29 ` [PATCH 2/9] ARM/Samsung: follow the name style of the other source files in this directory Juergen Beisert
@ 2012-07-20 19:29 ` Juergen Beisert
  2012-07-20 19:29 ` [PATCH 4/9] Samsung/serial: make the code more readable Juergen Beisert
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-20 19:29 UTC (permalink / raw)
  To: barebox

More or less just cosmetic. Easier to read, and lets the compiler remove unused
code.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/serial/serial_s3c.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index 7a9b355..ff3792b 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -115,11 +115,10 @@ static int s3c_serial_init_port(struct console_device *cdev)
 	writeb(0xf, base + UINTM);
 #endif
 
-#ifdef CONFIG_DRIVER_SERIAL_S3C_AUTOSYNC
-	writeb(0x10, base + UMCON); /* enable auto flow control */
-#else
-	writeb(0x01, base + UMCON); /* RTS up */
-#endif
+	if (IS_ENABLED(CONFIG_DRIVER_SERIAL_S3C_AUTOSYNC))
+		writeb(0x10, base + UMCON); /* enable auto flow control */
+	else
+		writeb(0x01, base + UMCON); /* RTS up */
 
 	return 0;
 }
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 4/9] Samsung/serial: make the code more readable
  2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
                   ` (2 preceding siblings ...)
  2012-07-20 19:29 ` [PATCH 3/9] Samsung/serial: remove more ugly ifdef lines Juergen Beisert
@ 2012-07-20 19:29 ` Juergen Beisert
  2012-07-20 19:29 ` [PATCH 5/9] Samsung/serial: there is no need to ifdef these register defines Juergen Beisert
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-20 19:29 UTC (permalink / raw)
  To: barebox

This bit magic is just setting and reading the UART's selected clock source.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/serial/serial_s3c.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index ff3792b..c537bc0 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -31,6 +31,8 @@
 /* Note: Offsets are for little endian access */
 #define ULCON 0x00		/* line control */
 #define UCON 0x04		/* UART control */
+# define UCON_SET_CLK_SRC(x) (((x) & 0x03) << 10)
+# define UCON_GET_CLK_SRC(x) (((x) >> 10) & 0x03)
 #define UFCON 0x08		/* FIFO control */
 #define UMCON 0x0c		/* modem control */
 #define UTRSTAT 0x10		/* Rx/Tx status */
@@ -62,8 +64,7 @@ struct s3c_uart {
 static unsigned s3c_get_arch_uart_input_clock(void __iomem *base)
 {
 	unsigned reg = readw(base + UCON);
-	reg = (reg >> 10) & 0x3;
-	return s3c_get_uart_clk(reg);
+	return s3c_get_uart_clk(UCON_GET_CLK_SRC(reg));
 }
 
 #ifdef S3C_UART_HAS_UBRDIVSLOT
@@ -108,7 +109,8 @@ static int s3c_serial_init_port(struct console_device *cdev)
 
 	/* tx=level,rx=edge,disable timeout int.,enable rx error int.,
 	 * normal, interrupt or polling, no pre-divider */
-	writew(0x0245 | ((S3C_UART_CLKSEL) << 10), base + UCON);
+	writew(0x0245 | UCON_SET_CLK_SRC(S3C_UART_CLKSEL),
+						base + UCON);
 
 #ifdef S3C_UART_HAS_UINTM
 	/* 'interrupt or polling mode' for both directions */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 5/9] Samsung/serial: there is no need to ifdef these register defines
  2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
                   ` (3 preceding siblings ...)
  2012-07-20 19:29 ` [PATCH 4/9] Samsung/serial: make the code more readable Juergen Beisert
@ 2012-07-20 19:29 ` Juergen Beisert
  2012-07-20 19:29 ` [PATCH 6/9] Samsung/serial: there is no need to ifdef the slot table Juergen Beisert
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-20 19:29 UTC (permalink / raw)
  To: barebox

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/serial/serial_s3c.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index c537bc0..3565edf 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -42,12 +42,8 @@
 #define UTXH 0x20		/* transmitt */
 #define URXH 0x24		/* receive */
 #define UBRDIV 0x28		/* baudrate generator */
-#ifdef S3C_UART_HAS_UBRDIVSLOT
-# define UBRDIVSLOT 0x2c	/* baudrate slot generator */
-#endif
-#ifdef S3C_UART_HAS_UINTM
-# define UINTM 0x38		/* interrupt mask register */
-#endif
+#define UBRDIVSLOT 0x2c		/* baudrate slot generator */
+#define UINTM 0x38		/* interrupt mask register */
 
 #ifndef S3C_UART_CLKSEL
 /* Use pclk */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 6/9] Samsung/serial: there is no need to ifdef the slot table
  2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
                   ` (4 preceding siblings ...)
  2012-07-20 19:29 ` [PATCH 5/9] Samsung/serial: there is no need to ifdef these register defines Juergen Beisert
@ 2012-07-20 19:29 ` Juergen Beisert
  2012-07-20 19:29 ` [PATCH 7/9] Samsung/serial: move the decision about an improved UART into Kconfig Juergen Beisert
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-20 19:29 UTC (permalink / raw)
  To: barebox

The '__maybe_unused' attribute prevents the compiler from warning about an
unused variable and the 'static' will remove it entirely if it's not used.
This patch is only cosmetic.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/serial/serial_s3c.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index 3565edf..2cb2eef 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -63,7 +63,6 @@ static unsigned s3c_get_arch_uart_input_clock(void __iomem *base)
 	return s3c_get_uart_clk(UCON_GET_CLK_SRC(reg));
 }
 
-#ifdef S3C_UART_HAS_UBRDIVSLOT
 /*
  * This table takes the fractional value of the baud divisor and gives
  * the recommended setting for the UDIVSLOT register. Refer the datasheet
@@ -73,7 +72,6 @@ static const uint16_t udivslot_table[] __maybe_unused = {
 	0x0000, 0x0080, 0x0808, 0x0888, 0x2222, 0x4924, 0x4A52, 0x54AA,
 	0x5555, 0xD555, 0xD5D5, 0xDDD5, 0xDDDD, 0xDFDD, 0xDFDF, 0xFFDF,
 };
-#endif
 
 static int s3c_serial_setbaudrate(struct console_device *cdev, int baudrate)
 {
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 7/9] Samsung/serial: move the decision about an improved UART into Kconfig
  2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
                   ` (5 preceding siblings ...)
  2012-07-20 19:29 ` [PATCH 6/9] Samsung/serial: there is no need to ifdef the slot table Juergen Beisert
@ 2012-07-20 19:29 ` Juergen Beisert
  2012-07-23  6:41   ` Sascha Hauer
  2012-07-20 19:29 ` [PATCH 8/9] Samsung/serial: unify UCON register settings Juergen Beisert
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Juergen Beisert @ 2012-07-20 19:29 UTC (permalink / raw)
  To: barebox

More or less just cosmetic (removing ifdefs!).

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 arch/arm/mach-samsung/Kconfig                     |    5 +++++
 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h |    5 +++--
 drivers/serial/serial_s3c.c                       |   16 ++++++++--------
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig
index c60f5ed..37d1aa3 100644
--- a/arch/arm/mach-samsung/Kconfig
+++ b/arch/arm/mach-samsung/Kconfig
@@ -18,6 +18,9 @@ config ARCH_BAREBOX_MAX_BARE_INIT_SIZE
 	hex
 	default 0x1ff0 if ARCH_S5PCxx
 
+config SAMSUNG_IMPROVED_UART
+	bool
+
 if ARCH_S3C24xx
 
 config CPU_S3C2410
@@ -87,9 +90,11 @@ endif
 if ARCH_S5PCxx
 
 config CPU_S5PC110
+	select SAMSUNG_IMPROVED_UART
 	bool
 
 config CPU_S5PV210
+	select SAMSUNG_IMPROVED_UART
 	bool
 
 #choice
diff --git a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h
index cb05527..448e3b8 100644
--- a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h
+++ b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h
@@ -45,5 +45,6 @@
 #define S3C_UART2_SIZE 0x400
 #define S3C_UART3_BASE (S3C_UART_BASE + 0x800)
 #define S3C_UART3_SIZE 0x400
-#define S3C_UART_HAS_UBRDIVSLOT
-#define S3C_UART_HAS_UINTM
+
+#define S5P_DMC0_BASE 0xF0000000
+#define S5P_DMC1_BASE 0xF1400000
diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index 2cb2eef..01f2246 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -79,10 +79,11 @@ static int s3c_serial_setbaudrate(struct console_device *cdev, int baudrate)
 	void __iomem *base = priv->regs;
 	unsigned val;
 
-#ifdef S3C_UART_HAS_UBRDIVSLOT
-	val = s3c_get_arch_uart_input_clock(base) / baudrate;
-	writew(udivslot_table[val & 15], base + UBRDIVSLOT);
-#endif
+	if (IS_ENABLED(CONFIG_SAMSUNG_IMPROVED_UART)) {
+		val = s3c_get_arch_uart_input_clock(base) / baudrate;
+		writew(udivslot_table[val & 15], base + UBRDIVSLOT);
+	}
+
 	val = s3c_get_arch_uart_input_clock(base) / (16 * baudrate) - 1;
 	writew(val, base + UBRDIV);
 
@@ -106,10 +107,9 @@ static int s3c_serial_init_port(struct console_device *cdev)
 	writew(0x0245 | UCON_SET_CLK_SRC(S3C_UART_CLKSEL),
 						base + UCON);
 
-#ifdef S3C_UART_HAS_UINTM
-	/* 'interrupt or polling mode' for both directions */
-	writeb(0xf, base + UINTM);
-#endif
+	if (IS_ENABLED(CONFIG_SAMSUNG_IMPROVED_UART))
+		/* 'interrupt or polling mode' for both directions */
+		writeb(0xf, base + UINTM);
 
 	if (IS_ENABLED(CONFIG_DRIVER_SERIAL_S3C_AUTOSYNC))
 		writeb(0x10, base + UMCON); /* enable auto flow control */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 8/9] Samsung/serial: unify UCON register settings
  2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
                   ` (6 preceding siblings ...)
  2012-07-20 19:29 ` [PATCH 7/9] Samsung/serial: move the decision about an improved UART into Kconfig Juergen Beisert
@ 2012-07-20 19:29 ` Juergen Beisert
  2012-07-20 19:29 ` [PATCH 9/9] Samsung/serial: make the clock source configureable Juergen Beisert
  2012-07-23 22:10 ` [PATCH] ARM/Samsung: more clean up Sascha Hauer
  9 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-20 19:29 UTC (permalink / raw)
  To: barebox

This should work on S3C24XX and S3C64XX SoCs.

Tested at runtime on a Mini2440 and Mini6410.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/serial/serial_s3c.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index 01f2246..39680ae 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -102,9 +102,13 @@ static int s3c_serial_init_port(struct console_device *cdev)
 	/* Normal,No parity,1 stop,8 bit */
 	writeb(0x03, base + ULCON);
 
-	/* tx=level,rx=edge,disable timeout int.,enable rx error int.,
-	 * normal, interrupt or polling, no pre-divider */
-	writew(0x0245 | UCON_SET_CLK_SRC(S3C_UART_CLKSEL),
+	/*
+	 * S3C2440 SoC:
+	 *  - no clock divider
+	 * all SoCs:
+	 *  - enable receive and transmit mode
+	 */
+	writew(0x0005 | UCON_SET_CLK_SRC(S3C_UART_CLKSEL),
 						base + UCON);
 
 	if (IS_ENABLED(CONFIG_SAMSUNG_IMPROVED_UART))
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 9/9] Samsung/serial: make the clock source configureable
  2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
                   ` (7 preceding siblings ...)
  2012-07-20 19:29 ` [PATCH 8/9] Samsung/serial: unify UCON register settings Juergen Beisert
@ 2012-07-20 19:29 ` Juergen Beisert
  2012-07-23 22:10 ` [PATCH] ARM/Samsung: more clean up Sascha Hauer
  9 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-20 19:29 UTC (permalink / raw)
  To: barebox

Instead of taking the value from somewhere, use the selected architecture to
select one. This ensures the selected clock source corresponds to the values
setup in the clocks-*.c from the mach directory.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/serial/serial_s3c.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index 39680ae..53ac77f 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -45,11 +45,6 @@
 #define UBRDIVSLOT 0x2c		/* baudrate slot generator */
 #define UINTM 0x38		/* interrupt mask register */
 
-#ifndef S3C_UART_CLKSEL
-/* Use pclk */
-# define S3C_UART_CLKSEL 0
-#endif
-
 struct s3c_uart {
 	void __iomem *regs;
 	struct console_device cdev;
@@ -57,6 +52,17 @@ struct s3c_uart {
 
 #define to_s3c_uart(c)	container_of(c, struct s3c_uart, cdev)
 
+/* each architecture has a preferred reference clock for its UARTs */
+static unsigned s3c_select_arch_input_clock(void)
+{
+	/* S3C24xx: 0=2=PCLK, 1=UEXTCLK, 3=FCLK/n */
+	if (IS_ENABLED(CONFIG_ARCH_S3C24xx))
+		return 0;	/* use the internal PCLK */
+	/* S5PCxx: 0=PCLK, 1=SCLK_UART */
+	if (IS_ENABLED(CONFIG_ARCH_S5PCxx))
+		return 0;	/* use the internal PCLK */
+}
+
 static unsigned s3c_get_arch_uart_input_clock(void __iomem *base)
 {
 	unsigned reg = readw(base + UCON);
@@ -108,7 +114,7 @@ static int s3c_serial_init_port(struct console_device *cdev)
 	 * all SoCs:
 	 *  - enable receive and transmit mode
 	 */
-	writew(0x0005 | UCON_SET_CLK_SRC(S3C_UART_CLKSEL),
+	writew(0x0005 | UCON_SET_CLK_SRC(s3c_select_arch_input_clock()),
 						base + UCON);
 
 	if (IS_ENABLED(CONFIG_SAMSUNG_IMPROVED_UART))
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 7/9] Samsung/serial: move the decision about an improved UART into Kconfig
  2012-07-20 19:29 ` [PATCH 7/9] Samsung/serial: move the decision about an improved UART into Kconfig Juergen Beisert
@ 2012-07-23  6:41   ` Sascha Hauer
  2012-07-24  9:24     ` [PATCH] ARM/Samsung: remaining clean up Juergen Beisert
  0 siblings, 1 reply; 17+ messages in thread
From: Sascha Hauer @ 2012-07-23  6:41 UTC (permalink / raw)
  To: Juergen Beisert; +Cc: barebox

On Fri, Jul 20, 2012 at 09:29:43PM +0200, Juergen Beisert wrote:
> More or less just cosmetic (removing ifdefs!).
> 
> Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
> ---
>  arch/arm/mach-samsung/Kconfig                     |    5 +++++
>  arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h |    5 +++--
>  drivers/serial/serial_s3c.c                       |   16 ++++++++--------
>  3 files changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/mach-samsung/Kconfig b/arch/arm/mach-samsung/Kconfig
> index c60f5ed..37d1aa3 100644
> --- a/arch/arm/mach-samsung/Kconfig
> +++ b/arch/arm/mach-samsung/Kconfig
> @@ -18,6 +18,9 @@ config ARCH_BAREBOX_MAX_BARE_INIT_SIZE
>  	hex
>  	default 0x1ff0 if ARCH_S5PCxx
>  
> +config SAMSUNG_IMPROVED_UART
> +	bool

This is a Samsung UART specific define, so it should be in
drivers/serial/Kconfig and be renamed to
DRIVER_SERIAL_S3C_IMPROVED.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ARM/Samsung: more clean up...
  2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
                   ` (8 preceding siblings ...)
  2012-07-20 19:29 ` [PATCH 9/9] Samsung/serial: make the clock source configureable Juergen Beisert
@ 2012-07-23 22:10 ` Sascha Hauer
  9 siblings, 0 replies; 17+ messages in thread
From: Sascha Hauer @ 2012-07-23 22:10 UTC (permalink / raw)
  To: Juergen Beisert; +Cc: barebox

Hi Jürgen,

On Fri, Jul 20, 2012 at 09:29:36PM +0200, Juergen Beisert wrote:
> ...in preparation to add the S3C6410 SoC support.
> 
> Mostly simplifying the Samsung serial driver and some more cosmetic.
> 
> Comments are welcome.

Applied up to 6/9

Thanks
 Sascha

> 
> Regards,
> Juergen
> 
> The following changes since commit b47220d7f70df9191fc456dbcaeaa6ead72c6c02:
> 
>   NAND/Samsung: remove a leftover from architeture clean ups (2012-07-20 08:41:35 +0200)
> 
> are available in the git repository at:
> 
>   git://git.pengutronix.de/git/jbe/barebox.git master_samsung_clean_up
> 
> for you to fetch changes up to fc361ff7de449f9bb8a7653a5705621320d84560:
> 
>   Samsung/serial: make the clock source configureable (2012-07-20 21:16:02 +0200)
> 
> ----------------------------------------------------------------
> Juergen Beisert (9):
>       ARM/Samsung: List only really supported S3C24xx SoCs
>       ARM/Samsung: follow the name style of the other source files in this directory
>       Samsung/serial: remove more ugly ifdef lines
>       Samsung/serial: make the code more readable
>       Samsung/serial: there is no need to ifdef these register defines
>       Samsung/serial: there is no need to ifdef the slot table
>       Samsung/serial: move the decision about an improved UART into Kconfig
>       Samsung/serial: unify UCON register settings
>       Samsung/serial: make the clock source configureable
> 
>  arch/arm/Kconfig                                   |    2 +-
>  arch/arm/mach-samsung/Kconfig                      |    5 ++
>  arch/arm/mach-samsung/Makefile                     |    3 +-
>  .../{s3c24xx-clocks.c => clocks-s3c24xx.c}         |    0
>  arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h  |    5 +-
>  drivers/serial/serial_s3c.c                        |   71 +++++++++++---------
>  6 files changed, 48 insertions(+), 38 deletions(-)
>  rename arch/arm/mach-samsung/{s3c24xx-clocks.c => clocks-s3c24xx.c} (100%)
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] ARM/Samsung: remaining clean up...
  2012-07-23  6:41   ` Sascha Hauer
@ 2012-07-24  9:24     ` Juergen Beisert
  2012-07-24  9:24       ` [PATCH 1/3] Samsung/serial: move the decision about an improved UART into Kconfig Juergen Beisert
                         ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-24  9:24 UTC (permalink / raw)
  To: barebox

...in preparation to add the S3C6410 SoC support.

Mostly simplifying the Samsung serial driver and some more cosmetic. These
patches are a re-work and re-send of the remaining ones not yet included from
the previous "ARM/Samsung: more clean up..." series.

The patches 1/3 and 3/3 base on the current "next", because they touch code
for the new S5Pxx SoCs.

jbe


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/3] Samsung/serial: move the decision about an improved UART into Kconfig
  2012-07-24  9:24     ` [PATCH] ARM/Samsung: remaining clean up Juergen Beisert
@ 2012-07-24  9:24       ` Juergen Beisert
  2012-07-24  9:24       ` [PATCH 2/3] Samsung/serial: unify UCON register settings Juergen Beisert
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-24  9:24 UTC (permalink / raw)
  To: barebox

More or less just cosmetic (removing ifdefs!).

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h |    2 --
 drivers/serial/Kconfig                            |    4 ++++
 drivers/serial/serial_s3c.c                       |   16 ++++++++--------
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h
index 248f868..448e3b8 100644
--- a/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h
+++ b/arch/arm/mach-samsung/include/mach/s5pcxx-iomap.h
@@ -45,8 +45,6 @@
 #define S3C_UART2_SIZE 0x400
 #define S3C_UART3_BASE (S3C_UART_BASE + 0x800)
 #define S3C_UART3_SIZE 0x400
-#define S3C_UART_HAS_UBRDIVSLOT
-#define S3C_UART_HAS_UINTM
 
 #define S5P_DMC0_BASE 0xF0000000
 #define S5P_DMC1_BASE 0xF1400000
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index a9383da..2b9a9b9 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -78,9 +78,13 @@ config DRIVER_SERIAL_PL010
 	help
 	  Enable this to get support for AMBA PL010 based serial devices
 
+config DRIVER_SERIAL_S3C_IMPROVED
+	bool
+
 config DRIVER_SERIAL_S3C
 	bool "Samsung S3C serial driver"
 	depends on ARCH_SAMSUNG
+	select DRIVER_SERIAL_S3C_IMPROVED if (CPU_S5PC110 || CPU_S5PV210)
 	default y
 	help
 	  Say Y here if you want to use the CONS on a Samsung S3C CPU
diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index 2cb2eef..877ccd2 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -79,10 +79,11 @@ static int s3c_serial_setbaudrate(struct console_device *cdev, int baudrate)
 	void __iomem *base = priv->regs;
 	unsigned val;
 
-#ifdef S3C_UART_HAS_UBRDIVSLOT
-	val = s3c_get_arch_uart_input_clock(base) / baudrate;
-	writew(udivslot_table[val & 15], base + UBRDIVSLOT);
-#endif
+	if (IS_ENABLED(CONFIG_DRIVER_SERIAL_S3C_IMPROVED)) {
+		val = s3c_get_arch_uart_input_clock(base) / baudrate;
+		writew(udivslot_table[val & 15], base + UBRDIVSLOT);
+	}
+
 	val = s3c_get_arch_uart_input_clock(base) / (16 * baudrate) - 1;
 	writew(val, base + UBRDIV);
 
@@ -106,10 +107,9 @@ static int s3c_serial_init_port(struct console_device *cdev)
 	writew(0x0245 | UCON_SET_CLK_SRC(S3C_UART_CLKSEL),
 						base + UCON);
 
-#ifdef S3C_UART_HAS_UINTM
-	/* 'interrupt or polling mode' for both directions */
-	writeb(0xf, base + UINTM);
-#endif
+	if (IS_ENABLED(CONFIG_DRIVER_SERIAL_S3C_IMPROVED))
+		/* 'interrupt or polling mode' for both directions */
+		writeb(0xf, base + UINTM);
 
 	if (IS_ENABLED(CONFIG_DRIVER_SERIAL_S3C_AUTOSYNC))
 		writeb(0x10, base + UMCON); /* enable auto flow control */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 2/3] Samsung/serial: unify UCON register settings
  2012-07-24  9:24     ` [PATCH] ARM/Samsung: remaining clean up Juergen Beisert
  2012-07-24  9:24       ` [PATCH 1/3] Samsung/serial: move the decision about an improved UART into Kconfig Juergen Beisert
@ 2012-07-24  9:24       ` Juergen Beisert
  2012-07-24  9:24       ` [PATCH 3/3] Samsung/serial: make the clock source configureable Juergen Beisert
  2012-07-25  6:31       ` [PATCH] ARM/Samsung: remaining clean up Sascha Hauer
  3 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-24  9:24 UTC (permalink / raw)
  To: barebox

This should work on S3C24XX and S3C64XX SoCs.

Tested at runtime on a Mini2440 and Mini6410.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/serial/serial_s3c.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index 877ccd2..96fe847 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -102,9 +102,13 @@ static int s3c_serial_init_port(struct console_device *cdev)
 	/* Normal,No parity,1 stop,8 bit */
 	writeb(0x03, base + ULCON);
 
-	/* tx=level,rx=edge,disable timeout int.,enable rx error int.,
-	 * normal, interrupt or polling, no pre-divider */
-	writew(0x0245 | UCON_SET_CLK_SRC(S3C_UART_CLKSEL),
+	/*
+	 * S3C2440 SoC:
+	 *  - no clock divider
+	 * all SoCs:
+	 *  - enable receive and transmit mode
+	 */
+	writew(0x0005 | UCON_SET_CLK_SRC(S3C_UART_CLKSEL),
 						base + UCON);
 
 	if (IS_ENABLED(CONFIG_DRIVER_SERIAL_S3C_IMPROVED))
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 3/3] Samsung/serial: make the clock source configureable
  2012-07-24  9:24     ` [PATCH] ARM/Samsung: remaining clean up Juergen Beisert
  2012-07-24  9:24       ` [PATCH 1/3] Samsung/serial: move the decision about an improved UART into Kconfig Juergen Beisert
  2012-07-24  9:24       ` [PATCH 2/3] Samsung/serial: unify UCON register settings Juergen Beisert
@ 2012-07-24  9:24       ` Juergen Beisert
  2012-07-25  6:31       ` [PATCH] ARM/Samsung: remaining clean up Sascha Hauer
  3 siblings, 0 replies; 17+ messages in thread
From: Juergen Beisert @ 2012-07-24  9:24 UTC (permalink / raw)
  To: barebox

Instead of taking the value from somewhere, use the selected architecture to
select one. This ensures the selected clock source corresponds to the values
setup in the clocks-*.c from the mach directory.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/serial/serial_s3c.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/serial/serial_s3c.c b/drivers/serial/serial_s3c.c
index 96fe847..0a7b137 100644
--- a/drivers/serial/serial_s3c.c
+++ b/drivers/serial/serial_s3c.c
@@ -45,11 +45,6 @@
 #define UBRDIVSLOT 0x2c		/* baudrate slot generator */
 #define UINTM 0x38		/* interrupt mask register */
 
-#ifndef S3C_UART_CLKSEL
-/* Use pclk */
-# define S3C_UART_CLKSEL 0
-#endif
-
 struct s3c_uart {
 	void __iomem *regs;
 	struct console_device cdev;
@@ -57,6 +52,17 @@ struct s3c_uart {
 
 #define to_s3c_uart(c)	container_of(c, struct s3c_uart, cdev)
 
+/* each architecture has a preferred reference clock for its UARTs */
+static unsigned s3c_select_arch_input_clock(void)
+{
+	/* S3C24xx: 0=2=PCLK, 1=UEXTCLK, 3=FCLK/n */
+	if (IS_ENABLED(CONFIG_ARCH_S3C24xx))
+		return 0;	/* use the internal PCLK */
+	/* S5PCxx: 0=PCLK, 1=SCLK_UART */
+	if (IS_ENABLED(CONFIG_ARCH_S5PCxx))
+		return 0;	/* use the internal PCLK */
+}
+
 static unsigned s3c_get_arch_uart_input_clock(void __iomem *base)
 {
 	unsigned reg = readw(base + UCON);
@@ -108,7 +114,7 @@ static int s3c_serial_init_port(struct console_device *cdev)
 	 * all SoCs:
 	 *  - enable receive and transmit mode
 	 */
-	writew(0x0005 | UCON_SET_CLK_SRC(S3C_UART_CLKSEL),
+	writew(0x0005 | UCON_SET_CLK_SRC(s3c_select_arch_input_clock()),
 						base + UCON);
 
 	if (IS_ENABLED(CONFIG_DRIVER_SERIAL_S3C_IMPROVED))
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] ARM/Samsung: remaining clean up...
  2012-07-24  9:24     ` [PATCH] ARM/Samsung: remaining clean up Juergen Beisert
                         ` (2 preceding siblings ...)
  2012-07-24  9:24       ` [PATCH 3/3] Samsung/serial: make the clock source configureable Juergen Beisert
@ 2012-07-25  6:31       ` Sascha Hauer
  3 siblings, 0 replies; 17+ messages in thread
From: Sascha Hauer @ 2012-07-25  6:31 UTC (permalink / raw)
  To: Juergen Beisert; +Cc: barebox

On Tue, Jul 24, 2012 at 11:24:48AM +0200, Juergen Beisert wrote:
> ...in preparation to add the S3C6410 SoC support.
> 
> Mostly simplifying the Samsung serial driver and some more cosmetic. These
> patches are a re-work and re-send of the remaining ones not yet included from
> the previous "ARM/Samsung: more clean up..." series.
> 
> The patches 1/3 and 3/3 base on the current "next", because they touch code
> for the new S5Pxx SoCs.

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-07-25  6:32 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-20 19:29 [PATCH] ARM/Samsung: more clean up Juergen Beisert
2012-07-20 19:29 ` [PATCH 1/9] ARM/Samsung: List only really supported S3C24xx SoCs Juergen Beisert
2012-07-20 19:29 ` [PATCH 2/9] ARM/Samsung: follow the name style of the other source files in this directory Juergen Beisert
2012-07-20 19:29 ` [PATCH 3/9] Samsung/serial: remove more ugly ifdef lines Juergen Beisert
2012-07-20 19:29 ` [PATCH 4/9] Samsung/serial: make the code more readable Juergen Beisert
2012-07-20 19:29 ` [PATCH 5/9] Samsung/serial: there is no need to ifdef these register defines Juergen Beisert
2012-07-20 19:29 ` [PATCH 6/9] Samsung/serial: there is no need to ifdef the slot table Juergen Beisert
2012-07-20 19:29 ` [PATCH 7/9] Samsung/serial: move the decision about an improved UART into Kconfig Juergen Beisert
2012-07-23  6:41   ` Sascha Hauer
2012-07-24  9:24     ` [PATCH] ARM/Samsung: remaining clean up Juergen Beisert
2012-07-24  9:24       ` [PATCH 1/3] Samsung/serial: move the decision about an improved UART into Kconfig Juergen Beisert
2012-07-24  9:24       ` [PATCH 2/3] Samsung/serial: unify UCON register settings Juergen Beisert
2012-07-24  9:24       ` [PATCH 3/3] Samsung/serial: make the clock source configureable Juergen Beisert
2012-07-25  6:31       ` [PATCH] ARM/Samsung: remaining clean up Sascha Hauer
2012-07-20 19:29 ` [PATCH 8/9] Samsung/serial: unify UCON register settings Juergen Beisert
2012-07-20 19:29 ` [PATCH 9/9] Samsung/serial: make the clock source configureable Juergen Beisert
2012-07-23 22:10 ` [PATCH] ARM/Samsung: more clean up Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox