diff --git a/drivers/pwm/pwm_stm32.c b/drivers/pwm/pwm_stm32.c index b05208673ff..8275bd5685e 100644 --- a/drivers/pwm/pwm_stm32.c +++ b/drivers/pwm/pwm_stm32.c @@ -340,6 +340,13 @@ static int pwm_stm32_init(const struct device *dev) .enr = DT_CLOCKS_CELL(DT_PARENT(DT_DRV_INST(index)), bits) \ } +/* Print warning if any pwm node has 'st,prescaler' property */ +#define PRESCALER_PWM(index) DT_INST_NODE_HAS_PROP(index, st_prescaler) || +#if (DT_INST_FOREACH_STATUS_OKAY(PRESCALER_PWM) 0) +#warning "DT property 'st,prescaler' in pwm node is deprecated and should be \ +replaced by 'st,prescaler' property in parent node, aka timers" +#endif + #define PWM_DEVICE_INIT(index) \ static struct pwm_stm32_data pwm_stm32_data_##index; \ \ @@ -349,7 +356,11 @@ static int pwm_stm32_init(const struct device *dev) static const struct pwm_stm32_config pwm_stm32_config_##index = { \ .timer = (TIM_TypeDef *)DT_REG_ADDR( \ DT_PARENT(DT_DRV_INST(index))), \ - .prescaler = DT_INST_PROP(index, st_prescaler), \ + /* For compatibility reason, use pwm st_prescaler property */ \ + /* if exist, otherwise use parent (timers) property */ \ + .prescaler = DT_PROP_OR(DT_DRV_INST(index), st_prescaler, \ + (DT_PROP(DT_PARENT(DT_DRV_INST(index)), \ + st_prescaler))), \ .pclken = DT_INST_CLK(index, timer), \ .pinctrl = pwm_pins_##index, \ .pinctrl_len = ARRAY_SIZE(pwm_pins_##index), \