[PATCH v3 0/3] Add RP1 PWM controller support

Andrea della Porta posted 3 patches 1 month, 3 weeks ago
There is a newer version of this series
.../bindings/pwm/raspberrypi,rp1-pwm.yaml     |  54 +++
.../boot/dts/broadcom/bcm2712-rpi-5-b.dts     |  12 +
arch/arm64/boot/dts/broadcom/rp1-common.dtsi  |  10 +
drivers/pwm/Kconfig                           |   9 +
drivers/pwm/Makefile                          |   1 +
drivers/pwm/pwm-rp1.c                         | 414 ++++++++++++++++++
6 files changed, 500 insertions(+)
create mode 100644 Documentation/devicetree/bindings/pwm/raspberrypi,rp1-pwm.yaml
create mode 100644 drivers/pwm/pwm-rp1.c
[PATCH v3 0/3] Add RP1 PWM controller support
Posted by Andrea della Porta 1 month, 3 weeks ago
This patchset adds support for the PWM controller found on the
Raspberry Pi RP1 southbridge. This is necessary to operate the
cooling fan connected to one of the PWM channels.

The tachometer pin for the fan speed is managed by the firmware 
running on the RP1's M-core. It uses the PHASE2 register
to report the RPM, which is then exported by this driver via
syscon registers. A subsequent patch will add a new device
and driver to read the RPM and export this value via hwmon.
 
Subsequent patches will also add the CPU thermal zone, which
acts as a consumer of the PWM device.

Best regards,
Andrea

CHANGES in V3:

- Refactored all the register macros. They now have RP1_PWM_ prefix
  and follow the register name.
- Dropped the tab alignment in front of struct declarations (use a space
  instead).
- Added a check in tohw() to test (and bail out quickly) in case that
  period_length_ns is zero.
- Probing now returns an error if clk_rate > 1 GHz.
- Added a check on minimum period ticks. Return 1 to signal round-up.
- Fixed inverted polarity detection on edge cases.
- Fixed rounding errors (in both tohwi() and fromhw()) in inverted
  polarity calculations.
- Dropped a redundant check on period >= duty.
- Replaced memset by inline struct init.
- Disabling a channel now is faster, skipping the duty/period/polarity
  setup.
- Fixed an error string (s/Fail/Failed)
- Used %pe to signal error string instead of an integer.
- Added several new sections to the Limitations paragraph to better
  explain what will happen on edge cases.
- Maximum period is now U32_MAX-1 to allow 100% duty cycle on all
  selectable periods.
- The hw period register now takes into account for the extra tick at
  the end of the period (subtracted one to wfhw->period_ticks in tohw
  and added 1 in fromhw).
- Added .remove() callback to free resources even if the driver is
  not unbindable/unloadable, to avoid accumulating tech debt.


Naushir Patuck (2):
  dt-bindings: pwm: Add Raspberry Pi RP1 PWM controller
  pwm: rp1: Add RP1 PWM controller driver

Stanimir Varbanov (1):
  arm64: dts: broadcom: rpi-5: Add RP1 PWM node

 .../bindings/pwm/raspberrypi,rp1-pwm.yaml     |  54 +++
 .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     |  12 +
 arch/arm64/boot/dts/broadcom/rp1-common.dtsi  |  10 +
 drivers/pwm/Kconfig                           |   9 +
 drivers/pwm/Makefile                          |   1 +
 drivers/pwm/pwm-rp1.c                         | 414 ++++++++++++++++++
 6 files changed, 500 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/raspberrypi,rp1-pwm.yaml
 create mode 100644 drivers/pwm/pwm-rp1.c

-- 
2.35.3
Re: [PATCH v3 0/3] Add RP1 PWM controller support
Posted by Andrea della Porta 1 month, 1 week ago
Hi Uwe,

On 10:30 Thu 23 Apr     , Andrea della Porta wrote:
> This patchset adds support for the PWM controller found on the
> Raspberry Pi RP1 southbridge. This is necessary to operate the
> cooling fan connected to one of the PWM channels.
> 
> The tachometer pin for the fan speed is managed by the firmware 
> running on the RP1's M-core. It uses the PHASE2 register
> to report the RPM, which is then exported by this driver via
> syscon registers. A subsequent patch will add a new device
> and driver to read the RPM and export this value via hwmon.
>  
> Subsequent patches will also add the CPU thermal zone, which
> acts as a consumer of the PWM device.
> 
> Best regards,
> Andrea
> 
> CHANGES in V3:
> 
> - Refactored all the register macros. They now have RP1_PWM_ prefix
>   and follow the register name.
> - Dropped the tab alignment in front of struct declarations (use a space
>   instead).
> - Added a check in tohw() to test (and bail out quickly) in case that
>   period_length_ns is zero.
> - Probing now returns an error if clk_rate > 1 GHz.
> - Added a check on minimum period ticks. Return 1 to signal round-up.
> - Fixed inverted polarity detection on edge cases.
> - Fixed rounding errors (in both tohwi() and fromhw()) in inverted
>   polarity calculations.
> - Dropped a redundant check on period >= duty.
> - Replaced memset by inline struct init.
> - Disabling a channel now is faster, skipping the duty/period/polarity
>   setup.
> - Fixed an error string (s/Fail/Failed)
> - Used %pe to signal error string instead of an integer.
> - Added several new sections to the Limitations paragraph to better
>   explain what will happen on edge cases.
> - Maximum period is now U32_MAX-1 to allow 100% duty cycle on all
>   selectable periods.
> - The hw period register now takes into account for the extra tick at
>   the end of the period (subtracted one to wfhw->period_ticks in tohw
>   and added 1 in fromhw).
> - Added .remove() callback to free resources even if the driver is
>   not unbindable/unloadable, to avoid accumulating tech debt.
> 
> 
> Naushir Patuck (2):
>   dt-bindings: pwm: Add Raspberry Pi RP1 PWM controller
>   pwm: rp1: Add RP1 PWM controller driver
> 
> Stanimir Varbanov (1):
>   arm64: dts: broadcom: rpi-5: Add RP1 PWM node
> 
>  .../bindings/pwm/raspberrypi,rp1-pwm.yaml     |  54 +++
>  .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     |  12 +
>  arch/arm64/boot/dts/broadcom/rp1-common.dtsi  |  10 +
>  drivers/pwm/Kconfig                           |   9 +
>  drivers/pwm/Makefile                          |   1 +
>  drivers/pwm/pwm-rp1.c                         | 414 ++++++++++++++++++
>  6 files changed, 500 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/pwm/raspberrypi,rp1-pwm.yaml
>  create mode 100644 drivers/pwm/pwm-rp1.c
> 
> -- 
> 2.35.3
>

A gentle reminder about this patchset :)

