i2c.h 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. /* Polled Synopsys DesignWare APB I2C master. Used by the Braswell LPSS
  2. * controllers, in particular the one the HID-over-I2C touchpad sits on. */
  3. #ifndef I2C_H
  4. #define I2C_H
  5. /* Probe and initialize the controller at a physical MMIO base. Returns 0
  6. * when the DesignWare component type matches. */
  7. int i2c_dw_init(unsigned int base);
  8. /* True when the controller at base looks like a DesignWare I2C block. */
  9. int i2c_dw_present(unsigned int base);
  10. /* TX_ABRT_SOURCE of the last failed transfer (0 = timeout, not a NAK). */
  11. extern unsigned int i2c_last_abort;
  12. /* Raw component-type / reset-release access for the LPSS scan. */
  13. unsigned int i2c_dw_comp_type(unsigned int base);
  14. void i2c_dw_reset_release(unsigned int base);
  15. /* Sunrise Point-LP only: enable the LPSS functional clock gate and set
  16. * the fractional divider (0x200). The BIOS leaves it off for unused
  17. * LPSS blocks; the register file still answers, but the I2C FSM does not
  18. * drive the bus. */
  19. void i2c_dw_clock_spt(unsigned int base);
  20. /* One-line controller register dump for the seriallog. */
  21. void i2c_dw_dump(unsigned int base);
  22. /* Combined write + repeated-start read, the form HID-over-I2C uses for
  23. * register-addressed transfers. Either buffer may be empty. */
  24. int i2c_dw_transfer(unsigned int base, unsigned int addr,
  25. const unsigned char *wr, unsigned int wrlen,
  26. unsigned char *rd, unsigned int rdlen);
  27. #endif