drivers: i2c: i2c_dw: Add capability for handling reset device
Reset the device on initializing if reset-node is available in dts. `snps,desingware-i2c` does not define reset-node itself. Add more of an element that inherits `reset-device.yaml` to the `compatible` section to allow defining the reset-node for using this feature. For example. ``` compatible = "reset-device-inherit-node", "snps,designware-i2c"; ``` Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
This commit is contained in:
parent
5f17a16ef4
commit
e2f47c0c38
2 changed files with 28 additions and 0 deletions
|
@ -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>
|
||||
|
@ -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) \
|
||||
}; \
|
||||
|
|
|
@ -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
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue