PWMBUS(9)
π PWMBUS(9) β like, the pwmbus methods, bestie π
okay so this is pwmbus(9), a section 9 kernel developer's manual page, and it's literally about the PWMBUS methods. if you're a kernel dev who wants their driver to do the pulse-width-modulation thing the generic way, this is your page. pull up a chair π«Ά
β¨ NAME β¨
pwmbus, PWMBUS_CHANNEL_CONFIG, PWMBUS_CHANNEL_COUNT, PWMBUS_CHANNEL_ENABLE, PWMBUS_CHANNEL_GET_CONFIG, PWMBUS_CHANNEL_GET_FLAGS, PWMBUS_CHANNEL_IS_ENABLED, PWMBUS_CHANNEL_SET_FLAGS, PWMBUS_GET_BUS β the PWMBUS methods, periodt π
πΈ SYNOPSIS πΈ
device pwm
#include <pwmbus_if.h>
int
PWMBUS_CHANNEL_CONFIG(device_t bus, u_int channel, u_int period,
u_int duty);
int
PWMBUS_CHANNEL_COUNT(device_t bus, u_int *nchannel);
int
PWMBUS_CHANNEL_ENABLE(device_t bus, u_int channel, bool enable);
int
PWMBUS_CHANNEL_GET_CONFIG(device_t bus, u_int channel, u_int *period,
u_int *duty);
int
PWMBUS_CHANNEL_GET_FLAGS(device_t bus, u_int channel, uint32_t *flags);
int
PWMBUS_CHANNEL_IS_ENABLED(device_t bus, u_int channel, bool *enabled);
int
PWMBUS_CHANNEL_SET_FLAGS(device_t bus, u_int channel, uint32_t flags);
π¦ DESCRIPTION π¦
okay so the big picture: the PWMBUS (that's Pulse-Width Modulation, iykyk) interface lets a device driver register onto a global bus, so that other devices in the kernel can then use them in a generic, uniform way. it's giving "everyone shares the aux" energy. β¨
now for the two arguments you'll see everywhere, so listen up bestie:
- the
periodargument = the duration, in nanoseconds, of one complete on-off cycle π - the
dutyargument = the duration, in nanoseconds, of the on portion of that cycle π‘
some PWM hardware is organized as a single controller with multiple channels, and channel numbers count up from zero (0οΈβ£, 1οΈβ£, 2οΈβ£β¦). when multiple channels are present, they sometimes share a common clock or other resources β and in those cases, changing the period or duty cycle of any one channel may affect other channels within the hardware that share the same resources. π so like, consult the documentation for the underlying PWM hardware device driver for the details on channels that share resources. no cap, read the docs.
π INTERFACE π
π§ PWMBUS_CHANNEL_CONFIG(device_t bus, u_int channel, u_int period, u_int duty)
configure the period and duty (both in nanoseconds) in the PWM controller on the bus, for the channel you specified.
returns 0 on success, or EINVAL if the values aren't supported by the controller, or EBUSY if the PWMBUS controller is in use and does not support changing the value on the fly. π
π PWMBUS_CHANNEL_COUNT(device_t bus, u_int *nchannel)
get the number of channels supported by the controller. that's it, that's the vibe. π’
π PWMBUS_CHANNEL_ENABLE(device_t bus, u_int channel, bool enable)
enable the PWM channel. turn it on, bestie. β‘
π PWMBUS_CHANNEL_GET_CONFIG(device_t bus, u_int channel, u_int *period, u_int *duty)
get the current configuration of the period and duty for the specified channel. a little peek at what's going on in there π
β PWMBUS_CHANNEL_GET_FLAGS(device_t bus, u_int channel, uint32_t *flags)
get the current flags for the channel. and here's the cute part: if the driver or controller doesn't support this, a default method returns a flags value of zero. so you always get something back π«Ά
π PWMBUS_CHANNEL_IS_ENABLED(device_t bus, u_int channel, bool *enable)
test whether the PWM channel is enabled. vibe check on the channel, basically β
π₯ PWMBUS_CHANNEL_SET_FLAGS(device_t bus, u_int channel, uint32_t flags)
set the flags of the channel (such as inverted polarity π). and if the driver or controller doesn't support this, a do-nothing default method is used β so nothing happens, and that's fine, no drama π
π§ HISTORY π§
the pwmbus interface first appear in FreeBSD 13.0 β¨ (yes, "appear" β we're keeping the original's exact wording, it's iconic). the pwmbus interface and this manual page were written by Emmanuel Vadot <manu@FreeBSD.org> π
ok that's the whole page bestie, you ate that π½οΈπ go forth and modulate those pulses π
this cutie came out of the Debian corner of the world, dated March 9, 2021, and it's the PWMBUS(9) page from the Kernel Developer's Manual β mwah, bye! π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2018 Emmanuel Vadot <manu@freebsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms