bool usb_enable_clock(bool enable) { static int count = 0; bool res = TRUE; unsigned long flags; spin_lock_irqsave(&musb_reg_clock_lock, flags); if (enable && count == 0) { enable_phy_clock(true); res = enable_clock(MT_CG_PERI_USB0, "PERI_USB"); } else if (!enable && count == 1) { res = disable_clock(MT_CG_PERI_USB0, "PERI_USB"); enable_phy_clock(false); } if (enable) count++; else count = (count==0) ? 0 : (count-1); spin_unlock_irqrestore(&musb_reg_clock_lock, flags); printk(KERN_DEBUG "enable(%d), count(%d) res=%d\n", enable, count, res); return 1; }
bool usb_enable_clock(bool enable) { static int count = 0; bool res1 = TRUE; bool res2 = TRUE; bool res3 = TRUE; unsigned long flags; spin_lock_irqsave(&musb_reg_clock_lock, flags); if (enable && count == 0) { enable_phy_clock(true); res1 = enable_clock(MT_CG_INFRA_USB, "INFRA_USB"); res2 = enable_clock(MT_CG_INFRA_USB_MCU, "INFRA_USB_MCU"); res3 = enable_clock(MT_CG_INFRA_ICUSB, "INFRA_ICUSB"); } else if (!enable && count == 1) { res2 = disable_clock(MT_CG_INFRA_USB_MCU, "INFRA_USB_MCU"); res1 = disable_clock(MT_CG_INFRA_USB, "INFRA_USB"); res3 = disable_clock(MT_CG_INFRA_ICUSB, "INFRA_ICUSB"); enable_phy_clock(false); } if (enable) count++; else count = (count==0) ? 0 : (count-1); spin_unlock_irqrestore(&musb_reg_clock_lock, flags); printk(KERN_DEBUG "enable(%d), count(%d) res1=%d, res2=%d\n", enable, count, res1, res2); return 1; }
bool usb_enable_clock(bool enable) { static int count; static int real_enable = 0, real_disable; static int virt_enable = 0, virt_disable; bool res = TRUE; unsigned long flags; DBG(1, "enable(%d),count(%d),<%d,%d,%d,%d>\n", enable, count, virt_enable, virt_disable, real_enable, real_disable); spin_lock_irqsave(&musb_reg_clock_lock, flags); if (enable && count == 0) { real_enable++; enable_phy_clock(true); #ifdef CONFIG_MTK_CLKMGR res = enable_clock(MT_CG_PERI_USB0, "PERI_USB"); #else res = clk_enable(musb_clk); #endif } else if (!enable && count == 1) { real_disable++; #ifdef CONFIG_MTK_CLKMGR res = disable_clock(MT_CG_PERI_USB0, "PERI_USB"); #else res = 0; clk_disable(musb_clk); #endif enable_phy_clock(false); } if (enable) { virt_enable++; count++; } else { virt_disable++; count = (count == 0) ? 0 : (count - 1); } spin_unlock_irqrestore(&musb_reg_clock_lock, flags); DBG(1, "enable(%d),count(%d),res(%d),<%d,%d,%d,%d>\n", enable, count, res, virt_enable, virt_disable, real_enable, real_disable); return 1; }