From: Bertrand BAUDET <bbaudet@lacie.com>
To: linuxppc-embedded@ozlabs.org
Subject: [PATCH] MPC52xxx I2C: make algo use of I2C_RSTA
Date: Thu, 11 Aug 2005 18:03:13 +0000 [thread overview]
Message-ID: <200508111803.13712.bbaudet@lacie.com> (raw)
[-- 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;
}
reply other threads:[~2005-08-11 16:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200508111803.13712.bbaudet@lacie.com \
--to=bbaudet@lacie.com \
--cc=linuxppc-embedded@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox