ipq40xx: backport I2C QUP driver changes from 4.17
[openwrt/staging/wigyori.git] / target / linux / ipq40xx / patches-4.14 / 088-0011-i2c-qup-send-NACK-for-last-read-sub-transfers.patch
1 From f7714b4e451bdcb7918b9aad14af22684ceac638 Mon Sep 17 00:00:00 2001
2 From: Abhishek Sahu <absahu@codeaurora.org>
3 Date: Mon, 12 Mar 2018 18:45:00 +0530
4 Subject: [PATCH 11/13] i2c: qup: send NACK for last read sub transfers
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 According to I2c specification, “If a master-receiver sends a
10 repeated START condition, it sends a not-acknowledge (A) just
11 before the repeated START condition”. QUP v2 supports sending
12 of NACK without stop with QUP_TAG_V2_DATARD_NACK so added the
13 same.
14
15 Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
16 Reviewed-by: Austin Christ <austinwc@codeaurora.org>
17 Reviewed-by: Andy Gross <andy.gross@linaro.org>
18 Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
19 ---
20 drivers/i2c/busses/i2c-qup.c | 5 ++++-
21 1 file changed, 4 insertions(+), 1 deletion(-)
22
23 --- a/drivers/i2c/busses/i2c-qup.c
24 +++ b/drivers/i2c/busses/i2c-qup.c
25 @@ -104,6 +104,7 @@
26 #define QUP_TAG_V2_DATAWR 0x82
27 #define QUP_TAG_V2_DATAWR_STOP 0x83
28 #define QUP_TAG_V2_DATARD 0x85
29 +#define QUP_TAG_V2_DATARD_NACK 0x86
30 #define QUP_TAG_V2_DATARD_STOP 0x87
31
32 /* Status, Error flags */
33 @@ -606,7 +607,9 @@ static int qup_i2c_set_tags(u8 *tags, st
34 tags[len++] = QUP_TAG_V2_DATAWR_STOP;
35 } else {
36 if (msg->flags & I2C_M_RD)
37 - tags[len++] = QUP_TAG_V2_DATARD;
38 + tags[len++] = qup->blk.pos == (qup->blk.count - 1) ?
39 + QUP_TAG_V2_DATARD_NACK :
40 + QUP_TAG_V2_DATARD;
41 else
42 tags[len++] = QUP_TAG_V2_DATAWR;
43 }