All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] arm:samsung:serial: Extract common Samsung UART code
@ 2013-07-21 21:50 Lukasz Majewski
  2013-07-25 21:43 ` [U-Boot] [PATCH v2] arm:samsung:serial Extract common " Lukasz Majewski
  2013-08-12 21:15 ` [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code Lukasz Majewski
  0 siblings, 2 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-07-21 21:50 UTC (permalink / raw)
  To: u-boot

This commit removes duplicated code for UART IP block embedded at Samsung
SoCs.
New ./include/asm/samsung-common directory has been created to store
common code for existing and future Samsung targets.

Additionally building of UART code now depends on more verbose
CONFIG_S5P_SERIAL define.
For this reason all relevant configs have been adjusted.

Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
Cc: Minkyu Kang <mk7.kang@samsung.com>
---
 arch/arm/include/asm/arch-exynos/uart.h    |   58 ------------------
 arch/arm/include/asm/arch-s5pc1xx/uart.h   |   58 ------------------
 arch/arm/include/asm/samsung-common/uart.h |   88 ++++++++++++++++++++++++++++
 drivers/serial/Makefile                    |    2 +-
 drivers/serial/serial_s5p.c                |   13 +---
 include/configs/exynos5250-dt.h            |    1 +
 include/configs/origen.h                   |    1 +
 include/configs/s5p_goni.h                 |    1 +
 include/configs/s5pc210_universal.h        |    1 +
 include/configs/smdkc100.h                 |    1 +
 include/configs/smdkv310.h                 |    1 +
 include/configs/trats.h                    |    1 +
 12 files changed, 98 insertions(+), 128 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-exynos/uart.h
 delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/uart.h
 create mode 100644 arch/arm/include/asm/samsung-common/uart.h

diff --git a/arch/arm/include/asm/arch-exynos/uart.h b/arch/arm/include/asm/arch-exynos/uart.h
deleted file mode 100644
index 6cc68df..0000000
--- a/arch/arm/include/asm/arch-exynos/uart.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * (C) Copyright 2009 Samsung Electronics
- * Minkyu Kang <mk7.kang@samsung.com>
- * Heungjun Kim <riverful.kim@samsung.com>
- *
- * 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_UART_H_
-#define __ASM_ARCH_UART_H_
-
-#ifndef __ASSEMBLY__
-/* baudrate rest value */
-union br_rest {
-	unsigned short	slot;		/* udivslot */
-	unsigned char	value;		/* ufracval */
-};
-
-struct s5p_uart {
-	unsigned int	ulcon;
-	unsigned int	ucon;
-	unsigned int	ufcon;
-	unsigned int	umcon;
-	unsigned int	utrstat;
-	unsigned int	uerstat;
-	unsigned int	ufstat;
-	unsigned int	umstat;
-	unsigned char	utxh;
-	unsigned char	res1[3];
-	unsigned char	urxh;
-	unsigned char	res2[3];
-	unsigned int	ubrdiv;
-	union br_rest	rest;
-	unsigned char	res3[0xffd0];
-};
-
-static inline int s5p_uart_divslot(void)
-{
-	return 0;
-}
-
-#endif	/* __ASSEMBLY__ */
-
-#endif
diff --git a/arch/arm/include/asm/arch-s5pc1xx/uart.h b/arch/arm/include/asm/arch-s5pc1xx/uart.h
deleted file mode 100644
index 1c56739..0000000
--- a/arch/arm/include/asm/arch-s5pc1xx/uart.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * (C) Copyright 2009 Samsung Electronics
- * Minkyu Kang <mk7.kang@samsung.com>
- * Heungjun Kim <riverful.kim@samsung.com>
- *
- * 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_UART_H_
-#define __ASM_ARCH_UART_H_
-
-#ifndef __ASSEMBLY__
-/* baudrate rest value */
-union br_rest {
-	unsigned short	slot;		/* udivslot */
-	unsigned char	value;		/* ufracval */
-};
-
-struct s5p_uart {
-	unsigned int	ulcon;
-	unsigned int	ucon;
-	unsigned int	ufcon;
-	unsigned int	umcon;
-	unsigned int	utrstat;
-	unsigned int	uerstat;
-	unsigned int	ufstat;
-	unsigned int	umstat;
-	unsigned char	utxh;
-	unsigned char	res1[3];
-	unsigned char	urxh;
-	unsigned char	res2[3];
-	unsigned int	ubrdiv;
-	union br_rest	rest;
-	unsigned char	res3[0x3d0];
-};
-
-static inline int s5p_uart_divslot(void)
-{
-	return 1;
-}
-
-#endif	/* __ASSEMBLY__ */
-
-#endif
diff --git a/arch/arm/include/asm/samsung-common/uart.h b/arch/arm/include/asm/samsung-common/uart.h
new file mode 100644
index 0000000..3b6572d
--- /dev/null
+++ b/arch/arm/include/asm/samsung-common/uart.h
@@ -0,0 +1,88 @@
+/*
+ * (C) Copyright 2009 Samsung Electronics
+ * Minkyu Kang <mk7.kang@samsung.com>
+ * Heungjun Kim <riverful.kim@samsung.com>
+ *
+ * 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_UART_H_
+#define __ASM_ARCH_UART_H_
+
+#ifndef __ASSEMBLY__
+/* baudrate rest value */
+union br_rest {
+	unsigned short	slot;		/* udivslot */
+	unsigned char	value;		/* ufracval */
+};
+
+struct s5p_uart {
+	unsigned int	ulcon;
+	unsigned int	ucon;
+	unsigned int	ufcon;
+	unsigned int	umcon;
+	unsigned int	utrstat;
+	unsigned int	uerstat;
+	unsigned int	ufstat;
+	unsigned int	umstat;
+	unsigned char	utxh;
+	unsigned char	res1[3];
+	unsigned char	urxh;
+	unsigned char	res2[3];
+	unsigned int	ubrdiv;
+	union br_rest	rest;
+#if defined(CONFIG_S5PC100) ||     \
+	defined(CONFIG_S5PC110) || \
+	defined(CONFIG_S3C64XX)
+	unsigned char	res3[0x3d0];
+#else /* Exynos 4 and 5 */
+	unsigned char	res3[0xffd0];
+#endif
+};
+
+
+static inline int s5p_uart_divslot(void)
+{
+#if defined(CONFIG_S5PC100) ||     \
+	defined(CONFIG_S5PC110) || \
+	defined(CONFIG_S3C64XX)
+	return 1;
+#else /* Exynos 4 and 5 */
+	return 0;
+#endif
+}
+
+#if defined(CONFIG_S3C64XX)
+#define RX_FIFO_COUNT_MASK	0x3f
+#define RX_FIFO_FULL_MASK	(1 << 6)
+#define TX_FIFO_FULL_MASK	(1 << 14)
+#else /* S5PC110 and Exynos 4 and 5 */
+#define RX_FIFO_COUNT_MASK      0xff
+#define RX_FIFO_FULL_MASK       (1 << 8)
+#define TX_FIFO_FULL_MASK       (1 << 24)
+#endif
+
+/* Information about a serial port */
+struct fdt_serial {
+	u32 base_addr;  /* address of registers in physical memory */
+	u8 port_id;     /* uart port number */
+	u8 enabled;     /* 1 if enabled, 0 if disabled */
+};
+
+#endif	/* __ASSEMBLY__ */
+
+#endif
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 0f954a5..4c4ba75 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -35,7 +35,7 @@ COBJS-$(CONFIG_LPC32XX_HSUART) += lpc32xx_hsuart.o
 COBJS-$(CONFIG_MCFUART) += mcfuart.o
 COBJS-$(CONFIG_OPENCORES_YANU) += opencores_yanu.o
 COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
-COBJS-$(CONFIG_S5P) += serial_s5p.o
+COBJS-$(CONFIG_S5P_SERIAL) += serial_s5p.o
 COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial_ns16550.o
 COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
 COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
index 6836c7a..fb0677b 100644
--- a/drivers/serial/serial_s5p.c
+++ b/drivers/serial/serial_s5p.c
@@ -25,22 +25,13 @@
 #include <fdtdec.h>
 #include <linux/compiler.h>
 #include <asm/io.h>
-#include <asm/arch/uart.h>
+#include <asm/samsung-common/uart.h>
 #include <asm/arch/clk.h>
 #include <serial.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define RX_FIFO_COUNT_MASK	0xff
-#define RX_FIFO_FULL_MASK	(1 << 8)
-#define TX_FIFO_FULL_MASK	(1 << 24)
-
-/* Information about a serial port */
-struct fdt_serial {
-	u32 base_addr;  /* address of registers in physical memory */
-	u8 port_id;     /* uart port number */
-	u8 enabled;     /* 1 if enabled, 0 if disabled */
-} config __attribute__ ((section(".data")));
+struct fdt_serial config __attribute__ ((section(".data")));
 
 static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
 {
diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index 582c584..303a8de 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -86,6 +86,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (4 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_BAUDRATE			115200
 #define EXYNOS5_DEFAULT_UART_OFFSET	0x010000
 #define CONFIG_SILENT_CONSOLE
diff --git a/include/configs/origen.h b/include/configs/origen.h
index 5013aee..7197243 100644
--- a/include/configs/origen.h
+++ b/include/configs/origen.h
@@ -64,6 +64,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2			1	/* use SERIAL 2 */
 #define CONFIG_BAUDRATE			115200
 #define EXYNOS4_DEFAULT_UART_OFFSET	0x020000
diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
index 56e8347..440c4a3 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -58,6 +58,7 @@
 /*
  * select serial console configuration
  */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2			1	/* use SERIAL2 */
 #define CONFIG_BAUDRATE			115200
 
diff --git a/include/configs/s5pc210_universal.h b/include/configs/s5pc210_universal.h
index eb13bb3..398db2a 100644
--- a/include/configs/s5pc210_universal.h
+++ b/include/configs/s5pc210_universal.h
@@ -64,6 +64,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2		1	/* use SERIAL 2 */
 #define CONFIG_BAUDRATE		115200
 
diff --git a/include/configs/smdkc100.h b/include/configs/smdkc100.h
index fb640db..6964a77 100644
--- a/include/configs/smdkc100.h
+++ b/include/configs/smdkc100.h
@@ -63,6 +63,7 @@
 /*
  * select serial console configuration
  */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL0			1	/* use SERIAL 0 on SMDKC100 */
 
 /* PWM */
diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h
index 0f04597..3c68543 100644
--- a/include/configs/smdkv310.h
+++ b/include/configs/smdkv310.h
@@ -64,6 +64,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL1			1	/* use SERIAL 1 */
 #define CONFIG_BAUDRATE			115200
 #define EXYNOS4_DEFAULT_UART_OFFSET	0x010000
diff --git a/include/configs/trats.h b/include/configs/trats.h
index 356d87b..e9c1fa4 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -69,6 +69,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (16 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2			/* use SERIAL 2 */
 #define CONFIG_BAUDRATE			115200
 
-- 
1.7.10.4

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

* [U-Boot] [PATCH v2] arm:samsung:serial Extract common UART code
  2013-07-21 21:50 [U-Boot] [PATCH] arm:samsung:serial: Extract common Samsung UART code Lukasz Majewski
@ 2013-07-25 21:43 ` Lukasz Majewski
  2013-08-12 21:15 ` [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code Lukasz Majewski
  1 sibling, 0 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-07-25 21:43 UTC (permalink / raw)
  To: u-boot

This commit brings removal of duplicated code for UART IP block embedded
at Samsung SoCs.
New include/asm/samsung-common directory has been created to store
common code for existing and future Samsung targets.

Moreover building of UART code now depends on more verbose CONFIG_S5P_SERIAL.
Thereof all relevant boards configs have been adjusted.

Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>

---
Changes for v2:
- Remove S3C64XX define from the code
---
 arch/arm/include/asm/arch-exynos/uart.h    |   58 ---------------------
 arch/arm/include/asm/arch-s5pc1xx/uart.h   |   58 ---------------------
 arch/arm/include/asm/samsung-common/uart.h |   78 ++++++++++++++++++++++++++++
 drivers/serial/Makefile                    |    2 +-
 drivers/serial/serial_s5p.c                |   13 +----
 include/configs/exynos5250-dt.h            |    1 +
 include/configs/origen.h                   |    1 +
 include/configs/s5p_goni.h                 |    1 +
 include/configs/s5pc210_universal.h        |    1 +
 include/configs/smdkc100.h                 |    1 +
 include/configs/smdkv310.h                 |    1 +
 include/configs/trats.h                    |    1 +
 12 files changed, 88 insertions(+), 128 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-exynos/uart.h
 delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/uart.h
 create mode 100644 arch/arm/include/asm/samsung-common/uart.h

diff --git a/arch/arm/include/asm/arch-exynos/uart.h b/arch/arm/include/asm/arch-exynos/uart.h
deleted file mode 100644
index 6cc68df..0000000
--- a/arch/arm/include/asm/arch-exynos/uart.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * (C) Copyright 2009 Samsung Electronics
- * Minkyu Kang <mk7.kang@samsung.com>
- * Heungjun Kim <riverful.kim@samsung.com>
- *
- * 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_UART_H_
-#define __ASM_ARCH_UART_H_
-
-#ifndef __ASSEMBLY__
-/* baudrate rest value */
-union br_rest {
-	unsigned short	slot;		/* udivslot */
-	unsigned char	value;		/* ufracval */
-};
-
-struct s5p_uart {
-	unsigned int	ulcon;
-	unsigned int	ucon;
-	unsigned int	ufcon;
-	unsigned int	umcon;
-	unsigned int	utrstat;
-	unsigned int	uerstat;
-	unsigned int	ufstat;
-	unsigned int	umstat;
-	unsigned char	utxh;
-	unsigned char	res1[3];
-	unsigned char	urxh;
-	unsigned char	res2[3];
-	unsigned int	ubrdiv;
-	union br_rest	rest;
-	unsigned char	res3[0xffd0];
-};
-
-static inline int s5p_uart_divslot(void)
-{
-	return 0;
-}
-
-#endif	/* __ASSEMBLY__ */
-
-#endif
diff --git a/arch/arm/include/asm/arch-s5pc1xx/uart.h b/arch/arm/include/asm/arch-s5pc1xx/uart.h
deleted file mode 100644
index 1c56739..0000000
--- a/arch/arm/include/asm/arch-s5pc1xx/uart.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * (C) Copyright 2009 Samsung Electronics
- * Minkyu Kang <mk7.kang@samsung.com>
- * Heungjun Kim <riverful.kim@samsung.com>
- *
- * 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_UART_H_
-#define __ASM_ARCH_UART_H_
-
-#ifndef __ASSEMBLY__
-/* baudrate rest value */
-union br_rest {
-	unsigned short	slot;		/* udivslot */
-	unsigned char	value;		/* ufracval */
-};
-
-struct s5p_uart {
-	unsigned int	ulcon;
-	unsigned int	ucon;
-	unsigned int	ufcon;
-	unsigned int	umcon;
-	unsigned int	utrstat;
-	unsigned int	uerstat;
-	unsigned int	ufstat;
-	unsigned int	umstat;
-	unsigned char	utxh;
-	unsigned char	res1[3];
-	unsigned char	urxh;
-	unsigned char	res2[3];
-	unsigned int	ubrdiv;
-	union br_rest	rest;
-	unsigned char	res3[0x3d0];
-};
-
-static inline int s5p_uart_divslot(void)
-{
-	return 1;
-}
-
-#endif	/* __ASSEMBLY__ */
-
-#endif
diff --git a/arch/arm/include/asm/samsung-common/uart.h b/arch/arm/include/asm/samsung-common/uart.h
new file mode 100644
index 0000000..164f1ef
--- /dev/null
+++ b/arch/arm/include/asm/samsung-common/uart.h
@@ -0,0 +1,78 @@
+/*
+ * (C) Copyright 2009 Samsung Electronics
+ * Minkyu Kang <mk7.kang@samsung.com>
+ * Heungjun Kim <riverful.kim@samsung.com>
+ *
+ * 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_UART_H_
+#define __ASM_ARCH_UART_H_
+
+#ifndef __ASSEMBLY__
+/* baudrate rest value */
+union br_rest {
+	unsigned short	slot;		/* udivslot */
+	unsigned char	value;		/* ufracval */
+};
+
+struct s5p_uart {
+	unsigned int	ulcon;
+	unsigned int	ucon;
+	unsigned int	ufcon;
+	unsigned int	umcon;
+	unsigned int	utrstat;
+	unsigned int	uerstat;
+	unsigned int	ufstat;
+	unsigned int	umstat;
+	unsigned char	utxh;
+	unsigned char	res1[3];
+	unsigned char	urxh;
+	unsigned char	res2[3];
+	unsigned int	ubrdiv;
+	union br_rest	rest;
+#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
+	unsigned char	res3[0x3d0];
+#else /* Exynos 4 and 5 */
+	unsigned char	res3[0xffd0];
+#endif
+};
+
+
+static inline int s5p_uart_divslot(void)
+{
+#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
+	return 1;
+#else /* Exynos 4 and 5 */
+	return 0;
+#endif
+}
+
+#define RX_FIFO_COUNT_MASK      0xff
+#define RX_FIFO_FULL_MASK       (1 << 8)
+#define TX_FIFO_FULL_MASK       (1 << 24)
+
+/* Information about a serial port */
+struct fdt_serial {
+	u32 base_addr;  /* address of registers in physical memory */
+	u8 port_id;     /* uart port number */
+	u8 enabled;     /* 1 if enabled, 0 if disabled */
+};
+
+#endif	/* __ASSEMBLY__ */
+
+#endif
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 0f954a5..4c4ba75 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -35,7 +35,7 @@ COBJS-$(CONFIG_LPC32XX_HSUART) += lpc32xx_hsuart.o
 COBJS-$(CONFIG_MCFUART) += mcfuart.o
 COBJS-$(CONFIG_OPENCORES_YANU) += opencores_yanu.o
 COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
-COBJS-$(CONFIG_S5P) += serial_s5p.o
+COBJS-$(CONFIG_S5P_SERIAL) += serial_s5p.o
 COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial_ns16550.o
 COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
 COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
index 6836c7a..fb0677b 100644
--- a/drivers/serial/serial_s5p.c
+++ b/drivers/serial/serial_s5p.c
@@ -25,22 +25,13 @@
 #include <fdtdec.h>
 #include <linux/compiler.h>
 #include <asm/io.h>
-#include <asm/arch/uart.h>
+#include <asm/samsung-common/uart.h>
 #include <asm/arch/clk.h>
 #include <serial.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define RX_FIFO_COUNT_MASK	0xff
-#define RX_FIFO_FULL_MASK	(1 << 8)
-#define TX_FIFO_FULL_MASK	(1 << 24)
-
-/* Information about a serial port */
-struct fdt_serial {
-	u32 base_addr;  /* address of registers in physical memory */
-	u8 port_id;     /* uart port number */
-	u8 enabled;     /* 1 if enabled, 0 if disabled */
-} config __attribute__ ((section(".data")));
+struct fdt_serial config __attribute__ ((section(".data")));
 
 static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
 {
diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index 582c584..303a8de 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -86,6 +86,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (4 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_BAUDRATE			115200
 #define EXYNOS5_DEFAULT_UART_OFFSET	0x010000
 #define CONFIG_SILENT_CONSOLE
diff --git a/include/configs/origen.h b/include/configs/origen.h
index 5013aee..7197243 100644
--- a/include/configs/origen.h
+++ b/include/configs/origen.h
@@ -64,6 +64,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2			1	/* use SERIAL 2 */
 #define CONFIG_BAUDRATE			115200
 #define EXYNOS4_DEFAULT_UART_OFFSET	0x020000
diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
index 56e8347..440c4a3 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -58,6 +58,7 @@
 /*
  * select serial console configuration
  */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2			1	/* use SERIAL2 */
 #define CONFIG_BAUDRATE			115200
 
diff --git a/include/configs/s5pc210_universal.h b/include/configs/s5pc210_universal.h
index eb13bb3..398db2a 100644
--- a/include/configs/s5pc210_universal.h
+++ b/include/configs/s5pc210_universal.h
@@ -64,6 +64,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2		1	/* use SERIAL 2 */
 #define CONFIG_BAUDRATE		115200
 
diff --git a/include/configs/smdkc100.h b/include/configs/smdkc100.h
index fb640db..6964a77 100644
--- a/include/configs/smdkc100.h
+++ b/include/configs/smdkc100.h
@@ -63,6 +63,7 @@
 /*
  * select serial console configuration
  */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL0			1	/* use SERIAL 0 on SMDKC100 */
 
 /* PWM */
diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h
index 0f04597..3c68543 100644
--- a/include/configs/smdkv310.h
+++ b/include/configs/smdkv310.h
@@ -64,6 +64,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL1			1	/* use SERIAL 1 */
 #define CONFIG_BAUDRATE			115200
 #define EXYNOS4_DEFAULT_UART_OFFSET	0x010000
diff --git a/include/configs/trats.h b/include/configs/trats.h
index 356d87b..e9c1fa4 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -69,6 +69,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (16 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2			/* use SERIAL 2 */
 #define CONFIG_BAUDRATE			115200
 
-- 
1.7.10.4

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

* [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code
  2013-07-21 21:50 [U-Boot] [PATCH] arm:samsung:serial: Extract common Samsung UART code Lukasz Majewski
  2013-07-25 21:43 ` [U-Boot] [PATCH v2] arm:samsung:serial Extract common " Lukasz Majewski
@ 2013-08-12 21:15 ` Lukasz Majewski
  2013-08-12 21:15   ` [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code Lukasz Majewski
                     ` (3 more replies)
  1 sibling, 4 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-08-12 21:15 UTC (permalink / raw)
  To: u-boot

This series of commits attempts to clean-up the Exynos3/4 code. Common code
for Exynos3 (S5PV210) and Exynos4 has been extracted.

Moreover it will facilitate support for older Samsung targets - like venerable 
s3c6410 (arm1176) SoC.

Lukasz Majewski (3):
  arm:samsung:serial Extract common UART code
  arm:samsung: Move common code from ./s5p-common to ./samsung-common/
  arm:samsung:cpu_info: Rename s5p_* to samsung_*

 Makefile                                    |    7 +-
 arch/arm/cpu/armv7/exynos/pinmux.c          |    2 +-
 arch/arm/cpu/armv7/s5p-common/Makefile      |   34 ------
 arch/arm/cpu/armv7/s5p-common/cpu_info.c    |   41 -------
 arch/arm/cpu/armv7/s5p-common/pwm.c         |  171 --------------------------
 arch/arm/cpu/armv7/s5p-common/sromc.c       |   33 -----
 arch/arm/cpu/armv7/s5p-common/timer.c       |  132 --------------------
 arch/arm/cpu/samsung-common/Makefile        |   30 +++++
 arch/arm/cpu/samsung-common/cpu_info.c      |   40 +++++++
 arch/arm/cpu/samsung-common/pwm.c           |  172 +++++++++++++++++++++++++++
 arch/arm/cpu/samsung-common/sromc.c         |   33 +++++
 arch/arm/cpu/samsung-common/timer.c         |  131 ++++++++++++++++++++
 arch/arm/include/asm/arch-exynos/cpu.h      |   24 ++--
 arch/arm/include/asm/arch-exynos/pwm.h      |   55 ---------
 arch/arm/include/asm/arch-exynos/sromc.h    |   55 ---------
 arch/arm/include/asm/arch-exynos/uart.h     |   44 -------
 arch/arm/include/asm/arch-s5pc1xx/cpu.h     |   12 +-
 arch/arm/include/asm/arch-s5pc1xx/pwm.h     |   55 ---------
 arch/arm/include/asm/arch-s5pc1xx/sromc.h   |   40 -------
 arch/arm/include/asm/arch-s5pc1xx/uart.h    |   44 -------
 arch/arm/include/asm/samsung-common/pwm.h   |   55 +++++++++
 arch/arm/include/asm/samsung-common/sromc.h |   60 ++++++++++
 arch/arm/include/asm/samsung-common/uart.h  |   64 ++++++++++
 board/samsung/smdk5250/exynos5-dt.c         |    2 +-
 board/samsung/smdkc100/smdkc100.c           |   11 +-
 board/samsung/smdkv310/smdkv310.c           |    2 +-
 drivers/serial/Makefile                     |    2 +-
 drivers/serial/serial_s5p.c                 |   13 +-
 include/configs/exynos5250-dt.h             |    1 +
 include/configs/origen.h                    |    1 +
 include/configs/s5p_goni.h                  |    1 +
 include/configs/s5pc210_universal.h         |    1 +
 include/configs/smdkc100.h                  |    1 +
 include/configs/smdkv310.h                  |    1 +
 include/configs/trats.h                     |    1 +
 spl/Makefile                                |    2 +-
 36 files changed, 626 insertions(+), 747 deletions(-)
 delete mode 100644 arch/arm/cpu/armv7/s5p-common/Makefile
 delete mode 100644 arch/arm/cpu/armv7/s5p-common/cpu_info.c
 delete mode 100644 arch/arm/cpu/armv7/s5p-common/pwm.c
 delete mode 100644 arch/arm/cpu/armv7/s5p-common/sromc.c
 delete mode 100644 arch/arm/cpu/armv7/s5p-common/timer.c
 create mode 100644 arch/arm/cpu/samsung-common/Makefile
 create mode 100644 arch/arm/cpu/samsung-common/cpu_info.c
 create mode 100644 arch/arm/cpu/samsung-common/pwm.c
 create mode 100644 arch/arm/cpu/samsung-common/sromc.c
 create mode 100644 arch/arm/cpu/samsung-common/timer.c
 delete mode 100644 arch/arm/include/asm/arch-exynos/pwm.h
 delete mode 100644 arch/arm/include/asm/arch-exynos/sromc.h
 delete mode 100644 arch/arm/include/asm/arch-exynos/uart.h
 delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/pwm.h
 delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/sromc.h
 delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/uart.h
 create mode 100644 arch/arm/include/asm/samsung-common/pwm.h
 create mode 100644 arch/arm/include/asm/samsung-common/sromc.h
 create mode 100644 arch/arm/include/asm/samsung-common/uart.h

-- 
1.7.10.4

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

* [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code
  2013-08-12 21:15 ` [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code Lukasz Majewski
@ 2013-08-12 21:15   ` Lukasz Majewski
  2013-08-16  7:16     ` Lukasz Majewski
  2013-08-28 10:11     ` Minkyu Kang
  2013-08-12 21:15   ` [U-Boot] [PATCH v3 2/3] arm:samsung: Move common code from ./s5p-common to ./samsung-common/ Lukasz Majewski
                     ` (2 subsequent siblings)
  3 siblings, 2 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-08-12 21:15 UTC (permalink / raw)
  To: u-boot

This commit brings removal of duplicated code for UART IP block embedded
at Samsung SoCs.
New include/asm/samsung-common directory has been created to store
common code for existing and future Samsung targets.

Moreover building of UART code now depends on more verbose CONFIG_S5P_SERIAL.
Thereof all relevant boards configs have been adjusted.

Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>

---
Changes for v3:
- Comply with SPDX license format

Changes for v2:
- Remove S3C64XX define from the code
---
 arch/arm/include/asm/arch-exynos/uart.h    |   44 -------------------
 arch/arm/include/asm/arch-s5pc1xx/uart.h   |   44 -------------------
 arch/arm/include/asm/samsung-common/uart.h |   64 ++++++++++++++++++++++++++++
 drivers/serial/Makefile                    |    2 +-
 drivers/serial/serial_s5p.c                |   13 +-----
 include/configs/exynos5250-dt.h            |    1 +
 include/configs/origen.h                   |    1 +
 include/configs/s5p_goni.h                 |    1 +
 include/configs/s5pc210_universal.h        |    1 +
 include/configs/smdkc100.h                 |    1 +
 include/configs/smdkv310.h                 |    1 +
 include/configs/trats.h                    |    1 +
 12 files changed, 74 insertions(+), 100 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-exynos/uart.h
 delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/uart.h
 create mode 100644 arch/arm/include/asm/samsung-common/uart.h

diff --git a/arch/arm/include/asm/arch-exynos/uart.h b/arch/arm/include/asm/arch-exynos/uart.h
deleted file mode 100644
index 33d6ba3..0000000
--- a/arch/arm/include/asm/arch-exynos/uart.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * (C) Copyright 2009 Samsung Electronics
- * Minkyu Kang <mk7.kang@samsung.com>
- * Heungjun Kim <riverful.kim@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#ifndef __ASM_ARCH_UART_H_
-#define __ASM_ARCH_UART_H_
-
-#ifndef __ASSEMBLY__
-/* baudrate rest value */
-union br_rest {
-	unsigned short	slot;		/* udivslot */
-	unsigned char	value;		/* ufracval */
-};
-
-struct s5p_uart {
-	unsigned int	ulcon;
-	unsigned int	ucon;
-	unsigned int	ufcon;
-	unsigned int	umcon;
-	unsigned int	utrstat;
-	unsigned int	uerstat;
-	unsigned int	ufstat;
-	unsigned int	umstat;
-	unsigned char	utxh;
-	unsigned char	res1[3];
-	unsigned char	urxh;
-	unsigned char	res2[3];
-	unsigned int	ubrdiv;
-	union br_rest	rest;
-	unsigned char	res3[0xffd0];
-};
-
-static inline int s5p_uart_divslot(void)
-{
-	return 0;
-}
-
-#endif	/* __ASSEMBLY__ */
-
-#endif
diff --git a/arch/arm/include/asm/arch-s5pc1xx/uart.h b/arch/arm/include/asm/arch-s5pc1xx/uart.h
deleted file mode 100644
index 26db098..0000000
--- a/arch/arm/include/asm/arch-s5pc1xx/uart.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * (C) Copyright 2009 Samsung Electronics
- * Minkyu Kang <mk7.kang@samsung.com>
- * Heungjun Kim <riverful.kim@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#ifndef __ASM_ARCH_UART_H_
-#define __ASM_ARCH_UART_H_
-
-#ifndef __ASSEMBLY__
-/* baudrate rest value */
-union br_rest {
-	unsigned short	slot;		/* udivslot */
-	unsigned char	value;		/* ufracval */
-};
-
-struct s5p_uart {
-	unsigned int	ulcon;
-	unsigned int	ucon;
-	unsigned int	ufcon;
-	unsigned int	umcon;
-	unsigned int	utrstat;
-	unsigned int	uerstat;
-	unsigned int	ufstat;
-	unsigned int	umstat;
-	unsigned char	utxh;
-	unsigned char	res1[3];
-	unsigned char	urxh;
-	unsigned char	res2[3];
-	unsigned int	ubrdiv;
-	union br_rest	rest;
-	unsigned char	res3[0x3d0];
-};
-
-static inline int s5p_uart_divslot(void)
-{
-	return 1;
-}
-
-#endif	/* __ASSEMBLY__ */
-
-#endif
diff --git a/arch/arm/include/asm/samsung-common/uart.h b/arch/arm/include/asm/samsung-common/uart.h
new file mode 100644
index 0000000..ce92399
--- /dev/null
+++ b/arch/arm/include/asm/samsung-common/uart.h
@@ -0,0 +1,64 @@
+/*
+ * (C) Copyright 2009 Samsung Electronics
+ * Minkyu Kang <mk7.kang@samsung.com>
+ * Heungjun Kim <riverful.kim@samsung.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __ASM_ARCH_UART_H_
+#define __ASM_ARCH_UART_H_
+
+#ifndef __ASSEMBLY__
+/* baudrate rest value */
+union br_rest {
+	unsigned short	slot;		/* udivslot */
+	unsigned char	value;		/* ufracval */
+};
+
+struct s5p_uart {
+	unsigned int	ulcon;
+	unsigned int	ucon;
+	unsigned int	ufcon;
+	unsigned int	umcon;
+	unsigned int	utrstat;
+	unsigned int	uerstat;
+	unsigned int	ufstat;
+	unsigned int	umstat;
+	unsigned char	utxh;
+	unsigned char	res1[3];
+	unsigned char	urxh;
+	unsigned char	res2[3];
+	unsigned int	ubrdiv;
+	union br_rest	rest;
+#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
+	unsigned char	res3[0x3d0];
+#else /* Exynos 4 and 5 */
+	unsigned char	res3[0xffd0];
+#endif
+};
+
+
+static inline int s5p_uart_divslot(void)
+{
+#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
+	return 1;
+#else /* Exynos 4 and 5 */
+	return 0;
+#endif
+}
+
+#define RX_FIFO_COUNT_MASK      0xff
+#define RX_FIFO_FULL_MASK       (1 << 8)
+#define TX_FIFO_FULL_MASK       (1 << 24)
+
+/* Information about a serial port */
+struct fdt_serial {
+	u32 base_addr;  /* address of registers in physical memory */
+	u8 port_id;     /* uart port number */
+	u8 enabled;     /* 1 if enabled, 0 if disabled */
+};
+
+#endif	/* __ASSEMBLY__ */
+
+#endif
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 697f2bb..e3ca49a 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -19,7 +19,7 @@ COBJS-$(CONFIG_LPC32XX_HSUART) += lpc32xx_hsuart.o
 COBJS-$(CONFIG_MCFUART) += mcfuart.o
 COBJS-$(CONFIG_OPENCORES_YANU) += opencores_yanu.o
 COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
-COBJS-$(CONFIG_S5P) += serial_s5p.o
+COBJS-$(CONFIG_S5P_SERIAL) += serial_s5p.o
 COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial_ns16550.o
 COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
 COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
index f98b422..be08925 100644
--- a/drivers/serial/serial_s5p.c
+++ b/drivers/serial/serial_s5p.c
@@ -12,22 +12,13 @@
 #include <fdtdec.h>
 #include <linux/compiler.h>
 #include <asm/io.h>
-#include <asm/arch/uart.h>
+#include <asm/samsung-common/uart.h>
 #include <asm/arch/clk.h>
 #include <serial.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define RX_FIFO_COUNT_MASK	0xff
-#define RX_FIFO_FULL_MASK	(1 << 8)
-#define TX_FIFO_FULL_MASK	(1 << 24)
-
-/* Information about a serial port */
-struct fdt_serial {
-	u32 base_addr;  /* address of registers in physical memory */
-	u8 port_id;     /* uart port number */
-	u8 enabled;     /* 1 if enabled, 0 if disabled */
-} config __attribute__ ((section(".data")));
+struct fdt_serial config __attribute__ ((section(".data")));
 
 static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
 {
diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index 8f8f85f..a759d07 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -69,6 +69,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (4 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_BAUDRATE			115200
 #define EXYNOS5_DEFAULT_UART_OFFSET	0x010000
 #define CONFIG_SILENT_CONSOLE
diff --git a/include/configs/origen.h b/include/configs/origen.h
index da13574..a59419d 100644
--- a/include/configs/origen.h
+++ b/include/configs/origen.h
@@ -48,6 +48,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2			1	/* use SERIAL 2 */
 #define CONFIG_BAUDRATE			115200
 #define EXYNOS4_DEFAULT_UART_OFFSET	0x020000
diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
index d0fafd7..812b7f3 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -42,6 +42,7 @@
 /*
  * select serial console configuration
  */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2			1	/* use SERIAL2 */
 #define CONFIG_BAUDRATE			115200
 
diff --git a/include/configs/s5pc210_universal.h b/include/configs/s5pc210_universal.h
index 97a4008..2270449 100644
--- a/include/configs/s5pc210_universal.h
+++ b/include/configs/s5pc210_universal.h
@@ -48,6 +48,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2		1	/* use SERIAL 2 */
 #define CONFIG_BAUDRATE		115200
 
diff --git a/include/configs/smdkc100.h b/include/configs/smdkc100.h
index a572e62..4631dac 100644
--- a/include/configs/smdkc100.h
+++ b/include/configs/smdkc100.h
@@ -47,6 +47,7 @@
 /*
  * select serial console configuration
  */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL0			1	/* use SERIAL 0 on SMDKC100 */
 
 /* PWM */
diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h
index 0496661..9e10bf1 100644
--- a/include/configs/smdkv310.h
+++ b/include/configs/smdkv310.h
@@ -48,6 +48,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL1			1	/* use SERIAL 1 */
 #define CONFIG_BAUDRATE			115200
 #define EXYNOS4_DEFAULT_UART_OFFSET	0x010000
diff --git a/include/configs/trats.h b/include/configs/trats.h
index 9b6aac9..6b301c8 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -53,6 +53,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (16 << 20))
 
 /* select serial console configuration */
+#define CONFIG_S5P_SERIAL
 #define CONFIG_SERIAL2			/* use SERIAL 2 */
 #define CONFIG_BAUDRATE			115200
 
-- 
1.7.10.4

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

* [U-Boot] [PATCH v3 2/3] arm:samsung: Move common code from ./s5p-common to ./samsung-common/
  2013-08-12 21:15 ` [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code Lukasz Majewski
  2013-08-12 21:15   ` [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code Lukasz Majewski
@ 2013-08-12 21:15   ` Lukasz Majewski
  2013-08-12 21:15   ` [U-Boot] [PATCH v3 3/3] arm:samsung:cpu_info: Rename s5p_* to samsung_* Lukasz Majewski
  2013-08-22 10:55   ` [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code Lukasz Majewski
  3 siblings, 0 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-08-12 21:15 UTC (permalink / raw)
  To: u-boot

Common Samsung code has been moved one level up - to ./samsung-common directory.
This would allow other - non S5P based targets to reuse this code base
Moreover duplicated header files were removed.

Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>

---
Changes for v3:
- Comply with SPDX license format when moving files to new location

Changes for v2:
- Only compile in libsamsung-common for non arm9 boards
- Exclude common sromc controller code
- Adjust smdkc100 to work with common sromc.h header
- Adjust boards #includes for asm/samsung-common/sromc.h
---
 Makefile                                    |    7 +-
 arch/arm/cpu/armv7/exynos/pinmux.c          |    2 +-
 arch/arm/cpu/armv7/s5p-common/Makefile      |   34 ------
 arch/arm/cpu/armv7/s5p-common/cpu_info.c    |   41 -------
 arch/arm/cpu/armv7/s5p-common/pwm.c         |  171 --------------------------
 arch/arm/cpu/armv7/s5p-common/sromc.c       |   33 -----
 arch/arm/cpu/armv7/s5p-common/timer.c       |  132 --------------------
 arch/arm/cpu/samsung-common/Makefile        |   30 +++++
 arch/arm/cpu/samsung-common/cpu_info.c      |   40 +++++++
 arch/arm/cpu/samsung-common/pwm.c           |  172 +++++++++++++++++++++++++++
 arch/arm/cpu/samsung-common/sromc.c         |   33 +++++
 arch/arm/cpu/samsung-common/timer.c         |  131 ++++++++++++++++++++
 arch/arm/include/asm/arch-exynos/pwm.h      |   55 ---------
 arch/arm/include/asm/arch-exynos/sromc.h    |   55 ---------
 arch/arm/include/asm/arch-s5pc1xx/pwm.h     |   55 ---------
 arch/arm/include/asm/arch-s5pc1xx/sromc.h   |   40 -------
 arch/arm/include/asm/samsung-common/pwm.h   |   55 +++++++++
 arch/arm/include/asm/samsung-common/sromc.h |   60 ++++++++++
 board/samsung/smdk5250/exynos5-dt.c         |    2 +-
 board/samsung/smdkc100/smdkc100.c           |   11 +-
 board/samsung/smdkv310/smdkv310.c           |    2 +-
 spl/Makefile                                |    2 +-
 22 files changed, 534 insertions(+), 629 deletions(-)
 delete mode 100644 arch/arm/cpu/armv7/s5p-common/Makefile
 delete mode 100644 arch/arm/cpu/armv7/s5p-common/cpu_info.c
 delete mode 100644 arch/arm/cpu/armv7/s5p-common/pwm.c
 delete mode 100644 arch/arm/cpu/armv7/s5p-common/sromc.c
 delete mode 100644 arch/arm/cpu/armv7/s5p-common/timer.c
 create mode 100644 arch/arm/cpu/samsung-common/Makefile
 create mode 100644 arch/arm/cpu/samsung-common/cpu_info.c
 create mode 100644 arch/arm/cpu/samsung-common/pwm.c
 create mode 100644 arch/arm/cpu/samsung-common/sromc.c
 create mode 100644 arch/arm/cpu/samsung-common/timer.c
 delete mode 100644 arch/arm/include/asm/arch-exynos/pwm.h
 delete mode 100644 arch/arm/include/asm/arch-exynos/sromc.h
 delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/pwm.h
 delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/sromc.h
 create mode 100644 arch/arm/include/asm/samsung-common/pwm.h
 create mode 100644 arch/arm/include/asm/samsung-common/sromc.h

diff --git a/Makefile b/Makefile
index d545d30..836c04d 100644
--- a/Makefile
+++ b/Makefile
@@ -330,11 +330,10 @@ ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
 LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o
 endif
 
-ifeq ($(SOC),s5pc1xx)
-LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o
+ifeq ($(VENDOR),samsung)
+ifneq ($(SOC), s3c24x0)
+LIBS-y += arch/$(ARCH)/cpu/samsung-common/libsamsung-common.o
 endif
-ifeq ($(SOC),exynos)
-LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o
 endif
 ifneq ($(CONFIG_TEGRA),)
 LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o
diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c b/arch/arm/cpu/armv7/exynos/pinmux.c
index 1b05ebf..ed662bb 100644
--- a/arch/arm/cpu/armv7/exynos/pinmux.c
+++ b/arch/arm/cpu/armv7/exynos/pinmux.c
@@ -9,7 +9,7 @@
 #include <fdtdec.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/pinmux.h>
-#include <asm/arch/sromc.h>
+#include <asm/samsung-common/sromc.h>
 
 static void exynos5_uart_config(int peripheral)
 {
diff --git a/arch/arm/cpu/armv7/s5p-common/Makefile b/arch/arm/cpu/armv7/s5p-common/Makefile
deleted file mode 100644
index fd7290c..0000000
--- a/arch/arm/cpu/armv7/s5p-common/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (C) 2009 Samsung Electronics
-# Minkyu Kang <mk7.kang@samsung.com>
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-
-include $(TOPDIR)/config.mk
-
-LIB	= $(obj)libs5p-common.o
-
-COBJS-y		+= cpu_info.o
-ifndef CONFIG_SPL_BUILD
-COBJS-y		+= timer.o
-COBJS-y		+= sromc.o
-COBJS-$(CONFIG_PWM)	+= pwm.o
-endif
-
-SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS	:= $(addprefix $(obj),$(COBJS-y) $(SOBJS))
-
-all:	 $(obj).depend $(LIB)
-
-$(LIB):	$(OBJS)
-	$(call cmd_link_o_target, $(OBJS))
-
-#########################################################################
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/arch/arm/cpu/armv7/s5p-common/cpu_info.c b/arch/arm/cpu/armv7/s5p-common/cpu_info.c
deleted file mode 100644
index a8d91e7..0000000
--- a/arch/arm/cpu/armv7/s5p-common/cpu_info.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2009 Samsung Electronics
- * Minkyu Kang <mk7.kang@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-#include <common.h>
-#include <asm/io.h>
-#include <asm/arch/clk.h>
-
-/* Default is s5pc100 */
-unsigned int s5p_cpu_id = 0xC100;
-/* Default is EVT1 */
-unsigned int s5p_cpu_rev = 1;
-
-#ifdef CONFIG_ARCH_CPU_INIT
-int arch_cpu_init(void)
-{
-	s5p_set_cpu_id();
-
-	return 0;
-}
-#endif
-
-u32 get_device_type(void)
-{
-	return s5p_cpu_id;
-}
-
-#ifdef CONFIG_DISPLAY_CPUINFO
-int print_cpuinfo(void)
-{
-	char buf[32];
-
-	printf("CPU:\t%s%X@%sMHz\n",
-			s5p_get_cpu_name(), s5p_cpu_id,
-			strmhz(buf, get_arm_clk()));
-
-	return 0;
-}
-#endif
diff --git a/arch/arm/cpu/armv7/s5p-common/pwm.c b/arch/arm/cpu/armv7/s5p-common/pwm.c
deleted file mode 100644
index 47aa9cc..0000000
--- a/arch/arm/cpu/armv7/s5p-common/pwm.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2011 Samsung Electronics
- *
- * Donghwa Lee <dh09.lee@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+ 
- */
-
-#include <common.h>
-#include <errno.h>
-#include <pwm.h>
-#include <asm/io.h>
-#include <asm/arch/pwm.h>
-#include <asm/arch/clk.h>
-
-int pwm_enable(int pwm_id)
-{
-	const struct s5p_timer *pwm =
-			(struct s5p_timer *)samsung_get_base_timer();
-	unsigned long tcon;
-
-	tcon = readl(&pwm->tcon);
-	tcon |= TCON_START(pwm_id);
-
-	writel(tcon, &pwm->tcon);
-
-	return 0;
-}
-
-void pwm_disable(int pwm_id)
-{
-	const struct s5p_timer *pwm =
-			(struct s5p_timer *)samsung_get_base_timer();
-	unsigned long tcon;
-
-	tcon = readl(&pwm->tcon);
-	tcon &= ~TCON_START(pwm_id);
-
-	writel(tcon, &pwm->tcon);
-}
-
-static unsigned long pwm_calc_tin(int pwm_id, unsigned long freq)
-{
-	unsigned long tin_parent_rate;
-	unsigned int div;
-
-	tin_parent_rate = get_pwm_clk();
-
-	for (div = 2; div <= 16; div *= 2) {
-		if ((tin_parent_rate / (div << 16)) < freq)
-			return tin_parent_rate / div;
-	}
-
-	return tin_parent_rate / 16;
-}
-
-#define NS_IN_SEC 1000000000UL
-
-int pwm_config(int pwm_id, int duty_ns, int period_ns)
-{
-	const struct s5p_timer *pwm =
-			(struct s5p_timer *)samsung_get_base_timer();
-	unsigned int offset;
-	unsigned long tin_rate;
-	unsigned long tin_ns;
-	unsigned long frequency;
-	unsigned long tcon;
-	unsigned long tcnt;
-	unsigned long tcmp;
-
-	/*
-	 * We currently avoid using 64bit arithmetic by using the
-	 * fact that anything faster than 1GHz is easily representable
-	 * by 32bits.
-	 */
-	if (period_ns > NS_IN_SEC || duty_ns > NS_IN_SEC || period_ns == 0)
-		return -ERANGE;
-
-	if (duty_ns > period_ns)
-		return -EINVAL;
-
-	frequency = NS_IN_SEC / period_ns;
-
-	/* Check to see if we are changing the clock rate of the PWM */
-	tin_rate = pwm_calc_tin(pwm_id, frequency);
-
-	tin_ns = NS_IN_SEC / tin_rate;
-	tcnt = period_ns / tin_ns;
-
-	/* Note, counters count down */
-	tcmp = duty_ns / tin_ns;
-	tcmp = tcnt - tcmp;
-
-	/* Update the PWM register block. */
-	offset = pwm_id * 3;
-	if (pwm_id < 4) {
-		writel(tcnt, &pwm->tcntb0 + offset);
-		writel(tcmp, &pwm->tcmpb0 + offset);
-	}
-
-	tcon = readl(&pwm->tcon);
-	tcon |= TCON_UPDATE(pwm_id);
-	if (pwm_id < 4)
-		tcon |= TCON_AUTO_RELOAD(pwm_id);
-	else
-		tcon |= TCON4_AUTO_RELOAD;
-	writel(tcon, &pwm->tcon);
-
-	tcon &= ~TCON_UPDATE(pwm_id);
-	writel(tcon, &pwm->tcon);
-
-	return 0;
-}
-
-int pwm_init(int pwm_id, int div, int invert)
-{
-	u32 val;
-	const struct s5p_timer *pwm =
-			(struct s5p_timer *)samsung_get_base_timer();
-	unsigned long ticks_per_period;
-	unsigned int offset, prescaler;
-
-	/*
-	 * Timer Freq(HZ) =
-	 *	PWM_CLK / { (prescaler_value + 1) * (divider_value) }
-	 */
-
-	val = readl(&pwm->tcfg0);
-	if (pwm_id < 2) {
-		prescaler = PRESCALER_0;
-		val &= ~0xff;
-		val |= (prescaler & 0xff);
-	} else {
-		prescaler = PRESCALER_1;
-		val &= ~(0xff << 8);
-		val |= (prescaler & 0xff) << 8;
-	}
-	writel(val, &pwm->tcfg0);
-	val = readl(&pwm->tcfg1);
-	val &= ~(0xf << MUX_DIV_SHIFT(pwm_id));
-	val |= (div & 0xf) << MUX_DIV_SHIFT(pwm_id);
-	writel(val, &pwm->tcfg1);
-
-	if (pwm_id == 4) {
-		/*
-		 * TODO(sjg): Use this as a countdown timer for now. We count
-		 * down from the maximum value to 0, then reset.
-		 */
-		ticks_per_period = -1UL;
-	} else {
-		const unsigned long pwm_hz = 1000;
-		unsigned long timer_rate_hz = get_pwm_clk() /
-			((prescaler + 1) * (1 << div));
-
-		ticks_per_period = timer_rate_hz / pwm_hz;
-	}
-
-	/* set count value */
-	offset = pwm_id * 3;
-
-	writel(ticks_per_period, &pwm->tcntb0 + offset);
-
-	val = readl(&pwm->tcon) & ~(0xf << TCON_OFFSET(pwm_id));
-	if (invert && (pwm_id < 4))
-		val |= TCON_INVERTER(pwm_id);
-	writel(val, &pwm->tcon);
-
-	pwm_enable(pwm_id);
-
-	return 0;
-}
diff --git a/arch/arm/cpu/armv7/s5p-common/sromc.c b/arch/arm/cpu/armv7/s5p-common/sromc.c
deleted file mode 100644
index 806456f..0000000
--- a/arch/arm/cpu/armv7/s5p-common/sromc.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2010 Samsung Electronics
- * Naveen Krishna Ch <ch.naveen@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/io.h>
-#include <asm/arch/sromc.h>
-
-/*
- * s5p_config_sromc() - select the proper SROMC Bank and configure the
- * band width control and bank control registers
- * srom_bank	- SROM
- * srom_bw_conf  - SMC Band witdh reg configuration value
- * srom_bc_conf  - SMC Bank Control reg configuration value
- */
-void s5p_config_sromc(u32 srom_bank, u32 srom_bw_conf, u32 srom_bc_conf)
-{
-	u32 tmp;
-	struct s5p_sromc *srom =
-		(struct s5p_sromc *)samsung_get_base_sromc();
-
-	/* Configure SMC_BW register to handle proper SROMC bank */
-	tmp = srom->bw;
-	tmp &= ~(0xF << (srom_bank * 4));
-	tmp |= srom_bw_conf;
-	srom->bw = tmp;
-
-	/* Configure SMC_BC register */
-	srom->bc[srom_bank] = srom_bc_conf;
-}
diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c
deleted file mode 100644
index 5b87a08..0000000
--- a/arch/arm/cpu/armv7/s5p-common/timer.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2009 Samsung Electronics
- * Heungjun Kim <riverful.kim@samsung.com>
- * Inki Dae <inki.dae@samsung.com>
- * Minkyu Kang <mk7.kang@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+ 
- */
-
-#include <common.h>
-#include <div64.h>
-#include <asm/io.h>
-#include <asm/arch/pwm.h>
-#include <asm/arch/clk.h>
-#include <pwm.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-unsigned long get_current_tick(void);
-
-/* macro to read the 16 bit timer */
-static inline struct s5p_timer *s5p_get_base_timer(void)
-{
-	return (struct s5p_timer *)samsung_get_base_timer();
-}
-
-/**
- * Read the countdown timer.
- *
- * This operates at 1MHz and counts downwards. It will wrap about every
- * hour (2^32 microseconds).
- *
- * @return current value of timer
- */
-static unsigned long timer_get_us_down(void)
-{
-	struct s5p_timer *const timer = s5p_get_base_timer();
-
-	return readl(&timer->tcnto4);
-}
-
-int timer_init(void)
-{
-	/* PWM Timer 4 */
-	pwm_init(4, MUX_DIV_4, 0);
-	pwm_config(4, 100000, 100000);
-	pwm_enable(4);
-
-	/* Use this as the current monotonic time in us */
-	gd->arch.timer_reset_value = 0;
-
-	/* Use this as the last timer value we saw */
-	gd->arch.lastinc = timer_get_us_down();
-	reset_timer_masked();
-
-	return 0;
-}
-
-/*
- * timer without interrupts
- */
-unsigned long get_timer(unsigned long base)
-{
-	unsigned long long time_ms;
-
-	ulong now = timer_get_us_down();
-
-	/*
-	 * Increment the time by the amount elapsed since the last read.
-	 * The timer may have wrapped around, but it makes no difference to
-	 * our arithmetic here.
-	 */
-	gd->arch.timer_reset_value += gd->arch.lastinc - now;
-	gd->arch.lastinc = now;
-
-	/* Divide by 1000 to convert from us to ms */
-	time_ms = gd->arch.timer_reset_value;
-	do_div(time_ms, 1000);
-	return time_ms - base;
-}
-
-unsigned long __attribute__((no_instrument_function)) timer_get_us(void)
-{
-	static unsigned long base_time_us;
-
-	struct s5p_timer *const timer =
-		(struct s5p_timer *)samsung_get_base_timer();
-	unsigned long now_downward_us = readl(&timer->tcnto4);
-
-	if (!base_time_us)
-		base_time_us = now_downward_us;
-
-	/* Note that this timer counts downward. */
-	return base_time_us - now_downward_us;
-}
-
-/* delay x useconds */
-void __udelay(unsigned long usec)
-{
-	unsigned long count_value;
-
-	count_value = timer_get_us_down();
-	while ((int)(count_value - timer_get_us_down()) < (int)usec)
-		;
-}
-
-void reset_timer_masked(void)
-{
-	struct s5p_timer *const timer = s5p_get_base_timer();
-
-	/* reset time */
-	gd->arch.lastinc = readl(&timer->tcnto4);
-	gd->arch.tbl = 0;
-}
-
-/*
- * This function is derived from PowerPC code (read timebase as long long).
- * On ARM it just returns the timer value.
- */
-unsigned long long get_ticks(void)
-{
-	return get_timer(0);
-}
-
-/*
- * This function is derived from PowerPC code (timebase clock frequency).
- * On ARM it returns the number of timer ticks per second.
- */
-unsigned long get_tbclk(void)
-{
-	return CONFIG_SYS_HZ;
-}
diff --git a/arch/arm/cpu/samsung-common/Makefile b/arch/arm/cpu/samsung-common/Makefile
new file mode 100644
index 0000000..22eae3e
--- /dev/null
+++ b/arch/arm/cpu/samsung-common/Makefile
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2009 Samsung Electronics
+# Minkyu Kang <mk7.kang@samsung.com>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)libsamsung-common.o
+
+COBJS-$(CONFIG_PWM)	+= pwm.o
+COBJS-y			+= timer.o sromc.o cpu_info.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS-y) $(SOBJS))
+
+all:	 $(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/arch/arm/cpu/samsung-common/cpu_info.c b/arch/arm/cpu/samsung-common/cpu_info.c
new file mode 100644
index 0000000..e18c4f6
--- /dev/null
+++ b/arch/arm/cpu/samsung-common/cpu_info.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2009 Samsung Electronics
+ * Minkyu Kang <mk7.kang@samsung.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/clk.h>
+
+/* Default is s5pc100 */
+unsigned int s5p_cpu_id = 0xC100;
+/* Default is EVT1 */
+unsigned int s5p_cpu_rev = 1;
+
+#ifdef CONFIG_ARCH_CPU_INIT
+int arch_cpu_init(void)
+{
+	s5p_set_cpu_id();
+
+	return 0;
+}
+#endif
+
+u32 get_device_type(void)
+{
+	return s5p_cpu_id;
+}
+
+#ifdef CONFIG_DISPLAY_CPUINFO
+int print_cpuinfo(void)
+{
+	char buf[32];
+
+	printf("CPU:\t%s%X@%sMHz\n", s5p_get_cpu_name(), s5p_cpu_id,
+	       strmhz(buf, get_arm_clk()));
+
+	return 0;
+}
+#endif
diff --git a/arch/arm/cpu/samsung-common/pwm.c b/arch/arm/cpu/samsung-common/pwm.c
new file mode 100644
index 0000000..d40af2f
--- /dev/null
+++ b/arch/arm/cpu/samsung-common/pwm.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ * Donghwa Lee <dh09.lee@samsung.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+ 
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <pwm.h>
+#include <asm/io.h>
+#include <asm/samsung-common/pwm.h>
+#include <asm/arch/clk.h>
+#include <asm/arch/cpu.h>
+
+int pwm_enable(int pwm_id)
+{
+	const struct s5p_timer *pwm =
+			(struct s5p_timer *)samsung_get_base_timer();
+	unsigned long tcon;
+
+	tcon = readl(&pwm->tcon);
+	tcon |= TCON_START(pwm_id);
+
+	writel(tcon, &pwm->tcon);
+
+	return 0;
+}
+
+void pwm_disable(int pwm_id)
+{
+	const struct s5p_timer *pwm =
+			(struct s5p_timer *)samsung_get_base_timer();
+	unsigned long tcon;
+
+	tcon = readl(&pwm->tcon);
+	tcon &= ~TCON_START(pwm_id);
+
+	writel(tcon, &pwm->tcon);
+}
+
+static unsigned long pwm_calc_tin(int pwm_id, unsigned long freq)
+{
+	unsigned long tin_parent_rate;
+	unsigned int div;
+
+	tin_parent_rate = get_pwm_clk();
+
+	for (div = 2; div <= 16; div *= 2) {
+		if ((tin_parent_rate / (div << 16)) < freq)
+			return tin_parent_rate / div;
+	}
+
+	return tin_parent_rate / 16;
+}
+
+#define NS_IN_SEC 1000000000UL
+
+int pwm_config(int pwm_id, int duty_ns, int period_ns)
+{
+	const struct s5p_timer *pwm =
+			(struct s5p_timer *)samsung_get_base_timer();
+	unsigned int offset;
+	unsigned long tin_rate;
+	unsigned long tin_ns;
+	unsigned long frequency;
+	unsigned long tcon;
+	unsigned long tcnt;
+	unsigned long tcmp;
+
+	/*
+	 * We currently avoid using 64bit arithmetic by using the
+	 * fact that anything faster than 1GHz is easily representable
+	 * by 32bits.
+	 */
+	if (period_ns > NS_IN_SEC || duty_ns > NS_IN_SEC || period_ns == 0)
+		return -ERANGE;
+
+	if (duty_ns > period_ns)
+		return -EINVAL;
+
+	frequency = NS_IN_SEC / period_ns;
+
+	/* Check to see if we are changing the clock rate of the PWM */
+	tin_rate = pwm_calc_tin(pwm_id, frequency);
+
+	tin_ns = NS_IN_SEC / tin_rate;
+	tcnt = period_ns / tin_ns;
+
+	/* Note, counters count down */
+	tcmp = duty_ns / tin_ns;
+	tcmp = tcnt - tcmp;
+
+	/* Update the PWM register block. */
+	offset = pwm_id * 3;
+	if (pwm_id < 4) {
+		writel(tcnt, &pwm->tcntb0 + offset);
+		writel(tcmp, &pwm->tcmpb0 + offset);
+	}
+
+	tcon = readl(&pwm->tcon);
+	tcon |= TCON_UPDATE(pwm_id);
+	if (pwm_id < 4)
+		tcon |= TCON_AUTO_RELOAD(pwm_id);
+	else
+		tcon |= TCON4_AUTO_RELOAD;
+	writel(tcon, &pwm->tcon);
+
+	tcon &= ~TCON_UPDATE(pwm_id);
+	writel(tcon, &pwm->tcon);
+
+	return 0;
+}
+
+int pwm_init(int pwm_id, int div, int invert)
+{
+	u32 val;
+	const struct s5p_timer *pwm =
+			(struct s5p_timer *)samsung_get_base_timer();
+	unsigned long ticks_per_period;
+	unsigned int offset, prescaler;
+
+	/*
+	 * Timer Freq(HZ) =
+	 *	PWM_CLK / { (prescaler_value + 1) * (divider_value) }
+	 */
+
+	val = readl(&pwm->tcfg0);
+	if (pwm_id < 2) {
+		prescaler = PRESCALER_0;
+		val &= ~0xff;
+		val |= (prescaler & 0xff);
+	} else {
+		prescaler = PRESCALER_1;
+		val &= ~(0xff << 8);
+		val |= (prescaler & 0xff) << 8;
+	}
+	writel(val, &pwm->tcfg0);
+	val = readl(&pwm->tcfg1);
+	val &= ~(0xf << MUX_DIV_SHIFT(pwm_id));
+	val |= (div & 0xf) << MUX_DIV_SHIFT(pwm_id);
+	writel(val, &pwm->tcfg1);
+
+	if (pwm_id == 4) {
+		/*
+		 * TODO(sjg): Use this as a countdown timer for now. We count
+		 * down from the maximum value to 0, then reset.
+		 */
+		ticks_per_period = -1UL;
+	} else {
+		const unsigned long pwm_hz = 1000;
+		unsigned long timer_rate_hz = get_pwm_clk() /
+			((prescaler + 1) * (1 << div));
+
+		ticks_per_period = timer_rate_hz / pwm_hz;
+	}
+
+	/* set count value */
+	offset = pwm_id * 3;
+
+	writel(ticks_per_period, &pwm->tcntb0 + offset);
+
+	val = readl(&pwm->tcon) & ~(0xf << TCON_OFFSET(pwm_id));
+	if (invert && (pwm_id < 4))
+		val |= TCON_INVERTER(pwm_id);
+	writel(val, &pwm->tcon);
+
+	pwm_enable(pwm_id);
+
+	return 0;
+}
diff --git a/arch/arm/cpu/samsung-common/sromc.c b/arch/arm/cpu/samsung-common/sromc.c
new file mode 100644
index 0000000..522f4d9
--- /dev/null
+++ b/arch/arm/cpu/samsung-common/sromc.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010 Samsung Electronics
+ * Naveen Krishna Ch <ch.naveen@samsung.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/samsung-common/sromc.h>
+
+/*
+ * s5p_config_sromc() - select the proper SROMC Bank and configure the
+ * band width control and bank control registers
+ * srom_bank	- SROM
+ * srom_bw_conf  - SMC Band witdh reg configuration value
+ * srom_bc_conf  - SMC Bank Control reg configuration value
+ */
+void s5p_config_sromc(u32 srom_bank, u32 srom_bw_conf, u32 srom_bc_conf)
+{
+	u32 tmp;
+	struct s5p_sromc *srom =
+		(struct s5p_sromc *)samsung_get_base_sromc();
+
+	/* Configure SMC_BW register to handle proper SROMC bank */
+	tmp = srom->bw;
+	tmp &= ~(0xF << (srom_bank * 4));
+	tmp |= srom_bw_conf;
+	srom->bw = tmp;
+
+	/* Configure SMC_BC register */
+	srom->bc[srom_bank] = srom_bc_conf;
+}
diff --git a/arch/arm/cpu/samsung-common/timer.c b/arch/arm/cpu/samsung-common/timer.c
new file mode 100644
index 0000000..42c8c8d
--- /dev/null
+++ b/arch/arm/cpu/samsung-common/timer.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2009 Samsung Electronics
+ * Heungjun Kim <riverful.kim@samsung.com>
+ * Inki Dae <inki.dae@samsung.com>
+ * Minkyu Kang <mk7.kang@samsung.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+ 
+ */
+
+#include <common.h>
+#include <div64.h>
+#include <asm/io.h>
+#include <asm/samsung-common/pwm.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/clk.h>
+#include <pwm.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* macro to read the 16 bit timer */
+static inline struct s5p_timer *s5p_get_base_timer(void)
+{
+	return (struct s5p_timer *)samsung_get_base_timer();
+}
+
+/**
+ * Read the countdown timer.
+ *
+ * This operates at 1MHz and counts downwards. It will wrap about every
+ * hour (2^32 microseconds).
+ *
+ * @return current value of timer
+ */
+static unsigned long timer_get_us_down(void)
+{
+	struct s5p_timer *const timer = s5p_get_base_timer();
+
+	return readl(&timer->tcnto4);
+}
+
+int timer_init(void)
+{
+	/* PWM Timer 4 */
+	pwm_init(4, MUX_DIV_4, 0);
+	pwm_config(4, 100000, 100000);
+	pwm_enable(4);
+
+	/* Use this as the current monotonic time in us */
+	gd->arch.timer_reset_value = 0;
+
+	/* Use this as the last timer value we saw */
+	gd->arch.lastinc = timer_get_us_down();
+	reset_timer_masked();
+
+	return 0;
+}
+
+/*
+ * timer without interrupts
+ */
+unsigned long get_timer(unsigned long base)
+{
+	unsigned long long time_ms;
+
+	ulong now = timer_get_us_down();
+
+	/*
+	 * Increment the time by the amount elapsed since the last read.
+	 * The timer may have wrapped around, but it makes no difference to
+	 * our arithmetic here.
+	 */
+	gd->arch.timer_reset_value += gd->arch.lastinc - now;
+	gd->arch.lastinc = now;
+
+	/* Divide by 1000 to convert from us to ms */
+	time_ms = gd->arch.timer_reset_value;
+	do_div(time_ms, 1000);
+	return time_ms - base;
+}
+
+unsigned long __attribute__((no_instrument_function)) timer_get_us(void)
+{
+	static unsigned long base_time_us;
+
+	struct s5p_timer *const timer =
+		(struct s5p_timer *)samsung_get_base_timer();
+	unsigned long now_downward_us = readl(&timer->tcnto4);
+
+	if (!base_time_us)
+		base_time_us = now_downward_us;
+
+	/* Note that this timer counts downward. */
+	return base_time_us - now_downward_us;
+}
+
+/* delay x useconds */
+void __udelay(unsigned long usec)
+{
+	unsigned long count_value;
+
+	count_value = timer_get_us_down();
+	while ((int)(count_value - timer_get_us_down()) < (int)usec)
+		;
+}
+
+void reset_timer_masked(void)
+{
+	struct s5p_timer *const timer = s5p_get_base_timer();
+
+	/* reset time */
+	gd->arch.lastinc = readl(&timer->tcnto4);
+	gd->arch.tbl = 0;
+}
+
+/*
+ * This function is derived from PowerPC code (read timebase as long long).
+ * On ARM it just returns the timer value.
+ */
+unsigned long long get_ticks(void)
+{
+	return get_timer(0);
+}
+
+/*
+ * This function is derived from PowerPC code (timebase clock frequency).
+ * On ARM it returns the number of timer ticks per second.
+ */
+unsigned long get_tbclk(void)
+{
+	return CONFIG_SYS_HZ;
+}
diff --git a/arch/arm/include/asm/arch-exynos/pwm.h b/arch/arm/include/asm/arch-exynos/pwm.h
deleted file mode 100644
index 43474c3..0000000
--- a/arch/arm/include/asm/arch-exynos/pwm.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2009 Samsung Electronics
- * Kyungmin Park <kyungmin.park@samsung.com>
- * Minkyu Kang <mk7.kang@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#ifndef __ASM_ARM_ARCH_PWM_H_
-#define __ASM_ARM_ARCH_PWM_H_
-
-#define PRESCALER_0		(8 - 1)		/* prescaler of timer 0, 1 */
-#define PRESCALER_1		(16 - 1)	/* prescaler of timer 2, 3, 4 */
-
-/* Divider MUX */
-#define MUX_DIV_1		0		/* 1/1 period */
-#define MUX_DIV_2		1		/* 1/2 period */
-#define MUX_DIV_4		2		/* 1/4 period */
-#define MUX_DIV_8		3		/* 1/8 period */
-#define MUX_DIV_16		4		/* 1/16 period */
-
-#define MUX_DIV_SHIFT(x)	(x * 4)
-
-#define TCON_OFFSET(x)		((x + 1) * (!!x) << 2)
-
-#define TCON_START(x)		(1 << TCON_OFFSET(x))
-#define TCON_UPDATE(x)		(1 << (TCON_OFFSET(x) + 1))
-#define TCON_INVERTER(x)	(1 << (TCON_OFFSET(x) + 2))
-#define TCON_AUTO_RELOAD(x)	(1 << (TCON_OFFSET(x) + 3))
-#define TCON4_AUTO_RELOAD	(1 << 22)
-
-#ifndef __ASSEMBLY__
-struct s5p_timer {
-	unsigned int	tcfg0;
-	unsigned int	tcfg1;
-	unsigned int	tcon;
-	unsigned int	tcntb0;
-	unsigned int	tcmpb0;
-	unsigned int	tcnto0;
-	unsigned int	tcntb1;
-	unsigned int	tcmpb1;
-	unsigned int	tcnto1;
-	unsigned int	tcntb2;
-	unsigned int	tcmpb2;
-	unsigned int	tcnto2;
-	unsigned int	tcntb3;
-	unsigned int	tcmpb3;
-	unsigned int	tcnto3;
-	unsigned int	tcntb4;
-	unsigned int	tcnto4;
-	unsigned int	tintcstat;
-};
-#endif	/* __ASSEMBLY__ */
-
-#endif
diff --git a/arch/arm/include/asm/arch-exynos/sromc.h b/arch/arm/include/asm/arch-exynos/sromc.h
deleted file mode 100644
index 7f58403..0000000
--- a/arch/arm/include/asm/arch-exynos/sromc.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * (C) Copyright 2010 Samsung Electronics
- * Naveen Krishna Ch <ch.naveen@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- *
- * Note: This file contains the register description for SROMC
- */
-
-#ifndef __ASM_ARCH_SROMC_H_
-#define __ASM_ARCH_SROMC_H_
-
-#define SROMC_DATA16_WIDTH(x)    (1<<((x*4)+0))
-#define SROMC_BYTE_ADDR_MODE(x)  (1<<((x*4)+1))  /* 0-> Half-word base address*/
-						/* 1-> Byte base address*/
-#define SROMC_WAIT_ENABLE(x)     (1<<((x*4)+2))
-#define SROMC_BYTE_ENABLE(x)     (1<<((x*4)+3))
-
-#define SROMC_BC_TACS(x) (x << 28) /* address set-up */
-#define SROMC_BC_TCOS(x) (x << 24) /* chip selection set-up */
-#define SROMC_BC_TACC(x) (x << 16) /* access cycle */
-#define SROMC_BC_TCOH(x) (x << 12) /* chip selection hold */
-#define SROMC_BC_TAH(x)  (x << 8)  /* address holding time */
-#define SROMC_BC_TACP(x) (x << 4)  /* page mode access cycle */
-#define SROMC_BC_PMC(x)  (x << 0)  /* normal(1data)page mode configuration */
-
-#ifndef __ASSEMBLY__
-struct s5p_sromc {
-	unsigned int	bw;
-	unsigned int	bc[4];
-};
-#endif	/* __ASSEMBLY__ */
-
-/* Configure the Band Width and Bank Control Regs for required SROMC Bank */
-void s5p_config_sromc(u32 srom_bank, u32 srom_bw_conf, u32 srom_bc_conf);
-
-enum {
-	FDT_SROM_PMC,
-	FDT_SROM_TACP,
-	FDT_SROM_TAH,
-	FDT_SROM_TCOH,
-	FDT_SROM_TACC,
-	FDT_SROM_TCOS,
-	FDT_SROM_TACS,
-
-	FDT_SROM_TIMING_COUNT,
-};
-
-struct fdt_sromc {
-	u8 bank;	/* srom bank number */
-	u8 width;	/* bus width in bytes */
-	unsigned int timing[FDT_SROM_TIMING_COUNT]; /* timing parameters */
-};
-
-#endif /* __ASM_ARCH_SROMC_H_ */
diff --git a/arch/arm/include/asm/arch-s5pc1xx/pwm.h b/arch/arm/include/asm/arch-s5pc1xx/pwm.h
deleted file mode 100644
index 7a33ed8..0000000
--- a/arch/arm/include/asm/arch-s5pc1xx/pwm.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2009 Samsung Electronics
- * Kyungmin Park <kyungmin.park@samsung.com>
- * Minkyu Kang <mk7.kang@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#ifndef __ASM_ARM_ARCH_PWM_H_
-#define __ASM_ARM_ARCH_PWM_H_
-
-#define PRESCALER_0		(8 - 1)		/* prescaler of timer 0, 1 */
-#define PRESCALER_1		(16 - 1)	/* prescaler of timer 2, 3, 4 */
-
-/* Divider MUX */
-#define MUX_DIV_1		0		/* 1/1 period */
-#define MUX_DIV_2		1		/* 1/2 period */
-#define MUX_DIV_4		2		/* 1/4 period */
-#define MUX_DIV_8		3		/* 1/8 period */
-#define MUX_DIV_16		4		/* 1/16 period */
-
-#define MUX_DIV_SHIFT(x)	(x * 4)
-
-#define TCON_OFFSET(x)		((x + 1) * (!!x) << 2)
-
-#define TCON_START(x)		(1 << TCON_OFFSET(x))
-#define TCON_UPDATE(x)		(1 << (TCON_OFFSET(x) + 1))
-#define TCON_INVERTER(x)	(1 << (TCON_OFFSET(x) + 2))
-#define TCON_AUTO_RELOAD(x)	(1 << (TCON_OFFSET(x) + 3))
-#define TCON4_AUTO_RELOAD	(1 << 22)
-
-#ifndef __ASSEMBLY__
-struct s5p_timer {
-	unsigned int	tcfg0;
-	unsigned int	tcfg1;
-	unsigned int	tcon;
-	unsigned int	tcntb0;
-	unsigned int	tcmpb0;
-	unsigned int	tcnto0;
-	unsigned int	tcntb1;
-	unsigned int	tcmpb1;
-	unsigned int	tcnto1;
-	unsigned int	tcntb2;
-	unsigned int	tcmpb2;
-	unsigned int	tcnto2;
-	unsigned int	tcntb3;
-	unsigned int	res1;
-	unsigned int	tcnto3;
-	unsigned int	tcntb4;
-	unsigned int	tcnto4;
-	unsigned int	tintcstat;
-};
-#endif	/* __ASSEMBLY__ */
-
-#endif
diff --git a/arch/arm/include/asm/arch-s5pc1xx/sromc.h b/arch/arm/include/asm/arch-s5pc1xx/sromc.h
deleted file mode 100644
index df1bf51..0000000
--- a/arch/arm/include/asm/arch-s5pc1xx/sromc.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * (C) Copyright 2010 Samsung Electronics
- * Naveen Krishna Ch <ch.naveen@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- *
- * Note: This file contains the register description for Memory subsystem
- * 	 (SROM, NAND Flash, OneNand, DDR, OneDRAM) on S5PC1XX.
- *
- * 	 Only SROMC is defined as of now
- */
-
-#ifndef __ASM_ARCH_SROMC_H_
-#define __ASM_ARCH_SROMC_H_
-
-#define SMC_DATA16_WIDTH(x)    (1<<((x*4)+0))
-#define SMC_BYTE_ADDR_MODE(x)  (1<<((x*4)+1))  /* 0-> Half-word base address*/
-						/* 1-> Byte base address*/
-#define SMC_WAIT_ENABLE(x)     (1<<((x*4)+2))
-#define SMC_BYTE_ENABLE(x)     (1<<((x*4)+3))
-
-#define SMC_BC_TACS(x) (x << 28) /* 0clk     address set-up */
-#define SMC_BC_TCOS(x) (x << 24) /* 4clk     chip selection set-up */
-#define SMC_BC_TACC(x) (x << 16) /* 14clk    access cycle */
-#define SMC_BC_TCOH(x) (x << 12) /* 1clk     chip selection hold */
-#define SMC_BC_TAH(x)  (x << 8)  /* 4clk     address holding time */
-#define SMC_BC_TACP(x) (x << 4)  /* 6clk     page mode access cycle */
-#define SMC_BC_PMC(x)  (x << 0)  /* normal(1data)page mode configuration */
-
-#ifndef __ASSEMBLY__
-struct s5p_sromc {
-	unsigned int	bw;
-	unsigned int	bc[6];
-};
-#endif	/* __ASSEMBLY__ */
-
-/* Configure the Band Width and Bank Control Regs for required SROMC Bank */
-void s5p_config_sromc(u32 srom_bank, u32 srom_bw_conf, u32 srom_bc_conf);
-
-#endif /* __ASM_ARCH_SMC_H_ */
diff --git a/arch/arm/include/asm/samsung-common/pwm.h b/arch/arm/include/asm/samsung-common/pwm.h
new file mode 100644
index 0000000..43474c3
--- /dev/null
+++ b/arch/arm/include/asm/samsung-common/pwm.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 Samsung Electronics
+ * Kyungmin Park <kyungmin.park@samsung.com>
+ * Minkyu Kang <mk7.kang@samsung.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __ASM_ARM_ARCH_PWM_H_
+#define __ASM_ARM_ARCH_PWM_H_
+
+#define PRESCALER_0		(8 - 1)		/* prescaler of timer 0, 1 */
+#define PRESCALER_1		(16 - 1)	/* prescaler of timer 2, 3, 4 */
+
+/* Divider MUX */
+#define MUX_DIV_1		0		/* 1/1 period */
+#define MUX_DIV_2		1		/* 1/2 period */
+#define MUX_DIV_4		2		/* 1/4 period */
+#define MUX_DIV_8		3		/* 1/8 period */
+#define MUX_DIV_16		4		/* 1/16 period */
+
+#define MUX_DIV_SHIFT(x)	(x * 4)
+
+#define TCON_OFFSET(x)		((x + 1) * (!!x) << 2)
+
+#define TCON_START(x)		(1 << TCON_OFFSET(x))
+#define TCON_UPDATE(x)		(1 << (TCON_OFFSET(x) + 1))
+#define TCON_INVERTER(x)	(1 << (TCON_OFFSET(x) + 2))
+#define TCON_AUTO_RELOAD(x)	(1 << (TCON_OFFSET(x) + 3))
+#define TCON4_AUTO_RELOAD	(1 << 22)
+
+#ifndef __ASSEMBLY__
+struct s5p_timer {
+	unsigned int	tcfg0;
+	unsigned int	tcfg1;
+	unsigned int	tcon;
+	unsigned int	tcntb0;
+	unsigned int	tcmpb0;
+	unsigned int	tcnto0;
+	unsigned int	tcntb1;
+	unsigned int	tcmpb1;
+	unsigned int	tcnto1;
+	unsigned int	tcntb2;
+	unsigned int	tcmpb2;
+	unsigned int	tcnto2;
+	unsigned int	tcntb3;
+	unsigned int	tcmpb3;
+	unsigned int	tcnto3;
+	unsigned int	tcntb4;
+	unsigned int	tcnto4;
+	unsigned int	tintcstat;
+};
+#endif	/* __ASSEMBLY__ */
+
+#endif
diff --git a/arch/arm/include/asm/samsung-common/sromc.h b/arch/arm/include/asm/samsung-common/sromc.h
new file mode 100644
index 0000000..2e3a99e
--- /dev/null
+++ b/arch/arm/include/asm/samsung-common/sromc.h
@@ -0,0 +1,60 @@
+/*
+ * (C) Copyright 2010 Samsung Electronics
+ * Naveen Krishna Ch <ch.naveen@samsung.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * Note: This file contains the register description for SROMC
+ */
+
+#ifndef __ASM_ARCH_SROMC_H_
+#define __ASM_ARCH_SROMC_H_
+
+#define SROMC_DATA16_WIDTH(x)    (1<<((x*4)+0))
+#define SROMC_BYTE_ADDR_MODE(x)  (1<<((x*4)+1))  /* 0-> Half-word base address*/
+						/* 1-> Byte base address*/
+#define SROMC_WAIT_ENABLE(x)     (1<<((x*4)+2))
+#define SROMC_BYTE_ENABLE(x)     (1<<((x*4)+3))
+
+#define SROMC_BC_TACS(x) (x << 28) /* address set-up */
+#define SROMC_BC_TCOS(x) (x << 24) /* chip selection set-up */
+#define SROMC_BC_TACC(x) (x << 16) /* access cycle */
+#define SROMC_BC_TCOH(x) (x << 12) /* chip selection hold */
+#define SROMC_BC_TAH(x)  (x << 8)  /* address holding time */
+#define SROMC_BC_TACP(x) (x << 4)  /* page mode access cycle */
+#define SROMC_BC_PMC(x)  (x << 0)  /* normal(1data)page mode configuration */
+
+#ifndef __ASSEMBLY__
+struct s5p_sromc {
+	unsigned int	bw;
+#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
+	unsigned int	bc[4];
+#else
+	unsigned int	bc[6];
+#endif
+};
+#endif	/* __ASSEMBLY__ */
+
+
+/* Configure the Band Width and Bank Control Regs for required SROMC Bank */
+void s5p_config_sromc(u32 srom_bank, u32 srom_bw_conf, u32 srom_bc_conf);
+
+enum {
+	FDT_SROM_PMC,
+	FDT_SROM_TACP,
+	FDT_SROM_TAH,
+	FDT_SROM_TCOH,
+	FDT_SROM_TACC,
+	FDT_SROM_TCOS,
+	FDT_SROM_TACS,
+
+	FDT_SROM_TIMING_COUNT,
+};
+
+struct fdt_sromc {
+	u8 bank;	/* srom bank number */
+	u8 width;	/* bus width in bytes */
+	unsigned int timing[FDT_SROM_TIMING_COUNT]; /* timing parameters */
+};
+
+#endif /* __ASM_ARCH_SROMC_H_ */
diff --git a/board/samsung/smdk5250/exynos5-dt.c b/board/samsung/smdk5250/exynos5-dt.c
index bb4a82f..734183a 100644
--- a/board/samsung/smdk5250/exynos5-dt.c
+++ b/board/samsung/smdk5250/exynos5-dt.c
@@ -18,7 +18,7 @@
 #include <asm/arch/mmc.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/power.h>
-#include <asm/arch/sromc.h>
+#include <asm/samsung-common/sromc.h>
 #include <power/pmic.h>
 #include <power/max77686_pmic.h>
 #include <tmu.h>
diff --git a/board/samsung/smdkc100/smdkc100.c b/board/samsung/smdkc100/smdkc100.c
index 860c851..1e481f9 100644
--- a/board/samsung/smdkc100/smdkc100.c
+++ b/board/samsung/smdkc100/smdkc100.c
@@ -8,7 +8,7 @@
 
 #include <common.h>
 #include <asm/io.h>
-#include <asm/arch/sromc.h>
+#include <asm/samsung-common/sromc.h>
 #include <asm/arch/gpio.h>
 #include <netdev.h>
 
@@ -28,10 +28,11 @@ static void smc9115_pre_init(void)
 	s5p_gpio_cfg_pin(&gpio->k0, CONFIG_ENV_SROM_BANK, GPIO_FUNC(2));
 
 	/* Ethernet needs bus width of 16 bits */
-	smc_bw_conf = SMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK);
-	smc_bc_conf = SMC_BC_TACS(0x0) | SMC_BC_TCOS(0x4) | SMC_BC_TACC(0xe)
-			| SMC_BC_TCOH(0x1) | SMC_BC_TAH(0x4)
-			| SMC_BC_TACP(0x6) | SMC_BC_PMC(0x0);
+	smc_bw_conf = SROMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK);
+	smc_bc_conf = SROMC_BC_TACS(0x0) | SROMC_BC_TCOS(0x4)
+		| SROMC_BC_TACC(0xe) | SROMC_BC_TCOH(0x1)
+		| SROMC_BC_TAH(0x4) | SROMC_BC_TACP(0x6)
+		| SROMC_BC_PMC(0x0);
 
 	/* Select and configure the SROMC bank */
 	s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf);
diff --git a/board/samsung/smdkv310/smdkv310.c b/board/samsung/smdkv310/smdkv310.c
index 81a3060..b85fe14 100644
--- a/board/samsung/smdkv310/smdkv310.c
+++ b/board/samsung/smdkv310/smdkv310.c
@@ -12,7 +12,7 @@
 #include <asm/arch/mmc.h>
 #include <asm/arch/periph.h>
 #include <asm/arch/pinmux.h>
-#include <asm/arch/sromc.h>
+#include <asm/samsung-common/sromc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 struct exynos4_gpio_part1 *gpio1;
diff --git a/spl/Makefile b/spl/Makefile
index 6e5299b..d7d7b40 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -102,7 +102,7 @@ LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o
 endif
 
 ifeq ($(SOC),exynos)
-LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o
+LIBS-y += arch/$(ARCH)/cpu/samsung-common/libsamsung-common.o
 endif
 
 # Add GCC lib
-- 
1.7.10.4

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

* [U-Boot] [PATCH v3 3/3] arm:samsung:cpu_info: Rename s5p_* to samsung_*
  2013-08-12 21:15 ` [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code Lukasz Majewski
  2013-08-12 21:15   ` [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code Lukasz Majewski
  2013-08-12 21:15   ` [U-Boot] [PATCH v3 2/3] arm:samsung: Move common code from ./s5p-common to ./samsung-common/ Lukasz Majewski
@ 2013-08-12 21:15   ` Lukasz Majewski
  2013-08-22 10:55   ` [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code Lukasz Majewski
  3 siblings, 0 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-08-12 21:15 UTC (permalink / raw)
  To: u-boot

Common CPU info code has been refactored to use more generic name - namely
samsung_* instead of s5p_*.
This change will prevent code duplication for non armv7a based SoCs (e.g.
s3c64xx).

Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>

---
Changes for v3:
- New patch
---
 arch/arm/cpu/samsung-common/cpu_info.c  |   10 +++++-----
 arch/arm/include/asm/arch-exynos/cpu.h  |   24 ++++++++++++------------
 arch/arm/include/asm/arch-s5pc1xx/cpu.h |   12 ++++++------
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/arch/arm/cpu/samsung-common/cpu_info.c b/arch/arm/cpu/samsung-common/cpu_info.c
index e18c4f6..89dc80d 100644
--- a/arch/arm/cpu/samsung-common/cpu_info.c
+++ b/arch/arm/cpu/samsung-common/cpu_info.c
@@ -9,14 +9,14 @@
 #include <asm/arch/clk.h>
 
 /* Default is s5pc100 */
-unsigned int s5p_cpu_id = 0xC100;
+unsigned int samsung_cpu_id = 0xC100;
 /* Default is EVT1 */
-unsigned int s5p_cpu_rev = 1;
+unsigned int samsung_cpu_rev = 1;
 
 #ifdef CONFIG_ARCH_CPU_INIT
 int arch_cpu_init(void)
 {
-	s5p_set_cpu_id();
+	samsung_set_cpu_id();
 
 	return 0;
 }
@@ -24,7 +24,7 @@ int arch_cpu_init(void)
 
 u32 get_device_type(void)
 {
-	return s5p_cpu_id;
+	return samsung_cpu_id;
 }
 
 #ifdef CONFIG_DISPLAY_CPUINFO
@@ -32,7 +32,7 @@ int print_cpuinfo(void)
 {
 	char buf[32];
 
-	printf("CPU:\t%s%X@%sMHz\n", s5p_get_cpu_name(), s5p_cpu_id,
+	printf("CPU:\t%s%X@%sMHz\n", samsung_get_cpu_name(), samsung_cpu_id,
 	       strmhz(buf, get_arm_clk()));
 
 	return 0;
diff --git a/arch/arm/include/asm/arch-exynos/cpu.h b/arch/arm/include/asm/arch-exynos/cpu.h
index cb924fb..17106df 100644
--- a/arch/arm/include/asm/arch-exynos/cpu.h
+++ b/arch/arm/include/asm/arch-exynos/cpu.h
@@ -124,40 +124,40 @@
 #ifndef __ASSEMBLY__
 #include <asm/io.h>
 /* CPU detection macros */
-extern unsigned int s5p_cpu_id;
-extern unsigned int s5p_cpu_rev;
+extern unsigned int samsung_cpu_id;
+extern unsigned int samsung_cpu_rev;
 
 static inline int s5p_get_cpu_rev(void)
 {
-	return s5p_cpu_rev;
+	return samsung_cpu_rev;
 }
 
-static inline void s5p_set_cpu_id(void)
+static inline void samsung_set_cpu_id(void)
 {
 	unsigned int pro_id = (readl(EXYNOS4_PRO_ID) & 0x00FFF000) >> 12;
 
 	switch (pro_id) {
 	case 0x200:
 		/* Exynos4210 EVT0 */
-		s5p_cpu_id = 0x4210;
-		s5p_cpu_rev = 0;
+		samsung_cpu_id = 0x4210;
+		samsung_cpu_rev = 0;
 		break;
 	case 0x210:
 		/* Exynos4210 EVT1 */
-		s5p_cpu_id = 0x4210;
+		samsung_cpu_id = 0x4210;
 		break;
 	case 0x412:
 		/* Exynos4412 */
-		s5p_cpu_id = 0x4412;
+		samsung_cpu_id = 0x4412;
 		break;
 	case 0x520:
 		/* Exynos5250 */
-		s5p_cpu_id = 0x5250;
+		samsung_cpu_id = 0x5250;
 		break;
 	}
 }
 
-static inline char *s5p_get_cpu_name(void)
+static inline char *samsung_get_cpu_name(void)
 {
 	return EXYNOS_CPU_NAME;
 }
@@ -165,7 +165,7 @@ static inline char *s5p_get_cpu_name(void)
 #define IS_SAMSUNG_TYPE(type, id)			\
 static inline int __attribute__((no_instrument_function)) cpu_is_##type(void) \
 {							\
-	return (s5p_cpu_id >> 12) == id;		\
+	return (samsung_cpu_id >> 12) == id;		\
 }
 
 IS_SAMSUNG_TYPE(exynos4, 0x4)
@@ -175,7 +175,7 @@ IS_SAMSUNG_TYPE(exynos5, 0x5)
 static inline int __attribute__((no_instrument_function)) \
 	proid_is_##type(void)				\
 {							\
-	return s5p_cpu_id == id;			\
+	return samsung_cpu_id == id;			\
 }
 
 IS_EXYNOS_TYPE(exynos4210, 0x4210)
diff --git a/arch/arm/include/asm/arch-s5pc1xx/cpu.h b/arch/arm/include/asm/arch-s5pc1xx/cpu.h
index 4fc5a0c..b3208ce 100644
--- a/arch/arm/include/asm/arch-s5pc1xx/cpu.h
+++ b/arch/arm/include/asm/arch-s5pc1xx/cpu.h
@@ -50,15 +50,15 @@
 #ifndef __ASSEMBLY__
 #include <asm/io.h>
 /* CPU detection macros */
-extern unsigned int s5p_cpu_id;
+extern unsigned int samsung_cpu_id;
 
-static inline void s5p_set_cpu_id(void)
+static inline void samsung_set_cpu_id(void)
 {
-	s5p_cpu_id = readl(S5PC100_PRO_ID);
-	s5p_cpu_id = 0xC000 | ((s5p_cpu_id & 0x00FFF000) >> 12);
+	samsung_cpu_id = readl(S5PC100_PRO_ID);
+	samsung_cpu_id = 0xC000 | ((samsung_cpu_id & 0x00FFF000) >> 12);
 }
 
-static inline char *s5p_get_cpu_name(void)
+static inline char *samsung_get_cpu_name(void)
 {
 	return S5P_CPU_NAME;
 }
@@ -66,7 +66,7 @@ static inline char *s5p_get_cpu_name(void)
 #define IS_SAMSUNG_TYPE(type, id)			\
 static inline int cpu_is_##type(void)			\
 {							\
-	return s5p_cpu_id == id ? 1 : 0;		\
+	return samsung_cpu_id == id ? 1 : 0;		\
 }
 
 IS_SAMSUNG_TYPE(s5pc100, 0xc100)
-- 
1.7.10.4

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

* [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code
  2013-08-12 21:15   ` [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code Lukasz Majewski
@ 2013-08-16  7:16     ` Lukasz Majewski
  2013-08-28 10:11     ` Minkyu Kang
  1 sibling, 0 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-08-16  7:16 UTC (permalink / raw)
  To: u-boot


Hi Minkyu,

By mistake I've forgotten to add you to CC for the v3 of this patch
series.

However you were on CC for last two versions of those patches.

I'd be very grateful for feedback :-)

> This commit brings removal of duplicated code for UART IP block
> embedded at Samsung SoCs.
> New include/asm/samsung-common directory has been created to store
> common code for existing and future Samsung targets.
> 
> Moreover building of UART code now depends on more verbose
> CONFIG_S5P_SERIAL. Thereof all relevant boards configs have been
> adjusted.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
> 
> ---
> Changes for v3:
> - Comply with SPDX license format
> 
> Changes for v2:
> - Remove S3C64XX define from the code
> ---
>  arch/arm/include/asm/arch-exynos/uart.h    |   44 -------------------
>  arch/arm/include/asm/arch-s5pc1xx/uart.h   |   44 -------------------
>  arch/arm/include/asm/samsung-common/uart.h |   64
> ++++++++++++++++++++++++++++
> drivers/serial/Makefile                    |    2 +-
> drivers/serial/serial_s5p.c                |   13 +-----
> include/configs/exynos5250-dt.h            |    1 +
> include/configs/origen.h                   |    1 +
> include/configs/s5p_goni.h                 |    1 +
> include/configs/s5pc210_universal.h        |    1 +
> include/configs/smdkc100.h                 |    1 +
> include/configs/smdkv310.h                 |    1 +
> include/configs/trats.h                    |    1 + 12 files changed,
> 74 insertions(+), 100 deletions(-) delete mode 100644
> arch/arm/include/asm/arch-exynos/uart.h delete mode 100644
> arch/arm/include/asm/arch-s5pc1xx/uart.h create mode 100644
> arch/arm/include/asm/samsung-common/uart.h
> 
> diff --git a/arch/arm/include/asm/arch-exynos/uart.h
> b/arch/arm/include/asm/arch-exynos/uart.h deleted file mode 100644
> index 33d6ba3..0000000
> --- a/arch/arm/include/asm/arch-exynos/uart.h
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -/*
> - * (C) Copyright 2009 Samsung Electronics
> - * Minkyu Kang <mk7.kang@samsung.com>
> - * Heungjun Kim <riverful.kim@samsung.com>
> - *
> - * SPDX-License-Identifier:	GPL-2.0+
> - */
> -
> -#ifndef __ASM_ARCH_UART_H_
> -#define __ASM_ARCH_UART_H_
> -
> -#ifndef __ASSEMBLY__
> -/* baudrate rest value */
> -union br_rest {
> -	unsigned short	slot;		/* udivslot */
> -	unsigned char	value;		/* ufracval */
> -};
> -
> -struct s5p_uart {
> -	unsigned int	ulcon;
> -	unsigned int	ucon;
> -	unsigned int	ufcon;
> -	unsigned int	umcon;
> -	unsigned int	utrstat;
> -	unsigned int	uerstat;
> -	unsigned int	ufstat;
> -	unsigned int	umstat;
> -	unsigned char	utxh;
> -	unsigned char	res1[3];
> -	unsigned char	urxh;
> -	unsigned char	res2[3];
> -	unsigned int	ubrdiv;
> -	union br_rest	rest;
> -	unsigned char	res3[0xffd0];
> -};
> -
> -static inline int s5p_uart_divslot(void)
> -{
> -	return 0;
> -}
> -
> -#endif	/* __ASSEMBLY__ */
> -
> -#endif
> diff --git a/arch/arm/include/asm/arch-s5pc1xx/uart.h
> b/arch/arm/include/asm/arch-s5pc1xx/uart.h deleted file mode 100644
> index 26db098..0000000
> --- a/arch/arm/include/asm/arch-s5pc1xx/uart.h
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -/*
> - * (C) Copyright 2009 Samsung Electronics
> - * Minkyu Kang <mk7.kang@samsung.com>
> - * Heungjun Kim <riverful.kim@samsung.com>
> - *
> - * SPDX-License-Identifier:	GPL-2.0+
> - */
> -
> -#ifndef __ASM_ARCH_UART_H_
> -#define __ASM_ARCH_UART_H_
> -
> -#ifndef __ASSEMBLY__
> -/* baudrate rest value */
> -union br_rest {
> -	unsigned short	slot;		/* udivslot */
> -	unsigned char	value;		/* ufracval */
> -};
> -
> -struct s5p_uart {
> -	unsigned int	ulcon;
> -	unsigned int	ucon;
> -	unsigned int	ufcon;
> -	unsigned int	umcon;
> -	unsigned int	utrstat;
> -	unsigned int	uerstat;
> -	unsigned int	ufstat;
> -	unsigned int	umstat;
> -	unsigned char	utxh;
> -	unsigned char	res1[3];
> -	unsigned char	urxh;
> -	unsigned char	res2[3];
> -	unsigned int	ubrdiv;
> -	union br_rest	rest;
> -	unsigned char	res3[0x3d0];
> -};
> -
> -static inline int s5p_uart_divslot(void)
> -{
> -	return 1;
> -}
> -
> -#endif	/* __ASSEMBLY__ */
> -
> -#endif
> diff --git a/arch/arm/include/asm/samsung-common/uart.h
> b/arch/arm/include/asm/samsung-common/uart.h new file mode 100644
> index 0000000..ce92399
> --- /dev/null
> +++ b/arch/arm/include/asm/samsung-common/uart.h
> @@ -0,0 +1,64 @@
> +/*
> + * (C) Copyright 2009 Samsung Electronics
> + * Minkyu Kang <mk7.kang@samsung.com>
> + * Heungjun Kim <riverful.kim@samsung.com>
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +#ifndef __ASM_ARCH_UART_H_
> +#define __ASM_ARCH_UART_H_
> +
> +#ifndef __ASSEMBLY__
> +/* baudrate rest value */
> +union br_rest {
> +	unsigned short	slot;		/* udivslot */
> +	unsigned char	value;		/* ufracval */
> +};
> +
> +struct s5p_uart {
> +	unsigned int	ulcon;
> +	unsigned int	ucon;
> +	unsigned int	ufcon;
> +	unsigned int	umcon;
> +	unsigned int	utrstat;
> +	unsigned int	uerstat;
> +	unsigned int	ufstat;
> +	unsigned int	umstat;
> +	unsigned char	utxh;
> +	unsigned char	res1[3];
> +	unsigned char	urxh;
> +	unsigned char	res2[3];
> +	unsigned int	ubrdiv;
> +	union br_rest	rest;
> +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
> +	unsigned char	res3[0x3d0];
> +#else /* Exynos 4 and 5 */
> +	unsigned char	res3[0xffd0];
> +#endif
> +};
> +
> +
> +static inline int s5p_uart_divslot(void)
> +{
> +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
> +	return 1;
> +#else /* Exynos 4 and 5 */
> +	return 0;
> +#endif
> +}
> +
> +#define RX_FIFO_COUNT_MASK      0xff
> +#define RX_FIFO_FULL_MASK       (1 << 8)
> +#define TX_FIFO_FULL_MASK       (1 << 24)
> +
> +/* Information about a serial port */
> +struct fdt_serial {
> +	u32 base_addr;  /* address of registers in physical memory */
> +	u8 port_id;     /* uart port number */
> +	u8 enabled;     /* 1 if enabled, 0 if disabled */
> +};
> +
> +#endif	/* __ASSEMBLY__ */
> +
> +#endif
> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> index 697f2bb..e3ca49a 100644
> --- a/drivers/serial/Makefile
> +++ b/drivers/serial/Makefile
> @@ -19,7 +19,7 @@ COBJS-$(CONFIG_LPC32XX_HSUART) += lpc32xx_hsuart.o
>  COBJS-$(CONFIG_MCFUART) += mcfuart.o
>  COBJS-$(CONFIG_OPENCORES_YANU) += opencores_yanu.o
>  COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
> -COBJS-$(CONFIG_S5P) += serial_s5p.o
> +COBJS-$(CONFIG_S5P_SERIAL) += serial_s5p.o
>  COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial_ns16550.o
>  COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
>  COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
> diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
> index f98b422..be08925 100644
> --- a/drivers/serial/serial_s5p.c
> +++ b/drivers/serial/serial_s5p.c
> @@ -12,22 +12,13 @@
>  #include <fdtdec.h>
>  #include <linux/compiler.h>
>  #include <asm/io.h>
> -#include <asm/arch/uart.h>
> +#include <asm/samsung-common/uart.h>
>  #include <asm/arch/clk.h>
>  #include <serial.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> -#define RX_FIFO_COUNT_MASK	0xff
> -#define RX_FIFO_FULL_MASK	(1 << 8)
> -#define TX_FIFO_FULL_MASK	(1 << 24)
> -
> -/* Information about a serial port */
> -struct fdt_serial {
> -	u32 base_addr;  /* address of registers in physical memory */
> -	u8 port_id;     /* uart port number */
> -	u8 enabled;     /* 1 if enabled, 0 if disabled */
> -} config __attribute__ ((section(".data")));
> +struct fdt_serial config __attribute__ ((section(".data")));
>  
>  static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
>  {
> diff --git a/include/configs/exynos5250-dt.h
> b/include/configs/exynos5250-dt.h index 8f8f85f..a759d07 100644
> --- a/include/configs/exynos5250-dt.h
> +++ b/include/configs/exynos5250-dt.h
> @@ -69,6 +69,7 @@
>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (4
> << 20)) 
>  /* select serial console configuration */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_BAUDRATE			115200
>  #define EXYNOS5_DEFAULT_UART_OFFSET	0x010000
>  #define CONFIG_SILENT_CONSOLE
> diff --git a/include/configs/origen.h b/include/configs/origen.h
> index da13574..a59419d 100644
> --- a/include/configs/origen.h
> +++ b/include/configs/origen.h
> @@ -48,6 +48,7 @@
>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1
> << 20)) 
>  /* select serial console configuration */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL2			1	/* use SERIAL
> 2 */ #define CONFIG_BAUDRATE			115200
>  #define EXYNOS4_DEFAULT_UART_OFFSET	0x020000
> diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
> index d0fafd7..812b7f3 100644
> --- a/include/configs/s5p_goni.h
> +++ b/include/configs/s5p_goni.h
> @@ -42,6 +42,7 @@
>  /*
>   * select serial console configuration
>   */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL2			1	/* use
> SERIAL2 */ #define CONFIG_BAUDRATE			115200
>  
> diff --git a/include/configs/s5pc210_universal.h
> b/include/configs/s5pc210_universal.h index 97a4008..2270449 100644
> --- a/include/configs/s5pc210_universal.h
> +++ b/include/configs/s5pc210_universal.h
> @@ -48,6 +48,7 @@
>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1
> << 20)) 
>  /* select serial console configuration */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL2		1	/* use SERIAL 2 */
>  #define CONFIG_BAUDRATE		115200
>  
> diff --git a/include/configs/smdkc100.h b/include/configs/smdkc100.h
> index a572e62..4631dac 100644
> --- a/include/configs/smdkc100.h
> +++ b/include/configs/smdkc100.h
> @@ -47,6 +47,7 @@
>  /*
>   * select serial console configuration
>   */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL0			1	/* use SERIAL
> 0 on SMDKC100 */ 
>  /* PWM */
> diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h
> index 0496661..9e10bf1 100644
> --- a/include/configs/smdkv310.h
> +++ b/include/configs/smdkv310.h
> @@ -48,6 +48,7 @@
>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1
> << 20)) 
>  /* select serial console configuration */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL1			1	/* use SERIAL
> 1 */ #define CONFIG_BAUDRATE			115200
>  #define EXYNOS4_DEFAULT_UART_OFFSET	0x010000
> diff --git a/include/configs/trats.h b/include/configs/trats.h
> index 9b6aac9..6b301c8 100644
> --- a/include/configs/trats.h
> +++ b/include/configs/trats.h
> @@ -53,6 +53,7 @@
>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (16
> << 20)) 
>  /* select serial console configuration */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL2			/* use SERIAL 2 */
>  #define CONFIG_BAUDRATE			115200
>  



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

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

* [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code
  2013-08-12 21:15 ` [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code Lukasz Majewski
                     ` (2 preceding siblings ...)
  2013-08-12 21:15   ` [U-Boot] [PATCH v3 3/3] arm:samsung:cpu_info: Rename s5p_* to samsung_* Lukasz Majewski
@ 2013-08-22 10:55   ` Lukasz Majewski
  3 siblings, 0 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-08-22 10:55 UTC (permalink / raw)
  To: u-boot

Hi Minkyu,

> This series of commits attempts to clean-up the Exynos3/4 code.
> Common code for Exynos3 (S5PV210) and Exynos4 has been extracted.
> 
> Moreover it will facilitate support for older Samsung targets - like
> venerable s3c6410 (arm1176) SoC.
> 

ping.

> Lukasz Majewski (3):
>   arm:samsung:serial Extract common UART code
>   arm:samsung: Move common code from ./s5p-common to ./samsung-common/
>   arm:samsung:cpu_info: Rename s5p_* to samsung_*
> 
>  Makefile                                    |    7 +-
>  arch/arm/cpu/armv7/exynos/pinmux.c          |    2 +-
>  arch/arm/cpu/armv7/s5p-common/Makefile      |   34 ------
>  arch/arm/cpu/armv7/s5p-common/cpu_info.c    |   41 -------
>  arch/arm/cpu/armv7/s5p-common/pwm.c         |  171
> --------------------------
> arch/arm/cpu/armv7/s5p-common/sromc.c       |   33 -----
> arch/arm/cpu/armv7/s5p-common/timer.c       |  132
> -------------------- arch/arm/cpu/samsung-common/Makefile        |
> 30 +++++ arch/arm/cpu/samsung-common/cpu_info.c      |   40 +++++++
> arch/arm/cpu/samsung-common/pwm.c           |  172
> +++++++++++++++++++++++++++
> arch/arm/cpu/samsung-common/sromc.c         |   33 +++++
> arch/arm/cpu/samsung-common/timer.c         |  131
> ++++++++++++++++++++ arch/arm/include/asm/arch-exynos/cpu.h      |
> 24 ++-- arch/arm/include/asm/arch-exynos/pwm.h      |   55 ---------
> arch/arm/include/asm/arch-exynos/sromc.h    |   55 ---------
> arch/arm/include/asm/arch-exynos/uart.h     |   44 -------
> arch/arm/include/asm/arch-s5pc1xx/cpu.h     |   12 +-
> arch/arm/include/asm/arch-s5pc1xx/pwm.h     |   55 ---------
> arch/arm/include/asm/arch-s5pc1xx/sromc.h   |   40 -------
> arch/arm/include/asm/arch-s5pc1xx/uart.h    |   44 -------
> arch/arm/include/asm/samsung-common/pwm.h   |   55 +++++++++
> arch/arm/include/asm/samsung-common/sromc.h |   60 ++++++++++
> arch/arm/include/asm/samsung-common/uart.h  |   64 ++++++++++
> board/samsung/smdk5250/exynos5-dt.c         |    2 +-
> board/samsung/smdkc100/smdkc100.c           |   11 +-
> board/samsung/smdkv310/smdkv310.c           |    2 +-
> drivers/serial/Makefile                     |    2 +-
> drivers/serial/serial_s5p.c                 |   13 +-
> include/configs/exynos5250-dt.h             |    1 +
> include/configs/origen.h                    |    1 +
> include/configs/s5p_goni.h                  |    1 +
> include/configs/s5pc210_universal.h         |    1 +
> include/configs/smdkc100.h                  |    1 +
> include/configs/smdkv310.h                  |    1 +
> include/configs/trats.h                     |    1 +
> spl/Makefile                                |    2 +- 36 files
> changed, 626 insertions(+), 747 deletions(-) delete mode 100644
> arch/arm/cpu/armv7/s5p-common/Makefile delete mode 100644
> arch/arm/cpu/armv7/s5p-common/cpu_info.c delete mode 100644
> arch/arm/cpu/armv7/s5p-common/pwm.c delete mode 100644
> arch/arm/cpu/armv7/s5p-common/sromc.c delete mode 100644
> arch/arm/cpu/armv7/s5p-common/timer.c create mode 100644
> arch/arm/cpu/samsung-common/Makefile create mode 100644
> arch/arm/cpu/samsung-common/cpu_info.c create mode 100644
> arch/arm/cpu/samsung-common/pwm.c create mode 100644
> arch/arm/cpu/samsung-common/sromc.c create mode 100644
> arch/arm/cpu/samsung-common/timer.c delete mode 100644
> arch/arm/include/asm/arch-exynos/pwm.h delete mode 100644
> arch/arm/include/asm/arch-exynos/sromc.h delete mode 100644
> arch/arm/include/asm/arch-exynos/uart.h delete mode 100644
> arch/arm/include/asm/arch-s5pc1xx/pwm.h delete mode 100644
> arch/arm/include/asm/arch-s5pc1xx/sromc.h delete mode 100644
> arch/arm/include/asm/arch-s5pc1xx/uart.h create mode 100644
> arch/arm/include/asm/samsung-common/pwm.h create mode 100644
> arch/arm/include/asm/samsung-common/sromc.h create mode 100644
> arch/arm/include/asm/samsung-common/uart.h
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

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

* [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code
  2013-08-12 21:15   ` [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code Lukasz Majewski
  2013-08-16  7:16     ` Lukasz Majewski
@ 2013-08-28 10:11     ` Minkyu Kang
  2013-08-28 21:01       ` Lukasz Majewski
  1 sibling, 1 reply; 14+ messages in thread
From: Minkyu Kang @ 2013-08-28 10:11 UTC (permalink / raw)
  To: u-boot

Dear Lukasz,

On 13/08/13 06:15, Lukasz Majewski wrote:
> This commit brings removal of duplicated code for UART IP block embedded
> at Samsung SoCs.
> New include/asm/samsung-common directory has been created to store
> common code for existing and future Samsung targets.
> 
> Moreover building of UART code now depends on more verbose CONFIG_S5P_SERIAL.
> Thereof all relevant boards configs have been adjusted.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
> 
> ---
> Changes for v3:
> - Comply with SPDX license format
> 
> Changes for v2:
> - Remove S3C64XX define from the code
> ---
>  arch/arm/include/asm/arch-exynos/uart.h    |   44 -------------------
>  arch/arm/include/asm/arch-s5pc1xx/uart.h   |   44 -------------------
>  arch/arm/include/asm/samsung-common/uart.h |   64 ++++++++++++++++++++++++++++
>  drivers/serial/Makefile                    |    2 +-
>  drivers/serial/serial_s5p.c                |   13 +-----
>  include/configs/exynos5250-dt.h            |    1 +
>  include/configs/origen.h                   |    1 +
>  include/configs/s5p_goni.h                 |    1 +
>  include/configs/s5pc210_universal.h        |    1 +
>  include/configs/smdkc100.h                 |    1 +
>  include/configs/smdkv310.h                 |    1 +
>  include/configs/trats.h                    |    1 +
>  12 files changed, 74 insertions(+), 100 deletions(-)
>  delete mode 100644 arch/arm/include/asm/arch-exynos/uart.h
>  delete mode 100644 arch/arm/include/asm/arch-s5pc1xx/uart.h
>  create mode 100644 arch/arm/include/asm/samsung-common/uart.h
> 
> diff --git a/arch/arm/include/asm/arch-exynos/uart.h b/arch/arm/include/asm/arch-exynos/uart.h
> deleted file mode 100644
> index 33d6ba3..0000000
> --- a/arch/arm/include/asm/arch-exynos/uart.h
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -/*
> - * (C) Copyright 2009 Samsung Electronics
> - * Minkyu Kang <mk7.kang@samsung.com>
> - * Heungjun Kim <riverful.kim@samsung.com>
> - *
> - * SPDX-License-Identifier:	GPL-2.0+
> - */
> -
> -#ifndef __ASM_ARCH_UART_H_
> -#define __ASM_ARCH_UART_H_
> -
> -#ifndef __ASSEMBLY__
> -/* baudrate rest value */
> -union br_rest {
> -	unsigned short	slot;		/* udivslot */
> -	unsigned char	value;		/* ufracval */
> -};
> -
> -struct s5p_uart {
> -	unsigned int	ulcon;
> -	unsigned int	ucon;
> -	unsigned int	ufcon;
> -	unsigned int	umcon;
> -	unsigned int	utrstat;
> -	unsigned int	uerstat;
> -	unsigned int	ufstat;
> -	unsigned int	umstat;
> -	unsigned char	utxh;
> -	unsigned char	res1[3];
> -	unsigned char	urxh;
> -	unsigned char	res2[3];
> -	unsigned int	ubrdiv;
> -	union br_rest	rest;
> -	unsigned char	res3[0xffd0];
> -};
> -
> -static inline int s5p_uart_divslot(void)
> -{
> -	return 0;
> -}
> -
> -#endif	/* __ASSEMBLY__ */
> -
> -#endif
> diff --git a/arch/arm/include/asm/arch-s5pc1xx/uart.h b/arch/arm/include/asm/arch-s5pc1xx/uart.h
> deleted file mode 100644
> index 26db098..0000000
> --- a/arch/arm/include/asm/arch-s5pc1xx/uart.h
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -/*
> - * (C) Copyright 2009 Samsung Electronics
> - * Minkyu Kang <mk7.kang@samsung.com>
> - * Heungjun Kim <riverful.kim@samsung.com>
> - *
> - * SPDX-License-Identifier:	GPL-2.0+
> - */
> -
> -#ifndef __ASM_ARCH_UART_H_
> -#define __ASM_ARCH_UART_H_
> -
> -#ifndef __ASSEMBLY__
> -/* baudrate rest value */
> -union br_rest {
> -	unsigned short	slot;		/* udivslot */
> -	unsigned char	value;		/* ufracval */
> -};
> -
> -struct s5p_uart {
> -	unsigned int	ulcon;
> -	unsigned int	ucon;
> -	unsigned int	ufcon;
> -	unsigned int	umcon;
> -	unsigned int	utrstat;
> -	unsigned int	uerstat;
> -	unsigned int	ufstat;
> -	unsigned int	umstat;
> -	unsigned char	utxh;
> -	unsigned char	res1[3];
> -	unsigned char	urxh;
> -	unsigned char	res2[3];
> -	unsigned int	ubrdiv;
> -	union br_rest	rest;
> -	unsigned char	res3[0x3d0];
> -};
> -
> -static inline int s5p_uart_divslot(void)
> -{
> -	return 1;
> -}
> -
> -#endif	/* __ASSEMBLY__ */
> -
> -#endif
> diff --git a/arch/arm/include/asm/samsung-common/uart.h b/arch/arm/include/asm/samsung-common/uart.h
> new file mode 100644
> index 0000000..ce92399
> --- /dev/null
> +++ b/arch/arm/include/asm/samsung-common/uart.h
> @@ -0,0 +1,64 @@
> +/*
> + * (C) Copyright 2009 Samsung Electronics
> + * Minkyu Kang <mk7.kang@samsung.com>
> + * Heungjun Kim <riverful.kim@samsung.com>
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +#ifndef __ASM_ARCH_UART_H_
> +#define __ASM_ARCH_UART_H_
> +
> +#ifndef __ASSEMBLY__
> +/* baudrate rest value */
> +union br_rest {
> +	unsigned short	slot;		/* udivslot */
> +	unsigned char	value;		/* ufracval */
> +};
> +
> +struct s5p_uart {
> +	unsigned int	ulcon;
> +	unsigned int	ucon;
> +	unsigned int	ufcon;
> +	unsigned int	umcon;
> +	unsigned int	utrstat;
> +	unsigned int	uerstat;
> +	unsigned int	ufstat;
> +	unsigned int	umstat;
> +	unsigned char	utxh;
> +	unsigned char	res1[3];
> +	unsigned char	urxh;
> +	unsigned char	res2[3];
> +	unsigned int	ubrdiv;
> +	union br_rest	rest;
> +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)

OK. I understood your patch's concept and patch looks good.
But, we have not been allowed ifdef at our SoCs.
So, I can't accept your patch easily.

How you think?
Do we really need to combine headers?
I agree that they are almost duplicate codes.
But I thinks it's not a redundant.

> +	unsigned char	res3[0x3d0];
> +#else /* Exynos 4 and 5 */
> +	unsigned char	res3[0xffd0];
> +#endif
> +};
> +
> +
> +static inline int s5p_uart_divslot(void)
> +{
> +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
> +	return 1;
> +#else /* Exynos 4 and 5 */
> +	return 0;
> +#endif
> +}
> +
> +#define RX_FIFO_COUNT_MASK      0xff
> +#define RX_FIFO_FULL_MASK       (1 << 8)
> +#define TX_FIFO_FULL_MASK       (1 << 24)
> +
> +/* Information about a serial port */
> +struct fdt_serial {
> +	u32 base_addr;  /* address of registers in physical memory */
> +	u8 port_id;     /* uart port number */
> +	u8 enabled;     /* 1 if enabled, 0 if disabled */
> +};
> +
> +#endif	/* __ASSEMBLY__ */
> +
> +#endif
> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> index 697f2bb..e3ca49a 100644
> --- a/drivers/serial/Makefile
> +++ b/drivers/serial/Makefile
> @@ -19,7 +19,7 @@ COBJS-$(CONFIG_LPC32XX_HSUART) += lpc32xx_hsuart.o
>  COBJS-$(CONFIG_MCFUART) += mcfuart.o
>  COBJS-$(CONFIG_OPENCORES_YANU) += opencores_yanu.o
>  COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
> -COBJS-$(CONFIG_S5P) += serial_s5p.o
> +COBJS-$(CONFIG_S5P_SERIAL) += serial_s5p.o
>  COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial_ns16550.o
>  COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
>  COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
> diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
> index f98b422..be08925 100644
> --- a/drivers/serial/serial_s5p.c
> +++ b/drivers/serial/serial_s5p.c
> @@ -12,22 +12,13 @@
>  #include <fdtdec.h>
>  #include <linux/compiler.h>
>  #include <asm/io.h>
> -#include <asm/arch/uart.h>
> +#include <asm/samsung-common/uart.h>
>  #include <asm/arch/clk.h>
>  #include <serial.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> -#define RX_FIFO_COUNT_MASK	0xff
> -#define RX_FIFO_FULL_MASK	(1 << 8)
> -#define TX_FIFO_FULL_MASK	(1 << 24)
> -
> -/* Information about a serial port */
> -struct fdt_serial {
> -	u32 base_addr;  /* address of registers in physical memory */
> -	u8 port_id;     /* uart port number */
> -	u8 enabled;     /* 1 if enabled, 0 if disabled */
> -} config __attribute__ ((section(".data")));
> +struct fdt_serial config __attribute__ ((section(".data")));
>  
>  static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
>  {
> diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
> index 8f8f85f..a759d07 100644
> --- a/include/configs/exynos5250-dt.h
> +++ b/include/configs/exynos5250-dt.h
> @@ -69,6 +69,7 @@
>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (4 << 20))
>  
>  /* select serial console configuration */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_BAUDRATE			115200
>  #define EXYNOS5_DEFAULT_UART_OFFSET	0x010000
>  #define CONFIG_SILENT_CONSOLE
> diff --git a/include/configs/origen.h b/include/configs/origen.h
> index da13574..a59419d 100644
> --- a/include/configs/origen.h
> +++ b/include/configs/origen.h
> @@ -48,6 +48,7 @@
>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
>  
>  /* select serial console configuration */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL2			1	/* use SERIAL 2 */
>  #define CONFIG_BAUDRATE			115200
>  #define EXYNOS4_DEFAULT_UART_OFFSET	0x020000
> diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
> index d0fafd7..812b7f3 100644
> --- a/include/configs/s5p_goni.h
> +++ b/include/configs/s5p_goni.h
> @@ -42,6 +42,7 @@
>  /*
>   * select serial console configuration
>   */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL2			1	/* use SERIAL2 */
>  #define CONFIG_BAUDRATE			115200
>  
> diff --git a/include/configs/s5pc210_universal.h b/include/configs/s5pc210_universal.h
> index 97a4008..2270449 100644
> --- a/include/configs/s5pc210_universal.h
> +++ b/include/configs/s5pc210_universal.h
> @@ -48,6 +48,7 @@
>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
>  
>  /* select serial console configuration */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL2		1	/* use SERIAL 2 */
>  #define CONFIG_BAUDRATE		115200
>  
> diff --git a/include/configs/smdkc100.h b/include/configs/smdkc100.h
> index a572e62..4631dac 100644
> --- a/include/configs/smdkc100.h
> +++ b/include/configs/smdkc100.h
> @@ -47,6 +47,7 @@
>  /*
>   * select serial console configuration
>   */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL0			1	/* use SERIAL 0 on SMDKC100 */
>  
>  /* PWM */
> diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h
> index 0496661..9e10bf1 100644
> --- a/include/configs/smdkv310.h
> +++ b/include/configs/smdkv310.h
> @@ -48,6 +48,7 @@
>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1 << 20))
>  
>  /* select serial console configuration */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL1			1	/* use SERIAL 1 */
>  #define CONFIG_BAUDRATE			115200
>  #define EXYNOS4_DEFAULT_UART_OFFSET	0x010000
> diff --git a/include/configs/trats.h b/include/configs/trats.h
> index 9b6aac9..6b301c8 100644
> --- a/include/configs/trats.h
> +++ b/include/configs/trats.h
> @@ -53,6 +53,7 @@
>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (16 << 20))
>  
>  /* select serial console configuration */
> +#define CONFIG_S5P_SERIAL
>  #define CONFIG_SERIAL2			/* use SERIAL 2 */
>  #define CONFIG_BAUDRATE			115200
>  
> 

Thanks,
Minkyu Kang.

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

* [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code
  2013-08-28 10:11     ` Minkyu Kang
@ 2013-08-28 21:01       ` Lukasz Majewski
  2013-09-12 19:43         ` Lukasz Majewski
                           ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-08-28 21:01 UTC (permalink / raw)
  To: u-boot

Hi Minkyu

> Dear Lukasz,
> 
> On 13/08/13 06:15, Lukasz Majewski wrote:
> > This commit brings removal of duplicated code for UART IP block
> > embedded at Samsung SoCs.
> > New include/asm/samsung-common directory has been created to store
> > common code for existing and future Samsung targets.
> > 
> > Moreover building of UART code now depends on more verbose
> > CONFIG_S5P_SERIAL. Thereof all relevant boards configs have been
> > adjusted.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
> > 
> > ---
> > Changes for v3:
> > - Comply with SPDX license format
> > 
> > Changes for v2:
> > - Remove S3C64XX define from the code
> > ---
> >  arch/arm/include/asm/arch-exynos/uart.h    |   44
> > ------------------- arch/arm/include/asm/arch-s5pc1xx/uart.h   |
> > 44 ------------------- arch/arm/include/asm/samsung-common/uart.h
> > |   64 ++++++++++++++++++++++++++++
> > drivers/serial/Makefile                    |    2 +-
> > drivers/serial/serial_s5p.c                |   13 +-----
> > include/configs/exynos5250-dt.h            |    1 +
> > include/configs/origen.h                   |    1 +
> > include/configs/s5p_goni.h                 |    1 +
> > include/configs/s5pc210_universal.h        |    1 +
> > include/configs/smdkc100.h                 |    1 +
> > include/configs/smdkv310.h                 |    1 +
> > include/configs/trats.h                    |    1 + 12 files
> > changed, 74 insertions(+), 100 deletions(-) delete mode 100644
> > arch/arm/include/asm/arch-exynos/uart.h delete mode 100644
> > arch/arm/include/asm/arch-s5pc1xx/uart.h create mode 100644
> > arch/arm/include/asm/samsung-common/uart.h
> > 
> > diff --git a/arch/arm/include/asm/arch-exynos/uart.h
> > b/arch/arm/include/asm/arch-exynos/uart.h deleted file mode 100644
> > index 33d6ba3..0000000
> > --- a/arch/arm/include/asm/arch-exynos/uart.h
> > +++ /dev/null
> > @@ -1,44 +0,0 @@
> > -/*
> > - * (C) Copyright 2009 Samsung Electronics
> > - * Minkyu Kang <mk7.kang@samsung.com>
> > - * Heungjun Kim <riverful.kim@samsung.com>
> > - *
> > - * SPDX-License-Identifier:	GPL-2.0+
> > - */
> > -
> > -#ifndef __ASM_ARCH_UART_H_
> > -#define __ASM_ARCH_UART_H_
> > -
> > -#ifndef __ASSEMBLY__
> > -/* baudrate rest value */
> > -union br_rest {
> > -	unsigned short	slot;		/* udivslot */
> > -	unsigned char	value;		/* ufracval */
> > -};
> > -
> > -struct s5p_uart {
> > -	unsigned int	ulcon;
> > -	unsigned int	ucon;
> > -	unsigned int	ufcon;
> > -	unsigned int	umcon;
> > -	unsigned int	utrstat;
> > -	unsigned int	uerstat;
> > -	unsigned int	ufstat;
> > -	unsigned int	umstat;
> > -	unsigned char	utxh;
> > -	unsigned char	res1[3];
> > -	unsigned char	urxh;
> > -	unsigned char	res2[3];
> > -	unsigned int	ubrdiv;
> > -	union br_rest	rest;
> > -	unsigned char	res3[0xffd0];
> > -};
> > -
> > -static inline int s5p_uart_divslot(void)
> > -{
> > -	return 0;
> > -}
> > -
> > -#endif	/* __ASSEMBLY__ */
> > -
> > -#endif
> > diff --git a/arch/arm/include/asm/arch-s5pc1xx/uart.h
> > b/arch/arm/include/asm/arch-s5pc1xx/uart.h deleted file mode 100644
> > index 26db098..0000000
> > --- a/arch/arm/include/asm/arch-s5pc1xx/uart.h
> > +++ /dev/null
> > @@ -1,44 +0,0 @@
> > -/*
> > - * (C) Copyright 2009 Samsung Electronics
> > - * Minkyu Kang <mk7.kang@samsung.com>
> > - * Heungjun Kim <riverful.kim@samsung.com>
> > - *
> > - * SPDX-License-Identifier:	GPL-2.0+
> > - */
> > -
> > -#ifndef __ASM_ARCH_UART_H_
> > -#define __ASM_ARCH_UART_H_
> > -
> > -#ifndef __ASSEMBLY__
> > -/* baudrate rest value */
> > -union br_rest {
> > -	unsigned short	slot;		/* udivslot */
> > -	unsigned char	value;		/* ufracval */
> > -};
> > -
> > -struct s5p_uart {
> > -	unsigned int	ulcon;
> > -	unsigned int	ucon;
> > -	unsigned int	ufcon;
> > -	unsigned int	umcon;
> > -	unsigned int	utrstat;
> > -	unsigned int	uerstat;
> > -	unsigned int	ufstat;
> > -	unsigned int	umstat;
> > -	unsigned char	utxh;
> > -	unsigned char	res1[3];
> > -	unsigned char	urxh;
> > -	unsigned char	res2[3];
> > -	unsigned int	ubrdiv;
> > -	union br_rest	rest;
> > -	unsigned char	res3[0x3d0];
> > -};
> > -
> > -static inline int s5p_uart_divslot(void)
> > -{
> > -	return 1;
> > -}
> > -
> > -#endif	/* __ASSEMBLY__ */
> > -
> > -#endif
> > diff --git a/arch/arm/include/asm/samsung-common/uart.h
> > b/arch/arm/include/asm/samsung-common/uart.h new file mode 100644
> > index 0000000..ce92399
> > --- /dev/null
> > +++ b/arch/arm/include/asm/samsung-common/uart.h
> > @@ -0,0 +1,64 @@
> > +/*
> > + * (C) Copyright 2009 Samsung Electronics
> > + * Minkyu Kang <mk7.kang@samsung.com>
> > + * Heungjun Kim <riverful.kim@samsung.com>
> > + *
> > + * SPDX-License-Identifier:	GPL-2.0+
> > + */
> > +
> > +#ifndef __ASM_ARCH_UART_H_
> > +#define __ASM_ARCH_UART_H_
> > +
> > +#ifndef __ASSEMBLY__
> > +/* baudrate rest value */
> > +union br_rest {
> > +	unsigned short	slot;		/* udivslot */
> > +	unsigned char	value;		/* ufracval */
> > +};
> > +
> > +struct s5p_uart {
> > +	unsigned int	ulcon;
> > +	unsigned int	ucon;
> > +	unsigned int	ufcon;
> > +	unsigned int	umcon;
> > +	unsigned int	utrstat;
> > +	unsigned int	uerstat;
> > +	unsigned int	ufstat;
> > +	unsigned int	umstat;
> > +	unsigned char	utxh;
> > +	unsigned char	res1[3];
> > +	unsigned char	urxh;
> > +	unsigned char	res2[3];
> > +	unsigned int	ubrdiv;
> > +	union br_rest	rest;
> > +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[1]

> 
> OK. I understood your patch's concept and patch looks good.
> But, we have not been allowed ifdef at our SoCs.
> So, I can't accept your patch easily.

The problem is that several Samsung SoCs reuse the same IP blocks. 

For example S3C6410 (which I want to add to u-boot), S5PC100, S5PC110,
Exynos4 and Exynos5 are using the same timer, pwm, sromc, uart, udc,
sdhci, and many others IP blocks.

As I've proposed in this patch series - several IP blocks *.c files
shall go into samsung-common directory at arch/arm/cpu/samsung-common.
This arm soc version independent code can be reused at s3c6410
(arm1176) CPU.

Another issue - headers. The register map for relevant IP blocks is the
same at s3c6410 and exynos5250. The only difference is the offset at
the end of the structure.

> 
> How you think?

We can remove [1] if we define the struct s5p_uart without the
"unsigned char res3[xxx];"in the end.

It is correct, since we are using the "IP block offset defines" anyway
to index correct IP block instance (like uart0/1/2...).

> Do we really need to combine headers?
> I agree that they are almost duplicate codes.
> But I thinks it's not a redundant.
> 

Another issue is the artificial distinction between s5pc1xx and exynos
families of the processors.

Both are armv7, both are cortex (A8 and A9).I think that
arch/arm/cpu/armv7/s5pc1xx code shall be moved to
arch/arm/cpu/armv7/exynos

Also arch/arm/include/asm/arch-{s5pc1xx|exynos} code can be put to
samsung-common directory (as also proposed in those patch series).

Frankly, we shall mimic the tegra or imx tree. As fair as I've noticed
at those SoCs the common code has been put to various *-common
directories.

I've added other Samsung boards maintainers to Cc.

> > +	unsigned char	res3[0x3d0];
> > +#else /* Exynos 4 and 5 */
> > +	unsigned char	res3[0xffd0];
> > +#endif
> > +};
> > +
> > +
> > +static inline int s5p_uart_divslot(void)
> > +{
> > +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
> > +	return 1;
> > +#else /* Exynos 4 and 5 */
> > +	return 0;
> > +#endif
> > +}
> > +
> > +#define RX_FIFO_COUNT_MASK      0xff
> > +#define RX_FIFO_FULL_MASK       (1 << 8)
> > +#define TX_FIFO_FULL_MASK       (1 << 24)
> > +
> > +/* Information about a serial port */
> > +struct fdt_serial {
> > +	u32 base_addr;  /* address of registers in physical memory
> > */
> > +	u8 port_id;     /* uart port number */
> > +	u8 enabled;     /* 1 if enabled, 0 if disabled */
> > +};
> > +
> > +#endif	/* __ASSEMBLY__ */
> > +
> > +#endif
> > diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> > index 697f2bb..e3ca49a 100644
> > --- a/drivers/serial/Makefile
> > +++ b/drivers/serial/Makefile
> > @@ -19,7 +19,7 @@ COBJS-$(CONFIG_LPC32XX_HSUART) += lpc32xx_hsuart.o
> >  COBJS-$(CONFIG_MCFUART) += mcfuart.o
> >  COBJS-$(CONFIG_OPENCORES_YANU) += opencores_yanu.o
> >  COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
> > -COBJS-$(CONFIG_S5P) += serial_s5p.o
> > +COBJS-$(CONFIG_S5P_SERIAL) += serial_s5p.o
> >  COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial_ns16550.o
> >  COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
> >  COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
> > diff --git a/drivers/serial/serial_s5p.c
> > b/drivers/serial/serial_s5p.c index f98b422..be08925 100644
> > --- a/drivers/serial/serial_s5p.c
> > +++ b/drivers/serial/serial_s5p.c
> > @@ -12,22 +12,13 @@
> >  #include <fdtdec.h>
> >  #include <linux/compiler.h>
> >  #include <asm/io.h>
> > -#include <asm/arch/uart.h>
> > +#include <asm/samsung-common/uart.h>
> >  #include <asm/arch/clk.h>
> >  #include <serial.h>
> >  
> >  DECLARE_GLOBAL_DATA_PTR;
> >  
> > -#define RX_FIFO_COUNT_MASK	0xff
> > -#define RX_FIFO_FULL_MASK	(1 << 8)
> > -#define TX_FIFO_FULL_MASK	(1 << 24)
> > -
> > -/* Information about a serial port */
> > -struct fdt_serial {
> > -	u32 base_addr;  /* address of registers in physical memory
> > */
> > -	u8 port_id;     /* uart port number */
> > -	u8 enabled;     /* 1 if enabled, 0 if disabled */
> > -} config __attribute__ ((section(".data")));
> > +struct fdt_serial config __attribute__ ((section(".data")));
> >  
> >  static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
> >  {
> > diff --git a/include/configs/exynos5250-dt.h
> > b/include/configs/exynos5250-dt.h index 8f8f85f..a759d07 100644
> > --- a/include/configs/exynos5250-dt.h
> > +++ b/include/configs/exynos5250-dt.h
> > @@ -69,6 +69,7 @@
> >  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (4
> > << 20)) 
> >  /* select serial console configuration */
> > +#define CONFIG_S5P_SERIAL
> >  #define CONFIG_BAUDRATE			115200
> >  #define EXYNOS5_DEFAULT_UART_OFFSET	0x010000
> >  #define CONFIG_SILENT_CONSOLE
> > diff --git a/include/configs/origen.h b/include/configs/origen.h
> > index da13574..a59419d 100644
> > --- a/include/configs/origen.h
> > +++ b/include/configs/origen.h
> > @@ -48,6 +48,7 @@
> >  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1
> > << 20)) 
> >  /* select serial console configuration */
> > +#define CONFIG_S5P_SERIAL
> >  #define CONFIG_SERIAL2			1	/* use
> > SERIAL 2 */ #define CONFIG_BAUDRATE			115200
> >  #define EXYNOS4_DEFAULT_UART_OFFSET	0x020000
> > diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
> > index d0fafd7..812b7f3 100644
> > --- a/include/configs/s5p_goni.h
> > +++ b/include/configs/s5p_goni.h
> > @@ -42,6 +42,7 @@
> >  /*
> >   * select serial console configuration
> >   */
> > +#define CONFIG_S5P_SERIAL
> >  #define CONFIG_SERIAL2			1	/* use
> > SERIAL2 */ #define CONFIG_BAUDRATE			115200
> >  
> > diff --git a/include/configs/s5pc210_universal.h
> > b/include/configs/s5pc210_universal.h index 97a4008..2270449 100644
> > --- a/include/configs/s5pc210_universal.h
> > +++ b/include/configs/s5pc210_universal.h
> > @@ -48,6 +48,7 @@
> >  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1
> > << 20)) 
> >  /* select serial console configuration */
> > +#define CONFIG_S5P_SERIAL
> >  #define CONFIG_SERIAL2		1	/* use SERIAL 2 */
> >  #define CONFIG_BAUDRATE		115200
> >  
> > diff --git a/include/configs/smdkc100.h b/include/configs/smdkc100.h
> > index a572e62..4631dac 100644
> > --- a/include/configs/smdkc100.h
> > +++ b/include/configs/smdkc100.h
> > @@ -47,6 +47,7 @@
> >  /*
> >   * select serial console configuration
> >   */
> > +#define CONFIG_S5P_SERIAL
> >  #define CONFIG_SERIAL0			1	/* use
> > SERIAL 0 on SMDKC100 */ 
> >  /* PWM */
> > diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h
> > index 0496661..9e10bf1 100644
> > --- a/include/configs/smdkv310.h
> > +++ b/include/configs/smdkv310.h
> > @@ -48,6 +48,7 @@
> >  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1
> > << 20)) 
> >  /* select serial console configuration */
> > +#define CONFIG_S5P_SERIAL
> >  #define CONFIG_SERIAL1			1	/* use
> > SERIAL 1 */ #define CONFIG_BAUDRATE			115200
> >  #define EXYNOS4_DEFAULT_UART_OFFSET	0x010000
> > diff --git a/include/configs/trats.h b/include/configs/trats.h
> > index 9b6aac9..6b301c8 100644
> > --- a/include/configs/trats.h
> > +++ b/include/configs/trats.h
> > @@ -53,6 +53,7 @@
> >  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE +
> > (16 << 20)) 
> >  /* select serial console configuration */
> > +#define CONFIG_S5P_SERIAL
> >  #define CONFIG_SERIAL2			/* use SERIAL 2 */
> >  #define CONFIG_BAUDRATE			115200
> >  
> > 
> 
> Thanks,
> Minkyu Kang.

Regards,

Lukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130828/c4698590/attachment.pgp>

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

* [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code
  2013-08-28 21:01       ` Lukasz Majewski
@ 2013-09-12 19:43         ` Lukasz Majewski
  2013-09-13  2:45         ` Chander Kashyap
  2013-09-24  8:42         ` Minkyu Kang
  2 siblings, 0 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-09-12 19:43 UTC (permalink / raw)
  To: u-boot

Hi Minkyu,

> Hi Minkyu
> 
> > Dear Lukasz,
> > 
> > On 13/08/13 06:15, Lukasz Majewski wrote:
> > > This commit brings removal of duplicated code for UART IP block
> > > embedded at Samsung SoCs.
> > > New include/asm/samsung-common directory has been created to store
> > > common code for existing and future Samsung targets.
> > > 
> > > Moreover building of UART code now depends on more verbose
> > > CONFIG_S5P_SERIAL. Thereof all relevant boards configs have been
> > > adjusted.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
> > > 
> > > ---
> > > Changes for v3:
> > > - Comply with SPDX license format
> > > 
> > > Changes for v2:
> > > - Remove S3C64XX define from the code
> > > ---
> > >  arch/arm/include/asm/arch-exynos/uart.h    |   44
> > > ------------------- arch/arm/include/asm/arch-s5pc1xx/uart.h   |
> > > 44 ------------------- arch/arm/include/asm/samsung-common/uart.h
> > > |   64 ++++++++++++++++++++++++++++
> > > drivers/serial/Makefile                    |    2 +-
> > > drivers/serial/serial_s5p.c                |   13 +-----
> > > include/configs/exynos5250-dt.h            |    1 +
> > > include/configs/origen.h                   |    1 +
> > > include/configs/s5p_goni.h                 |    1 +
> > > include/configs/s5pc210_universal.h        |    1 +
> > > include/configs/smdkc100.h                 |    1 +
> > > include/configs/smdkv310.h                 |    1 +
> > > include/configs/trats.h                    |    1 + 12 files
> > > changed, 74 insertions(+), 100 deletions(-) delete mode 100644
> > > arch/arm/include/asm/arch-exynos/uart.h delete mode 100644
> > > arch/arm/include/asm/arch-s5pc1xx/uart.h create mode 100644
> > > arch/arm/include/asm/samsung-common/uart.h
> > > 
> > > diff --git a/arch/arm/include/asm/arch-exynos/uart.h
> > > b/arch/arm/include/asm/arch-exynos/uart.h deleted file mode 100644
> > > index 33d6ba3..0000000
> > > --- a/arch/arm/include/asm/arch-exynos/uart.h
> > > +++ /dev/null
> > > @@ -1,44 +0,0 @@
> > > -/*
> > > - * (C) Copyright 2009 Samsung Electronics
> > > - * Minkyu Kang <mk7.kang@samsung.com>
> > > - * Heungjun Kim <riverful.kim@samsung.com>
> > > - *
> > > - * SPDX-License-Identifier:	GPL-2.0+
> > > - */
> > > -
> > > -#ifndef __ASM_ARCH_UART_H_
> > > -#define __ASM_ARCH_UART_H_
> > > -
> > > -#ifndef __ASSEMBLY__
> > > -/* baudrate rest value */
> > > -union br_rest {
> > > -	unsigned short	slot;		/* udivslot */
> > > -	unsigned char	value;		/* ufracval */
> > > -};
> > > -
> > > -struct s5p_uart {
> > > -	unsigned int	ulcon;
> > > -	unsigned int	ucon;
> > > -	unsigned int	ufcon;
> > > -	unsigned int	umcon;
> > > -	unsigned int	utrstat;
> > > -	unsigned int	uerstat;
> > > -	unsigned int	ufstat;
> > > -	unsigned int	umstat;
> > > -	unsigned char	utxh;
> > > -	unsigned char	res1[3];
> > > -	unsigned char	urxh;
> > > -	unsigned char	res2[3];
> > > -	unsigned int	ubrdiv;
> > > -	union br_rest	rest;
> > > -	unsigned char	res3[0xffd0];
> > > -};
> > > -
> > > -static inline int s5p_uart_divslot(void)
> > > -{
> > > -	return 0;
> > > -}
> > > -
> > > -#endif	/* __ASSEMBLY__ */
> > > -
> > > -#endif
> > > diff --git a/arch/arm/include/asm/arch-s5pc1xx/uart.h
> > > b/arch/arm/include/asm/arch-s5pc1xx/uart.h deleted file mode
> > > 100644 index 26db098..0000000
> > > --- a/arch/arm/include/asm/arch-s5pc1xx/uart.h
> > > +++ /dev/null
> > > @@ -1,44 +0,0 @@
> > > -/*
> > > - * (C) Copyright 2009 Samsung Electronics
> > > - * Minkyu Kang <mk7.kang@samsung.com>
> > > - * Heungjun Kim <riverful.kim@samsung.com>
> > > - *
> > > - * SPDX-License-Identifier:	GPL-2.0+
> > > - */
> > > -
> > > -#ifndef __ASM_ARCH_UART_H_
> > > -#define __ASM_ARCH_UART_H_
> > > -
> > > -#ifndef __ASSEMBLY__
> > > -/* baudrate rest value */
> > > -union br_rest {
> > > -	unsigned short	slot;		/* udivslot */
> > > -	unsigned char	value;		/* ufracval */
> > > -};
> > > -
> > > -struct s5p_uart {
> > > -	unsigned int	ulcon;
> > > -	unsigned int	ucon;
> > > -	unsigned int	ufcon;
> > > -	unsigned int	umcon;
> > > -	unsigned int	utrstat;
> > > -	unsigned int	uerstat;
> > > -	unsigned int	ufstat;
> > > -	unsigned int	umstat;
> > > -	unsigned char	utxh;
> > > -	unsigned char	res1[3];
> > > -	unsigned char	urxh;
> > > -	unsigned char	res2[3];
> > > -	unsigned int	ubrdiv;
> > > -	union br_rest	rest;
> > > -	unsigned char	res3[0x3d0];
> > > -};
> > > -
> > > -static inline int s5p_uart_divslot(void)
> > > -{
> > > -	return 1;
> > > -}
> > > -
> > > -#endif	/* __ASSEMBLY__ */
> > > -
> > > -#endif
> > > diff --git a/arch/arm/include/asm/samsung-common/uart.h
> > > b/arch/arm/include/asm/samsung-common/uart.h new file mode 100644
> > > index 0000000..ce92399
> > > --- /dev/null
> > > +++ b/arch/arm/include/asm/samsung-common/uart.h
> > > @@ -0,0 +1,64 @@
> > > +/*
> > > + * (C) Copyright 2009 Samsung Electronics
> > > + * Minkyu Kang <mk7.kang@samsung.com>
> > > + * Heungjun Kim <riverful.kim@samsung.com>
> > > + *
> > > + * SPDX-License-Identifier:	GPL-2.0+
> > > + */
> > > +
> > > +#ifndef __ASM_ARCH_UART_H_
> > > +#define __ASM_ARCH_UART_H_
> > > +
> > > +#ifndef __ASSEMBLY__
> > > +/* baudrate rest value */
> > > +union br_rest {
> > > +	unsigned short	slot;		/* udivslot */
> > > +	unsigned char	value;		/* ufracval */
> > > +};
> > > +
> > > +struct s5p_uart {
> > > +	unsigned int	ulcon;
> > > +	unsigned int	ucon;
> > > +	unsigned int	ufcon;
> > > +	unsigned int	umcon;
> > > +	unsigned int	utrstat;
> > > +	unsigned int	uerstat;
> > > +	unsigned int	ufstat;
> > > +	unsigned int	umstat;
> > > +	unsigned char	utxh;
> > > +	unsigned char	res1[3];
> > > +	unsigned char	urxh;
> > > +	unsigned char	res2[3];
> > > +	unsigned int	ubrdiv;
> > > +	union br_rest	rest;
> > > +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[1]
> 
> > 
> > OK. I understood your patch's concept and patch looks good.
> > But, we have not been allowed ifdef at our SoCs.
> > So, I can't accept your patch easily.
> 
> The problem is that several Samsung SoCs reuse the same IP blocks. 
> 
> For example S3C6410 (which I want to add to u-boot), S5PC100, S5PC110,
> Exynos4 and Exynos5 are using the same timer, pwm, sromc, uart, udc,
> sdhci, and many others IP blocks.
> 
> As I've proposed in this patch series - several IP blocks *.c files
> shall go into samsung-common directory at arch/arm/cpu/samsung-common.
> This arm soc version independent code can be reused at s3c6410
> (arm1176) CPU.
> 
> Another issue - headers. The register map for relevant IP blocks is
> the same at s3c6410 and exynos5250. The only difference is the offset
> at the end of the structure.
> 
> > 
> > How you think?
> 
> We can remove [1] if we define the struct s5p_uart without the
> "unsigned char res3[xxx];"in the end.
> 
> It is correct, since we are using the "IP block offset defines" anyway
> to index correct IP block instance (like uart0/1/2...).
> 
> > Do we really need to combine headers?
> > I agree that they are almost duplicate codes.
> > But I thinks it's not a redundant.
> > 
> 
> Another issue is the artificial distinction between s5pc1xx and exynos
> families of the processors.
> 
> Both are armv7, both are cortex (A8 and A9).I think that
> arch/arm/cpu/armv7/s5pc1xx code shall be moved to
> arch/arm/cpu/armv7/exynos
> 
> Also arch/arm/include/asm/arch-{s5pc1xx|exynos} code can be put to
> samsung-common directory (as also proposed in those patch series).
> 
> Frankly, we shall mimic the tegra or imx tree. As fair as I've noticed
> at those SoCs the common code has been put to various *-common
> directories.
> 
> I've added other Samsung boards maintainers to Cc.

Have you thought about this?

> 
> > > +	unsigned char	res3[0x3d0];
> > > +#else /* Exynos 4 and 5 */
> > > +	unsigned char	res3[0xffd0];
> > > +#endif
> > > +};
> > > +
> > > +
> > > +static inline int s5p_uart_divslot(void)
> > > +{
> > > +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
> > > +	return 1;
> > > +#else /* Exynos 4 and 5 */
> > > +	return 0;
> > > +#endif
> > > +}
> > > +
> > > +#define RX_FIFO_COUNT_MASK      0xff
> > > +#define RX_FIFO_FULL_MASK       (1 << 8)
> > > +#define TX_FIFO_FULL_MASK       (1 << 24)
> > > +
> > > +/* Information about a serial port */
> > > +struct fdt_serial {
> > > +	u32 base_addr;  /* address of registers in physical
> > > memory */
> > > +	u8 port_id;     /* uart port number */
> > > +	u8 enabled;     /* 1 if enabled, 0 if disabled */
> > > +};
> > > +
> > > +#endif	/* __ASSEMBLY__ */
> > > +
> > > +#endif
> > > diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> > > index 697f2bb..e3ca49a 100644
> > > --- a/drivers/serial/Makefile
> > > +++ b/drivers/serial/Makefile
> > > @@ -19,7 +19,7 @@ COBJS-$(CONFIG_LPC32XX_HSUART) +=
> > > lpc32xx_hsuart.o COBJS-$(CONFIG_MCFUART) += mcfuart.o
> > >  COBJS-$(CONFIG_OPENCORES_YANU) += opencores_yanu.o
> > >  COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
> > > -COBJS-$(CONFIG_S5P) += serial_s5p.o
> > > +COBJS-$(CONFIG_S5P_SERIAL) += serial_s5p.o
> > >  COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial_ns16550.o
> > >  COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
> > >  COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
> > > diff --git a/drivers/serial/serial_s5p.c
> > > b/drivers/serial/serial_s5p.c index f98b422..be08925 100644
> > > --- a/drivers/serial/serial_s5p.c
> > > +++ b/drivers/serial/serial_s5p.c
> > > @@ -12,22 +12,13 @@
> > >  #include <fdtdec.h>
> > >  #include <linux/compiler.h>
> > >  #include <asm/io.h>
> > > -#include <asm/arch/uart.h>
> > > +#include <asm/samsung-common/uart.h>
> > >  #include <asm/arch/clk.h>
> > >  #include <serial.h>
> > >  
> > >  DECLARE_GLOBAL_DATA_PTR;
> > >  
> > > -#define RX_FIFO_COUNT_MASK	0xff
> > > -#define RX_FIFO_FULL_MASK	(1 << 8)
> > > -#define TX_FIFO_FULL_MASK	(1 << 24)
> > > -
> > > -/* Information about a serial port */
> > > -struct fdt_serial {
> > > -	u32 base_addr;  /* address of registers in physical
> > > memory */
> > > -	u8 port_id;     /* uart port number */
> > > -	u8 enabled;     /* 1 if enabled, 0 if disabled */
> > > -} config __attribute__ ((section(".data")));
> > > +struct fdt_serial config __attribute__ ((section(".data")));
> > >  
> > >  static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
> > >  {
> > > diff --git a/include/configs/exynos5250-dt.h
> > > b/include/configs/exynos5250-dt.h index 8f8f85f..a759d07 100644
> > > --- a/include/configs/exynos5250-dt.h
> > > +++ b/include/configs/exynos5250-dt.h
> > > @@ -69,6 +69,7 @@
> > >  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE +
> > > (4 << 20)) 
> > >  /* select serial console configuration */
> > > +#define CONFIG_S5P_SERIAL
> > >  #define CONFIG_BAUDRATE			115200
> > >  #define EXYNOS5_DEFAULT_UART_OFFSET	0x010000
> > >  #define CONFIG_SILENT_CONSOLE
> > > diff --git a/include/configs/origen.h b/include/configs/origen.h
> > > index da13574..a59419d 100644
> > > --- a/include/configs/origen.h
> > > +++ b/include/configs/origen.h
> > > @@ -48,6 +48,7 @@
> > >  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE +
> > > (1 << 20)) 
> > >  /* select serial console configuration */
> > > +#define CONFIG_S5P_SERIAL
> > >  #define CONFIG_SERIAL2			1	/* use
> > > SERIAL 2 */ #define CONFIG_BAUDRATE			115200
> > >  #define EXYNOS4_DEFAULT_UART_OFFSET	0x020000
> > > diff --git a/include/configs/s5p_goni.h
> > > b/include/configs/s5p_goni.h index d0fafd7..812b7f3 100644
> > > --- a/include/configs/s5p_goni.h
> > > +++ b/include/configs/s5p_goni.h
> > > @@ -42,6 +42,7 @@
> > >  /*
> > >   * select serial console configuration
> > >   */
> > > +#define CONFIG_S5P_SERIAL
> > >  #define CONFIG_SERIAL2			1	/* use
> > > SERIAL2 */ #define CONFIG_BAUDRATE			115200
> > >  
> > > diff --git a/include/configs/s5pc210_universal.h
> > > b/include/configs/s5pc210_universal.h index 97a4008..2270449
> > > 100644 --- a/include/configs/s5pc210_universal.h
> > > +++ b/include/configs/s5pc210_universal.h
> > > @@ -48,6 +48,7 @@
> > >  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE +
> > > (1 << 20)) 
> > >  /* select serial console configuration */
> > > +#define CONFIG_S5P_SERIAL
> > >  #define CONFIG_SERIAL2		1	/* use SERIAL 2 */
> > >  #define CONFIG_BAUDRATE		115200
> > >  
> > > diff --git a/include/configs/smdkc100.h
> > > b/include/configs/smdkc100.h index a572e62..4631dac 100644
> > > --- a/include/configs/smdkc100.h
> > > +++ b/include/configs/smdkc100.h
> > > @@ -47,6 +47,7 @@
> > >  /*
> > >   * select serial console configuration
> > >   */
> > > +#define CONFIG_S5P_SERIAL
> > >  #define CONFIG_SERIAL0			1	/* use
> > > SERIAL 0 on SMDKC100 */ 
> > >  /* PWM */
> > > diff --git a/include/configs/smdkv310.h
> > > b/include/configs/smdkv310.h index 0496661..9e10bf1 100644
> > > --- a/include/configs/smdkv310.h
> > > +++ b/include/configs/smdkv310.h
> > > @@ -48,6 +48,7 @@
> > >  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE +
> > > (1 << 20)) 
> > >  /* select serial console configuration */
> > > +#define CONFIG_S5P_SERIAL
> > >  #define CONFIG_SERIAL1			1	/* use
> > > SERIAL 1 */ #define CONFIG_BAUDRATE			115200
> > >  #define EXYNOS4_DEFAULT_UART_OFFSET	0x010000
> > > diff --git a/include/configs/trats.h b/include/configs/trats.h
> > > index 9b6aac9..6b301c8 100644
> > > --- a/include/configs/trats.h
> > > +++ b/include/configs/trats.h
> > > @@ -53,6 +53,7 @@
> > >  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE +
> > > (16 << 20)) 
> > >  /* select serial console configuration */
> > > +#define CONFIG_S5P_SERIAL
> > >  #define CONFIG_SERIAL2			/* use SERIAL 2 */
> > >  #define CONFIG_BAUDRATE			115200
> > >  
> > > 
> > 
> > Thanks,
> > Minkyu Kang.
> 
> Regards,
> 
> Lukasz Majewski

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130912/6d4631cd/attachment.pgp>

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

* [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code
  2013-08-28 21:01       ` Lukasz Majewski
  2013-09-12 19:43         ` Lukasz Majewski
@ 2013-09-13  2:45         ` Chander Kashyap
  2013-09-24  8:42         ` Minkyu Kang
  2 siblings, 0 replies; 14+ messages in thread
From: Chander Kashyap @ 2013-09-13  2:45 UTC (permalink / raw)
  To: u-boot

On 29 August 2013 02:31, Lukasz Majewski <l.majewski@majess.pl> wrote:
> Hi Minkyu
>
>> Dear Lukasz,
>>
>> On 13/08/13 06:15, Lukasz Majewski wrote:
>> > This commit brings removal of duplicated code for UART IP block
>> > embedded at Samsung SoCs.
>> > New include/asm/samsung-common directory has been created to store
>> > common code for existing and future Samsung targets.
>> >
>> > Moreover building of UART code now depends on more verbose
>> > CONFIG_S5P_SERIAL. Thereof all relevant boards configs have been
>> > adjusted.
>> >
>> > Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
>> >
>> > ---
>> > Changes for v3:
>> > - Comply with SPDX license format
>> >
>> > Changes for v2:
>> > - Remove S3C64XX define from the code
>> > ---
>> >  arch/arm/include/asm/arch-exynos/uart.h    |   44
>> > ------------------- arch/arm/include/asm/arch-s5pc1xx/uart.h   |
>> > 44 ------------------- arch/arm/include/asm/samsung-common/uart.h
>> > |   64 ++++++++++++++++++++++++++++
>> > drivers/serial/Makefile                    |    2 +-
>> > drivers/serial/serial_s5p.c                |   13 +-----
>> > include/configs/exynos5250-dt.h            |    1 +
>> > include/configs/origen.h                   |    1 +
>> > include/configs/s5p_goni.h                 |    1 +
>> > include/configs/s5pc210_universal.h        |    1 +
>> > include/configs/smdkc100.h                 |    1 +
>> > include/configs/smdkv310.h                 |    1 +
>> > include/configs/trats.h                    |    1 + 12 files
>> > changed, 74 insertions(+), 100 deletions(-) delete mode 100644
>> > arch/arm/include/asm/arch-exynos/uart.h delete mode 100644
>> > arch/arm/include/asm/arch-s5pc1xx/uart.h create mode 100644
>> > arch/arm/include/asm/samsung-common/uart.h
>> >
>> > diff --git a/arch/arm/include/asm/arch-exynos/uart.h
>> > b/arch/arm/include/asm/arch-exynos/uart.h deleted file mode 100644
>> > index 33d6ba3..0000000
>> > --- a/arch/arm/include/asm/arch-exynos/uart.h
>> > +++ /dev/null
>> > @@ -1,44 +0,0 @@
>> > -/*
>> > - * (C) Copyright 2009 Samsung Electronics
>> > - * Minkyu Kang <mk7.kang@samsung.com>
>> > - * Heungjun Kim <riverful.kim@samsung.com>
>> > - *
>> > - * SPDX-License-Identifier:        GPL-2.0+
>> > - */
>> > -
>> > -#ifndef __ASM_ARCH_UART_H_
>> > -#define __ASM_ARCH_UART_H_
>> > -
>> > -#ifndef __ASSEMBLY__
>> > -/* baudrate rest value */
>> > -union br_rest {
>> > -   unsigned short  slot;           /* udivslot */
>> > -   unsigned char   value;          /* ufracval */
>> > -};
>> > -
>> > -struct s5p_uart {
>> > -   unsigned int    ulcon;
>> > -   unsigned int    ucon;
>> > -   unsigned int    ufcon;
>> > -   unsigned int    umcon;
>> > -   unsigned int    utrstat;
>> > -   unsigned int    uerstat;
>> > -   unsigned int    ufstat;
>> > -   unsigned int    umstat;
>> > -   unsigned char   utxh;
>> > -   unsigned char   res1[3];
>> > -   unsigned char   urxh;
>> > -   unsigned char   res2[3];
>> > -   unsigned int    ubrdiv;
>> > -   union br_rest   rest;
>> > -   unsigned char   res3[0xffd0];
>> > -};
>> > -
>> > -static inline int s5p_uart_divslot(void)
>> > -{
>> > -   return 0;
>> > -}
>> > -
>> > -#endif     /* __ASSEMBLY__ */
>> > -
>> > -#endif
>> > diff --git a/arch/arm/include/asm/arch-s5pc1xx/uart.h
>> > b/arch/arm/include/asm/arch-s5pc1xx/uart.h deleted file mode 100644
>> > index 26db098..0000000
>> > --- a/arch/arm/include/asm/arch-s5pc1xx/uart.h
>> > +++ /dev/null
>> > @@ -1,44 +0,0 @@
>> > -/*
>> > - * (C) Copyright 2009 Samsung Electronics
>> > - * Minkyu Kang <mk7.kang@samsung.com>
>> > - * Heungjun Kim <riverful.kim@samsung.com>
>> > - *
>> > - * SPDX-License-Identifier:        GPL-2.0+
>> > - */
>> > -
>> > -#ifndef __ASM_ARCH_UART_H_
>> > -#define __ASM_ARCH_UART_H_
>> > -
>> > -#ifndef __ASSEMBLY__
>> > -/* baudrate rest value */
>> > -union br_rest {
>> > -   unsigned short  slot;           /* udivslot */
>> > -   unsigned char   value;          /* ufracval */
>> > -};
>> > -
>> > -struct s5p_uart {
>> > -   unsigned int    ulcon;
>> > -   unsigned int    ucon;
>> > -   unsigned int    ufcon;
>> > -   unsigned int    umcon;
>> > -   unsigned int    utrstat;
>> > -   unsigned int    uerstat;
>> > -   unsigned int    ufstat;
>> > -   unsigned int    umstat;
>> > -   unsigned char   utxh;
>> > -   unsigned char   res1[3];
>> > -   unsigned char   urxh;
>> > -   unsigned char   res2[3];
>> > -   unsigned int    ubrdiv;
>> > -   union br_rest   rest;
>> > -   unsigned char   res3[0x3d0];
>> > -};
>> > -
>> > -static inline int s5p_uart_divslot(void)
>> > -{
>> > -   return 1;
>> > -}
>> > -
>> > -#endif     /* __ASSEMBLY__ */
>> > -
>> > -#endif
>> > diff --git a/arch/arm/include/asm/samsung-common/uart.h
>> > b/arch/arm/include/asm/samsung-common/uart.h new file mode 100644
>> > index 0000000..ce92399
>> > --- /dev/null
>> > +++ b/arch/arm/include/asm/samsung-common/uart.h
>> > @@ -0,0 +1,64 @@
>> > +/*
>> > + * (C) Copyright 2009 Samsung Electronics
>> > + * Minkyu Kang <mk7.kang@samsung.com>
>> > + * Heungjun Kim <riverful.kim@samsung.com>
>> > + *
>> > + * SPDX-License-Identifier:        GPL-2.0+
>> > + */
>> > +
>> > +#ifndef __ASM_ARCH_UART_H_
>> > +#define __ASM_ARCH_UART_H_
>> > +
>> > +#ifndef __ASSEMBLY__
>> > +/* baudrate rest value */
>> > +union br_rest {
>> > +   unsigned short  slot;           /* udivslot */
>> > +   unsigned char   value;          /* ufracval */
>> > +};
>> > +
>> > +struct s5p_uart {
>> > +   unsigned int    ulcon;
>> > +   unsigned int    ucon;
>> > +   unsigned int    ufcon;
>> > +   unsigned int    umcon;
>> > +   unsigned int    utrstat;
>> > +   unsigned int    uerstat;
>> > +   unsigned int    ufstat;
>> > +   unsigned int    umstat;
>> > +   unsigned char   utxh;
>> > +   unsigned char   res1[3];
>> > +   unsigned char   urxh;
>> > +   unsigned char   res2[3];
>> > +   unsigned int    ubrdiv;
>> > +   union br_rest   rest;
>> > +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[1]
>
>>
>> OK. I understood your patch's concept and patch looks good.
>> But, we have not been allowed ifdef at our SoCs.
>> So, I can't accept your patch easily.
>
> The problem is that several Samsung SoCs reuse the same IP blocks.
>
> For example S3C6410 (which I want to add to u-boot), S5PC100, S5PC110,
> Exynos4 and Exynos5 are using the same timer, pwm, sromc, uart, udc,
> sdhci, and many others IP blocks.
>
> As I've proposed in this patch series - several IP blocks *.c files
> shall go into samsung-common directory at arch/arm/cpu/samsung-common.
> This arm soc version independent code can be reused at s3c6410
> (arm1176) CPU.
>
> Another issue - headers. The register map for relevant IP blocks is the
> same at s3c6410 and exynos5250. The only difference is the offset at
> the end of the structure.
>
>>
>> How you think?
>
> We can remove [1] if we define the struct s5p_uart without the
> "unsigned char res3[xxx];"in the end.

first of all sorry for late response.

I think it is a good thought. By removing the res[3] padding in the
structure we can do away with ifdef's.
As uart_offset is used to hop next uart port.

But keep in mind that there are another two reserved fields(res2, res3).
If there is any any change in those reserve field values in future
soc's then this approach will not work.

>
> It is correct, since we are using the "IP block offset defines" anyway
> to index correct IP block instance (like uart0/1/2...).
>
>> Do we really need to combine headers?
>> I agree that they are almost duplicate codes.
>> But I thinks it's not a redundant.
>>
>
> Another issue is the artificial distinction between s5pc1xx and exynos
> families of the processors.
>
> Both are armv7, both are cortex (A8 and A9).I think that
> arch/arm/cpu/armv7/s5pc1xx code shall be moved to
> arch/arm/cpu/armv7/exynos
>
> Also arch/arm/include/asm/arch-{s5pc1xx|exynos} code can be put to
> samsung-common directory (as also proposed in those patch series).
>
> Frankly, we shall mimic the tegra or imx tree. As fair as I've noticed
> at those SoCs the common code has been put to various *-common
> directories.
>
> I've added other Samsung boards maintainers to Cc.
>
>> > +   unsigned char   res3[0x3d0];
>> > +#else /* Exynos 4 and 5 */
>> > +   unsigned char   res3[0xffd0];
>> > +#endif
>> > +};
>> > +
>> > +
>> > +static inline int s5p_uart_divslot(void)
>> > +{
>> > +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)

This can be done away using cpu_is_xxX.

>> > +   return 1;
>> > +#else /* Exynos 4 and 5 */
>> > +   return 0;
>> > +#endif
>> > +}
>> > +
>> > +#define RX_FIFO_COUNT_MASK      0xff
>> > +#define RX_FIFO_FULL_MASK       (1 << 8)
>> > +#define TX_FIFO_FULL_MASK       (1 << 24)
>> > +
>> > +/* Information about a serial port */
>> > +struct fdt_serial {
>> > +   u32 base_addr;  /* address of registers in physical memory
>> > */
>> > +   u8 port_id;     /* uart port number */
>> > +   u8 enabled;     /* 1 if enabled, 0 if disabled */
>> > +};
>> > +
>> > +#endif     /* __ASSEMBLY__ */
>> > +
>> > +#endif
>> > diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
>> > index 697f2bb..e3ca49a 100644
>> > --- a/drivers/serial/Makefile
>> > +++ b/drivers/serial/Makefile
>> > @@ -19,7 +19,7 @@ COBJS-$(CONFIG_LPC32XX_HSUART) += lpc32xx_hsuart.o
>> >  COBJS-$(CONFIG_MCFUART) += mcfuart.o
>> >  COBJS-$(CONFIG_OPENCORES_YANU) += opencores_yanu.o
>> >  COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
>> > -COBJS-$(CONFIG_S5P) += serial_s5p.o
>> > +COBJS-$(CONFIG_S5P_SERIAL) += serial_s5p.o
>> >  COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial_ns16550.o
>> >  COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
>> >  COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
>> > diff --git a/drivers/serial/serial_s5p.c
>> > b/drivers/serial/serial_s5p.c index f98b422..be08925 100644
>> > --- a/drivers/serial/serial_s5p.c
>> > +++ b/drivers/serial/serial_s5p.c
>> > @@ -12,22 +12,13 @@
>> >  #include <fdtdec.h>
>> >  #include <linux/compiler.h>
>> >  #include <asm/io.h>
>> > -#include <asm/arch/uart.h>
>> > +#include <asm/samsung-common/uart.h>
>> >  #include <asm/arch/clk.h>
>> >  #include <serial.h>
>> >
>> >  DECLARE_GLOBAL_DATA_PTR;
>> >
>> > -#define RX_FIFO_COUNT_MASK 0xff
>> > -#define RX_FIFO_FULL_MASK  (1 << 8)
>> > -#define TX_FIFO_FULL_MASK  (1 << 24)
>> > -
>> > -/* Information about a serial port */
>> > -struct fdt_serial {
>> > -   u32 base_addr;  /* address of registers in physical memory
>> > */
>> > -   u8 port_id;     /* uart port number */
>> > -   u8 enabled;     /* 1 if enabled, 0 if disabled */
>> > -} config __attribute__ ((section(".data")));
>> > +struct fdt_serial config __attribute__ ((section(".data")));
>> >
>> >  static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
>> >  {
>> > diff --git a/include/configs/exynos5250-dt.h
>> > b/include/configs/exynos5250-dt.h index 8f8f85f..a759d07 100644
>> > --- a/include/configs/exynos5250-dt.h
>> > +++ b/include/configs/exynos5250-dt.h
>> > @@ -69,6 +69,7 @@
>> >  #define CONFIG_SYS_MALLOC_LEN              (CONFIG_ENV_SIZE + (4
>> > << 20))
>> >  /* select serial console configuration */
>> > +#define CONFIG_S5P_SERIAL
>> >  #define CONFIG_BAUDRATE                    115200
>> >  #define EXYNOS5_DEFAULT_UART_OFFSET        0x010000
>> >  #define CONFIG_SILENT_CONSOLE
>> > diff --git a/include/configs/origen.h b/include/configs/origen.h
>> > index da13574..a59419d 100644
>> > --- a/include/configs/origen.h
>> > +++ b/include/configs/origen.h
>> > @@ -48,6 +48,7 @@
>> >  #define CONFIG_SYS_MALLOC_LEN              (CONFIG_ENV_SIZE + (1
>> > << 20))
>> >  /* select serial console configuration */
>> > +#define CONFIG_S5P_SERIAL
>> >  #define CONFIG_SERIAL2                     1       /* use
>> > SERIAL 2 */ #define CONFIG_BAUDRATE                 115200
>> >  #define EXYNOS4_DEFAULT_UART_OFFSET        0x020000
>> > diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
>> > index d0fafd7..812b7f3 100644
>> > --- a/include/configs/s5p_goni.h
>> > +++ b/include/configs/s5p_goni.h
>> > @@ -42,6 +42,7 @@
>> >  /*
>> >   * select serial console configuration
>> >   */
>> > +#define CONFIG_S5P_SERIAL
>> >  #define CONFIG_SERIAL2                     1       /* use
>> > SERIAL2 */ #define CONFIG_BAUDRATE                  115200
>> >
>> > diff --git a/include/configs/s5pc210_universal.h
>> > b/include/configs/s5pc210_universal.h index 97a4008..2270449 100644
>> > --- a/include/configs/s5pc210_universal.h
>> > +++ b/include/configs/s5pc210_universal.h
>> > @@ -48,6 +48,7 @@
>> >  #define CONFIG_SYS_MALLOC_LEN              (CONFIG_ENV_SIZE + (1
>> > << 20))
>> >  /* select serial console configuration */
>> > +#define CONFIG_S5P_SERIAL
>> >  #define CONFIG_SERIAL2             1       /* use SERIAL 2 */
>> >  #define CONFIG_BAUDRATE            115200
>> >
>> > diff --git a/include/configs/smdkc100.h b/include/configs/smdkc100.h
>> > index a572e62..4631dac 100644
>> > --- a/include/configs/smdkc100.h
>> > +++ b/include/configs/smdkc100.h
>> > @@ -47,6 +47,7 @@
>> >  /*
>> >   * select serial console configuration
>> >   */
>> > +#define CONFIG_S5P_SERIAL
>> >  #define CONFIG_SERIAL0                     1       /* use
>> > SERIAL 0 on SMDKC100 */
>> >  /* PWM */
>> > diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h
>> > index 0496661..9e10bf1 100644
>> > --- a/include/configs/smdkv310.h
>> > +++ b/include/configs/smdkv310.h
>> > @@ -48,6 +48,7 @@
>> >  #define CONFIG_SYS_MALLOC_LEN              (CONFIG_ENV_SIZE + (1
>> > << 20))
>> >  /* select serial console configuration */
>> > +#define CONFIG_S5P_SERIAL
>> >  #define CONFIG_SERIAL1                     1       /* use
>> > SERIAL 1 */ #define CONFIG_BAUDRATE                 115200
>> >  #define EXYNOS4_DEFAULT_UART_OFFSET        0x010000
>> > diff --git a/include/configs/trats.h b/include/configs/trats.h
>> > index 9b6aac9..6b301c8 100644
>> > --- a/include/configs/trats.h
>> > +++ b/include/configs/trats.h
>> > @@ -53,6 +53,7 @@
>> >  #define CONFIG_SYS_MALLOC_LEN              (CONFIG_ENV_SIZE +
>> > (16 << 20))
>> >  /* select serial console configuration */
>> > +#define CONFIG_S5P_SERIAL
>> >  #define CONFIG_SERIAL2                     /* use SERIAL 2 */
>> >  #define CONFIG_BAUDRATE                    115200
>> >
>> >
>>
>> Thanks,
>> Minkyu Kang.
>
> Regards,
>
> Lukasz Majewski
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>



-- 
with warm regards,
Chander Kashyap

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

* [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code
  2013-08-28 21:01       ` Lukasz Majewski
  2013-09-12 19:43         ` Lukasz Majewski
  2013-09-13  2:45         ` Chander Kashyap
@ 2013-09-24  8:42         ` Minkyu Kang
  2013-09-24 10:11           ` Lukasz Majewski
  2 siblings, 1 reply; 14+ messages in thread
From: Minkyu Kang @ 2013-09-24  8:42 UTC (permalink / raw)
  To: u-boot

Dear Lukasz,

On 29/08/13 06:01, Lukasz Majewski wrote:
> Hi Minkyu
> 
>> Dear Lukasz,
>>
>> On 13/08/13 06:15, Lukasz Majewski wrote:
>>> This commit brings removal of duplicated code for UART IP block
>>> embedded at Samsung SoCs.
>>> New include/asm/samsung-common directory has been created to store
>>> common code for existing and future Samsung targets.
>>>
>>> Moreover building of UART code now depends on more verbose
>>> CONFIG_S5P_SERIAL. Thereof all relevant boards configs have been
>>> adjusted.
>>>
>>> Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
>>>
>>> ---
>>> Changes for v3:
>>> - Comply with SPDX license format
>>>
>>> Changes for v2:
>>> - Remove S3C64XX define from the code
>>> ---
>>>  arch/arm/include/asm/arch-exynos/uart.h    |   44
>>> ------------------- arch/arm/include/asm/arch-s5pc1xx/uart.h   |
>>> 44 ------------------- arch/arm/include/asm/samsung-common/uart.h
>>> |   64 ++++++++++++++++++++++++++++
>>> drivers/serial/Makefile                    |    2 +-
>>> drivers/serial/serial_s5p.c                |   13 +-----
>>> include/configs/exynos5250-dt.h            |    1 +
>>> include/configs/origen.h                   |    1 +
>>> include/configs/s5p_goni.h                 |    1 +
>>> include/configs/s5pc210_universal.h        |    1 +
>>> include/configs/smdkc100.h                 |    1 +
>>> include/configs/smdkv310.h                 |    1 +
>>> include/configs/trats.h                    |    1 + 12 files
>>> changed, 74 insertions(+), 100 deletions(-) delete mode 100644
>>> arch/arm/include/asm/arch-exynos/uart.h delete mode 100644
>>> arch/arm/include/asm/arch-s5pc1xx/uart.h create mode 100644
>>> arch/arm/include/asm/samsung-common/uart.h
>>>
>>> diff --git a/arch/arm/include/asm/arch-exynos/uart.h
>>> b/arch/arm/include/asm/arch-exynos/uart.h deleted file mode 100644
>>> index 33d6ba3..0000000
>>> --- a/arch/arm/include/asm/arch-exynos/uart.h
>>> +++ /dev/null
>>> @@ -1,44 +0,0 @@
>>> -/*
>>> - * (C) Copyright 2009 Samsung Electronics
>>> - * Minkyu Kang <mk7.kang@samsung.com>
>>> - * Heungjun Kim <riverful.kim@samsung.com>
>>> - *
>>> - * SPDX-License-Identifier:	GPL-2.0+
>>> - */
>>> -
>>> -#ifndef __ASM_ARCH_UART_H_
>>> -#define __ASM_ARCH_UART_H_
>>> -
>>> -#ifndef __ASSEMBLY__
>>> -/* baudrate rest value */
>>> -union br_rest {
>>> -	unsigned short	slot;		/* udivslot */
>>> -	unsigned char	value;		/* ufracval */
>>> -};
>>> -
>>> -struct s5p_uart {
>>> -	unsigned int	ulcon;
>>> -	unsigned int	ucon;
>>> -	unsigned int	ufcon;
>>> -	unsigned int	umcon;
>>> -	unsigned int	utrstat;
>>> -	unsigned int	uerstat;
>>> -	unsigned int	ufstat;
>>> -	unsigned int	umstat;
>>> -	unsigned char	utxh;
>>> -	unsigned char	res1[3];
>>> -	unsigned char	urxh;
>>> -	unsigned char	res2[3];
>>> -	unsigned int	ubrdiv;
>>> -	union br_rest	rest;
>>> -	unsigned char	res3[0xffd0];
>>> -};
>>> -
>>> -static inline int s5p_uart_divslot(void)
>>> -{
>>> -	return 0;
>>> -}
>>> -
>>> -#endif	/* __ASSEMBLY__ */
>>> -
>>> -#endif
>>> diff --git a/arch/arm/include/asm/arch-s5pc1xx/uart.h
>>> b/arch/arm/include/asm/arch-s5pc1xx/uart.h deleted file mode 100644
>>> index 26db098..0000000
>>> --- a/arch/arm/include/asm/arch-s5pc1xx/uart.h
>>> +++ /dev/null
>>> @@ -1,44 +0,0 @@
>>> -/*
>>> - * (C) Copyright 2009 Samsung Electronics
>>> - * Minkyu Kang <mk7.kang@samsung.com>
>>> - * Heungjun Kim <riverful.kim@samsung.com>
>>> - *
>>> - * SPDX-License-Identifier:	GPL-2.0+
>>> - */
>>> -
>>> -#ifndef __ASM_ARCH_UART_H_
>>> -#define __ASM_ARCH_UART_H_
>>> -
>>> -#ifndef __ASSEMBLY__
>>> -/* baudrate rest value */
>>> -union br_rest {
>>> -	unsigned short	slot;		/* udivslot */
>>> -	unsigned char	value;		/* ufracval */
>>> -};
>>> -
>>> -struct s5p_uart {
>>> -	unsigned int	ulcon;
>>> -	unsigned int	ucon;
>>> -	unsigned int	ufcon;
>>> -	unsigned int	umcon;
>>> -	unsigned int	utrstat;
>>> -	unsigned int	uerstat;
>>> -	unsigned int	ufstat;
>>> -	unsigned int	umstat;
>>> -	unsigned char	utxh;
>>> -	unsigned char	res1[3];
>>> -	unsigned char	urxh;
>>> -	unsigned char	res2[3];
>>> -	unsigned int	ubrdiv;
>>> -	union br_rest	rest;
>>> -	unsigned char	res3[0x3d0];
>>> -};
>>> -
>>> -static inline int s5p_uart_divslot(void)
>>> -{
>>> -	return 1;
>>> -}
>>> -
>>> -#endif	/* __ASSEMBLY__ */
>>> -
>>> -#endif
>>> diff --git a/arch/arm/include/asm/samsung-common/uart.h
>>> b/arch/arm/include/asm/samsung-common/uart.h new file mode 100644
>>> index 0000000..ce92399
>>> --- /dev/null
>>> +++ b/arch/arm/include/asm/samsung-common/uart.h
>>> @@ -0,0 +1,64 @@
>>> +/*
>>> + * (C) Copyright 2009 Samsung Electronics
>>> + * Minkyu Kang <mk7.kang@samsung.com>
>>> + * Heungjun Kim <riverful.kim@samsung.com>
>>> + *
>>> + * SPDX-License-Identifier:	GPL-2.0+
>>> + */
>>> +
>>> +#ifndef __ASM_ARCH_UART_H_
>>> +#define __ASM_ARCH_UART_H_
>>> +
>>> +#ifndef __ASSEMBLY__
>>> +/* baudrate rest value */
>>> +union br_rest {
>>> +	unsigned short	slot;		/* udivslot */
>>> +	unsigned char	value;		/* ufracval */
>>> +};
>>> +
>>> +struct s5p_uart {
>>> +	unsigned int	ulcon;
>>> +	unsigned int	ucon;
>>> +	unsigned int	ufcon;
>>> +	unsigned int	umcon;
>>> +	unsigned int	utrstat;
>>> +	unsigned int	uerstat;
>>> +	unsigned int	ufstat;
>>> +	unsigned int	umstat;
>>> +	unsigned char	utxh;
>>> +	unsigned char	res1[3];
>>> +	unsigned char	urxh;
>>> +	unsigned char	res2[3];
>>> +	unsigned int	ubrdiv;
>>> +	union br_rest	rest;
>>> +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[1]
> 
>>
>> OK. I understood your patch's concept and patch looks good.
>> But, we have not been allowed ifdef at our SoCs.
>> So, I can't accept your patch easily.
> 
> The problem is that several Samsung SoCs reuse the same IP blocks. 
> 
> For example S3C6410 (which I want to add to u-boot), S5PC100, S5PC110,
> Exynos4 and Exynos5 are using the same timer, pwm, sromc, uart, udc,
> sdhci, and many others IP blocks.
> 
> As I've proposed in this patch series - several IP blocks *.c files
> shall go into samsung-common directory at arch/arm/cpu/samsung-common.
> This arm soc version independent code can be reused at s3c6410
> (arm1176) CPU.
> 
> Another issue - headers. The register map for relevant IP blocks is the
> same at s3c6410 and exynos5250. The only difference is the offset at
> the end of the structure.
> 
>>
>> How you think?
> 
> We can remove [1] if we define the struct s5p_uart without the
> "unsigned char res3[xxx];"in the end.

It's OK.
but, how can you remove other ifdefs?

> 
> It is correct, since we are using the "IP block offset defines" anyway
> to index correct IP block instance (like uart0/1/2...).
> 
>> Do we really need to combine headers?
>> I agree that they are almost duplicate codes.
>> But I thinks it's not a redundant.
>>
> 
> Another issue is the artificial distinction between s5pc1xx and exynos
> families of the processors.
> 
> Both are armv7, both are cortex (A8 and A9).I think that
> arch/arm/cpu/armv7/s5pc1xx code shall be moved to
> arch/arm/cpu/armv7/exynos

hm.. then, some files (cpu, clock, gpio,,, ) will be complicated.

> 
> Also arch/arm/include/asm/arch-{s5pc1xx|exynos} code can be put to
> samsung-common directory (as also proposed in those patch series).
> 
> Frankly, we shall mimic the tegra or imx tree. As fair as I've noticed
> at those SoCs the common code has been put to various *-common
> directories.
> 
> I've added other Samsung boards maintainers to Cc.
> 
>>> +	unsigned char	res3[0x3d0];
>>> +#else /* Exynos 4 and 5 */
>>> +	unsigned char	res3[0xffd0];
>>> +#endif
>>> +};
>>> +
>>> +
>>> +static inline int s5p_uart_divslot(void)
>>> +{
>>> +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
>>> +	return 1;
>>> +#else /* Exynos 4 and 5 */
>>> +	return 0;
>>> +#endif
>>> +}
>>> +
>>> +#define RX_FIFO_COUNT_MASK      0xff
>>> +#define RX_FIFO_FULL_MASK       (1 << 8)
>>> +#define TX_FIFO_FULL_MASK       (1 << 24)
>>> +
>>> +/* Information about a serial port */
>>> +struct fdt_serial {
>>> +	u32 base_addr;  /* address of registers in physical memory
>>> */
>>> +	u8 port_id;     /* uart port number */
>>> +	u8 enabled;     /* 1 if enabled, 0 if disabled */
>>> +};
>>> +
>>> +#endif	/* __ASSEMBLY__ */
>>> +
>>> +#endif
>>> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
>>> index 697f2bb..e3ca49a 100644
>>> --- a/drivers/serial/Makefile
>>> +++ b/drivers/serial/Makefile
>>> @@ -19,7 +19,7 @@ COBJS-$(CONFIG_LPC32XX_HSUART) += lpc32xx_hsuart.o
>>>  COBJS-$(CONFIG_MCFUART) += mcfuart.o
>>>  COBJS-$(CONFIG_OPENCORES_YANU) += opencores_yanu.o
>>>  COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
>>> -COBJS-$(CONFIG_S5P) += serial_s5p.o
>>> +COBJS-$(CONFIG_S5P_SERIAL) += serial_s5p.o
>>>  COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial_ns16550.o
>>>  COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
>>>  COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
>>> diff --git a/drivers/serial/serial_s5p.c
>>> b/drivers/serial/serial_s5p.c index f98b422..be08925 100644
>>> --- a/drivers/serial/serial_s5p.c
>>> +++ b/drivers/serial/serial_s5p.c
>>> @@ -12,22 +12,13 @@
>>>  #include <fdtdec.h>
>>>  #include <linux/compiler.h>
>>>  #include <asm/io.h>
>>> -#include <asm/arch/uart.h>
>>> +#include <asm/samsung-common/uart.h>
>>>  #include <asm/arch/clk.h>
>>>  #include <serial.h>
>>>  
>>>  DECLARE_GLOBAL_DATA_PTR;
>>>  
>>> -#define RX_FIFO_COUNT_MASK	0xff
>>> -#define RX_FIFO_FULL_MASK	(1 << 8)
>>> -#define TX_FIFO_FULL_MASK	(1 << 24)
>>> -
>>> -/* Information about a serial port */
>>> -struct fdt_serial {
>>> -	u32 base_addr;  /* address of registers in physical memory
>>> */
>>> -	u8 port_id;     /* uart port number */
>>> -	u8 enabled;     /* 1 if enabled, 0 if disabled */
>>> -} config __attribute__ ((section(".data")));
>>> +struct fdt_serial config __attribute__ ((section(".data")));
>>>  
>>>  static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
>>>  {
>>> diff --git a/include/configs/exynos5250-dt.h
>>> b/include/configs/exynos5250-dt.h index 8f8f85f..a759d07 100644
>>> --- a/include/configs/exynos5250-dt.h
>>> +++ b/include/configs/exynos5250-dt.h
>>> @@ -69,6 +69,7 @@
>>>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (4
>>> << 20)) 
>>>  /* select serial console configuration */
>>> +#define CONFIG_S5P_SERIAL
>>>  #define CONFIG_BAUDRATE			115200
>>>  #define EXYNOS5_DEFAULT_UART_OFFSET	0x010000
>>>  #define CONFIG_SILENT_CONSOLE
>>> diff --git a/include/configs/origen.h b/include/configs/origen.h
>>> index da13574..a59419d 100644
>>> --- a/include/configs/origen.h
>>> +++ b/include/configs/origen.h
>>> @@ -48,6 +48,7 @@
>>>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1
>>> << 20)) 
>>>  /* select serial console configuration */
>>> +#define CONFIG_S5P_SERIAL
>>>  #define CONFIG_SERIAL2			1	/* use
>>> SERIAL 2 */ #define CONFIG_BAUDRATE			115200
>>>  #define EXYNOS4_DEFAULT_UART_OFFSET	0x020000
>>> diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
>>> index d0fafd7..812b7f3 100644
>>> --- a/include/configs/s5p_goni.h
>>> +++ b/include/configs/s5p_goni.h
>>> @@ -42,6 +42,7 @@
>>>  /*
>>>   * select serial console configuration
>>>   */
>>> +#define CONFIG_S5P_SERIAL
>>>  #define CONFIG_SERIAL2			1	/* use
>>> SERIAL2 */ #define CONFIG_BAUDRATE			115200
>>>  
>>> diff --git a/include/configs/s5pc210_universal.h
>>> b/include/configs/s5pc210_universal.h index 97a4008..2270449 100644
>>> --- a/include/configs/s5pc210_universal.h
>>> +++ b/include/configs/s5pc210_universal.h
>>> @@ -48,6 +48,7 @@
>>>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1
>>> << 20)) 
>>>  /* select serial console configuration */
>>> +#define CONFIG_S5P_SERIAL
>>>  #define CONFIG_SERIAL2		1	/* use SERIAL 2 */
>>>  #define CONFIG_BAUDRATE		115200
>>>  
>>> diff --git a/include/configs/smdkc100.h b/include/configs/smdkc100.h
>>> index a572e62..4631dac 100644
>>> --- a/include/configs/smdkc100.h
>>> +++ b/include/configs/smdkc100.h
>>> @@ -47,6 +47,7 @@
>>>  /*
>>>   * select serial console configuration
>>>   */
>>> +#define CONFIG_S5P_SERIAL
>>>  #define CONFIG_SERIAL0			1	/* use
>>> SERIAL 0 on SMDKC100 */ 
>>>  /* PWM */
>>> diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h
>>> index 0496661..9e10bf1 100644
>>> --- a/include/configs/smdkv310.h
>>> +++ b/include/configs/smdkv310.h
>>> @@ -48,6 +48,7 @@
>>>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + (1
>>> << 20)) 
>>>  /* select serial console configuration */
>>> +#define CONFIG_S5P_SERIAL
>>>  #define CONFIG_SERIAL1			1	/* use
>>> SERIAL 1 */ #define CONFIG_BAUDRATE			115200
>>>  #define EXYNOS4_DEFAULT_UART_OFFSET	0x010000
>>> diff --git a/include/configs/trats.h b/include/configs/trats.h
>>> index 9b6aac9..6b301c8 100644
>>> --- a/include/configs/trats.h
>>> +++ b/include/configs/trats.h
>>> @@ -53,6 +53,7 @@
>>>  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE +
>>> (16 << 20)) 
>>>  /* select serial console configuration */
>>> +#define CONFIG_S5P_SERIAL
>>>  #define CONFIG_SERIAL2			/* use SERIAL 2 */
>>>  #define CONFIG_BAUDRATE			115200
>>>  
>>>
>>
>> Thanks,
>> Minkyu Kang.
> 
> Regards,
> 
> Lukasz Majewski
> 

Thanks,
Minkyu Kang.

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

* [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code
  2013-09-24  8:42         ` Minkyu Kang
@ 2013-09-24 10:11           ` Lukasz Majewski
  0 siblings, 0 replies; 14+ messages in thread
From: Lukasz Majewski @ 2013-09-24 10:11 UTC (permalink / raw)
  To: u-boot

Hi Minkyu,

> Dear Lukasz,
> 
> On 29/08/13 06:01, Lukasz Majewski wrote:
> > Hi Minkyu
> >
> >> Dear Lukasz,
> >>
> >> On 13/08/13 06:15, Lukasz Majewski wrote:
> >>> This commit brings removal of duplicated code for UART IP block
> >>> embedded at Samsung SoCs.
> >>> New include/asm/samsung-common directory has been created to store
> >>> common code for existing and future Samsung targets.
> >>>
> >>> Moreover building of UART code now depends on more verbose
> >>> CONFIG_S5P_SERIAL. Thereof all relevant boards configs have been
> >>> adjusted.
> >>>
> >>> Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
> >>>
> >>> ---
> >>> Changes for v3:
> >>> - Comply with SPDX license format
> >>>
> >>> Changes for v2:
> >>> - Remove S3C64XX define from the code
> >>> ---
> >>>  arch/arm/include/asm/arch-exynos/uart.h    |   44
> >>> ------------------- arch/arm/include/asm/arch-s5pc1xx/uart.h   |
> >>> 44 ------------------- arch/arm/include/asm/samsung-common/uart.h
> >>> |   64 ++++++++++++++++++++++++++++
> >>> drivers/serial/Makefile                    |    2 +-
> >>> drivers/serial/serial_s5p.c                |   13 +-----
> >>> include/configs/exynos5250-dt.h            |    1 +
> >>> include/configs/origen.h                   |    1 +
> >>> include/configs/s5p_goni.h                 |    1 +
> >>> include/configs/s5pc210_universal.h        |    1 +
> >>> include/configs/smdkc100.h                 |    1 +
> >>> include/configs/smdkv310.h                 |    1 +
> >>> include/configs/trats.h                    |    1 + 12 files
> >>> changed, 74 insertions(+), 100 deletions(-) delete mode 100644
> >>> arch/arm/include/asm/arch-exynos/uart.h delete mode 100644
> >>> arch/arm/include/asm/arch-s5pc1xx/uart.h create mode 100644
> >>> arch/arm/include/asm/samsung-common/uart.h
> >>>
> >>> diff --git a/arch/arm/include/asm/arch-exynos/uart.h
> >>> b/arch/arm/include/asm/arch-exynos/uart.h deleted file mode 100644
> >>> index 33d6ba3..0000000
> >>> --- a/arch/arm/include/asm/arch-exynos/uart.h
> >>> +++ /dev/null
> >>> @@ -1,44 +0,0 @@
> >>> -/*
> >>> - * (C) Copyright 2009 Samsung Electronics
> >>> - * Minkyu Kang <mk7.kang@samsung.com>
> >>> - * Heungjun Kim <riverful.kim@samsung.com>
> >>> - *
> >>> - * SPDX-License-Identifier:        GPL-2.0+
> >>> - */
> >>> -
> >>> -#ifndef __ASM_ARCH_UART_H_
> >>> -#define __ASM_ARCH_UART_H_
> >>> -
> >>> -#ifndef __ASSEMBLY__
> >>> -/* baudrate rest value */
> >>> -union br_rest {
> >>> -   unsigned short  slot;           /* udivslot */
> >>> -   unsigned char   value;          /* ufracval */
> >>> -};
> >>> -
> >>> -struct s5p_uart {
> >>> -   unsigned int    ulcon;
> >>> -   unsigned int    ucon;
> >>> -   unsigned int    ufcon;
> >>> -   unsigned int    umcon;
> >>> -   unsigned int    utrstat;
> >>> -   unsigned int    uerstat;
> >>> -   unsigned int    ufstat;
> >>> -   unsigned int    umstat;
> >>> -   unsigned char   utxh;
> >>> -   unsigned char   res1[3];
> >>> -   unsigned char   urxh;
> >>> -   unsigned char   res2[3];
> >>> -   unsigned int    ubrdiv;
> >>> -   union br_rest   rest;
> >>> -   unsigned char   res3[0xffd0];
> >>> -};
> >>> -
> >>> -static inline int s5p_uart_divslot(void)
> >>> -{
> >>> -   return 0;
> >>> -}
> >>> -
> >>> -#endif     /* __ASSEMBLY__ */
> >>> -
> >>> -#endif
> >>> diff --git a/arch/arm/include/asm/arch-s5pc1xx/uart.h
> >>> b/arch/arm/include/asm/arch-s5pc1xx/uart.h deleted file mode
> >>> 100644 index 26db098..0000000
> >>> --- a/arch/arm/include/asm/arch-s5pc1xx/uart.h
> >>> +++ /dev/null
> >>> @@ -1,44 +0,0 @@
> >>> -/*
> >>> - * (C) Copyright 2009 Samsung Electronics
> >>> - * Minkyu Kang <mk7.kang@samsung.com>
> >>> - * Heungjun Kim <riverful.kim@samsung.com>
> >>> - *
> >>> - * SPDX-License-Identifier:        GPL-2.0+
> >>> - */
> >>> -
> >>> -#ifndef __ASM_ARCH_UART_H_
> >>> -#define __ASM_ARCH_UART_H_
> >>> -
> >>> -#ifndef __ASSEMBLY__
> >>> -/* baudrate rest value */
> >>> -union br_rest {
> >>> -   unsigned short  slot;           /* udivslot */
> >>> -   unsigned char   value;          /* ufracval */
> >>> -};
> >>> -
> >>> -struct s5p_uart {
> >>> -   unsigned int    ulcon;
> >>> -   unsigned int    ucon;
> >>> -   unsigned int    ufcon;
> >>> -   unsigned int    umcon;
> >>> -   unsigned int    utrstat;
> >>> -   unsigned int    uerstat;
> >>> -   unsigned int    ufstat;
> >>> -   unsigned int    umstat;
> >>> -   unsigned char   utxh;
> >>> -   unsigned char   res1[3];
> >>> -   unsigned char   urxh;
> >>> -   unsigned char   res2[3];
> >>> -   unsigned int    ubrdiv;
> >>> -   union br_rest   rest;
> >>> -   unsigned char   res3[0x3d0];
> >>> -};
> >>> -
> >>> -static inline int s5p_uart_divslot(void)
> >>> -{
> >>> -   return 1;
> >>> -}
> >>> -
> >>> -#endif     /* __ASSEMBLY__ */
> >>> -
> >>> -#endif
> >>> diff --git a/arch/arm/include/asm/samsung-common/uart.h
> >>> b/arch/arm/include/asm/samsung-common/uart.h new file mode 100644
> >>> index 0000000..ce92399
> >>> --- /dev/null
> >>> +++ b/arch/arm/include/asm/samsung-common/uart.h
> >>> @@ -0,0 +1,64 @@
> >>> +/*
> >>> + * (C) Copyright 2009 Samsung Electronics
> >>> + * Minkyu Kang <mk7.kang@samsung.com>
> >>> + * Heungjun Kim <riverful.kim@samsung.com>
> >>> + *
> >>> + * SPDX-License-Identifier:        GPL-2.0+
> >>> + */
> >>> +
> >>> +#ifndef __ASM_ARCH_UART_H_
> >>> +#define __ASM_ARCH_UART_H_
> >>> +
> >>> +#ifndef __ASSEMBLY__
> >>> +/* baudrate rest value */
> >>> +union br_rest {
> >>> +   unsigned short  slot;           /* udivslot */
> >>> +   unsigned char   value;          /* ufracval */
> >>> +};
> >>> +
> >>> +struct s5p_uart {
> >>> +   unsigned int    ulcon;
> >>> +   unsigned int    ucon;
> >>> +   unsigned int    ufcon;
> >>> +   unsigned int    umcon;
> >>> +   unsigned int    utrstat;
> >>> +   unsigned int    uerstat;
> >>> +   unsigned int    ufstat;
> >>> +   unsigned int    umstat;
> >>> +   unsigned char   utxh;
> >>> +   unsigned char   res1[3];
> >>> +   unsigned char   urxh;
> >>> +   unsigned char   res2[3];
> >>> +   unsigned int    ubrdiv;
> >>> +   union br_rest   rest;
> >>> +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
> >      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^[1]
> >
> >>
> >> OK. I understood your patch's concept and patch looks good.
> >> But, we have not been allowed ifdef at our SoCs.
> >> So, I can't accept your patch easily.
> >
> > The problem is that several Samsung SoCs reuse the same IP blocks.
> >
> > For example S3C6410 (which I want to add to u-boot), S5PC100,
> > S5PC110, Exynos4 and Exynos5 are using the same timer, pwm, sromc,
> > uart, udc, sdhci, and many others IP blocks.
> >
> > As I've proposed in this patch series - several IP blocks *.c files
> > shall go into samsung-common directory at
> > arch/arm/cpu/samsung-common. This arm soc version independent code
> > can be reused at s3c6410 (arm1176) CPU.
> >
> > Another issue - headers. The register map for relevant IP blocks is
> > the same at s3c6410 and exynos5250. The only difference is the
> > offset at the end of the structure.
> >
> >>
> >> How you think?
> >
> > We can remove [1] if we define the struct s5p_uart without the
> > "unsigned char res3[xxx];"in the end.
> 
> It's OK.
> but, how can you remove other ifdefs?

Other #ifdef here is the s5p_uart_divslot function:

+static inline int s5p_uart_divslot(void)
+{
+#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
+	return 1;
+#else /* Exynos 4 and 5 */
+	return 0;
+#endif
+}

It looks like a good candidate for clean up.

> 
> >
> > It is correct, since we are using the "IP block offset defines"
> > anyway to index correct IP block instance (like uart0/1/2...).
> >
> >> Do we really need to combine headers?
> >> I agree that they are almost duplicate codes.
> >> But I thinks it's not a redundant.
> >>
> >
> > Another issue is the artificial distinction between s5pc1xx and
> > exynos families of the processors.
> >
> > Both are armv7, both are cortex (A8 and A9).I think that
> > arch/arm/cpu/armv7/s5pc1xx code shall be moved to
> > arch/arm/cpu/armv7/exynos
> 
> hm.. then, some files (cpu, clock, gpio,,, ) will be complicated.

The timer handling code is directly reused at s3c6410. Also please look
into PATCH 2/3 and PATCH 3/3 in this series. For example, PATCH 3/3
unifies cpu info.

Now at arch/arm/cpu/armv7/s5pc1xx directory one finds: cache.S, clock.c
and reset.S

Moreover, if we plan to describe Samsung boards in a device tree - in
a similar way to e.g. Tegra, common code base would be more than
welcome. 



> 
> >
> > Also arch/arm/include/asm/arch-{s5pc1xx|exynos} code can be put to
> > samsung-common directory (as also proposed in those patch series).
> >
> > Frankly, we shall mimic the tegra or imx tree. As fair as I've
> > noticed at those SoCs the common code has been put to various
> > *-common directories.
> >
> > I've added other Samsung boards maintainers to Cc.
> >
> >>> +   unsigned char   res3[0x3d0];
> >>> +#else /* Exynos 4 and 5 */
> >>> +   unsigned char   res3[0xffd0];
> >>> +#endif
> >>> +};
> >>> +
> >>> +
> >>> +static inline int s5p_uart_divslot(void)
> >>> +{
> >>> +#if defined(CONFIG_S5PC100) || defined(CONFIG_S5PC110)
> >>> +   return 1;
> >>> +#else /* Exynos 4 and 5 */
> >>> +   return 0;
> >>> +#endif
> >>> +}
> >>> +
> >>> +#define RX_FIFO_COUNT_MASK      0xff
> >>> +#define RX_FIFO_FULL_MASK       (1 << 8)
> >>> +#define TX_FIFO_FULL_MASK       (1 << 24)
> >>> +
> >>> +/* Information about a serial port */
> >>> +struct fdt_serial {
> >>> +   u32 base_addr;  /* address of registers in physical memory
> >>> */
> >>> +   u8 port_id;     /* uart port number */
> >>> +   u8 enabled;     /* 1 if enabled, 0 if disabled */
> >>> +};
> >>> +
> >>> +#endif     /* __ASSEMBLY__ */
> >>> +
> >>> +#endif
> >>> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> >>> index 697f2bb..e3ca49a 100644
> >>> --- a/drivers/serial/Makefile
> >>> +++ b/drivers/serial/Makefile
> >>> @@ -19,7 +19,7 @@ COBJS-$(CONFIG_LPC32XX_HSUART) +=
> >>> lpc32xx_hsuart.o COBJS-$(CONFIG_MCFUART) += mcfuart.o
> >>>  COBJS-$(CONFIG_OPENCORES_YANU) += opencores_yanu.o
> >>>  COBJS-$(CONFIG_SYS_NS16550) += ns16550.o
> >>> -COBJS-$(CONFIG_S5P) += serial_s5p.o
> >>> +COBJS-$(CONFIG_S5P_SERIAL) += serial_s5p.o
> >>>  COBJS-$(CONFIG_SYS_NS16550_SERIAL) += serial_ns16550.o
> >>>  COBJS-$(CONFIG_IMX_SERIAL) += serial_imx.o
> >>>  COBJS-$(CONFIG_IXP_SERIAL) += serial_ixp.o
> >>> diff --git a/drivers/serial/serial_s5p.c
> >>> b/drivers/serial/serial_s5p.c index f98b422..be08925 100644
> >>> --- a/drivers/serial/serial_s5p.c
> >>> +++ b/drivers/serial/serial_s5p.c
> >>> @@ -12,22 +12,13 @@
> >>>  #include <fdtdec.h>
> >>>  #include <linux/compiler.h>
> >>>  #include <asm/io.h>
> >>> -#include <asm/arch/uart.h>
> >>> +#include <asm/samsung-common/uart.h>
> >>>  #include <asm/arch/clk.h>
> >>>  #include <serial.h>
> >>>
> >>>  DECLARE_GLOBAL_DATA_PTR;
> >>>
> >>> -#define RX_FIFO_COUNT_MASK 0xff
> >>> -#define RX_FIFO_FULL_MASK  (1 << 8)
> >>> -#define TX_FIFO_FULL_MASK  (1 << 24)
> >>> -
> >>> -/* Information about a serial port */
> >>> -struct fdt_serial {
> >>> -   u32 base_addr;  /* address of registers in physical memory
> >>> */
> >>> -   u8 port_id;     /* uart port number */
> >>> -   u8 enabled;     /* 1 if enabled, 0 if disabled */
> >>> -} config __attribute__ ((section(".data")));
> >>> +struct fdt_serial config __attribute__ ((section(".data")));
> >>>
> >>>  static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
> >>>  {
> >>> diff --git a/include/configs/exynos5250-dt.h
> >>> b/include/configs/exynos5250-dt.h index 8f8f85f..a759d07 100644
> >>> --- a/include/configs/exynos5250-dt.h
> >>> +++ b/include/configs/exynos5250-dt.h
> >>> @@ -69,6 +69,7 @@
> >>>  #define CONFIG_SYS_MALLOC_LEN              (CONFIG_ENV_SIZE + (4
> >>> << 20))
> >>>  /* select serial console configuration */
> >>> +#define CONFIG_S5P_SERIAL
> >>>  #define CONFIG_BAUDRATE                    115200
> >>>  #define EXYNOS5_DEFAULT_UART_OFFSET        0x010000
> >>>  #define CONFIG_SILENT_CONSOLE
> >>> diff --git a/include/configs/origen.h b/include/configs/origen.h
> >>> index da13574..a59419d 100644
> >>> --- a/include/configs/origen.h
> >>> +++ b/include/configs/origen.h
> >>> @@ -48,6 +48,7 @@
> >>>  #define CONFIG_SYS_MALLOC_LEN              (CONFIG_ENV_SIZE + (1
> >>> << 20))
> >>>  /* select serial console configuration */
> >>> +#define CONFIG_S5P_SERIAL
> >>>  #define CONFIG_SERIAL2                     1       /* use
> >>> SERIAL 2 */ #define CONFIG_BAUDRATE                 115200
> >>>  #define EXYNOS4_DEFAULT_UART_OFFSET        0x020000
> >>> diff --git a/include/configs/s5p_goni.h
> >>> b/include/configs/s5p_goni.h index d0fafd7..812b7f3 100644
> >>> --- a/include/configs/s5p_goni.h
> >>> +++ b/include/configs/s5p_goni.h
> >>> @@ -42,6 +42,7 @@
> >>>  /*
> >>>   * select serial console configuration
> >>>   */
> >>> +#define CONFIG_S5P_SERIAL
> >>>  #define CONFIG_SERIAL2                     1       /* use
> >>> SERIAL2 */ #define CONFIG_BAUDRATE                  115200
> >>>
> >>> diff --git a/include/configs/s5pc210_universal.h
> >>> b/include/configs/s5pc210_universal.h index 97a4008..2270449
> >>> 100644 --- a/include/configs/s5pc210_universal.h
> >>> +++ b/include/configs/s5pc210_universal.h
> >>> @@ -48,6 +48,7 @@
> >>>  #define CONFIG_SYS_MALLOC_LEN              (CONFIG_ENV_SIZE + (1
> >>> << 20))
> >>>  /* select serial console configuration */
> >>> +#define CONFIG_S5P_SERIAL
> >>>  #define CONFIG_SERIAL2             1       /* use SERIAL 2 */
> >>>  #define CONFIG_BAUDRATE            115200
> >>>
> >>> diff --git a/include/configs/smdkc100.h
> >>> b/include/configs/smdkc100.h index a572e62..4631dac 100644
> >>> --- a/include/configs/smdkc100.h
> >>> +++ b/include/configs/smdkc100.h
> >>> @@ -47,6 +47,7 @@
> >>>  /*
> >>>   * select serial console configuration
> >>>   */
> >>> +#define CONFIG_S5P_SERIAL
> >>>  #define CONFIG_SERIAL0                     1       /* use
> >>> SERIAL 0 on SMDKC100 */
> >>>  /* PWM */
> >>> diff --git a/include/configs/smdkv310.h
> >>> b/include/configs/smdkv310.h index 0496661..9e10bf1 100644
> >>> --- a/include/configs/smdkv310.h
> >>> +++ b/include/configs/smdkv310.h
> >>> @@ -48,6 +48,7 @@
> >>>  #define CONFIG_SYS_MALLOC_LEN              (CONFIG_ENV_SIZE + (1
> >>> << 20))
> >>>  /* select serial console configuration */
> >>> +#define CONFIG_S5P_SERIAL
> >>>  #define CONFIG_SERIAL1                     1       /* use
> >>> SERIAL 1 */ #define CONFIG_BAUDRATE                 115200
> >>>  #define EXYNOS4_DEFAULT_UART_OFFSET        0x010000
> >>> diff --git a/include/configs/trats.h b/include/configs/trats.h
> >>> index 9b6aac9..6b301c8 100644
> >>> --- a/include/configs/trats.h
> >>> +++ b/include/configs/trats.h
> >>> @@ -53,6 +53,7 @@
> >>>  #define CONFIG_SYS_MALLOC_LEN              (CONFIG_ENV_SIZE +
> >>> (16 << 20))
> >>>  /* select serial console configuration */
> >>> +#define CONFIG_S5P_SERIAL
> >>>  #define CONFIG_SERIAL2                     /* use SERIAL 2 */
> >>>  #define CONFIG_BAUDRATE                    115200
> >>>
> >>>
> >>
> >> Thanks,
> >> Minkyu Kang.
> >
> > Regards,
> >
> > Lukasz Majewski
> >
> 
> Thanks,
> Minkyu Kang.



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

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

end of thread, other threads:[~2013-09-24 10:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-21 21:50 [U-Boot] [PATCH] arm:samsung:serial: Extract common Samsung UART code Lukasz Majewski
2013-07-25 21:43 ` [U-Boot] [PATCH v2] arm:samsung:serial Extract common " Lukasz Majewski
2013-08-12 21:15 ` [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code Lukasz Majewski
2013-08-12 21:15   ` [U-Boot] [PATCH v3 1/3] arm:samsung:serial Extract common UART code Lukasz Majewski
2013-08-16  7:16     ` Lukasz Majewski
2013-08-28 10:11     ` Minkyu Kang
2013-08-28 21:01       ` Lukasz Majewski
2013-09-12 19:43         ` Lukasz Majewski
2013-09-13  2:45         ` Chander Kashyap
2013-09-24  8:42         ` Minkyu Kang
2013-09-24 10:11           ` Lukasz Majewski
2013-08-12 21:15   ` [U-Boot] [PATCH v3 2/3] arm:samsung: Move common code from ./s5p-common to ./samsung-common/ Lukasz Majewski
2013-08-12 21:15   ` [U-Boot] [PATCH v3 3/3] arm:samsung:cpu_info: Rename s5p_* to samsung_* Lukasz Majewski
2013-08-22 10:55   ` [U-Boot] [PATCH v3 0/3] arm:exynos:cleanup: Extract common code Lukasz Majewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.