]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/plat-mxc/devices/platform-mxc_pwm.c
3d8ebdba38eed86771e3bdd6dab97fa7e3d73c18
[karo-tx-linux.git] / arch / arm / plat-mxc / devices / platform-mxc_pwm.c
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, _id, _hwid, _size)           \
13         {                                                               \
14                 .id = _id,                                              \
15                 .iobase = soc ## _PWM ## _hwid ## _BASE_ADDR,           \
16                 .iosize = _size,                                        \
17                 .irq = soc ## _INT_PWM ## _hwid,                        \
18         }
19 #define imx_mxc_pwm_data_entry(soc, _id, _hwid, _size)                  \
20         [_id] = imx_mxc_pwm_data_entry_single(soc, _id, _hwid, _size)
21
22 #ifdef CONFIG_SOC_IMX21
23 const struct imx_mxc_pwm_data imx21_mxc_pwm_data __initconst =
24         imx_mxc_pwm_data_entry_single(MX21, 0, , SZ_4K);
25 #endif /* ifdef CONFIG_SOC_IMX21 */
26
27 #ifdef CONFIG_SOC_IMX25
28 const struct imx_mxc_pwm_data imx25_mxc_pwm_data[] __initconst = {
29 #define imx25_mxc_pwm_data_entry(_id, _hwid)                            \
30         imx_mxc_pwm_data_entry(MX25, _id, _hwid, SZ_16K)
31         imx25_mxc_pwm_data_entry(0, 1),
32         imx25_mxc_pwm_data_entry(1, 2),
33         imx25_mxc_pwm_data_entry(2, 3),
34         imx25_mxc_pwm_data_entry(3, 4),
35 };
36 #endif /* ifdef CONFIG_SOC_IMX25 */
37
38 #ifdef CONFIG_SOC_IMX27
39 const struct imx_mxc_pwm_data imx27_mxc_pwm_data __initconst =
40         imx_mxc_pwm_data_entry_single(MX27, 0, , SZ_4K);
41 #endif /* ifdef CONFIG_SOC_IMX27 */
42
43 struct platform_device *__init imx_add_mxc_pwm(
44                 const struct imx_mxc_pwm_data *data)
45 {
46         struct resource res[] = {
47                 {
48                         .start = data->iobase,
49                         .end = data->iobase + data->iosize - 1,
50                         .flags = IORESOURCE_MEM,
51                 }, {
52                         .start = data->irq,
53                         .end = data->irq,
54                         .flags = IORESOURCE_IRQ,
55                 },
56         };
57
58         return imx_add_platform_device("mxc_pwm", data->id,
59                         res, ARRAY_SIZE(res), NULL, 0);
60 }