platform-imx-i2c.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (C) 2009-2010 Pengutronix
  3. * Uwe Kleine-Koenig <u.kleine-koenig@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 "../hardware.h"
  10. #include "devices-common.h"
  11. #define imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size) \
  12. { \
  13. .devid = _devid, \
  14. .id = _id, \
  15. .iobase = soc ## _I2C ## _hwid ## _BASE_ADDR, \
  16. .iosize = _size, \
  17. .irq = soc ## _INT_I2C ## _hwid, \
  18. }
  19. #define imx_imx_i2c_data_entry(soc, _devid, _id, _hwid, _size) \
  20. [_id] = imx_imx_i2c_data_entry_single(soc, _devid, _id, _hwid, _size)
  21. #ifdef CONFIG_SOC_IMX21
  22. const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst =
  23. imx_imx_i2c_data_entry_single(MX21, "imx21-i2c", 0, , SZ_4K);
  24. #endif /* ifdef CONFIG_SOC_IMX21 */
  25. #ifdef CONFIG_SOC_IMX27
  26. const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst = {
  27. #define imx27_imx_i2c_data_entry(_id, _hwid) \
  28. imx_imx_i2c_data_entry(MX27, "imx21-i2c", _id, _hwid, SZ_4K)
  29. imx27_imx_i2c_data_entry(0, 1),
  30. imx27_imx_i2c_data_entry(1, 2),
  31. };
  32. #endif /* ifdef CONFIG_SOC_IMX27 */
  33. #ifdef CONFIG_SOC_IMX31
  34. const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = {
  35. #define imx31_imx_i2c_data_entry(_id, _hwid) \
  36. imx_imx_i2c_data_entry(MX31, "imx21-i2c", _id, _hwid, SZ_4K)
  37. imx31_imx_i2c_data_entry(0, 1),
  38. imx31_imx_i2c_data_entry(1, 2),
  39. imx31_imx_i2c_data_entry(2, 3),
  40. };
  41. #endif /* ifdef CONFIG_SOC_IMX31 */
  42. #ifdef CONFIG_SOC_IMX35
  43. const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = {
  44. #define imx35_imx_i2c_data_entry(_id, _hwid) \
  45. imx_imx_i2c_data_entry(MX35, "imx21-i2c", _id, _hwid, SZ_4K)
  46. imx35_imx_i2c_data_entry(0, 1),
  47. imx35_imx_i2c_data_entry(1, 2),
  48. imx35_imx_i2c_data_entry(2, 3),
  49. };
  50. #endif /* ifdef CONFIG_SOC_IMX35 */
  51. struct platform_device *__init imx_add_imx_i2c(
  52. const struct imx_imx_i2c_data *data,
  53. const struct imxi2c_platform_data *pdata)
  54. {
  55. struct resource res[] = {
  56. {
  57. .start = data->iobase,
  58. .end = data->iobase + data->iosize - 1,
  59. .flags = IORESOURCE_MEM,
  60. }, {
  61. .start = data->irq,
  62. .end = data->irq,
  63. .flags = IORESOURCE_IRQ,
  64. },
  65. };
  66. return imx_add_platform_device(data->devid, data->id,
  67. res, ARRAY_SIZE(res),
  68. pdata, sizeof(*pdata));
  69. }