i2c.c 1.9 KB

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