Skip to content

Commit 9db744b

Browse files
Ayush1325kartben
authored andcommitted
drivers: i2c: omap: Use DEVICE_MMIO macro for registers
- Use DEVICE_MMIO_* macros for getting the registers. - These macros automatically used the proper RAM/ROM address. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
1 parent 3239544 commit 9db744b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/i2c/i2c_omap.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ static void i2c_omap_resize_fifo(const struct device *dev, uint8_t size)
315315
*/
316316
static int i2c_omap_get_sda(void *io_context)
317317
{
318-
const struct i2c_omap_cfg *cfg = (const struct i2c_omap_cfg *)io_context;
319-
i2c_omap_regs_t *i2c_base_addr = (i2c_omap_regs_t *)cfg->base.addr;
318+
const struct device *dev = io_context;
319+
i2c_omap_regs_t *i2c_base_addr = DEV_I2C_BASE(dev);
320320

321321
return (i2c_base_addr->SYSTEST & I2C_OMAP_SYSTEST_SDA_I_FUNC) ? 1 : 0;
322322
}
@@ -331,8 +331,8 @@ static int i2c_omap_get_sda(void *io_context)
331331
*/
332332
static void i2c_omap_set_sda(void *io_context, int state)
333333
{
334-
const struct i2c_omap_cfg *cfg = (const struct i2c_omap_cfg *)io_context;
335-
i2c_omap_regs_t *i2c_base_addr = (i2c_omap_regs_t *)cfg->base.addr;
334+
const struct device *dev = io_context;
335+
i2c_omap_regs_t *i2c_base_addr = DEV_I2C_BASE(dev);
336336

337337
if (state) {
338338
i2c_base_addr->SYSTEST |= I2C_OMAP_SYSTEST_SDA_O;
@@ -351,8 +351,8 @@ static void i2c_omap_set_sda(void *io_context, int state)
351351
*/
352352
static void i2c_omap_set_scl(void *io_context, int state)
353353
{
354-
const struct i2c_omap_cfg *cfg = (const struct i2c_omap_cfg *)io_context;
355-
i2c_omap_regs_t *i2c_base_addr = (i2c_omap_regs_t *)cfg->base.addr;
354+
const struct device *dev = io_context;
355+
i2c_omap_regs_t *i2c_base_addr = DEV_I2C_BASE(dev);
356356

357357
if (state) {
358358
i2c_base_addr->SYSTEST |= I2C_OMAP_SYSTEST_SCL_O;
@@ -388,7 +388,7 @@ static int i2c_omap_recover_bus(const struct device *dev)
388388
k_sem_take(&data->lock, K_FOREVER);
389389
i2c_base_addr->SYSTEST |= I2C_OMAP_SYSTEST_ST_EN | (3 << I2C_OMAP_SYSTEST_TMODE_SHIFT) |
390390
I2C_OMAP_SYSTEST_SCL_O | I2C_OMAP_SYSTEST_SDA_O;
391-
i2c_bitbang_init(&bitbang_omap, &bitbang_omap_io, (void *)cfg);
391+
i2c_bitbang_init(&bitbang_omap, &bitbang_omap_io, (void *)dev);
392392
error = i2c_bitbang_recover_bus(&bitbang_omap);
393393
if (error != 0) {
394394
LOG_ERR("failed to recover bus (err %d)", error);

0 commit comments

Comments
 (0)