Skip to content

Wrap PWM output as GPIO #4629

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

Merged
merged 1 commit into from
Oct 14, 2021
Merged

Conversation

6by9
Copy link
Contributor

@6by9 6by9 commented Oct 14, 2021

This needs a dt binding, but I wondered what people thought.

Scenario is for things like DSI screens where we have I2C up the FFC, and want a combination of GPIO outputs for resets and regulators, and PWM for the backlight.
You can get chips such as NXP PCA9685 which gives 16 PWM outputs, or you can get I2C expanders that give GPIOs. To avoid having to put both on the controller board, wrap some PWM outputs of an PCA9685 as GPIO outputs, and drive them as such.

https://forums.raspberrypi.com/viewtopic.php?f=98&t=321245&p=1925007

One thing that would be nice to do would be to read an array of PWM outputs and create a single gpiochip supporting all of them. Currently you need a separate instance for each output. I couldn't see a way of configuring multiple PWM devices without also specifying names for each one, but I may have just missed it.

For cases where spare PWM outputs are available, but are desired
to be addressed a standard outputs instead.
Wraps a PWM channel as a new GPIO chip with the one output.

Signed-off-by: Dave Stevenson <[email protected]>
@6by9 6by9 force-pushed the rpi-5.10.y-pwm_gpio branch from 4fe5331 to 2777d6d Compare October 14, 2021 13:57
@6by9
Copy link
Contributor Author

6by9 commented Oct 14, 2021

Updated to wrap all PWMs listed in DT as GPIOs. Names are needed due to the way the way the API works.

dtoverlay hack dropped as it doesn't want to be merged. For reference, it was

+
+       fragment@1 {
+               target-path = "/";
+               __overlay__ {
+                       pwm_gpio: pwm_gpio@0 {
+                               compatible = "pwm-gpio";
+                               reg = <0x0>;
+                               gpio-controller;
+                               #gpio-cells = <2>;
+
+                               pwms =  <&pca 15 1000000>, //100ns or 1kHz
+                                       <&pca 14 1000000>,
+                                       <&pca 13 1000000>;
+                               pwm-names = "gpio1", "gpio2", "gpio3";
+
+                               status = "okay";
+                       };
+               };
+       };
+

Copying the example set by gpio-fsm, no dt binding doc as it won't be acceptable to upstream anyway ;-)

@pelwell
Copy link
Contributor

pelwell commented Oct 14, 2021

I'm happy with that. Any objections to me ignoring the "RFC" and merging?

@6by9 6by9 changed the title RFC: Wrap PWM output as GPIO Wrap PWM output as GPIO Oct 14, 2021
@6by9
Copy link
Contributor Author

6by9 commented Oct 14, 2021

RFC removed

@pelwell pelwell merged commit 4dd67ca into raspberrypi:rpi-5.10.y Oct 14, 2021
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Oct 15, 2021
See: raspberrypi/linux#4624

kernel: Wrap PWM output as GPIO
See: raspberrypi/linux#4629

kernel: mmc: sdhost: Pass DT pointer to rpi_firmware_get
kernel: ARM: dts: Give sdhost a firmware reference
See: raspberrypi/linux#4631

kernel: rtc: pcf85063: Always clear EXT_TEST from set_time
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this pull request Oct 15, 2021
See: raspberrypi/linux#4624

kernel: Wrap PWM output as GPIO
See: raspberrypi/linux#4629

kernel: mmc: sdhost: Pass DT pointer to rpi_firmware_get
kernel: ARM: dts: Give sdhost a firmware reference
See: raspberrypi/linux#4631

kernel: rtc: pcf85063: Always clear EXT_TEST from set_time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants