i2c.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include <mach/i2c.h>
  19. static struct i2c_adapter pnx_adapter0 = {
  20. .name = I2C_CHIP_NAME "0",
  21. };
  22. static struct i2c_adapter pnx_adapter1 = {
  23. .name = I2C_CHIP_NAME "1",
  24. };
  25. static struct i2c_adapter pnx_adapter2 = {
  26. .name = "USB-I2C",
  27. };
  28. static struct i2c_pnx_data i2c0_data = {
  29. .adapter = &pnx_adapter0,
  30. .base = PNX4008_I2C1_BASE,
  31. .irq = I2C_1_INT,
  32. };
  33. static struct i2c_pnx_data i2c1_data = {
  34. .adapter = &pnx_adapter1,
  35. .base = PNX4008_I2C2_BASE,
  36. .irq = I2C_2_INT,
  37. };
  38. static struct i2c_pnx_data i2c2_data = {
  39. .adapter = &pnx_adapter2,
  40. .base = (PNX4008_USB_CONFIG_BASE + 0x300),
  41. .irq = USB_I2C_INT,
  42. };
  43. static struct platform_device i2c0_device = {
  44. .name = "pnx-i2c",
  45. .id = 0,
  46. .dev = {
  47. .platform_data = &i2c0_data,
  48. },
  49. };
  50. static struct platform_device i2c1_device = {
  51. .name = "pnx-i2c",
  52. .id = 1,
  53. .dev = {
  54. .platform_data = &i2c1_data,
  55. },
  56. };
  57. static struct platform_device i2c2_device = {
  58. .name = "pnx-i2c",
  59. .id = 2,
  60. .dev = {
  61. .platform_data = &i2c2_data,
  62. },
  63. };
  64. static struct platform_device *devices[] __initdata = {
  65. &i2c0_device,
  66. &i2c1_device,
  67. &i2c2_device,
  68. };
  69. void __init pnx4008_register_i2c_devices(void)
  70. {
  71. platform_add_devices(devices, ARRAY_SIZE(devices));
  72. }