Skip to content

Commit 9132ac4

Browse files
sebhubdanieldegrasse
authored andcommitted
drivers: i2c: mchp_mss: Add reset support
Add support to reset the device through a reset controller. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
1 parent dbb8ee3 commit 9132ac4

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

drivers/i2c/i2c_mchp_mss.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ LOG_MODULE_REGISTER(i2c_mchp, CONFIG_I2C_LOG_LEVEL);
2020

2121
#define DT_DRV_COMPAT microchip_mpfs_i2c
2222

23+
/* Is MSS I2C module 'resets' line property defined */
24+
#define MSS_I2C_RESET_ENABLED DT_ANY_INST_HAS_PROP_STATUS_OKAY(resets)
25+
26+
#if MSS_I2C_RESET_ENABLED
27+
#include <zephyr/drivers/reset.h>
28+
#endif
29+
2330
#define CORE_I2C_CTRL (0x00)
2431
#define CORE_I2C_STATUS (0x04)
2532
#define CORE_I2C_DATA (0x08)
@@ -94,6 +101,9 @@ struct mss_i2c_config {
94101
uint32_t clock_freq;
95102
uintptr_t i2c_base_addr;
96103
uint32_t i2c_irq_base;
104+
#if MSS_I2C_RESET_ENABLED
105+
struct reset_dt_spec reset_spec;
106+
#endif
97107
};
98108

99109
struct mss_i2c_data {
@@ -243,6 +253,13 @@ static DEVICE_API(i2c, mss_i2c_driver_api) = {
243253
static void mss_i2c_reset(const struct device *dev)
244254
{
245255
const struct mss_i2c_config *cfg = dev->config;
256+
257+
#if MSS_I2C_RESET_ENABLED
258+
if (cfg->reset_spec.dev != NULL) {
259+
(void)reset_line_deassert_dt(&cfg->reset_spec);
260+
}
261+
#endif
262+
246263
uint8_t ctrl = sys_read8(cfg->i2c_base_addr + CORE_I2C_CTRL);
247264

248265
sys_write8((ctrl & ~CTRL_ENS1), cfg->i2c_base_addr + CORE_I2C_CTRL);
@@ -380,6 +397,8 @@ static void mss_i2c_irq_handler(const struct device *dev)
380397
.i2c_base_addr = DT_INST_REG_ADDR(n), \
381398
.i2c_irq_base = DT_INST_IRQN(n), \
382399
.clock_freq = DT_INST_PROP(n, clock_frequency), \
400+
IF_ENABLED(DT_INST_NODE_HAS_PROP(n, resets), \
401+
(.reset_spec = RESET_DT_SPEC_INST_GET(n),)) \
383402
}; \
384403
\
385404
I2C_DEVICE_DT_INST_DEFINE(n, mss_i2c_init_##n, NULL, &mss_i2c_data_##n, \

dts/bindings/i2c/microchip,mpfs-i2c.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: Microchip MPFS I2C Controller
88

99
compatible: "microchip,mpfs-i2c"
1010

11-
include: i2c-controller.yaml
11+
include: [i2c-controller.yaml, reset-device.yaml]
1212

1313
properties:
1414
reg:

0 commit comments

Comments
 (0)