Skip to content

Commit a8514b5

Browse files
sebhubcfriedt
authored andcommitted
drivers: i2c: mchp_mss: Fix mss_i2c_configure()
Clear the clock bits before setting new ones. Signed-off-by: Sebastian Huber <[email protected]>
1 parent e8972a9 commit a8514b5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/i2c/i2c_mchp_mss.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,25 @@ struct mss_i2c_data {
137137
};
138138

139139

140-
static int mss_i2c_configure(const struct device *dev, uint32_t dev_config_raw)
140+
static int mss_i2c_configure(const struct device *dev, uint32_t dev_config)
141141
{
142142
const struct mss_i2c_config *cfg = dev->config;
143-
144143
uint8_t ctrl = sys_read8(cfg->i2c_base_addr + CORE_I2C_CTRL);
145144

146-
switch (I2C_SPEED_GET(dev_config_raw)) {
145+
ctrl &= ~CLK_MASK;
146+
147+
switch (I2C_SPEED_GET(dev_config)) {
147148
case I2C_SPEED_STANDARD:
148-
sys_write8((ctrl | PCLK_DIV_960), cfg->i2c_base_addr + CORE_I2C_CTRL);
149+
ctrl |= PCLK_DIV_960;
149150
break;
150151
case I2C_SPEED_FAST:
151-
sys_write8((ctrl | PCLK_DIV_256), cfg->i2c_base_addr + CORE_I2C_CTRL);
152+
ctrl |= PCLK_DIV_256;
152153
break;
153154
default:
154155
return -EINVAL;
155156
}
156157

158+
sys_write8(ctrl, cfg->i2c_base_addr + CORE_I2C_CTRL);
157159
return 0;
158160
}
159161

0 commit comments

Comments
 (0)