-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce gpio-keys wake-up sources using pinctrl #64538
Introduce gpio-keys wake-up sources using pinctrl #64538
Conversation
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
This add the pin wake-up source configuration capabilities to the SAM pinctrl driver. It add the SUPC functions at SoC and update gpio and pinctrl drivers to allow user configure the wake-up core power supply functionality. Signed-off-by: Gerson Fernando Budke <[email protected]>
ffc2386
to
071d958
Compare
Some devices require use of pinctrl driver to initialize and configure advanced features like wake-up sources. This introduce minimal support to pinctrl driver to enable such resource for those platforms. Signed-off-by: Gerson Fernando Budke <[email protected]>
Add pinctrl configuration to enable wake-up sources for gpio-keys driver. After this the special function for some wake-up source will be enabled by default and can wake-up device from a power-off state. In addition it reorder pinctrl definitions to be ascendent. Signed-off-by: Gerson Fernando Budke <[email protected]>
071d958
to
282bdb3
Compare
The gpio-keys is a standard mechanism in Linux to be used as wake-up source. This introduces an example to demonstrate how to use such functionality toguether with power-off API. Signed-off-by: Gerson Fernando Budke <[email protected]>
282bdb3
to
9d8833f
Compare
The first commit is from #64213 and can be ignored. |
pinctrl-0 = <&gpio_keys_default>; | ||
pinctrl-names = "default"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you look at Linux, the way gpio-keys
are configured as wake-up sources is via the wakeup-source
property (in each subnode). So, I guess the proper way to handle this is to make the input driver handle such property and forward it to the GPIO/pinctrl(?) driver when configuring the pin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you look at Linux, the way gpio-keys are configured as wake-up sources is via the wakeup-source property (in each subnode). So, I guess the proper way to handle this is to make the input driver handle such property and forward it to the GPIO/pinctrl(?) driver when configuring the pin.
This PR seems to be the most far I can go with what is implemented in tree. IMHO the use of wakeup-source
can be addressed in another moment because it seems to require a dedicated API which, for the moment, is out of scope for this PR. To propose an API change or new API require in deep knowledge from other architectures which I don't have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine adding these pinctrl entries (thanks for the https://github.com/torvalds/linux/blob/750b95887e567848ac2c851dae47922cac6db946/arch/arm/boot/dts/microchip/at91-sama5d2_xplained.dts#L708-L720 example). However, these entries should be of course optional, and the driver needs to be prepared to handle the case when they're not present, that is, handle the -ENOENT
error case gracefully. Also, the wakeup-source
can be used as a toggle to apply such configuration, I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine adding these pinctrl entries
Ok, thank you. Can I get your approval on #64213 since it a dependency?
However, these entries should be of course optional, and the driver needs to be prepared to handle the case when they're not present, that is, handle the -ENOENT error case gracefully.
Perfect! I'll do it.
Also, the wakeup-source can be used as a toggle to apply such configuration, I guess.
This is what I want add later on another PR but that is the final idea.
if (ret < 0) { | ||
return ret; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will make the driver useless to any platform that has CONFIG_PINCTRL=y and no pinctrl entries for each gpio-keys subnode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your suggestion about how to handle it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comment above
Hey this approach is cool for the demo, but how would it work if you wanted to setup wake up from a different source? Like a device interrupt or some other signal. I think that the wakeup property should be somewhere else, not in pinctrl. |
The demo is quite specific, it uses
Why? Why the pinctrl is not the right place to stored the information required by this SoC to enable the required functionality? I question because maybe it is missing context about why pinctrl should be present. The Atmel requires specific bit to be set at SUPC which doesn't have nothing to do with gpio itself but it is defined as a special attribute for a specific gpio pin (random). This can be easy defined at pinconfig structure as stated in the datasheet, see #64213 (comment). Further, this information can be used together with That said, because after this PR it is possible to use the wake-up feature directly for the Atmel platform by pinctrl, as a short cut, it doesn't mean that it is wrong nor it is violating something. However, using the GPIO only will require a custom solution on my view because it necessary to bind SUPC with GPIO. It is important mention that there is no As reference, the About Remarks:
|
I'm fine with a vendor specific solution but this seems like would require modifying existing drivers to add pinctrl code when they don't need it for any other reasons. How would you wakeup, say, from an accelerometer interrupt? The driver does not have a pinctrl setup, it does not have to, would you start adding pinctrl call to every driver in the repository? |
There is no API changes here or on any place. So, if I understood you correctly the answer is no. There is no reason to do any changes on any pinctrl driver. For the specific edge case of Atmel it was necessary the functionality but that doesn't means that others driver will require that. Even for the Atmel, the information was encoded in a way that don't require any pinctrl API changes. As @gmarull suggested above, I need to fix the
The same way it is made today. In the case of |
Hi @ceolin , Here there is the proposal how to connect a few bits about wakeup. With this, at least with Atmel, will be possible to link pinctrl pin info with gpio flags to indicate to SUPC controller what are the active wakeup sources. After that, the SUPC driver could be used to monitor what sources were active for that purpose since it knows that all the time. Then, I imagine that PM could consult the SoC supply/PM driver about the registered sources and take acton. On this model each driver will be responsible to register itself on the SoC supply manager. I understand that those connections are anyway vendor specific and should not be a problem. The PM than only needs to talk with SoC supply manager to know what to do. Users donˋt need to do anything. Maybe I still didnˋt figure out all the implications but I think is a start. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Some devices require use of pinctrl driver to initialize and configure advanced features like wake-up sources. This introduce minimal support to pinctrl driver to enable such resource for those platforms in the gpio-keys driver.
Since the gpio-keys can be used as an standard mechanism as wake-up this introduces an example how to demonstrate such
functionality together with power-off API.
depends on #64213