i2c-algo-pca.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef _LINUX_I2C_ALGO_PCA_H
  2. #define _LINUX_I2C_ALGO_PCA_H
  3. /* Chips known to the pca algo */
  4. #define I2C_PCA_CHIP_9564 0x00
  5. #define I2C_PCA_CHIP_9665 0x01
  6. /* Internal period for PCA9665 oscilator */
  7. #define I2C_PCA_OSC_PER 3 /* e10-8s */
  8. /* Clock speeds for the bus for PCA9564*/
  9. #define I2C_PCA_CON_330kHz 0x00
  10. #define I2C_PCA_CON_288kHz 0x01
  11. #define I2C_PCA_CON_217kHz 0x02
  12. #define I2C_PCA_CON_146kHz 0x03
  13. #define I2C_PCA_CON_88kHz 0x04
  14. #define I2C_PCA_CON_59kHz 0x05
  15. #define I2C_PCA_CON_44kHz 0x06
  16. #define I2C_PCA_CON_36kHz 0x07
  17. /* PCA9564 registers */
  18. #define I2C_PCA_STA 0x00 /* STATUS Read Only */
  19. #define I2C_PCA_TO 0x00 /* TIMEOUT Write Only */
  20. #define I2C_PCA_DAT 0x01 /* DATA Read/Write */
  21. #define I2C_PCA_ADR 0x02 /* OWN ADR Read/Write */
  22. #define I2C_PCA_CON 0x03 /* CONTROL Read/Write */
  23. /* PCA9665 registers */
  24. #define I2C_PCA_INDPTR 0x00 /* INDIRECT Pointer Write Only */
  25. #define I2C_PCA_IND 0x02 /* INDIRECT Read/Write */
  26. /* PCA9665 indirect registers */
  27. #define I2C_PCA_ICOUNT 0x00 /* Byte Count for buffered mode */
  28. #define I2C_PCA_IADR 0x01 /* OWN ADR */
  29. #define I2C_PCA_ISCLL 0x02 /* SCL LOW period */
  30. #define I2C_PCA_ISCLH 0x03 /* SCL HIGH period */
  31. #define I2C_PCA_ITO 0x04 /* TIMEOUT */
  32. #define I2C_PCA_IPRESET 0x05 /* Parallel bus reset */
  33. #define I2C_PCA_IMODE 0x06 /* I2C Bus mode */
  34. /* PCA9665 I2C bus mode */
  35. #define I2C_PCA_MODE_STD 0x00 /* Standard mode */
  36. #define I2C_PCA_MODE_FAST 0x01 /* Fast mode */
  37. #define I2C_PCA_MODE_FASTP 0x02 /* Fast Plus mode */
  38. #define I2C_PCA_MODE_TURBO 0x03 /* Turbo mode */
  39. #define I2C_PCA_CON_AA 0x80 /* Assert Acknowledge */
  40. #define I2C_PCA_CON_ENSIO 0x40 /* Enable */
  41. #define I2C_PCA_CON_STA 0x20 /* Start */
  42. #define I2C_PCA_CON_STO 0x10 /* Stop */
  43. #define I2C_PCA_CON_SI 0x08 /* Serial Interrupt */
  44. #define I2C_PCA_CON_CR 0x07 /* Clock Rate (MASK) */
  45. struct i2c_algo_pca_data {
  46. void *data; /* private low level data */
  47. void (*write_byte) (void *data, int reg, int val);
  48. int (*read_byte) (void *data, int reg);
  49. int (*wait_for_completion) (void *data);
  50. void (*reset_chip) (void *data);
  51. /* For PCA9564, use one of the predefined frequencies:
  52. * 330000, 288000, 217000, 146000, 88000, 59000, 44000, 36000
  53. * For PCA9665, use the frequency you want here. */
  54. unsigned int i2c_clock;
  55. unsigned int chip;
  56. };
  57. int i2c_pca_add_bus(struct i2c_adapter *);
  58. int i2c_pca_add_numbered_bus(struct i2c_adapter *);
  59. #endif /* _LINUX_I2C_ALGO_PCA_H */