linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
To: Gary Thomas <gary-kIKI1E8EpGZWk0Htik3J/w@public.gmane.org>
Cc: jean-philippe francois
	<jp.francois-JOfcSVQZ0GHQT0dZR+AlfA@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Subject: Re: [RFC/PATCH 0/3] OMAP3 I2C/SCCB support
Date: Tue, 26 Jun 2012 18:36:14 +0200	[thread overview]
Message-ID: <2180241.tDMasfKvry@avalon> (raw)
In-Reply-To: <4FE9E296.4020905-kIKI1E8EpGZWk0Htik3J/w@public.gmane.org>

Hi Gary,

On Tuesday 26 June 2012 10:25:58 Gary Thomas wrote:
> On 2012-06-26 10:20, Laurent Pinchart wrote:
> > On Tuesday 26 June 2012 16:49:35 jean-philippe francois wrote:
> >> 2012/6/26 Laurent Pinchart<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>:
> >>> Hi everybody,
> >>> 
> >>> While trying to use an OV7725 camera sensor with an OMAP3 system I ran
> >>> into a couple of issues related to the sensor communication protocol.
> >>> Instead of using the obiquitous I2C protocol, Omnivision invited the
> >>> SCCB communication bus, very similar to I2C but different enough not to
> >>> be compatible.
> >> 
> >> I have been using omnivision sensor without being aware of this issue,
> >> and without any i2c reliability issue either.
> >> 
> >> Here is typical code I use :
> >> 
> >> /* This function is used to read value from register for i2c client */
> >> static int ov2710_read(struct i2c_client *client, unsigned short reg,
> >> unsigned char *val)
> >> {
> >> 
> >>      int err = 0;
> >>      unsigned char outbuf[] = {(reg>>8)&0xff, reg&0xff};
> > 
> > According to the SCCB specification (or at least the version I've found)
> > register addresses are 8-bit. The OV2710 might just be I2C-compatible.
> > 
> >>      unsigned char inbuf[1];
> >>      struct i2c_msg msg[] = {
> >>      
> >>          { .addr = client->addr, .flags = 0, .buf = outbuf, .len = 2 },
> >>          { .addr = client->addr, .flags = I2C_M_RD, .buf = inbuf, .len =
> >>          1 },
> >> 
> >> };
> >> 
> >>      err = i2c_transfer(client->adapter, msg, 2);
> >>      /* error handling and pass by ref handling */
> >>      ....
> >> 
> >> }
> > 
> > The ov772x driver uses i2c_smbus_write_byte_data() and
> > i2c_smbus_read_byte_data(). The later calls
> > 
> > i2c_smbus_xfer(client->adapter, client->addr, client->flags,
> > 
> >                 I2C_SMBUS_READ, I2C_SMBUS_BYTE_DATA,&data);
> > 
> > which calls i2c_smbus_xfer_emulated() for hosts that don't support SMBus
> > transfers natively, and that's pretty much equivalent to your above code
> > (except for the 8/16 bit register address).
> > 
> > It might be a good idea to implement i2c_smbus_*-like functions for 16-bit
> > register addresses in the I2C core, they could be reused across drivers.
> > 
> >> Is the point of this patch to avoid writing such functions again and
> >> again in every ov driver ?
> > 
> > No, but that's a good idea as well :-)
> > 
> >> What is solved in practice by this patch that is not solved by a regular
> >> i2c transfer ?
> > 
> > The above code will not ignore acks/nacks and will not generate a stop
> > condition between the two messages. The SCCB specification states that
> > acks/nacks must be ignored and that a stop condition must be generated.
> > The OV7725 handles acks/nacks correctly, but chokes if no stop condition
> > is generated. The point of this patch set is to fix both problems
> > (although the acks/nacks issue might be theoretical only).
> 
> How does it "choke"?  I've had success talking to the OV8820 using the
> normal I2C driver as well.

With the patches applied:

[   23.277893] omap3isp omap3isp: Revision 15.0 found
[   23.283721] omap-iommu omap-iommu.0: isp: version 1.1
[   25.244079] ov772x 2-0021: ov7725 Product ID 77:21 Manufacturer ID 7f:a2

Without the patches applied:

[   23.505493] omap3isp omap3isp: Revision 15.0 found
[   23.511138] omap-iommu omap-iommu.0: isp: version 1.1
[   25.552246] omap_i2c omap_i2c.2: Arbitration lost
[   26.583160] omap_i2c omap_i2c.2: timeout waiting for bus ready
[   27.598785] omap_i2c omap_i2c.2: timeout waiting for bus ready
[   28.614196] omap_i2c omap_i2c.2: timeout waiting for bus ready
[   28.623260] isp_register_subdev_group: Unable to register subdev ov772x

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2012-06-26 16:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26 14:17 [RFC/PATCH 0/3] OMAP3 I2C/SCCB support Laurent Pinchart
2012-06-26 14:17 ` [RFC/PATCH 1/3] i2c: Add SCCB support Laurent Pinchart
2012-07-17 11:53   ` Jean Delvare
     [not found]     ` <20120717135307.6745729f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-07-17 11:57       ` Laurent Pinchart
2012-07-17 12:08         ` Jean Delvare
2012-06-26 14:17 ` [RFC/PATCH 2/3] i2c: Fall back to emulated SMBus if the operation isn't supported natively Laurent Pinchart
     [not found]   ` <1340720229-30356-3-git-send-email-laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2012-07-17 15:02     ` Jean Delvare
     [not found]       ` <20120717170243.5def41a3-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-07-17 15:06         ` Laurent Pinchart
     [not found] ` <1340720229-30356-1-git-send-email-laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2012-06-26 14:17   ` [RFC/PATCH 3/3] i2c: omap: Add support for I2C_M_STOP message flag Laurent Pinchart
     [not found]     ` <1340720229-30356-4-git-send-email-laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2012-07-17 15:29       ` Jean Delvare
     [not found]         ` <20120717172935.45ff210f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-07-18  1:05           ` Laurent Pinchart
2012-07-18  6:19       ` Shubhrajyoti
     [not found]         ` <5006556C.8070003-l0cyMroinI0@public.gmane.org>
2012-07-18 11:13           ` Laurent Pinchart
2012-07-18 12:08             ` Shubhrajyoti Datta
2012-06-26 14:49 ` [RFC/PATCH 0/3] OMAP3 I2C/SCCB support jean-philippe francois
2012-06-26 16:20   ` Laurent Pinchart
2012-06-26 16:25     ` Gary Thomas
     [not found]       ` <4FE9E296.4020905-kIKI1E8EpGZWk0Htik3J/w@public.gmane.org>
2012-06-26 16:36         ` Laurent Pinchart [this message]
2012-06-26 16:56     ` Jean Delvare
     [not found]       ` <20120626185616.7fafc53b-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-06-26 21:37         ` Laurent Pinchart

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=2180241.tDMasfKvry@avalon \
    --to=laurent.pinchart-rylnwiuwjnjg/c1bvhzhaw@public.gmane.org \
    --cc=gary-kIKI1E8EpGZWk0Htik3J/w@public.gmane.org \
    --cc=jp.francois-JOfcSVQZ0GHQT0dZR+AlfA@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-omap-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).