46 lines
1.3 KiB
Diff
46 lines
1.3 KiB
Diff
|
From 1f890e9fd62d10449d74d0b66bc9648afbe8a0bd Mon Sep 17 00:00:00 2001
|
||
|
From: The-going <48602507+The-going@users.noreply.github.com>
|
||
|
Date: Wed, 2 Feb 2022 11:35:27 +0300
|
||
|
Subject: [PATCH 07/50] drv:spi:spi.c fix cs_gpio spi support
|
||
|
|
||
|
---
|
||
|
drivers/spi/spi.c | 14 ++++++++++++++
|
||
|
1 file changed, 14 insertions(+)
|
||
|
|
||
|
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
|
||
|
index a42b9e852..b89f83df5 100644
|
||
|
--- a/drivers/spi/spi.c
|
||
|
+++ b/drivers/spi/spi.c
|
||
|
@@ -3467,6 +3467,7 @@ int spi_setup(struct spi_device *spi)
|
||
|
{
|
||
|
unsigned bad_bits, ugly_bits;
|
||
|
int status;
|
||
|
+ int ret;
|
||
|
|
||
|
/*
|
||
|
* check mode to prevent that any two of DUAL, QUAD and NO_MOSI/MISO
|
||
|
@@ -3539,6 +3540,19 @@ int spi_setup(struct spi_device *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);
|
||
|
+ 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);
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
if (spi->controller->auto_runtime_pm && spi->controller->set_cs) {
|
||
|
status = pm_runtime_get_sync(spi->controller->dev.parent);
|
||
|
if (status < 0) {
|
||
|
--
|
||
|
2.34.1
|
||
|
|
||
|
|