From: Gerhard Sittig <gsi-ynQEQJNshbs@public.gmane.org>
To: Alexander Shiyan <shc_work-JGs/UdohzUI@public.gmane.org>
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH RFC] Remove "spi-cs-high" property for GPIO-based chipselects
Date: Mon, 2 Dec 2013 15:59:11 +0100 [thread overview]
Message-ID: <20131202145911.GT2982@book.gsilab.sittig.org> (raw)
In-Reply-To: <1385884756-31373-1-git-send-email-shc_work-JGs/UdohzUI@public.gmane.org>
On Sun, Dec 01, 2013 at 11:59 +0400, Alexander Shiyan wrote:
>
> This patch takes the CS active level from the GPIO bindings,
> so we remove the special property "spi-cs-high" for chipselects
> that use GPIO.
I'm afraid this description does not reflect what the patch does.
This is not saying that the patch is wrong, but suggests that the
description may be in need of an update.
Whether there is some gain in the change is a different matter,
see below.
> Signed-off-by: Alexander Shiyan <shc_work-JGs/UdohzUI@public.gmane.org>
> ---
> drivers/spi/spi.c | 28 ++++++++++++++++++----------
> include/linux/spi/spi.h | 2 ++
> 2 files changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 98f4b77..d2ba1ec 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -413,8 +413,12 @@ int spi_add_device(struct spi_device *spi)
> goto done;
> }
>
> - if (master->cs_gpios)
> + if (master->cs_gpios) {
> spi->cs_gpio = master->cs_gpios[spi->chip_select];
> + if (!(master->cs_gpios_flags[spi->chip_select] &
> + OF_GPIO_ACTIVE_LOW))
> + spi->mode |= SPI_CS_HIGH;
> + }
>
> /* Drivers may modify this initial i/o setup, but will
> * normally rely on the device being setup. Devices
OK, so you accept GPIO flags as an _additional_ source of
information, to derive "CS high" attributes in the SPI subsystem
in the (potential) absence of explicit specs in the device tree.
I'm not quite certain whether the GPIO pin's "not being inverted"
(not being low-active, the de-facto default for a GPIO pin) and
the SPI chip select's being high-active really are the same
thing. Unless I'm missing something, this is quite a change in
semantics. (Should this automatic deriving attributes emit a
message as well, to raise awareness? Are we spamming users then,
or do these go unnoticed und ignored?)
Does this patch _force_ those who use GPIOs for SPI CS to adjust
their GPIO configuration in device trees? Or make SPI
communication fail if the device tree won't get adjusted? Should
you adjust users as well, and put a big fat remark into the
documentation?
A quick 'git grep spi-cs-high' reveals just one in-tree user, but
I'd expect quite a lot out-of-tree users which assume "regular,
straight semantics".
> @@ -1027,10 +1031,14 @@ static void of_register_spi_devices(struct spi_master *master)
> spi->mode |= SPI_CPHA;
> if (of_find_property(nc, "spi-cpol", NULL))
> spi->mode |= SPI_CPOL;
> - if (of_find_property(nc, "spi-cs-high", NULL))
> - spi->mode |= SPI_CS_HIGH;
> if (of_find_property(nc, "spi-3wire", NULL))
> spi->mode |= SPI_3WIRE;
> + if (of_find_property(nc, "spi-cs-high", NULL)) {
> + if (master->cs_gpios)
> + dev_notice(&master->dev,
> + "\"spi-cs-high\" property is obsolete.\n");
> + spi->mode |= SPI_CS_HIGH;
> + }
>
> /* Device DUAL/QUAD mode */
> if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) {
Here you keep the evaluation of the 'spi-cs-high' property.
Which is a good thing, and should not go away as Mark has
suggested, at least not without proper period of migration.
You introduce a diagnostic message if SPI CS is high-active (and
this spec comes from the SPI node) and the CS is backed by a GPIO
pin.
Considering that you cannot remove the "CS high-active" attribute
in general, and need to keep the 'spi-cs-high' property for those
cases where the signal is not driven by means of GPIO, and keep
backwards compatibility for GPIO backed signals -- is there
really any gain in the change?
I'm afraid that forcing users to specify the same "this SPI
slave's CS is high-active" information in different ways
depending on whether the signal is generated by GPIO or by other
means is not a good thing. I'm even questioning the benefit of
introducing the optional second source of this information by
deriving it from the GPIO flags. Am I missing something?
[ it's just a nit that hou move the 'spi-cs-high' evaluation in
the patch while I fail to see the motivation of the move, it's
neither logical grouping nor alphabetical sorting ]
virtually yours
Gerhard Sittig
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office-ynQEQJNshbs@public.gmane.org
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-12-02 14:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-01 7:59 [PATCH RFC] Remove "spi-cs-high" property for GPIO-based chipselects Alexander Shiyan
[not found] ` <1385884756-31373-1-git-send-email-shc_work-JGs/UdohzUI@public.gmane.org>
2013-12-02 11:43 ` Mark Brown
[not found] ` <20131202114310.GP27568-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-12-02 11:58 ` Alexander Shiyan
[not found] ` <1385985513.987194654-zxFGIbyeZotsdVUOrk1QfQ@public.gmane.org>
2013-12-02 12:33 ` Mark Brown
[not found] ` <20131202123339.GZ27568-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-12-02 12:42 ` Alexander Shiyan
[not found] ` <1385988152.848953040-u8tvknxLvilsdVUOrk1QfQ@public.gmane.org>
2013-12-02 12:46 ` Mark Brown
2013-12-02 13:49 ` Jonas Gorski
[not found] ` <CAOiHx=nAcGdk7QgKPrbmkbQYzWL6qNb2cnJj3c_A+9++RrLoeA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-02 14:54 ` Alexander Shiyan
[not found] ` <1385996099.869286515-/wTItXjRvv7WO3iv0lnsqw@public.gmane.org>
2013-12-02 18:03 ` Jonas Gorski
[not found] ` <CAOiHx=kLkiWjnuUV_1-rVrO-EDQw=Ut0eZE5egYrmiVK9wmxfw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-02 20:17 ` Gerhard Sittig
[not found] ` <20131202201722.GZ2982-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org>
2013-12-02 22:09 ` Jonas Gorski
[not found] ` <CAOiHx=krrM+NZ7detAv9_UsB+bUXtKL0m4=pDHO30uduJsDdFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-12-02 22:36 ` Gerhard Sittig
[not found] ` <20131202223632.GA2982-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org>
2013-12-03 4:23 ` Alexander Shiyan
2013-12-02 14:59 ` Gerhard Sittig [this message]
[not found] ` <20131202145911.GT2982-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org>
2013-12-02 15:24 ` Alexander Shiyan
[not found] ` <1385997862.727371043-/wTItXjRvv7WO3iv0lnsqw@public.gmane.org>
2013-12-02 16:31 ` Gerhard Sittig
[not found] ` <20131202163124.GW2982-kDjWylLy9wD0K7fsECOQyeGNnDKD8DIp@public.gmane.org>
2013-12-02 17:14 ` Alexander Shiyan
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=20131202145911.GT2982@book.gsilab.sittig.org \
--to=gsi-ynqeqjnshbs@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=shc_work-JGs/UdohzUI@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).