2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2010-10-06 07:00:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <usb.h>
|
|
|
|
#include <asm/io.h>
|
2011-03-14 14:43:56 +00:00
|
|
|
#include <asm/arch/imx-regs.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2016-03-31 21:12:23 +00:00
|
|
|
#include <usb/ehci-ci.h>
|
2010-10-06 07:00:01 +00:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "ehci.h"
|
|
|
|
|
|
|
|
#define USBCTRL_OTGBASE_OFFSET 0x600
|
|
|
|
|
2012-11-13 09:57:48 +00:00
|
|
|
#define MX25_OTG_SIC_SHIFT 29
|
|
|
|
#define MX25_OTG_SIC_MASK (0x3 << MX25_OTG_SIC_SHIFT)
|
|
|
|
#define MX25_OTG_PM_BIT (1 << 24)
|
|
|
|
#define MX25_OTG_PP_BIT (1 << 11)
|
|
|
|
#define MX25_OTG_OCPOL_BIT (1 << 3)
|
|
|
|
|
|
|
|
#define MX25_H1_SIC_SHIFT 21
|
|
|
|
#define MX25_H1_SIC_MASK (0x3 << MX25_H1_SIC_SHIFT)
|
|
|
|
#define MX25_H1_PP_BIT (1 << 18)
|
2012-11-16 06:46:24 +00:00
|
|
|
#define MX25_H1_PM_BIT (1 << 16)
|
2012-11-13 09:57:48 +00:00
|
|
|
#define MX25_H1_IPPUE_UP_BIT (1 << 7)
|
|
|
|
#define MX25_H1_IPPUE_DOWN_BIT (1 << 6)
|
|
|
|
#define MX25_H1_TLL_BIT (1 << 5)
|
|
|
|
#define MX25_H1_USBTE_BIT (1 << 4)
|
|
|
|
#define MX25_H1_OCPOL_BIT (1 << 2)
|
2011-07-06 00:28:30 +00:00
|
|
|
|
2010-10-06 07:00:01 +00:00
|
|
|
#define MX31_OTG_SIC_SHIFT 29
|
|
|
|
#define MX31_OTG_SIC_MASK (0x3 << MX31_OTG_SIC_SHIFT)
|
|
|
|
#define MX31_OTG_PM_BIT (1 << 24)
|
|
|
|
|
|
|
|
#define MX31_H2_SIC_SHIFT 21
|
|
|
|
#define MX31_H2_SIC_MASK (0x3 << MX31_H2_SIC_SHIFT)
|
|
|
|
#define MX31_H2_PM_BIT (1 << 16)
|
|
|
|
#define MX31_H2_DT_BIT (1 << 5)
|
|
|
|
|
|
|
|
#define MX31_H1_SIC_SHIFT 13
|
|
|
|
#define MX31_H1_SIC_MASK (0x3 << MX31_H1_SIC_SHIFT)
|
|
|
|
#define MX31_H1_PM_BIT (1 << 8)
|
|
|
|
#define MX31_H1_DT_BIT (1 << 4)
|
|
|
|
|
2012-11-13 09:58:12 +00:00
|
|
|
#define MX35_OTG_SIC_SHIFT 29
|
|
|
|
#define MX35_OTG_SIC_MASK (0x3 << MX35_OTG_SIC_SHIFT)
|
|
|
|
#define MX35_OTG_PM_BIT (1 << 24)
|
|
|
|
#define MX35_OTG_PP_BIT (1 << 11)
|
|
|
|
#define MX35_OTG_OCPOL_BIT (1 << 3)
|
|
|
|
|
|
|
|
#define MX35_H1_SIC_SHIFT 21
|
|
|
|
#define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT)
|
|
|
|
#define MX35_H1_PP_BIT (1 << 18)
|
2012-11-16 01:42:49 +00:00
|
|
|
#define MX35_H1_PM_BIT (1 << 16)
|
2012-11-13 09:58:12 +00:00
|
|
|
#define MX35_H1_IPPUE_UP_BIT (1 << 7)
|
|
|
|
#define MX35_H1_IPPUE_DOWN_BIT (1 << 6)
|
|
|
|
#define MX35_H1_TLL_BIT (1 << 5)
|
|
|
|
#define MX35_H1_USBTE_BIT (1 << 4)
|
|
|
|
#define MX35_H1_OCPOL_BIT (1 << 2)
|
|
|
|
|
2010-10-06 07:00:01 +00:00
|
|
|
static int mxc_set_usbcontrol(int port, unsigned int flags)
|
|
|
|
{
|
|
|
|
unsigned int v;
|
2011-07-06 00:28:30 +00:00
|
|
|
|
2012-11-13 09:55:57 +00:00
|
|
|
v = readl(IMX_USB_BASE + USBCTRL_OTGBASE_OFFSET);
|
2021-09-09 11:54:50 +00:00
|
|
|
#if defined(CONFIG_MX31)
|
2012-11-13 09:55:57 +00:00
|
|
|
switch (port) {
|
|
|
|
case 0: /* OTG port */
|
|
|
|
v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
|
|
|
|
v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX31_OTG_SIC_SHIFT;
|
|
|
|
|
|
|
|
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
|
|
|
|
v |= MX31_OTG_PM_BIT;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 1: /* H1 port */
|
|
|
|
v &= ~(MX31_H1_SIC_MASK | MX31_H1_PM_BIT | MX31_H1_DT_BIT);
|
|
|
|
v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX31_H1_SIC_SHIFT;
|
2011-07-06 00:28:30 +00:00
|
|
|
|
2012-11-13 09:55:57 +00:00
|
|
|
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
|
|
|
|
v |= MX31_H1_PM_BIT;
|
|
|
|
|
|
|
|
if (!(flags & MXC_EHCI_TTL_ENABLED))
|
|
|
|
v |= MX31_H1_DT_BIT;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 2: /* H2 port */
|
|
|
|
v &= ~(MX31_H2_SIC_MASK | MX31_H2_PM_BIT | MX31_H2_DT_BIT);
|
|
|
|
v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX31_H2_SIC_SHIFT;
|
|
|
|
|
|
|
|
if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
|
|
|
|
v |= MX31_H2_PM_BIT;
|
|
|
|
|
|
|
|
if (!(flags & MXC_EHCI_TTL_ENABLED))
|
|
|
|
v |= MX31_H2_DT_BIT;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#error MXC EHCI USB driver not supported on this platform
|
|
|
|
#endif
|
2011-07-06 00:28:30 +00:00
|
|
|
writel(v, IMX_USB_BASE + USBCTRL_OTGBASE_OFFSET);
|
2012-11-13 09:55:57 +00:00
|
|
|
|
2011-07-06 00:28:30 +00:00
|
|
|
return 0;
|
2010-10-06 07:00:01 +00:00
|
|
|
}
|
|
|
|
|
2013-10-10 22:27:57 +00:00
|
|
|
int ehci_hcd_init(int index, enum usb_init_type init,
|
|
|
|
struct ehci_hccr **hccr, struct ehci_hcor **hcor)
|
2010-10-06 07:00:01 +00:00
|
|
|
{
|
|
|
|
struct usb_ehci *ehci;
|
2011-07-06 00:28:30 +00:00
|
|
|
#ifdef CONFIG_MX31
|
2010-10-06 07:00:01 +00:00
|
|
|
struct clock_control_regs *sc_regs =
|
|
|
|
(struct clock_control_regs *)CCM_BASE;
|
|
|
|
|
2011-11-19 10:10:33 +00:00
|
|
|
__raw_readl(&sc_regs->ccmr);
|
2010-10-06 07:00:01 +00:00
|
|
|
__raw_writel(__raw_readl(&sc_regs->ccmr) | (1 << 9), &sc_regs->ccmr) ;
|
2011-07-06 00:28:30 +00:00
|
|
|
#endif
|
2010-10-06 07:00:01 +00:00
|
|
|
|
|
|
|
udelay(80);
|
|
|
|
|
2011-07-06 00:28:30 +00:00
|
|
|
ehci = (struct usb_ehci *)(IMX_USB_BASE +
|
2012-11-13 09:57:59 +00:00
|
|
|
IMX_USB_PORT_OFFSET * CONFIG_MXC_USB_PORT);
|
2012-09-25 22:14:35 +00:00
|
|
|
*hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength);
|
|
|
|
*hcor = (struct ehci_hcor *)((uint32_t) *hccr +
|
|
|
|
HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
|
2010-10-06 07:00:01 +00:00
|
|
|
setbits_le32(&ehci->usbmode, CM_HOST);
|
|
|
|
__raw_writel(CONFIG_MXC_USB_PORTSC, &ehci->portsc);
|
|
|
|
mxc_set_usbcontrol(CONFIG_MXC_USB_PORT, CONFIG_MXC_USB_FLAGS);
|
|
|
|
|
2010-10-18 08:23:05 +00:00
|
|
|
udelay(10000);
|
|
|
|
|
2010-10-06 07:00:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Destroy the appropriate control structures corresponding
|
|
|
|
* the the EHCI host controller.
|
|
|
|
*/
|
2012-09-25 22:14:35 +00:00
|
|
|
int ehci_hcd_stop(int index)
|
2010-10-06 07:00:01 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|