1 Optionally omit the CS signal, if there's only one device on the bus.
7 Index: linux-2.6.28.2/drivers/spi/spi_gpio.c
8 ===================================================================
9 --- linux-2.6.28.2.orig/drivers/spi/spi_gpio.c 2009-02-11 18:48:23.000000000 +0100
10 +++ linux-2.6.28.2/drivers/spi/spi_gpio.c 2009-02-11 18:48:50.000000000 +0100
11 @@ -178,8 +178,10 @@ static void spi_gpio_chipselect(struct s
13 setsck(spi, spi->mode & SPI_CPOL);
15 - /* SPI is normally active-low */
16 - gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
17 + if (cs != SPI_GPIO_NO_CHIPSELECT) {
18 + /* SPI is normally active-low */
19 + gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
23 static int spi_gpio_setup(struct spi_device *spi)
24 @@ -191,15 +193,17 @@ static int spi_gpio_setup(struct spi_dev
27 if (!spi->controller_state) {
28 - status = gpio_request(cs, spi->dev.bus_id);
31 - status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
32 + if (cs != SPI_GPIO_NO_CHIPSELECT) {
33 + status = gpio_request(cs, spi->dev.bus_id);
36 + status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
40 status = spi_bitbang_setup(spi);
42 - if (!spi->controller_state)
43 + if (!spi->controller_state && cs != SPI_GPIO_NO_CHIPSELECT)
47 @@ -209,7 +213,8 @@ static void spi_gpio_cleanup(struct spi_
49 unsigned long cs = (unsigned long) spi->controller_data;
52 + if (cs != SPI_GPIO_NO_CHIPSELECT)
54 spi_bitbang_cleanup(spi);
57 Index: linux-2.6.28.2/include/linux/spi/spi_gpio.h
58 ===================================================================
59 --- linux-2.6.28.2.orig/include/linux/spi/spi_gpio.h 2009-02-11 18:48:23.000000000 +0100
60 +++ linux-2.6.28.2/include/linux/spi/spi_gpio.h 2009-02-11 18:58:31.000000000 +0100
65 + * If chipselect is not used (there's only one device on the bus), assign
66 + * SPI_GPIO_NO_CHIPSELECT to the controller_data:
67 + * .controller_data = (void *) SPI_GPIO_NO_CHIPSELECT;
69 * If the bitbanged bus is later switched to a "native" controller,
70 * that platform_device and controller_data should be removed.
73 +#define SPI_GPIO_NO_CHIPSELECT ((unsigned long)-1l)
76 * struct spi_gpio_platform_data - parameter for bitbanged SPI master
77 * @sck: number of the GPIO used for clock output