summaryrefslogtreecommitdiff
path: root/drivers/usb/musb/omap3.c
blob: 3e502e7d853dd9e2ca9e766a28c31bbf8b7eef2e (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * Copyright (c) 2009 Wind River Systems, Inc.
 * Tom Rix <Tom.Rix@windriver.com>
 *
 * This is file is based on
 * repository git.gitorious.org/u-boot-omap3/mainline.git,
 * branch omap3-dev-usb, file drivers/usb/host/omap3530_usb.c
 *
 * This is the unique part of its copyright :
 *
 * ------------------------------------------------------------------------
 *
 * Copyright (c) 2009 Texas Instruments
 *
 * ------------------------------------------------------------------------
 *
 * 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 <twl4030.h>
#include "omap3.h"

static int platform_needs_initialization = 1;

struct musb_config musb_cfg = {
	(struct	musb_regs *)MENTOR_USB0_BASE,
	OMAP3_USB_TIMEOUT,
	0
};

/*
 * OMAP3 USB OTG registers.
 */
struct omap3_otg_regs {
	u32	revision;
	u32	sysconfig;
	u32	sysstatus;
	u32	interfsel;
	u32	simenable;
	u32	forcestdby;
};

static struct omap3_otg_regs *otg;

#define OMAP3_OTG_SYSCONFIG_SMART_STANDBY_MODE		0x2000
#define OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE		0x1000
#define OMAP3_OTG_SYSCONFIG_SMART_IDLE_MODE		0x0010
#define OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE		0x0008
#define OMAP3_OTG_SYSCONFIG_ENABLEWAKEUP		0x0004
#define OMAP3_OTG_SYSCONFIG_SOFTRESET			0x0002
#define OMAP3_OTG_SYSCONFIG_AUTOIDLE			0x0001

#define OMAP3_OTG_SYSSTATUS_RESETDONE			0x0001

#define OMAP3_OTG_INTERFSEL_OMAP			0x0001

#define OMAP3_OTG_FORCESTDBY_STANDBY			0x0001


#ifdef DEBUG_MUSB_OMAP3
static void musb_db_otg_regs(void)
{
	u32 l;
	l = readl(&otg->revision);
	serial_printf("OTG_REVISION 0x%x\n", l);
	l = readl(&otg->sysconfig);
	serial_printf("OTG_SYSCONFIG 0x%x\n", l);
	l = readl(&otg->sysstatus);
	serial_printf("OTG_SYSSTATUS 0x%x\n", l);
	l = readl(&otg->interfsel);
	serial_printf("OTG_INTERFSEL 0x%x\n", l);
	l = readl(&otg->forcestdby);
	serial_printf("OTG_FORCESTDBY 0x%x\n", l);
}
#endif

int musb_platform_init(void)
{
	int ret = -1;

	if (platform_needs_initialization) {
		u32 stdby;

		if (twl4030_usb_ulpi_init()) {
			serial_printf("ERROR: %s Could not initialize PHY\n",
				__PRETTY_FUNCTION__);
			goto end;
		}

		otg = (struct omap3_otg_regs *)OMAP3_OTG_BASE;

		/* Set OTG to always be on */
		writel(OMAP3_OTG_SYSCONFIG_NO_STANDBY_MODE |
		       OMAP3_OTG_SYSCONFIG_NO_IDLE_MODE, &otg->sysconfig);

		/* Set the interface */
		writel(OMAP3_OTG_INTERFSEL_OMAP, &otg->interfsel);

		/* Clear force standby */
		stdby = readl(&otg->forcestdby);
		stdby &= ~OMAP3_OTG_FORCESTDBY_STANDBY;
		writel(stdby, &otg->forcestdby);

		platform_needs_initialization = 0;
	}

	ret = platform_needs_initialization;
end:
	return ret;

}

void musb_platform_deinit(void)
{
	/* noop */
}