platform-flexcan.c 1.6 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 "../hardware.h"
  9. #include "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. {
  38. struct resource res[] = {
  39. {
  40. .start = data->iobase,
  41. .end = data->iobase + data->iosize - 1,
  42. .flags = IORESOURCE_MEM,
  43. }, {
  44. .start = data->irq,
  45. .end = data->irq,
  46. .flags = IORESOURCE_IRQ,
  47. },
  48. };
  49. return imx_add_platform_device("flexcan", data->id,
  50. res, ARRAY_SIZE(res), NULL, 0);
  51. }