diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2010-11-05 10:01:16 -0400 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2010-11-17 04:01:28 -0500 |
commit | bf182bcc6e726cce2f02b699bd0fba787734554f (patch) | |
tree | d5de2ac0de946eeafa21c262d6a8a12f85ce45a9 | |
parent | c06246576a6e71b72ecc6b4b39a5c8eaf45dc2ed (diff) |
ARM: imx: dynamically allocate mxc_pwm devices
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
-rw-r--r-- | arch/arm/mach-imx/devices.c | 19 | ||||
-rw-r--r-- | arch/arm/mach-imx/devices.h | 1 | ||||
-rw-r--r-- | arch/arm/plat-mxc/devices/Kconfig | 3 | ||||
-rw-r--r-- | arch/arm/plat-mxc/devices/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/plat-mxc/devices/platform-mxc_pwm.c | 45 | ||||
-rw-r--r-- | arch/arm/plat-mxc/include/mach/devices-common.h | 7 |
6 files changed, 56 insertions, 20 deletions
diff --git a/arch/arm/mach-imx/devices.c b/arch/arm/mach-imx/devices.c index d78456411f3f..9ee0e0924f55 100644 --- a/arch/arm/mach-imx/devices.c +++ b/arch/arm/mach-imx/devices.c | |||
@@ -77,25 +77,6 @@ int __init imx1_register_gpios(void) | |||
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27) | 79 | #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27) |
80 | static struct resource mxc_pwm_resources[] = { | ||
81 | { | ||
82 | .start = MX2x_PWM_BASE_ADDR, | ||
83 | .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1, | ||
84 | .flags = IORESOURCE_MEM, | ||
85 | }, { | ||
86 | .start = MX2x_INT_PWM, | ||
87 | .end = MX2x_INT_PWM, | ||
88 | .flags = IORESOURCE_IRQ, | ||
89 | } | ||
90 | }; | ||
91 | |||
92 | struct platform_device mxc_pwm_device = { | ||
93 | .name = "mxc_pwm", | ||
94 | .id = 0, | ||
95 | .num_resources = ARRAY_SIZE(mxc_pwm_resources), | ||
96 | .resource = mxc_pwm_resources, | ||
97 | }; | ||
98 | |||
99 | #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \ | 80 | #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \ |
100 | static struct resource mxc_sdhc_resources ## n[] = { \ | 81 | static struct resource mxc_sdhc_resources ## n[] = { \ |
101 | { \ | 82 | { \ |
diff --git a/arch/arm/mach-imx/devices.h b/arch/arm/mach-imx/devices.h index 407e90aa0bc4..1ba5042067ec 100644 --- a/arch/arm/mach-imx/devices.h +++ b/arch/arm/mach-imx/devices.h | |||
@@ -1,5 +1,4 @@ | |||
1 | #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27) | 1 | #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27) |
2 | extern struct platform_device mxc_pwm_device; | ||
3 | extern struct platform_device mxc_sdhc_device0; | 2 | extern struct platform_device mxc_sdhc_device0; |
4 | extern struct platform_device mxc_sdhc_device1; | 3 | extern struct platform_device mxc_sdhc_device1; |
5 | extern struct platform_device mxc_otg_udc_device; | 4 | extern struct platform_device mxc_otg_udc_device; |
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig index 25423713b498..2ded17b51fc2 100644 --- a/arch/arm/plat-mxc/devices/Kconfig +++ b/arch/arm/plat-mxc/devices/Kconfig | |||
@@ -40,6 +40,9 @@ config IMX_HAVE_PLATFORM_MX2_CAMERA | |||
40 | config IMX_HAVE_PLATFORM_MXC_NAND | 40 | config IMX_HAVE_PLATFORM_MXC_NAND |
41 | bool | 41 | bool |
42 | 42 | ||
43 | config IMX_HAVE_PLATFORM_MXC_PWM | ||
44 | bool | ||
45 | |||
43 | config IMX_HAVE_PLATFORM_MXC_W1 | 46 | config IMX_HAVE_PLATFORM_MXC_W1 |
44 | bool | 47 | bool |
45 | 48 | ||
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile index d3f845eea1ca..8ecd974c40e0 100644 --- a/arch/arm/plat-mxc/devices/Makefile +++ b/arch/arm/plat-mxc/devices/Makefile | |||
@@ -12,5 +12,6 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UDC) += platform-imx_udc.o | |||
12 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MX1_CAMERA) += platform-mx1-camera.o | 12 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MX1_CAMERA) += platform-mx1-camera.o |
13 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MX2_CAMERA) += platform-mx2-camera.o | 13 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MX2_CAMERA) += platform-mx2-camera.o |
14 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o | 14 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o |
15 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_PWM) += platform-mxc_pwm.o | ||
15 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_W1) += platform-mxc_w1.o | 16 | obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_W1) += platform-mxc_w1.o |
16 | obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o | 17 | obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o |
diff --git a/arch/arm/plat-mxc/devices/platform-mxc_pwm.c b/arch/arm/plat-mxc/devices/platform-mxc_pwm.c new file mode 100644 index 000000000000..3ebbc671638c --- /dev/null +++ b/arch/arm/plat-mxc/devices/platform-mxc_pwm.c | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009-2010 Pengutronix | ||
3 | * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it under | ||
6 | * the terms of the GNU General Public License version 2 as published by the | ||
7 | * Free Software Foundation. | ||
8 | */ | ||
9 | #include <mach/hardware.h> | ||
10 | #include <mach/devices-common.h> | ||
11 | |||
12 | #define imx_mxc_pwm_data_entry_single(soc) \ | ||
13 | { \ | ||
14 | .iobase = soc ## _PWM_BASE_ADDR, \ | ||
15 | .irq = soc ## _INT_PWM, \ | ||
16 | } | ||
17 | |||
18 | #ifdef CONFIG_SOC_IMX21 | ||
19 | const struct imx_mxc_pwm_data imx21_mxc_pwm_data __initconst = | ||
20 | imx_mxc_pwm_data_entry_single(MX21); | ||
21 | #endif /* ifdef CONFIG_SOC_IMX21 */ | ||
22 | |||
23 | #ifdef CONFIG_SOC_IMX27 | ||
24 | const struct imx_mxc_pwm_data imx27_mxc_pwm_data __initconst = | ||
25 | imx_mxc_pwm_data_entry_single(MX27); | ||
26 | #endif /* ifdef CONFIG_SOC_IMX27 */ | ||
27 | |||
28 | struct platform_device *__init imx_add_mxc_pwm( | ||
29 | const struct imx_mxc_pwm_data *data) | ||
30 | { | ||
31 | struct resource res[] = { | ||
32 | { | ||
33 | .start = data->iobase, | ||
34 | .end = data->iobase + SZ_4K - 1, | ||
35 | .flags = IORESOURCE_MEM, | ||
36 | }, { | ||
37 | .start = data->irq, | ||
38 | .end = data->irq, | ||
39 | .flags = IORESOURCE_IRQ, | ||
40 | }, | ||
41 | }; | ||
42 | |||
43 | return imx_add_platform_device("mxc_pwm", 0, | ||
44 | res, ARRAY_SIZE(res), NULL, 0); | ||
45 | } | ||
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h index b1d765634860..e241e41e7484 100644 --- a/arch/arm/plat-mxc/include/mach/devices-common.h +++ b/arch/arm/plat-mxc/include/mach/devices-common.h | |||
@@ -168,6 +168,13 @@ struct platform_device *__init imx_add_mxc_nand( | |||
168 | const struct imx_mxc_nand_data *data, | 168 | const struct imx_mxc_nand_data *data, |
169 | const struct mxc_nand_platform_data *pdata); | 169 | const struct mxc_nand_platform_data *pdata); |
170 | 170 | ||
171 | struct imx_mxc_pwm_data { | ||
172 | resource_size_t iobase; | ||
173 | resource_size_t irq; | ||
174 | }; | ||
175 | struct platform_device *__init imx_add_mxc_pwm( | ||
176 | const struct imx_mxc_pwm_data *data); | ||
177 | |||
171 | struct imx_mxc_w1_data { | 178 | struct imx_mxc_w1_data { |
172 | resource_size_t iobase; | 179 | resource_size_t iobase; |
173 | }; | 180 | }; |