diff options
| -rw-r--r-- | Documentation/devicetree/bindings/spi/spi-bus.txt | 10 | ||||
| -rw-r--r-- | drivers/spi/spi.c | 77 |
2 files changed, 47 insertions, 40 deletions
diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt index 296015e3c632..800dafe5b01b 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. | |||
| 55 | chip select active high | 55 | chip select active high |
| 56 | - spi-3wire - (optional) Empty property indicating device requires | 56 | - spi-3wire - (optional) Empty property indicating device requires |
| 57 | 3-wire mode. | 57 | 3-wire mode. |
| 58 | - spi-tx-bus-width - (optional) The bus width(number of data wires) that | ||
| 59 | used for MOSI. Defaults to 1 if not present. | ||
| 60 | - spi-rx-bus-width - (optional) The bus width(number of data wires) that | ||
| 61 | used for MISO. Defaults to 1 if not present. | ||
| 62 | |||
| 63 | Some SPI controllers and devices support Dual and Quad SPI transfer mode. | ||
| 64 | It allows data in SPI system transfered in 2 wires(DUAL) or 4 wires(QUAD). | ||
| 65 | Now the value that spi-tx-bus-width and spi-rx-bus-width can receive is | ||
| 66 | only 1(SINGLE), 2(DUAL) and 4(QUAD). | ||
| 67 | Dual/Quad mode is not allowed when 3-wire mode is used. | ||
| 58 | 68 | ||
| 59 | If a gpio chipselect is used for the SPI slave the gpio number will be passed | 69 | If a gpio chipselect is used for the SPI slave the gpio number will be passed |
| 60 | via the cs_gpio | 70 | via the cs_gpio |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 6ef349f82b5f..9e039c60c068 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
| @@ -886,48 +886,44 @@ static void of_register_spi_devices(struct spi_master *master) | |||
| 886 | spi->mode |= SPI_3WIRE; | 886 | spi->mode |= SPI_3WIRE; |
| 887 | 887 | ||
| 888 | /* Device DUAL/QUAD mode */ | 888 | /* Device DUAL/QUAD mode */ |
| 889 | prop = of_get_property(nc, "spi-tx-nbits", &len); | 889 | prop = of_get_property(nc, "spi-tx-bus-width", &len); |
| 890 | if (!prop || len < sizeof(*prop)) { | 890 | if (prop && len == sizeof(*prop)) { |
| 891 | dev_err(&master->dev, "%s has no 'spi-tx-nbits' property\n", | 891 | switch (be32_to_cpup(prop)) { |
| 892 | nc->full_name); | 892 | case SPI_NBITS_SINGLE: |
| 893 | spi_dev_put(spi); | 893 | break; |
| 894 | continue; | 894 | case SPI_NBITS_DUAL: |
| 895 | } | 895 | spi->mode |= SPI_TX_DUAL; |
| 896 | switch (be32_to_cpup(prop)) { | 896 | break; |
| 897 | case SPI_NBITS_SINGLE: | 897 | case SPI_NBITS_QUAD: |
| 898 | break; | 898 | spi->mode |= SPI_TX_QUAD; |
| 899 | case SPI_NBITS_DUAL: | 899 | break; |
| 900 | spi->mode |= SPI_TX_DUAL; | 900 | default: |
| 901 | break; | 901 | dev_err(&master->dev, |
| 902 | case SPI_NBITS_QUAD: | 902 | "spi-tx-bus-width %d not supported\n", |
| 903 | spi->mode |= SPI_TX_QUAD; | 903 | be32_to_cpup(prop)); |
| 904 | break; | 904 | spi_dev_put(spi); |
| 905 | default: | 905 | continue; |
| 906 | dev_err(&master->dev, "spi-tx-nbits value is not supported\n"); | 906 | } |
| 907 | spi_dev_put(spi); | ||
| 908 | continue; | ||
| 909 | } | 907 | } |
| 910 | 908 | ||
| 911 | prop = of_get_property(nc, "spi-rx-nbits", &len); | 909 | prop = of_get_property(nc, "spi-rx-bus-width", &len); |
| 912 | if (!prop || len < sizeof(*prop)) { | 910 | if (prop && len == sizeof(*prop)) { |
| 913 | dev_err(&master->dev, "%s has no 'spi-rx-nbits' property\n", | 911 | switch (be32_to_cpup(prop)) { |
| 914 | nc->full_name); | 912 | case SPI_NBITS_SINGLE: |
| 915 | spi_dev_put(spi); | 913 | break; |
| 916 | continue; | 914 | case SPI_NBITS_DUAL: |
| 917 | } | 915 | spi->mode |= SPI_RX_DUAL; |
| 918 | switch (be32_to_cpup(prop)) { | 916 | break; |
| 919 | case SPI_NBITS_SINGLE: | 917 | case SPI_NBITS_QUAD: |
| 920 | break; | 918 | spi->mode |= SPI_RX_QUAD; |
| 921 | case SPI_NBITS_DUAL: | 919 | break; |
| 922 | spi->mode |= SPI_RX_DUAL; | 920 | default: |
| 923 | break; | 921 | dev_err(&master->dev, |
| 924 | case SPI_NBITS_QUAD: | 922 | "spi-rx-bus-width %d not supported\n", |
| 925 | spi->mode |= SPI_RX_QUAD; | 923 | be32_to_cpup(prop)); |
| 926 | break; | 924 | spi_dev_put(spi); |
| 927 | default: | 925 | continue; |
| 928 | dev_err(&master->dev, "spi-rx-nbits value is not supported\n"); | 926 | } |
| 929 | spi_dev_put(spi); | ||
| 930 | continue; | ||
| 931 | } | 927 | } |
| 932 | 928 | ||
| 933 | /* Device speed */ | 929 | /* Device speed */ |
| @@ -1480,6 +1476,7 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) | |||
| 1480 | return -EINVAL; | 1476 | return -EINVAL; |
| 1481 | if (xfer->speed_hz && master->max_speed_hz && | 1477 | if (xfer->speed_hz && master->max_speed_hz && |
| 1482 | xfer->speed_hz > master->max_speed_hz) | 1478 | xfer->speed_hz > master->max_speed_hz) |
| 1479 | return -EINVAL; | ||
| 1483 | 1480 | ||
| 1484 | if (xfer->tx_buf && !xfer->tx_nbits) | 1481 | if (xfer->tx_buf && !xfer->tx_nbits) |
| 1485 | xfer->tx_nbits = SPI_NBITS_SINGLE; | 1482 | xfer->tx_nbits = SPI_NBITS_SINGLE; |
