platform-mxc_pwm.c 2.0 KB

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