Skip to content

Commit a7135a6

Browse files
blemouzycarlescufi
authored andcommitted
drivers: watchdog: wdt_mcux_imx_wdog: add pinctrl support
i.MX RT SoC have some pins related to the watchdog. For example, iomuxc_gpio_ad_b0_15_wdog1_rst_b_deb allows WDOG1_RST_B_DEB signal to be used as reset source for i.MX RT10xx boards. Signed-off-by: Benjamin Lemouzy <[email protected]>
1 parent 9f0f9b8 commit a7135a6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

drivers/watchdog/Kconfig.mcux_imx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ config WDT_MCUX_IMX_WDOG
77
bool "MCUX IMX WDOG driver"
88
default y
99
depends on DT_HAS_NXP_IMX_WDOG_ENABLED
10+
select PINCTRL
1011
help
1112
Enable the mcux imx wdog driver.

drivers/watchdog/wdt_mcux_imx_wdog.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#define DT_DRV_COMPAT nxp_imx_wdog
88

9+
#include <zephyr/drivers/pinctrl.h>
910
#include <zephyr/drivers/watchdog.h>
1011
#include <zephyr/sys_clock.h>
1112
#include <fsl_wdog.h>
@@ -20,6 +21,7 @@ LOG_MODULE_REGISTER(wdt_mcux_wdog);
2021
struct mcux_wdog_config {
2122
WDOG_Type *base;
2223
void (*irq_config_func)(const struct device *dev);
24+
const struct pinctrl_dev_config *pcfg;
2325
};
2426

2527
struct mcux_wdog_data {
@@ -135,9 +137,15 @@ static void mcux_wdog_isr(const struct device *dev)
135137
static int mcux_wdog_init(const struct device *dev)
136138
{
137139
const struct mcux_wdog_config *config = dev->config;
140+
int ret;
138141

139142
config->irq_config_func(dev);
140143

144+
ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
145+
if (ret < 0 && ret != -ENOENT) {
146+
return ret;
147+
}
148+
141149
return 0;
142150
}
143151

@@ -150,9 +158,12 @@ static const struct wdt_driver_api mcux_wdog_api = {
150158

151159
static void mcux_wdog_config_func(const struct device *dev);
152160

161+
PINCTRL_DT_INST_DEFINE(0);
162+
153163
static const struct mcux_wdog_config mcux_wdog_config = {
154164
.base = (WDOG_Type *) DT_INST_REG_ADDR(0),
155165
.irq_config_func = mcux_wdog_config_func,
166+
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
156167
};
157168

158169
static struct mcux_wdog_data mcux_wdog_data;

dts/bindings/watchdog/nxp,imx-wdog.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: imxRT watchdog
55

66
compatible: "nxp,imx-wdog"
77

8-
include: base.yaml
8+
include: [base.yaml, pinctrl-device.yaml]
99

1010
properties:
1111
reg:

0 commit comments

Comments
 (0)