i2c.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * I2C initialization for PNX4008.
  3. *
  4. * Author: Vitaly Wool <vitalywool@gmail.com>
  5. *
  6. * 2005-2006 (c) MontaVista Software, Inc. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. */
  11. #include <linux/clk.h>
  12. #include <linux/i2c.h>
  13. #include <linux/i2c-pnx.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/err.h>
  16. #include <mach/platform.h>
  17. #include <mach/irqs.h>
  18. static struct resource i2c0_resources[] = {
  19. {
  20. .start = PNX4008_I2C1_BASE,
  21. .end = PNX4008_I2C1_BASE + SZ_4K - 1,
  22. .flags = IORESOURCE_MEM,
  23. }, {
  24. .start = I2C_1_INT,
  25. .end = I2C_1_INT,
  26. .flags = IORESOURCE_IRQ,
  27. },
  28. };
  29. static struct resource i2c1_resources[] = {
  30. {
  31. .start = PNX4008_I2C2_BASE,
  32. .end = PNX4008_I2C2_BASE + SZ_4K - 1,
  33. .flags = IORESOURCE_MEM,
  34. }, {
  35. .start = I2C_2_INT,
  36. .end = I2C_2_INT,
  37. .flags = IORESOURCE_IRQ,
  38. },
  39. };
  40. static struct resource i2c2_resources[] = {
  41. {
  42. .start = PNX4008_USB_CONFIG_BASE + 0x300,
  43. .end = PNX4008_USB_CONFIG_BASE + 0x300 + SZ_4K - 1,
  44. .flags = IORESOURCE_MEM,
  45. }, {
  46. .start = USB_I2C_INT,
  47. .end = USB_I2C_INT,
  48. .flags = IORESOURCE_IRQ,
  49. },
  50. };
  51. static struct platform_device i2c0_device = {
  52. .name = "pnx-i2c.0",
  53. .id = 0,
  54. .resource = i2c0_resources,
  55. .num_resources = ARRAY_SIZE(i2c0_resources),
  56. };
  57. static struct platform_device i2c1_device = {
  58. .name = "pnx-i2c.1",
  59. .id = 1,
  60. .resource = i2c1_resources,
  61. .num_resources = ARRAY_SIZE(i2c1_resources),
  62. };
  63. static struct platform_device i2c2_device = {
  64. .name = "pnx-i2c.2",
  65. .id = 2,
  66. .resource = i2c2_resources,
  67. .num_resources = ARRAY_SIZE(i2c2_resources),
  68. };
  69. static struct platform_device *devices[] __initdata = {
  70. &i2c0_device,
  71. &i2c1_device,
  72. &i2c2_device,
  73. };
  74. void __init pnx4008_register_i2c_devices(void)
  75. {
  76. platform_add_devices(devices, ARRAY_SIZE(devices));
  77. }