All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/4 V2] SMDK5250: FDT: Add device tree support for console
@ 2013-03-01 10:16 Rajeshwari Shinde
  2013-03-01 10:16 ` [U-Boot] [PATCH 1/4 V2] EXYNOS5: FDT: Add compatible strings for Serial Rajeshwari Shinde
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Rajeshwari Shinde @ 2013-03-01 10:16 UTC (permalink / raw)
  To: u-boot

Enabled fdt support for default console on SMDK5250.

Changes in V2:
	- Changed the compatible string to "samsung,exynos4210-uart"

Rajeshwari Shinde (4):
  EXYNOS5: FDT: Add compatible strings for Serial
  EXYNOS5: FDT: Add serial device node values
  S5P: Serial: Add fdt support to driver
  CONFIG: EXYNOS5: Enable silent console

 arch/arm/dts/exynos5250.dtsi              |   27 ++++++++++
 board/samsung/dts/exynos5250-smdk5250.dts |    1 +
 drivers/serial/serial_s5p.c               |   80 +++++++++++++++++++++++++++++
 include/configs/exynos5250-dt.h           |    2 +
 include/fdtdec.h                          |    1 +
 lib/fdtdec.c                              |    1 +
 6 files changed, 112 insertions(+), 0 deletions(-)

-- 
1.7.4.4

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

* [U-Boot] [PATCH 1/4 V2] EXYNOS5: FDT: Add compatible strings for Serial
  2013-03-01 10:16 [U-Boot] [PATCH 0/4 V2] SMDK5250: FDT: Add device tree support for console Rajeshwari Shinde
@ 2013-03-01 10:16 ` Rajeshwari Shinde
  2013-03-03  0:38   ` Simon Glass
  2013-03-01 10:16 ` [U-Boot] [PATCH 2/4 V2] EXYNOS5: FDT: Add serial device node values Rajeshwari Shinde
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Rajeshwari Shinde @ 2013-03-01 10:16 UTC (permalink / raw)
  To: u-boot

Add required compatible information for s5p serial driver

Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>
Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
---
Changes in V2:
	- Changed the compatible string to "samsung,exynos4210-uart"
 include/fdtdec.h |    1 +
 lib/fdtdec.c     |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 77f244f..cca9be1 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -81,6 +81,7 @@ enum fdt_compat_id {
 	COMPAT_SAMSUNG_EXYNOS_EHCI,	/* Exynos EHCI controller */
 	COMPAT_SAMSUNG_EXYNOS_USB_PHY,	/* Exynos phy controller for usb2.0 */
 	COMPAT_MAXIM_MAX77686_PMIC,	/* MAX77686 PMIC */
+	COMPAT_SAMSUNG_EXYNOS5_SERIAL,	/* Exynos5 UART */
 
 	COMPAT_COUNT,
 };
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 3ae348d..e8e4e8b 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -56,6 +56,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(SAMSUNG_EXYNOS_EHCI, "samsung,exynos-ehci"),
 	COMPAT(SAMSUNG_EXYNOS_USB_PHY, "samsung,exynos-usb-phy"),
 	COMPAT(MAXIM_MAX77686_PMIC, "maxim,max77686_pmic"),
+	COMPAT(SAMSUNG_EXYNOS5_SERIAL, "samsung,exynos4210-uart"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
-- 
1.7.4.4

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

* [U-Boot] [PATCH 2/4 V2] EXYNOS5: FDT: Add serial device node values
  2013-03-01 10:16 [U-Boot] [PATCH 0/4 V2] SMDK5250: FDT: Add device tree support for console Rajeshwari Shinde
  2013-03-01 10:16 ` [U-Boot] [PATCH 1/4 V2] EXYNOS5: FDT: Add compatible strings for Serial Rajeshwari Shinde
@ 2013-03-01 10:16 ` Rajeshwari Shinde
  2013-03-03  0:40   ` Simon Glass
  2013-03-01 10:16 ` [U-Boot] [PATCH 3/4 V2] S5P: Serial: Add fdt support to driver Rajeshwari Shinde
  2013-03-01 10:16 ` [U-Boot] [PATCH 4/4 V2] CONFIG: EXYNOS5: Enable silent console Rajeshwari Shinde
  3 siblings, 1 reply; 9+ messages in thread
From: Rajeshwari Shinde @ 2013-03-01 10:16 UTC (permalink / raw)
  To: u-boot

This patch adds the device node required for serial driver

Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>
Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
---
Changes in V2:
	- Changed the compatible string to "samsung,exynos4210-uart"
 arch/arm/dts/exynos5250.dtsi              |   27 +++++++++++++++++++++++++++
 board/samsung/dts/exynos5250-smdk5250.dts |    1 +
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/exynos5250.dtsi b/arch/arm/dts/exynos5250.dtsi
index ed8c8dd..52ce539 100644
--- a/arch/arm/dts/exynos5250.dtsi
+++ b/arch/arm/dts/exynos5250.dtsi
@@ -151,4 +151,31 @@
 		};
 	};
 
+	serial at 12C00000 {
+		compatible = "samsung,exynos4210-uart";
+		reg = <0x12C00000 0x100>;
+		interrupts = <0 51 0>;
+		id = <0>;
+	};
+
+	serial at 12C10000 {
+		compatible = "samsung,exynos4210-uart";
+		reg = <0x12C10000 0x100>;
+		interrupts = <0 52 0>;
+		id = <1>;
+	};
+
+	serial at 12C20000 {
+		compatible = "samsung,exynos4210-uart";
+		reg = <0x12C20000 0x100>;
+		interrupts = <0 53 0>;
+		id = <2>;
+	};
+
+	serial at 12C30000 {
+		compatible = "samsung,exynos4210-uart";
+		reg = <0x12C30000 0x100>;
+		interrupts = <0 54 0>;
+		id = <3>;
+	};
 };
diff --git a/board/samsung/dts/exynos5250-smdk5250.dts b/board/samsung/dts/exynos5250-smdk5250.dts
index cbfab6f..89db11b 100644
--- a/board/samsung/dts/exynos5250-smdk5250.dts
+++ b/board/samsung/dts/exynos5250-smdk5250.dts
@@ -30,6 +30,7 @@
 		spi2 = "/spi at 12d40000";
 		spi3 = "/spi at 131a0000";
 		spi4 = "/spi at 131b0000";
+		serial0 = "/serial at 12C30000";
 	};
 
 	sromc at 12250000 {
-- 
1.7.4.4

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

* [U-Boot] [PATCH 3/4 V2] S5P: Serial: Add fdt support to driver
  2013-03-01 10:16 [U-Boot] [PATCH 0/4 V2] SMDK5250: FDT: Add device tree support for console Rajeshwari Shinde
  2013-03-01 10:16 ` [U-Boot] [PATCH 1/4 V2] EXYNOS5: FDT: Add compatible strings for Serial Rajeshwari Shinde
  2013-03-01 10:16 ` [U-Boot] [PATCH 2/4 V2] EXYNOS5: FDT: Add serial device node values Rajeshwari Shinde
@ 2013-03-01 10:16 ` Rajeshwari Shinde
  2013-03-03  0:45   ` Simon Glass
  2013-03-03  0:46   ` Simon Glass
  2013-03-01 10:16 ` [U-Boot] [PATCH 4/4 V2] CONFIG: EXYNOS5: Enable silent console Rajeshwari Shinde
  3 siblings, 2 replies; 9+ messages in thread
From: Rajeshwari Shinde @ 2013-03-01 10:16 UTC (permalink / raw)
  To: u-boot

This patch adds FDT support to the serial s5p driver.
At present disabling the serial console (from the device tree) crashes
U-Boot. Add checks for this case, so that execution can continue without
a serial console.
It also enables the serial_s5p driver recognize the silent_console option.

Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>
Signed-off-by: Gabe Black <gabeblack@google.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes in V2:
	- None
 drivers/serial/serial_s5p.c |   80 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
index 3c41242..4502ffb 100644
--- a/drivers/serial/serial_s5p.c
+++ b/drivers/serial/serial_s5p.c
@@ -24,16 +24,30 @@
 #include <common.h>
 #include <linux/compiler.h>
 #include <asm/io.h>
+#include <fdtdec.h>
 #include <asm/arch/uart.h>
 #include <asm/arch/clk.h>
 #include <serial.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/* 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 = {
+	-1U
+};
+
 static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
 {
+#ifdef CONFIG_OF_CONTROL
+	return (struct s5p_uart *)(config.base_addr);
+#else
 	u32 offset = dev_index * sizeof(struct s5p_uart);
 	return (struct s5p_uart *)(samsung_get_base_uart() + offset);
+#endif
 }
 
 /*
@@ -69,6 +83,9 @@ void serial_setbrg_dev(const int dev_index)
 	u32 baudrate = gd->baudrate;
 	u32 val;
 
+	if (!config.enabled)
+		return;
+
 	val = uclk / baudrate;
 
 	writel(val / 16 - 1, &uart->ubrdiv);
@@ -87,6 +104,16 @@ int serial_init_dev(const int dev_index)
 {
 	struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
 
+#if defined(CONFIG_SILENT_CONSOLE) && \
+		defined(CONFIG_OF_CONTROL) && \
+		!defined(CONFIG_SPL_BUILD)
+	if (fdtdec_get_config_int(gd->fdt_blob, "silent_console", 0))
+		gd->flags |= GD_FLG_SILENT;
+#endif
+
+	if (!config.enabled)
+		return 0;
+
 	/* reset and enable FIFOs, set triggers to the maximum */
 	writel(0, &uart->ufcon);
 	writel(0, &uart->umcon);
@@ -129,6 +156,9 @@ int serial_getc_dev(const int dev_index)
 {
 	struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
 
+	if (!config.enabled)
+		return 0;
+
 	/* wait for character to arrive */
 	while (!(readl(&uart->utrstat) & 0x1)) {
 		if (serial_err_check(dev_index, 0))
@@ -145,6 +175,9 @@ void serial_putc_dev(const char c, const int dev_index)
 {
 	struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
 
+	if (!config.enabled)
+		return;
+
 	/* wait for room in the tx FIFO */
 	while (!(readl(&uart->utrstat) & 0x2)) {
 		if (serial_err_check(dev_index, 1))
@@ -165,6 +198,9 @@ int serial_tstc_dev(const int dev_index)
 {
 	struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
 
+	if (!config.enabled)
+		return 0;
+
 	return (int)(readl(&uart->utrstat) & 0x1);
 }
 
@@ -207,8 +243,51 @@ DECLARE_S5P_SERIAL_FUNCTIONS(3);
 struct serial_device s5p_serial3_device =
 	INIT_S5P_SERIAL_STRUCTURE(3, "s5pser3");
 
+#ifdef CONFIG_OF_CONTROL
+int fdtdec_decode_console(int *index, struct fdt_serial *uart)
+{
+	const void *blob = gd->fdt_blob;
+	int node;
+
+	node = fdtdec_next_alias(blob, "serial", COMPAT_SAMSUNG_EXYNOS5_SERIAL,
+		index);
+	if (node < 0)
+		return node;
+
+	uart->base_addr = fdtdec_get_addr(blob, node, "reg");
+	if (uart->base_addr == FDT_ADDR_T_NONE)
+		return -FDT_ERR_NOTFOUND;
+
+	uart->port_id = fdtdec_get_int(blob, node, "id", -1);
+	uart->enabled = fdtdec_get_is_enabled(blob, node);
+
+	return 0;
+}
+#endif
+
 __weak struct serial_device *default_serial_console(void)
 {
+#ifdef CONFIG_OF_CONTROL
+	int index = 0;
+	if (fdtdec_decode_console(&index, &config)) {
+		debug("Cannot decode default console node\n");
+		return NULL;
+	}
+
+	if (config.port_id == 0)
+		return &s5p_serial0_device;
+	else if (config.port_id == 1)
+		return &s5p_serial1_device;
+	else if (config.port_id == 2)
+		return &s5p_serial2_device;
+	else if (config.port_id == 3)
+		return &s5p_serial3_device;
+	else
+		debug("Unknown config.port_id: %d", config.port_id);
+
+	return NULL;
+#else
+	config.enabled = 1;
 #if defined(CONFIG_SERIAL0)
 	return &s5p_serial0_device;
 #elif defined(CONFIG_SERIAL1)
@@ -220,6 +299,7 @@ __weak struct serial_device *default_serial_console(void)
 #else
 #error "CONFIG_SERIAL? missing."
 #endif
+#endif
 }
 
 void s5p_serial_initialize(void)
-- 
1.7.4.4

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

* [U-Boot] [PATCH 4/4 V2] CONFIG: EXYNOS5: Enable silent console
  2013-03-01 10:16 [U-Boot] [PATCH 0/4 V2] SMDK5250: FDT: Add device tree support for console Rajeshwari Shinde
                   ` (2 preceding siblings ...)
  2013-03-01 10:16 ` [U-Boot] [PATCH 3/4 V2] S5P: Serial: Add fdt support to driver Rajeshwari Shinde
@ 2013-03-01 10:16 ` Rajeshwari Shinde
  3 siblings, 0 replies; 9+ messages in thread
From: Rajeshwari Shinde @ 2013-03-01 10:16 UTC (permalink / raw)
  To: u-boot

This patch enables CONFIG_SILENT_CONSOLE for EXYNOS5.

Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
Changes in V2:
	- None
 include/configs/exynos5250-dt.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index cabd2f2..3bf7d1b 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -85,6 +85,8 @@
 		"stdout=serial,lcd\0" \
 		"stderr=serial,lcd\0"
 
+#define CONFIG_SILENT_CONSOLE
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	EXYNOS_DEVICE_SETTINGS
 
-- 
1.7.4.4

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

* [U-Boot] [PATCH 1/4 V2] EXYNOS5: FDT: Add compatible strings for Serial
  2013-03-01 10:16 ` [U-Boot] [PATCH 1/4 V2] EXYNOS5: FDT: Add compatible strings for Serial Rajeshwari Shinde
@ 2013-03-03  0:38   ` Simon Glass
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2013-03-03  0:38 UTC (permalink / raw)
  To: u-boot

On Fri, Mar 1, 2013 at 2:16 AM, Rajeshwari Shinde
<rajeshwari.s@samsung.com> wrote:
> Add required compatible information for s5p serial driver
>
> Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>
> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>

Acked-by: Simon Glass <sjg@chromium.org>

> ---
> Changes in V2:
>         - Changed the compatible string to "samsung,exynos4210-uart"
>  include/fdtdec.h |    1 +
>  lib/fdtdec.c     |    1 +
>  2 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/include/fdtdec.h b/include/fdtdec.h
> index 77f244f..cca9be1 100644
> --- a/include/fdtdec.h
> +++ b/include/fdtdec.h
> @@ -81,6 +81,7 @@ enum fdt_compat_id {
>         COMPAT_SAMSUNG_EXYNOS_EHCI,     /* Exynos EHCI controller */
>         COMPAT_SAMSUNG_EXYNOS_USB_PHY,  /* Exynos phy controller for usb2.0 */
>         COMPAT_MAXIM_MAX77686_PMIC,     /* MAX77686 PMIC */
> +       COMPAT_SAMSUNG_EXYNOS5_SERIAL,  /* Exynos5 UART */
>
>         COMPAT_COUNT,
>  };
> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> index 3ae348d..e8e4e8b 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -56,6 +56,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
>         COMPAT(SAMSUNG_EXYNOS_EHCI, "samsung,exynos-ehci"),
>         COMPAT(SAMSUNG_EXYNOS_USB_PHY, "samsung,exynos-usb-phy"),
>         COMPAT(MAXIM_MAX77686_PMIC, "maxim,max77686_pmic"),
> +       COMPAT(SAMSUNG_EXYNOS5_SERIAL, "samsung,exynos4210-uart"),
>  };
>
>  const char *fdtdec_get_compatible(enum fdt_compat_id id)
> --
> 1.7.4.4
>

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

