From d5ee722ab942451929ccf5bec4fb41f6d044b5c7 Mon Sep 17 00:00:00 2001 From: wangyuhang Date: Fri, 30 Aug 2013 18:05:10 +0800 Subject: spi: quad: Fix missing return Delete a "return" when commit the patch to a new kernel version by mistake. So recover it. Signed-off-by: wangyuhang Signed-off-by: Mark Brown diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 50f7fc3..f0a6582 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1463,6 +1463,7 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) return -EINVAL; if (xfer->speed_hz && master->max_speed_hz && xfer->speed_hz > master->max_speed_hz) + return -EINVAL; if (xfer->tx_buf && !xfer->tx_nbits) xfer->tx_nbits = SPI_NBITS_SINGLE; -- cgit v0.10.2 From a822e99c70f448c4068ea85bb195dac0b2eb3afe Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 30 Aug 2013 23:19:40 +0100 Subject: spi: quad: Make DT properties optional The addition SPI quad support made the DT properties mandatory, breaking compatibility with existing systems. Fix that by making them optional, also improving the error messages while we're at it. Signed-off-by: Mark Brown Tested-by: Stephen Warren diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index f0a6582..7557f61 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -871,47 +871,43 @@ static void of_register_spi_devices(struct spi_master *master) /* Device DUAL/QUAD mode */ prop = of_get_property(nc, "spi-tx-nbits", &len); - if (!prop || len < sizeof(*prop)) { - dev_err(&master->dev, "%s has no 'spi-tx-nbits' property\n", - nc->full_name); - spi_dev_put(spi); - continue; - } - switch (be32_to_cpup(prop)) { - case SPI_NBITS_SINGLE: - break; - case SPI_NBITS_DUAL: - spi->mode |= SPI_TX_DUAL; - break; - case SPI_NBITS_QUAD: - spi->mode |= SPI_TX_QUAD; - break; - default: - dev_err(&master->dev, "spi-tx-nbits value is not supported\n"); - spi_dev_put(spi); - continue; + if (prop && len == sizeof(*prop)) { + switch (be32_to_cpup(prop)) { + case SPI_NBITS_SINGLE: + break; + case SPI_NBITS_DUAL: + spi->mode |= SPI_TX_DUAL; + break; + case SPI_NBITS_QUAD: + spi->mode |= SPI_TX_QUAD; + break; + default: + dev_err(&master->dev, + "spi-tx-nbits %d not supported\n", + be32_to_cpup(prop)); + spi_dev_put(spi); + continue; + } } prop = of_get_property(nc, "spi-rx-nbits", &len); - if (!prop || len < sizeof(*prop)) { - dev_err(&master->dev, "%s has no 'spi-rx-nbits' property\n", - nc->full_name); - spi_dev_put(spi); - continue; - } - switch (be32_to_cpup(prop)) { - case SPI_NBITS_SINGLE: - break; - case SPI_NBITS_DUAL: - spi->mode |= SPI_RX_DUAL; - break; - case SPI_NBITS_QUAD: - spi->mode |= SPI_RX_QUAD; - break; - default: - dev_err(&master->dev, "spi-rx-nbits value is not supported\n"); - spi_dev_put(spi); - continue; + if (prop && len == sizeof(*prop)) { + switch (be32_to_cpup(prop)) { + case SPI_NBITS_SINGLE: + break; + case SPI_NBITS_DUAL: + spi->mode |= SPI_RX_DUAL; + break; + case SPI_NBITS_QUAD: + spi->mode |= SPI_RX_QUAD; + break; + default: + dev_err(&master->dev, + "spi-rx-nbits %d not supported\n", + be32_to_cpup(prop)); + spi_dev_put(spi); + continue; + } } /* Device speed */ -- cgit v0.10.2 From a110f93d8b4672c4ad18d911f62b9e861010e83b Mon Sep 17 00:00:00 2001 From: wangyuhang Date: Sun, 1 Sep 2013 17:36:21 +0800 Subject: spi: quad: fix the name of DT property spi: quad: fix the name of DT property in patch The previous property name spi-tx-nbits and spi-rx-nbits looks not human-readable. To make it consistent with other devices, using property name spi-tx-bus-width and spi-rx-bus-width instead of the previous one specify the number of data wires that spi controller will work in. Add the specification in spi-bus.txt. Signed-off-by: wangyuhang Signed-off-by: Mark Brown diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt index 296015e..800dafe 100644 --- a/Documentation/devicetree/bindings/spi/spi-bus.txt +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt @@ -55,6 +55,16 @@ contain the following properties. chip select active high - spi-3wire - (optional) Empty property indicating device requires 3-wire mode. +- spi-tx-bus-width - (optional) The bus width(number of data wires) that + used for MOSI. Defaults to 1 if not present. +- spi-rx-bus-width - (optional) The bus width(number of data wires) that + used for MISO. Defaults to 1 if not present. + +Some SPI controllers and devices support Dual and Quad SPI transfer mode. +It allows data in SPI system transfered in 2 wires(DUAL) or 4 wires(QUAD). +Now the value that spi-tx-bus-width and spi-rx-bus-width can receive is +only 1(SINGLE), 2(DUAL) and 4(QUAD). +Dual/Quad mode is not allowed when 3-wire mode is used. If a gpio chipselect is used for the SPI slave the gpio number will be passed via the cs_gpio diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 7557f61..0075318 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -870,7 +870,7 @@ static void of_register_spi_devices(struct spi_master *master) spi->mode |= SPI_3WIRE; /* Device DUAL/QUAD mode */ - prop = of_get_property(nc, "spi-tx-nbits", &len); + prop = of_get_property(nc, "spi-tx-bus-width", &len); if (prop && len == sizeof(*prop)) { switch (be32_to_cpup(prop)) { case SPI_NBITS_SINGLE: @@ -883,14 +883,14 @@ static void of_register_spi_devices(struct spi_master *master) break; default: dev_err(&master->dev, - "spi-tx-nbits %d not supported\n", + "spi-tx-bus-width %d not supported\n", be32_to_cpup(prop)); spi_dev_put(spi); continue; } } - prop = of_get_property(nc, "spi-rx-nbits", &len); + prop = of_get_property(nc, "spi-rx-bus-width", &len); if (prop && len == sizeof(*prop)) { switch (be32_to_cpup(prop)) { case SPI_NBITS_SINGLE: @@ -903,7 +903,7 @@ static void of_register_spi_devices(struct spi_master *master) break; default: dev_err(&master->dev, - "spi-rx-nbits %d not supported\n", + "spi-rx-bus-width %d not supported\n", be32_to_cpup(prop)); spi_dev_put(spi); continue; -- cgit v0.10.2