From: Philby John <pjohn-k0rHJ+Hhz/SB+jHODAdFcQ@public.gmane.org>
To: David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org
Subject: Re: [PATCH/RFC 1/1] recover from davinci i2c time out conditions
Date: Mon, 23 Nov 2009 20:53:56 +0530 [thread overview]
Message-ID: <1258989836.20007.236.camel@localhost.localdomain> (raw)
In-Reply-To: <200907151010.18709.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
Hello David,
On Wed, 2009-07-15 at 10:10 -0700, David Brownell wrote:
> On Wednesday 15 July 2009, Philby John wrote:
> > /*
> > + * Configure the i2c data pin as a GPIO input and the i2c clock pin as a
> > + * high GPIO output.
> > + */
> > +static void disable_i2c_pins(void)
> > +{
> > + unsigned long flags;
> > +
> > + local_irq_save(flags);
> > + if (cpu_is_davinci_dm355()) {
> > + gpio_direction_input(15);
> > + gpio_direction_output(14, 0);
> > + gpio_set_value(14, 1);
>
> As noted: gpio_direction_output(14, 1) is better.
Now Corrected!
>
> > + davinci_cfg_reg(DM355_I2C_SDA);
> > + davinci_cfg_reg(DM355_I2C_SCL);
> > + }
> > + local_irq_restore(flags);
> > +}
> > +
> > +/* Connect the i2c pins to the i2c controller. */
> > +static void enable_i2c_pins(void)
> > +{
> > + unsigned long flags;
> > +
> > + local_irq_save(flags);
> > + if (cpu_is_davinci_dm355()) {
> > + davinci_cfg_reg(DM355_I2C_SDA);
> > + davinci_cfg_reg(DM355_I2C_SCL);
> > + }
> > + local_irq_restore(flags);
> > +}
> > +
> > +
> > +/* Generate a pulse on the i2c clock pin. */
> > +static void pulse_i2c_clock(void)
> > +{
> > + if (cpu_is_davinci_dm355()) {
> > + gpio_set_value(14, 0);
> > + udelay(20);
> > + gpio_set_value(14, 1);
> > + udelay(20);
> > + }
> > +}
> > +
>
> The general problem with how that's done is that the SoC-specific
> bits should not be in this file. The mach-davinc/dm355.c file
> should hold that configuration; likewise for other SoCs.
Not quite sure what you were expecting here. What I could do is to set
sda_pin and scl_pin in struct davinci_i2c_platform_data, for all davinci
platforms there is, rather than make davinci specific changes to
i2c-gpio.c I would also prefer not to make changes to
board-dm646x-evm.c/board-dm365-evm.c/board-dm355-evm.c etc...
Please let me know what you think.
>
> > + /* Disable i2c */
> > + disable_i2c_pins();
> > + for (i = 0; i < 10; i++)
> > + pulse_i2c_clock();
> > + /* Re-enable i2c */
> > + enable_i2c_pins();
>
> A better description of this is that you're trying to follow
> the I2Cv3 instructions about how to *reset* the bus, yes?
This is correct. To be precise, I am following the bus recovery
procedure as outlined in AN10216-01 I2C Manual. Reproducing here as
general information.
•SDA line is then non usable anymore because of the
“Slave-Transmitter”mode.
•Methods to recover the SDA line are:
–Reset the slave device (assuming the device has a Reset pin)
–Use a bus recovery sequence to leave the “Slave-Transmitter” mode
•Bus recovery sequence is done as following:
1-Send 9 clock pulses on SCL line
2-Ask the master to keep SDA High until the “Slave-Transmitter” releases
the SDA line to perform the ACK operation
3-Keeping SDA High during the ACK means that the “Master-Receiver”does
not acknowledge the previous byte receive
4-The “Slave-Transmitter” then goes in an idle state
5-The master then sends a STOP command initializing completely the bus
Thank you for your comments.
Regards,
Philby
next prev parent reply other threads:[~2009-11-23 15:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-15 7:34 [PATCH/RFC 1/1] recover from davinci i2c time out conditions Philby John
[not found] ` <1247643267.5981.82.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-07-15 12:34 ` Sergei Shtylyov
[not found] ` <4A5DCCBD.909-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
2009-11-23 15:23 ` Philby John
2009-07-15 17:10 ` David Brownell
[not found] ` <200907151010.18709.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2009-11-23 15:23 ` Philby John [this message]
2009-07-15 17:15 ` Troy Kisky
[not found] ` <4A5E0E98.2030108-Q5RJGjKts06CY9SHAMCTRUEOCMrvLtNR@public.gmane.org>
2009-07-24 14:34 ` Karicheri, Muralidharan
[not found] ` <A69FA2915331DC488A831521EAE36FE40144FDB54B-UmuGNrFEPrGIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2009-07-24 18:14 ` Troy Kisky
2009-11-23 15:24 ` Philby John
2009-07-22 11:03 ` Nitin Mahajan
[not found] ` <218571.29671.qm-LK+a5U5w+t2B9c0Qi4KiSl5cfvJIxWXgQQ4Iyu8u01E@public.gmane.org>
2009-07-22 11:14 ` Philby John
[not found] ` <1248261275.4077.4.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-09-19 5:12 ` Craig Matsuura
[not found] ` <200909182312.58018.cmatsuura-/SMLdF/PHsZWk0Htik3J/w@public.gmane.org>
2009-09-21 6:31 ` Philby John
[not found] ` <1253514660.4507.2.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2009-09-21 13:34 ` Craig Matsuura
2009-09-21 13:41 ` Craig Matsuura
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=1258989836.20007.236.camel@localhost.localdomain \
--to=pjohn-k0rhj+hhz/sb+jhodadfcq@public.gmane.org \
--cc=david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org \
--cc=davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).