Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
platform-mxc_pwm.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2010 Pengutronix
3  * Uwe Kleine-Koenig <[email protected]>
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 =
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 =
41 #endif /* ifdef CONFIG_SOC_IMX27 */
42 
43 #ifdef CONFIG_SOC_IMX51
44 const struct imx_mxc_pwm_data imx51_mxc_pwm_data[] __initconst = {
45 #define imx51_mxc_pwm_data_entry(_id, _hwid) \
46  imx_mxc_pwm_data_entry(MX51, _id, _hwid, SZ_16K)
47  imx51_mxc_pwm_data_entry(0, 1),
48  imx51_mxc_pwm_data_entry(1, 2),
49 };
50 #endif /* ifdef CONFIG_SOC_IMX51 */
51 
53  const struct imx_mxc_pwm_data *data)
54 {
55  struct resource res[] = {
56  {
57  .start = data->iobase,
58  .end = data->iobase + data->iosize - 1,
59  .flags = IORESOURCE_MEM,
60  }, {
61  .start = data->irq,
62  .end = data->irq,
63  .flags = IORESOURCE_IRQ,
64  },
65  };
66 
67  return imx_add_platform_device("mxc_pwm", data->id,
68  res, ARRAY_SIZE(res), NULL, 0);
69 }