Commit dbc4245b authored by Shawn Guo's avatar Shawn Guo Committed by Sascha Hauer

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: default avatarShawn Guo <shawn.guo@freescale.com>
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
parent 48f76ed1
...@@ -15,7 +15,7 @@ comment "MXS platforms:" ...@@ -15,7 +15,7 @@ comment "MXS platforms:"
config MACH_MX23EVK config MACH_MX23EVK
bool "Support MX23EVK Platform" bool "Support MX23EVK Platform"
select SOC_IMX23 select SOC_IMX23
select MXS_HAVE_PLATFORM_DUART select MXS_HAVE_AMBA_DUART
default y default y
help help
Include support for MX23EVK platform. This includes specific Include support for MX23EVK platform. This includes specific
...@@ -24,7 +24,7 @@ config MACH_MX23EVK ...@@ -24,7 +24,7 @@ config MACH_MX23EVK
config MACH_MX28EVK config MACH_MX28EVK
bool "Support MX28EVK Platform" bool "Support MX28EVK Platform"
select SOC_IMX28 select SOC_IMX28
select MXS_HAVE_PLATFORM_DUART select MXS_HAVE_AMBA_DUART
select MXS_HAVE_PLATFORM_FEC select MXS_HAVE_PLATFORM_FEC
default y default y
help help
......
...@@ -437,10 +437,12 @@ _DEFINE_CLOCK(clk32k_clk, XTAL, TIMROT_CLK32K_GATE, &ref_xtal_clk); ...@@ -437,10 +437,12 @@ _DEFINE_CLOCK(clk32k_clk, XTAL, TIMROT_CLK32K_GATE, &ref_xtal_clk);
}, },
static struct clk_lookup lookups[] = { static struct clk_lookup lookups[] = {
_REGISTER_CLOCK("mxs-duart.0", NULL, uart_clk) /* for amba bus driver */
_REGISTER_CLOCK("duart", "apb_pclk", xbus_clk)
/* for amba-pl011 driver */
_REGISTER_CLOCK("duart", NULL, uart_clk)
_REGISTER_CLOCK("rtc", NULL, rtc_clk) _REGISTER_CLOCK("rtc", NULL, rtc_clk)
_REGISTER_CLOCK(NULL, "hclk", hbus_clk) _REGISTER_CLOCK(NULL, "hclk", hbus_clk)
_REGISTER_CLOCK(NULL, "xclk", xbus_clk)
_REGISTER_CLOCK(NULL, "usb", usb_clk) _REGISTER_CLOCK(NULL, "usb", usb_clk)
_REGISTER_CLOCK(NULL, "audio", audio_clk) _REGISTER_CLOCK(NULL, "audio", audio_clk)
_REGISTER_CLOCK(NULL, "pwm", pwm_clk) _REGISTER_CLOCK(NULL, "pwm", pwm_clk)
...@@ -518,6 +520,12 @@ int __init mx23_clocks_init(void) ...@@ -518,6 +520,12 @@ int __init mx23_clocks_init(void)
{ {
clk_misc_init(); clk_misc_init();
clk_enable(&cpu_clk);
clk_enable(&hbus_clk);
clk_enable(&xbus_clk);
clk_enable(&emi_clk);
clk_enable(&uart_clk);
clkdev_add_table(lookups, ARRAY_SIZE(lookups)); clkdev_add_table(lookups, ARRAY_SIZE(lookups));
mxs_timer_init(&clk32k_clk, MX23_INT_TIMER0); mxs_timer_init(&clk32k_clk, MX23_INT_TIMER0);
......
...@@ -602,7 +602,10 @@ _DEFINE_CLOCK(fec_clk, ENET, DISABLE, &hbus_clk); ...@@ -602,7 +602,10 @@ _DEFINE_CLOCK(fec_clk, ENET, DISABLE, &hbus_clk);
}, },
static struct clk_lookup lookups[] = { static struct clk_lookup lookups[] = {
_REGISTER_CLOCK("mxs-duart.0", NULL, uart_clk) /* for amba bus driver */
_REGISTER_CLOCK("duart", "apb_pclk", xbus_clk)
/* for amba-pl011 driver */
_REGISTER_CLOCK("duart", NULL, uart_clk)
_REGISTER_CLOCK("imx28-fec.0", NULL, fec_clk) _REGISTER_CLOCK("imx28-fec.0", NULL, fec_clk)
_REGISTER_CLOCK("imx28-fec.1", NULL, fec_clk) _REGISTER_CLOCK("imx28-fec.1", NULL, fec_clk)
_REGISTER_CLOCK("fec.0", NULL, fec_clk) _REGISTER_CLOCK("fec.0", NULL, fec_clk)
...@@ -728,6 +731,12 @@ int __init mx28_clocks_init(void) ...@@ -728,6 +731,12 @@ int __init mx28_clocks_init(void)
{ {
clk_misc_init(); clk_misc_init();
clk_enable(&cpu_clk);
clk_enable(&hbus_clk);
clk_enable(&xbus_clk);
clk_enable(&emi_clk);
clk_enable(&uart_clk);
clkdev_add_table(lookups, ARRAY_SIZE(lookups)); clkdev_add_table(lookups, ARRAY_SIZE(lookups));
mxs_timer_init(&clk32k_clk, MX28_INT_TIMER0); mxs_timer_init(&clk32k_clk, MX28_INT_TIMER0);
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#include <mach/mx23.h> #include <mach/mx23.h>
#include <mach/devices-common.h> #include <mach/devices-common.h>
extern const struct mxs_duart_data mx23_duart_data __initconst; extern const struct amba_device mx23_duart_device __initconst;
#define mx23_add_duart() \ #define mx23_add_duart() \
mxs_add_duart(&mx23_duart_data) mxs_add_duart(&mx23_duart_device)
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
#include <mach/mx28.h> #include <mach/mx28.h>
#include <mach/devices-common.h> #include <mach/devices-common.h>
extern const struct mxs_duart_data mx28_duart_data __initconst; extern const struct amba_device mx28_duart_device __initconst;
#define mx28_add_duart() \ #define mx28_add_duart() \
mxs_add_duart(&mx28_duart_data) mxs_add_duart(&mx28_duart_device)
extern const struct mxs_fec_data mx28_fec_data[] __initconst; extern const struct mxs_fec_data mx28_fec_data[] __initconst;
#define mx28_add_fec(id, pdata) \ #define mx28_add_fec(id, pdata) \
......
...@@ -19,9 +19,8 @@ ...@@ -19,9 +19,8 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <mach/common.h> #include <linux/amba/bus.h>
struct platform_device *__init mxs_add_platform_device_dmamask( struct platform_device *__init mxs_add_platform_device_dmamask(
const char *name, int id, const char *name, int id,
...@@ -73,3 +72,17 @@ struct platform_device *__init mxs_add_platform_device_dmamask( ...@@ -73,3 +72,17 @@ struct platform_device *__init mxs_add_platform_device_dmamask(
return pdev; return pdev;
} }
int __init mxs_add_amba_device(const struct amba_device *dev)
{
struct amba_device *adev = kmalloc(sizeof(*adev), GFP_KERNEL);
if (!adev) {
pr_err("%s: failed to allocate memory", __func__);
return -ENOMEM;
}
*adev = *dev;
return amba_device_register(adev, &iomem_resource);
}
config MXS_HAVE_PLATFORM_DUART config MXS_HAVE_AMBA_DUART
bool bool
select ARM_AMBA
config MXS_HAVE_PLATFORM_FEC config MXS_HAVE_PLATFORM_FEC
bool bool
obj-$(CONFIG_MXS_HAVE_PLATFORM_DUART) += platform-duart.o obj-$(CONFIG_MXS_HAVE_AMBA_DUART) += amba-duart.o
obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o
...@@ -8,41 +8,33 @@ ...@@ -8,41 +8,33 @@
* the terms of the GNU General Public License version 2 as published by the * the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation. * Free Software Foundation.
*/ */
#include <asm/irq.h>
#include <mach/mx23.h> #include <mach/mx23.h>
#include <mach/mx28.h> #include <mach/mx28.h>
#include <mach/devices-common.h> #include <mach/devices-common.h>
#define mxs_duart_data_entry(soc) \ #define MXS_AMBA_DUART_DEVICE(name, soc) \
{ \ const struct amba_device name##_device __initconst = { \
.iobase = soc ## _DUART_BASE_ADDR, \ .dev = { \
.irq = soc ## _INT_DUART, \ .init_name = "duart", \
} }, \
.res = { \
.start = soc ## _DUART_BASE_ADDR, \
.end = (soc ## _DUART_BASE_ADDR) + SZ_8K - 1, \
.flags = IORESOURCE_MEM, \
}, \
.irq = {soc ## _INT_DUART, NO_IRQ}, \
}
#ifdef CONFIG_SOC_IMX23 #ifdef CONFIG_SOC_IMX23
const struct mxs_duart_data mx23_duart_data __initconst = MXS_AMBA_DUART_DEVICE(mx23_duart, MX23);
mxs_duart_data_entry(MX23);
#endif #endif
#ifdef CONFIG_SOC_IMX28 #ifdef CONFIG_SOC_IMX28
const struct mxs_duart_data mx28_duart_data __initconst = MXS_AMBA_DUART_DEVICE(mx28_duart, MX28);
mxs_duart_data_entry(MX28);
#endif #endif
struct platform_device *__init mxs_add_duart( int __init mxs_add_duart(const struct amba_device *dev)
const struct mxs_duart_data *data)
{ {
struct resource res[] = { return mxs_add_amba_device(dev);
{
.start = data->iobase,
.end = data->iobase + SZ_8K - 1,
.flags = IORESOURCE_MEM,
}, {
.start = data->irq,
.end = data->irq,
.flags = IORESOURCE_IRQ,
},
};
return mxs_add_platform_device("mxs-duart", 0, res, ARRAY_SIZE(res),
NULL, 0);
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/amba/bus.h>
struct platform_device *mxs_add_platform_device_dmamask( struct platform_device *mxs_add_platform_device_dmamask(
const char *name, int id, const char *name, int id,
...@@ -24,14 +25,10 @@ static inline struct platform_device *mxs_add_platform_device( ...@@ -24,14 +25,10 @@ static inline struct platform_device *mxs_add_platform_device(
name, id, res, num_resources, data, size_data, 0); name, id, res, num_resources, data, size_data, 0);
} }
int __init mxs_add_amba_device(const struct amba_device *dev);
/* duart */ /* duart */
struct mxs_duart_data { int __init mxs_add_duart(const struct amba_device *dev);
resource_size_t iobase;
resource_size_t iosize;
resource_size_t irq;
};
struct platform_device *__init mxs_add_duart(
const struct mxs_duart_data *data);
/* fec */ /* fec */
#include <linux/fec.h> #include <linux/fec.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment