mxc_i2c.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #if defined(CONFIG_MX6QDL)
  20. #define I2C_PADS(name, scl_i2c, scl_gpio, scl_gp, sda_i2c, sda_gpio, sda_gp) \
  21. struct i2c_pads_info mx6q_##name = { \
  22. .scl = { \
  23. .i2c_mode = MX6Q_##scl_i2c, \
  24. .gpio_mode = MX6Q_##scl_gpio, \
  25. .gp = scl_gp, \
  26. }, \
  27. .sda = { \
  28. .i2c_mode = MX6Q_##sda_i2c, \
  29. .gpio_mode = MX6Q_##sda_gpio, \
  30. .gp = sda_gp, \
  31. } \
  32. }; \
  33. struct i2c_pads_info mx6s_##name = { \
  34. .scl = { \
  35. .i2c_mode = MX6DL_##scl_i2c, \
  36. .gpio_mode = MX6DL_##scl_gpio, \
  37. .gp = scl_gp, \
  38. }, \
  39. .sda = { \
  40. .i2c_mode = MX6DL_##sda_i2c, \
  41. .gpio_mode = MX6DL_##sda_gpio, \
  42. .gp = sda_gp, \
  43. } \
  44. };
  45. #define I2C_PADS_INFO(name) \
  46. (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) ? \
  47. &mx6q_##name : &mx6s_##name
  48. #endif
  49. void setup_i2c(unsigned i2c_index, int speed, int slave_addr,
  50. struct i2c_pads_info *p);
  51. void bus_i2c_init(void *base, int speed, int slave_addr,
  52. int (*idle_bus_fn)(void *p), void *p);
  53. int bus_i2c_read(void *base, uchar chip, uint addr, int alen, uchar *buf,
  54. int len);
  55. int bus_i2c_write(void *base, uchar chip, uint addr, int alen,
  56. const uchar *buf, int len);
  57. #endif