platform-flexcan.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) 2010 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU General Public License version 2 as published by the
  6. * Free Software Foundation.
  7. */
  8. #include <mach/hardware.h>
  9. #include <mach/devices-common.h>
  10. #define imx_flexcan_data_entry_single(soc, _id, _hwid, _size) \
  11. { \
  12. .id = _id, \
  13. .iobase = soc ## _CAN ## _hwid ## _BASE_ADDR, \
  14. .iosize = _size, \
  15. .irq = soc ## _INT_CAN ## _hwid, \
  16. }
  17. #define imx_flexcan_data_entry(soc, _id, _hwid, _size) \
  18. [_id] = imx_flexcan_data_entry_single(soc, _id, _hwid, _size)
  19. #ifdef CONFIG_SOC_IMX25
  20. const struct imx_flexcan_data imx25_flexcan_data[] __initconst = {
  21. #define imx25_flexcan_data_entry(_id, _hwid) \
  22. imx_flexcan_data_entry(MX25, _id, _hwid, SZ_16K)
  23. imx25_flexcan_data_entry(0, 1),
  24. imx25_flexcan_data_entry(1, 2),
  25. };
  26. #endif /* ifdef CONFIG_SOC_IMX25 */
  27. #ifdef CONFIG_SOC_IMX35
  28. const struct imx_flexcan_data imx35_flexcan_data[] __initconst = {
  29. #define imx35_flexcan_data_entry(_id, _hwid) \
  30. imx_flexcan_data_entry(MX35, _id, _hwid, SZ_16K)
  31. imx35_flexcan_data_entry(0, 1),
  32. imx35_flexcan_data_entry(1, 2),
  33. };
  34. #endif /* ifdef CONFIG_SOC_IMX35 */
  35. struct platform_device *__init imx_add_flexcan(
  36. const struct imx_flexcan_data *data,
  37. const struct flexcan_platform_data *pdata)
  38. {
  39. struct resource res[] = {
  40. {
  41. .start = data->iobase,
  42. .end = data->iobase + data->iosize - 1,
  43. .flags = IORESOURCE_MEM,
  44. }, {
  45. .start = data->irq,
  46. .end = data->irq,
  47. .flags = IORESOURCE_IRQ,
  48. },
  49. };
  50. return imx_add_platform_device("flexcan", data->id,
  51. res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
  52. }