of_pwm_get(9)
π« of_pwm_get(9) β like, the whole tea π«
Okay bestie, sit down, grab your matcha π β this is of_pwm_get(9) straight out of the Kernel API Manual, and honestly? It's giving "small function, big responsibilities." Let's get into it π
β¨ NAME β¨
of_pwm_get β request a PWM via the PWM framework π
No cap, that's the whole pitch. You want a PWM? This is the door you knock on.
β¨ SYNOPSIS β¨
struct pwm_device * of_pwm_get (struct device *dev , struct device_node
*np , const char *con_id );
Three arguments, one pointer out. Iconic signature honestly π«Ά
β¨ ARGUMENTS β¨
devβ the device for the PWM consumer. Like, who's asking for the PWM πnpβ the device node to get the PWM from. This is the tree branch you're pulling from π³con_idβ the consumer name. Your little name tag at the PWM party π
β¨ DESCRIPTION β¨
So here's the vibe: it returns the PWM device parsed from the phandle and index specified in the "pwms" property of a device tree node β or a negative error-code on failure π. Everything parsed from the device tree gets stored in the returned PWM device object, so it's not just handing you a pointer, it's handing you a fully loaded one β¨
Now, the con_id tea β β and this part matters, so pay attention:
If con_id is NULL, the first PWM device listed in the "pwms" property will be requested. Easy, default behavior, slay π
Otherwise, the "pwm-names" property is used to do a reverse lookup of the PWM index. Which also means β and this is the part people forget and then cry about β the "pwm-names" property becomes mandatory for devices that look up the PWM device via the con_id parameter. Mandatory. Like, required required. Not optional, bestie π¨
Lowkey the biggest gotcha on this whole page: pass acon_id, and you must have"pwm-names"in your device tree. No exceptions, no "but it worked on my machine" π«
β¨ RETURN β¨
A pointer to the requested PWM device π β or, if things went sideways, an ERR_PTR-encoded error code. So like, always check it with IS_ERR() before you go dereferencing it, iykyk π
β¨ SEE ALSO β¨
The kernel file lives at ./drivers/pwm/core.c, and here's the whole friend group π«Ά:
pwm_round_waveform_might_sleep(9), pwm_get_waveform_might_sleep(9), pwm_set_waveform_might_sleep(9), pwm_apply_might_sleep(9), pwm_apply_atomic(9), pwm_get_state_hw(9), pwm_adjust_config(9), pwm_capture(9), pwm_request_from_chip(9), acpi_pwm_get(9), pwm_get(9), pwm_put(9), devm_pwm_get(9), devm_fwnode_pwm_get(9), __pwmchip_add(9), pwmchip_remove(9), pwm_add_table(9), pwm_remove_table(9)
That's a lot of PWMs. Go read them. Or don't. But like, you should π
Alright bestie, that's the whole page β from ./drivers/pwm, October 2026, in the Kernel API Manual. Go forth and request your PWMs responsibly πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms