i2c-8815nhk.c 2.2 KB

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