All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gary Thomas <gary@mlbassoc.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: jean-philippe francois <jp.francois@cynove.com>,
	linux-i2c@vger.kernel.org, linux-omap@vger.kernel.org,
	Jean Delvare <khali@linux-fr.org>
Subject: Re: [RFC/PATCH 0/3] OMAP3 I2C/SCCB support
Date: Tue, 26 Jun 2012 10:25:58 -0600	[thread overview]
Message-ID: <4FE9E296.4020905@mlbassoc.com> (raw)
In-Reply-To: <2898283.yhxlxrlhzg@avalon>

On 2012-06-26 10:20, Laurent Pinchart wrote:
> Hi Jean-Philippe,
>
> On Tuesday 26 June 2012 16:49:35 jean-philippe francois wrote:
>> 2012/6/26 Laurent Pinchart<laurent.pinchart@ideasonboard.com>:
>>> 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.

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

  reply	other threads:[~2012-06-26 16:25 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 [this message]
     [not found]       ` <4FE9E296.4020905-kIKI1E8EpGZWk0Htik3J/w@public.gmane.org>
2012-06-26 16:36         ` Laurent Pinchart
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=4FE9E296.4020905@mlbassoc.com \
    --to=gary@mlbassoc.com \
    --cc=jp.francois@cynove.com \
    --cc=khali@linux-fr.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-omap@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.