Skip to content

Commit 83ef106

Browse files
Viken DadhaniyaAndi Shyti
authored andcommitted
i2c: qcom-geni: Correct I2C TRE sequence
For i2c read operation in GSI mode, we are getting timeout due to malformed TRE basically incorrect TRE sequence in gpi(drivers/dma/qcom/gpi.c) driver. I2C driver has geni_i2c_gpi(I2C_WRITE) function which generates GO TRE and geni_i2c_gpi(I2C_READ)generates DMA TRE. Hence to generate GO TRE before DMA TRE, we should move geni_i2c_gpi(I2C_WRITE) before geni_i2c_gpi(I2C_READ) inside the I2C GSI mode transfer function i.e. geni_i2c_gpi_xfer(). TRE stands for Transfer Ring Element - which is basically an element with size of 4 words. It contains all information like slave address, clk divider, dma address value data size etc). Mainly we have 3 TREs(Config, GO and DMA tre). - CONFIG TRE : consists of internal register configuration which is required before start of the transfer. - DMA TRE : contains DDR/Memory address, called as DMA descriptor. - GO TRE : contains Transfer directions, slave ID, Delay flags, Length of the transfer. I2c driver calls GPI driver API to config each TRE depending on the protocol. For read operation tre sequence will be as below which is not aligned to hardware programming guide. - CONFIG tre - DMA tre - GO tre As per Qualcomm's internal Hardware Programming Guide, we should configure TREs in below sequence for any RX only transfer. - CONFIG tre - GO tre - DMA tre Fixes: d870355 ("i2c: qcom-geni: Add support for GPI DMA") Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # qrb5165-rb5 Co-developed-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com> Signed-off-by: Viken Dadhaniya <quic_vdadhani@quicinc.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent 54be6c6 commit 83ef106

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/i2c/busses/i2c-qcom-geni.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -613,20 +613,20 @@ static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2c, struct i2c_msg msgs[], i
613613

614614
peripheral.addr = msgs[i].addr;
615615

616+
ret = geni_i2c_gpi(gi2c, &msgs[i], &config,
617+
&tx_addr, &tx_buf, I2C_WRITE, gi2c->tx_c);
618+
if (ret)
619+
goto err;
620+
616621
if (msgs[i].flags & I2C_M_RD) {
617622
ret = geni_i2c_gpi(gi2c, &msgs[i], &config,
618623
&rx_addr, &rx_buf, I2C_READ, gi2c->rx_c);
619624
if (ret)
620625
goto err;
621-
}
622-
623-
ret = geni_i2c_gpi(gi2c, &msgs[i], &config,
624-
&tx_addr, &tx_buf, I2C_WRITE, gi2c->tx_c);
625-
if (ret)
626-
goto err;
627626

628-
if (msgs[i].flags & I2C_M_RD)
629627
dma_async_issue_pending(gi2c->rx_c);
628+
}
629+
630630
dma_async_issue_pending(gi2c->tx_c);
631631

632632
timeout = wait_for_completion_timeout(&gi2c->done, XFER_TIMEOUT);

0 commit comments

Comments
 (0)