* [PATCH] Add support for SCCB devices into PXA27x I2C controller
@ 2014-11-22 22:52 Petr Cvek
2014-11-23 8:31 ` Wolfram Sang
2014-11-23 16:23 ` [PATCH] Add support for SCCB devices into PXA27x I2C controller Sergei Shtylyov
0 siblings, 2 replies; 7+ messages in thread
From: Petr Cvek @ 2014-11-22 22:52 UTC (permalink / raw)
To: linux-arm-kernel
Add support for SCCB devices into PXA27x I2C controller.
Fix generated START but no STOP for message without I2C_M_NOSTART flag.
Add support for I2C_M_IGNORE_NAK flag.
Signed-off-by: Petr Cvek <petr.cvek@tul.cz>
---
drivers/i2c/busses/i2c-pxa.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index be671f7..adad044 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -885,7 +885,14 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c
*i2c, u32 isr)
return; /* ignore */
}
- if (isr & ISR_BED) {
+ /*
+ * Ignore NAK when flag I2C_M_IGNORE_NAK is present,
+ * this enables use of SCCB devices
+ */
+ if ((isr & ISR_BED) &&
+ (!((i2c->msg->flags & I2C_M_IGNORE_NAK) &&
+ (isr & ISR_ACKNAK)))) {
+
int ret = BUS_ERROR;
/*
@@ -919,12 +926,15 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c
*i2c, u32 isr)
icr |= ICR_ALDIE | ICR_TB;
/*
- * If this is the last byte of the last message, send
- * a STOP.
+ * If this is the last byte of the last message or last byte
+ * or any message without I2C_M_NOSTART, send a STOP.
*/
- if (i2c->msg_ptr == i2c->msg->len &&
- i2c->msg_idx == i2c->msg_num - 1)
- icr |= ICR_STOP;
+ if (((i2c->msg_ptr == i2c->msg->len) &&
+ (!(i2c->msg->flags & I2C_M_NOSTART))) ||
+ ((i2c->msg_ptr == i2c->msg->len) &&
+ (i2c->msg_idx == i2c->msg_num - 1)))
+ icr |= ICR_STOP;
+
} else if (i2c->msg_idx < i2c->msg_num - 1) {
/*
* Next segment of the message.
--
1.7.12.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] Add support for SCCB devices into PXA27x I2C controller
2014-11-22 22:52 [PATCH] Add support for SCCB devices into PXA27x I2C controller Petr Cvek
@ 2014-11-23 8:31 ` Wolfram Sang
2014-11-23 22:21 ` [PATCH v2] " Petr Cvek
2014-11-23 16:23 ` [PATCH] Add support for SCCB devices into PXA27x I2C controller Sergei Shtylyov
1 sibling, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2014-11-23 8:31 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Nov 22, 2014 at 11:52:07PM +0100, Petr Cvek wrote:
> Add support for SCCB devices into PXA27x I2C controller.
>
> Fix generated START but no STOP for message without I2C_M_NOSTART flag. Add
> support for I2C_M_IGNORE_NAK flag.
>
> Signed-off-by: Petr Cvek <petr.cvek@tul.cz>
I can't apply the patch. What is this based on? Can you rebase it to
i2c/for-next or the latest rc or at least the latest stable?
> ---
> drivers/i2c/busses/i2c-pxa.c | 22 ++++++++++++++++------
> 1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index be671f7..adad044 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -885,7 +885,14 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c,
> u32 isr)
> return; /* ignore */
> }
>
> - if (isr & ISR_BED) {
> + /*
> + * Ignore NAK when flag I2C_M_IGNORE_NAK is present,
> + * this enables use of SCCB devices
> + */
I'd think this comment is not needed since I2C_M_IGNORE_NAK is
self-explaining.
> + if ((isr & ISR_BED) &&
> + (!((i2c->msg->flags & I2C_M_IGNORE_NAK) &&
> + (isr & ISR_ACKNAK)))) {
> +
> int ret = BUS_ERROR;
>
> /*
> @@ -919,12 +926,15 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c,
> u32 isr)
> icr |= ICR_ALDIE | ICR_TB;
>
> /*
> - * If this is the last byte of the last message, send
> - * a STOP.
> + * If this is the last byte of the last message or last byte
> + * or any message without I2C_M_NOSTART, send a STOP.
> */
> - if (i2c->msg_ptr == i2c->msg->len &&
> - i2c->msg_idx == i2c->msg_num - 1)
> - icr |= ICR_STOP;
> + if (((i2c->msg_ptr == i2c->msg->len) &&
> + (!(i2c->msg->flags & I2C_M_NOSTART))) ||
> + ((i2c->msg_ptr == i2c->msg->len) &&
> + (i2c->msg_idx == i2c->msg_num - 1)))
You could factor out the length check. And you should check for
I2C_M_STOP, no?
> + icr |= ICR_STOP;
> +
> } else if (i2c->msg_idx < i2c->msg_num - 1) {
> /*
> * Next segment of the message.
> --
> 1.7.12.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141123/5b4b7190/attachment.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] Add support for SCCB devices into PXA27x I2C controller
2014-11-23 8:31 ` Wolfram Sang
@ 2014-11-23 22:21 ` Petr Cvek
2014-11-24 17:27 ` Wolfram Sang
0 siblings, 1 reply; 7+ messages in thread
From: Petr Cvek @ 2014-11-23 22:21 UTC (permalink / raw)
To: linux-arm-kernel
I'm sorry for spacing, I didn't realize thunderbird automatically replaces tabs with spaces. Now it should be OK.
I created this patch by fixing both I2C controller and SCCB device, so it seems I incorrectly used I2C_M_NOSTART instead I2C_M_STOP. Problem with I2C_M_STOP is that it causes bus freeze when using userspace utility "i2cget" on SCCB device (unfreeze can be done with i2c-pxa module reload). But this can be probably repaired in i2cget.
Patched kernel was from vanilla 3.18.0-rc5 commit fc14f9c1272f62c3e8d01300f52467c0d9af50f9
Signed-off-by: Petr Cvek <petr.cvek@tul.cz>
---
drivers/i2c/busses/i2c-pxa.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index be671f7..f80df8f 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -885,7 +885,9 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr)
return; /* ignore */
}
- if (isr & ISR_BED) {
+ if ((isr & ISR_BED) &&
+ (!((i2c->msg->flags & I2C_M_IGNORE_NAK) &&
+ (isr & ISR_ACKNAK)))) {
int ret = BUS_ERROR;
/*
@@ -919,12 +921,14 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr)
icr |= ICR_ALDIE | ICR_TB;
/*
- * If this is the last byte of the last message, send
- * a STOP.
+ * If this is the last byte of the last message or last byte
+ * of any message with I2C_M_STOP (e.g. SCCB), send a STOP.
*/
- if (i2c->msg_ptr == i2c->msg->len &&
- i2c->msg_idx == i2c->msg_num - 1)
- icr |= ICR_STOP;
+ if ((i2c->msg_ptr == i2c->msg->len) &&
+ ((i2c->msg->flags & I2C_M_STOP) ||
+ (i2c->msg_idx == i2c->msg_num - 1)))
+ icr |= ICR_STOP;
+
} else if (i2c->msg_idx < i2c->msg_num - 1) {
/*
* Next segment of the message.
@@ -1071,7 +1075,8 @@ static int i2c_pxa_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num
static u32 i2c_pxa_functionality(struct i2c_adapter *adap)
{
- return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
+ return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
+ I2C_FUNC_PROTOCOL_MANGLING | I2C_FUNC_NOSTART;
}
static const struct i2c_algorithm i2c_pxa_algorithm = {
--
1.7.12.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2] Add support for SCCB devices into PXA27x I2C controller
2014-11-23 22:21 ` [PATCH v2] " Petr Cvek
@ 2014-11-24 17:27 ` Wolfram Sang
2014-11-25 5:05 ` [PATCH v3] i2c-pxa: add support for SCCB devices Petr Cvek
0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2014-11-24 17:27 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Nov 23, 2014 at 11:21:22PM +0100, Petr Cvek wrote:
> I created this patch by fixing both I2C controller and SCCB device, so
> it seems I incorrectly used I2C_M_NOSTART instead I2C_M_STOP. Problem
> with I2C_M_STOP is that it causes bus freeze when using userspace
> utility "i2cget" on SCCB device (unfreeze can be done with i2c-pxa
> module reload). But this can be probably repaired in i2cget.
Please CC Jean Delvare, he maintains the I2C tools.
> Patched kernel was from vanilla 3.18.0-rc5 commit fc14f9c1272f62c3e8d01300f52467c0d9af50f9
Thanks but all these paragraphs describing the updates should have gone
below the "---" line. Your original commit message was more apropriate
and should have stayed.
> static u32 i2c_pxa_functionality(struct i2c_adapter *adap)
> {
> - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
> + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
> + I2C_FUNC_PROTOCOL_MANGLING | I2C_FUNC_NOSTART;
Okay, so NOSTART was previously implemented but not advertised? Please
update the commit log to say that this will be also fixed by your patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141124/21258621/attachment.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3] i2c-pxa: add support for SCCB devices
2014-11-24 17:27 ` Wolfram Sang
@ 2014-11-25 5:05 ` Petr Cvek
2014-11-25 14:26 ` Wolfram Sang
0 siblings, 1 reply; 7+ messages in thread
From: Petr Cvek @ 2014-11-25 5:05 UTC (permalink / raw)
To: linux-arm-kernel
Fixed missing functionality flag I2C_FUNC_NOSTART.
Added support for SCCB by implementing I2C_M_IGNORE_NAK and I2C_M_STOP flag and belonging functionality flag I2C_FUNC_PROTOCOL_MANGLING.
Signed-off-by: Petr Cvek <petr.cvek@tul.cz>
---
drivers/i2c/busses/i2c-pxa.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index be671f7..f80df8f 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -885,7 +885,9 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr)
return; /* ignore */
}
- if (isr & ISR_BED) {
+ if ((isr & ISR_BED) &&
+ (!((i2c->msg->flags & I2C_M_IGNORE_NAK) &&
+ (isr & ISR_ACKNAK)))) {
int ret = BUS_ERROR;
/*
@@ -919,12 +921,14 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr)
icr |= ICR_ALDIE | ICR_TB;
/*
- * If this is the last byte of the last message, send
- * a STOP.
+ * If this is the last byte of the last message or last byte
+ * of any message with I2C_M_STOP (e.g. SCCB), send a STOP.
*/
- if (i2c->msg_ptr == i2c->msg->len &&
- i2c->msg_idx == i2c->msg_num - 1)
- icr |= ICR_STOP;
+ if ((i2c->msg_ptr == i2c->msg->len) &&
+ ((i2c->msg->flags & I2C_M_STOP) ||
+ (i2c->msg_idx == i2c->msg_num - 1)))
+ icr |= ICR_STOP;
+
} else if (i2c->msg_idx < i2c->msg_num - 1) {
/*
* Next segment of the message.
@@ -1071,7 +1075,8 @@ static int i2c_pxa_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num
static u32 i2c_pxa_functionality(struct i2c_adapter *adap)
{
- return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
+ return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
+ I2C_FUNC_PROTOCOL_MANGLING | I2C_FUNC_NOSTART;
}
static const struct i2c_algorithm i2c_pxa_algorithm = {
--
1.7.12.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] Add support for SCCB devices into PXA27x I2C controller
2014-11-22 22:52 [PATCH] Add support for SCCB devices into PXA27x I2C controller Petr Cvek
2014-11-23 8:31 ` Wolfram Sang
@ 2014-11-23 16:23 ` Sergei Shtylyov
1 sibling, 0 replies; 7+ messages in thread
From: Sergei Shtylyov @ 2014-11-23 16:23 UTC (permalink / raw)
To: linux-arm-kernel
Hello.
On 11/23/2014 1:52 AM, Petr Cvek wrote:
> Add support for SCCB devices into PXA27x I2C controller.
> Fix generated START but no STOP for message without I2C_M_NOSTART flag. Add
> support for I2C_M_IGNORE_NAK flag.
> Signed-off-by: Petr Cvek <petr.cvek@tul.cz>
> ---
> drivers/i2c/busses/i2c-pxa.c | 22 ++++++++++++++++------
> 1 file changed, 16 insertions(+), 6 deletions(-)
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index be671f7..adad044 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -885,7 +885,14 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32
> isr)
> return; /* ignore */
> }
>
> - if (isr & ISR_BED) {
> + /*
Your patch has tabs replaces by spaces; probably your email agent's work. :-)
> + * Ignore NAK when flag I2C_M_IGNORE_NAK is present,
> + * this enables use of SCCB devices
> + */
> + if ((isr & ISR_BED) &&
> + (!((i2c->msg->flags & I2C_M_IGNORE_NAK) &&
> + (isr & ISR_ACKNAK)))) {
> +
This empty line is not needed.
[...]
WBR, Sergei
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-11-25 14:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-22 22:52 [PATCH] Add support for SCCB devices into PXA27x I2C controller Petr Cvek
2014-11-23 8:31 ` Wolfram Sang
2014-11-23 22:21 ` [PATCH v2] " Petr Cvek
2014-11-24 17:27 ` Wolfram Sang
2014-11-25 5:05 ` [PATCH v3] i2c-pxa: add support for SCCB devices Petr Cvek
2014-11-25 14:26 ` Wolfram Sang
2014-11-23 16:23 ` [PATCH] Add support for SCCB devices into PXA27x I2C controller Sergei Shtylyov
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).