multi_i2c.c 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (C) 2012 Samsung Electronics
  3. * Lukasz Majewski <l.majewski@samsung.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <i2c.h>
  9. #ifndef CONFIG_SOFT_I2C_I2C10_SCL
  10. #define CONFIG_SOFT_I2C_I2C10_SCL 0
  11. #endif
  12. #ifndef CONFIG_SOFT_I2C_I2C10_SDA
  13. #define CONFIG_SOFT_I2C_I2C10_SDA 0
  14. #endif
  15. /* Handle multiple I2C buses instances */
  16. int get_multi_scl_pin(void)
  17. {
  18. unsigned int bus = i2c_get_bus_num();
  19. switch (bus) {
  20. case I2C_0:
  21. return CONFIG_SOFT_I2C_I2C5_SCL;
  22. case I2C_1:
  23. return CONFIG_SOFT_I2C_I2C9_SCL;
  24. case I2C_2:
  25. return CONFIG_SOFT_I2C_I2C10_SCL;
  26. default:
  27. printf("I2C_%d not supported!\n", bus);
  28. };
  29. return 0;
  30. }
  31. int get_multi_sda_pin(void)
  32. {
  33. unsigned int bus = i2c_get_bus_num();
  34. switch (bus) {
  35. case I2C_0:
  36. return CONFIG_SOFT_I2C_I2C5_SDA;
  37. case I2C_1:
  38. return CONFIG_SOFT_I2C_I2C9_SDA;
  39. case I2C_2:
  40. return CONFIG_SOFT_I2C_I2C10_SDA;
  41. default:
  42. printf("I2C_%d not supported!\n", bus);
  43. };
  44. return 0;
  45. }
  46. int multi_i2c_init(void)
  47. {
  48. return 0;
  49. }