Re: [RFC] Initial state for GPIOs

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

 



On 20.06.19 15:16, Martyn Welch wrote:

Hi,

I haven't followed the previous discussions, so please forgive me when
I'm missing something and asking dumb or already answered questions:

> An alternative that has been briefly raised[4] when I approached the> subject recently on the GPIO mailing list is to add a property to the>
controller node, rather than child nodes, that listed the expected>
initial states of the pins as an array, much like the line names are>
handled through "gpio-line-names".
If it's really about early setting a specific state *once*, then I think
this would be the best approach.

OTOH, I'm still a bit unsure, whether the whole idea is really correct
to begin with:

I'd guess if a specific initial state is required, the pin has some
special meaning, which indicates there should be a specific driver for
it. I've got a strange feeling on splitting the semantics between board
configuration like DT (or some board init code) and the driver - even if
the driver is just some script in userland.

What are the reasons for not just doing it in a bootup script ?

Another problem might be timing: in either case, we don't know when the
initial state is actually set. Doing it in the kernel instead of
userland certainly moves it to an earlier point in time, but still a
pretty much unpredictable one.

> --- gpio.h
>         /* Bit 4 express initial state */
>         #define GPIO_INPUT 0
>         #define GPIO_OUTPUT 16
> 
>         /* Bit 5 express initial state */
>         #define GPIO_INITIAL_LOW 0
>         #define GPIO_INITIAL_HIGH 32
>         
>         #define GPIO_OUTPUT_LOW (GPIO_OUTPUT | GPIO_INITIAL_LOW)
>         #define GPIO_OUTPUT_HIGH (GPIO_OUTPUT | GPIO_INITIAL_HIGH)

Does it need to be an int value in DT ?
Why not using human-readable strings, eg:

   "in"
   "out-low"
   "out-hi"

Yes, doing three strcmp()s takes more cycles than just a switch(),
but does that really matter ?

> An alternative option may be to provide the offset as the first item
> (though this is then different from "gpio-line-names"), so:
>
> 
> --- device tree
>         &gpiochip {
>                 gpio-line-names = "", "", "", "widget_en",
> 			"widget_signal";
>                 gpio-initial-states =
> 			<3 GPIO_OUTPUT_HIGH | GPIO_LINE_OPEN_DRAIN>,
> 			<4 GPIO_INPUT | GPIO_ACTIVE_LOW>;
>         };

hmm, feels a bit strange to me. Yes, it allows a shorter notation, if
one just wants to set very few lines, but IMHO complicates things.
I feel a list w/ possibly NULL entries is cleaner.


--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@xxxxxxxxx -- +49-151-27565287



[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