devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
To: Joachim Eastwood <manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 1/2] i2c: add i2c-lpc2k driver
Date: Sat, 15 Aug 2015 22:24:28 +0200	[thread overview]
Message-ID: <20150815202423.GD3463@katana> (raw)
In-Reply-To: <1436741242-13489-2-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Mon, Jul 13, 2015 at 12:47:21AM +0200, Joachim Eastwood wrote:
> Add support for the I2C controller found on several NXP devices
> including LPC2xxx, LPC178x/7x and LPC18xx/43xx. The controller
> is implemented as a state machine and the driver act upon the
> state changes when the bus is accessed.
> 
> The I2C controller supports master/slave operation, bus
> arbitration, programmable clock rate, and speeds up to 1 Mbit/s.
> 
> Signed-off-by: Joachim Eastwood <manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Thanks for the submission! Looking mostly good already.

> +static void i2c_lpc2k_pump_msg(struct lpc2k_i2c *i2c)
> +{
> +	unsigned char data;
> +	u32 status;
> +
> +	/*
> +	 * I2C in the LPC2xxx series is basically a state machine.
> +	 * Just run through the steps based on the current status.
> +	 */
> +	status = readl(i2c->reg_base + LPC24XX_I2STAT);
> +
> +	switch (status) {
> +	case M_START:
> +	case M_REPSTART:
> +		/* Start bit was just sent out, send out addr and dir */
> +		data = (i2c->msg->addr << 1);
> +		if (i2c->msg->flags & I2C_M_RD)
> +			data |= 1;
> +
> +		writel(data, i2c->reg_base + LPC24XX_I2DAT);
> +		writel(LPC24XX_STA, i2c->reg_base + LPC24XX_I2CONCLR);
> +
> +		dev_dbg(&i2c->adap.dev, "Start sent with addr 0x%02x\n", data);

I assume the driver is basically working. So, in my book, most of this
debug output is useful when the driver was developed, not so much
afterwards. Also, it is printed in interrupt context possibly causing
latency. However, the information is useful for understanding the
driver, so I'd suggest to convert them into comments?

> +	i2c->adap.nr = pdev->id;
> +
> +	ret = i2c_add_numbered_adapter(&i2c->adap);

Intended? Most DT enabled drivers simply user i2c_add_adapter(). The
core then takes care of aliases defined in DT.

And please have a look at Documentation/i2c/fault-codes. Arbitration
Lost should be -EAGAIN, NACK should be -ENXIO, and so forth...

Thanks,

   Wolfram

  parent reply	other threads:[~2015-08-15 20:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-12 22:47 [PATCH 0/2] I2C support for NXP LPC18xx family Joachim Eastwood
     [not found] ` <1436741242-13489-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-12 22:47   ` [PATCH 1/2] i2c: add i2c-lpc2k driver Joachim Eastwood
     [not found]     ` <1436741242-13489-2-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-15 20:24       ` Wolfram Sang [this message]
2015-08-15 21:57         ` Joachim Eastwood
2015-07-12 22:47   ` [PATCH 2/2] doc: dt: add documentation for i2c-lpc2k Joachim Eastwood

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=20150815202423.GD3463@katana \
    --to=wsa-z923lk4zbo2bacvfa/9k2g@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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).