From: Wolfram Sang <wsa@the-dreams.de>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: robh+dt@kernel.org, mark.rutland@arm.com,
linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, jassisinghbrar@gmail.com,
andy.shevchenko@gmail.com
Subject: Re: [PATCH v5 2/2] i2c: add support for Socionext SynQuacer I2C controller
Date: Sun, 25 Mar 2018 00:19:10 +0100 [thread overview]
Message-ID: <20180324231910.unzvwty3xia4mqu2@ninjato> (raw)
In-Reply-To: <20180302083123.7259-3-ard.biesheuvel@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 2670 bytes --]
Hi Ard,
> +static int synquacer_i2c_master_start(struct synquacer_i2c *i2c,
> + struct i2c_msg *pmsg)
> +{
> + unsigned char bsr, bcr;
> +
> + if (pmsg->flags & I2C_M_RD)
> + writeb((pmsg->addr << 1) | 1,
> + i2c->base + SYNQUACER_I2C_REG_DAR);
> + else
> + writeb(pmsg->addr << 1,
> + i2c->base + SYNQUACER_I2C_REG_DAR);
writeb(i2c_8bit_addr_from_msg(pmsg), i2c->base + SYNQUACER_I2C_REG_DAR);
?
> +static int synquacer_i2c_master_recover(struct synquacer_i2c *i2c)
> +{
This is the bus recovery mechanism with toggling SCL pulses, right?
That should be implemented using a 'struct i2c_bus_recovery_info' and
the core helpers.
> +static int synquacer_i2c_doxfer(struct synquacer_i2c *i2c,
> + struct i2c_msg *msgs, int num)
> +{
> + unsigned char bsr;
> + unsigned long timeout, bb_timeout;
> + int ret;
> +
> + if (i2c->is_suspended)
> + return -EBUSY;
> +
> + synquacer_i2c_hw_init(i2c);
> + bsr = readb(i2c->base + SYNQUACER_I2C_REG_BSR);
> + if (bsr & SYNQUACER_I2C_BSR_BB) {
> + dev_err(i2c->dev, "cannot get bus (bus busy)\n");
> + return -EBUSY;
> + }
> +
> + init_completion(&i2c->completion);
reinit_completion? And init_completion() in probe()?
> + /* ensure the stop has been through the bus */
> + bb_timeout = jiffies + HZ;
> + do {
> + bsr = readb(i2c->base + SYNQUACER_I2C_REG_BSR);
> + if (!(bsr & SYNQUACER_I2C_BSR_BB))
> + return 0;
> + } while (time_before(jiffies, bb_timeout));
Busy looping for one second? And won't the bus_free detection at the
beginning of a transfer do?
> +static int synquacer_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
> + int num)
> +{
> + struct synquacer_i2c *i2c;
> + int retry;
> + int ret;
> +
> + if (!msgs)
> + return -EINVAL;
> + if (num <= 0)
> + return -EINVAL;
Hmm, this should be done by the core. I am surprised it doesn't do that yet :/
> +
> + i2c = i2c_get_adapdata(adap);
> + i2c->timeout_ms = calc_timeout_ms(i2c, msgs, num);
> +
> + dev_dbg(i2c->dev, "calculated timeout %d ms\n", i2c->timeout_ms);
> +
> + for (retry = 0; retry < adap->retries; retry++) {
> +
> + ret = synquacer_i2c_doxfer(i2c, msgs, num);
> + if (ret != -EAGAIN)
> + return ret;
> +
> + dev_dbg(i2c->dev, "Retrying transmission (%d)\n", retry);
> +
> + synquacer_i2c_master_recover(i2c);
Recovery is only when SDA is stuck low, held by a client. That is
nothing you should do just on any error.
If you want the driver in v4.17, I'd suggest to drop
synquacer_i2c_master_recover() now and add it incrementally later, using
the existing recovery infrastructure. The rest is only minor stuff and
needs not much further discussion IMO.
Regards,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-03-24 23:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-02 8:31 [PATCH v5 0/2] add support for Socionext SynQuacer I2C controller Ard Biesheuvel
2018-03-02 8:31 ` [PATCH v5 1/2] dt-bindings: i2c: add binding for Socionext SynQuacer I2C Ard Biesheuvel
2018-03-02 8:31 ` [PATCH v5 2/2] i2c: add support for Socionext SynQuacer I2C controller Ard Biesheuvel
2018-03-24 23:19 ` Wolfram Sang [this message]
2018-03-24 23:25 ` Wolfram Sang
2018-03-25 10:30 ` Ard Biesheuvel
2018-03-10 15:01 ` [PATCH v5 0/2] " Ard Biesheuvel
2018-03-16 16:19 ` Ard Biesheuvel
2018-03-21 1:48 ` Ard Biesheuvel
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=20180324231910.unzvwty3xia4mqu2@ninjato \
--to=wsa@the-dreams.de \
--cc=andy.shevchenko@gmail.com \
--cc=ard.biesheuvel@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=jassisinghbrar@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@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