* [PATCH] MPC52xxx I2C: make algo use of I2C_RSTA
@ 2005-08-11 18:03 Bertrand BAUDET
0 siblings, 0 replies; only message in thread
From: Bertrand BAUDET @ 2005-08-11 18:03 UTC (permalink / raw)
To: linuxppc-embedded
[-- Attachment #1: Type: text/plain, Size: 273 bytes --]
This patch makes use of I2C RESTART sequence when sending severals i2c_msg
instead of the STOP and START sequence.
Some I2C component reset there internal values when a STOP is sent.
(like the Ricoh rs5c372b I2C RTC)
Patch is against DENX linuxppc CVS
Regards,
Bertrand
[-- Attachment #2: mpc52xx_i2c-algo.patch --]
[-- Type: text/x-diff, Size: 1421 bytes --]
--- linuxppc_2_4_devel_new/drivers/i2c/i2c-algo-mpc5xxx.c 2004-05-08 18:49:39.000000000 +0200
+++ linuxppc_2_4_devel-lacie6/drivers/i2c/i2c-algo-mpc5xxx.c 2004-12-13 15:53:37.000000000 +0100
@@ -62,6 +62,14 @@
return;
}
+static void i2c_restart(struct i2c_algo_mpc5xxx_data *algo_data)
+{
+ struct mpc5xxx_i2c *regs = algo_data->regs;
+
+ mpc5xxx_out(®s->mcr, MPC5xxx_I2C_RSTA, MPC5xxx_I2C_RSTA);
+
+ return;
+}
static void i2c_stop(struct i2c_algo_mpc5xxx_data *algo_data)
{
@@ -311,13 +319,14 @@
int status;
int i;
+ if (wait_for_bb(algo_data))
+ return -EREMOTEIO;
+
+ i2c_start(algo_data);
+
for (i = 0; i < num; i++) {
pmsg = &msgs[i];
- if (wait_for_bb(algo_data))
- return -EREMOTEIO;
-
- i2c_start(algo_data);
mpc5xxx_do_address(algo_data, pmsg, adap->retries);
if (wait_for_pin(algo_data, &status)) {
@@ -332,17 +341,21 @@
if (pmsg->flags & I2C_M_RD) {
ret = mpc5xxx_readbytes(adap, pmsg->buf, pmsg->len);
- if (ret != pmsg->len)
+ if (ret != pmsg->len) {
+ i2c_stop(algo_data);
return (ret < 0) ? ret : -EREMOTEIO;
+ }
} else {
ret = mpc5xxx_sendbytes(adap, pmsg->buf, pmsg->len);
- if (ret != pmsg->len)
+ if (ret != pmsg->len) {
+ i2c_stop(algo_data);
return (ret < 0) ? ret : -EREMOTEIO;
+ }
}
-
- i2c_stop(algo_data);
+ if (i+1 < num) i2c_restart(algo_data);
}
-
+
+ i2c_stop(algo_data);
return num;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-08-11 16:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-11 18:03 [PATCH] MPC52xxx I2C: make algo use of I2C_RSTA Bertrand BAUDET
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox