* [PATCH 1/4] serial: samsung: Keep a copy of the location of platform data in driver's private data
2011-08-02 23:08 [PATCH 0/4] Add device tree enabled Exynos4 machine Thomas Abraham
@ 2011-08-02 23:08 ` Thomas Abraham
2011-08-02 23:08 ` [PATCH 2/4] serial: s5pv210: Add device tree support Thomas Abraham
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Thomas Abraham @ 2011-08-02 23:08 UTC (permalink / raw)
To: linux-arm-kernel
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.
CC: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
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(-)
diff --git a/drivers/tty/serial/s5pv210.c b/drivers/tty/serial/s5pv210.c
index 8b0b888..fb0806c 100644
--- a/drivers/tty/serial/s5pv210.c
+++ b/drivers/tty/serial/s5pv210.c
@@ -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)
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index afc6294..47fee73 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -169,10 +169,13 @@ static inline struct s3c24xx_uart_info *s3c24xx_port_to_info(struct uart_port *p
static 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);
diff --git a/drivers/tty/serial/samsung.h b/drivers/tty/serial/samsung.h
index a69d9a5..b1ff17a 100644
--- a/drivers/tty/serial/samsung.h
+++ b/drivers/tty/serial/samsung.h
@@ -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 */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/4] serial: s5pv210: Add device tree support
2011-08-02 23:08 [PATCH 0/4] Add device tree enabled Exynos4 machine Thomas Abraham
2011-08-02 23:08 ` [PATCH 1/4] serial: samsung: Keep a copy of the location of platform data in driver's private data Thomas Abraham
@ 2011-08-02 23:08 ` Thomas Abraham
2011-08-03 9:12 ` Ben Dooks
2011-08-02 23:08 ` [PATCH 3/4] arm: exynos4: Add a new Exynos4 device tree enabled machine Thomas Abraham
2011-08-02 23:08 ` [PATCH 4/4] arm: dts: Add device tree source file for Exynos4 platforms Thomas Abraham
3 siblings, 1 reply; 8+ messages in thread
From: Thomas Abraham @ 2011-08-02 23:08 UTC (permalink / raw)
To: linux-arm-kernel
For 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.
CC: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
.../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
diff --git a/Documentation/devicetree/bindings/serial/samsung_uart.txt b/Documentation/devicetree/bindings/serial/samsung_uart.txt
new file mode 100644
index 0000000..9174499
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/samsung_uart.txt
@@ -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.
diff --git a/drivers/tty/serial/s5pv210.c b/drivers/tty/serial/s5pv210.c
index fb0806c..a44b599 100644
--- a/drivers/tty/serial/s5pv210.c
+++ b/drivers/tty/serial/s5pv210.c
@@ -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]);
+ 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;
+
+ cfg = devm_kzalloc(&pdev->dev, sizeof(*cfg), GFP_KERNEL);
+ if (!cfg)
+ return -ENOMEM;
+
+ match = of_match_node(s5pv210_uart_dt_match, pdev->dev.of_node);
+ *cfg = *((struct s3c2410_uartcfg *)match->data);
+ s5p_uart_inf[probe_index]->cfg = cfg;
+ cfg->hwport = probe_index;
+ port = probe_index++;
+ }
+
+ return s3c24xx_serial_probe(pdev, s5p_uart_inf[port]);
}
static struct platform_driver s5p_serial_driver = {
@@ -144,6 +184,7 @@ static struct platform_driver s5p_serial_driver = {
.driver = {
.name = "s5pv210-uart",
.owner = THIS_MODULE,
+ .of_match_table = s5pv210_uart_dt_match,
},
};
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 47fee73..49ba4a5a 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -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__,
--
1.7.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/4] serial: s5pv210: Add device tree support
2011-08-02 23:08 ` [PATCH 2/4] serial: s5pv210: Add device tree support Thomas Abraham
@ 2011-08-03 9:12 ` Ben Dooks
2011-08-03 10:09 ` Thomas Abraham
2011-08-10 17:41 ` Thomas Abraham
0 siblings, 2 replies; 8+ messages in thread
From: Ben Dooks @ 2011-08-03 9:12 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Aug 03, 2011 at 12:08:27AM +0100, Thomas Abraham wrote:
> For 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.
>
> CC: Ben Dooks <ben-linux@fluff.org>
> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
> ---
> .../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
>
> diff --git a/Documentation/devicetree/bindings/serial/samsung_uart.txt b/Documentation/devicetree/bindings/serial/samsung_uart.txt
> new file mode 100644
> index 0000000..9174499
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/serial/samsung_uart.txt
> @@ -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.
> diff --git a/drivers/tty/serial/s5pv210.c b/drivers/tty/serial/s5pv210.c
> index fb0806c..a44b599 100644
> --- a/drivers/tty/serial/s5pv210.c
> +++ b/drivers/tty/serial/s5pv210.c
> @@ -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]);
> + 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.
> .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.
> },
> };
--
Ben Dooks, ben at fluff.org, http://www.fluff.org/ben/
Large Hadron Colada: A large Pina Colada that makes the universe disappear.
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 2/4] serial: s5pv210: Add device tree support
2011-08-03 9:12 ` Ben Dooks
@ 2011-08-03 10:09 ` Thomas Abraham
2011-08-10 17:41 ` Thomas Abraham
1 sibling, 0 replies; 8+ messages in thread
From: Thomas Abraham @ 2011-08-03 10:09 UTC (permalink / raw)
To: linux-arm-kernel
Hi Ben,
On 3 August 2011 10:12, Ben Dooks <ben-linux@fluff.org> wrote:
> On Wed, Aug 03, 2011 at 12:08:27AM +0100, Thomas Abraham wrote:
>> For 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.
>>
>> CC: Ben Dooks <ben-linux@fluff.org>
>> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
>> ---
>> ?.../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
[...]
>>
>> +
>> + ? ? 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.
>
>> ? ? ? .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.
Ok. I will change it.
Thanks,
Thomas.
>
>> ? ? ? },
>> ?};
>
> --
> Ben Dooks, ben at fluff.org, http://www.fluff.org/ben/
>
> Large Hadron Colada: A large Pina Colada that makes the universe disappear.
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 2/4] serial: s5pv210: Add device tree support
2011-08-03 9:12 ` Ben Dooks
2011-08-03 10:09 ` Thomas Abraham
@ 2011-08-10 17:41 ` Thomas Abraham
1 sibling, 0 replies; 8+ messages in thread
From: Thomas Abraham @ 2011-08-10 17:41 UTC (permalink / raw)
To: linux-arm-kernel
Hi Ben,
On 3 August 2011 14:42, Ben Dooks <ben-linux@fluff.org> wrote:
> On Wed, Aug 03, 2011 at 12:08:27AM +0100, Thomas Abraham wrote:
>> For 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.
>>
>> CC: Ben Dooks <ben-linux@fluff.org>
>> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
>> ---
>> ?.../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
>>
[...]
>> ?/* device management */
>> ?static int s5p_serial_probe(struct platform_device *pdev)
>> ?{
>> - ? ? return s3c24xx_serial_probe(pdev, s5p_uart_inf[pdev->id]);
>> + ? ? 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.
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.
>
>> ? ? ? .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.
>
>> ? ? ? },
>> ?};
>
> --
> Ben Dooks, ben at fluff.org, http://www.fluff.org/ben/
>
> Large Hadron Colada: A large Pina Colada that makes the universe disappear.
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/4] arm: exynos4: Add a new Exynos4 device tree enabled machine
2011-08-02 23:08 [PATCH 0/4] Add device tree enabled Exynos4 machine Thomas Abraham
2011-08-02 23:08 ` [PATCH 1/4] serial: samsung: Keep a copy of the location of platform data in driver's private data Thomas Abraham
2011-08-02 23:08 ` [PATCH 2/4] serial: s5pv210: Add device tree support Thomas Abraham
@ 2011-08-02 23:08 ` Thomas Abraham
2011-08-02 23:08 ` [PATCH 4/4] arm: dts: Add device tree source file for Exynos4 platforms Thomas Abraham
3 siblings, 0 replies; 8+ messages in thread
From: Thomas Abraham @ 2011-08-02 23:08 UTC (permalink / raw)
To: linux-arm-kernel
Add 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.
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
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
diff --git a/Documentation/devicetree/bindings/arm/samsung.txt b/Documentation/devicetree/bindings/arm/samsung.txt
new file mode 100644
index 0000000..ce4a1aa
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/samsung.txt
@@ -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.
diff --git a/arch/arm/mach-exynos4/Kconfig b/arch/arm/mach-exynos4/Kconfig
index 0c77ab9..c29de4e 100644
--- a/arch/arm/mach-exynos4/Kconfig
+++ b/arch/arm/mach-exynos4/Kconfig
@@ -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"
diff --git a/arch/arm/mach-exynos4/Makefile b/arch/arm/mach-exynos4/Makefile
index b7fe1d7..d2bf5bf 100644
--- a/arch/arm/mach-exynos4/Makefile
+++ b/arch/arm/mach-exynos4/Makefile
@@ -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
diff --git a/arch/arm/mach-exynos4/mach-exynos4-dt.c b/arch/arm/mach-exynos4/mach-exynos4-dt.c
new file mode 100644
index 0000000..47c3892
--- /dev/null
+++ b/arch/arm/mach-exynos4/mach-exynos4-dt.c
@@ -0,0 +1,84 @@
+/*
+ * Samsung's Exynos4 device tree enabled machine.
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ * Copyright (c) 2010-2011 Linaro Ltd.
+ * www.linaro.org
+ *
+ * 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.
+*/
+
+#include <linux/io.h>
+#include <linux/of_platform.h>
+#include <linux/irq.h>
+#include <linux/irqdomain.h>
+#include <linux/serial_core.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach-types.h>
+
+#include <plat/regs-serial.h>
+#include <plat/exynos4.h>
+#include <plat/cpu.h>
+
+#include <mach/map.h>
+
+/*
+ * The following lookup table is used to override device names when devices
+ * are registered from device tree. This is temporarily added to enable
+ * device tree support addition for the Exynos4 architecture.
+ *
+ * For drivers that require platform data to be provided from the machine
+ * file, a platform data pointer can also be supplied along with the
+ * devices names. Usually, the platform data elements that cannot be parsed
+ * from the device tree by the drivers (example: function pointers) are
+ * supplied. But it should be noted that this is a temporary mechanism and
+ * at some point, the drivers should be capable of parsing all the platform
+ * data from the device tree.
+ */
+static const struct of_dev_auxdata exynos4_auxdata_lookup[] __initconst = {
+ OF_DEV_AUXDATA("samsung,s5pv310-uart", S5P_PA_UART0,
+ "s5pv210-uart.0", NULL),
+ OF_DEV_AUXDATA("samsung,s5pv310-uart", S5P_PA_UART1,
+ "s5pv210-uart.1", NULL),
+ OF_DEV_AUXDATA("samsung,s5pv310-uart", S5P_PA_UART2,
+ "s5pv210-uart.2", NULL),
+ OF_DEV_AUXDATA("samsung,s5pv310-uart", S5P_PA_UART3,
+ "s5pv210-uart.3", NULL),
+ {},
+};
+
+static void __init exynos4_dt_map_io(void)
+{
+ s5p_init_io(NULL, 0, S5P_VA_CHIPID);
+ s3c24xx_init_clocks(24000000);
+}
+
+static const struct of_device_id intc_of_match[] __initconst = {
+ { .compatible = "samsung,exynos4-gic", },
+ {},
+};
+
+static void __init exynos4_dt_machine_init(void)
+{
+ irq_domain_generate_simple(intc_of_match, EXYNOS4_PA_GIC_DIST, 0);
+ of_platform_populate(NULL, of_default_bus_match_table,
+ exynos4_auxdata_lookup, NULL);
+}
+
+static char const *exynos4_dt_compat[] __initdata = {
+ "samsung,exynos4",
+ NULL
+};
+
+DT_MACHINE_START(SMDKV310, "Samsung Exynos4 DT")
+ /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
+ .init_irq = exynos4_init_irq,
+ .map_io = exynos4_dt_map_io,
+ .init_machine = exynos4_dt_machine_init,
+ .timer = &exynos4_timer,
+ .dt_compat = exynos4_dt_compat,
+MACHINE_END
--
1.7.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 4/4] arm: dts: Add device tree source file for Exynos4 platforms
2011-08-02 23:08 [PATCH 0/4] Add device tree enabled Exynos4 machine Thomas Abraham
` (2 preceding siblings ...)
2011-08-02 23:08 ` [PATCH 3/4] arm: exynos4: Add a new Exynos4 device tree enabled machine Thomas Abraham
@ 2011-08-02 23:08 ` Thomas Abraham
3 siblings, 0 replies; 8+ messages in thread
From: Thomas Abraham @ 2011-08-02 23:08 UTC (permalink / raw)
To: linux-arm-kernel
Create 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.
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
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
diff --git a/arch/arm/boot/dts/exynos4-smdkv310.dts b/arch/arm/boot/dts/exynos4-smdkv310.dts
new file mode 100644
index 0000000..34a00b5
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4-smdkv310.dts
@@ -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";
+ };
+};
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
new file mode 100644
index 0000000..babb24d
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -0,0 +1,72 @@
+/*
+ * Samsung's Exynos4 Architecture device tree source.
+ *
+ * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ * Copyright (c) 2010-2011 Linaro Ltd.
+ * www.linaro.org
+ *
+ * This file acts as the core device tree for Samsung's Exynos4 based board
+ * device tree files. The Exynos4 architecture related device tree nodes
+ * will be listed in this file and Exynos4 based board device tree files
+ * should include this file.
+ *
+ * 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.
+*/
+
+/include/ "skeleton.dtsi"
+
+/ {
+ compatible = "samsung,exynos4";
+
+ soc {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "simple-bus";
+ interrupt-parent = <&intc>;
+ ranges;
+
+ intc:interrupt-controller at 10490000 {
+ compatible = "samsung,exynos4-gic","arm,cortex-a9-gic";
+ #interrupt-cells = <1>;
+ interrupt-controller;
+ reg = <0x10490000 0x1000>, <0x10480000 0x100>;
+ };
+
+ watchdog at 10060000 {
+ compatible = "samsung,s3c2410-wdt";
+ reg = <0x10060000 0x100>;
+ interrupts = <107>;
+ };
+
+ serial at 13800000 {
+ compatible = "samsung,s5pv310-uart";
+ reg = <0x13800000 0x100>;
+ interrupts = <16 18 17>;
+ samsung,uart-fifosize = <256>;
+ };
+
+ serial at 13810000 {
+ compatible = "samsung,s5pv310-uart";
+ reg = <0x13810000 0x100>;
+ interrupts = <20 22 21>;
+ samsung,uart-fifosize = <64>;
+ };
+
+ serial at 13820000 {
+ compatible = "samsung,s5pv310-uart";
+ reg = <0x13820000 0x100>;
+ interrupts = <24 26 25>;
+ samsung,uart-fifosize = <16>;
+ };
+
+ serial at 13830000 {
+ compatible = "samsung,s5pv310-uart";
+ reg = <0x13830000 0x100>;
+ interrupts = <28 30 29>;
+ samsung,uart-fifosize = <16>;
+ };
+ };
+};
--
1.7.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread