platform-flexcan.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (C) 2010, 2011 Pengutronix,
  3. * Marc Kleine-Budde <kernel@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 <asm/sizes.h>
  10. #include <mach/mx28.h>
  11. #include <mach/devices-common.h>
  12. #define mxs_flexcan_data_entry_single(soc, _id, _hwid, _size) \
  13. { \
  14. .id = _id, \
  15. .iobase = soc ## _CAN ## _hwid ## _BASE_ADDR, \
  16. .iosize = _size, \
  17. .irq = soc ## _INT_CAN ## _hwid, \
  18. }
  19. #define mxs_flexcan_data_entry(soc, _id, _hwid, _size) \
  20. [_id] = mxs_flexcan_data_entry_single(soc, _id, _hwid, _size)
  21. #ifdef CONFIG_SOC_IMX28
  22. const struct mxs_flexcan_data mx28_flexcan_data[] __initconst = {
  23. #define mx28_flexcan_data_entry(_id, _hwid) \
  24. mxs_flexcan_data_entry_single(MX28, _id, _hwid, SZ_8K)
  25. mx28_flexcan_data_entry(0, 0),
  26. mx28_flexcan_data_entry(1, 1),
  27. };
  28. #endif /* ifdef CONFIG_SOC_IMX28 */
  29. struct platform_device *__init mxs_add_flexcan(
  30. const struct mxs_flexcan_data *data,
  31. const struct flexcan_platform_data *pdata)
  32. {
  33. struct resource res[] = {
  34. {
  35. .start = data->iobase,
  36. .end = data->iobase + data->iosize - 1,
  37. .flags = IORESOURCE_MEM,
  38. }, {
  39. .start = data->irq,
  40. .end = data->irq,
  41. .flags = IORESOURCE_IRQ,
  42. },
  43. };
  44. return mxs_add_platform_device("flexcan", data->id,
  45. res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
  46. }