未验证 提交 ea235786 编写于 作者: J John Garry 提交者: Mark Brown

spi: Allow SPI controller override device buswidth

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
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: NJohn Garry <john.garry@huawei.com>
Link: https://lore.kernel.org/r/1582903131-160033-2-git-send-email-john.garry@huawei.comSigned-off-by: NMark Brown <broonie@kernel.org>
上级 3d24b2a4
...@@ -510,6 +510,7 @@ struct spi_device *spi_alloc_device(struct spi_controller *ctlr) ...@@ -510,6 +510,7 @@ struct spi_device *spi_alloc_device(struct spi_controller *ctlr)
spi->dev.bus = &spi_bus_type; spi->dev.bus = &spi_bus_type;
spi->dev.release = spidev_release; spi->dev.release = spidev_release;
spi->cs_gpio = -ENOENT; spi->cs_gpio = -ENOENT;
spi->mode = ctlr->buswidth_override_bits;
spin_lock_init(&spi->statistics.lock); spin_lock_init(&spi->statistics.lock);
...@@ -2181,9 +2182,10 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr, ...@@ -2181,9 +2182,10 @@ static acpi_status acpi_register_spi_device(struct spi_controller *ctlr,
return AE_NO_MEMORY; return AE_NO_MEMORY;
} }
ACPI_COMPANION_SET(&spi->dev, adev); ACPI_COMPANION_SET(&spi->dev, adev);
spi->max_speed_hz = lookup.max_speed_hz; spi->max_speed_hz = lookup.max_speed_hz;
spi->mode = lookup.mode; spi->mode |= lookup.mode;
spi->irq = lookup.irq; spi->irq = lookup.irq;
spi->bits_per_word = lookup.bits_per_word; spi->bits_per_word = lookup.bits_per_word;
spi->chip_select = lookup.chip_select; spi->chip_select = lookup.chip_select;
......
...@@ -481,6 +481,9 @@ struct spi_controller { ...@@ -481,6 +481,9 @@ struct spi_controller {
/* spi_device.mode flags understood by this controller driver */ /* spi_device.mode flags understood by this controller driver */
u32 mode_bits; u32 mode_bits;
/* spi_device.mode flags override flags for this controller */
u32 buswidth_override_bits;
/* bitmask of supported bits_per_word for transfers */ /* bitmask of supported bits_per_word for transfers */
u32 bits_per_word_mask; u32 bits_per_word_mask;
#define SPI_BPW_MASK(bits) BIT((bits) - 1) #define SPI_BPW_MASK(bits) BIT((bits) - 1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册