subsys/disk: stm32 sdmmc: Add support for device tree pinctrl
Add required code to support pinctrl setup base don device tree. Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
f4a4583e13
commit
b9a4e9b3b7
1 changed files with 21 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <disk/disk_access.h>
|
||||
#include <drivers/clock_control.h>
|
||||
#include <drivers/clock_control/stm32_clock_control.h>
|
||||
#include <pinmux/stm32/pinmux_stm32.h>
|
||||
#include <drivers/gpio.h>
|
||||
#include <logging/log.h>
|
||||
#include <soc.h>
|
||||
|
@ -34,6 +35,10 @@ struct stm32_sdmmc_priv {
|
|||
int flags;
|
||||
} pe;
|
||||
struct stm32_pclken pclken;
|
||||
struct {
|
||||
const struct soc_gpio_pinctrl *list;
|
||||
size_t len;
|
||||
} pinctrl;
|
||||
};
|
||||
|
||||
static int stm32_sdmmc_clock_enable(struct stm32_sdmmc_priv *priv)
|
||||
|
@ -357,6 +362,14 @@ static int disk_stm32_sdmmc_init(const struct device *dev)
|
|||
|
||||
k_work_init(&priv->work, stm32_sdmmc_cd_handler);
|
||||
|
||||
/* Configure dt provided device signals when available */
|
||||
err = stm32_dt_pinctrl_configure(priv->pinctrl.list,
|
||||
priv->pinctrl.len,
|
||||
(uint32_t)priv->hsd.Instance);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = stm32_sdmmc_card_detect_init(priv);
|
||||
if (err) {
|
||||
return err;
|
||||
|
@ -388,6 +401,10 @@ err_card_detect:
|
|||
}
|
||||
|
||||
#if DT_NODE_HAS_STATUS(DT_DRV_INST(0), okay)
|
||||
|
||||
static const struct soc_gpio_pinctrl sdmmc_pins_1[] =
|
||||
ST_STM32_DT_INST_PINCTRL(0, 0);
|
||||
|
||||
static struct stm32_sdmmc_priv stm32_sdmmc_priv_1 = {
|
||||
.hsd = {
|
||||
.Instance = (SDMMC_TypeDef *)DT_INST_REG_ADDR(0),
|
||||
|
@ -410,6 +427,10 @@ static struct stm32_sdmmc_priv stm32_sdmmc_priv_1 = {
|
|||
.bus = DT_INST_CLOCKS_CELL(0, bus),
|
||||
.enr = DT_INST_CLOCKS_CELL(0, bits),
|
||||
},
|
||||
.pinctrl = {
|
||||
.list = sdmmc_pins_1,
|
||||
.len = ARRAY_SIZE(sdmmc_pins_1)
|
||||
}
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(stm32_sdmmc_dev1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue