drivers: pwm: stm32: move "st,prescaler" to timers instead of pwm
Prescaler was misplaced in pwm binding, instead of timers binding. For example, TIM6/TIM7 doesn't have PWM capability, but have a prescaler. This change also prepares the introduction of timer based counter (which requires prescaler at timer level) For compatibility reason temporarily use pwm prescaler if it exists, otehrwise use timers prescaler. And thus avoid to avoid breaking boards out of tree. Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
This commit is contained in:
parent
7f3423ae48
commit
3a60344522
1 changed files with 12 additions and 1 deletions
|
@ -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), \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue