forked from Minki/linux
Merge remote-tracking branch 'spi/topic/quad' into spi-next
This commit is contained in:
commit
278ac33bbd
|
@ -55,6 +55,16 @@ contain the following properties.
|
||||||
chip select active high
|
chip select active high
|
||||||
- spi-3wire - (optional) Empty property indicating device requires
|
- spi-3wire - (optional) Empty property indicating device requires
|
||||||
3-wire mode.
|
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
|
If a gpio chipselect is used for the SPI slave the gpio number will be passed
|
||||||
via the cs_gpio
|
via the cs_gpio
|
||||||
|
|
|
@ -886,48 +886,44 @@ static void of_register_spi_devices(struct spi_master *master)
|
||||||
spi->mode |= SPI_3WIRE;
|
spi->mode |= SPI_3WIRE;
|
||||||
|
|
||||||
/* Device DUAL/QUAD mode */
|
/* 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)) {
|
if (prop && len == sizeof(*prop)) {
|
||||||
dev_err(&master->dev, "%s has no 'spi-tx-nbits' property\n",
|
switch (be32_to_cpup(prop)) {
|
||||||
nc->full_name);
|
case SPI_NBITS_SINGLE:
|
||||||
spi_dev_put(spi);
|
break;
|
||||||
continue;
|
case SPI_NBITS_DUAL:
|
||||||
}
|
spi->mode |= SPI_TX_DUAL;
|
||||||
switch (be32_to_cpup(prop)) {
|
break;
|
||||||
case SPI_NBITS_SINGLE:
|
case SPI_NBITS_QUAD:
|
||||||
break;
|
spi->mode |= SPI_TX_QUAD;
|
||||||
case SPI_NBITS_DUAL:
|
break;
|
||||||
spi->mode |= SPI_TX_DUAL;
|
default:
|
||||||
break;
|
dev_err(&master->dev,
|
||||||
case SPI_NBITS_QUAD:
|
"spi-tx-bus-width %d not supported\n",
|
||||||
spi->mode |= SPI_TX_QUAD;
|
be32_to_cpup(prop));
|
||||||
break;
|
spi_dev_put(spi);
|
||||||
default:
|
continue;
|
||||||
dev_err(&master->dev, "spi-tx-nbits value is not supported\n");
|
}
|
||||||
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)) {
|
if (prop && len == sizeof(*prop)) {
|
||||||
dev_err(&master->dev, "%s has no 'spi-rx-nbits' property\n",
|
switch (be32_to_cpup(prop)) {
|
||||||
nc->full_name);
|
case SPI_NBITS_SINGLE:
|
||||||
spi_dev_put(spi);
|
break;
|
||||||
continue;
|
case SPI_NBITS_DUAL:
|
||||||
}
|
spi->mode |= SPI_RX_DUAL;
|
||||||
switch (be32_to_cpup(prop)) {
|
break;
|
||||||
case SPI_NBITS_SINGLE:
|
case SPI_NBITS_QUAD:
|
||||||
break;
|
spi->mode |= SPI_RX_QUAD;
|
||||||
case SPI_NBITS_DUAL:
|
break;
|
||||||
spi->mode |= SPI_RX_DUAL;
|
default:
|
||||||
break;
|
dev_err(&master->dev,
|
||||||
case SPI_NBITS_QUAD:
|
"spi-rx-bus-width %d not supported\n",
|
||||||
spi->mode |= SPI_RX_QUAD;
|
be32_to_cpup(prop));
|
||||||
break;
|
spi_dev_put(spi);
|
||||||
default:
|
continue;
|
||||||
dev_err(&master->dev, "spi-rx-nbits value is not supported\n");
|
}
|
||||||
spi_dev_put(spi);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Device speed */
|
/* Device speed */
|
||||||
|
@ -1480,6 +1476,7 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (xfer->speed_hz && master->max_speed_hz &&
|
if (xfer->speed_hz && master->max_speed_hz &&
|
||||||
xfer->speed_hz > master->max_speed_hz)
|
xfer->speed_hz > master->max_speed_hz)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (xfer->tx_buf && !xfer->tx_nbits)
|
if (xfer->tx_buf && !xfer->tx_nbits)
|
||||||
xfer->tx_nbits = SPI_NBITS_SINGLE;
|
xfer->tx_nbits = SPI_NBITS_SINGLE;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user