aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@freescale.com>2011-01-04 01:20:52 -0500
committerSascha Hauer <s.hauer@pengutronix.de>2011-01-12 08:47:15 -0500
commitdbc4245bb520580fc1b01105727fde7d7cbe452d (patch)
tree993aa43d0831ddb9a981640a9bf48bb92e8e78bf /arch
parent48f76ed1cc034c682666c43815fd0ef27c2a7215 (diff)
ARM: mxs: Change duart device to use amba-pl011
The mxs duart is actually an amba-pl011 device. This commit changes the duart device code to dynamically allocate amba-pl011 device, so that drivers/serial/amba-pl011.c can be used on mxs. Signed-off-by: Shawn Guo <shawn.guo@freescale.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-mxs/Kconfig4
-rw-r--r--arch/arm/mach-mxs/clock-mx23.c12
-rw-r--r--arch/arm/mach-mxs/clock-mx28.c11
-rw-r--r--arch/arm/mach-mxs/devices-mx23.h4
-rw-r--r--arch/arm/mach-mxs/devices-mx28.h4
-rw-r--r--arch/arm/mach-mxs/devices.c17
-rw-r--r--arch/arm/mach-mxs/devices/Kconfig3
-rw-r--r--arch/arm/mach-mxs/devices/Makefile2
-rw-r--r--arch/arm/mach-mxs/devices/amba-duart.c40
-rw-r--r--arch/arm/mach-mxs/devices/platform-duart.c48
-rw-r--r--arch/arm/mach-mxs/include/mach/devices-common.h11
11 files changed, 88 insertions, 68 deletions
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index c4ac7b415195..8bfc8df54617 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig
@@ -15,7 +15,7 @@ comment "MXS platforms:"
15config MACH_MX23EVK 15config MACH_MX23EVK
16 bool "Support MX23EVK Platform" 16 bool "Support MX23EVK Platform"
17 select SOC_IMX23 17 select SOC_IMX23
18 select MXS_HAVE_PLATFORM_DUART 18 select MXS_HAVE_AMBA_DUART
19 default y 19 default y
20 help 20 help
21 Include support for MX23EVK platform. This includes specific 21 Include support for MX23EVK platform. This includes specific
@@ -24,7 +24,7 @@ config MACH_MX23EVK
24config MACH_MX28EVK 24config MACH_MX28EVK
25 bool "Support MX28EVK Platform" 25 bool "Support MX28EVK Platform"
26 select SOC_IMX28 26 select SOC_IMX28
27 select MXS_HAVE_PLATFORM_DUART 27 select MXS_HAVE_AMBA_DUART
28 select MXS_HAVE_PLATFORM_FEC 28 select MXS_HAVE_PLATFORM_FEC
29 default y 29 default y
30 help 30 help
diff --git a/arch/arm/mach-mxs/clock-mx23.c b/arch/arm/mach-mxs/clock-mx23.c
index 8f5a19ab558c..136341de05e1 100644
--- a/arch/arm/mach-mxs/clock-mx23.c
+++ b/arch/arm/mach-mxs/clock-mx23.c
@@ -437,10 +437,12 @@ _DEFINE_CLOCK(clk32k_clk, XTAL, TIMROT_CLK32K_GATE, &ref_xtal_clk);
437 }, 437 },
438 438
439static struct clk_lookup lookups[] = { 439static struct clk_lookup lookups[] = {
440 _REGISTER_CLOCK("mxs-duart.0", NULL, uart_clk) 440 /* for amba bus driver */
441 _REGISTER_CLOCK("duart", "apb_pclk", xbus_clk)
442 /* for amba-pl011 driver */
443 _REGISTER_CLOCK("duart", NULL, uart_clk)
441 _REGISTER_CLOCK("rtc", NULL, rtc_clk) 444 _REGISTER_CLOCK("rtc", NULL, rtc_clk)
442 _REGISTER_CLOCK(NULL, "hclk", hbus_clk) 445 _REGISTER_CLOCK(NULL, "hclk", hbus_clk)
443 _REGISTER_CLOCK(NULL, "xclk", xbus_clk)
444 _REGISTER_CLOCK(NULL, "usb", usb_clk) 446 _REGISTER_CLOCK(NULL, "usb", usb_clk)
445 _REGISTER_CLOCK(NULL, "audio", audio_clk) 447 _REGISTER_CLOCK(NULL, "audio", audio_clk)
446 _REGISTER_CLOCK(NULL, "pwm", pwm_clk) 448 _REGISTER_CLOCK(NULL, "pwm", pwm_clk)
@@ -518,6 +520,12 @@ int __init mx23_clocks_init(void)
518{ 520{
519 clk_misc_init(); 521 clk_misc_init();
520 522
523 clk_enable(&cpu_clk);
524 clk_enable(&hbus_clk);
525 clk_enable(&xbus_clk);
526 clk_enable(&emi_clk);
527 clk_enable(&uart_clk);
528
521 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 529 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
522 530
523 mxs_timer_init(&clk32k_clk, MX23_INT_TIMER0); 531 mxs_timer_init(&clk32k_clk, MX23_INT_TIMER0);
diff --git a/arch/arm/mach-mxs/clock-mx28.c b/arch/arm/mach-mxs/clock-mx28.c
index fbb8d7424d0c..fcac1a5663b4 100644
--- a/arch/arm/mach-mxs/clock-mx28.c
+++ b/arch/arm/mach-mxs/clock-mx28.c
@@ -602,7 +602,10 @@ _DEFINE_CLOCK(fec_clk, ENET, DISABLE, &hbus_clk);
602 }, 602 },
603 603
604static struct clk_lookup lookups[] = { 604static struct clk_lookup lookups[] = {
605 _REGISTER_CLOCK("mxs-duart.0", NULL, uart_clk) 605 /* for amba bus driver */
606 _REGISTER_CLOCK("duart", "apb_pclk", xbus_clk)
607 /* for amba-pl011 driver */
608 _REGISTER_CLOCK("duart", NULL, uart_clk)
606 _REGISTER_CLOCK("imx28-fec.0", NULL, fec_clk) 609 _REGISTER_CLOCK("imx28-fec.0", NULL, fec_clk)
607 _REGISTER_CLOCK("imx28-fec.1", NULL, fec_clk) 610 _REGISTER_CLOCK("imx28-fec.1", NULL, fec_clk)
608 _REGISTER_CLOCK("fec.0", NULL, fec_clk) 611 _REGISTER_CLOCK("fec.0", NULL, fec_clk)
@@ -728,6 +731,12 @@ int __init mx28_clocks_init(void)
728{ 731{
729 clk_misc_init(); 732 clk_misc_init();
730 733
734 clk_enable(&cpu_clk);
735 clk_enable(&hbus_clk);
736 clk_enable(&xbus_clk);
737 clk_enable(&emi_clk);
738 clk_enable(&uart_clk);
739
731 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 740 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
732 741
733 mxs_timer_init(&clk32k_clk, MX28_INT_TIMER0); 742 mxs_timer_init(&clk32k_clk, MX28_INT_TIMER0);
diff --git a/arch/arm/mach-mxs/devices-mx23.h b/arch/arm/mach-mxs/devices-mx23.h
index d0f49fc0abb5..1256788561d0 100644
--- a/arch/arm/mach-mxs/devices-mx23.h
+++ b/arch/arm/mach-mxs/devices-mx23.h
@@ -11,6 +11,6 @@
11#include <mach/mx23.h> 11#include <mach/mx23.h>
12#include <mach/devices-common.h> 12#include <mach/devices-common.h>
13 13
14extern const struct mxs_duart_data mx23_duart_data __initconst; 14extern const struct amba_device mx23_duart_device __initconst;
15#define mx23_add_duart() \ 15#define mx23_add_duart() \
16 mxs_add_duart(&mx23_duart_data) 16 mxs_add_duart(&mx23_duart_device)
diff --git a/arch/arm/mach-mxs/devices-mx28.h b/arch/arm/mach-mxs/devices-mx28.h
index 00b736c434ba..33773a6333a2 100644
--- a/arch/arm/mach-mxs/devices-mx28.h
+++ b/arch/arm/mach-mxs/devices-mx28.h
@@ -11,9 +11,9 @@
11#include <mach/mx28.h> 11#include <mach/mx28.h>
12#include <mach/devices-common.h> 12#include <mach/devices-common.h>
13 13
14extern const struct mxs_duart_data mx28_duart_data __initconst; 14extern const struct amba_device mx28_duart_device __initconst;
15#define mx28_add_duart() \ 15#define mx28_add_duart() \
16 mxs_add_duart(&mx28_duart_data) 16 mxs_add_duart(&mx28_duart_device)
17 17
18extern const struct mxs_fec_data mx28_fec_data[] __initconst; 18extern const struct mxs_fec_data mx28_fec_data[] __initconst;
19#define mx28_add_fec(id, pdata) \ 19#define mx28_add_fec(id, pdata) \
diff --git a/arch/arm/mach-mxs/devices.c b/arch/arm/mach-mxs/devices.c
index 6b60f02ca2e3..c20d54740b0b 100644
--- a/arch/arm/mach-mxs/devices.c
+++ b/arch/arm/mach-mxs/devices.c
@@ -19,9 +19,8 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/err.h>
23#include <linux/platform_device.h> 22#include <linux/platform_device.h>
24#include <mach/common.h> 23#include <linux/amba/bus.h>
25 24
26struct platform_device *__init mxs_add_platform_device_dmamask( 25struct platform_device *__init mxs_add_platform_device_dmamask(
27 const char *name, int id, 26 const char *name, int id,
@@ -73,3 +72,17 @@ err:
73 72
74 return pdev; 73 return pdev;
75} 74}
75
76int __init mxs_add_amba_device(const struct amba_device *dev)
77{
78 struct amba_device *adev = kmalloc(sizeof(*adev), GFP_KERNEL);
79
80 if (!adev) {
81 pr_err("%s: failed to allocate memory", __func__);
82 return -ENOMEM;
83 }
84
85 *adev = *dev;
86
87 return amba_device_register(adev, &iomem_resource);
88}
diff --git a/arch/arm/mach-mxs/devices/Kconfig b/arch/arm/mach-mxs/devices/Kconfig
index a35a2dc55395..cf7dc1ae575b 100644
--- a/arch/arm/mach-mxs/devices/Kconfig
+++ b/arch/arm/mach-mxs/devices/Kconfig
@@ -1,5 +1,6 @@
1config MXS_HAVE_PLATFORM_DUART 1config MXS_HAVE_AMBA_DUART
2 bool 2 bool
3 select ARM_AMBA
3 4
4config MXS_HAVE_PLATFORM_FEC 5config MXS_HAVE_PLATFORM_FEC
5 bool 6 bool
diff --git a/arch/arm/mach-mxs/devices/Makefile b/arch/arm/mach-mxs/devices/Makefile
index 4b5266a3e6d9..d0a09f6934b8 100644
--- a/arch/arm/mach-mxs/devices/Makefile
+++ b/arch/arm/mach-mxs/devices/Makefile
@@ -1,2 +1,2 @@
1obj-$(CONFIG_MXS_HAVE_PLATFORM_DUART) += platform-duart.o 1obj-$(CONFIG_MXS_HAVE_AMBA_DUART) += amba-duart.o
2obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o 2obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o
diff --git a/arch/arm/mach-mxs/devices/amba-duart.c b/arch/arm/mach-mxs/devices/amba-duart.c
new file mode 100644
index 000000000000..a559db09b49c
--- /dev/null
+++ b/arch/arm/mach-mxs/devices/amba-duart.c
@@ -0,0 +1,40 @@
1/*
2 * Copyright (C) 2009-2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
5 * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License version 2 as published by the
9 * Free Software Foundation.
10 */
11#include <asm/irq.h>
12#include <mach/mx23.h>
13#include <mach/mx28.h>
14#include <mach/devices-common.h>
15
16#define MXS_AMBA_DUART_DEVICE(name, soc) \
17const struct amba_device name##_device __initconst = { \
18 .dev = { \
19 .init_name = "duart", \
20 }, \
21 .res = { \
22 .start = soc ## _DUART_BASE_ADDR, \
23 .end = (soc ## _DUART_BASE_ADDR) + SZ_8K - 1, \
24 .flags = IORESOURCE_MEM, \
25 }, \
26 .irq = {soc ## _INT_DUART, NO_IRQ}, \
27}
28
29#ifdef CONFIG_SOC_IMX23
30MXS_AMBA_DUART_DEVICE(mx23_duart, MX23);
31#endif
32
33#ifdef CONFIG_SOC_IMX28
34MXS_AMBA_DUART_DEVICE(mx28_duart, MX28);
35#endif
36
37int __init mxs_add_duart(const struct amba_device *dev)
38{
39 return mxs_add_amba_device(dev);
40}
diff --git a/arch/arm/mach-mxs/devices/platform-duart.c b/arch/arm/mach-mxs/devices/platform-duart.c
deleted file mode 100644
index 2fe0df5b0aad..000000000000
--- a/arch/arm/mach-mxs/devices/platform-duart.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 * Copyright (C) 2009-2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
5 * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License version 2 as published by the
9 * Free Software Foundation.
10 */
11#include <mach/mx23.h>
12#include <mach/mx28.h>
13#include <mach/devices-common.h>
14
15#define mxs_duart_data_entry(soc) \
16 { \
17 .iobase = soc ## _DUART_BASE_ADDR, \
18 .irq = soc ## _INT_DUART, \
19 }
20
21#ifdef CONFIG_SOC_IMX23
22const struct mxs_duart_data mx23_duart_data __initconst =
23 mxs_duart_data_entry(MX23);
24#endif
25
26#ifdef CONFIG_SOC_IMX28
27const struct mxs_duart_data mx28_duart_data __initconst =
28 mxs_duart_data_entry(MX28);
29#endif
30
31struct platform_device *__init mxs_add_duart(
32 const struct mxs_duart_data *data)
33{
34 struct resource res[] = {
35 {
36 .start = data->iobase,
37 .end = data->iobase + SZ_8K - 1,
38 .flags = IORESOURCE_MEM,
39 }, {
40 .start = data->irq,
41 .end = data->irq,
42 .flags = IORESOURCE_IRQ,
43 },
44 };
45
46 return mxs_add_platform_device("mxs-duart", 0, res, ARRAY_SIZE(res),
47 NULL, 0);
48}
diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h
index 3da48d4d3273..6c3d1a103433 100644
--- a/arch/arm/mach-mxs/include/mach/devices-common.h
+++ b/arch/arm/mach-mxs/include/mach/devices-common.h
@@ -9,6 +9,7 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/amba/bus.h>
12 13
13struct platform_device *mxs_add_platform_device_dmamask( 14struct platform_device *mxs_add_platform_device_dmamask(
14 const char *name, int id, 15 const char *name, int id,
@@ -24,14 +25,10 @@ static inline struct platform_device *mxs_add_platform_device(
24 name, id, res, num_resources, data, size_data, 0); 25 name, id, res, num_resources, data, size_data, 0);
25} 26}
26 27
28int __init mxs_add_amba_device(const struct amba_device *dev);
29
27/* duart */ 30/* duart */
28struct mxs_duart_data { 31int __init mxs_add_duart(const struct amba_device *dev);
29 resource_size_t iobase;
30 resource_size_t iosize;
31 resource_size_t irq;
32};
33struct platform_device *__init mxs_add_duart(
34 const struct mxs_duart_data *data);
35 32
36/* fec */ 33/* fec */
37#include <linux/fec.h> 34#include <linux/fec.h>