Skip to content
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

dts/bindings: Add gpio-generic binding #18544

Closed
wants to merge 1 commit into from

Conversation

tsvehagen
Copy link
Collaborator

This binding is meant to specify gpios in the device-tree that are not leds
or buttons.

Signed-off-by: Tobias Svehagen [email protected]

@zephyrbot
Copy link
Collaborator

zephyrbot commented Aug 21, 2019

All checks are passing now.

Review history of this comment for details about previous failed status.
Note that some checks might have not completed yet.

@mnkp mnkp self-requested a review August 21, 2019 10:39
dts/bindings/gpio/gpio-generic.yaml Outdated Show resolved Hide resolved
dts/bindings/gpio/gpio-generic.yaml Outdated Show resolved Hide resolved
dts/bindings/gpio/gpio-generic.yaml Outdated Show resolved Hide resolved
Copy link
Collaborator

@galak galak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give an example of when or how this would be used. Normally I'd expect GPIOs to be related to some other device.

@raveslave
Copy link

Can you give an example of when or how this would be used. Normally I'd expect GPIOs to be related to some other device.

some examples:

  • getting defines for named gpio's (usually mirroring the netnames of the schematic)
    • used directly in application code where there isn't a particular driver or peripheral IC involved
  • could be a state-machine that looks at a few generic signals like POWER_GOOD + BOOT_DONE from some Co-processor or FPGA

@galak
Copy link
Collaborator

galak commented Aug 21, 2019

  • getting defines for named gpio's (usually mirroring the netnames of the schematic)

    • used directly in application code where there isn't a particular driver or peripheral IC involved

This is a bit too vague as an example.

  • could be a state-machine that looks at a few generic signals like POWER_GOOD + BOOT_DONE from some Co-processor or FPGA

I would argue that the FPGA or co-processor should have a node in the device tree and the gpio's would live there.

@tsvehagen
Copy link
Collaborator Author

Can you give an example of when or how this would be used. Normally I'd expect GPIOs to be related to some other device.

A lot of peripheral devices have very simple interfaces. For example a motion sensor as an input or a relay control pin as output. I think it makes more sense to have these as generic gpios rather than having a separate binding.

This binding is meant to specify gpios in the device-tree that are not
leds or buttons.

Signed-off-by: Tobias Svehagen <[email protected]>
@galak
Copy link
Collaborator

galak commented Aug 21, 2019

A lot of peripheral devices have very simple interfaces. For example a motion sensor as an input or a relay control pin as output. I think it makes more sense to have these as generic gpios rather than having a separate binding.

And how is that motion sensor connected to the SoC? Is this some on SoC peripheral or I2C or SPI device. As in the case of the FPGA, the motion sensor should have a device node in the device tree and that device can have a -gpios property as part of it.

@tsvehagen
Copy link
Collaborator Author

A lot of peripheral devices have very simple interfaces. For example a motion sensor as an input or a relay control pin as output. I think it makes more sense to have these as generic gpios rather than having a separate binding.

And how is that motion sensor connected to the SoC? Is this some on SoC peripheral or I2C or SPI device. As in the case of the FPGA, the motion sensor should have a device node in the device tree and that device can have a -gpios property as part of it.

In the case of a PIR sensor it's usually just connected with a pin to signal motion, no bus involved. I agree with you that these devices could have their own node in the device-tree but then there would be a lot of different names for all of the different devices. It would be kind of a hassle to have all of these upstream. I guess it could be okay if it's possible to have out-of-tree dts bindings. Is this possible?

@galak
Copy link
Collaborator

galak commented Aug 21, 2019

In the case of a PIR sensor it's usually just connected with a pin to signal motion, no bus involved. I agree with you that these devices could have their own node in the device-tree but then there would be a lot of different names for all of the different devices. It would be kind of a hassle to have all of these upstream. I guess it could be okay if it's possible to have out-of-tree dts bindings. Is this possible?

Yes, out of tree bindings is possible, see:

https://docs.zephyrproject.org/latest/application/index.html?highlight=dts_root#devicetree-definitions

@raveslave
Copy link

I would argue that the FPGA or co-processor should have a node in the device tree and the gpio's would live there.

Sounds reasonable that this is the right way. Can you please reference to an example?

@mnkp
Copy link
Member

mnkp commented Aug 22, 2019

The requirement to give names to arbitrary GPIO pins keeps popping up on the email list and Slack. I assume, as a convenient and quick way to play with the evaluation board - which typically offers lots of free GPIO pins readily available - without hard coding pin numbers in the source code. In truth, I never asked.

One example of a more legitimate use case would be to give names to pins that control power domains on the board. If we have a pin that controls power supply of a high voltage or analog part of the board having a way to easily name it is quite convenient. Creating an extra DTS node describing such a 'virtual' component feels like a long way to go. Another example would be to name a GPIO wake-up pin that is not associated with any specific hardware module.

That said, some time ago I searched through the Linux DTS files and documentation to see if they provide a similar 'general' mapping mechanism but couldn't find anything. It seems like they don't.

@pabigot
Copy link
Collaborator

pabigot commented Sep 24, 2019

One example of a more legitimate use case would be to give names to pins that control power domains on the board. If we have a pin that controls power supply of a high voltage or analog part of the board having a way to easily name it is quite convenient. Creating an extra DTS node describing such a 'virtual' component feels like a long way to go.

If the only thing it powers is a single device, such a pin could be a power-gpios property on that device. But in the general case it should be in a regulator-gpio device node where it can participate in power management of dependent devices.

Another example would be to name a GPIO wake-up pin that is not associated with any specific hardware module.

Linux use would also have that within a standard node.

@henrikbrixandersen
Copy link
Member

That said, some time ago I searched through the Linux DTS files and documentation to see if they provide a similar 'general' mapping mechanism but couldn't find anything. It seems like they don't.

@pabigot Actually, Linux does support named GPIOs: See gpio-line-names in https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt.

@galak
Copy link
Collaborator

galak commented Aug 4, 2020

See #25945 as to the provider solution path for this.

@pabigot
Copy link
Collaborator

pabigot commented Sep 4, 2020

Superseded by #27937. Please open a new RFC if that solution doesn't meet the need.

@pabigot pabigot closed this Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree area: GPIO
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants