commit
6f4e050639
@ -0,0 +1,22 @@ |
||||
/*
|
||||
* Copyright 2015 Broadcom Corporation. |
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0+ |
||||
*/ |
||||
|
||||
#ifndef __BCM_UDC_OTG_H |
||||
#define __BCM_UDC_OTG_H |
||||
|
||||
#include <common.h> |
||||
|
||||
static inline void wfld_set(uintptr_t addr, uint32_t fld_val, uint32_t fld_mask) |
||||
{ |
||||
writel(((readl(addr) & ~(fld_mask)) | (fld_val)), (addr)); |
||||
} |
||||
|
||||
static inline void wfld_clear(uintptr_t addr, uint32_t fld_mask) |
||||
{ |
||||
writel((readl(addr) & ~(fld_mask)), (addr)); |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,51 @@ |
||||
/*
|
||||
* Copyright 2015 Broadcom Corporation. |
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0+ |
||||
*/ |
||||
|
||||
#include <config.h> |
||||
#include <common.h> |
||||
#include <asm/io.h> |
||||
#include <asm/arch/sysmap.h> |
||||
|
||||
#include <usb/s3c_udc.h> |
||||
#include "bcm_udc_otg.h" |
||||
|
||||
void otg_phy_init(struct s3c_udc *dev) |
||||
{ |
||||
/* set Phy to driving mode */ |
||||
wfld_clear(HSOTG_CTRL_BASE_ADDR + HSOTG_CTRL_PHY_P1CTL_OFFSET, |
||||
HSOTG_CTRL_PHY_P1CTL_NON_DRIVING_MASK); |
||||
|
||||
udelay(100); |
||||
|
||||
/* clear Soft Disconnect */ |
||||
wfld_clear(HSOTG_BASE_ADDR + HSOTG_DCTL_OFFSET, |
||||
HSOTG_DCTL_SFTDISCON_MASK); |
||||
|
||||
/* invoke Reset (active low) */ |
||||
wfld_clear(HSOTG_CTRL_BASE_ADDR + HSOTG_CTRL_PHY_P1CTL_OFFSET, |
||||
HSOTG_CTRL_PHY_P1CTL_SOFT_RESET_MASK); |
||||
|
||||
/* Reset needs to be asserted for 2ms */ |
||||
udelay(2000); |
||||
|
||||
/* release Reset */ |
||||
wfld_set(HSOTG_CTRL_BASE_ADDR + HSOTG_CTRL_PHY_P1CTL_OFFSET, |
||||
HSOTG_CTRL_PHY_P1CTL_SOFT_RESET_MASK, |
||||
HSOTG_CTRL_PHY_P1CTL_SOFT_RESET_MASK); |
||||
} |
||||
|
||||
void otg_phy_off(struct s3c_udc *dev) |
||||
{ |
||||
/* Soft Disconnect */ |
||||
wfld_set(HSOTG_BASE_ADDR + HSOTG_DCTL_OFFSET, |
||||
HSOTG_DCTL_SFTDISCON_MASK, |
||||
HSOTG_DCTL_SFTDISCON_MASK); |
||||
|
||||
/* set Phy to non-driving (reset) mode */ |
||||
wfld_set(HSOTG_CTRL_BASE_ADDR + HSOTG_CTRL_PHY_P1CTL_OFFSET, |
||||
HSOTG_CTRL_PHY_P1CTL_NON_DRIVING_MASK, |
||||
HSOTG_CTRL_PHY_P1CTL_NON_DRIVING_MASK); |
||||
} |
@ -0,0 +1,97 @@ |
||||
/*
|
||||
* Copyright 2015 Freescale Semiconductor, Inc. |
||||
* |
||||
* DWC3 controller driver |
||||
* |
||||
* Author: Ramneek Mehresh<ramneek.mehresh@freescale.com> |
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0+ |
||||
*/ |
||||
|
||||
#include <common.h> |
||||
#include <asm/io.h> |
||||
#include <linux/usb/dwc3.h> |
||||
|
||||
void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode) |
||||
{ |
||||
clrsetbits_le32(&dwc3_reg->g_ctl, |
||||
DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG), |
||||
DWC3_GCTL_PRTCAPDIR(mode)); |
||||
} |
||||
|
||||
void dwc3_phy_reset(struct dwc3 *dwc3_reg) |
||||
{ |
||||
/* Assert USB3 PHY reset */ |
||||
setbits_le32(&dwc3_reg->g_usb3pipectl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST); |
||||
|
||||
/* Assert USB2 PHY reset */ |
||||
setbits_le32(&dwc3_reg->g_usb2phycfg, DWC3_GUSB2PHYCFG_PHYSOFTRST); |
||||
|
||||
mdelay(100); |
||||
|
||||
/* Clear USB3 PHY reset */ |
||||
clrbits_le32(&dwc3_reg->g_usb3pipectl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST); |
||||
|
||||
/* Clear USB2 PHY reset */ |
||||
clrbits_le32(&dwc3_reg->g_usb2phycfg, DWC3_GUSB2PHYCFG_PHYSOFTRST); |
||||
} |
||||
|
||||
void dwc3_core_soft_reset(struct dwc3 *dwc3_reg) |
||||
{ |
||||
/* Before Resetting PHY, put Core in Reset */ |
||||
setbits_le32(&dwc3_reg->g_ctl, DWC3_GCTL_CORESOFTRESET); |
||||
|
||||
/* reset USB3 phy - if required */ |
||||
dwc3_phy_reset(dwc3_reg); |
||||
|
||||
/* After PHYs are stable we can take Core out of reset state */ |
||||
clrbits_le32(&dwc3_reg->g_ctl, DWC3_GCTL_CORESOFTRESET); |
||||
} |
||||
|
||||
int dwc3_core_init(struct dwc3 *dwc3_reg) |
||||
{ |
||||
u32 reg; |
||||
u32 revision; |
||||
unsigned int dwc3_hwparams1; |
||||
|
||||
revision = readl(&dwc3_reg->g_snpsid); |
||||
/* This should read as U3 followed by revision number */ |
||||
if ((revision & DWC3_GSNPSID_MASK) != 0x55330000) { |
||||
puts("this is not a DesignWare USB3 DRD Core\n"); |
||||
return -1; |
||||
} |
||||
|
||||
dwc3_core_soft_reset(dwc3_reg); |
||||
|
||||
dwc3_hwparams1 = readl(&dwc3_reg->g_hwparams1); |
||||
|
||||
reg = readl(&dwc3_reg->g_ctl); |
||||
reg &= ~DWC3_GCTL_SCALEDOWN_MASK; |
||||
reg &= ~DWC3_GCTL_DISSCRAMBLE; |
||||
switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc3_hwparams1)) { |
||||
case DWC3_GHWPARAMS1_EN_PWROPT_CLK: |
||||
reg &= ~DWC3_GCTL_DSBLCLKGTNG; |
||||
break; |
||||
default: |
||||
debug("No power optimization available\n"); |
||||
} |
||||
|
||||
/*
|
||||
* WORKAROUND: DWC3 revisions <1.90a have a bug |
||||
* where the device can fail to connect at SuperSpeed |
||||
* and falls back to high-speed mode which causes |
||||
* the device to enter a Connect/Disconnect loop |
||||
*/ |
||||
if ((revision & DWC3_REVISION_MASK) < 0x190a) |
||||
reg |= DWC3_GCTL_U2RSTECN; |
||||
|
||||
writel(reg, &dwc3_reg->g_ctl); |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
void dwc3_set_fladj(struct dwc3 *dwc3_reg, u32 val) |
||||
{ |
||||
setbits_le32(&dwc3_reg->g_fladj, GFLADJ_30MHZ_REG_SEL | |
||||
GFLADJ_30MHZ(val)); |
||||
} |
@ -0,0 +1,111 @@ |
||||
/*
|
||||
* Copyright 2015 Freescale Semiconductor, Inc. |
||||
* |
||||
* FSL USB HOST xHCI Controller |
||||
* |
||||
* Author: Ramneek Mehresh<ramneek.mehresh@freescale.com> |
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0+ |
||||
*/ |
||||
|
||||
#include <common.h> |
||||
#include <usb.h> |
||||
#include <asm-generic/errno.h> |
||||
#include <linux/compat.h> |
||||
#include <linux/usb/xhci-fsl.h> |
||||
#include <linux/usb/dwc3.h> |
||||
#include "xhci.h" |
||||
|
||||
/* Declare global data pointer */ |
||||
DECLARE_GLOBAL_DATA_PTR; |
||||
|
||||
static struct fsl_xhci fsl_xhci; |
||||
unsigned long ctr_addr[] = FSL_USB_XHCI_ADDR; |
||||
|
||||
__weak int __board_usb_init(int index, enum usb_init_type init) |
||||
{ |
||||
return 0; |
||||
} |
||||
|
||||
void usb_phy_reset(struct dwc3 *dwc3_reg) |
||||
{ |
||||
/* Assert USB3 PHY reset */ |
||||
setbits_le32(&dwc3_reg->g_usb3pipectl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST); |
||||
|
||||
/* Assert USB2 PHY reset */ |
||||
setbits_le32(&dwc3_reg->g_usb2phycfg, DWC3_GUSB2PHYCFG_PHYSOFTRST); |
||||
|
||||
mdelay(200); |
||||
|
||||
/* Clear USB3 PHY reset */ |
||||
clrbits_le32(&dwc3_reg->g_usb3pipectl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST); |
||||
|
||||
/* Clear USB2 PHY reset */ |
||||
clrbits_le32(&dwc3_reg->g_usb2phycfg, DWC3_GUSB2PHYCFG_PHYSOFTRST); |
||||
} |
||||
|
||||
static int fsl_xhci_core_init(struct fsl_xhci *fsl_xhci) |
||||
{ |
||||
int ret = 0; |
||||
|
||||
ret = dwc3_core_init(fsl_xhci->dwc3_reg); |
||||
if (ret) { |
||||
debug("%s:failed to initialize core\n", __func__); |
||||
return ret; |
||||
} |
||||
|
||||
/* We are hard-coding DWC3 core to Host Mode */ |
||||
dwc3_set_mode(fsl_xhci->dwc3_reg, DWC3_GCTL_PRTCAP_HOST); |
||||
|
||||
/* Set GFLADJ_30MHZ as 20h as per XHCI spec default value */ |
||||
dwc3_set_fladj(fsl_xhci->dwc3_reg, GFLADJ_30MHZ_DEFAULT); |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
static int fsl_xhci_core_exit(struct fsl_xhci *fsl_xhci) |
||||
{ |
||||
/*
|
||||
* Currently fsl socs do not support PHY shutdown from |
||||
* sw. But this support may be added in future socs. |
||||
*/ |
||||
return 0; |
||||
} |
||||
|
||||
int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor) |
||||
{ |
||||
struct fsl_xhci *ctx = &fsl_xhci; |
||||
int ret = 0; |
||||
|
||||
ctx->hcd = (struct xhci_hccr *)ctr_addr[index]; |
||||
ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + DWC3_REG_OFFSET); |
||||
|
||||
ret = board_usb_init(index, USB_INIT_HOST); |
||||
if (ret != 0) { |
||||
puts("Failed to initialize board for USB\n"); |
||||
return ret; |
||||
} |
||||
|
||||
ret = fsl_xhci_core_init(ctx); |
||||
if (ret < 0) { |
||||
puts("Failed to initialize xhci\n"); |
||||
return ret; |
||||
} |
||||
|
||||
*hccr = (struct xhci_hccr *)ctx->hcd; |
||||
*hcor = (struct xhci_hcor *)((uintptr_t) *hccr |
||||
+ HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase))); |
||||
|
||||
debug("fsl-xhci: init hccr %lx and hcor %lx hc_length %lx\n", |
||||
(uintptr_t)*hccr, (uintptr_t)*hcor, |
||||
(uintptr_t)HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase))); |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
void xhci_hcd_stop(int index) |
||||
{ |
||||
struct fsl_xhci *ctx = &fsl_xhci; |
||||
|
||||
fsl_xhci_core_exit(ctx); |
||||
} |
@ -0,0 +1,64 @@ |
||||
/*
|
||||
* Copyright 2015 Freescale Semiconductor, Inc. |
||||
* |
||||
* FSL USB HOST xHCI Controller |
||||
* |
||||
* Author: Ramneek Mehresh<ramneek.mehresh@freescale.com> |
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0+ |
||||
*/ |
||||
|
||||
#ifndef _ASM_ARCH_XHCI_FSL_H_ |
||||
#define _ASM_ARCH_XHCI_FSL_H_ |
||||
|
||||
/* Default to the FSL XHCI defines */ |
||||
#define USB3_PWRCTL_CLK_CMD_MASK 0x3FE000 |
||||
#define USB3_PWRCTL_CLK_FREQ_MASK 0xFFC |
||||
#define USB3_PHY_PARTIAL_RX_POWERON BIT(6) |
||||
#define USB3_PHY_RX_POWERON BIT(14) |
||||
#define USB3_PHY_TX_POWERON BIT(15) |
||||
#define USB3_PHY_TX_RX_POWERON (USB3_PHY_RX_POWERON | USB3_PHY_TX_POWERON) |
||||
#define USB3_PWRCTL_CLK_CMD_SHIFT 14 |
||||
#define USB3_PWRCTL_CLK_FREQ_SHIFT 22 |
||||
|
||||
/* USBOTGSS_WRAPPER definitions */ |
||||
#define USBOTGSS_WRAPRESET BIT(17) |
||||
#define USBOTGSS_DMADISABLE BIT(16) |
||||
#define USBOTGSS_STANDBYMODE_NO_STANDBY BIT(4) |
||||
#define USBOTGSS_STANDBYMODE_SMRT BIT(5) |
||||
#define USBOTGSS_STANDBYMODE_SMRT_WKUP (0x3 << 4) |
||||
#define USBOTGSS_IDLEMODE_NOIDLE BIT(2) |
||||
#define USBOTGSS_IDLEMODE_SMRT BIT(3) |
||||
#define USBOTGSS_IDLEMODE_SMRT_WKUP (0x3 << 2) |
||||
|
||||
/* USBOTGSS_IRQENABLE_SET_0 bit */ |
||||
#define USBOTGSS_COREIRQ_EN BIT(1) |
||||
|
||||
/* USBOTGSS_IRQENABLE_SET_1 bits */ |
||||
#define USBOTGSS_IRQ_SET_1_IDPULLUP_FALL_EN BIT(1) |
||||
#define USBOTGSS_IRQ_SET_1_DISCHRGVBUS_FALL_EN BIT(3) |
||||
#define USBOTGSS_IRQ_SET_1_CHRGVBUS_FALL_EN BIT(4) |
||||
#define USBOTGSS_IRQ_SET_1_DRVVBUS_FALL_EN BIT(5) |
||||
#define USBOTGSS_IRQ_SET_1_IDPULLUP_RISE_EN BIT(8) |
||||
#define USBOTGSS_IRQ_SET_1_DISCHRGVBUS_RISE_EN BIT(11) |
||||
#define USBOTGSS_IRQ_SET_1_CHRGVBUS_RISE_EN BIT(12) |
||||
#define USBOTGSS_IRQ_SET_1_DRVVBUS_RISE_EN BIT(13) |
||||
#define USBOTGSS_IRQ_SET_1_OEVT_EN BIT(16) |
||||
#define USBOTGSS_IRQ_SET_1_DMADISABLECLR_EN BIT(17) |
||||
|
||||
struct fsl_xhci { |
||||
struct xhci_hccr *hcd; |
||||
struct dwc3 *dwc3_reg; |
||||
}; |
||||
|
||||
#if defined(CONFIG_LS102XA) |
||||
#define CONFIG_SYS_FSL_XHCI_USB1_ADDR CONFIG_SYS_LS102XA_XHCI_USB1_ADDR |
||||
#define CONFIG_SYS_FSL_XHCI_USB2_ADDR 0 |
||||
#elif defined(CONFIG_LS2085A) |
||||
#define CONFIG_SYS_FSL_XHCI_USB1_ADDR CONFIG_SYS_LS2085A_XHCI_USB1_ADDR |
||||
#define CONFIG_SYS_FSL_XHCI_USB2_ADDR CONFIG_SYS_LS2085A_XHCI_USB2_ADDR |
||||
#endif |
||||
|
||||
#define FSL_USB_XHCI_ADDR {CONFIG_SYS_FSL_XHCI_USB1_ADDR, \ |
||||
CONFIG_SYS_FSL_XHCI_USB2_ADDR} |
||||
#endif /* _ASM_ARCH_XHCI_FSL_H_ */ |
Loading…
Reference in new issue