]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
USB: MUSB: Let board specific code handle clock initialization
authorFelipe Balbi <felipe.balbi@nokia.com>
Tue, 18 Mar 2008 18:26:30 +0000 (20:26 +0200)
committerTony Lindgren <tony@atomide.com>
Fri, 28 Mar 2008 10:16:40 +0000 (12:16 +0200)
Instead of clk_get() in omap2430.c driver, we can let
musb_core.c do it by setting the clock id in
musb_platform_data structure.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/board-2430sdp-usb.c
arch/arm/mach-omap2/board-3430sdp-usb.c
drivers/usb/musb/omap2430.c

index 908a0c0be5b123e206e72bfd8a9db0a1d0a8ba02..7f4e017f30edb8fd0580c0f634e6371691a5a9f3 100644 (file)
 #include <linux/errno.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
+#include <linux/clk.h>
 #include <linux/usb/musb.h>
 
 #include <asm/arch/hardware.h>
+#include <asm/arch/pm.h>
 #include <asm/arch/usb.h>
 
 static struct resource musb_resources[] = {
@@ -34,6 +36,29 @@ static struct resource musb_resources[] = {
        },
 };
 
+static int usbhs_ick_on;
+
+static int musb_set_clock(struct clk *clk, int state)
+{
+       if (state) {
+               if (usbhs_ick_on > 0)
+                       return -ENODEV;
+
+               omap2_block_sleep();
+               clk_enable(clk);
+               usbhs_ick_on = 1;
+       } else {
+               if (usbhs_ick_on == 0)
+                       return -ENODEV;
+
+               clk_disable(clk);
+               usbhs_ick_on = 0;
+               omap2_allow_sleep();
+       }
+
+       return 0;
+}
+
 static struct musb_hdrc_platform_data musb_plat = {
 #ifdef CONFIG_USB_MUSB_OTG
        .mode           = MUSB_OTG,
@@ -43,6 +68,8 @@ static struct musb_hdrc_platform_data musb_plat = {
        .mode           = MUSB_PERIPHERAL,
 #endif
        .multipoint     = 1,
+       .clock          = "usbhs_ick",
+       .set_clock      = musb_set_clock,
 };
 
 static u64 musb_dmamask = ~(u32)0;
index 77088b4287851ed2b3a976fe9b45ad6f950f22f7..81c9af7f9e00ac8d1926c5955ab790d8ca878e6a 100644 (file)
 #include <linux/errno.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
+#include <linux/clk.h>
 #include <asm/io.h>
 #include <asm/arch/mux.h>
 #include <linux/usb/musb.h>
 
 #include <asm/arch/hardware.h>
+#include <asm/arch/pm.h>
 #include <asm/arch/usb.h>
 
 #ifdef CONFIG_USB_MUSB_SOC
@@ -40,6 +42,29 @@ static struct resource musb_resources[] = {
        },
 };
 
+static int hsotgusb_ick_on;
+
+static int musb_set_clock(struct clk *clk, int state)
+{
+       if (state) {
+               if (hsotgusb_ick_on > 0)
+                       return -ENODEV;
+
+               omap2_block_sleep();
+               clk_enable(clk);
+               hsotgusb_ick_on = 1;
+       } else {
+               if (hsotgusb_ick_on == 0)
+                       return -ENODEV;
+
+               clk_disable(clk);
+               hsotgusb_ick_on = 0;
+               omap2_allow_sleep();
+       }
+
+       return 0;
+}
+
 static struct musb_hdrc_platform_data musb_plat = {
 #ifdef CONFIG_USB_MUSB_OTG
        .mode           = MUSB_OTG,
@@ -49,8 +74,8 @@ static struct musb_hdrc_platform_data musb_plat = {
        .mode           = MUSB_PERIPHERAL,
 #endif
        .multipoint     = 1,
-       .clock          = NULL,
-       .set_clock      = NULL,
+       .clock          = "hsotgusb_ick",
+       .set_clock      = musb_set_clock,
 };
 
 static u64 musb_dmamask = ~(u32)0;
index caae81b0bed612f89575fc7a07432ec960e51edb..364d746d635436231063080a4bf6c11d626fed32 100644 (file)
@@ -219,13 +219,7 @@ int __init musb_platform_init(struct musb *musb)
 
 #if defined(CONFIG_ARCH_OMAP2430)
        omap_cfg_reg(AE5_2430_USB0HS_STP);
-       /* get the clock */
-       musb->clock = clk_get((struct device *)musb->controller, "usbhs_ick");
-#else
-       musb->clock = clk_get((struct device *)musb->controller, "hsotgusb_ick");
 #endif
-       if(IS_ERR(musb->clock))
-               return PTR_ERR(musb->clock);
 
        musb->xceiv = *xceiv;
        musb_platform_resume(musb);
@@ -261,13 +255,11 @@ int musb_platform_suspend(struct musb *musb)
        OTG_SYSCONFIG_REG |= AUTOIDLE;          /* enable auto idle */
 
        musb->xceiv.set_suspend(&musb->xceiv, 1);
-       clk_disable(musb->clock);
        return 0;
 }
 
 int musb_platform_resume(struct musb *musb)
 {
-       clk_enable(musb->clock);
        musb->xceiv.set_suspend(&musb->xceiv, 0);
 
        OTG_FORCESTDBY_REG &= ~ENABLEFORCE; /* disable MSTANDBY */