devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Bernie Thompson
	<bhthompson-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Andrew Bresticker
	<abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Rhyland Klein <rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
	Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
	Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Ian Campbell
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>
Subject: Re: [PATCH] mfd: cros ec: spi: Add delay for raising CS
Date: Mon, 25 Nov 2013 11:04:29 +0100	[thread overview]
Message-ID: <20131125100428.GG22043@ulmo.nvidia.com> (raw)
In-Reply-To: <20131125094503.GD17722@lee--X1>

[-- Attachment #1: Type: text/plain, Size: 3370 bytes --]

On Mon, Nov 25, 2013 at 09:45:03AM +0000, Lee Jones wrote:
> On Fri, 22 Nov 2013, Thierry Reding wrote:
> 
> > From: Rhyland Klein <rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> > 
> > The EC has specific timing it requires. Add support for an optional delay
> > after raising CS to fix timing issues. This is configurable based on
> > a DT property "google,cros-ec-spi-msg-delay".
> > 
> > If this property isn't set, then no delay will be added. However, if set
> > it will cause a delay equal to the value passed to it to be inserted at
> > the end of a transaction.
> > 
> > Signed-off-by: Rhyland Klein <rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> > Reviewed-by: Bernie Thompson <bhthompson-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> > Reviewed-by: Andrew Bresticker <abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> > Cc: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> > Cc: Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>
> > Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
> > Cc: Ian Campbell <ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>
> > Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> > ---
> > Changes in v2:
> > - make property description more verbose
> > 
> >  Documentation/devicetree/bindings/mfd/cros-ec.txt |  9 +++++++
> 
> We need a DT dude to look over this.

I think Mark Rutland looked at this last week and I think I've addressed
all his comments. Hopefully he'll find the time to review this.

> >  drivers/mfd/cros_ec_spi.c                         | 30 +++++++++++++++++++++++
> >  2 files changed, 39 insertions(+)
> 
> <snip>
> 
> >  static void debug_packet(struct device *dev, const char *name, u8 *ptr,
> > @@ -238,6 +242,17 @@ static int cros_ec_command_spi_xfer(struct cros_ec_device *ec_dev,
> >  
> >  	/* turn off CS */
> >  	spi_message_init(&msg);
> > +
> > +	if (ec_spi->end_of_msg_delay) {
> > +		/*
> > +		 * Add delay for last transaction, to ensure the rising edge
> > +		 * doesn't come too soon after the end of the data.
> > +		 */
> > +		memset(&trans, '\0', sizeof(trans));
> 
> Just use the usual 0 for the third parameter.

Will fix.

> > +static void cros_ec_probe_spi_dt(struct cros_ec_spi *ec_spi, struct device *dev)
> 
> Traditionally we have 'probe' as the last word in the function name.

Okay.

> > +{
> > +	struct device_node *np = dev->of_node;
> > +	u32 val;
> > +	int ret;
> > +
> > +	ret = of_property_read_u32(np, "google,cros-ec-spi-msg-delay", &val);
> > +	if (!ret)
> > +		ec_spi->end_of_msg_delay = val;
> > +}
> > +
> >  static int cros_ec_probe_spi(struct spi_device *spi)
> 
> Can you send a pre-patch to fix this too please:
>   static int cros_ec_spi_probe(struct spi_device *spi)

Yes, I will.

> <snip>
> 
> > +	/* Check for any DT properties */
> > +	if (IS_ENABLED(CONFIG_OF) && dev->of_node)
> 
> No need for the first check.

Why not? While it is true that dev->of_node would be enough to determine
that the device was instantiated from a device tree, the IS_ENABLED()
will allow the compiler to throw away cros_ec_spi_dt_probe() if OF isn't
enabled. At the same time it's nicer than #ifdeffery sprinkled across
the file and it actually compile-tests all the code. Win-win-win, isn't
it?

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2013-11-25 10:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-22 18:05 [PATCH] mfd: cros ec: spi: Add delay for raising CS Thierry Reding
     [not found] ` <1385143550-31901-1-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-11-25  9:45   ` Lee Jones
2013-11-25 10:04     ` Thierry Reding [this message]
     [not found]       ` <20131125100428.GG22043-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2013-11-25 10:45         ` Lee Jones
2013-11-25 11:28           ` Thierry Reding
     [not found]             ` <20131125112852.GK22043-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2013-11-25 12:10               ` Lee Jones
2013-12-06 21:02                 ` Thierry Reding
2013-12-06 21:12                   ` Andrew Bresticker
2013-11-25 10:08     ` Thierry Reding
     [not found]       ` <20131125100834.GH22043-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2013-11-25 10:36         ` Lee Jones

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=20131125100428.GG22043@ulmo.nvidia.com \
    --to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=bhthompson-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
    --cc=rklein-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
    --cc=sameo-VuQAYsv1563Yd54FQh9/CA@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).