summaryrefslogtreecommitdiff
path: root/arch/arm/plat-mxc/include/mach/fsl_usb.h
blob: d1235fc337ffe2da18b2ea52dc25d29ddcf0b6c5 (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
/*
 * Copyright 2005-2009 Freescale Semiconductor, Inc. All Rights Reserved.
 */

/*
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */

/*
 * USB Host side, platform-specific functionality.
 */

#include <linux/usb/fsl_xcvr.h>
#include <mach/arc_otg.h>

static void fsl_setup_phy(struct ehci_hcd *ehci,
			  enum fsl_usb2_phy_modes phy_mode,
			  int port_offset);

static inline void fsl_platform_usb_setup(struct ehci_hcd *ehci)
{
	struct fsl_usb2_platform_data *pdata;

	pdata = ehci_to_hcd(ehci)->self.controller->platform_data;
	fsl_setup_phy(ehci, pdata->phy_mode, 0);
}

static inline void fsl_platform_set_host_mode(struct usb_hcd *hcd)
{
	unsigned int temp;
	struct fsl_usb2_platform_data *pdata;

	pdata = hcd->self.controller->platform_data;

	if (pdata->xcvr_ops && pdata->xcvr_ops->set_host)
		pdata->xcvr_ops->set_host();

	/* set host mode */
	temp = readl(hcd->regs + 0x1a8);
	writel(temp | USBMODE_CM_HOST, hcd->regs + 0x1a8);
}

/* Needed for enable PP and i2c/serial transceivers */
static inline void
fsl_platform_set_vbus_power(struct fsl_usb2_platform_data *pdata, int on)
{
	u32 temp;

	/* HCSPARAMS */
	temp = readl(pdata->regs + 0x104);
	/* Port Power Control */
	if (temp & HCSPARAMS_PPC) {
		temp = readl(pdata->regs + FSL_SOC_USB_PORTSC1);
		if (on)
			temp |= PORT_POWER;
		else
			temp &= ~PORT_POWER;

		writel(temp, pdata->regs + FSL_SOC_USB_PORTSC1);
	}

	if (pdata->xcvr_ops && pdata->xcvr_ops->set_vbus_power)
		pdata->xcvr_ops->set_vbus_power(pdata->xcvr_ops, pdata, on);
}

/* Set USB AHB burst length for host */
static inline void fsl_platform_set_ahb_burst(struct usb_hcd *hcd)
{
	struct fsl_usb2_platform_data *pdata;
	unsigned int temp;

	pdata = hcd->self.controller->platform_data;
	if (pdata->change_ahb_burst) {
		temp = readl(hcd->regs + FSL_SOC_USB_SBUSCFG);
		writel((temp & (~(0x7))) | pdata->ahb_burst_mode,
			hcd->regs + FSL_SOC_USB_SBUSCFG);
	}

	/* Increase TX fifo threshold for USB+ATA for i.mx35 2.0 */
	if (cpu_is_mx35_rev(CHIP_REV_2_0) >= 1) {
		temp = readl(hcd->regs + FSL_SOC_USB_TXFILLTUNING);
		/* Change TX FIFO threshold to be 0x20 */
		writel((temp & (~(0x3f << 16))) | (0x20 << 16),
			hcd->regs + FSL_SOC_USB_TXFILLTUNING);
	}
}