PWM with power management fix - #25
Aksel Mellbye (asmellby) merged 2 commits into
Conversation
This patch ensure that clock_control_get_rate function returns the correct clock rate for the PWM peripheral. PWM is clocked from M4 processor clock. Upstream-status: pending Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
| * 32.768 kHz when the sleeptimer system timer is selected, which breaks | ||
| * pwm_set() nsec-to-cycles conversion. | ||
| */ | ||
| *rate = SystemCoreClock; |
There was a problem hiding this comment.
Use devicetree for this: DT_PROP(DT_NODELABEL(cpu0), clock_frequency)
There was a problem hiding this comment.
So we have a debate about that with Jérôme Pouiller (@jerome-pouiller), SystemCoreClock is actually the real Core clock value updated dynamically in Wiseconnect. But fair point, will use DT_PROP(DT_NODELABEL(cpu0), clock_frequency) for the moment to have consistency.
There was a problem hiding this comment.
I thought this was in the PWM driver when I first reviewed, in which case it would be a violation of responsibility between drivers (PWM should use clock control only). Since this is in the clock driver, it's more OK since the clock driver is responsible for clocks, and should therefore be allowed to use that global as part of its HAL usage.
There was a problem hiding this comment.
Ok then let's still use SystemCoreClock for the moment (since this is with what i've tested).
dda4e11 to
6b5ab88
Compare
This patch adds PM runtime management for the PWM peripheral. It allows to block CPU from entering the sleep state when PWM is active. Upstream-status: pending Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
6b5ab88 to
772f6db
Compare
|
v2: fix compliance check |
| data->pwm_channel_cfg[channel].is_chan_active = true; | ||
| } | ||
|
|
||
| if (pulse_cycles == 0 && data->pwm_channel_cfg[channel].is_chan_active == true) { |
There was a problem hiding this comment.
Minor: is_chan_active is an essentially boolean type (bool) so the explicit comparison with true is redundant.
There was a problem hiding this comment.
Agree, I've to admit that I've reapplied the existing pattern in the function but that's a fair point. Will do that in another PR if that's ok for you.
1650c70
into
SiliconLabsSoftware:silabs/dev
Without this fix, when PM is enabled, clock_control_get_rate() for the PWM peripheral returns 32,768 Hz, which is incorrect because the PWM runs at the CPU frequency.
Moreover, this change applies proper PM device runtime management to prevent the CPU from entering sleep mode while a PWM is active.