Many thanks,
Andrea
Re: [PATCH v3 0/3] Add RP1 PWM controller support
Posted by Florian Fainelli 3 weeks, 6 days ago
On 5/8/26 01:15, Andrea della Porta wrote:
> Hi Uwe,
> 
> On 10:30 Thu 23 Apr     , Andrea della Porta wrote:
>> This patchset adds support for the PWM controller found on the
>> Raspberry Pi RP1 southbridge. This is necessary to operate the
>> cooling fan connected to one of the PWM channels.
>>
>> The tachometer pin for the fan speed is managed by the firmware
>> running on the RP1's M-core. It uses the PHASE2 register
>> to report the RPM, which is then exported by this driver via
>> syscon registers. A subsequent patch will add a new device
>> and driver to read the RPM and export this value via hwmon.
>>   
>> Subsequent patches will also add the CPU thermal zone, which
>> acts as a consumer of the PWM device.
>>
>> Best regards,
>> Andrea
>>
>> CHANGES in V3:
>>
>> - Refactored all the register macros. They now have RP1_PWM_ prefix
>>    and follow the register name.
>> - Dropped the tab alignment in front of struct declarations (use a space
>>    instead).
>> - Added a check in tohw() to test (and bail out quickly) in case that
>>    period_length_ns is zero.
>> - Probing now returns an error if clk_rate > 1 GHz.
>> - Added a check on minimum period ticks. Return 1 to signal round-up.
>> - Fixed inverted polarity detection on edge cases.
>> - Fixed rounding errors (in both tohwi() and fromhw()) in inverted
>>    polarity calculations.
>> - Dropped a redundant check on period >= duty.
>> - Replaced memset by inline struct init.
>> - Disabling a channel now is faster, skipping the duty/period/polarity
>>    setup.
>> - Fixed an error string (s/Fail/Failed)
>> - Used %pe to signal error string instead of an integer.
>> - Added several new sections to the Limitations paragraph to better
>>    explain what will happen on edge cases.
>> - Maximum period is now U32_MAX-1 to allow 100% duty cycle on all
>>    selectable periods.
>> - The hw period register now takes into account for the extra tick at
>>    the end of the period (subtracted one to wfhw->period_ticks in tohw
>>    and added 1 in fromhw).
>> - Added .remove() callback to free resources even if the driver is
>>    not unbindable/unloadable, to avoid accumulating tech debt.
>>
>>
>> Naushir Patuck (2):
>>    dt-bindings: pwm: Add Raspberry Pi RP1 PWM controller
>>    pwm: rp1: Add RP1 PWM controller driver
>>
>> Stanimir Varbanov (1):
>>    arm64: dts: broadcom: rpi-5: Add RP1 PWM node
>>
>>   .../bindings/pwm/raspberrypi,rp1-pwm.yaml     |  54 +++
>>   .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     |  12 +
>>   arch/arm64/boot/dts/broadcom/rp1-common.dtsi  |  10 +
>>   drivers/pwm/Kconfig                           |   9 +
>>   drivers/pwm/Makefile                          |   1 +
>>   drivers/pwm/pwm-rp1.c                         | 414 ++++++++++++++++++
>>   6 files changed, 500 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/pwm/raspberrypi,rp1-pwm.yaml
>>   create mode 100644 drivers/pwm/pwm-rp1.c
>>
>> -- 
>> 2.35.3
>>
> 
> A gentle reminder about this patchset :)

Hi Uwe,

I would prefer to take the DTS changes through the Broadcom ARM SoC tree 
to minimize conflicts on my end, are you going to take the PWM patches 
for 7.2? Thanks!
-- 
Florian
Re: [PATCH v3 0/3] Add RP1 PWM controller support
Posted by Uwe Kleine-König 2 weeks, 6 days ago
Hello,

On Wed, May 20, 2026 at 04:31:42PM -0700, Florian Fainelli wrote:
> I would prefer to take the DTS changes through the Broadcom ARM SoC tree to
> minimize conflicts on my end, are you going to take the PWM patches for 7.2?

I didn't find the time yet to look in detail, but skimming
https://sashiko.dev/#/patchset/cover.1776932336.git.andrea.porta%40suse.com
suggests that there is still something to do for Andrea.

Best regards
Uwe
Re: [PATCH v3 0/3] Add RP1 PWM controller support
Posted by Andrea della Porta 2 weeks, 5 days ago
Hi,

On 09:55 Wed 27 May     , Uwe Kleine-König wrote:
> Hello,
> 
> On Wed, May 20, 2026 at 04:31:42PM -0700, Florian Fainelli wrote:
> > I would prefer to take the DTS changes through the Broadcom ARM SoC tree to
> > minimize conflicts on my end, are you going to take the PWM patches for 7.2?
> 
> I didn't find the time yet to look in detail, but skimming
> https://sashiko.dev/#/patchset/cover.1776932336.git.andrea.porta%40suse.com
> suggests that there is still something to do for Andrea.

Right, so I guess a V4 is on the way soon...
specifically, about teh DTS, I will rename rp1_pwm to rp1_pwm1 to differentiate
it from pwm0.

Thanks,
Andrea

> 
> Best regards
> Uwe