All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gupta, Pekon" <pekon-l0cyMroinI0@public.gmane.org>
To: Trent Piepho <tpiepho-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	yuhang wang
	<wangyuhang2014-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "thomas.langer-th3ZBGNqt+7QT0dZR+AlfA@public.gmane.org"
	<thomas.langer-th3ZBGNqt+7QT0dZR+AlfA@public.gmane.org>,
	"Poddar, Sourav" <sourav.poddar-l0cyMroinI0@public.gmane.org>,
	"broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
	<broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	"spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org"
	<spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: RE: support DUAL and QUAD[patch v1]
Date: Fri, 19 Jul 2013 19:34:45 +0000	[thread overview]
Message-ID: <20980858CB6D3A4BAE95CA194937D5E73E9E967D@DBDE04.ent.ti.com> (raw)
In-Reply-To: <CA+7tXihoZZhpoyvxj58c+Zi-Zy631kK5s-kDoSxPKq=ej0qyvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

> 
> On Wed, Jul 17, 2013 at 6:58 PM, yuhang wang
> <wangyuhang2014-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > >> > >
> > >> > > > [Pekon]: Instead of adding new fields you can use existing 'mode'
> > >> > > > field
> > >> to
> > >> > > > pass on the platform specific configurations. And if 'u8 mode'
> > >> > > > does not
> > >> > > > suffice you can increase it to 'u32'.
> 
> But what about spidev?
> 
> > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> > index 004b10f..36d2451 100644
> > --- a/drivers/spi/spi.c
> > +++ b/drivers/spi/spi.c
> > @@ -868,6 +868,14 @@ static void of_register_spi_devices(struct
> > spi_master *master)
> >   spi->mode |= SPI_CS_HIGH;
> >   if (of_find_property(nc, "spi-3wire", NULL))
> >   spi->mode |= SPI_3WIRE;
> > + if (of_find_property(nc, "spi-tx-dual", NULL))
> > + spi->mode |= SPI_TX_DUAL;
> > + if (of_find_property(nc, "spi-tx-quad", NULL))
> > + spi->mode |= SPI_TX_QUAD;
> > + if (of_find_property(nc, "spi-rx-dual", NULL))
> > + spi->mode |= SPI_RX_DUAL;
> > + if (of_find_property(nc, "spi-rx-quad", NULL))
> > + spi->mode |= SPI_RX_QUAD;
> >
> >   /* Device speed */
> >   prop = of_get_property(nc, "spi-max-frequency", &len);
> > @@ -1316,6 +1324,12 @@ int spi_setup(struct spi_device *spi)
> >   /* help drivers fail *cleanly* when they need options
> >   * that aren't supported with their current master
> >   */
> > + if (((spi->mode >> 8) & 0x03) == 0x03 ||
> > + ((spi->mode >> 10) & 0x03) == 0x03) {
> > + dev_err(&spi->dev,
> > + "setup: can not select dual and quad at the same time\n");
> > + return -EINVAL;
> > + }
> 
> Maybe it would make more sense to have a spi-rx-width and spi-tx-width
> than can be set to 1, 2, 4, etc. bits instead of a bunch of properties
> that are mutually exclusive?  Sooner or later someone is going to want
> 8 bits.
> 
Then it would not remain a serial interface (Serial Peripheral Interface),
rather it would be more of parallel memory like interface.
And you would not like to use SPI controller for it, instead you would use
On-chip General Purpose External Interface controllers (like GPMC)
because it gives you more options to tweak and configure.

In general, If the place-holders are already there (like 'mode' field in 
struct spi_device), I would prefer to re-use them.
But if you are adding new ones just ensure its scalability and usage.
Names don't matter much there then, except for good readability.

> > diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
> > index 38c2b92..e9ba1cf 100644
> > --- a/include/linux/spi/spi.h
> > +++ b/include/linux/spi/spi.h
> > @@ -74,7 +74,7 @@ struct spi_device {
> >   struct spi_master *master;
> >   u32 max_speed_hz;
> >   u8 chip_select;
> > - u8 mode;
> > + u16 mode;
> 
> What about this, from include/uapi/linux/spi/spidev.h:
> 
> /* Read / Write of SPI mode (SPI_MODE_0..SPI_MODE_3) */
> #define SPI_IOC_RD_MODE                 _IOR(SPI_IOC_MAGIC, 1, __u8)
> #define SPI_IOC_WR_MODE                 _IOW(SPI_IOC_MAGIC, 1, __u8)
> 
> Note that you can't just change the type in the ioctl define, as it
> won't be backward compatible.
> 
Thanks, for pointing this out. Yes this is a constrain, if we change the
existing type. But I don't think u8 -> u32 is really required, it was just
a thought, not deep-dived.


with regards, pekon

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk

WARNING: multiple messages have this Message-ID (diff)
From: "Gupta, Pekon" <pekon@ti.com>
To: Trent Piepho <tpiepho@gmail.com>, yuhang wang <wangyuhang2014@gmail.com>
Cc: "thomas.langer@lantiq.com" <thomas.langer@lantiq.com>,
	"Poddar, Sourav" <sourav.poddar@ti.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"spi-devel-general@lists.sourceforge.net"
	<spi-devel-general@lists.sourceforge.net>
Subject: RE: support DUAL and QUAD[patch v1]
Date: Fri, 19 Jul 2013 19:34:45 +0000	[thread overview]
Message-ID: <20980858CB6D3A4BAE95CA194937D5E73E9E967D@DBDE04.ent.ti.com> (raw)
In-Reply-To: <CA+7tXihoZZhpoyvxj58c+Zi-Zy631kK5s-kDoSxPKq=ej0qyvA@mail.gmail.com>

> 
> On Wed, Jul 17, 2013 at 6:58 PM, yuhang wang
> <wangyuhang2014@gmail.com> wrote:
> > >> > >
> > >> > > > [Pekon]: Instead of adding new fields you can use existing 'mode'
> > >> > > > field
> > >> to
> > >> > > > pass on the platform specific configurations. And if 'u8 mode'
> > >> > > > does not
> > >> > > > suffice you can increase it to 'u32'.
> 
> But what about spidev?
> 
> > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> > index 004b10f..36d2451 100644
> > --- a/drivers/spi/spi.c
> > +++ b/drivers/spi/spi.c
> > @@ -868,6 +868,14 @@ static void of_register_spi_devices(struct
> > spi_master *master)
> >   spi->mode |= SPI_CS_HIGH;
> >   if (of_find_property(nc, "spi-3wire", NULL))
> >   spi->mode |= SPI_3WIRE;
> > + if (of_find_property(nc, "spi-tx-dual", NULL))
> > + spi->mode |= SPI_TX_DUAL;
> > + if (of_find_property(nc, "spi-tx-quad", NULL))
> > + spi->mode |= SPI_TX_QUAD;
> > + if (of_find_property(nc, "spi-rx-dual", NULL))
> > + spi->mode |= SPI_RX_DUAL;
> > + if (of_find_property(nc, "spi-rx-quad", NULL))
> > + spi->mode |= SPI_RX_QUAD;
> >
> >   /* Device speed */
> >   prop = of_get_property(nc, "spi-max-frequency", &len);
> > @@ -1316,6 +1324,12 @@ int spi_setup(struct spi_device *spi)
> >   /* help drivers fail *cleanly* when they need options
> >   * that aren't supported with their current master
> >   */
> > + if (((spi->mode >> 8) & 0x03) == 0x03 ||
> > + ((spi->mode >> 10) & 0x03) == 0x03) {
> > + dev_err(&spi->dev,
> > + "setup: can not select dual and quad at the same time\n");
> > + return -EINVAL;
> > + }
> 
> Maybe it would make more sense to have a spi-rx-width and spi-tx-width
> than can be set to 1, 2, 4, etc. bits instead of a bunch of properties
> that are mutually exclusive?  Sooner or later someone is going to want
> 8 bits.
> 
Then it would not remain a serial interface (Serial Peripheral Interface),
rather it would be more of parallel memory like interface.
And you would not like to use SPI controller for it, instead you would use
On-chip General Purpose External Interface controllers (like GPMC)
because it gives you more options to tweak and configure.

In general, If the place-holders are already there (like 'mode' field in 
struct spi_device), I would prefer to re-use them.
But if you are adding new ones just ensure its scalability and usage.
Names don't matter much there then, except for good readability.

> > diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
> > index 38c2b92..e9ba1cf 100644
> > --- a/include/linux/spi/spi.h
> > +++ b/include/linux/spi/spi.h
> > @@ -74,7 +74,7 @@ struct spi_device {
> >   struct spi_master *master;
> >   u32 max_speed_hz;
> >   u8 chip_select;
> > - u8 mode;
> > + u16 mode;
> 
> What about this, from include/uapi/linux/spi/spidev.h:
> 
> /* Read / Write of SPI mode (SPI_MODE_0..SPI_MODE_3) */
> #define SPI_IOC_RD_MODE                 _IOR(SPI_IOC_MAGIC, 1, __u8)
> #define SPI_IOC_WR_MODE                 _IOW(SPI_IOC_MAGIC, 1, __u8)
> 
> Note that you can't just change the type in the ioctl define, as it
> won't be backward compatible.
> 
Thanks, for pointing this out. Yes this is a constrain, if we change the
existing type. But I don't think u8 -> u32 is really required, it was just
a thought, not deep-dived.


with regards, pekon

  parent reply	other threads:[~2013-07-19 19:34 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-10  8:34 SPI: support DUAL and QUAD[patch v1] yuhang wang
2013-07-10  8:34 ` yuhang wang
     [not found] ` <CAHSAbzP0Nc1ahf_ra6yDuMvV998_+EGcUOGDv5ifKaagYf+NOg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-07-16  8:08   ` Gupta, Pekon
2013-07-16  8:08     ` Gupta, Pekon
     [not found]     ` <20980858CB6D3A4BAE95CA194937D5E73E9E84D2-yXqyApvAXouIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2013-07-16  8:59       ` yuhang wang
2013-07-16  8:59         ` yuhang wang
     [not found]         ` <CAHSAbzMDOWo5oBqUHqMxybuDwUjFbczYwN+85gH+rxZ9z8u2Pw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-07-16  9:11           ` Gupta, Pekon
2013-07-16  9:11             ` Gupta, Pekon
     [not found]             ` <20980858CB6D3A4BAE95CA194937D5E73E9E851E-yXqyApvAXouIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2013-07-16 10:12               ` thomas.langer-th3ZBGNqt+7QT0dZR+AlfA
2013-07-16 10:12                 ` thomas.langer
     [not found]                 ` <593AEF6C47F46446852B067021A273D6D93B49E1-6yu8tajIPx7U45ihrnOXy0EOCMrvLtNR@public.gmane.org>
2013-07-16 11:20                   ` Gupta, Pekon
2013-07-16 11:20                     ` Gupta, Pekon
     [not found]                     ` <20980858CB6D3A4BAE95CA194937D5E73E9E85D0-yXqyApvAXouIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2013-07-16 11:59                       ` yuhang wang
2013-07-16 11:59                         ` yuhang wang
2013-07-16 12:18                       ` thomas.langer-th3ZBGNqt+7QT0dZR+AlfA
2013-07-16 12:18                         ` thomas.langer
2013-07-18  1:58                       ` yuhang wang
2013-07-18  1:58                         ` yuhang wang
     [not found]                         ` <CAHSAbzP5jqHwCm0qhu=DiNzpP0swqWHsQ0=MnF+EKaSN22E5hg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-07-18  2:25                           ` Trent Piepho
2013-07-18  2:25                             ` Trent Piepho
     [not found]                             ` <CA+7tXihoZZhpoyvxj58c+Zi-Zy631kK5s-kDoSxPKq=ej0qyvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-07-19  2:24                               ` yuhang wang
2013-07-19  2:24                                 ` yuhang wang
2013-07-19 19:34                               ` Gupta, Pekon [this message]
2013-07-19 19:34                                 ` Gupta, Pekon
2013-07-22  9:33                                 ` Mark Brown
2013-07-22  9:33                                   ` Mark Brown
     [not found]                                   ` <20130722093342.GJ9858-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-07-22  9:56                                     ` Gupta, Pekon
2013-07-22  9:56                                       ` Gupta, Pekon
2013-07-22 10:32                                       ` Huang Shijie
2013-07-22 10:32                                         ` Huang Shijie
     [not found]                                         ` <51ED0A57.4060105-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-07-22 11:21                                           ` thomas.langer-th3ZBGNqt+7QT0dZR+AlfA
2013-07-22 11:21                                             ` thomas.langer
2013-07-22 12:55                                             ` Gupta, Pekon
2013-07-22 12:55                                               ` Gupta, Pekon
     [not found]                                               ` <20980858CB6D3A4BAE95CA194937D5E73E9ECAFC-yXqyApvAXouIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2013-07-23  2:24                                                 ` Huang Shijie
2013-07-23  2:24                                                   ` Huang Shijie
     [not found]                                       ` <20980858CB6D3A4BAE95CA194937D5E73E9EC9B1-yXqyApvAXouIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2013-07-27 11:35                                         ` yuhang wang
2013-07-27 11:35                                           ` yuhang wang
2013-07-16  9:29         ` Mark Brown
2013-07-16  9:29           ` Mark Brown

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=20980858CB6D3A4BAE95CA194937D5E73E9E967D@DBDE04.ent.ti.com \
    --to=pekon-l0cymroini0@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=sourav.poddar-l0cyMroinI0@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=thomas.langer-th3ZBGNqt+7QT0dZR+AlfA@public.gmane.org \
    --cc=tpiepho-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=wangyuhang2014-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 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.