]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-2430sdp-usb.c
ARM: OMAP: omap3beagle: register SD interface
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-2430sdp-usb.c
1 /*
2  * linux/arch/arm/mach-omap2/board-2430sdp-usb.c
3  *
4  * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
5  * Author: Kevin Hilman
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11
12 #include <linux/types.h>
13 #include <linux/errno.h>
14 #include <linux/delay.h>
15 #include <linux/platform_device.h>
16 #include <linux/clk.h>
17 #include <linux/usb/musb.h>
18
19 #include <asm/arch/hardware.h>
20 #include <asm/arch/pm.h>
21 #include <asm/arch/usb.h>
22
23 static struct resource musb_resources[] = {
24         [0] = {
25                 .start  = OMAP243X_HS_BASE,
26                 .end    = OMAP243X_HS_BASE + SZ_8K - 1,
27                 .flags  = IORESOURCE_MEM,
28         },
29         [1] = { /* general IRQ */
30                 .start  = INT_243X_HS_USB_MC,
31                 .flags  = IORESOURCE_IRQ,
32         },
33         [2] = { /* DMA IRQ */
34                 .start  = INT_243X_HS_USB_DMA,
35                 .flags  = IORESOURCE_IRQ,
36         },
37 };
38
39 static int usbhs_ick_on;
40
41 static int musb_set_clock(struct clk *clk, int state)
42 {
43        if (state) {
44                if (usbhs_ick_on > 0)
45                        return -ENODEV;
46
47                omap2_block_sleep();
48                clk_enable(clk);
49                usbhs_ick_on = 1;
50        } else {
51                if (usbhs_ick_on == 0)
52                        return -ENODEV;
53
54                clk_disable(clk);
55                usbhs_ick_on = 0;
56                omap2_allow_sleep();
57        }
58
59        return 0;
60 }
61
62 static struct musb_hdrc_platform_data musb_plat = {
63 #ifdef CONFIG_USB_MUSB_OTG
64         .mode           = MUSB_OTG,
65 #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
66         .mode           = MUSB_HOST,
67 #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
68         .mode           = MUSB_PERIPHERAL,
69 #endif
70         .multipoint     = 1,
71         .clock          = "usbhs_ick",
72         .set_clock      = musb_set_clock,
73 };
74
75 static u64 musb_dmamask = ~(u32)0;
76
77 static struct platform_device musb_device = {
78         .name           = "musb_hdrc",
79         .id             = 0,
80         .dev = {
81                 .dma_mask               = &musb_dmamask,
82                 .coherent_dma_mask      = 0xffffffff,
83                 .platform_data          = &musb_plat,
84         },
85         .num_resources  = ARRAY_SIZE(musb_resources),
86         .resource       = musb_resources,
87 };
88
89 void __init sdp2430_usb_init(void)
90 {
91         if (platform_device_register(&musb_device) < 0) {
92                 printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
93                 return;
94         }
95 }
96