On 03/04/2015 05:40 PM, kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org wrote: > From: Martin Sperl > > Allow the cs-gpios property in DT to be used instead of the > fixed two chip-selects provided by the SPI-HW itself > > Signed-off-by: Martin Sperl > > --- > > There is the question if we still need to support the chip_selects > provided by the hardware (plus the buggy CSPOL_HIGH support for those cases) > or if we could just make the cs-gpios a required setting for this driver. > Going with the GPIO only solution would clean up the code a bit. > > drivers/spi/spi-bcm2835.c | 53 +++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 46 insertions(+), 7 deletions(-) > > diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c > index 419a782..128a152 100644 > --- a/drivers/spi/spi-bcm2835.c > +++ b/drivers/spi/spi-bcm2835.c > @@ -3,6 +3,7 @@ > * > * Copyright (C) 2012 Chris Boot > * Copyright (C) 2013 Stephen Warren > + * Copyright (C) 2015 Martin Sperl > * > * This driver is inspired by: > * spi-ath79.c, Copyright (C) 2009-2011 Gabor Juhos > @@ -30,6 +31,7 @@ > #include > #include > #include > +#include > #include > > /* SPI register offsets */ > @@ -116,6 +118,18 @@ static inline void bcm2835_wr_fifo(struct bcm2835_spi *bs, int len) > } > } > > +/* ideally spi_set_cs would be exported by spi-core */ > +static inline void bcm2835_set_cs(struct spi_device *spi, bool enable) > +{ > + > + if (spi->mode & SPI_CS_HIGH) > + enable = !enable; > + > + if (spi->cs_gpio >= 0) You might want to use gpio_is_valid() instead of open coding it. Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |