public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] spi: gpio: Enable a single always-selected device
@ 2025-02-05 13:19 Andy Shevchenko
  2025-02-05 13:19 ` [PATCH v1 1/2] spi: gpio: Remove stale documentation part Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andy Shevchenko @ 2025-02-05 13:19 UTC (permalink / raw)
  To: Andy Shevchenko, linux-spi, linux-kernel; +Cc: Mark Brown

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(-)

-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v1 1/2] spi: gpio: Remove stale documentation part
  2025-02-05 13:19 [PATCH v1 0/2] spi: gpio: Enable a single always-selected device Andy Shevchenko
@ 2025-02-05 13:19 ` Andy Shevchenko
  2025-02-05 13:19 ` [PATCH v1 2/2] spi: gpio: Support a single always-selected device Andy Shevchenko
  2025-02-06 14:07 ` [PATCH v1 0/2] spi: gpio: Enable " Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2025-02-05 13:19 UTC (permalink / raw)
  To: Andy Shevchenko, linux-spi, linux-kernel; +Cc: Mark Brown

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.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-gpio.c | 34 ++--------------------------------
 1 file changed, 2 insertions(+), 32 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 4f192e013cd6..80a1aed42951 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -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);
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v1 2/2] spi: gpio: Support a single always-selected device
  2025-02-05 13:19 [PATCH v1 0/2] spi: gpio: Enable a single always-selected device Andy Shevchenko
  2025-02-05 13:19 ` [PATCH v1 1/2] spi: gpio: Remove stale documentation part Andy Shevchenko
@ 2025-02-05 13:19 ` Andy Shevchenko
  2025-02-06 14:07 ` [PATCH v1 0/2] spi: gpio: Enable " Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2025-02-05 13:19 UTC (permalink / raw)
  To: Andy Shevchenko, linux-spi, linux-kernel; +Cc: Mark Brown

The 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.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-gpio.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 80a1aed42951..405deb6677c1 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -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);
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 0/2] spi: gpio: Enable a single always-selected device
  2025-02-05 13:19 [PATCH v1 0/2] spi: gpio: Enable a single always-selected device Andy Shevchenko
  2025-02-05 13:19 ` [PATCH v1 1/2] spi: gpio: Remove stale documentation part Andy Shevchenko
  2025-02-05 13:19 ` [PATCH v1 2/2] spi: gpio: Support a single always-selected device Andy Shevchenko
@ 2025-02-06 14:07 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2025-02-06 14:07 UTC (permalink / raw)
  To: linux-spi, linux-kernel, Andy Shevchenko

On Wed, 05 Feb 2025 15:19:18 +0200, Andy Shevchenko wrote:
> 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: 25fac20edd09b60651eabcc57c187b1277f43d08

All 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-06 14:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 13:19 [PATCH v1 0/2] spi: gpio: Enable a single always-selected device Andy Shevchenko
2025-02-05 13:19 ` [PATCH v1 1/2] spi: gpio: Remove stale documentation part Andy Shevchenko
2025-02-05 13:19 ` [PATCH v1 2/2] spi: gpio: Support a single always-selected device Andy Shevchenko
2025-02-06 14:07 ` [PATCH v1 0/2] spi: gpio: Enable " Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox