i2c-8815nhk.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include <linux/module.h>
  2. #include <linux/init.h>
  3. #include <linux/i2c.h>
  4. #include <linux/i2c-algo-bit.h>
  5. #include <linux/i2c-gpio.h>
  6. #include <linux/platform_device.h>
  7. #include <plat/gpio-nomadik.h>
  8. #include <plat/pincfg.h>
  9. /*
  10. * There are two busses in the 8815NHK.
  11. * They could, in theory, be driven by the hardware component, but we
  12. * use bit-bang through GPIO by now, to keep things simple
  13. */
  14. /* I2C0 connected to the STw4811 power management chip */
  15. static struct i2c_gpio_platform_data nhk8815_i2c_data0 = {
  16. /* keep defaults for timeouts; pins are push-pull bidirectional */
  17. .scl_pin = 62,
  18. .sda_pin = 63,
  19. };
  20. /* I2C1 connected to various sensors */
  21. static struct i2c_gpio_platform_data nhk8815_i2c_data1 = {
  22. /* keep defaults for timeouts; pins are push-pull bidirectional */
  23. .scl_pin = 53,
  24. .sda_pin = 54,
  25. };
  26. /* I2C2 connected to the USB portions of the STw4811 only */
  27. static struct i2c_gpio_platform_data nhk8815_i2c_data2 = {
  28. /* keep defaults for timeouts; pins are push-pull bidirectional */
  29. .scl_pin = 73,
  30. .sda_pin = 74,
  31. };
  32. static struct platform_device nhk8815_i2c_dev0 = {
  33. .name = "i2c-gpio",
  34. .id = 0,
  35. .dev = {
  36. .platform_data = &nhk8815_i2c_data0,
  37. },
  38. };
  39. static struct platform_device nhk8815_i2c_dev1 = {
  40. .name = "i2c-gpio",
  41. .id = 1,
  42. .dev = {
  43. .platform_data = &nhk8815_i2c_data1,
  44. },
  45. };
  46. static struct platform_device nhk8815_i2c_dev2 = {
  47. .name = "i2c-gpio",
  48. .id = 2,
  49. .dev = {
  50. .platform_data = &nhk8815_i2c_data2,
  51. },
  52. };
  53. static pin_cfg_t cpu8815_pins_i2c[] = {
  54. PIN_CFG_INPUT(62, GPIO, PULLUP),
  55. PIN_CFG_INPUT(63, GPIO, PULLUP),
  56. PIN_CFG_INPUT(53, GPIO, PULLUP),
  57. PIN_CFG_INPUT(54, GPIO, PULLUP),
  58. PIN_CFG_INPUT(73, GPIO, PULLUP),
  59. PIN_CFG_INPUT(74, GPIO, PULLUP),
  60. };
  61. static int __init nhk8815_i2c_init(void)
  62. {
  63. nmk_config_pins(cpu8815_pins_i2c, ARRAY_SIZE(cpu8815_pins_i2c));
  64. platform_device_register(&nhk8815_i2c_dev0);
  65. platform_device_register(&nhk8815_i2c_dev1);
  66. platform_device_register(&nhk8815_i2c_dev2);
  67. return 0;
  68. }
  69. static void __exit nhk8815_i2c_exit(void)
  70. {
  71. platform_device_unregister(&nhk8815_i2c_dev0);
  72. platform_device_unregister(&nhk8815_i2c_dev1);
  73. platform_device_unregister(&nhk8815_i2c_dev2);
  74. return;
  75. }
  76. module_init(nhk8815_i2c_init);
  77. module_exit(nhk8815_i2c_exit);