diff --git a/drivers/i2c/i2c_dw.c b/drivers/i2c/i2c_dw.c index 74cf471783b..bb5ecc3779f 100644 --- a/drivers/i2c/i2c_dw.c +++ b/drivers/i2c/i2c_dw.c @@ -21,6 +21,9 @@ #if defined(CONFIG_PINCTRL) #include #endif +#if defined(CONFIG_RESET) +#include +#endif #include #include @@ -847,6 +850,15 @@ static int i2c_dw_initialize(const struct device *dev) union ic_con_register ic_con; int ret = 0; +#if defined(CONFIG_RESET) + if (rom->reset.dev) { + ret = reset_line_toggle_dt(&rom->reset); + if (ret) { + return ret; + } + } +#endif + #if defined(CONFIG_PINCTRL) ret = pinctrl_apply_state(rom->pcfg, PINCTRL_STATE_DEFAULT); if (ret) { @@ -922,6 +934,14 @@ static int i2c_dw_initialize(const struct device *dev) #define PINCTRL_DW_CONFIG(n) #endif +#if defined(CONFIG_RESET) +#define RESET_DW_CONFIG(n) \ + IF_ENABLED(DT_INST_NODE_HAS_PROP(0, resets), \ + (.reset = RESET_DT_SPEC_INST_GET(n),)) +#else +#define RESET_DW_CONFIG(n) +#endif + #define I2C_DW_INIT_PCIE0(n) #define I2C_DW_INIT_PCIE1(n) DEVICE_PCIE_INST_INIT(n, pcie), #define I2C_DW_INIT_PCIE(n) \ @@ -985,6 +1005,7 @@ static int i2c_dw_initialize(const struct device *dev) I2C_CONFIG_REG_INIT(n) \ .config_func = i2c_config_##n, \ .bitrate = DT_INST_PROP(n, clock_frequency), \ + RESET_DW_CONFIG(n) \ PINCTRL_DW_CONFIG(n) \ I2C_DW_INIT_PCIE(n) \ }; \ diff --git a/drivers/i2c/i2c_dw.h b/drivers/i2c/i2c_dw.h index c9f7381eb89..1aac3d20340 100644 --- a/drivers/i2c/i2c_dw.h +++ b/drivers/i2c/i2c_dw.h @@ -18,6 +18,10 @@ BUILD_ASSERT(IS_ENABLED(CONFIG_PCIE), "DW I2C in DT needs CONFIG_PCIE"); #include #endif +#if defined(CONFIG_RESET) +#include +#endif + #ifdef __cplusplus extern "C" { #endif @@ -93,6 +97,9 @@ struct i2c_dw_rom_config { #if defined(CONFIG_PINCTRL) const struct pinctrl_dev_config *pcfg; #endif +#if defined(CONFIG_RESET) + const struct reset_dt_spec reset; +#endif #if DT_ANY_INST_ON_BUS_STATUS_OKAY(pcie) struct pcie_dev *pcie;