Skip to content

Commit 15a83fe

Browse files
GrixaYrevcarlescufi
authored andcommitted
drivers: pwm: pwm_mcux: Reload mode option
DTS property "nxp,reload" selects how to load the buffered-registers with new values. Signed-off-by: Grixa Yrev <[email protected]>
1 parent b4fb530 commit 15a83fe

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

drivers/pwm/pwm_mcux.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct pwm_mcux_config {
2525
const struct device *clock_dev;
2626
clock_control_subsys_t clock_subsys;
2727
pwm_clock_prescale_t prescale;
28+
pwm_register_reload_t reload;
2829
pwm_mode_t mode;
2930
bool run_wait;
3031
bool run_debug;
@@ -80,7 +81,7 @@ static int mcux_pwm_set_cycles(const struct device *dev, uint32_t channel,
8081

8182
data->period_cycles[channel] = period_cycles;
8283

83-
LOG_DBG("SETUP dutycycle to %u\n", duty_cycle);
84+
LOG_DBG("SETUP dutycycle to %u", duty_cycle);
8485

8586
if (clock_control_get_rate(config->clock_dev, config->clock_subsys,
8687
&clock_freq)) {
@@ -153,9 +154,12 @@ static int pwm_mcux_init(const struct device *dev)
153154
return err;
154155
}
155156

157+
LOG_DBG("Set prescaler %d, reload mode %d",
158+
1 << config->prescale, config->reload);
159+
156160
PWM_GetDefaultConfig(&pwm_config);
157161
pwm_config.prescale = config->prescale;
158-
pwm_config.reloadLogic = kPWM_ReloadPwmFullCycle;
162+
pwm_config.reloadLogic = config->reload;
159163
pwm_config.clockSource = kPWM_BusClock;
160164
pwm_config.enableDebugMode = config->run_debug;
161165
pwm_config.enableWait = config->run_wait;
@@ -193,6 +197,8 @@ static const struct pwm_driver_api pwm_mcux_driver_api = {
193197
.index = DT_INST_PROP(n, index), \
194198
.mode = kPWM_EdgeAligned, \
195199
.prescale = _CONCAT(kPWM_Prescale_Divide_, DT_INST_PROP(n, nxp_prescaler)),\
200+
.reload = DT_ENUM_IDX_OR(DT_DRV_INST(n), nxp_reload,\
201+
kPWM_ReloadPwmFullCycle),\
196202
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
197203
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
198204
.run_wait = DT_INST_PROP(n, run_in_wait), \

dts/bindings/pwm/nxp,imx-pwm.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ properties:
3333
description: |
3434
Clock prescaler at the input of the PWM.
3535
36+
nxp,reload:
37+
type: string
38+
enum:
39+
- "immediate"
40+
- "half-cycle"
41+
- "full-cycle"
42+
- "half-and-full-cycle"
43+
description: |
44+
Select how to load the buffered-registers with new values:
45+
"immediate" - buffered-registers get loaded with new values as soon as LDOK bit is set;
46+
"half-cycle" - registers loaded on a PWM half cycle;
47+
"full-cycle" - registers loaded on a PWM full cycle;
48+
"half-and-full-cycle" - registers loaded on a PWM half & full cycle.
49+
3650
"#pwm-cells":
3751
const: 2
3852

0 commit comments

Comments
 (0)