Subject: Re: [PATCH] powerpc: i2c-mpc: make speed registers configurable via FDT

From: Wolfgang Grandegger <[email-masked]>
Date: Thu, 31 Jul 2008 21:54:48 +0200

Timur Tabi wrote:
> Wolfgang Grandegger wrote:
> 
>> No, the source clock is not identical for all 8[356]xx. Some use half or 
>> even a third of the SOC clock frequency. 
> 
> The platform clock divided by 2 or 3 *is* the source clock to the I2C.  That's
> what I'm talking about.
> 
>> Linux must determine the real
>> source clock frequency somehow. We may introduce the SOC property 
>> "i2c-clock-frequency", which could be fixed up by U-Boot or a pre-loader 
>> (in case U-Boot is not used). Like for other frequency properties as well.
> 
> That's what I'm proposing, but drop the "i2c-".

But clock-frequency, aka bus-frequency, is already used by 
fsl_get_sys_freq():

http://lxr.linux.no/linux+v2.6.26/arch/powerpc/sysdev/fsl_soc.c#L80

Thinking more about it, it would be best to add the property 
"i2c-clock-divider" to the soc node and implement fsl_get_i2c_freq() in 
a similar way:

         soc8541@e0000000 {
                 #address-cells = <1>;
                 #size-cells = <1>;
                 device_type = "soc";
                 ranges = <0x0 0xe0000000 0x100000>;
                 reg = <0xe0000000 0x1000>;      // CCSRBAR 1M
                 bus-frequency = <0>;
                 i2c-clock-divider = <2>;

U-Boot could then fixup that value like bus-frequency() and the i2c-mpc 
driver simply calls fsl_get_i2c_freq().

Wolfgang.