device initialization The situation has been observed that on the RPI after a reboot the GPIOs used for chip-selects are set to low when pinctl finishes setting up the direction of the pins. This can negatively impact the spi-bus and inhibit propper device detection. This (incomplete) code pulls the CS high to avoid the situation in the common case of "normal" CS-priority - it still needs a revisit to get the reverse polarity cases right as well. A variation of this probably should get moved into spi_register_master to fix this for other spi-controller as well. Signed-off-by: Martin Sperl <kernel@xxxxxxxxxxxxxxxx> Tested-by: Martin Sperl <kernel@xxxxxxxxxxxxxxxx> --- drivers/spi/spi-bcm2835.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) Applies against spi - topic/bcm2835. diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index 1d731b8..b6825a4 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -349,6 +349,26 @@ static int bcm2835_spi_setup(struct spi_device *spi) return -EINVAL; } +static void bcm2835_spi_initialsetup_gpio(struct spi_master *master) +{ + int i; + bool level; + + if (!master->cs_gpios) + return; + + for (i = 0; i < master->num_chipselect; i++) { + if (gpio_is_valid(master->cs_gpios[i])) { + /* actually we need to figure out the + * configured CSPOL of that device here, + * not sure how to do that... + */ + level = true; + gpio_set_value(master->cs_gpios[i], level); + } + } +} + static int bcm2835_spi_probe(struct platform_device *pdev) { struct spi_master *master; @@ -414,6 +434,9 @@ static int bcm2835_spi_probe(struct platform_device *pdev) goto out_clk_disable; } + /* set GPIO-CS to disabled */ + bcm2835_spi_initialsetup_gpio(master); + return 0; out_clk_disable: -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html