include/linux/pwm.h
Source file repositories/reference/linux-study-clean/include/linux/pwm.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/pwm.h- Extension
.h- Size
- 18520 bytes
- Lines
- 661
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cdev.hlinux/device.hlinux/err.hlinux/gpio/driver.hlinux/module.hlinux/mutex.hlinux/of.h
Detected Declarations
struct pwm_chipstruct pwm_argsstruct pwm_waveformstruct pwm_statestruct pwm_devicestruct pwm_capturestruct pwm_opsstruct pwm_chipstruct pwm_lookupenum pwm_polarityfunction pwm_get_statefunction pwm_is_enabledfunction pwm_get_periodfunction pwm_get_duty_cyclefunction pwm_get_polarityfunction pwm_get_argsfunction pwm_init_statefunction pwm_get_relative_duty_cyclefunction inconsistentfunction pwmchip_supports_waveformfunction pwmchip_set_drvdatafunction pwm_configfunction pwm_enablefunction pwm_disablefunction pwm_might_sleepfunction pwm_might_sleepfunction pwm_apply_might_sleepfunction pwm_apply_atomicfunction pwm_get_state_hwfunction pwm_adjust_configfunction pwm_configfunction pwm_enablefunction pwm_disablefunction pwmchip_putfunction pwmchip_addfunction pwmchip_removefunction devm_pwmchip_addfunction pwm_putfunction devm_fwnode_pwm_getfunction pwm_add_table
Annotated Snippet
struct pwm_args {
u64 period;
enum pwm_polarity polarity;
};
enum {
PWMF_REQUESTED = 0,
PWMF_EXPORTED = 1,
};
/**
* struct pwm_waveform - description of a PWM waveform
* @period_length_ns: PWM period
* @duty_length_ns: PWM duty cycle
* @duty_offset_ns: offset of the rising edge from the period's start
*
* This is a representation of a PWM waveform alternative to struct pwm_state
* below. It's more expressive than struct pwm_state as it contains a
* duty_offset_ns and so can represent offsets other than zero (with .polarity =
* PWM_POLARITY_NORMAL) and period - duty_cycle (.polarity =
* PWM_POLARITY_INVERSED).
*
* Note there is no explicit bool for enabled. A "disabled" PWM is represented
* by .period_length_ns = 0. Note further that the behaviour of a "disabled" PWM
* is undefined. Depending on the hardware's capabilities it might drive the
* active or inactive level, go high-z or even continue to toggle.
*
* The unit for all three members is nanoseconds.
*/
struct pwm_waveform {
u64 period_length_ns;
u64 duty_length_ns;
u64 duty_offset_ns;
};
/*
* struct pwm_state - state of a PWM channel
* @period: PWM period (in nanoseconds)
* @duty_cycle: PWM duty cycle (in nanoseconds)
* @polarity: PWM polarity
* @enabled: PWM enabled status
* @usage_power: If set, the PWM driver is only required to maintain the power
* output but has more freedom regarding signal form.
* If supported, the signal can be optimized, for example to
* improve EMI by phase shifting individual channels.
*/
struct pwm_state {
u64 period;
u64 duty_cycle;
enum pwm_polarity polarity;
bool enabled;
bool usage_power;
};
/**
* struct pwm_device - PWM channel object
* @label: name of the PWM device
* @flags: flags associated with the PWM device
* @hwpwm: per-chip relative index of the PWM device
* @chip: PWM chip providing this PWM device
* @args: PWM arguments
* @state: last applied state
* @last: last implemented state (for PWM_DEBUG)
*/
struct pwm_device {
const char *label;
unsigned long flags;
unsigned int hwpwm;
struct pwm_chip *chip;
struct pwm_args args;
struct pwm_state state;
struct pwm_state last;
};
/**
* pwm_get_state() - retrieve the current PWM state
* @pwm: PWM device
* @state: state to fill with the current PWM state
*
* The returned PWM state represents the state that was applied by a previous call to
* pwm_apply_might_sleep(). Drivers may have to slightly tweak that state before programming it to
* hardware. If pwm_apply_might_sleep() was never called, this returns either the current hardware
* state (if supported) or the default settings.
*/
static inline void pwm_get_state(const struct pwm_device *pwm,
struct pwm_state *state)
{
*state = pwm->state;
}
Annotation
- Immediate include surface: `linux/cdev.h`, `linux/device.h`, `linux/err.h`, `linux/gpio/driver.h`, `linux/module.h`, `linux/mutex.h`, `linux/of.h`.
- Detected declarations: `struct pwm_chip`, `struct pwm_args`, `struct pwm_waveform`, `struct pwm_state`, `struct pwm_device`, `struct pwm_capture`, `struct pwm_ops`, `struct pwm_chip`, `struct pwm_lookup`, `enum pwm_polarity`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.