[ramips] rt288x: fix serial console
[openwrt.git] / target / linux / coldfire / patches / 088-m547x_8x_i2c_timeout_fix.patch
1 From b9607c9083b767eac26df1d39a030f3cba5d3ae3 Mon Sep 17 00:00:00 2001
2 From: Kurt Mahan <kmahan@freescale.com>
3 Date: Fri, 18 Jul 2008 12:40:04 -0600
4 Subject: [PATCH] Increase timeouts on I2C bus.
5
6 LTIBName: m547x-8x-i2c-timeout-fix
7 Signed-off-by: Shrek Wu <b16972@freescale.com>
8 ---
9 drivers/i2c/busses/i2c-mcf548x.c | 40 +++++++++++++++++++++++++++++--------
10 1 files changed, 31 insertions(+), 9 deletions(-)
11
12 --- a/drivers/i2c/busses/i2c-mcf548x.c
13 +++ b/drivers/i2c/busses/i2c-mcf548x.c
14 @@ -43,8 +43,8 @@ static struct i2c_adapter i2c_mcf_board_
15 .id = I2C_HW_MPC107,
16 .algo_data = &i2c_mcf_board_data,
17 .class = I2C_CLASS_HWMON,
18 - .timeout = 1,
19 - .retries = 1
20 + .timeout = 100,
21 + .retries = 2
22 };
23 /*
24 * static void i2c_start()
25 @@ -105,7 +105,7 @@ wait_for_bb(
26 for (i = 0; i < adap->timeout; i++) {
27 if (!(MCF_I2SR & MCF_I2SR_IBB))
28 return 0;
29 - udelay(10);
30 + udelay(100);
31 }
32 printk(KERN_ERR "%s: timeout", __FUNCTION__);
33 return -ETIMEDOUT;
34 @@ -124,7 +124,7 @@ wait_for_not_bb(
35 for (i = 0; i < adap->timeout; i++) {
36 if (MCF_I2SR & MCF_I2SR_IBB)
37 return 0;
38 - udelay(10);
39 + udelay(100);
40 }
41 printk(KERN_ERR "%s: timeout", __FUNCTION__);
42 return -ETIMEDOUT;
43 @@ -146,7 +146,7 @@ wait_xfer_done(
44 MCF_I2SR &= ~MCF_I2SR_IIF;
45 return 0;
46 }
47 - udelay(1);
48 + udelay(10);
49 }
50 printk(KERN_ERR "%s: timeout", __FUNCTION__);
51 return -ETIMEDOUT;
52 @@ -166,7 +166,7 @@ i2c_set_addr(
53 ) {
54 unsigned short flags = msg->flags;
55 unsigned char addr;
56 -
57 + MCF_I2CR |= MCF_I2CR_MTX;
58 if ((flags & I2C_M_TEN)) {
59 /* 10 bit address not supported yet */
60 return -EIO;
61 @@ -269,7 +269,7 @@ mcf_sendbytes(
62 i2c_stop(adap);
63 wait_for_bb(adap);
64 } else {
65 - i2c_repstart(adap);
66 + /* i2c_repstart(adap);*/
67 }
68
69 return (i);
70 @@ -330,7 +330,7 @@ mcf_readbytes(
71 i2c_stop(adap);
72 wait_for_bb(adap);
73 } else {
74 - i2c_repstart(adap);
75 + /* i2c_repstart(adap);*/
76 }
77
78 return (i+1);
79 @@ -380,6 +380,27 @@ mcf_xfer(
80 wait_for_bb(adap);
81
82 for (i = 0; ret >= 0 && i < num; i++) {
83 + if (MCF_I2SR & MCF_I2SR_IBB) {
84 + MCF_I2ICR = 0x00;
85 + MCF_I2CR = 0x00;
86 + MCF_I2CR = 0x0A;
87 + timeout = MCF_I2DR;
88 + MCF_I2SR = 0x00;
89 + MCF_I2CR = 0x00;
90 + MCF_I2ICR = 0x01;
91 + }
92 + /* setup SCL clock */
93 + MCF_I2FDR = get_clock(adap);
94 + /* set slave address */
95 + MCF_I2AR = get_own(adap);
96 + /* enable I2C module */
97 + MCF_I2CR = MCF_I2CR_IEN;
98 +
99 + MCF_I2CR |= MCF_I2CR_TXAK;
100 +
101 + /* Check for bus busy */
102 + wait_for_bb(adap);
103 +
104 pmsg = &msgs[i];
105
106 printk(KERN_DEBUG "i2c-algo-mcf: Doing %s %d bytes "
107 @@ -388,7 +409,7 @@ mcf_xfer(
108 pmsg->len, pmsg->addr, i + 1, num);
109
110 /* Send START */
111 - if (i == 0)
112 + /*if (i == 0)*/
113 i2c_start(adap);
114
115 /* Wait for Bus Busy */
116 @@ -440,6 +461,7 @@ mcf_xfer(
117 "%d bytes.\n", ret);
118 }
119 }
120 + MCF_I2CR = 0;
121 }
122
123 /* Disable I2C module */
This page took 0.053137 seconds and 5 git commands to generate.