soc/arm: stm32: use _INST_ namespace in devicetree pinctrl helpers
Current set of helpers provided for STM32 pinctrl devicetree are using device instance as input. In order to prepare for next version that will take node identifier as input, change existing set of macros using _INST_ namespace. Additionally rename NODE_ID_FROM_PINCTRL to ST_STM32_DT_INST_NODE_ID_FROM_PINCTRL. Finally update existing macros users to this new name scheme. Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
4b3a6a0e91
commit
2d3cda7663
3 changed files with 44 additions and 41 deletions
|
@ -461,7 +461,7 @@ static int pwm_stm32_init(const struct device *dev)
|
|||
static struct pwm_stm32_data pwm_stm32_data_##index; \
|
||||
\
|
||||
static const struct soc_gpio_pinctrl pwm_pins_##index[] = \
|
||||
ST_STM32_DT_PINCTRL(0, index); \
|
||||
ST_STM32_DT_INST_PINCTRL(0, index); \
|
||||
\
|
||||
static const struct pwm_stm32_config pwm_stm32_config_##index = { \
|
||||
.timer = (TIM_TypeDef *)DT_REG_ADDR( \
|
||||
|
|
|
@ -815,7 +815,7 @@ static void uart_stm32_irq_config_func_##index(const struct device *dev) \
|
|||
STM32_UART_IRQ_HANDLER_DECL(index); \
|
||||
\
|
||||
static const struct soc_gpio_pinctrl uart_pins_##index[] = \
|
||||
ST_STM32_DT_PINCTRL(0, index); \
|
||||
ST_STM32_DT_INST_PINCTRL(0, index); \
|
||||
\
|
||||
static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
||||
.uconf = { \
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* @param i index of soc_gpio_pinctrl element
|
||||
* @return elements's node identifier
|
||||
*/
|
||||
#define NODE_ID_FROM_PINCTRL(inst, x, i) \
|
||||
#define ST_STM32_DT_INST_NODE_ID_FROM_PINCTRL(inst, x, i) \
|
||||
DT_INST_PHANDLE_BY_IDX(inst, pinctrl_##x, i)
|
||||
|
||||
/**
|
||||
|
@ -43,8 +43,8 @@
|
|||
* @param i index of soc_gpio_pinctrl element
|
||||
* @return pinmux property value
|
||||
*/
|
||||
#define ST_STM32_PINMUX(inst, x, i) \
|
||||
DT_PROP(NODE_ID_FROM_PINCTRL(inst, x, i), pinmux)
|
||||
#define ST_STM32_DT_INST_PINMUX(inst, x, i) \
|
||||
DT_PROP(ST_STM32_DT_INST_NODE_ID_FROM_PINCTRL(inst, x, i), pinmux)
|
||||
|
||||
/**
|
||||
* @brief Internal: Get <function> property of a node indentifier for an element
|
||||
|
@ -56,8 +56,8 @@
|
|||
* @param function property of a targeted element
|
||||
* @return <function> property value
|
||||
*/
|
||||
#define ST_STM32_FUNC(inst, x, i, function) \
|
||||
DT_PROP(NODE_ID_FROM_PINCTRL(inst, x, i), function)
|
||||
#define ST_STM32_DT_INST_FUNC(inst, x, i, function) \
|
||||
DT_PROP(ST_STM32_DT_INST_NODE_ID_FROM_PINCTRL(inst, x, i), function)
|
||||
|
||||
/**
|
||||
* @brief Internal: Provide slew-rate value for a pin with index i of a
|
||||
|
@ -68,8 +68,9 @@
|
|||
* @param i index of soc_gpio_pinctrl element
|
||||
* @return slew rate value
|
||||
*/
|
||||
#define ST_STM32_SLEW_RATE(inst, x, i) \
|
||||
DT_ENUM_IDX(NODE_ID_FROM_PINCTRL(inst, x, i), slew_rate)
|
||||
#define ST_STM32_DT_INST_SLEW_RATE(inst, x, i) \
|
||||
DT_ENUM_IDX(ST_STM32_DT_INST_NODE_ID_FROM_PINCTRL(inst, x, i), \
|
||||
slew_rate)
|
||||
|
||||
/**
|
||||
* @brief Internal: Contruct a pincfg field of a soc_gpio_pinctrl element
|
||||
|
@ -81,31 +82,33 @@
|
|||
* @return pincfg field
|
||||
*/
|
||||
#ifndef CONFIG_SOC_SERIES_STM32F1X
|
||||
#define ST_STM32_PINCFG(inst, x, i) \
|
||||
(((STM32_NO_PULL * ST_STM32_FUNC(inst, x, i, bias_disable)) \
|
||||
<< STM32_PUPDR_SHIFT) | \
|
||||
((STM32_PULL_UP * ST_STM32_FUNC(inst, x, i, bias_pull_up)) \
|
||||
<< STM32_PUPDR_SHIFT) | \
|
||||
((STM32_PULL_DOWN * ST_STM32_FUNC(inst, x, i, bias_pull_down)) \
|
||||
<< STM32_PUPDR_SHIFT) | \
|
||||
((STM32_PUSH_PULL * ST_STM32_FUNC(inst, x, i, drive_push_pull)) \
|
||||
<< STM32_OTYPER_SHIFT) | \
|
||||
((STM32_OPEN_DRAIN * ST_STM32_FUNC(inst, x, i, drive_open_drain))\
|
||||
<< STM32_OTYPER_SHIFT) | \
|
||||
(ST_STM32_SLEW_RATE(inst, x, i) << STM32_OSPEEDR_SHIFT))
|
||||
#define ST_STM32_DT_INST_PINCFG(inst, x, i) \
|
||||
(((STM32_NO_PULL * ST_STM32_DT_INST_FUNC(inst, x, i, bias_disable)) \
|
||||
<< STM32_PUPDR_SHIFT) | \
|
||||
((STM32_PULL_UP * ST_STM32_DT_INST_FUNC(inst, x, i, bias_pull_up)) \
|
||||
<< STM32_PUPDR_SHIFT) | \
|
||||
((STM32_PULL_DOWN * ST_STM32_DT_INST_FUNC(inst, x, i, bias_pull_down)) \
|
||||
<< STM32_PUPDR_SHIFT) | \
|
||||
((STM32_PUSH_PULL * ST_STM32_DT_INST_FUNC(inst, x, i, drive_push_pull))\
|
||||
<< STM32_OTYPER_SHIFT) | \
|
||||
((STM32_OPEN_DRAIN * ST_STM32_DT_INST_FUNC(inst, x, i, \
|
||||
drive_open_drain)) \
|
||||
<< STM32_OTYPER_SHIFT) | \
|
||||
(ST_STM32_DT_INST_SLEW_RATE(inst, x, i) << STM32_OSPEEDR_SHIFT))
|
||||
#else
|
||||
#define ST_STM32_PINCFG(inst, x, i) \
|
||||
(((STM32_NO_PULL * ST_STM32_FUNC(inst, x, i, bias_disable)) \
|
||||
<< STM32_PUPD_SHIFT) | \
|
||||
((STM32_PULL_UP * ST_STM32_FUNC(inst, x, i, bias_pull_up)) \
|
||||
<< STM32_PUPD_SHIFT) | \
|
||||
((STM32_PULL_DOWN * ST_STM32_FUNC(inst, x, i, bias_pull_down)) \
|
||||
<< STM32_PUPD_SHIFT) | \
|
||||
((STM32_PUSH_PULL * ST_STM32_FUNC(inst, x, i, drive_push_pull)) \
|
||||
<< STM32_CNF_OUT_0_SHIFT) | \
|
||||
((STM32_OPEN_DRAIN * ST_STM32_FUNC(inst, x, i, drive_open_drain)) \
|
||||
<< STM32_CNF_OUT_0_SHIFT) | \
|
||||
(ST_STM32_SLEW_RATE(inst, x, i) << STM32_MODE_OSPEED_SHIFT))
|
||||
#define ST_STM32_DT_INST_PINCFG(inst, x, i) \
|
||||
(((STM32_NO_PULL * ST_STM32_DT_INST_FUNC(inst, x, i, bias_disable)) \
|
||||
<< STM32_PUPD_SHIFT) | \
|
||||
((STM32_PULL_UP * ST_STM32_DT_INST_FUNC(inst, x, i, bias_pull_up)) \
|
||||
<< STM32_PUPD_SHIFT) | \
|
||||
((STM32_PULL_DOWN * ST_STM32_DT_INST_FUNC(inst, x, i, bias_pull_down)) \
|
||||
<< STM32_PUPD_SHIFT) | \
|
||||
((STM32_PUSH_PULL * ST_STM32_DT_INST_FUNC(inst, x, i, drive_push_pull))\
|
||||
<< STM32_CNF_OUT_0_SHIFT) | \
|
||||
((STM32_OPEN_DRAIN * ST_STM32_DT_INST_FUNC(inst, x, i, \
|
||||
drive_open_drain)) \
|
||||
<< STM32_CNF_OUT_0_SHIFT) | \
|
||||
(ST_STM32_DT_INST_SLEW_RATE(inst, x, i) << STM32_MODE_OSPEED_SHIFT))
|
||||
#endif /* CONFIG_SOC_SERIES_STM32F1X */
|
||||
|
||||
/**
|
||||
|
@ -117,10 +120,10 @@
|
|||
* @param inst device instance number
|
||||
* @return soc_gpio_pinctrl element
|
||||
*/
|
||||
#define ST_STM32_DT_PIN_ELEM(i, x, inst) \
|
||||
#define ST_STM32_DT_INST_PIN_ELEM(i, x, inst) \
|
||||
{ \
|
||||
ST_STM32_PINMUX(inst, x, i), \
|
||||
ST_STM32_PINCFG(inst, x, i) \
|
||||
ST_STM32_DT_INST_PINMUX(inst, x, i), \
|
||||
ST_STM32_DT_INST_PINCFG(inst, x, i) \
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -134,7 +137,7 @@
|
|||
* @param x index of targeted pinctrl- property (eg: pinctrl-<x>)
|
||||
* @return number of element in property
|
||||
*/
|
||||
#define ST_STM32_DT_NUM_PINS(inst, x) DT_INST_PROP_LEN(inst, pinctrl_##x)
|
||||
#define ST_STM32_DT_INST_NUM_PINS(inst, x) DT_INST_PROP_LEN(inst, pinctrl_##x)
|
||||
|
||||
|
||||
/**
|
||||
|
@ -148,10 +151,10 @@
|
|||
* @param inst device instance number
|
||||
* @return array of soc_gpio_pinctrl
|
||||
*/
|
||||
#define ST_STM32_DT_PINCTRL(x, inst) \
|
||||
{ COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, pinctrl_##x), \
|
||||
(UTIL_LISTIFY(ST_STM32_DT_NUM_PINS(inst, x), \
|
||||
ST_STM32_DT_PIN_ELEM, \
|
||||
#define ST_STM32_DT_INST_PINCTRL(x, inst) \
|
||||
{ COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, pinctrl_##x), \
|
||||
(UTIL_LISTIFY(ST_STM32_DT_INST_NUM_PINS(inst, x), \
|
||||
ST_STM32_DT_INST_PIN_ELEM, \
|
||||
x, \
|
||||
inst)), \
|
||||
()) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue