diff options
| author | Nicolas Boichat <drinkcat@chromium.org> | 2015-11-08 23:14:51 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2015-11-16 12:44:57 -0500 |
| commit | 98c8dccf2b2771fb622d449b2ec1604fc5d260e5 (patch) | |
| tree | 8ec9304fd36f1c224f3e0cf5677997cd55ca3581 | |
| parent | 8005c49d9aea74d382f474ce11afbbc7d7130bec (diff) | |
spi: mediatek: single device does not require cs_gpios
When only one device is present, it is not necessary to specify
cs_gpios, as the CS line can be controlled by the hardware
module.
Without this patch, older device tree bindings used before
37457607 "spi: mediatek: mt8173 spi multiple devices support"
would cause a panic on boot. This fixes the crash, and
re-introduces backward compatibility.
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Acked-by: Leilk Liu <leilk.liu@mediatek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
| -rw-r--r-- | drivers/spi/spi-mt65xx.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 563954a61424..7840067062a8 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c | |||
| @@ -410,7 +410,7 @@ static int mtk_spi_setup(struct spi_device *spi) | |||
| 410 | if (!spi->controller_data) | 410 | if (!spi->controller_data) |
| 411 | spi->controller_data = (void *)&mtk_default_chip_info; | 411 | spi->controller_data = (void *)&mtk_default_chip_info; |
| 412 | 412 | ||
| 413 | if (mdata->dev_comp->need_pad_sel) | 413 | if (mdata->dev_comp->need_pad_sel && gpio_is_valid(spi->cs_gpio)) |
| 414 | gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); | 414 | gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); |
| 415 | 415 | ||
| 416 | return 0; | 416 | return 0; |
| @@ -632,13 +632,23 @@ static int mtk_spi_probe(struct platform_device *pdev) | |||
| 632 | goto err_put_master; | 632 | goto err_put_master; |
| 633 | } | 633 | } |
| 634 | 634 | ||
| 635 | for (i = 0; i < master->num_chipselect; i++) { | 635 | if (!master->cs_gpios && master->num_chipselect > 1) { |
| 636 | ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i], | 636 | dev_err(&pdev->dev, |
| 637 | dev_name(&pdev->dev)); | 637 | "cs_gpios not specified and num_chipselect > 1\n"); |
| 638 | if (ret) { | 638 | ret = -EINVAL; |
| 639 | dev_err(&pdev->dev, | 639 | goto err_put_master; |
| 640 | "can't get CS GPIO %i\n", i); | 640 | } |
| 641 | goto err_put_master; | 641 | |
| 642 | if (master->cs_gpios) { | ||
| 643 | for (i = 0; i < master->num_chipselect; i++) { | ||
| 644 | ret = devm_gpio_request(&pdev->dev, | ||
| 645 | master->cs_gpios[i], | ||
| 646 | dev_name(&pdev->dev)); | ||
| 647 | if (ret) { | ||
| 648 | dev_err(&pdev->dev, | ||
| 649 | "can't get CS GPIO %i\n", i); | ||
| 650 | goto err_put_master; | ||
| 651 | } | ||
| 642 | } | 652 | } |
| 643 | } | 653 | } |
| 644 | } | 654 | } |
