---
name: "pwmbus"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/pwm/9"
---

# pwmbus(9)

PWMBUS methods

Part of [pwm(9)](/pwm/9.md).

## 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** – PWMBUS methods

## 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

The PWMBUS (Pulse-Width Modulation) interface allows a device driver to register to a global bus so other devices in the kernel can use them in a generic way.

For all **pwmbus** methods, the *period* argument is the duration in nanoseconds of one complete on-off cycle, and the *duty* argument is the duration in nanoseconds of the on portion of that cycle.

Some PWM hardware is organized as a single controller with multiple channels. Channel numbers count up from zero. When multiple channels are present, they sometimes share a common clock or other resources. In such cases, changing the period or duty cycle of any one channel may affect other channels within the hardware which share the same resources. Consult the documentation for the underlying PWM hardware device driver for details on channels that share resources.

## INTERFACE

- **PWMBUS\_CHANNEL\_CONFIG**(*device\_t bus*, *u\_int channel*, *u\_int period*, *u\_int duty*)

  Configure the period and duty (in nanoseconds) in the PWM controller on the bus for the specified channel. Returns 0 on success or EINVAL if the values are not 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.

- **PWMBUS\_CHANNEL\_ENABLE**(*device\_t bus*, *u\_int channel*, *bool enable*)

  Enable the PWM channel.

- **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.

- **PWMBUS\_CHANNEL\_GET\_FLAGS**(*device\_t bus*, *u\_int channel*, *uint32\_t \*flags*)

  Get the current flags for the channel. If the driver or controller does not support this, a default method returns a flags value of zero.

- **PWMBUS\_CHANNEL\_IS\_ENABLED**(*device\_t bus*, *u\_int channel*, *bool \*enable*)

  Test whether the PWM channel is enabled.

- **PWMBUS\_CHANNEL\_SET\_FLAGS**(*device\_t bus*, *u\_int channel*, *uint32\_t flags*)

  Set the flags of the channel (such as inverted polarity). If the driver or controller does not support this a do-nothing default method is used.

## HISTORY

The **pwmbus** interface first appear in FreeBSD 13.0. The **pwmbus** interface and manual page was written by Emmanuel Vadot ⟨*manu@FreeBSD.org*⟩.
