Re: [PATCH 1/2] SPI: control CS via standard GPIO operations instead of SPI-HW

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/04/2015 05:40 PM, kernel@xxxxxxxxxxxxxxxx wrote:
> From: Martin Sperl <kernel@xxxxxxxxxxxxxxxx>
> 
> 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 <kernel@xxxxxxxxxxxxxxxx>
> 
> ---
> 
> 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 <juhosg@xxxxxxxxxxx>
> @@ -30,6 +31,7 @@
>  #include <linux/of.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>  #include <linux/spi/spi.h>
>  
>  /* 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   |

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux