static unsigned int pca_probe_chip(struct i2c_adapter *adap) { struct i2c_algo_pca_data *pca_data = adap->algo_data; /* The trick here is to check if there is an indirect register * available. If there is one, we will read the value we first * wrote on I2C_PCA_IADR. Otherwise, we will read the last value * we wrote on I2C_PCA_ADR */ pca_outw(pca_data, I2C_PCA_INDPTR, I2C_PCA_IADR); pca_outw(pca_data, I2C_PCA_IND, 0xAA); pca_outw(pca_data, I2C_PCA_INDPTR, I2C_PCA_ITO); pca_outw(pca_data, I2C_PCA_IND, 0x00); pca_outw(pca_data, I2C_PCA_INDPTR, I2C_PCA_IADR); if (pca_inw(pca_data, I2C_PCA_IND) == 0xAA) { ; return I2C_PCA_CHIP_9665; } else { ; return I2C_PCA_CHIP_9564; } }
static void pca_rx_byte(struct i2c_algo_pca_data *adap, __u8 *b, int ack) { *b = pca_inw(adap, I2C_PCA_DAT); DEB2("=== READ %#04x %s\n", *b, ack ? "ACK" : "NACK"); }