drivers/dac: stm32: use new pinctrl API
Use the new pinctrl API to configure pins. Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
8b0c2ca290
commit
956afc3a08
2 changed files with 6 additions and 21 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <drivers/dac.h>
|
#include <drivers/dac.h>
|
||||||
|
#include <drivers/pinctrl.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
|
@ -20,7 +21,6 @@
|
||||||
LOG_MODULE_REGISTER(dac_stm32);
|
LOG_MODULE_REGISTER(dac_stm32);
|
||||||
|
|
||||||
#include <drivers/clock_control/stm32_clock_control.h>
|
#include <drivers/clock_control/stm32_clock_control.h>
|
||||||
#include <pinmux/pinmux_stm32.h>
|
|
||||||
|
|
||||||
/* some low-end MCUs have DAC with only one channel */
|
/* some low-end MCUs have DAC with only one channel */
|
||||||
#ifdef LL_DAC_CHANNEL_2
|
#ifdef LL_DAC_CHANNEL_2
|
||||||
|
@ -47,9 +47,7 @@ struct dac_stm32_cfg {
|
||||||
/* Clock configuration. */
|
/* Clock configuration. */
|
||||||
struct stm32_pclken pclken;
|
struct stm32_pclken pclken;
|
||||||
/* pinctrl configurations. */
|
/* pinctrl configurations. */
|
||||||
const struct soc_gpio_pinctrl *pinctrl;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
/* Number of pinctrl configurations. */
|
|
||||||
size_t pinctrl_len;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Runtime driver data */
|
/* Runtime driver data */
|
||||||
|
@ -129,9 +127,7 @@ static int dac_stm32_init(const struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure dt provided device signals when available */
|
/* Configure dt provided device signals when available */
|
||||||
err = stm32_dt_pinctrl_configure(cfg->pinctrl,
|
err = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
cfg->pinctrl_len,
|
|
||||||
(uint32_t)cfg->base);
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
LOG_ERR("DAC pinctrl setup failed (%d)", err);
|
LOG_ERR("DAC pinctrl setup failed (%d)", err);
|
||||||
return err;
|
return err;
|
||||||
|
@ -148,8 +144,7 @@ static const struct dac_driver_api api_stm32_driver_api = {
|
||||||
|
|
||||||
#define STM32_DAC_INIT(index) \
|
#define STM32_DAC_INIT(index) \
|
||||||
\
|
\
|
||||||
static const struct soc_gpio_pinctrl dac_pins_##index[] = \
|
PINCTRL_DT_INST_DEFINE(index) \
|
||||||
ST_STM32_DT_INST_PINCTRL(index, 0); \
|
|
||||||
\
|
\
|
||||||
static const struct dac_stm32_cfg dac_stm32_cfg_##index = { \
|
static const struct dac_stm32_cfg dac_stm32_cfg_##index = { \
|
||||||
.base = (DAC_TypeDef *)DT_INST_REG_ADDR(index), \
|
.base = (DAC_TypeDef *)DT_INST_REG_ADDR(index), \
|
||||||
|
@ -157,8 +152,7 @@ static const struct dac_stm32_cfg dac_stm32_cfg_##index = { \
|
||||||
.enr = DT_INST_CLOCKS_CELL(index, bits), \
|
.enr = DT_INST_CLOCKS_CELL(index, bits), \
|
||||||
.bus = DT_INST_CLOCKS_CELL(index, bus), \
|
.bus = DT_INST_CLOCKS_CELL(index, bus), \
|
||||||
}, \
|
}, \
|
||||||
.pinctrl = dac_pins_##index, \
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
|
||||||
.pinctrl_len = ARRAY_SIZE(dac_pins_##index), \
|
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
static struct dac_stm32_data dac_stm32_data_##index = { \
|
static struct dac_stm32_data dac_stm32_data_##index = { \
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: ST STM32 family DAC
|
||||||
|
|
||||||
compatible: "st,stm32-dac"
|
compatible: "st,stm32-dac"
|
||||||
|
|
||||||
include: dac-controller.yaml
|
include: [dac-controller.yaml, pinctrl-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
reg:
|
||||||
|
@ -14,15 +14,6 @@ properties:
|
||||||
clocks:
|
clocks:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
pinctrl-0:
|
|
||||||
type: phandles
|
|
||||||
required: false
|
|
||||||
description: |
|
|
||||||
GPIO pin configuration for DAC output. The phandles are
|
|
||||||
expected to reference pinctrl nodes, e.g.
|
|
||||||
|
|
||||||
pinctrl-0 = <&dac_out1_pa4 &dac_out2_pa5>;
|
|
||||||
|
|
||||||
"#io-channel-cells":
|
"#io-channel-cells":
|
||||||
const: 1
|
const: 1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue