build/patch/kernel/archive/sunxi-5.4/general-fix-cs_gpio-spi-support.patch
Igor Pečovnik 0cdffb29b0
Renaming DEV branch to EDGE (#2704)
* Change DEV to EDGE
* Renaming patches dev folder to edge
* Move patches into subdir where they will be archived.
* Relink patch directories properly
2021-03-24 19:01:53 +01:00

24 lines
823 B
Diff

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 9a7def7..08c6a05 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2884,6 +2884,19 @@ int spi_setup(struct spi_device *spi)
if (spi->controller->setup)
status = spi->controller->setup(spi);
+ if (gpio_is_valid(spi->cs_gpio)) {
+ dev_info(&spi->dev, "spi_setup / gpio_is_valid(%d) ... doing gpio_request ...\n", spi->cs_gpio);
+ int ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
+ if (ret) {
+ dev_err(&spi->dev, "failed to request gpio\n");
+ }
+ else {
+ gpio_direction_output(spi->cs_gpio,
+ !(spi->mode & SPI_CS_HIGH));
+ dev_info(&spi->dev, "spi_setup / gpio_direction_output(%d) done !\n", spi->cs_gpio);
+ }
+ }
+
spi_set_cs(spi, false);
dev_dbg(&spi->dev, "setup mode %d, %s%s%s%s%u bits/w, %u Hz max --> %d\n",