* [U-Boot] [PATCH 2/4 V2] EXYNOS5: FDT: Add serial device node values
  2013-03-01 10:16 ` [U-Boot] [PATCH 2/4 V2] EXYNOS5: FDT: Add serial device node values Rajeshwari Shinde
@ 2013-03-03  0:40   ` Simon Glass
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2013-03-03  0:40 UTC (permalink / raw)
  To: u-boot

Hi Rajeshwari,

On Fri, Mar 1, 2013 at 2:16 AM, Rajeshwari Shinde
<rajeshwari.s@samsung.com> wrote:
> This patch adds the device node required for serial driver
>
> Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>
> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
> ---
> Changes in V2:
>         - Changed the compatible string to "samsung,exynos4210-uart"
>  arch/arm/dts/exynos5250.dtsi              |   27 +++++++++++++++++++++++++++
>  board/samsung/dts/exynos5250-smdk5250.dts |    1 +
>  2 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/dts/exynos5250.dtsi b/arch/arm/dts/exynos5250.dtsi
> index ed8c8dd..52ce539 100644
> --- a/arch/arm/dts/exynos5250.dtsi
> +++ b/arch/arm/dts/exynos5250.dtsi
> @@ -151,4 +151,31 @@
>                 };
>         };
>
> +       serial at 12C00000 {
> +               compatible = "samsung,exynos4210-uart";
> +               reg = <0x12C00000 0x100>;
> +               interrupts = <0 51 0>;
> +               id = <0>;
> +       };
> +
> +       serial at 12C10000 {
> +               compatible = "samsung,exynos4210-uart";
> +               reg = <0x12C10000 0x100>;
> +               interrupts = <0 52 0>;
> +               id = <1>;
> +       };
> +
> +       serial at 12C20000 {
> +               compatible = "samsung,exynos4210-uart";
> +               reg = <0x12C20000 0x100>;
> +               interrupts = <0 53 0>;
> +               id = <2>;
> +       };
> +
> +       serial at 12C30000 {
> +               compatible = "samsung,exynos4210-uart";
> +               reg = <0x12C30000 0x100>;
> +               interrupts = <0 54 0>;
> +               id = <3>;
> +       };
>  };
> diff --git a/board/samsung/dts/exynos5250-smdk5250.dts b/board/samsung/dts/exynos5250-smdk5250.dts
> index cbfab6f..89db11b 100644
> --- a/board/samsung/dts/exynos5250-smdk5250.dts
> +++ b/board/samsung/dts/exynos5250-smdk5250.dts
> @@ -30,6 +30,7 @@
>                 spi2 = "/spi at 12d40000";
>                 spi3 = "/spi at 131a0000";
>                 spi4 = "/spi at 131b0000";
> +               serial0 = "/serial at 12C30000";

s/serial0/console/

Since you only support one, I think it would be better to use this as the alias.

>         };
>
>         sromc at 12250000 {
> --
> 1.7.4.4
>

Regards,
Simon

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

* [U-Boot] [PATCH 3/4 V2] S5P: Serial: Add fdt support to driver
  2013-03-01 10:16 ` [U-Boot] [PATCH 3/4 V2] S5P: Serial: Add fdt support to driver Rajeshwari Shinde
@ 2013-03-03  0:45   ` Simon Glass
  2013-03-03  0:46   ` Simon Glass
  1 sibling, 0 replies; 9+ messages in thread
From: Simon Glass @ 2013-03-03  0:45 UTC (permalink / raw)
  To: u-boot

Hi Rajeshwari,

On Fri, Mar 1, 2013 at 2:16 AM, Rajeshwari Shinde
<rajeshwari.s@samsung.com> wrote:
> This patch adds FDT support to the serial s5p driver.
> At present disabling the serial console (from the device tree) crashes
> U-Boot. Add checks for this case, so that execution can continue without
> a serial console.
> It also enables the serial_s5p driver recognize the silent_console option.
>
> Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>
> Signed-off-by: Gabe Black <gabeblack@google.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
> Changes in V2:
>         - None
>  drivers/serial/serial_s5p.c |   80 +++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 80 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
> index 3c41242..4502ffb 100644
> --- a/drivers/serial/serial_s5p.c
> +++ b/drivers/serial/serial_s5p.c
> @@ -24,16 +24,30 @@
>  #include <common.h>
>  #include <linux/compiler.h>
>  #include <asm/io.h>
> +#include <fdtdec.h>
>  #include <asm/arch/uart.h>
>  #include <asm/arch/clk.h>
>  #include <serial.h>
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> +/* 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 = {
> +       -1U

I think it might be better to explicitly put this on the end of the variable:

__attribute__ ((section(".data")))

to force it into the data section. I think that is the only reason for
the -1 assignment.

> +};
> +
>  static inline struct s5p_uart *s5p_get_base_uart(int dev_index)
>  {
> +#ifdef CONFIG_OF_CONTROL
> +       return (struct s5p_uart *)(config.base_addr);
> +#else
>         u32 offset = dev_index * sizeof(struct s5p_uart);
>         return (struct s5p_uart *)(samsung_get_base_uart() + offset);
> +#endif
>  }
>
>  /*
> @@ -69,6 +83,9 @@ void serial_setbrg_dev(const int dev_index)
>         u32 baudrate = gd->baudrate;
>         u32 val;
>
> +       if (!config.enabled)
> +               return;
> +
>         val = uclk / baudrate;
>
>         writel(val / 16 - 1, &uart->ubrdiv);
> @@ -87,6 +104,16 @@ int serial_init_dev(const int dev_index)
>  {
>         struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
>
> +#if defined(CONFIG_SILENT_CONSOLE) && \
> +               defined(CONFIG_OF_CONTROL) && \
> +               !defined(CONFIG_SPL_BUILD)
> +       if (fdtdec_get_config_int(gd->fdt_blob, "silent_console", 0))
> +               gd->flags |= GD_FLG_SILENT;
> +#endif
> +
> +       if (!config.enabled)
> +               return 0;
> +
>         /* reset and enable FIFOs, set triggers to the maximum */
>         writel(0, &uart->ufcon);
>         writel(0, &uart->umcon);
> @@ -129,6 +156,9 @@ int serial_getc_dev(const int dev_index)
>  {
>         struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
>
> +       if (!config.enabled)
> +               return 0;
> +
>         /* wait for character to arrive */
>         while (!(readl(&uart->utrstat) & 0x1)) {
>                 if (serial_err_check(dev_index, 0))
> @@ -145,6 +175,9 @@ void serial_putc_dev(const char c, const int dev_index)
>  {
>         struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
>
> +       if (!config.enabled)
> +               return;
> +
>         /* wait for room in the tx FIFO */
>         while (!(readl(&uart->utrstat) & 0x2)) {
>                 if (serial_err_check(dev_index, 1))
> @@ -165,6 +198,9 @@ int serial_tstc_dev(const int dev_index)
>  {
>         struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
>
> +       if (!config.enabled)
> +               return 0;
> +
>         return (int)(readl(&uart->utrstat) & 0x1);
>  }
>
> @@ -207,8 +243,51 @@ DECLARE_S5P_SERIAL_FUNCTIONS(3);
>  struct serial_device s5p_serial3_device =
>         INIT_S5P_SERIAL_STRUCTURE(3, "s5pser3");
>
> +#ifdef CONFIG_OF_CONTROL
> +int fdtdec_decode_console(int *index, struct fdt_serial *uart)
> +{
> +       const void *blob = gd->fdt_blob;
> +       int node;
> +
> +       node = fdtdec_next_alias(blob, "serial", COMPAT_SAMSUNG_EXYNOS5_SERIAL,
> +               index);
> +       if (node < 0)
> +               return node;
> +
> +       uart->base_addr = fdtdec_get_addr(blob, node, "reg");
> +       if (uart->base_addr == FDT_ADDR_T_NONE)
> +               return -FDT_ERR_NOTFOUND;
> +
> +       uart->port_id = fdtdec_get_int(blob, node, "id", -1);
> +       uart->enabled = fdtdec_get_is_enabled(blob, node);
> +
> +       return 0;
> +}
> +#endif
> +
>  __weak struct serial_device *default_serial_console(void)
>  {
> +#ifdef CONFIG_OF_CONTROL
> +       int index = 0;

blank line here

> +       if (fdtdec_decode_console(&index, &config)) {
> +               debug("Cannot decode default console node\n");
> +               return NULL;
> +       }

I think this function might be called for every character output prior
to relocation. So perhaps you need to only do the decode once? You can
check for base_addr being 0 perhaps and only init if it is 0.

> +
> +       if (config.port_id == 0)
> +               return &s5p_serial0_device;
> +       else if (config.port_id == 1)
> +               return &s5p_serial1_device;
> +       else if (config.port_id == 2)
> +               return &s5p_serial2_device;
> +       else if (config.port_id == 3)
> +               return &s5p_serial3_device;
> +       else
> +               debug("Unknown config.port_id: %d", config.port_id);
> +
> +       return NULL;
> +#else
> +       config.enabled = 1;
>  #if defined(CONFIG_SERIAL0)
>         return &s5p_serial0_device;
>  #elif defined(CONFIG_SERIAL1)
> @@ -220,6 +299,7 @@ __weak struct serial_device *default_serial_console(void)
>  #else
>  #error "CONFIG_SERIAL? missing."
>  #endif
> +#endif
>  }
>
>  void s5p_serial_initialize(void)
> --
> 1.7.4.4
>

Regards,
Simon

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

* [U-Boot] [PATCH 3/4 V2] S5P: Serial: Add fdt support to driver
  2013-03-01 10:16 ` [U-Boot] [PATCH 3/4 V2] S5P: Serial: Add fdt support to driver Rajeshwari Shinde
  2013-03-03  0:45   ` Simon Glass
@ 2013-03-03  0:46   ` Simon Glass
  1 sibling, 0 replies; 9+ messages in thread
From: Simon Glass @ 2013-03-03  0:46 UTC (permalink / raw)
  To: u-boot

Hi Rajeshwari,

On Fri, Mar 1, 2013 at 2:16 AM, Rajeshwari Shinde
<rajeshwari.s@samsung.com> wrote:
> This patch adds FDT support to the serial s5p driver.
> At present disabling the serial console (from the device tree) crashes
> U-Boot. Add checks for this case, so that execution can continue without
> a serial console.
> It also enables the serial_s5p driver recognize the silent_console option.
>
> Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com>
> Signed-off-by: Gabe Black <gabeblack@google.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
> Changes in V2:
>         - None
>  drivers/serial/serial_s5p.c |   80 +++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 80 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
> index 3c41242..4502ffb 100644
> --- a/drivers/serial/serial_s5p.c
> +++ b/drivers/serial/serial_s5p.c

[snip]

> @@ -87,6 +104,16 @@ int serial_init_dev(const int dev_index)
>  {
>         struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
>
> +#if defined(CONFIG_SILENT_CONSOLE) && \
> +               defined(CONFIG_OF_CONTROL) && \
> +               !defined(CONFIG_SPL_BUILD)
> +       if (fdtdec_get_config_int(gd->fdt_blob, "silent_console", 0))
> +               gd->flags |= GD_FLG_SILENT;

One more thing - can you please use 'silent-console' for this instead?
We should try to use hyphen in FDT except for phandles.

> +#endif
> +
> +       if (!config.enabled)
> +               return 0;
> +
>         /* reset and enable FIFOs, set triggers to the maximum */
>         writel(0, &uart->ufcon);
>         writel(0, &uart->umcon);


Regards,
Simon

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

end of thread, other threads:[~2013-03-03  0:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-01 10:16 [U-Boot] [PATCH 0/4 V2] SMDK5250: FDT: Add device tree support for console Rajeshwari Shinde
2013-03-01 10:16 ` [U-Boot] [PATCH 1/4 V2] EXYNOS5: FDT: Add compatible strings for Serial Rajeshwari Shinde
2013-03-03  0:38   ` Simon Glass
2013-03-01 10:16 ` [U-Boot] [PATCH 2/4 V2] EXYNOS5: FDT: Add serial device node values Rajeshwari Shinde
2013-03-03  0:40   ` Simon Glass
2013-03-01 10:16 ` [U-Boot] [PATCH 3/4 V2] S5P: Serial: Add fdt support to driver Rajeshwari Shinde
2013-03-03  0:45   ` Simon Glass
2013-03-03  0:46   ` Simon Glass
2013-03-01 10:16 ` [U-Boot] [PATCH 4/4 V2] CONFIG: EXYNOS5: Enable silent console Rajeshwari Shinde

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.