STRUCT PWM_CHIP(9)
π struct pwm_chip(9) β or, like, the whole vibe of a PWM controller in one struct π
okay so this is a page from the Kernel API Manual, bestie, and it's all about struct pwm_chip β the literal main character that abstracts a PWM controller. no cap, this is the blueprint. let's get into it π
β¨ NAME β¨
struct pwm_chip β abstract a PWM controller
likeβ¦ it is the PWM controller, conceptually. the abstracted truth of it. π
πΈ SYNOPSIS πΈ
struct pwm_chip {
struct device dev;
struct cdev cdev;
const struct pwm_ops *ops;
struct module *owner;
unsigned int id;
unsigned int npwm;
struct pwm_device * (*of_xlate)(struct pwm_chip *chip, const struct of_phandle_args *args);
bool atomic;
struct gpio_chip gpio;
bool uses_pwmchip_alloc;
bool operational;
union {
struct mutex nonatomic_lock;
spinlock_t atomic_lock;
};
struct pwm_device pwms[];
};
okay look at her. gorgeous. every field hand-picked. β¨
π¦ Members π¦
bestie, this is the field-by-field tour, and yes we're doing all of them, because every single one matters:
devβ the device providing the PWMs. the actual hardware parent, basically. πcdevβ thestruct cdevfor this device.opsβ the callbacks for this PWM controller. this is where the driver's behaviour lives, iykyk.ownerβ the module providing this chip. gotta know who's responsible. πidβ the unique number of this PWM chip. her little ID card. πnpwmβ number of PWMs controlled by this chip. the headcount. π₯of_xlateβ request a PWM device given a device tree PWM specifier. device-tree translation duty, very demure, very mindful.atomicβ can the driver's->applybe called in atomic context. big question, answer carefully. β‘gpioβstruct gpio_chipto operate this PWM chip's lines as GPO.uses_pwmchip_allocβ signals ifpwmchip_allowwas used to allocate this chip.operationalβ signals if the chip can be used (or is already deregistered). vibe check: passed or deregistered, no in-between. π{unnamed_union}β anonymous. yes, it's just vibes. no name. πnonatomic_lockβ mutex for nonatomic chips.atomic_lockβ mutex for atomic chips.
pwmsβ array of PWM devices allocated by the framework. the flexible array member, the icon, the finale. β
heads up:nonatomic_lockandatomic_locklive in the same anonymous union, so they're two flavours of the same slot β one for nonatomic chips, one for atomic chips. pick your fighter. π
π§ SEE ALSO π§
literally the whole friend group, go read these next (Kernel file ./include/linux/pwm.h):
enum pwm_polarity(9)struct pwm_args(9)struct pwm_waveform(9)struct pwm_device(9)pwm_get_state(9)pwm_init_state(9)pwm_get_relative_duty_cycle(9)pwm_set_relative_duty_cycle(9)struct pwm_capture(9)struct pwm_ops(9)pwmchip_supports_waveform(9)pwm_config(9)pwm_enable(9)pwm_disable(9)pwm_might_sleep(9)
and that's the whole page, bestie β no skips, no cuts, every field accounted for. π
okay so this was brought to you by ./include/linux, dated October 2026, filed lovingly under struct pwm_chip(9). periodt. π«Άπ
π¦ 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