Le 27/11/2019 à 11:55, Linus Walleij a écrit :
On Wed, Nov 27, 2019 at 11:39 AM Christophe Leroy
<christophe.leroy@xxxxxx> wrote:
Le 27/11/2019 à 11:02, Linus Walleij a écrit :
On Wed, Nov 27, 2019 at 10:34 AM Christophe Leroy
<christophe.leroy@xxxxxx> wrote:
In the meantime, I have tried changing "gpios" by "cs-gpios" in the
device tree, and I get the following warning:
(...)
[ 3.156654] WARNING: CPU: 0 PID: 1 at drivers/spi/spi-fsl-spi.c:716
fsl_spi_cs_control+0x64/0x7c
That should be this one:
if (WARN_ON_ONCE(!pinfo->immr_spi_cs))
return;
That happens when spi->cs_gpiod is NULL so the
chipselect isn't found and assigned, and the code
goes on to check the native CS and find that this isn't
available either and issues the warning.
That's in spi_add_device(), it is spi->cs_gpio and not spi->cs_gpiod
which is assigned, so spi->cs_gpiod remains NULL.
That's weird, because when ->use_gpio_descriptors is set
(as for this driver) the core only attempts to look up
spi->cs_gpiods and not spi->cs_gpios, and consequently
can only assign spi->cd_gpiod and not spi->cs_gpio:
That's it. ->use_gpio_descriptors isn't set for the FSL driver:
[root@po16098vm linux-powerpc]# git grep use_gpio_descriptors drivers/spi/
drivers/spi/spi-ath79.c: master->use_gpio_descriptors = true;
drivers/spi/spi-atmel.c: master->use_gpio_descriptors = true;
drivers/spi/spi-bcm2835.c: * as the flag use_gpio_descriptors enforces
SPI_CS_HIGH.
drivers/spi/spi-bcm2835.c: ctlr->use_gpio_descriptors = true;
drivers/spi/spi-cadence.c: master->use_gpio_descriptors = true;
drivers/spi/spi-clps711x.c: master->use_gpio_descriptors = true;
drivers/spi/spi-davinci.c: master->use_gpio_descriptors = true;
drivers/spi/spi-dw.c: master->use_gpio_descriptors = true;
drivers/spi/spi-ep93xx.c: master->use_gpio_descriptors = true;
drivers/spi/spi-gpio.c: master->use_gpio_descriptors = true;
drivers/spi/spi-sh-msiof.c: ctlr->use_gpio_descriptors = true;
drivers/spi/spi-tegra114.c: master->use_gpio_descriptors = true;
drivers/spi/spi.c: if (ctlr->use_gpio_descriptors)
drivers/spi/spi.c: if (ctlr->use_gpio_descriptors) {
I have now added it, together with the DTS cs-gpios name change (without
your counting patch with crashes), and I get something which is almost
working: I get temperature back into sensors, but temperature is 0°C !!!
root@vgoip:~# sensors
lm74-spi-0-5
Adapter: SPI adapter
Temperature processeur: +0.0 C
lm74-spi-0-1
Adapter: SPI adapter
Temperature MIAE: +0.0 C
Looking into dmesg, I see:
[ 3.153521] lm74@1 GPIO handle specifies active low - ignored
[ 3.178093] lm74@5 GPIO handle specifies active low - ignored
Any link with the problem ?
Christophe
if (ctlr->use_gpio_descriptors) {
status = spi_get_gpio_descs(ctlr);
(...)
} else {
(....)
status = of_spi_get_gpio_numbers(ctlr);
}
(...)
/* Descriptors take precedence */
if (ctlr->cs_gpiods)
spi->cs_gpiod = ctlr->cs_gpiods[spi->chip_select];
else if (ctlr->cs_gpios)
spi->cs_gpio = ctlr->cs_gpios[spi->chip_select];
So I'm a bit confused...
Yours,
Linus Walleij