build/patch/kernel/archive/sunxi-5.10/general-fix-cs_gpio-spi-support.patch

25 lines
870 B
Diff
Raw Normal View History

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5e4c453..028ef66 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3262,6 +3262,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);
+ }
+ }
+
if (spi->controller->auto_runtime_pm && spi->controller->set_cs) {
status = pm_runtime_get_sync(spi->controller->dev.parent);
if (status < 0) {