kernel: backport v5.8 i2c-pxa updates
[openwrt/openwrt.git] / target / linux / generic / backport-5.4 / 808-v5.8-i2c-pxa-add-and-use-definitions-for-IBMR-register.patch
1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Bcc: linux@mail.armlinux.org.uk
3 Cc: linux-i2c@vger.kernel.org
4 Subject: [PATCH 06/17] i2c: pxa: add and use definitions for IBMR register
5 MIME-Version: 1.0
6 Content-Disposition: inline
7 Content-Transfer-Encoding: 8bit
8 Content-Type: text/plain; charset="utf-8"
9
10 Add definitions for the bits in the IBMR register, and use them in the
11 code. This improves readability.
12
13 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
14 ---
15 drivers/i2c/busses/i2c-pxa.c | 12 ++++++++----
16 1 file changed, 8 insertions(+), 4 deletions(-)
17
18 diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
19 index ea96dfa6b9d5..b3286d7ab75d 100644
20 --- a/drivers/i2c/busses/i2c-pxa.c
21 +++ b/drivers/i2c/busses/i2c-pxa.c
22 @@ -34,6 +34,9 @@
23 #include <linux/slab.h>
24
25 /* I2C register field definitions */
26 +#define IBMR_SDAS (1 << 0)
27 +#define IBMR_SCLS (1 << 1)
28 +
29 #define ICR_START (1 << 0) /* start bit */
30 #define ICR_STOP (1 << 1) /* stop bit */
31 #define ICR_ACKNAK (1 << 2) /* send ACK(0) or NAK(1) */
32 @@ -335,7 +338,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
33 return;
34 }
35
36 - while ((i > 0) && (readl(_IBMR(i2c)) & 0x1) == 0) {
37 + while ((i > 0) && (readl(_IBMR(i2c)) & IBMR_SDAS) == 0) {
38 unsigned long icr = readl(_ICR(i2c));
39
40 icr &= ~ICR_START;
41 @@ -390,7 +393,8 @@ static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
42 * quick check of the i2c lines themselves to ensure they've
43 * gone high...
44 */
45 - if ((readl(_ISR(i2c)) & (ISR_UB | ISR_IBB)) == 0 && readl(_IBMR(i2c)) == 3) {
46 + if ((readl(_ISR(i2c)) & (ISR_UB | ISR_IBB)) == 0 &&
47 + readl(_IBMR(i2c)) == (IBMR_SCLS | IBMR_SDAS)) {
48 if (i2c_debug > 0)
49 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__);
50 return 1;
51 @@ -575,7 +579,7 @@ static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr)
52 timeout = 0x10000;
53
54 while (1) {
55 - if ((readl(_IBMR(i2c)) & 2) == 2)
56 + if ((readl(_IBMR(i2c)) & IBMR_SCLS) == IBMR_SCLS)
57 break;
58
59 timeout--;
60 @@ -638,7 +642,7 @@ static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr)
61 timeout = 0x10000;
62
63 while (1) {
64 - if ((readl(_IBMR(i2c)) & 2) == 2)
65 + if ((readl(_IBMR(i2c)) & IBMR_SCLS) == IBMR_SCLS)
66 break;
67
68 timeout--;
69 --
70 2.20.1
71