[brcm63xx] fixes for the bcm6338 clocks, thanks Maxime
[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 --- a/drivers/spi/spi_gpio.c
8 +++ b/drivers/spi/spi_gpio.c
9 @@ -178,8 +178,10 @@ static void spi_gpio_chipselect(struct s
10 if (is_active)
11 setsck(spi, spi->mode & SPI_CPOL);
12
13 - /* SPI is normally active-low */
14 - gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
15 + if (cs != SPI_GPIO_NO_CHIPSELECT) {
16 + /* SPI is normally active-low */
17 + gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
18 + }
19 }
20
21 static int spi_gpio_setup(struct spi_device *spi)
22 @@ -191,15 +193,17 @@ static int spi_gpio_setup(struct spi_dev
23 return -EINVAL;
24
25 if (!spi->controller_state) {
26 - status = gpio_request(cs, spi->dev.bus_id);
27 - if (status)
28 - return status;
29 - status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
30 + if (cs != SPI_GPIO_NO_CHIPSELECT) {
31 + status = gpio_request(cs, spi->dev.bus_id);
32 + if (status)
33 + return status;
34 + status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
35 + }
36 }
37 if (!status)
38 status = spi_bitbang_setup(spi);
39 if (status) {
40 - if (!spi->controller_state)
41 + if (!spi->controller_state && cs != SPI_GPIO_NO_CHIPSELECT)
42 gpio_free(cs);
43 }
44 return status;
45 @@ -209,7 +213,8 @@ static void spi_gpio_cleanup(struct spi_
46 {
47 unsigned long cs = (unsigned long) spi->controller_data;
48
49 - gpio_free(cs);
50 + if (cs != SPI_GPIO_NO_CHIPSELECT)
51 + gpio_free(cs);
52 spi_bitbang_cleanup(spi);
53 }
54
55 --- a/include/linux/spi/spi_gpio.h
56 +++ b/include/linux/spi/spi_gpio.h
57 @@ -25,10 +25,16 @@
58 * ...
59 * };
60 *
61 + * If chipselect is not used (there's only one device on the bus), assign
62 + * SPI_GPIO_NO_CHIPSELECT to the controller_data:
63 + * .controller_data = (void *) SPI_GPIO_NO_CHIPSELECT;
64 + *
65 * If the bitbanged bus is later switched to a "native" controller,
66 * that platform_device and controller_data should be removed.
67 */
68
69 +#define SPI_GPIO_NO_CHIPSELECT ((unsigned long)-1l)
70 +
71 /**
72 * struct spi_gpio_platform_data - parameter for bitbanged SPI master
73 * @sck: number of the GPIO used for clock output
This page took 0.052545 seconds and 5 git commands to generate.