mxc_i2c.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __ASM_ARCH_MXC_MXC_I2C_H__
  7. #define __ASM_ARCH_MXC_MXC_I2C_H__
  8. #include <asm/imx-common/iomux-v3.h>
  9. struct i2c_pin_ctrl {
  10. iomux_v3_cfg_t i2c_mode;
  11. iomux_v3_cfg_t gpio_mode;
  12. unsigned char gp;
  13. unsigned char spare;
  14. };
  15. struct i2c_pads_info {
  16. struct i2c_pin_ctrl scl;
  17. struct i2c_pin_ctrl sda;
  18. };
  19. /*
  20. * Information about i2c controller
  21. * struct mxc_i2c_bus - information about the i2c[x] bus
  22. * @index: i2c bus index
  23. * @base: Address of I2C bus controller
  24. * @driver_data: Flags for different platforms, such as I2C_QUIRK_FLAG.
  25. * @speed: Speed of I2C bus
  26. * @pads_info: pinctrl info for this i2c bus, will be used when pinctrl is ok.
  27. * The following two is only to be compatible with non-DM part.
  28. * @idle_bus_fn: function to force bus idle
  29. * @idle_bus_data: parameter for idle_bus_fun
  30. */
  31. struct mxc_i2c_bus {
  32. /*
  33. * board file can use this index to locate which i2c_pads_info is for
  34. * i2c_idle_bus. When pinmux is implement, this entry can be
  35. * discarded. Here we do not use dev->seq, because we do not want to
  36. * export device to board file.
  37. */
  38. int index;
  39. ulong base;
  40. ulong driver_data;
  41. int speed;
  42. struct i2c_pads_info *pads_info;
  43. #ifndef CONFIG_DM_I2C
  44. int (*idle_bus_fn)(void *p);
  45. void *idle_bus_data;
  46. #endif
  47. };
  48. #if defined(CONFIG_MX6QDL)
  49. #define I2C_PADS(name, scl_i2c, scl_gpio, scl_gp, sda_i2c, sda_gpio, sda_gp) \
  50. struct i2c_pads_info mx6q_##name = { \
  51. .scl = { \
  52. .i2c_mode = MX6Q_##scl_i2c, \
  53. .gpio_mode = MX6Q_##scl_gpio, \
  54. .gp = scl_gp, \
  55. }, \
  56. .sda = { \
  57. .i2c_mode = MX6Q_##sda_i2c, \
  58. .gpio_mode = MX6Q_##sda_gpio, \
  59. .gp = sda_gp, \
  60. } \
  61. }; \
  62. struct i2c_pads_info mx6s_##name = { \
  63. .scl = { \
  64. .i2c_mode = MX6DL_##scl_i2c, \
  65. .gpio_mode = MX6DL_##scl_gpio, \
  66. .gp = scl_gp, \
  67. }, \
  68. .sda = { \
  69. .i2c_mode = MX6DL_##sda_i2c, \
  70. .gpio_mode = MX6DL_##sda_gpio, \
  71. .gp = sda_gp, \
  72. } \
  73. };
  74. #define I2C_PADS_INFO(name) \
  75. (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) ? \
  76. &mx6q_##name : &mx6s_##name
  77. #endif
  78. int setup_i2c(unsigned i2c_index, int speed, int slave_addr,
  79. struct i2c_pads_info *p);
  80. void bus_i2c_init(int index, int speed, int slave_addr,
  81. int (*idle_bus_fn)(void *p), void *p);
  82. int force_idle_bus(void *priv);
  83. int i2c_idle_bus(struct mxc_i2c_bus *i2c_bus);
  84. #endif