2 * drivers/usb/musb/ubi32_usb.c
3 * Ubicom32 usb controller driver.
5 * (C) Copyright 2009, Ubicom, Inc.
6 * Copyright (C) 2005-2006 by Texas Instruments
8 * Derived from the Texas Instruments Inventra Controller Driver for Linux.
10 * This file is part of the Ubicom32 Linux Kernel Port.
12 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
13 * it and/or modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 2 of the
15 * License, or (at your option) any later version.
17 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
18 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
19 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
20 * the GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with the Ubicom32 Linux Kernel Port. If not,
24 * see <http://www.gnu.org/licenses/>.
26 * Ubicom32 implementation derived from (with many thanks):
31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/sched.h>
34 #include <linux/slab.h>
35 #include <linux/init.h>
36 #include <linux/list.h>
37 #include <linux/clk.h>
41 #include <asm/ip5000.h>
42 #include "musb_core.h"
44 void musb_platform_enable(struct musb
*musb
)
47 void musb_platform_disable(struct musb
*musb
)
51 int musb_platform_set_mode(struct musb
*musb
, u8 musb_mode
) {
55 static void ip5k_usb_hcd_vbus_power(struct musb
*musb
, int is_on
, int sleeping
)
59 static void ip5k_usb_hcd_set_vbus(struct musb
*musb
, int is_on
)
62 /* HDRC controls CPEN, but beware current surges during device
63 * connect. They can trigger transient overcurrent conditions
64 * that must be ignored.
67 devctl
= musb_readb(musb
->mregs
, MUSB_DEVCTL
);
71 musb
->xceiv
.default_a
= 1;
72 musb
->xceiv
.state
= OTG_STATE_A_WAIT_VRISE
;
73 devctl
|= MUSB_DEVCTL_SESSION
;
79 /* NOTE: we're skipping A_WAIT_VFALL -> A_IDLE and
80 * jumping right to B_IDLE...
83 musb
->xceiv
.default_a
= 0;
84 musb
->xceiv
.state
= OTG_STATE_B_IDLE
;
85 devctl
&= ~MUSB_DEVCTL_SESSION
;
89 musb_writeb(musb
->mregs
, MUSB_DEVCTL
, devctl
);
91 DBG(1, "VBUS %s, devctl %02x "
92 /* otg %3x conf %08x prcm %08x */ "\n",
93 otg_state_string(musb
),
94 musb_readb(musb
->mregs
, MUSB_DEVCTL
));
96 static int ip5k_usb_hcd_set_power(struct otg_transceiver
*x
, unsigned mA
)
101 static int musb_platform_resume(struct musb
*musb
);
103 int __init
musb_platform_init(struct musb
*musb
)
106 #ifdef CONFIG_UBICOM32_V4
109 "move.4 %0, CHIP_ID \n\t"
112 if (chip_id
== 0x30001) {
113 *((u32_t
*)(GENERAL_CFG_BASE
+ GEN_USB_PHY_TEST
)) &= ~(1 << 30);
115 *((u32_t
*)(GENERAL_CFG_BASE
+ GEN_USB_PHY_TEST
)) &= ~(1 << 31);
117 *((u32_t
*)(GENERAL_CFG_BASE
+ GEN_USB_PHY_TEST
)) &= ~(1 << 17);
119 *((u32_t
*)(GENERAL_CFG_BASE
+ GEN_USB_PHY_TEST
)) &= ~(1 << 14);
123 *((u32_t
*)(GENERAL_CFG_BASE
+ GEN_USB_PHY_CFG
)) |= ((1 << 14) | (1 <<15));
125 /* The i-clk is AUTO gated. Hence there is no need
126 * to disable it until the driver is shutdown */
128 clk_enable(musb
->clock
);
129 musb_platform_resume(musb
);
131 ip5k_usb_hcd_vbus_power(musb
, musb
->board_mode
== MUSB_HOST
, 1);
133 if (is_host_enabled(musb
))
134 musb
->board_set_vbus
= ip5k_usb_hcd_set_vbus
;
135 if (is_peripheral_enabled(musb
))
136 musb
->xceiv
.set_power
= ip5k_usb_hcd_set_power
;
142 int musb_platform_suspend(struct musb
*musb
)
146 int musb_platform_resume(struct musb
*musb
)
151 int musb_platform_exit(struct musb
*musb
)
153 ip5k_usb_hcd_vbus_power(musb
, 0 /*off*/, 1);
154 musb_platform_suspend(musb
);
This page took 0.04642 seconds and 5 git commands to generate.