i2c-8815nhk.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 <asm/mach-types.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 int __init nhk8815_i2c_init(void)
  53. {
  54. /* For e.g. devicetree boot */
  55. if (!machine_is_nomadik())
  56. return 0;
  57. platform_device_register(&nhk8815_i2c_dev0);
  58. platform_device_register(&nhk8815_i2c_dev1);
  59. platform_device_register(&nhk8815_i2c_dev2);
  60. return 0;
  61. }
  62. static void __exit nhk8815_i2c_exit(void)
  63. {
  64. platform_device_unregister(&nhk8815_i2c_dev0);
  65. platform_device_unregister(&nhk8815_i2c_dev1);
  66. platform_device_unregister(&nhk8815_i2c_dev2);
  67. return;
  68. }
  69. module_init(nhk8815_i2c_init);
  70. module_exit(nhk8815_i2c_exit);