drivers/memc: 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:
Erwan Gouriou 2021-11-08 11:34:00 +01:00 committed by Carles Cufí
parent ab306b34db
commit ab893d5fef
2 changed files with 6 additions and 18 deletions

View file

@ -9,7 +9,7 @@
#include <device.h>
#include <drivers/clock_control/stm32_clock_control.h>
#include <pinmux/pinmux_stm32.h>
#include <drivers/pinctrl.h>
#include <logging/log.h>
LOG_MODULE_REGISTER(memc_stm32, CONFIG_MEMC_LOG_LEVEL);
@ -17,8 +17,7 @@ LOG_MODULE_REGISTER(memc_stm32, CONFIG_MEMC_LOG_LEVEL);
struct memc_stm32_config {
uint32_t fmc;
struct stm32_pclken pclken;
const struct soc_gpio_pinctrl *pinctrl;
size_t pinctrl_len;
const struct pinctrl_dev_config *pcfg;
};
static int memc_stm32_init(const struct device *dev)
@ -29,8 +28,7 @@ static int memc_stm32_init(const struct device *dev)
const struct device *clk;
/* configure pinmux */
r = stm32_dt_pinctrl_configure(config->pinctrl, config->pinctrl_len,
config->fmc);
r = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
if (r < 0) {
LOG_ERR("FMC pinctrl setup failed (%d)", r);
return r;
@ -48,14 +46,13 @@ static int memc_stm32_init(const struct device *dev)
return 0;
}
static const struct soc_gpio_pinctrl pinctrl[] = ST_STM32_DT_INST_PINCTRL(0, 0);
PINCTRL_DT_INST_DEFINE(0)
static const struct memc_stm32_config config = {
.fmc = DT_INST_REG_ADDR(0),
.pclken = { .bus = DT_INST_CLOCKS_CELL(0, bus),
.enr = DT_INST_CLOCKS_CELL(0, bits) },
.pinctrl = pinctrl,
.pinctrl_len = ARRAY_SIZE(pinctrl),
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
};
DEVICE_DT_INST_DEFINE(0, memc_stm32_init, NULL, NULL,

View file

@ -29,7 +29,7 @@ description: |
compatible: "st,stm32-fmc"
include: base.yaml
include: [base.yaml, pinctrl-device.yaml]
properties:
reg:
@ -40,12 +40,3 @@ properties:
clocks:
required: true
pinctrl-0:
type: phandles
required: false
description: |
GPIO pin configuration for FMC signals. We expect that the phandles
will reference pinctrl nodes, e.g.
pinctrl-0 = <&fmc_a0_pf0 &fmc_a1_pf1...>;