I2C on i.mx28 EVK - cannot switch to 400KHz

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I2C on i.mx28 EVK - cannot switch to 400KHz

Jump to solution
993 Views
ArtyomKamshilin
Contributor II

Hi everyone,

I'm stuck trying to switch i.mx28 board to 400 KHz mode. I patched the following file:

drivers/i2c/busses/i2c-mxs.c

to set HW_I2C_TIMING0 register to 0x000F0007 as recommended by the MX28 Reference Manual. However, something resets it all the time to its default value of 0x00780030, and the bus falls back to 100 KHz mode. Worst yet, it happens while a I2C transfer is under way:

(line 328 of the above file):

    printk("Timing reg 3: 0x%08x\n", __raw_readl(dev->regbase + HW_I2C_TIMING0));

    err = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
                            msecs_to_jiffies(1000)
        );

    printk("Timing reg 4: 0x%08x\n", __raw_readl(dev->regbase + HW_I2C_TIMING0));

outputs:

Timing reg 3: 0x000f0007
Timing reg 4: 0x00780030

I grep'ped through the kernel source trying to find any reference to HW_I2C_TIMING0 register (and change it) - but found none except for its definition in a header file.

Does HW_I2C_TIMING0 reset itself to default values somehow? How do I make my changes stick? Anything helps... thanks in advance.

Regards,

Arty

0 Kudos
1 Solution
761 Views
PeterChan
NXP Employee
NXP Employee

Hello Arty,

 

The i2c timing registers always restore to their default values after i2c reset. (i.e. HW_I2C_CTRL0.SFTRST = 1). Please check if any error condition has occurred which leads to i2c reset.

 

Regards,

Peter

View solution in original post

0 Kudos
2 Replies
762 Views
PeterChan
NXP Employee
NXP Employee

Hello Arty,

 

The i2c timing registers always restore to their default values after i2c reset. (i.e. HW_I2C_CTRL0.SFTRST = 1). Please check if any error condition has occurred which leads to i2c reset.

 

Regards,

Peter

0 Kudos
761 Views
ArtyomKamshilin
Contributor II

That worked, thanks a lot, Peter! Didn't realize registers are restored to defaults after bus reset.

0 Kudos