spi: gpio: Enable a single always-selected device
cover spi: gpio: Enable a single always-selected device
Enable a single always-selected device hardware setup for SPI GPIO driver, so some custom SPI bitbang code may be replaced with the generic implementation in the future (e.g. Up Board FPGA driver).
Andy Shevchenko (2):
spi: gpio: Remove stale documentation part
spi: gpio: Support a single always-selected device
drivers/spi/spi-gpio.c | 45 +++++++----------------------------------- 1 file changed, 7 insertions(+), 38 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 1/2 spi: gpio: Remove stale documentation part
The SPI GPIO driver doesn't support hard coded absolute GPIO numbers anymore. However, it may still be instantiated from board files with help of GPIO lookup tables or device properties. Neither of this is covered by the old part of the documentation, it's the opposite, i.e. old documentation pretend that antique approach still works. With all this said, remove stale and confusing part of the documentation.
--- drivers/spi/spi-gpio.c | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-)
drivers/spi/spi-gpio.c +2 -32
@@ -39,36 +39,8 @@ struct spi_gpio {/*----------------------------------------------------------------------*/ -/* -* Because the overhead of going through four GPIO procedure calls -* per transferred bit can make performance a problem, this code -* is set up so that you can use it in either of two ways: -* -* - The slow generic way: set up platform_data to hold the GPIO -* numbers used for MISO/MOSI/SCK, and issue procedure calls for -* each of them. This driver can handle several such busses. -* -* - The quicker inlined way: only helps with platform GPIO code -* that inlines operations for constant GPIOs. This can give -* you tight (fast!) inner loops, but each such bus needs a -* new driver. You'll define a new C file, with Makefile and -* Kconfig support; the C code can be a total of six lines: -* -* #define DRIVER_NAME "myboard_spi2" -* #define SPI_MISO_GPIO 119 -* #define SPI_MOSI_GPIO 120 -* #define SPI_SCK_GPIO 121 -* #define SPI_N_CHIPSEL 4 -* #include "spi-gpio.c" -*/ - -#ifndef DRIVER_NAME #define DRIVER_NAME "spi_gpio" -#define GENERIC_BITBANG /* vs tight inlines */ - -#endif -/*----------------------------------------------------------------------*/ static inline struct spi_gpio *__pure
@@ -341,10 +313,9 @@ static int spi_gpio_probe_pdata(struct platform_device *pdev,struct spi_gpio *spi_gpio =spi_controller_get_devdata (host);int i; -#ifdef GENERIC_BITBANG if (!pdata || !pdata->num_chipselect)return -ENODEV ; -#endif +/* * The host needs to think there is a chipselect even if not * connected
@@ -445,8 +416,6 @@ static int spi_gpio_probe(struct platform_device *pdev)return devm_spi_register_controller (&pdev->dev, host); } -MODULE_ALIAS ("platform:" DRIVER_NAME ); -static const struct of_device_id spi_gpio_dt_ids[] = { { .compatible ="spi-gpio" }, {}
@@ -465,3 +434,4 @@ module_platform_driver(spi_gpio_driver);MODULE_DESCRIPTION ("SPI host driver using generic bitbanged GPIO " );MODULE_AUTHOR ("David Brownell" );MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:" DRIVER_NAME );
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 2/2 spi: gpio: Support a single always-selected device
In reply to Andy ShevchenkoThe generic SPI code, the SPI GPIO driver functions support a single always-connected device cases. The only impediment is that board instantiation prevents that from happening. Update spi_gpio_probe_pdata() checks to support the mentioned hardware setup.
--- drivers/spi/spi-gpio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/spi/spi-gpio.c +5 -6
@@ -313,15 +313,14 @@ static int spi_gpio_probe_pdata(struct platform_device *pdev,struct spi_gpio *spi_gpio =spi_controller_get_devdata (host);int i; -if (!pdata || !pdata->num_chipselect) +if (!pdata)return -ENODEV ; -/* -* The host needs to think there is a chipselect even if not -* connected -*/ - host->num_chipselect = pdata->num_chipselect ?:1 ; +/* It's just one always-selected device, fine to continue */ +if (!pdata->num_chipselect) +return 0 ; + host->num_chipselect = pdata->num_chipselect; spi_gpio->cs_gpios =devm_kcalloc (dev, host->num_chipselect,sizeof (*spi_gpio->cs_gpios),GFP_KERNEL );
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Mark Brown
maintainerQuoted 9 lines · Andy Shevchenko
Enable a single always-selected device hardware setup for SPI GPIO driver, so some custom SPI bitbang code may be replaced with the generic implementation in the future (e.g. Up Board FPGA driver).
Andy Shevchenko (2):
spi: gpio: Remove stale documentation part
spi: gpio: Support a single always-selected device[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/2] spi: gpio: Remove stale documentation part
commit: c108905a7423d44237d17374f845fc5bb9cb9728
[2/2] spi: gpio: Support a single always-selected device
commit: 25fac20edd09b60651eabcc57c187b1277f43d08All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark