mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 14:50:19 +00:00
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>
This commit is contained in:
parent
01cfef57ef
commit
8d19534a8d
@ -446,6 +446,21 @@ static int sh_msiof_spi_setup_transfer(struct spi_device *spi,
|
|||||||
return spi_bitbang_setup_transfer(spi, t);
|
return spi_bitbang_setup_transfer(spi, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sh_msiof_spi_setup(struct spi_device *spi)
|
||||||
|
{
|
||||||
|
struct device_node *np = spi->master->dev.of_node;
|
||||||
|
|
||||||
|
if (!np) {
|
||||||
|
/*
|
||||||
|
* Use spi->controller_data for CS (same strategy as spi_gpio),
|
||||||
|
* if any. otherwise let HW control CS
|
||||||
|
*/
|
||||||
|
spi->cs_gpio = (uintptr_t)spi->controller_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return spi_bitbang_setup(spi);
|
||||||
|
}
|
||||||
|
|
||||||
static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on)
|
static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on)
|
||||||
{
|
{
|
||||||
struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master);
|
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)
|
|||||||
!!(spi->mode & SPI_CS_HIGH));
|
!!(spi->mode & SPI_CS_HIGH));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use spi->controller data for CS (same strategy as spi_gpio) */
|
if (spi->cs_gpio >= 0)
|
||||||
gpio_set_value((uintptr_t)spi->controller_data, value);
|
gpio_set_value(spi->cs_gpio, value);
|
||||||
|
|
||||||
if (is_on == BITBANG_CS_INACTIVE) {
|
if (is_on == BITBANG_CS_INACTIVE) {
|
||||||
if (test_and_clear_bit(0, &p->flags)) {
|
if (test_and_clear_bit(0, &p->flags)) {
|
||||||
@ -759,7 +774,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
|
|||||||
master->bus_num = pdev->id;
|
master->bus_num = pdev->id;
|
||||||
master->dev.of_node = pdev->dev.of_node;
|
master->dev.of_node = pdev->dev.of_node;
|
||||||
master->num_chipselect = p->info->num_chipselect;
|
master->num_chipselect = p->info->num_chipselect;
|
||||||
master->setup = spi_bitbang_setup;
|
master->setup = sh_msiof_spi_setup;
|
||||||
master->cleanup = spi_bitbang_cleanup;
|
master->cleanup = spi_bitbang_cleanup;
|
||||||
|
|
||||||
p->bitbang.master = master;
|
p->bitbang.master = master;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user