]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/usb/musb/omap2430.c
18aba33c91985b09b3aaf40a09087b7208e987ce
[linux-2.6-omap-h63xx.git] / drivers / usb / musb / omap2430.c
1 /*
2  * Copyright (C) 2005-2006 by Texas Instruments
3  *
4  * This file is part of the Inventra Controller Driver for Linux.
5  *
6  * The Inventra Controller Driver for Linux is free software; you
7  * can redistribute it and/or modify it under the terms of the GNU
8  * General Public License version 2 as published by the Free Software
9  * Foundation.
10  *
11  * The Inventra Controller Driver for Linux is distributed in
12  * the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with The Inventra Controller Driver for Linux ; if not,
19  * write to the Free Software Foundation, Inc., 59 Temple Place,
20  * Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23 #include <linux/module.h>
24 #include <linux/kernel.h>
25 #include <linux/sched.h>
26 #include <linux/slab.h>
27 #include <linux/init.h>
28 #include <linux/list.h>
29 #include <linux/clk.h>
30
31 #include <asm/io.h>
32 #include <asm/mach-types.h>
33 #include <asm/arch/hardware.h>
34 #include <asm/arch/mux.h>
35
36 #include "musbdefs.h"
37 #include "omap2430.h"
38
39
40 static int dma_off;
41
42 void musb_platform_enable(struct musb *musb)
43 {
44         if (is_dma_capable() && dma_off)
45                 printk(KERN_WARNING "%s %s: dma not reactivated\n",
46                                 __FILE__, __FUNCTION__);
47         else
48                 dma_off = 1;
49 }
50
51 void musb_platform_disable(struct musb *musb)
52 {
53         if (is_dma_capable()) {
54                 printk(KERN_WARNING "%s %s: dma still active\n",
55                                 __FILE__, __FUNCTION__);
56                 dma_off = 1;
57         }
58 }
59
60 static void omap_vbus_power(struct musb *musb, int is_on, int sleeping)
61 {
62 }
63
64 static void omap_set_vbus(struct musb *musb, int is_on)
65 {
66         WARN_ON(is_on && is_peripheral_active(musb));
67         return omap_vbus_power(musb, is_on, 0);
68 }
69
70 int __init musb_platform_init(struct musb *musb)
71 {
72         /* Erratum - reset value of STP has pull-down.
73            Change it to pull-up. */
74         omap_cfg_reg(AE5_2430_USB0HS_STP);
75
76         /* start clock */
77         musb->clock = clk_get((struct device *)musb->controller, "usbhs_ick");
78         clk_enable(musb->clock);
79
80         omap_writel(omap_readl(OTG_INTERFSEL) | (1<<0), OTG_INTERFSEL);
81         omap_writel(omap_readl(OTG_SYSCONFIG) |
82                     ((1 << 12) | (1 << 3) | (1 << 2)),
83                     OTG_SYSCONFIG);
84
85         pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, "
86                         "sysstatus 0x%x, intrfsel 0x%x, simenable  0x%x\n",
87                         omap_readl(OTG_REVISION), omap_readl(OTG_SYSCONFIG),
88                         omap_readl(OTG_SYSSTATUS), omap_readl(OTG_INTERFSEL),
89                         omap_readl(OTG_SIMENABLE));
90
91         musb->board_set_vbus = omap_set_vbus;
92         omap_vbus_power(musb, musb->board_mode == MUSB_HOST, 1);
93
94         return 0;
95 }
96
97 int musb_platform_exit(struct musb *musb)
98 {
99         omap_vbus_power(musb, 0 /*off*/, 1);
100         clk_disable(musb->clock);
101
102         return 0;
103 }