Skip to content

Commit b623663

Browse files
xiaolusucfriedt
authored andcommitted
drivers: i2c_sedi: Apply DTS clock_frequency to I2C during initialization
Previously, the clock_frequency property defined in the Device Tree was not applied to the I2C controller, causing the controller to ignore the specified bitrate configuration if no other config for speed. When using default hardware settings, the lack of an explicit timing or frequency config may result in the controller ignoring bitrate settings. This change ensures that the clock_frequency value from DTS is now correctly mapped and set during controller initialization, allowing the bitrate to take effect as intended. This improves hardware configurability and ensures the I2C bus operates at the desired speed specified in the Device Tree. Signed-off-by: Xiaolu Sun <[email protected]>
1 parent 26fe43d commit b623663

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/i2c/i2c_sedi.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
#include <zephyr/kernel.h>
1212
#include <sedi_driver_i2c.h>
1313
#include <zephyr/pm/device.h>
14+
#include <zephyr/logging/log.h>
15+
LOG_MODULE_REGISTER(i2c_sedi);
1416

17+
#include "i2c-priv.h"
1518
#define I2C_SEDI_TIMEOUT_MS (1000)
1619

1720
struct i2c_sedi_context {
@@ -21,6 +24,7 @@ struct i2c_sedi_context {
2124
struct k_mutex *mutex;
2225
int err;
2326
uint16_t addr_10bit;
27+
uint32_t bitrate;
2428
};
2529

2630
struct i2c_sedi_config {
@@ -192,6 +196,12 @@ static int i2c_sedi_init(const struct device *dev)
192196
return -EIO;
193197
}
194198

199+
ret = i2c_sedi_api_configure(dev,
200+
I2C_MODE_CONTROLLER |
201+
i2c_map_dt_bitrate(context->bitrate));
202+
if (ret != 0) {
203+
return -EIO;
204+
}
195205
config->irq_config(dev);
196206

197207
return 0;
@@ -213,6 +223,7 @@ static void i2c_sedi_isr(const struct device *dev)
213223
static K_MUTEX_DEFINE(i2c_sedi_mutex_##n); \
214224
static struct i2c_sedi_context i2c_sedi_data_##n = { \
215225
.sedi_device = DT_INST_PROP(n, peripheral_id), \
226+
.bitrate = DT_INST_PROP(n, clock_frequency), \
216227
.sem = &i2c_sedi_sem_##n, \
217228
.mutex = &i2c_sedi_mutex_##n, \
218229
}; \

0 commit comments

Comments
 (0)