diff mbox series

Documentation: spi: Update gpio+bitbang instruction

Message ID 20240414065305.9796-1-marco@sirabella.org
State New
Headers show
Series Documentation: spi: Update gpio+bitbang instruction | expand

Commit Message

Marco Sirabella April 14, 2024, 6:53 a.m. UTC
The way to do this was changed in
9b00bc7b901f (spi-gpio: Rewrite to use GPIO descriptors)
and there's no real docs outlining this,
update defunct #include "spi-gpio.c" instructions

Signed-off-by: Marco Sirabella <marco@sirabella.org>
---
 drivers/spi/spi-gpio.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

Comments

Jonas Gorski April 16, 2024, 2:48 p.m. UTC | #1
Hi,

On Sun, 14 Apr 2024 at 08:54, Marco Sirabella <marco@sirabella.org> wrote:
>
> The way to do this was changed in
> 9b00bc7b901f (spi-gpio: Rewrite to use GPIO descriptors)
> and there's no real docs outlining this,
> update defunct #include "spi-gpio.c" instructions
>
> Signed-off-by: Marco Sirabella <marco@sirabella.org>
> ---
>  drivers/spi/spi-gpio.c | 17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
> index 909cce109bba..8c5f88f01db2 100644
> --- a/drivers/spi/spi-gpio.c
> +++ b/drivers/spi/spi-gpio.c
> @@ -44,22 +44,13 @@ struct spi_gpio {
>   * 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
> + *   - The 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.

9b00bc7b901f (spi-gpio: Rewrite to use GPIO descriptors) removed the
fields for the GPIO numbers, so this is definitely not the way
anymore.

Since the code now always uses descriptors, the performance comment in
the first paragraph does not apply anymore as well and should be
dropped as well.

>   *
> - *   - 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"
> + *   - The inlined way:  manually set up and register a gpiod_lookup_table with
> + *     the appropriately labelled gpio pins "sck", "mosi", "miso" & an array
> + *     named "cs" before calling devm_spi_register_controller (XXX).

I think you need to use platform_device_register(), at least both
remaining users do so. And this is AFAICT now the only option for
registering it via C code (which also means that DRIVER_NAME will
never be defined from outside, and GENERIC_BITBANG will always be true
... ).

Best Regards,
Jonas
diff mbox series

Patch

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 909cce109bba..8c5f88f01db2 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -44,22 +44,13 @@  struct spi_gpio {
  * 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
+ *   - The 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"
+ *   - The inlined way:  manually set up and register a gpiod_lookup_table with
+ *     the appropriately labelled gpio pins "sck", "mosi", "miso" & an array
+ *     named "cs" before calling devm_spi_register_controller (XXX).
  */
 
 #ifndef DRIVER_NAME