[PATCH 0/3] Add PWM support for the Sophgo CV1800B

From: Hiago De Franco

Date: Tue Nov 17 2026 - 07:57:42 EST


This series adds support for the PWM controller of the Sophgo CV1800B,
the SoC used on the Milk-V Duo. The same block is also found on the
CV181x and SG200x, which share cv180x.dtsi.

The CV1800B has four PWM controller instances at 0x03060000, 0x03061000,
0x03062000 and 0x03063000, each with four channels, for 16 outputs in
total. The register layout is derived from the controller already
supported by drivers/pwm/pwm-sophgo-sg2042.c, so instead of adding a
separate driver the new SoC is handled by a new chip_data variant in that
driver, as suggested during the review of the previous submissions [1].

Compared to the SG2044, the CV1800B differs in these points:

- PERIOD and HLPERIOD are 30 bits wide and PERIOD must be strictly
greater than HLPERIOD. A 100% duty cycle is therefore not
representable, and the period must be at least two input clock cycles.
- POLARITY has the opposite meaning: with bit 0, HLPERIOD counts the low
part of the period and the pin idles low; with bit 1, HLPERIOD counts
the high part and the pin idles high.
- A POLARITY change takes effect immediately, even while the channel is
running, and does not need PWMUPDATE.
- HLPERIOD/PERIOD written while the channel is running are only latched
on a 0 -> 1 transition of PWMUPDATE. Toggling PWMSTART must not be used
for that, as it restarts the counter.
- When the counter is stopped the pin is parked at the level selected by
POLARITY; emitting the inactive level would require changing POLARITY, so
the driver switches the pin to input mode while the channel is disabled.

Patch 1 extends the DT binding, patch 2 adds the CV1800B variant to the
driver and updates the Kconfig help text, and patch 3 adds the
controller nodes to the shared cv180x.dtsi.

The hardware behaviour described above was verified on a Milk-V Duo with
a logic analyzer (GP4 routed to PWM, i.e. pwm1 channel 1), at 1 kHz/25%
and at 0.5 Hz: polarity mapping, PWMUPDATE latching with a running
channel, and the pin state of a disabled channel.

This follows the earlier CV1800B PWM submissions by Jingbao Qiu (v1-v7)
and Thomas Bonnefille (v8).

[1] https://lore.kernel.org/lkml/20250509-pwm_sophgo-v8-0-cfaebeb8ee17@xxxxxxxxxxx/

Signed-off-by: Hiago De Franco <hfranco@xxxxxxxxxxxx>
---
Hiago De Franco (3):
dt-bindings: pwm: sophgo: add PWM controller for CV1800B
pwm: sophgo-sg2042: add support for CV1800B
riscv: dts: sophgo: cv180x: add PWM controller nodes

.../devicetree/bindings/pwm/sophgo,sg2042-pwm.yaml | 3 +-
arch/riscv/boot/dts/sophgo/cv180x.dtsi | 40 ++++
drivers/pwm/Kconfig | 7 +-
drivers/pwm/pwm-sophgo-sg2042.c | 201 ++++++++++++++++++++-
4 files changed, 241 insertions(+), 10 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261104-milkv-duo-pwm-42fbc28b0693

Best regards,
--
Hiago