From patchwork Fri May 29 09:17:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ramneek mehresh X-Patchwork-Id: 477692 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D06F4140E56 for ; Fri, 29 May 2015 19:22:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 05BE44B617; Fri, 29 May 2015 11:22:00 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NGjgdWNRSPSi; Fri, 29 May 2015 11:21:59 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9C6CA4A039; Fri, 29 May 2015 11:21:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F12474A039 for ; Fri, 29 May 2015 11:21:56 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tGNcEEEyJnD5 for ; Fri, 29 May 2015 11:21:56 +0200 (CEST) X-Greylist: delayed 916 seconds by postgrey-1.34 at theia; Fri, 29 May 2015 11:21:52 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0135.outbound.protection.outlook.com [157.56.111.135]) by theia.denx.de (Postfix) with ESMTPS id 1F6134A033 for ; Fri, 29 May 2015 11:21:52 +0200 (CEST) Received: from BY2PR03CA051.namprd03.prod.outlook.com (10.141.249.24) by BY2PR0301MB1574.namprd03.prod.outlook.com (10.163.28.16) with Microsoft SMTP Server (TLS) id 15.1.172.22; Fri, 29 May 2015 09:06:31 +0000 Received: from BY2FFO11FD042.protection.gbl (2a01:111:f400:7c0c::181) by BY2PR03CA051.outlook.office365.com (2a01:111:e400:2c5d::24) with Microsoft SMTP Server (TLS) id 15.1.172.22 via Frontend Transport; Fri, 29 May 2015 09:06:31 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD042.mail.protection.outlook.com (10.1.14.227) with Microsoft SMTP Server (TLS) id 15.1.184.11 via Frontend Transport; Fri, 29 May 2015 09:06:31 +0000 Received: from localhost.ap.freescale.net (udp166559uds.ap.freescale.net [10.232.133.5]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t4T96CXT019459; Fri, 29 May 2015 02:06:29 -0700 From: Ramneek Mehresh To: Date: Fri, 29 May 2015 14:47:19 +0530 Message-ID: <1432891042-19781-6-git-send-email-ramneek.mehresh@freescale.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1432891042-19781-1-git-send-email-ramneek.mehresh@freescale.com> References: <1432891042-19781-1-git-send-email-ramneek.mehresh@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD042; 1:c4qLE/44rbrW4HIJghW0+7MTAieSRPAzdJU2ZyfTS69silXVLCVjWmraW03kfalaFEubKqDeSk/9sekLPACLIAt9tAZUaOaaNnY5Ih5znyq2YSQb4MdqkqxUW1EkvF3Xs9BqHGLBraOFbi1ZTngu3A0M1nZ/Is+bthdC9BsxSikXFqkCbLzwptX0fW/N5AFiHnC4iBD6K8+HQH6VD+qpP2xmg0Q11byx8am3WyiIm004Pu6XvWm50Dt02rwsJcmG43rYcFVsCsM2GTf/ulSbKCQ+Cbf+pBUvyEAknUMp/tr7DZfUwrIRZ9ZLtN0KoTaGt9tnsUSoSeZ2z5PVC1D+cA== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(199003)(189002)(107886002)(97736004)(110136002)(85426001)(6806004)(19580395003)(104016003)(229853001)(2351001)(33646002)(81156007)(4001540100001)(19580405001)(5001830100001)(77156002)(69596002)(76176999)(5001860100001)(106466001)(2950100001)(36756003)(47776003)(64706001)(46102003)(86362001)(50466002)(189998001)(105606002)(92566002)(76506005)(5001960100002)(87936001)(68736005)(62966003)(50986999)(48376002)(50226001)(77096005)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR0301MB1574; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1574; 2:tF+Qfq6DWEeoHzfVDb/+AMYO7LvO8xLuwNy/vJAAp9DwtLeREMceTEXmQQTZWx/8; 2:AZok8SzGlFq1G/ArNIe8NVhlpgdSpsy23DImJGR2+hSgS8jb/+sBi/ivL6cIEEwBnb2TO9mieRbGx7HcHHcvOwsVgTS9pfjIu+HZE+USc7w6zCKEFPInGiTFK1saNBZoWkCPwd9FZ54jWnpLbjL8TJYuj3mSfmfbI3EFadizcmx3JkrRR1kqoBC/eBacNoyQNlglXhlicXzQxa2aCeuTo37tUQ2PkmNizvmBdA2iwwM=; 6:ppskPi90H+6cgtfUIO/ngd78rLrSadycRYZSNfcE6+Q9aaSSiG9GlhIR0UkiynIwgCyIzT8voSUvhsAcHI/izqPNxNMDB+iaY3y05C3RdYuOoRV0aLHou+9oqyYlTPk3SYd8FfDiBjxz+XHSd8UR4F/Xduts6A4O3+TOL6/9byUJYFA1oz4ImezoWSqWF8bDd2FLyGtcAumbtYrXNcAlTBNzAS057Rc6ZU7h9Ff/yUIjdNG1L0rDNYK3aJW2P/TPjqux5Z+ZWS7O7kiQl+Bka20B1P0adj9mRhurLPSFXtU3KRGFX7WkpNwVH9Gforh5hUQ19m46LNiTpIIq/qG89A== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB1574; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(520003)(3002001); SRVR:BY2PR0301MB1574; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB1574; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1574; 3:tNdm9KTx+kiC4YhKJ9bUGjkkIBfZGAHrW3gMkc1zZ3Fg1MWF8cKe+P1rrMuo9Ct8IdczQF1vZusE2GGc44PJRF05iAbZy5O4j4njcHWBHo2I0Rp5zODYuSBdFyiomfDV9e4R8cE+XKXmTCom2vb/ExgzuFyRCmNS7WE+4Otu1lEN6aKLxBIkOZ0zjA04pAS9ZaiJA1SbsqkeuDZAPuXVPUHNrbXXpa7UnTChziy0FDevLyxlUbx3ckBEU1ClxUUTEU+fhvzcRRd7x9CTINZGo2nY0pN23NYGCEwelyaIJpN3ZiK9esUuYSZgLvNj7/MB X-Forefront-PRVS: 059185FE08 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB1574; 9:s6F1pOa8k/bRyImS3+kCW6PTBSaF/yw5FkvzGGbO?= =?us-ascii?Q?z0R7Rpp2+AVXis84MXefOYfSYq812KMt4DjoUCHXGIwDMVLeMAzi9O7Y3j97?= =?us-ascii?Q?b+mdYAJkgNOCYzHMMq1deLNBRhLJbzSZ8CkXqm74hjuB/ZKOsMi5V+tRzZIV?= =?us-ascii?Q?UKzclwVasqxduFODVEJgZs0MwLjd4bxuJUvsjuh67SrpA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lpmMc7ZEJhaYpAgU3d+c++wJp0uY4/g1ue6Y?= =?us-ascii?Q?oMBTWWt8BdwtCSMDQfqlmfTdOWW0cd/3?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1574; 3:jPonSwbpFyKASXAV5aZgk6lFICWEftvpXge4HbhZt+YKY11qW84Gz45xqDtHywuLH9myzg5Jam59LEvKji0tAdJZlP4mB6f7wFStJZUvaEH6IMcgOJJW+kA7830QRH2j6PDHMrBlIz0KqEzkz6yw1Q==; 10:7Vy96Sp8+y7xTmUXu/kBvNEYXfcQjOqjJOTpfhwpwxhPK+4ewQiZESaR3rfUhgmhffiEo06Rhdqqv+E4+euoTK8E1YHtnFo+EcmNzuVmZxo=; 6:5U5mw3Jj5EPyOxGkwftUEoUHmU/xa/lR/8HfthgZPqMH1u12/xzDnuf0kkiiO8Ei X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2015 09:06:31.4545 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB1574 Cc: marex@denx.de, ramneek mehresh , gautam.vivek@samsung.com Subject: [U-Boot] [PATCH 5/8] drivers:usb:fsl: Add XHCI driver support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: ramneek mehresh Add xhci driver support for all FSL socs Signed-off-by: Ramneek Mehresh Reviewed-by: Tom Rini --- drivers/usb/host/Makefile | 1 + drivers/usb/host/xhci-fsl.c | 109 +++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/xhci-fsl.h | 54 +++++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 drivers/usb/host/xhci-fsl.c create mode 100644 include/linux/usb/xhci-fsl.h diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 310d979..6cc3bbd 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -54,6 +54,7 @@ obj-$(CONFIG_USB_XHCI) += xhci.o xhci-mem.o xhci-ring.o obj-$(CONFIG_USB_XHCI_DWC3) += xhci-dwc3.o obj-$(CONFIG_USB_XHCI_KEYSTONE) += xhci-keystone.o obj-$(CONFIG_USB_XHCI_EXYNOS) += xhci-exynos5.o +obj-$(CONFIG_USB_XHCI_FSL) += xhci-fsl.o obj-$(CONFIG_USB_XHCI_OMAP) += xhci-omap.o obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o obj-$(CONFIG_USB_XHCI_UNIPHIER) += xhci-uniphier.o diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c new file mode 100644 index 0000000..f624c90 --- /dev/null +++ b/drivers/usb/host/xhci-fsl.c @@ -0,0 +1,109 @@ +/* + * Copyright 2015 Freescale Semiconductor, Inc. + * + * FSL USB HOST xHCI Controller + * + * Author: Ramneek Mehresh + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#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); + + 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 *)((uint32_t) *hccr + + HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase))); + + debug("fsl-xhci: init hccr %x and hcor %x hc_length %d\n", + (uint32_t)*hccr, (uint32_t)*hcor, + (uint32_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); +} diff --git a/include/linux/usb/xhci-fsl.h b/include/linux/usb/xhci-fsl.h new file mode 100644 index 0000000..8eaab2c --- /dev/null +++ b/include/linux/usb/xhci-fsl.h @@ -0,0 +1,54 @@ +/* + * Copyright 2015 Freescale Semiconductor, Inc. + * + * FSL USB HOST xHCI Controller + * + * Author: Ramneek Mehresh + * + * 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; +}; + +#endif /* _ASM_ARCH_XHCI_FSL_H_ */