summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/u8500_udc.c
blob: 109e11ddabfe73872cc4664a915d3fbff29f60b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * u8500_udc.c - 
 *
 * (C) Copyright 2009 ST-Ericsson
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307	 USA
 *
 */

#include <common.h>
#include "u8500_udc.h"
#include <asm/arch/gpio.h>

static volatile struct mg_dev_register *pRegs = 0;

int udc_musb_platform_init(void)
{
	u16 top;
	u8 power;
	u8 soft_reset;
	u16	temp;
	pRegs = (volatile struct mg_dev_register *) CONFIG_USB_BASE;
	
	gpio_altfuncenable(GPIO_ALT_USB_OTG, "USB-OTG");

	top =  pRegs->OTG_TOPCTRL;
	pRegs->OTG_TOPCTRL = (top | MODE_ULPI);

	soft_reset =  pRegs->OTG_SOFTRST;
	pRegs->OTG_SOFTRST = (soft_reset | 0x2);

	power = pRegs->OTG_PWR;
	/* Enabling high speed and soft connection */
	power = power | POWER_HSENAB;
	pRegs->OTG_PWR = (power | POWER_SOFTCONN);

	pRegs->OTG_INTUSBEN = 0x0;
	pRegs->OTG_INTTXEN  = 0x0;
	pRegs->OTG_INTRXEN  = 0x0;

	/* off */
	pRegs->OTG_DEVCTL  = 0x0;

	/*  flush pending interrupts */
	temp = pRegs->OTG_INTUSB;
	temp = pRegs->OTG_INTTX;
	temp = pRegs->OTG_INTRX;
	return 0;
}