Re: GPIOs not correctly exported via sysfs on ATSAMA5D2

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

 



On Fri, Feb 28, 2020 at 11:58:21AM +0100, Romain Izard wrote:
> Hello,
> 
> While experimenting with a new chip, I connected it on the SDIO
> interface on my board based on a SAMA5D2 SoC. For a first step, I need
> to drive the pins on the SDIO bus at a given level to program this new
> chip. To do so, I tried to control the GPIO lines manually by unbinding
> the SDHCI controller, and using /sys/class/gpio/export to control the
> pins, with the following code:
> 
> echo a0000000.sdio-host > /sys/bus/platform/drivers/sdhci-at91/unbind
> echo 4 > /sys/class/gpio/export
> echo low > /sys/class/gpio/PA4/direction
> 
> Unfortunately, the state of the pin does not change and it remains
> driven to 1. I checked the configuration register with devmem2, and it
> appeared that the selected function remains the SDIO function even after
> calling export.
> 
> The issue does not appear when I use a GPIO in a driver with an explicit
> pinctrl configuration in the device tree, which explains why I did not
> see it until now.
> 
> The kernel version used is Linux 5.4.22
> 
> Is this a user error from my part, or is there something missing in the
> AT91 PIO4 pinctrl driver ?

IMHO this is all as expected. There are gpio controllers that
automatically mux the matching pin, but you must not expect that.

My personal opinion on this is, that the downside of this automatic is
worse than its benefits:

 - It's not universal, as there are SoCs that don't have a single pin
   for a given GPIO, so you cannot reliably implement it for all
   controllers.

 - Sometimes it is useful to make use of a GPIO and a dedicated function
   on the same pin in a driver (e.g. an i2c driver might need to switch
   to gpio to do a bus recovery). The automatic pinmuxing then has
   strange side effect because you have to remux the pins after
   requesting the GPIOs even if you didn't drive the pins as GPIO and
   there is a short time where the pin function isn't the dedicated
   one.

So to me this is too magic and less explicit and so bad.

Just my 0.02€
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |



[Index of Archives]     [Linux SPI]     [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