Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions drivers/i2c/i2c_dw.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#if defined(CONFIG_PINCTRL)
#include <zephyr/drivers/pinctrl.h>
#endif
#if defined(CONFIG_RESET)
#include <zephyr/drivers/reset.h>
#endif

#include <errno.h>
#include <zephyr/sys/sys_io.h>
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) \
Expand Down Expand Up @@ -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) \
}; \
Expand Down
7 changes: 7 additions & 0 deletions drivers/i2c/i2c_dw.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ BUILD_ASSERT(IS_ENABLED(CONFIG_PCIE), "DW I2C in DT needs CONFIG_PCIE");
#include <zephyr/drivers/pcie/pcie.h>
#endif

#if defined(CONFIG_RESET)
#include <zephyr/drivers/reset.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions dts/arm/rpi_pico/rp2040.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,23 @@
};

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";
status = "disabled";
};

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";
Expand Down
5 changes: 5 additions & 0 deletions dts/bindings/i2c/raspberrypi,pico-i2c.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Raspberry Pi Pico I2C

compatible: "raspberrypi,pico-i2c"

include: ["snps,designware-i2c.yaml", "reset-device.yaml"]