diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2019-01-07 10:51:56 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-01-09 07:42:18 -0500 |
commit | 9400c41e77b8f1f9c711b08a6c79bdbc5681fb00 (patch) | |
tree | ba0ccbe34e4898631308066fd54c46d1395ba0cb | |
parent | 101a68e74fe089b975c407f1bc9359882b05489a (diff) |
spi: dw: Convert to use CS GPIO descriptors
This converts the DesignWare (dw) SPI master driver to
use GPIO descriptors for chip select handling.
This driver has a duplicate DT parser in addition to the
one in the core, sets up the line as non-asserted and
relies on the core to drive the GPIOs.
It is a pretty straight-forward conversion.
Cc: Talel Shenhar <talel@amazon.com>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Linuxarm <linuxarm@huawei.com>
Tested-by: Jay Fang <f.fangjian@huawei.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-dw-mmio.c | 22 | ||||
-rw-r--r-- | drivers/spi/spi-dw.c | 9 |
2 files changed, 1 insertions, 30 deletions
diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index d0dd7814e997..4bd59a93d988 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/mfd/syscon.h> | 18 | #include <linux/mfd/syscon.h> |
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/of.h> | 20 | #include <linux/of.h> |
21 | #include <linux/of_gpio.h> | ||
22 | #include <linux/of_platform.h> | 21 | #include <linux/of_platform.h> |
23 | #include <linux/acpi.h> | 22 | #include <linux/acpi.h> |
24 | #include <linux/property.h> | 23 | #include <linux/property.h> |
@@ -185,27 +184,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) | |||
185 | 184 | ||
186 | dws->num_cs = num_cs; | 185 | dws->num_cs = num_cs; |
187 | 186 | ||
188 | if (pdev->dev.of_node) { | ||
189 | int i; | ||
190 | |||
191 | for (i = 0; i < dws->num_cs; i++) { | ||
192 | int cs_gpio = of_get_named_gpio(pdev->dev.of_node, | ||
193 | "cs-gpios", i); | ||
194 | |||
195 | if (cs_gpio == -EPROBE_DEFER) { | ||
196 | ret = cs_gpio; | ||
197 | goto out; | ||
198 | } | ||
199 | |||
200 | if (gpio_is_valid(cs_gpio)) { | ||
201 | ret = devm_gpio_request(&pdev->dev, cs_gpio, | ||
202 | dev_name(&pdev->dev)); | ||
203 | if (ret) | ||
204 | goto out; | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | |||
209 | init_func = device_get_match_data(&pdev->dev); | 187 | init_func = device_get_match_data(&pdev->dev); |
210 | if (init_func) { | 188 | if (init_func) { |
211 | ret = init_func(pdev, dwsmmio); | 189 | ret = init_func(pdev, dwsmmio); |
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index a945fad3db62..f54b498001a9 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | #include <linux/spi/spi.h> | 22 | #include <linux/spi/spi.h> |
23 | #include <linux/gpio.h> | ||
24 | 23 | ||
25 | #include "spi-dw.h" | 24 | #include "spi-dw.h" |
26 | 25 | ||
@@ -426,13 +425,6 @@ static int dw_spi_setup(struct spi_device *spi) | |||
426 | 425 | ||
427 | chip->tmode = SPI_TMOD_TR; | 426 | chip->tmode = SPI_TMOD_TR; |
428 | 427 | ||
429 | if (gpio_is_valid(spi->cs_gpio)) { | ||
430 | ret = gpio_direction_output(spi->cs_gpio, | ||
431 | !(spi->mode & SPI_CS_HIGH)); | ||
432 | if (ret) | ||
433 | return ret; | ||
434 | } | ||
435 | |||
436 | return 0; | 428 | return 0; |
437 | } | 429 | } |
438 | 430 | ||
@@ -497,6 +489,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) | |||
497 | goto err_free_master; | 489 | goto err_free_master; |
498 | } | 490 | } |
499 | 491 | ||
492 | master->use_gpio_descriptors = true; | ||
500 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP; | 493 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP; |
501 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); | 494 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); |
502 | master->bus_num = dws->bus_num; | 495 | master->bus_num = dws->bus_num; |