diff options
author | Geert Uytterhoeven <geert+renesas@linux-m68k.org> | 2014-02-20 09:43:04 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-02-21 22:11:12 -0500 |
commit | 8d19534a8d539bb2e598e56e017a423f205e909e (patch) | |
tree | 3bfccab6e9f7fa585b31f88bec1cec8ebe19e98e /drivers/spi/spi-sh-msiof.c | |
parent | 01cfef57efe9c8ef445d4a5ad3bf26770fd5942a (diff) |
spi: sh-msiof: Use the core cs_gpio field, and make it optional
In current implementation, CS is controlled by GPIO, which is passed
through spi->controller_data. However, the MSIOF HW module has a function
to output CS by itself, which is already enabled and actual switch will be
done by pinmux.
Store the GPIO number in the core cs_gpio field, and ignore it if it is
an invalid (negative) GPIO number.
Loosely based on a patch from Takashi Yoshii <takasi-y@ops.dti.ne.jp>.
Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-sh-msiof.c')
-rw-r--r-- | drivers/spi/spi-sh-msiof.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index 7acbc4052757..6e2ba62ceb63 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c | |||
@@ -446,6 +446,21 @@ static int sh_msiof_spi_setup_transfer(struct spi_device *spi, | |||
446 | return spi_bitbang_setup_transfer(spi, t); | 446 | return spi_bitbang_setup_transfer(spi, t); |
447 | } | 447 | } |
448 | 448 | ||
449 | static int sh_msiof_spi_setup(struct spi_device *spi) | ||
450 | { | ||
451 | struct device_node *np = spi->master->dev.of_node; | ||
452 | |||
453 | if (!np) { | ||
454 | /* | ||
455 | * Use spi->controller_data for CS (same strategy as spi_gpio), | ||
456 | * if any. otherwise let HW control CS | ||
457 | */ | ||
458 | spi->cs_gpio = (uintptr_t)spi->controller_data; | ||
459 | } | ||
460 | |||
461 | return spi_bitbang_setup(spi); | ||
462 | } | ||
463 | |||
449 | static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on) | 464 | static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on) |
450 | { | 465 | { |
451 | struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master); | 466 | struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master); |
@@ -471,8 +486,8 @@ static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on) | |||
471 | !!(spi->mode & SPI_CS_HIGH)); | 486 | !!(spi->mode & SPI_CS_HIGH)); |
472 | } | 487 | } |
473 | 488 | ||
474 | /* use spi->controller data for CS (same strategy as spi_gpio) */ | 489 | if (spi->cs_gpio >= 0) |
475 | gpio_set_value((uintptr_t)spi->controller_data, value); | 490 | gpio_set_value(spi->cs_gpio, value); |
476 | 491 | ||
477 | if (is_on == BITBANG_CS_INACTIVE) { | 492 | if (is_on == BITBANG_CS_INACTIVE) { |
478 | if (test_and_clear_bit(0, &p->flags)) { | 493 | if (test_and_clear_bit(0, &p->flags)) { |
@@ -759,7 +774,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev) | |||
759 | master->bus_num = pdev->id; | 774 | master->bus_num = pdev->id; |
760 | master->dev.of_node = pdev->dev.of_node; | 775 | master->dev.of_node = pdev->dev.of_node; |
761 | master->num_chipselect = p->info->num_chipselect; | 776 | master->num_chipselect = p->info->num_chipselect; |
762 | master->setup = spi_bitbang_setup; | 777 | master->setup = sh_msiof_spi_setup; |
763 | master->cleanup = spi_bitbang_cleanup; | 778 | master->cleanup = spi_bitbang_cleanup; |
764 | 779 | ||
765 | p->bitbang.master = master; | 780 | p->bitbang.master = master; |