It is clear that we always send the address in TX_FIRST and data in TX.
No need to pass it from the caller.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
return sh_mobile_i2c_check_timing(pd);
}
return sh_mobile_i2c_check_timing(pd);
}
-static unsigned char i2c_op(struct sh_mobile_i2c_data *pd,
- enum sh_mobile_i2c_op op, unsigned char data)
+static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, enum sh_mobile_i2c_op op)
{
unsigned char ret = 0;
unsigned long flags;
{
unsigned char ret = 0;
unsigned long flags;
- dev_dbg(pd->dev, "op %d, data in 0x%02x\n", op, data);
+ dev_dbg(pd->dev, "op %d\n", op);
spin_lock_irqsave(&pd->lock, flags);
spin_lock_irqsave(&pd->lock, flags);
case OP_START: /* issue start and trigger DTE interrupt */
iic_wr(pd, ICCR, ICCR_ICE | ICCR_TRS | ICCR_BBSY);
break;
case OP_START: /* issue start and trigger DTE interrupt */
iic_wr(pd, ICCR, ICCR_ICE | ICCR_TRS | ICCR_BBSY);
break;
- case OP_TX_FIRST: /* disable DTE interrupt and write data */
+ case OP_TX_FIRST: /* disable DTE interrupt and write client address */
iic_wr(pd, ICIC, ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
iic_wr(pd, ICIC, ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
- iic_wr(pd, ICDR, data);
+ iic_wr(pd, ICDR, i2c_8bit_addr_from_msg(pd->msg));
break;
case OP_TX: /* write data */
break;
case OP_TX: /* write data */
- iic_wr(pd, ICDR, data);
+ iic_wr(pd, ICDR, pd->msg->buf[pd->pos]);
break;
case OP_TX_STOP: /* issue a stop (or rep_start) */
iic_wr(pd, ICCR, pd->send_stop ? ICCR_ICE | ICCR_TRS
break;
case OP_TX_STOP: /* issue a stop (or rep_start) */
iic_wr(pd, ICCR, pd->send_stop ? ICCR_ICE | ICCR_TRS
static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd)
{
static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd)
{
if (pd->pos == pd->msg->len) {
if (pd->pos == pd->msg->len) {
- i2c_op(pd, OP_TX_STOP, 0);
+ i2c_op(pd, OP_TX_STOP);
- if (sh_mobile_i2c_is_first_byte(pd)) {
- data = i2c_8bit_addr_from_msg(pd->msg);
- i2c_op(pd, OP_TX_FIRST, data);
- } else {
- data = pd->msg->buf[pd->pos];
- i2c_op(pd, OP_TX, data);
- }
+ if (sh_mobile_i2c_is_first_byte(pd))
+ i2c_op(pd, OP_TX_FIRST);
+ else
+ i2c_op(pd, OP_TX);
do {
if (sh_mobile_i2c_is_first_byte(pd)) {
do {
if (sh_mobile_i2c_is_first_byte(pd)) {
- data = i2c_8bit_addr_from_msg(pd->msg);
- i2c_op(pd, OP_TX_FIRST, data);
+ i2c_op(pd, OP_TX_FIRST);
break;
}
if (pd->pos == 0) {
break;
}
if (pd->pos == 0) {
- i2c_op(pd, OP_TX_TO_RX, 0);
+ i2c_op(pd, OP_TX_TO_RX);
if (pd->pos == pd->msg->len) {
if (pd->stop_after_dma) {
/* Simulate PIO end condition after DMA transfer */
if (pd->pos == pd->msg->len) {
if (pd->stop_after_dma) {
/* Simulate PIO end condition after DMA transfer */
- i2c_op(pd, OP_RX_STOP, 0);
+ i2c_op(pd, OP_RX_STOP);
pd->pos++;
break;
}
if (real_pos < 0) {
pd->pos++;
break;
}
if (real_pos < 0) {
- i2c_op(pd, OP_RX_STOP, 0);
+ i2c_op(pd, OP_RX_STOP);
- data = i2c_op(pd, OP_RX_STOP_DATA, 0);
+ data = i2c_op(pd, OP_RX_STOP_DATA);
} else if (real_pos >= 0) {
} else if (real_pos >= 0) {
- data = i2c_op(pd, OP_RX, 0);
+ data = i2c_op(pd, OP_RX);
start_ch(pd, msg, do_start);
if (do_start)
start_ch(pd, msg, do_start);
if (do_start)
- i2c_op(pd, OP_START, 0);
/* The interrupt handler takes care of the rest... */
timeout = wait_event_timeout(pd->wait,
/* The interrupt handler takes care of the rest... */
timeout = wait_event_timeout(pd->wait,