/* FIXME: Implement join handling correctly */ static int i2c_readbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg, int joined) { struct au0828_dev *dev = i2c_adap->algo_data; int i; dprintk(4, "%s()\n", __func__); au0828_write(dev, AU0828_I2C_MULTIBYTE_MODE_2FF, 0x01); /* Set the I2C clock */ au0828_write(dev, AU0828_I2C_CLK_DIVIDER_202, dev->board.i2c_clk_divider); /* Hardware needs 8 bit addresses */ au0828_write(dev, AU0828_I2C_DEST_ADDR_203, msg->addr << 1); dprintk(4, " RECV:\n"); /* Deal with i2c_scan */ if (msg->len == 0) { au0828_write(dev, AU0828_I2C_TRIGGER_200, AU0828_I2C_TRIGGER_READ); if (i2c_wait_read_ack(i2c_adap)) return -EIO; return 0; } for (i = 0; i < msg->len;) { i++; if (i < msg->len) au0828_write(dev, AU0828_I2C_TRIGGER_200, AU0828_I2C_TRIGGER_READ | AU0828_I2C_TRIGGER_HOLD); else au0828_write(dev, AU0828_I2C_TRIGGER_200, AU0828_I2C_TRIGGER_READ); if (!i2c_wait_read_done(i2c_adap)) return -EIO; msg->buf[i-1] = au0828_read(dev, AU0828_I2C_READ_FIFO_209) & 0xff; dprintk(4, " %02x\n", msg->buf[i-1]); } if (!i2c_wait_done(i2c_adap)) return -EIO; dprintk(4, "\n"); return msg->len; }
/* FIXME: Implement join handling correctly */ static int i2c_readbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg, int joined) { struct au0828_dev *dev = i2c_adap->algo_data; int i; dprintk(4, "%s()\n", __func__); au0828_write(dev, REG_2FF, 0x01); au0828_write(dev, REG_202, 0x07); /* Hardware needs 8 bit addresses */ au0828_write(dev, REG_203, msg->addr << 1); dprintk(4, " RECV:\n"); /* Deal with i2c_scan */ if (msg->len == 0) { au0828_write(dev, REG_200, 0x20); if (i2c_wait_read_ack(i2c_adap)) return -EIO; return 0; } for (i = 0; i < msg->len;) { i++; if (i < msg->len) au0828_write(dev, REG_200, 0x60); else au0828_write(dev, REG_200, 0x20); if (!i2c_wait_read_done(i2c_adap)) return -EIO; msg->buf[i-1] = au0828_read(dev, REG_209) & 0xff; dprintk(4, " %02x\n", msg->buf[i-1]); } if (!i2c_wait_done(i2c_adap)) return -EIO; dprintk(4, "\n"); return msg->len; }