Open keith-zephyr opened 1 year ago
@ElectricalPaul - The shell support proposed here could be used by your project.
@ElectricalPaul - The shell support proposed here could be used by your project.
That would definitely help in the migration, thanks for opening the issue!
As mentioned in https://github.com/zephyrproject-rtos/zephyr/pull/54845#issuecomment-1433749509, I find this approach way too application specific to be included in upstream Zephyr.
Applications can already control GPIOs. GPIO hogs are not intended to be exposed to the application nor by the shell; they are simply a way of doing GPIO initialization at boot time.
The whole issue of "delayed" or "application-driven" driver initialization is not specific to the GPIO hogs "driver" and we should not add custom ways of working around it per driver/per driver class. A robust, generic solution needs to be found.
Furthermore, the change of exposing the GPIO hogs initialization function as a public API conflicts with my plans for addressing some of the concerns on the original GPIO hogs PR (#54110). To overcome these issues, each GPIO controller driver instance will handle its own GPIO hogs during driver initialization and thus there will be not only one configuration function. This initialization can still happen in generic GPIO controller driver code to avoid code duplication between drivers, but with one call per instance.
The proposed change to the binding (renaming the line-name property) break compatibility with the upstream binding, which was an explicit design goal of introducing GPIO hogs.
CC: @galak, @mbolivar, @cfriedt
The whole issue of "delayed" or "application-driven" driver initialization is not specific to the GPIO hogs "driver" and we should not add custom ways of working around it per driver/per driver class. A robust, generic solution needs to be found.
As mentioned in #54845 (comment), I find this approach way too application specific to be included in upstream Zephyr.
Applications can already control GPIOs. GPIO hogs are not intended to be exposed to the application nor by the shell; they are simply a way of doing GPIO initialization at boot time.
The whole issue of "delayed" or "application-driven" driver initialization is not specific to the GPIO hogs "driver" and we should not add custom ways of working around it per driver/per driver class. A robust, generic solution needs to be found.
Furthermore, the change of exposing the GPIO hogs initialization function as a public API conflicts with my plans for addressing some of the concerns on the original GPIO hogs PR (#54110). To overcome these issues, each GPIO controller driver instance will handle its own GPIO hogs during driver initialization and thus there will be not only one configuration function. This initialization can still happen in generic GPIO controller driver code to avoid code duplication between drivers, but with one call per instance.
The proposed change to the binding (renaming the line-name property) break compatibility with the upstream binding, which was an explicit design goal of introducing GPIO hogs.
CC: @galak, @mbolivar, @cfriedt
@henrikbrixandersen do you have a draft PR that can share that demonstrates your future work for the GPIO hogs?
The current GPIO shell command I find basically unusable in it's current form. Even if a user knows their desired GPIO signal is on port "GPIOA", pin 3, the user has no way to associate "GPIOA" with the GPIO controller name derived from the devicetree node name gpio@40095000
. The gpio-line-names
property could potentially solve this, but a user would have to assign names to all GPIO pins on a given controller, and there isn't a mechanism to allow-list just specific GPIOs.
I proposed adding a shell command to GPIO hogs because it's devicetree representation already has everything one needs: the GPIO controller, the pin, and a friendly name for the pin (derived from either the node name or the line-name). I want to avoid adding another devicetree entry to get a better shell.
@henrikbrixandersen do you have a draft PR that can share that demonstrates your future work for the GPIO hogs?
Not yet.
GPIO Hogs Enhancements
Add features to the GPIO hogs implementation:
Application controlled configuration
A new Kconfig option,
GPIO_HOGS_INITIALIZE_BY_APPLICATION
, instructs the GPIO hogs driver to bypass GPIO configuration automatically at initialization. Instead the application code must callgpio_hogs_configure()
manually, passing in a mask of GPIO flags to configure. The code snipped below demonstrates how the an application code can make a run-time decision affecting the GPIO hog configuration.The
gpio_hogs_configure()
routine takes 2 parameters, allowing the application to filter on the GPIO controller port.GPIO hogs shell
The current gpio shell commands are difficult to use, as the user must know the GPIO controller nodename and the pin number associated with the signal on the board. The current gpio shell command provides no tab completion, and will accept any valid nodename, regardless of whether it points to a GPIO controller.
The GPIO hogs driver provides the
line-name
a property, but this property is currently unused.For this proposal, the
line-name
property is changed tolines-names
as each GPIO hog can specify multiple GPIO pins.The shell commands use the line-names property as an argument for getting the state of GPIO inputs or setting the state of GPIO outputs.
An application can make a GPIO pin available to the GPIO shell commands, without the GPIO hogs driver configuring the pin, by omitting input, output-low, and output-high properties.
Benefits over the existing "gpio" shell command:
Implementation
A draft PR demonstrating the application driven initialization and a GPIO hogs shell command is on PR https://github.com/zephyrproject-rtos/zephyr/pull/54845.