]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
I2C: Fix twl4030 clock init
authorTony Lindgren <tony@atomide.com>
Tue, 1 Apr 2008 13:58:02 +0000 (16:58 +0300)
committerTony Lindgren <tony@atomide.com>
Tue, 1 Apr 2008 14:04:09 +0000 (17:04 +0300)
Without this patch twl4030 clock can get programmed to incorrect rate
which can eventually hang twl4030 reads. Also minor formatting fixes.

Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/i2c/chips/twl4030-core.c

index c979241f377702fb19accef6a018e15b5459d0d4..cb457b3ddf7539218afd97978b117d8e37fa02ee 100644 (file)
@@ -672,11 +672,20 @@ static int power_companion_init(void)
        u32 rate, ctrl = HFCLK_FREQ_26_MHZ;
        int e = 0;
 
-       osc = clk_get(NULL,"osc_ck");
+       if (cpu_is_omap2430())
+               osc = clk_get(NULL, "osc_ck");
+       else
+               osc = clk_get(NULL, "osc_sys_ck");
+       if (IS_ERR(osc)) {
+               printk(KERN_ERR "Skipping twl3040 internal clock init and "
+                               "using bootloader value (unknown osc rate)\n");
+               return 0;
+       }
+
        rate = clk_get_rate(osc);
        clk_put(osc);
 
-       switch(rate) {
+       switch (rate) {
                case 19200000 : ctrl = HFCLK_FREQ_19p2_MHZ; break;
                case 26000000 : ctrl = HFCLK_FREQ_26_MHZ; break;
                case 38400000 : ctrl = HFCLK_FREQ_38p4_MHZ; break;
@@ -684,7 +693,7 @@ static int power_companion_init(void)
 
        ctrl |= HIGH_PERF_SQ;
        e |= unprotect_pm_master();
-                       /* effect->MADC+USB ck en */
+       /* effect->MADC+USB ck en */
        e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, ctrl, R_CFG_BOOT);
        e |= protect_pm_master();