From: jacopo mondi <jacopo@jmondi.org>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-i2c@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Subject: Re: [PATCH] i2c: sh_mobile: send STOP according to datasheet
Date: Tue, 14 Nov 2017 10:10:16 +0100 [thread overview]
Message-ID: <20171114091016.GF19070@w540> (raw)
In-Reply-To: <20171110115210.21955-1-wsa+renesas@sang-engineering.com>
Hi Wolfram,
On Fri, Nov 10, 2017 at 12:52:10PM +0100, Wolfram Sang wrote:
> We initiate STOP (or REP_START) on the second last WAIT interrupt
> currently. This works fine but is not according to the datasheet which
> says to do it on the last WAIT interrupt. This also simplifies the code
> quite a lot, so let's do it.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>
> Jacopo: another one to test, pretty please.
No regressions on Migo-R during image capture.
Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Thanks
j
>
> drivers/i2c/busses/i2c-sh_mobile.c | 29 ++++++-----------------------
> 1 file changed, 6 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
> index 40a66d466c3c49..c904be631db302 100644
> --- a/drivers/i2c/busses/i2c-sh_mobile.c
> +++ b/drivers/i2c/busses/i2c-sh_mobile.c
> @@ -40,21 +40,21 @@
> /* BUS: S A8 ACK P(*) */
> /* IRQ: DTE WAIT */
> /* ICIC: */
> -/* ICCR: 0x94 0x90 */
> +/* ICCR: 0x94 0x90 */
> /* ICDR: A8 */
> /* */
> /* 1 byte transmit */
> /* BUS: S A8 ACK D8(1) ACK P(*) */
> /* IRQ: DTE WAIT WAIT */
> /* ICIC: -DTE */
> -/* ICCR: 0x94 0x90 */
> +/* ICCR: 0x94 0x90 */
> /* ICDR: A8 D8(1) */
> /* */
> /* 2 byte transmit */
> /* BUS: S A8 ACK D8(1) ACK D8(2) ACK P(*) */
> /* IRQ: DTE WAIT WAIT WAIT */
> /* ICIC: -DTE */
> -/* ICCR: 0x94 0x90 */
> +/* ICCR: 0x94 0x90 */
> /* ICDR: A8 D8(1) D8(2) */
> /* */
> /* 3 bytes or more, +---------+ gets repeated */
> @@ -113,7 +113,6 @@ enum sh_mobile_i2c_op {
> OP_TX_FIRST,
> OP_TX,
> OP_TX_STOP,
> - OP_TX_STOP_DATA,
> OP_TX_TO_RX,
> OP_RX,
> OP_RX_STOP,
> @@ -319,10 +318,7 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd,
> case OP_TX: /* write data */
> iic_wr(pd, ICDR, data);
> break;
> - case OP_TX_STOP_DATA: /* write data and issue a stop afterwards */
> - iic_wr(pd, ICDR, data);
> - /* fallthrough */
> - case OP_TX_STOP: /* issue a stop */
> + case OP_TX_STOP: /* issue a stop (or rep_start) */
> iic_wr(pd, ICCR, pd->send_stop ? ICCR_ICE | ICCR_TRS
> : ICCR_ICE | ICCR_TRS | ICCR_BBSY);
> break;
> @@ -356,11 +352,6 @@ static bool sh_mobile_i2c_is_first_byte(struct sh_mobile_i2c_data *pd)
> return pd->pos == -1;
> }
>
> -static bool sh_mobile_i2c_is_last_byte(struct sh_mobile_i2c_data *pd)
> -{
> - return pd->pos == pd->msg->len - 1;
> -}
> -
> static void sh_mobile_i2c_get_data(struct sh_mobile_i2c_data *pd,
> unsigned char *buf)
> {
> @@ -378,20 +369,12 @@ static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd)
> unsigned char data;
>
> if (pd->pos == pd->msg->len) {
> - /* Send stop if we haven't yet (DMA case) */
> - if (pd->send_stop && pd->stop_after_dma)
> - i2c_op(pd, OP_TX_STOP, 0);
> + i2c_op(pd, OP_TX_STOP, 0);
> return 1;
> }
>
> sh_mobile_i2c_get_data(pd, &data);
> -
> - if (sh_mobile_i2c_is_last_byte(pd))
> - i2c_op(pd, OP_TX_STOP_DATA, data);
> - else if (sh_mobile_i2c_is_first_byte(pd))
> - i2c_op(pd, OP_TX_FIRST, data);
> - else
> - i2c_op(pd, OP_TX, data);
> + i2c_op(pd, sh_mobile_i2c_is_first_byte(pd) ? OP_TX_FIRST : OP_TX, data);
>
> pd->pos++;
> return 0;
> --
> 2.11.0
>
next prev parent reply other threads:[~2017-11-14 9:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 11:52 [PATCH] i2c: sh_mobile: send STOP according to datasheet Wolfram Sang
2017-11-10 13:29 ` Niklas Söderlund
2017-11-10 13:29 ` Niklas Söderlund
2017-11-14 9:10 ` jacopo mondi [this message]
2017-11-27 17:57 ` Wolfram Sang
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=20171114091016.GF19070@w540 \
--to=jacopo@jmondi.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/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.