PRCM: OMAP3: Fix to wrongly modified omap2_clk_wait_ready
[linux-ginger.git] / arch / arm / mach-omap2 / usb-musb.c
blobcbd59f8e81c0bec778524b98fb28611d48cd3768
1 /*
2 * linux/arch/arm/mach-omap2/usb-musb.c
4 * This file will contain the board specific details for the
5 * MENTOR USB OTG controller on OMAP3430
7 * Copyright (C) 2007-2008 Texas Instruments
8 * Copyright (C) 2008 Nokia Corporation
9 * Author: Vikram Pandita
11 * Generalization by:
12 * Felipe Balbi <felipe.balbi@nokia.com>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
19 #include <linux/types.h>
20 #include <linux/errno.h>
21 #include <linux/delay.h>
22 #include <linux/platform_device.h>
23 #include <linux/clk.h>
24 #include <asm/io.h>
25 #include <asm/arch/mux.h>
26 #include <linux/usb/musb.h>
28 #include <asm/arch/hardware.h>
29 #include <asm/arch/pm.h>
30 #include <asm/arch/usb.h>
32 #ifdef CONFIG_USB_MUSB_SOC
33 static struct resource musb_resources[] = {
34 [0] = {
35 .start = cpu_is_omap34xx()
36 ? OMAP34XX_HSUSB_OTG_BASE
37 : OMAP243X_HS_BASE,
38 .end = cpu_is_omap34xx()
39 ? OMAP34XX_HSUSB_OTG_BASE + SZ_8K - 1
40 : OMAP243X_HS_BASE + SZ_8K -1,
41 .flags = IORESOURCE_MEM,
43 [1] = { /* general IRQ */
44 .start = INT_243X_HS_USB_MC,
45 .flags = IORESOURCE_IRQ,
47 [2] = { /* DMA IRQ */
48 .start = INT_243X_HS_USB_DMA,
49 .flags = IORESOURCE_IRQ,
53 static int clk_on;
55 static int musb_set_clock(struct clk *clk, int state)
57 if (state) {
58 if (clk_on > 0)
59 return -ENODEV;
61 omap2_block_sleep();
62 clk_enable(clk);
63 clk_on = 1;
64 } else {
65 if (clk_on == 0)
66 return -ENODEV;
68 clk_disable(clk);
69 clk_on = 0;
70 omap2_allow_sleep();
73 return 0;
76 static struct musb_hdrc_platform_data musb_plat = {
77 #ifdef CONFIG_USB_MUSB_OTG
78 .mode = MUSB_OTG,
79 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
80 .mode = MUSB_HOST,
81 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
82 .mode = MUSB_PERIPHERAL,
83 #endif
84 .multipoint = 1,
85 .clock = cpu_is_omap34xx()
86 ? "hsotgusb_ick"
87 : "usbhs_ick",
88 .set_clock = musb_set_clock,
91 static u64 musb_dmamask = ~(u32)0;
93 static struct platform_device musb_device = {
94 .name = "musb_hdrc",
95 .id = 0,
96 .dev = {
97 .dma_mask = &musb_dmamask,
98 .coherent_dma_mask = 0xffffffff,
99 .platform_data = &musb_plat,
101 .num_resources = ARRAY_SIZE(musb_resources),
102 .resource = musb_resources,
104 #endif
107 void __init usb_musb_init(void)
109 #ifdef CONFIG_USB_MUSB_SOC
110 if (platform_device_register(&musb_device) < 0) {
111 printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
112 return;
114 #endif