platform-flexcan.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_IMX35
  20. const struct imx_flexcan_data imx35_flexcan_data[] __initconst = {
  21. #define imx35_flexcan_data_entry(_id, _hwid) \
  22. imx_flexcan_data_entry(MX35, _id, _hwid, SZ_16K)
  23. imx35_flexcan_data_entry(0, 1),
  24. imx35_flexcan_data_entry(1, 2),
  25. };
  26. #endif /* ifdef CONFIG_SOC_IMX35 */
  27. struct platform_device *__init imx_add_flexcan(
  28. const struct imx_flexcan_data *data)
  29. {
  30. struct resource res[] = {
  31. {
  32. .start = data->iobase,
  33. .end = data->iobase + data->iosize - 1,
  34. .flags = IORESOURCE_MEM,
  35. }, {
  36. .start = data->irq,
  37. .end = data->irq,
  38. .flags = IORESOURCE_IRQ,
  39. },
  40. };
  41. return imx_add_platform_device("flexcan", data->id,
  42. res, ARRAY_SIZE(res), NULL, 0);
  43. }