fix a typo in the image generation makefile (closes #4624)
[oweals/openwrt.git] / target / linux / generic-2.6 / patches-2.6.28 / 920-02-spi-gpio-without-cs.patch
1 Optionally omit the CS signal, if there's only one device on the bus.
2
3 --mb
4
5
6
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
12         if (is_active)
13                 setsck(spi, spi->mode & SPI_CPOL);
14  
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);
20 +       }
21  }
22  
23  static int spi_gpio_setup(struct spi_device *spi)
24 @@ -191,15 +193,17 @@ static int spi_gpio_setup(struct spi_dev
25                 return -EINVAL;
26  
27         if (!spi->controller_state) {
28 -               status = gpio_request(cs, spi->dev.bus_id);
29 -               if (status)
30 -                       return status;
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);
34 +                       if (status)
35 +                               return status;
36 +                       status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
37 +               }
38         }
39         if (!status)
40                 status = spi_bitbang_setup(spi);
41         if (status) {
42 -               if (!spi->controller_state)
43 +               if (!spi->controller_state && cs != SPI_GPIO_NO_CHIPSELECT)
44                         gpio_free(cs);
45         }
46         return status;
47 @@ -209,7 +213,8 @@ static void spi_gpio_cleanup(struct spi_
48  {
49         unsigned long   cs = (unsigned long) spi->controller_data;
50  
51 -       gpio_free(cs);
52 +       if (cs != SPI_GPIO_NO_CHIPSELECT)
53 +               gpio_free(cs);
54         spi_bitbang_cleanup(spi);
55  }
56  
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
61 @@ -25,10 +25,16 @@
62   *     ...
63   *     };
64   *
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;
68 + *
69   * If the bitbanged bus is later switched to a "native" controller,
70   * that platform_device and controller_data should be removed.
71   */
72  
73 +#define SPI_GPIO_NO_CHIPSELECT         ((unsigned long)-1l)
74 +
75  /**
76   * struct spi_gpio_platform_data - parameter for bitbanged SPI master
77   * @sck: number of the GPIO used for clock output