From: Jean Delvare <khali@linux-fr.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-i2c@vger.kernel.org, linux-omap@vger.kernel.org
Subject: Re: [RFC/PATCH 1/3] i2c: Add SCCB support
Date: Tue, 17 Jul 2012 13:53:07 +0200 [thread overview]
Message-ID: <20120717135307.6745729f@endymion.delvare> (raw)
In-Reply-To: <1340720229-30356-2-git-send-email-laurent.pinchart@ideasonboard.com>
Salut Laurent,
On Tue, 26 Jun 2012 16:17:07 +0200, Laurent Pinchart wrote:
> SCCB is a serial communication bus developed by Omnivision. Its 2-wire
> mode is very similar to SMBus byte data transactions, but requires the
> controller to ignore the ACK bit and to insert a stop condition after
> each message.
>
> Add a device SCCB flag and a message stop flag to be passed to
> controller drivers.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/i2c/i2c-core.c | 13 ++++++++++++-
> include/linux/i2c.h | 2 ++
> 2 files changed, 14 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index feb7dc3..8cfa660 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -1939,6 +1939,12 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
> u8 partial_pec = 0;
> int status;
>
> + if (unlikely(flags & I2C_CLIENT_SCCB) && size != I2C_SMBUS_BYTE_DATA) {
> + dev_err(&adapter->dev,
> + "SCCB devices only support I2C_SMBUS_BYTE_DATA\n");
> + return -EINVAL;
> + }
> +
I'm not sure if we really want this. If the SCCB protocol evolves,
we'll have to loosen the check. If a devices follows SCCB for byte data
transactions and I2C/SMBus for others, it won't work. Plus it slows
down the function a bit, to catch a developer error which would not
result in anything catastrophic anyway.
I propose that we either drop the check completely (my preference) or
make it depend on DEBUG.
> msgbuf0[0] = command;
> switch (size) {
> case I2C_SMBUS_QUICK:
> @@ -1956,6 +1962,11 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
> }
> break;
> case I2C_SMBUS_BYTE_DATA:
> + if (unlikely(flags & I2C_CLIENT_SCCB)) {
> + msg[0].flags |= I2C_M_IGNORE_NAK | I2C_M_STOP;
> + msg[1].flags |= I2C_M_IGNORE_NAK | I2C_M_STOP;
> + }
> +
> if (read_write == I2C_SMBUS_READ)
> msg[1].len = 1;
> else {
> @@ -2105,7 +2116,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
> int try;
> s32 res;
>
> - flags &= I2C_M_TEN | I2C_CLIENT_PEC;
> + flags &= I2C_M_TEN | I2C_CLIENT_PEC | I2C_CLIENT_SCCB;
>
> if (adapter->algo->smbus_xfer) {
> i2c_lock_adapter(adapter);
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index 195d8b3..bd42914 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -420,6 +420,7 @@ void i2c_lock_adapter(struct i2c_adapter *);
> void i2c_unlock_adapter(struct i2c_adapter *);
>
> /*flags for the client struct: */
> +#define I2C_CLIENT_SCCB 0x02 /* Use Omnivision SCCB protocol */
> #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */
> #define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */
> /* Must equal I2C_M_TEN below */
> @@ -540,6 +541,7 @@ struct i2c_msg {
> __u16 flags;
> #define I2C_M_TEN 0x0010 /* this is a ten bit chip address */
> #define I2C_M_RD 0x0001 /* read data, from slave to master */
> +#define I2C_M_STOP 0x8000 /* if I2C_FUNC_PROTOCOL_MANGLING */
> #define I2C_M_NOSTART 0x4000 /* if I2C_FUNC_PROTOCOL_MANGLING */
> #define I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */
> #define I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */
Other than this your patch looks fine, I'll apply it, thanks.
--
Jean Delvare
next prev parent reply other threads:[~2012-07-17 11:53 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 [this message]
[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
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=20120717135307.6745729f@endymion.delvare \
--to=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 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).