diff --git a/drivers/i2c/i2c_dw.c b/drivers/i2c/i2c_dw.c index 74cf471783bb0..bb5ecc3779f46 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 c9f7381eb89fc..1aac3d20340bc 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; diff --git a/dts/arm/rpi_pico/rp2040.dtsi b/dts/arm/rpi_pico/rp2040.dtsi index 24c0a3e7bae01..131c59a1b1b0c 100644 --- a/dts/arm/rpi_pico/rp2040.dtsi +++ b/dts/arm/rpi_pico/rp2040.dtsi @@ -138,10 +138,11 @@ }; i2c0: i2c@40044000 { - compatible = "snps,designware-i2c"; + compatible = "raspberrypi,pico-i2c", "snps,designware-i2c"; #address-cells = <1>; #size-cells = <0>; reg = <0x40044000 DT_SIZE_K(4)>; + resets = <&reset RPI_PICO_RESETS_RESET_I2C0>; clocks = <&system_clk>; interrupts = <23 RPI_PICO_DEFAULT_IRQ_PRIORITY>; interrupt-names = "i2c0"; @@ -149,10 +150,11 @@ }; i2c1: i2c@40048000 { - compatible = "snps,designware-i2c"; + compatible = "raspberrypi,pico-i2c", "snps,designware-i2c"; #address-cells = <1>; #size-cells = <0>; reg = <0x40048000 DT_SIZE_K(4)>; + resets = <&reset RPI_PICO_RESETS_RESET_I2C0>; clocks = <&system_clk>; interrupts = <24 RPI_PICO_DEFAULT_IRQ_PRIORITY>; interrupt-names = "i2c1"; diff --git a/dts/bindings/i2c/raspberrypi,pico-i2c.yaml b/dts/bindings/i2c/raspberrypi,pico-i2c.yaml new file mode 100644 index 0000000000000..ac055dcfd591d --- /dev/null +++ b/dts/bindings/i2c/raspberrypi,pico-i2c.yaml @@ -0,0 +1,5 @@ +description: Raspberry Pi Pico I2C + +compatible: "raspberrypi,pico-i2c" + +include: ["snps,designware-i2c.yaml", "reset-device.yaml"]