Add device tree enabled Exynos4 machine
Subsystems (5)
cover Add device tree enabled Exynos4 machine
This patchset adds a basic device tree enabled machine for Samsung's Exynos4 processor. This enables further development of device tree coverge for Exynos4. A basic device tree source file for Exynos4 processor and the smdkv310 board is also included.
The device tree enabled machine has been boot tested till serial console. The watchdog driver is probed with information from dtb.
Notes:
- The interrupt controller device tree bindings are not documented yet. That is because, it will be replaced with a new irq_domain support soon.
Thomas Abraham (4):
serial: samsung: Keep a copy of the location of platform data in driver's private data
serial: s5pv210: Add device tree support
arm: exynos4: Add a new Exynos4 device tree enabled machine
arm: dts: Add device tree source file for Exynos4 platforms
Documentation/devicetree/bindings/arm/samsung.txt | 8 ++ .../devicetree/bindings/serial/samsung_uart.txt | 16 ++++ arch/arm/boot/dts/exynos4-smdkv310.dts | 31 +++++++ arch/arm/boot/dts/exynos4.dtsi | 72 +++++++++++++++++ arch/arm/mach-exynos4/Kconfig | 10 +++ arch/arm/mach-exynos4/Makefile | 1 + arch/arm/mach-exynos4/mach-exynos4-dt.c | 84 ++++++++++++++++++++ drivers/tty/serial/s5pv210.c | 55 ++++++++++++- drivers/tty/serial/samsung.c | 19 ++++- drivers/tty/serial/samsung.h | 4 +- 10 files changed, 292 insertions(+), 8 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/samsung.txt create mode 100644 Documentation/devicetree/bindings/serial/samsung_uart.txt create mode 100644 arch/arm/boot/dts/exynos4-smdkv310.dts create mode 100644 arch/arm/boot/dts/exynos4.dtsi create mode 100644 arch/arm/mach-exynos4/mach-exynos4-dt.c
PATCH 1/4 serial: samsung: Keep a copy of the location of platform data in driver's private data
In preparation for the device tree support in the driver, a copy of the platform data pointer is maintained in the driver's private data. With device tree support, the driver can parse the platform data from the device tree and create a dynamic platform data structure. Having a pointer in the driver's private data that points to the platform data in use simplifies the device tree support addition to the driver.
--- drivers/tty/serial/s5pv210.c | 12 ++++++++++-- drivers/tty/serial/samsung.c | 16 ++++++++++++---- drivers/tty/serial/samsung.h | 4 +++- 3 files changed, 25 insertions(+), 7 deletions(-)
drivers/tty/serial/s5pv210.c +10 -2
@@ -28,9 +28,13 @@static int s5pv210_serial_setsource (struct uart_port *port,struct s3c24xx_uart_clksrc *clk) { -struct s3c2410_uartcfg *cfg = port->dev->platform_data; +struct s3c24xx_uart_port *ourport; +struct s3c2410_uartcfg *cfg;unsigned long ucon =rd_regl (port,S3C2410_UCON ); + ourport = container_of(port, struct s3c24xx_uart_port, port); + cfg = ourport->info->cfg; +if (cfg->flags &NO_NEED_CHECK_CLKSRC )return 0 ;
@@ -51,9 +55,13 @@ static int s5pv210_serial_setsource(struct uart_port *port,static int s5pv210_serial_getsource (struct uart_port *port,struct s3c24xx_uart_clksrc *clk) { -struct s3c2410_uartcfg *cfg = port->dev->platform_data; +struct s3c24xx_uart_port *ourport; +struct s3c2410_uartcfg *cfg;u32 ucon =rd_regl (port,S3C2410_UCON ); + ourport = container_of(port, struct s3c24xx_uart_port, port); + cfg = ourport->info->cfg; + clk->divisor =1 ;if (cfg->flags &NO_NEED_CHECK_CLKSRC )
drivers/tty/serial/samsung.c +12 -4
@@ -169,10 +169,13 @@ static inline struct s3c24xx_uart_info *s3c24xx_port_to_info(struct uart_port *pstatic inline struct s3c2410_uartcfg *s3c24xx_port_to_cfg (struct uart_port *port) { +struct s3c24xx_uart_port *ourport; +if (port->dev ==NULL )return NULL ; -return (struct s3c2410_uartcfg *)port->dev->platform_data; + ourport = container_of(port, struct s3c24xx_uart_port, port); +return ourport->info->cfg; } static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport,
@@ -1053,7 +1056,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, struct platform_device *platdev) {struct uart_port *port = &ourport->port; -struct s3c2410_uartcfg *cfg; +struct s3c2410_uartcfg *cfg = platdev->dev.platform_data;struct resource *res;int ret;
@@ -1062,11 +1065,16 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,if (platdev ==NULL )return -ENODEV ; - cfg =s3c24xx_dev_to_cfg (&platdev->dev); -if (port->mapbase !=0 )return 0 ; +/* +* If platform data is supplied, keep a copy of the location of +* platform data in the driver's private data. +*/ +if (cfg) + info->cfg = cfg; +if (cfg->hwport >CONFIG_SERIAL_SAMSUNG_UARTS ) {printk (KERN_ERR "%s: port %d bigger than %d\n" , __func__, cfg->hwport,CONFIG_SERIAL_SAMSUNG_UARTS );
drivers/tty/serial/samsung.h +3 -1
@@ -24,6 +24,9 @@ struct s3c24xx_uart_info { unsigned int has_divslot:1; +/* reference to platform data */ +struct s3c2410_uartcfg *cfg; +/* clock source control */ int (*get_clksrc)(struct uart_port *,struct s3c24xx_uart_clksrc *clk);
@@ -56,7 +59,6 @@ struct s3c24xx_uart_port {/* conversion functions */ #define s3c24xx_dev_to_port (__dev) (struct uart_port *)dev_get_drvdata(__dev) -#define s3c24xx_dev_to_cfg (__dev) (struct s3c2410_uartcfg *)((__dev)->platform_data)/* register access controls */
Signature · 1 line
1.7.4.1
PATCH 2/4 serial: s5pv210: Add device tree support
In reply to Thomas AbrahamFor device tree based probe, the dependecy on pdev->id to attach a corresponding default port info to the driver's private data is removed. The fifosize parameter is obtained from the device tree node and the next available instance of port info is updated with the fifosize value and attached to the driver's private data. The default platform data is selected based on the compatible property.
--- .../devicetree/bindings/serial/samsung_uart.txt | 16 +++++++ drivers/tty/serial/s5pv210.c | 43 +++++++++++++++++++- drivers/tty/serial/samsung.c | 5 ++- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/serial/samsung_uart.txt
Documentation/devicetree/bindings/serial/samsung_uart.txt new file +16 -0
@@ -0,0 +1,16 @@ +* Samsung's UART Controller + +The Samsung's UART controller is used for serial communications on all of +Samsung's s3c24xx, s3c64xx and s5p series application processors. + +Required properties: +- compatible: should be specific to the application processor + - "samsung,s5pv310-uart" , for Exynos4 processors. + +- reg: base physical address of the controller and length of memory mapped + region. + +- interrupts : Three interrupt numbers should be specified in the following + order - Rx interrupt, Tx interrupt, Error Interrupt. + +- samsung,uart-fifosize: Size of the tx/rx fifo used in the controller.
drivers/tty/serial/s5pv210.c +42 -1
64 lines not on this page · raw message
drivers/tty/serial/samsung.c +4 -1
@@ -1070,10 +1070,13 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,/* * If platform data is supplied, keep a copy of the location of -* platform data in the driver's private data. +* platform data in the driver's private data. In case of device tree +* based probe, the location of platform data is already set. */ if (cfg) info->cfg = cfg; +else + cfg = info->cfg;if (cfg->hwport >CONFIG_SERIAL_SAMSUNG_UARTS ) { printk(KERN_ERR "%s: port %d bigger than %d\n", __func__,
Signature · 1 line
1.7.4.1
PATCH 2/4 serial: s5pv210: Add device tree support
Quoted 75 lines · Thomas Abraham
For device tree based probe, the dependecy on
pdev->idto attach a corresponding default port info to the driver's private data is removed. The fifosize parameter is obtained from the device tree node and the next available instance of port info is updated with the fifosize value and attached to the driver's private data. The default platform data is selected based on the compatible property.CC Ben Dooks <[email protected]>Signed-off-by Thomas Abraham <[email protected]>--- .../devicetree/bindings/serial/samsung_uart.txt | 16 +++++++ drivers/tty/serial/s5pv210.c | 43 +++++++++++++++++++- drivers/tty/serial/samsung.c | 5 ++- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/serial/samsung_uart.txtDocumentation/devicetree/bindings/serial/samsung_uart.txt new file +16
-0@@ -0,0 +1,16 @@ +* Samsung's UART Controller + +The Samsung's UART controller is used for serial communications on all of +Samsung's s3c24xx, s3c64xx and s5p series application processors. + +Required properties: +- compatible: should be specific to the application processor + - "samsung,s5pv310-uart" , for Exynos4 processors. + +- reg: base physical address of the controller and length of memory mapped + region. + +- interrupts : Three interrupt numbers should be specified in the following + order - Rx interrupt, Tx interrupt, Error Interrupt. + +- samsung,uart-fifosize: Size of the tx/rx fifo used in the controller.drivers/tty/serial/s5pv210.c +18
-1@@ -19,6 +19,7 @@#include <linux/serial_core.h> #include <linux/serial.h> #include <linux/delay.h> +#include <linux/of.h> #include <asm/irq.h> #include <mach/hardware.h> @@ -132,10 +133,49 @@ static struct s3c24xx_uart_info *s5p_uart_inf[] = { [3] = &s5p_port_fifo16, }; +#ifdef CONFIG_OF +static struct s3c2410_uartcfg s5pv310_uart_defcfg = { + .ucon =0x3c5 , + .ufcon =0x111 , + .flags =NO_NEED_CHECK_CLKSRC , + .has_fracval =1 , +}; + +static const struct of_device_id s5pv210_uart_dt_match[] = { + { .compatible ="samsung,s5pv310-uart" , .data = &s5pv310_uart_defcfg }, + {}, +}; +MODULE_DEVICE_TABLE (of, s5pv210_uart_match); +#else +#define s5pv210_uart_match NULL +#endif +/* device management */ static int s5p_serial_probe (struct platform_device *pdev) { -return s3c24xx_serial_probe (pdev, s5p_uart_inf[pdev->id]);
drivers/tty/serial/s5pv210.c static struct s3c24xx_uart_info *s5p_uart_inf[] = { · line 165
Quoted 10 lines
drivers/tty/serial/s5pv210.c +10
-0+static unsigned int probe_index; +unsigned int port = pdev->id; +const struct of_device_id *match; +struct s3c2410_uartcfg *cfg; + +if (pdev->dev.of_node) { +if (of_property_read_u32 (pdev->dev.of_node, +"samsung,uart-fifosize" , + &s5p_uart_inf[probe_index]->fifosize)) +return -EINVAL ;
I'd rather see the fifo size either being a property of the soc itself or being inferred by the compatible field.
drivers/tty/serial/s5pv210.c static struct platform_driver s5p_serial_driver = { · line 187
Quoted 4 lines
drivers/tty/serial/s5pv210.c +1
-0.driver = { .name = "s5pv210-uart", .owner = THIS_MODULE, + .of_match_table = s5pv210_uart_dt_match,
I think maybe doing something like
.of_match_table = of_match_ptr(5pv210_uart_dt_match),
so we can avoid having the #else and #define 5pv210_uart_dt_match NULL in a number of places.
Quoted 2 lines
},
};
Signature · 3 lines
Ben Dooks, ben at fluff.org, http://www.fluff.org/ben/ Large Hadron Colada: A large Pina Colada that makes the universe disappear.
PATCH 2/4 serial: s5pv210: Add device tree support
Hi Ben,
Quoted 16 lines · Ben Dooks
Quoted 15 lines · Thomas Abraham
For device tree based probe, the dependecy on
pdev->idto attach a corresponding default port info to the driver's private data is removed. The fifosize parameter is obtained from the device tree node and the next available instance of port info is updated with the fifosize value and attached to the driver's private data. The default platform data is selected based on the compatible property.CC Ben Dooks <[email protected]>Signed-off-by Thomas Abraham <[email protected]>---
?.../devicetree/bindings/serial/samsung_uart.txt ? ?| ? 16 +++++++ ?drivers/tty/serial/s5pv210.c ? ? ? ? ? ? ? ? ? ? ? | ? 43 +++++++++++++++++++- ?drivers/tty/serial/samsung.c ? ? ? ? ? ? ? ? ? ? ? | ? ?5 ++-?3 files changed, 62 insertions(+), 2 deletions(-)
?create mode 100644Documentation/devicetree/bindings/serial/samsung_uart.txt
[...]
Quoted 10 lines
Quoted 7 lines
+
+ ? ? if (pdev->dev.of_node) {
+ ? ? ? ? ? ? if (of_property_read_u32(pdev->dev.of_node,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? "samsung,uart-fifosize",
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? &s5p_uart_inf[probe_index]->fifosize))
+ ? ? ? ? ? ? ? ? ? ? return-EINVAL;I'd rather see the fifo size either being a property of the soc itself or being inferred by the compatible field.
Ok. I missed that. I will make it part of the SoC data.
Quoted 6 lines
Quoted 5 lines
? ? ? .driver ? ? ? ? = {
? ? ? ? ? ? ? .name ? = "s5pv210-uart",
? ? ? ? ? ? ? .owner ?=THIS_MODULE,
+ ? ? ? ? ? ? .of_match_table =s5pv210_uart_dt_match,
Quoted 6 lines
I think maybe doing something like
? ? ? ? ? ? ? ?.of_match_table =
of_match_ptr(5pv210_uart_dt_match),so we can avoid having the #else and #define 5pv210_uart_dt_match NULL in a number of places.
Ok. I will change it.
Thanks,
Thomas.
Quoted 10 lines
Quoted 3 lines
? ? ? },
?};--
Ben Dooks, ben at fluff.org, http://www.fluff.org/ben/Large Hadron Colada: A large Pina Colada that makes the universe disappear.
PATCH 2/4 serial: s5pv210: Add device tree support
In reply to Ben DooksHi Ben,
Quoted 17 lines · Ben Dooks
Quoted 16 lines · Thomas Abraham
For device tree based probe, the dependecy on
pdev->idto attach a corresponding default port info to the driver's private data is removed. The fifosize parameter is obtained from the device tree node and the next available instance of port info is updated with the fifosize value and attached to the driver's private data. The default platform data is selected based on the compatible property.CC Ben Dooks <[email protected]>Signed-off-by Thomas Abraham <[email protected]>---
?.../devicetree/bindings/serial/samsung_uart.txt ? ?| ? 16 +++++++ ?drivers/tty/serial/s5pv210.c ? ? ? ? ? ? ? ? ? ? ? | ? 43 +++++++++++++++++++- ?drivers/tty/serial/samsung.c ? ? ? ? ? ? ? ? ? ? ? | ? ?5 ++-?3 files changed, 62 insertions(+), 2 deletions(-)
?create mode 100644Documentation/devicetree/bindings/serial/samsung_uart.txt
[...]
Quoted 15 lines
Quoted 6 lines
?/* device management */
?static ints5p_serial_probe(struct platform_device *pdev)?{
- ? ? returns3c24xx_serial_probe(pdev, s5p_uart_inf[pdev->id]);
+ ? ? static unsigned intprobe_index;
+ ? ? unsigned int port =pdev->id;Quoted 8 lines
+ ? ? const struct
of_device_id*match;
+ ? ? structs3c2410_uartcfg*cfg;
+
+ ? ? if (pdev->dev.of_node) {
+ ? ? ? ? ? ? if (of_property_read_u32(pdev->dev.of_node,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? "samsung,uart-fifosize",
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? &s5p_uart_inf[probe_index]->fifosize))
+ ? ? ? ? ? ? ? ? ? ? return-EINVAL;
Quoted 2 lines
I'd rather see the fifo size either being a property of the soc itself or being inferred by the compatible field.
When using the compatible field to infer the fifosize of the controller, the code looks as listed below.
struct s3c24xx_uart_dt_compat_data {
unsigned int fifosize;
struct s3c2410_uartcfg *uartcfg;
};static struct s3c2410_uartcfg s5pv310_uart_defcfg = {
.ucon = 0x3c5,
.ufcon = 0x111,
.flags = NO_NEED_CHECK_CLKSRC,
.has_fracval = 1,
};static struct s3c24xx_uart_dt_compat_data s5pv210_compat_fs256 = {
.fifosize = 256;
.uartcfg = &s5pv310_uart_defcfg;
};static struct s3c24xx_uart_dt_compat_data s5pv210_compat_fs64 = {
.fifosize = 64;
.uartcfg = &s5pv310_uart_defcfg;
};static struct s3c24xx_uart_dt_compat_data s5pv210_compat_fs16 = {
.fifosize = 16;
.uartcfg = &s5pv310_uart_defcfg;
};static const struct of_device_id s5pv210_uart_dt_match[] = {
{ .compatible = "samsung,s5pv310-uart-fs256", .data =
&s5pv210_compat_fs256 },
{ .compatible = "samsung,s5pv310-uart-fs64", .data =
s5pv210_compat_fs64 },
{ .compatible = "samsung,s5pv310-uart-fs16", .data =
s5pv210_compat_fs16 },
{},
};MODULE_DEVICE_TABLE(of, s5pv210_uart_match);
This requires a new structure definition and additional data in the driver. So I still prefer to use a property in the uart device node to define the fifosize of the controller.
What would you be your preference? Or is there a better way to obtain the fifosize?
Thanks,
Thomas.
Quoted 22 lines
Quoted 5 lines
? ? ? .driver ? ? ? ? = {
? ? ? ? ? ? ? .name ? = "s5pv210-uart",
? ? ? ? ? ? ? .owner ?=THIS_MODULE,
+ ? ? ? ? ? ? .of_match_table =s5pv210_uart_dt_match,I think maybe doing something like
? ? ? ? ? ? ? ?.of_match_table =
of_match_ptr(5pv210_uart_dt_match),so we can avoid having the #else and #define 5pv210_uart_dt_match NULL in a number of places.
Quoted 2 lines
? ? ? },
?};--
Ben Dooks, ben at fluff.org, http://www.fluff.org/ben/Large Hadron Colada: A large Pina Colada that makes the universe disappear.
PATCH 3/4 arm: exynos4: Add a new Exynos4 device tree enabled machine
In reply to Thomas AbrahamAdd a new basic Exynos4 machine with device tree support that can boot on a Exynos4 processor based board and bring up the console. This acts as a stating point to add device tree support for Exynos4 architecture.
--- Documentation/devicetree/bindings/arm/samsung.txt | 8 ++ arch/arm/mach-exynos4/Kconfig | 10 +++ arch/arm/mach-exynos4/Makefile | 1 + arch/arm/mach-exynos4/mach-exynos4-dt.c | 84 +++++++++++++++++++++ 4 files changed, 103 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/samsung.txt create mode 100644 arch/arm/mach-exynos4/mach-exynos4-dt.c
Documentation/devicetree/bindings/arm/samsung.txt new file +8 -0
@@ -0,0 +1,8 @@ +Samsung Exynos4 based SMDKV310 eval board + + SMDKV310 eval board is based on Samsung's Exynos4 processor architecture. + +Required root node properties: + - compatible = "samsung,smdkv310","samsung,exynos4" + (a) "samsung,smdkv310" - for Samsung's SMDKV310 eval board. + (b) "samsung,exynos4" - for boards based on Exynos4 architecture.
arch/arm/mach-exynos4/Kconfig +10 -0
@@ -218,6 +218,16 @@ config MACH_NURI help Machine support for Samsung Mobile NURI Board. +config MACH_EXYNOS4_DT + bool "Samsung Exynos4 Machine using device tree" + select CPU_EXYNOS4210 + select USE_OF + select S3C_DEV_HSMMC + select S3C_DEV_HSMMC2 + select EXYNOS4_SETUP_SDHCI + help + Machine support for Samsung Exynos4 machine with device tree enabled. + endmenu comment "Configuration for HSMMC bus width"
arch/arm/mach-exynos4/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_MACH_SMDKV310) += mach-smdkv310.o obj-$(CONFIG_MACH_ARMLEX4210) += mach-armlex4210.o obj-$(CONFIG_MACH_UNIVERSAL_C210) += mach-universal_c210.o obj-$(CONFIG_MACH_NURI) += mach-nuri.o +obj-$(CONFIG_MACH_EXYNOS4_DT) += mach-exynos4-dt.o # device support
arch/arm/mach-exynos4/mach-exynos4-dt.c new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 4/4 arm: dts: Add device tree source file for Exynos4 platforms
In reply to Thomas AbrahamCreate a new device tree source file for Samsung's Exynos4 architecture and let Exynos4 based boards include it. We start with a uart device nodes in the device tree source file and incrementally add nodes as we improve the device tree coverage for Exynos4 architecture and related boards.
--- arch/arm/boot/dts/exynos4-smdkv310.dts | 31 ++++++++++++++ arch/arm/boot/dts/exynos4.dtsi | 72 ++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 0 deletions(-) create mode 100644 arch/arm/boot/dts/exynos4-smdkv310.dts create mode 100644 arch/arm/boot/dts/exynos4.dtsi
arch/arm/boot/dts/exynos4-smdkv310.dts new file +31 -0
@@ -0,0 +1,31 @@ +/* + * Samsung's Exynos4 based SMDKV310 board device tree source. + * + * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * Copyright (c) 2010-2011 Linaro Ltd. + * www.linaro.org + * + * Device tree source file for Samsung's SMDKV310 board which is based on + * Samsung's Exynos4 architecture. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. +*/ + +/dts-v1/; +/include/ "exynos4.dtsi" + +/ { + model = "Samsung Exynos4 smdkv310 eval board"; + compatible = "samsung,smdkv310", "samsung,exynos4"; + + memory { + reg = <0x40000000 0x80000000>; + }; + + chosen { + bootargs ="root=/dev/ram0 rw ramdisk=8192 console=ttySAC1,115200 init=/linuxrc"; + }; +};
arch/arm/boot/dts/exynos4.dtsi new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
1.7.4.1