i2c-8815nhk.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /*
  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. static struct i2c_gpio_platform_data nhk8815_i2c_data0 = {
  14. /* keep defaults for timeouts; pins are push-pull bidirectional */
  15. .scl_pin = 62,
  16. .sda_pin = 63,
  17. };
  18. static struct i2c_gpio_platform_data nhk8815_i2c_data1 = {
  19. /* keep defaults for timeouts; pins are push-pull bidirectional */
  20. .scl_pin = 53,
  21. .sda_pin = 54,
  22. };
  23. /* first bus: GPIO XX and YY */
  24. static struct platform_device nhk8815_i2c_dev0 = {
  25. .name = "i2c-gpio",
  26. .id = 0,
  27. .dev = {
  28. .platform_data = &nhk8815_i2c_data0,
  29. },
  30. };
  31. /* second bus: GPIO XX and YY */
  32. static struct platform_device nhk8815_i2c_dev1 = {
  33. .name = "i2c-gpio",
  34. .id = 1,
  35. .dev = {
  36. .platform_data = &nhk8815_i2c_data1,
  37. },
  38. };
  39. static int __init nhk8815_i2c_init(void)
  40. {
  41. nmk_gpio_set_mode(nhk8815_i2c_data0.scl_pin, NMK_GPIO_ALT_GPIO);
  42. nmk_gpio_set_mode(nhk8815_i2c_data0.sda_pin, NMK_GPIO_ALT_GPIO);
  43. platform_device_register(&nhk8815_i2c_dev0);
  44. nmk_gpio_set_mode(nhk8815_i2c_data1.scl_pin, NMK_GPIO_ALT_GPIO);
  45. nmk_gpio_set_mode(nhk8815_i2c_data1.sda_pin, NMK_GPIO_ALT_GPIO);
  46. platform_device_register(&nhk8815_i2c_dev1);
  47. return 0;
  48. }
  49. static void __exit nhk8815_i2c_exit(void)
  50. {
  51. platform_device_unregister(&nhk8815_i2c_dev0);
  52. platform_device_unregister(&nhk8815_i2c_dev1);
  53. return;
  54. }
  55. module_init(nhk8815_i2c_init);
  56. module_exit(nhk8815_i2c_exit);