/arch/arm/mach-mxs/devices/platform-mxs-i2c.c

https://github.com/AICP/kernel_asus_grouper · C · 52 lines · 39 code · 5 blank · 8 comment · 0 complexity · abdbddc33e805db69b7a0cae614b951d MD5 · raw file

  1. /*
  2. * Copyright (C) 2011 Pengutronix
  3. * Wolfram Sang <w.sang@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_i2c_data_entry_single(soc, _id) \
  13. { \
  14. .id = _id, \
  15. .iobase = soc ## _I2C ## _id ## _BASE_ADDR, \
  16. .errirq = soc ## _INT_I2C ## _id ## _ERROR, \
  17. .dmairq = soc ## _INT_I2C ## _id ## _DMA, \
  18. }
  19. #define mxs_i2c_data_entry(soc, _id) \
  20. [_id] = mxs_i2c_data_entry_single(soc, _id)
  21. #ifdef CONFIG_SOC_IMX28
  22. const struct mxs_mxs_i2c_data mx28_mxs_i2c_data[] __initconst = {
  23. mxs_i2c_data_entry(MX28, 0),
  24. mxs_i2c_data_entry(MX28, 1),
  25. };
  26. #endif
  27. struct platform_device *__init mxs_add_mxs_i2c(
  28. const struct mxs_mxs_i2c_data *data)
  29. {
  30. struct resource res[] = {
  31. {
  32. .start = data->iobase,
  33. .end = data->iobase + SZ_8K - 1,
  34. .flags = IORESOURCE_MEM,
  35. }, {
  36. .start = data->errirq,
  37. .end = data->errirq,
  38. .flags = IORESOURCE_IRQ,
  39. }, {
  40. .start = data->dmairq,
  41. .end = data->dmairq,
  42. .flags = IORESOURCE_IRQ,
  43. },
  44. };
  45. return mxs_add_platform_device("mxs-i2c", data->id, res,
  46. ARRAY_SIZE(res), NULL, 0);
  47. }