cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
4,625 Views
Registered: ‎04-07-2017

Cadence I2C Clock Frequency

Jump to solution

Where does the I2C clock frequency in the device tree come from? As far as I can tell, it is merged in from pcw.dtsi when the final device tree (plnx_arm-system.dts in my case) is created.

 

The relevant section of pcw.dtsi looks like:

 

&i2c0 {
        clock-frequency = <400000>;
        status = "okay";
};

The related section of the plnx_arm-system.dts is:

 

 i2c@e0004000 {
                        compatible = "cdns,i2c-r1p10";
                        status = "okay";
                        clocks = <0x1 0x26>;
                        interrupt-parent = <0x3>;
                        interrupts = <0x0 0x19 0x4>;
                        reg = <0xe0004000 0x1000>;
                        #address-cells = <0x1>;
                        #size-cells = <0x0>;
                        clock-frequency = <0x61a80>;
                };

I am able to override the frequency in system-top.dts with something like...

 

 

&amba {
    i2c@e0005000 {
        clock-frequency = <100000>;
    };
};

...but would like to know where the default frequency comes from so that I can change it in the correct place instead of modifying it. If the 400kHz setting is just a hard-coded default and I'm doing the right thing by overriding it in out system-top.dts, that would also be good to know.

 

 

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Adventurer
Adventurer
6,366 Views
Registered: ‎12-03-2015

As far as I can tell the default clock_frequency value in pcw.dtsi is coming from the board description file used by Vivado to generate the HDF. It might be possible to change it in Vivado.

system-top.dts is designed to be used to overwrite or add new entries to the device tree.

Short answer: Yes, this is the correct way to change the value of the clock frequency.

View solution in original post

4 Replies
Highlighted
4,431 Views
Registered: ‎02-15-2017

That's a great question.  I was wondering this myself,

0 Kudos
Highlighted
Voyager
Voyager
4,389 Views
Registered: ‎09-14-2016

Hi @matt.stclair,

 

I'm not i2c expert but if you take a looke here :

 

http://lxr.free-electrons.com/source/drivers/i2c/busses/i2c-cadence.c#L112

 

http://lxr.free-electrons.com/source/drivers/i2c/busses/i2c-cadence.c#L945

 

We can see that the Max value is used. It's not surprise because it's a really common value for i2c bus.

 

In addition the driver set the default to default speed (100kHz) if the device-tree is not populated, according to that if we don't overwrite the dts the driver will use the clock-frequency speed (set in the dts) so less is often less :-)

 

I'm not sure if i'm clear :S

 

Regards,

Trigger

 

 

 

Highlighted
Visitor
Visitor
4,381 Views
Registered: ‎04-07-2017

The device tree entry with the clock frequency is automatically being generated in pcw.dtsi, so not setting a clock frequency doesn't seem to be an option. My question is where the clock frequency in pcw.dtsi is coming from.

 

Maybe I'm doing the right thing by just overriding it in system-top.dts, but it would be nice if someone could either confirm that or give me the correct way to do it.

0 Kudos
Highlighted
Adventurer
Adventurer
6,367 Views
Registered: ‎12-03-2015

As far as I can tell the default clock_frequency value in pcw.dtsi is coming from the board description file used by Vivado to generate the HDF. It might be possible to change it in Vivado.

system-top.dts is designed to be used to overwrite or add new entries to the device tree.

Short answer: Yes, this is the correct way to change the value of the clock frequency.

View solution in original post