Re: [PATCH RFC 1/3] spi: Allow SPI controller override device buswidth

From: John Garry
Date: Mon Mar 02 2020 - 04:30:12 EST


On 01/03/2020 10:04, Sergei Shtylyov wrote:
Hello!


Hi Sergei,

On 28.02.2020 18:18, John Garry wrote:

Currently ACPI firmware description for a SPI device does not have any
method to describe the data buswidth on the board.

So even through the controller and device may support higher modes than
ÂÂÂÂÂÂÂÂÂ ^^^^^^^
ÂÂ Though?


right

standard SPI, it cannot be assumed that the board does - as such, that
device is limited to standard SPI in such a circumstance.

As a workaround, allow the controller driver supply buswidth override bits,
which are used inform the core code that the controller driver knows the
buswidth supported on that board for that device.

A host controller driver might know this info from DMI tables, for example.

Signed-off-by: John Garry <john.garry@xxxxxxxxxx>
---
 drivers/spi/spi.c | 4 +++-
 include/linux/spi/spi.h | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 38b4c78df506..292f26807b41 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -510,6 +510,7 @@ struct spi_device *spi_alloc_device(struct spi_controller *ctlr)
ÂÂÂÂÂ spi->dev.bus = &spi_bus_type;
ÂÂÂÂÂ spi->dev.release = spidev_release;
ÂÂÂÂÂ spi->cs_gpio = -ENOENT;
+ÂÂÂ spi->mode = ctlr->buswidth_override_bits;
ÂÂÂÂÂ spin_lock_init(&spi->statistics.lock);
@@ -2181,9 +2182,10 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr,
ÂÂÂÂÂÂÂÂÂ return AE_NO_MEMORY;
ÂÂÂÂÂ }
+

ÂÂ What for?

slipped through the net


ÂÂÂÂÂ ACPI_COMPANION_SET(&spi->dev, adev);
ÂÂÂÂÂ spi->max_speed_hzÂÂÂ = lookup.max_speed_hz;
-ÂÂÂ spi->modeÂÂÂÂÂÂÂ = lookup.mode;
+ÂÂÂ spi->modeÂÂÂÂÂÂÂ |= lookup.mode;
ÂÂÂÂÂ spi->irqÂÂÂÂÂÂÂ = lookup.irq;
ÂÂÂÂÂ spi->bits_per_wordÂÂÂ = lookup.bits_per_word;
ÂÂÂÂÂ spi->chip_selectÂÂÂ = lookup.chip_select;
[...]

TBH, I did not think that this series would be applied since I tagged it as RFC, hence the typos which would have been caught. Indeed, this also exposes an issue with enabling quad SPI for a spansion SPI NOR part, which I need to debug now in the SPI NOR driver.

Hi Mark,

Do you want me to do anything about the above superfluous newline?

Thanks,
John


MBR, Sergei

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
.