Re: cs-gpios and request_gpio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From Trent Piepho <tpiepho () impinj ! com>:
> The SPI drivers do it.
> If you look in the spi master driver's probe function in the most up-
> to-date drivers, there is usually a loop over every cs-gpio that does a
> devm_gpio_request_one.
> 
What's the proper ordering of driver behavior here?  Currently, spi_register_master() results in gpio activity before the GPIOs are reserved by the core.  The stack trace looks like:

gpio_set_value
spi_set_cs
spi_setup
spi_add_device
of_register_spi_device 
of_register_spi_devices
spi_register_master

Where is the spi driver supposed to get in there and reserve the GPIOs?  Should the driver be iterating the devtree and doing a devm_reserve_gpio() on each of the cs-gpios before calling spi_register_master (or spi_bitbang_start, which itself calls spi_register_master)?

The spi-imx driver cs handling seems broken, at least in 4.9 where I live, and code inspection suggests in 4.18 as well.  The gpio is configured as an output via spi_setup->spi_imx_setup->gpio_direction_output, but then that setting can be trampled via the later call to devm_gpio_request in the driver's probe method.

Any comments much appreciated!

Jonah
> Given all the problems getting this right, one wonders if the spi core
> could do it automatically.  The DT property is pretty standard.
> 
> In some drivers, the gpio is only requested when the spi slave is used.
> I think the idea there was sort of pre device tree run time
> configuration.  There dev kit has a gpio going to a gpio header and you
> can also use the same gpio as a chip select on the spi header.  Depends
> on what you want to connect to the dev kit.  If request the gpio as a
> chip select when the spi master is probed, you can't use it as a
> regular gpio.  So only request it when the spi slave is used, if the
> slave isn't used, then the pin can be a normal gpio.
> 
> Now days I think one would enable the proper nodes in the DT to do
> this.
> 
> On Tue, 2018-07-31 at 17:31 +0000, Langer, Thomas wrote:
> > Hello spi experts,
> > 
> > I am using cs-gpios on a "Lantiq" platform (based on devicetree and
> > lantiq-ssc
> > driver).
> > This works without problem, when the gpio is setup by some pinctrl
> > definitions.
> > 
> > What I am missing the request_gpio or a similar call, which does the
> > reservation
> > of the gpio. Is this expected from the spi-core or must this be
> > implemented in
> > the specific spi driver?
> > 
> > Thanks for clarification,
> > Thomas Langer





[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux