From 328e0be13246252895170f83896ea720bee941a7 Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Fri, 25 Mar 2022 16:28:36 -0500 Subject: [PATCH] drivers: memc: memc_mcux_flexspi: make pinctrl support conditional Make pinctrl support conditional for memc flexspi driver Signed-off-by: Daniel DeGrasse --- drivers/memc/memc_mcux_flexspi.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/memc/memc_mcux_flexspi.c b/drivers/memc/memc_mcux_flexspi.c index d88a7d7c0f..29c6c66ffc 100644 --- a/drivers/memc/memc_mcux_flexspi.c +++ b/drivers/memc/memc_mcux_flexspi.c @@ -8,7 +8,9 @@ #include #include +#ifdef CONFIG_PINCTRL #include +#endif #include "memc_mcux_flexspi.h" @@ -38,7 +40,9 @@ struct memc_flexspi_data { bool combination_mode; bool sck_differential_clock; flexspi_read_sample_clock_t rx_sample_clock; +#ifdef CONFIG_PINCTRL const struct pinctrl_dev_config *pincfg; +#endif size_t size[kFLEXSPI_PortCount]; }; @@ -132,7 +136,6 @@ static int memc_flexspi_init(const struct device *dev) { struct memc_flexspi_data *data = dev->data; flexspi_config_t flexspi_config; - int ret; /* we should not configure the device we are running on */ if (memc_flexspi_is_running_xip(dev)) { @@ -141,10 +144,14 @@ static int memc_flexspi_init(const struct device *dev) } /* Apply pinctrl state */ +#ifdef CONFIG_PINCTRL + int ret; + ret = pinctrl_apply_state(data->pincfg, PINCTRL_STATE_DEFAULT); if (ret < 0) { return ret; } +#endif FLEXSPI_GetDefaultConfig(&flexspi_config); @@ -174,8 +181,16 @@ static int memc_flexspi_init(const struct device *dev) #define MEMC_FLEXSPI_CFG_XIP(node_id) false #endif +#ifdef CONFIG_PINCTRL +#define PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n); +#define PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), +#else +#define PINCTRL_DEFINE(n) +#define PINCTRL_INIT(n) +#endif + #define MEMC_FLEXSPI(n) \ - PINCTRL_DT_INST_DEFINE(n); \ + PINCTRL_DEFINE(n) \ static struct memc_flexspi_data \ memc_flexspi_data_##n = { \ .base = (FLEXSPI_Type *) DT_INST_REG_ADDR(n), \ @@ -188,7 +203,7 @@ static int memc_flexspi_init(const struct device *dev) .combination_mode = DT_INST_PROP(n, combination_mode), \ .sck_differential_clock = DT_INST_PROP(n, sck_differential_clock), \ .rx_sample_clock = DT_INST_PROP(n, rx_clock_source), \ - .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ + PINCTRL_INIT(n) \ }; \ \ DEVICE_DT_INST_DEFINE(n, \