From nobody Mon Dec 23 18:08:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515407781227251.5167935205834; Mon, 8 Jan 2018 02:36:21 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2D693222A54DC; Mon, 8 Jan 2018 02:31:09 -0800 (PST) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0055.outbound.protection.outlook.com [104.47.37.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 539E9222A54D2 for ; Mon, 8 Jan 2018 02:31:07 -0800 (PST) Received: from MWHPR03CA0044.namprd03.prod.outlook.com (10.174.173.161) by BN6PR03MB2690.namprd03.prod.outlook.com (10.173.144.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.366.8; Mon, 8 Jan 2018 10:36:15 +0000 Received: from BN1AFFO11FD014.protection.gbl (2a01:111:f400:7c10::156) by MWHPR03CA0044.outlook.office365.com (2603:10b6:301:3b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.386.5 via Frontend Transport; Mon, 8 Jan 2018 10:36:15 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD014.mail.protection.outlook.com (10.58.52.74) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Mon, 8 Jan 2018 10:35:45 +0000 Received: from uefi-OptiPlex-790.ap.freescale.net (uefi-OptiPlex-790.ap.freescale.net [10.232.132.78]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w08Aa7wR005473; Mon, 8 Jan 2018 03:36:12 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.37.55; helo=nam02-cy1-obe.outbound.protection.outlook.com; envelope-from=meenakshi.aggarwal@nxp.com; receiver=edk2-devel@lists.01.org Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; From: Meenakshi Aggarwal To: , , , Date: Mon, 8 Jan 2018 21:54:06 +0530 Message-ID: <1515428647-26811-2-git-send-email-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1515428647-26811-1-git-send-email-meenakshi.aggarwal@nxp.com> References: <1515428647-26811-1-git-send-email-meenakshi.aggarwal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131598813455774225; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(39380400002)(346002)(396003)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(2906002)(50226002)(53376002)(76176011)(2201001)(68736007)(36756003)(498600001)(966005)(4326008)(8936002)(97736004)(105606002)(110136005)(8656006)(85426001)(53936002)(16586007)(51416003)(54906003)(106466001)(316002)(59450400001)(5660300001)(77096006)(86362001)(305945005)(2950100002)(575784001)(104016004)(47776003)(16799955002)(6306002)(15188155005)(81156014)(81166006)(6666003)(48376002)(356003)(50466002)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2690; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD014; 1:4TQsT2ahZQKsRvevI/tqTeFpAJldWZBbRkOApljWLQeTEsKg7Ks+e3uTDRmZXEaZfJfvTUDbkPq+pAjz1+C4PHw2+z5RBIgGd2N4UxlyOEAmS73PbIm/9sehIFqtFXGB MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: e8a5774c-5567-485a-90b2-08d556839359 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603307); SRVR:BN6PR03MB2690; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2690; 3:Jp54jEXtCAMw6ue7S8FfmTRLfLJo1TZMwAtkQNlr0AHxrSxkFIs7DqxRJWFgTyNl85xcXqyy/lJnJhdOC5MPjHUTOtBapF9o1pbjlb69lWqqncJ39VmER7cgOgVOhcSiy8YbGKHcw0FPsDtuHYOi1rE2eGXkofeWgLC1mKOK/1zGhsS3CrRjgb0ucVIQDIn58o8jkRyEx/uOJRrtZxhEvVJ6lvp5XeZoHoQwhmrdoC1aas36j072mSUzhqhxudu7M8C1BMeIgGgPf+3vKz+F/K30/bA65IZJLdsLKgJezb5Oi1xUy9G/mSrJHRnoVTe1nB102ERS0RQBgwRN4GDPzLu2jlasNoAp8GUdL0KTQRs=; 25:XPlsT9RlDsZjiIes3DVklKqddlckILMfzyv/pwZMDYnO8AXebXijzT26/Bay24hUVrBPYOMdQXuQt4TTHAjxM3cTxeZHec+rplVswFeF2Z3i8IXBy0taH46Wcwx0D3rjhr2sKZ1ks30wFFhmK8bD67WA6LCNet8Juvb1hRQ89MaAfkMIbH+CDkvfeV5jSD/IMBfF8wtIJX57rO2bI/pBQj1bCu2WqljSYQdp+yKwM5vdzppyS2YEvVqDm14A0GlqEUfJD+ADkDb/65Z2/lZzYk4SMsRY2J2vgR0Xsq+7PVddMaL4M3sE4UM73kB3nst7aMbRMvNSJsfTUIDn6rwMSg== X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN6PR03MB2690: X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2690; 31:4LPzKERhheb96quRxIzRFZV50w9cTotSeyLIfW63Un4q4vXJKhZmuLQastc+hC6egWo+k0gDKn+nwL/iyK5JIJ9nzys+chx+s9SHJZtLwYe2wNXJK1O+lRr33pbfPVGOjbm2itzRLm2hn55jsyPP9W/im3N7MbwWGRH+3fo6iyvuTMbsHZRnrnHcDprxOSvNlBmOzo61RsIRvMJslsRTmwXXxPgjZo+lKvJIA56lfsg=; 4:FWu8efEsJKBpwlBuUrnFc8cuiE80qqmUUyZJmxBsWw83IlMLf25Wz/1GsYWYr7D3NCqaH5k2QB5zzO5EJge8dibKRN+WqQ8UpbbJ9hTSP28roP4Mlxw17TD324QSzmb6ORrbZu+WzQen3IqEpd5gVf2H89fMMugx+LzizGgKV6Vj0mTgYG9lKVKZpSeHY7hF3EmU7LmknrrPm8mgP8qpkwr42sf8FmB0sJ74fOoBes+mU3HT6YWckFXJGBKs+Fd8KQFklY8LbvHqLXXb73iOMry3aj1m+etIntFl5ClUmX3KsIkRXDLGxNdgLup7qT3S X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(3231023)(944510075)(944921075)(946801075)(946901075)(3002001)(10201501046)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123559100)(20161123563025)(20161123561025)(20161123565025)(20161123556025)(201708071742011); SRVR:BN6PR03MB2690; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BN6PR03MB2690; X-Forefront-PRVS: 054642504A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB2690; 23:TgeJEjv5V3631Kqeo/NJkWkzUwsS81uyyYfu+JwuX?= =?us-ascii?Q?2vGkGkaJ1VvT5LbCBZ54XvnsiTi248Fuaky14qnTANUvzdjCBqOiOG1/tH95?= =?us-ascii?Q?IDasXw2jKR+C7ZuATi4tQFDWbYb61+5propr5v2Z1A1qZkTwQBhHPQr2IKCI?= =?us-ascii?Q?oWHoBUuHlf9AmKc7AdKJbNz2+QbmF33EvJq5J9WTZp4Oo271+0SLr1Trz/Ia?= =?us-ascii?Q?CYZL6Ka0t42euefu3tUMaFXq6g6TmVhl4hY+qv1d+Xx+R9BOnAViA6a+hmgT?= =?us-ascii?Q?o9HPvvGfDTf4I9p7po7waZTJSk6yfdLLjYjKVo/FnriSiCRRf+PSjZ+O2Bul?= =?us-ascii?Q?xZmFn4hFXkMX83FYAEFODQiaijdILJzmEgIG9GtxkvM4b2YD55lBAGVCHbYK?= =?us-ascii?Q?kYunEW6CHn2UNrWQpfqwcpi0Fx6eJROtJV6F5oSt8bEQ5GPwB04bzDJ6XuTm?= =?us-ascii?Q?W57Lp6swC7AVlGgXUcR3POicC0BYxBYlnPXjfjSbAIu9xRvRQher4faiizSp?= =?us-ascii?Q?9jtWW21QzmEV+Fc1oFY9BIDAumqdQBe+GBwS2abCZLfcy61o5+A/27K/CJyM?= =?us-ascii?Q?9Ce61IDHe+p396o5XRl08O7yfP8Fy1xWNmlhvMJJWrsx0LML04tIQUYUm8MJ?= =?us-ascii?Q?7wd+V7C+g0mljYHvaYUAXIT5Z06DNo8W2EFSCruQAeVYb4Z7Zr9eSm68PId8?= =?us-ascii?Q?4oHBexaa7g7G8zEiea2Gc8u+7CRyC55dF+qWQ8kWDoWMwyUCBHu44qusH2ZA?= =?us-ascii?Q?uEqHKD2JyRhLXIGkUEqBURWd0TyXjl62q87FIqmcBCUzIixWSDbUDHTJA8up?= =?us-ascii?Q?VNTk5Fs9QdIUNz1uXWQwQYUSKjRnKaXrpLNf1L7wg8tFFnX+6ekk0sUJ+wmT?= =?us-ascii?Q?dFoU1L7ShlN2LVfuVdm/2U4CBxfpIduLuZ1PE2dURCi/jcKG3xfgTkpVvQIv?= =?us-ascii?Q?Ojpxo+4OxYKakSqOz1AkA8CIJ64cd7K1iaeO2OdAw52LBJini1CSf+44XywN?= =?us-ascii?Q?FL5Bf9dV4w4d5L/to/3g7qX1B+ycDZ3ReMZRYPXrCe1ddNJJahw+0YGlNi1i?= =?us-ascii?Q?CAQbzjgp7qD5U09su1rjOvfxTri55HUuBbq7p8JanzmHDJfms3YM6vhOUqtc?= =?us-ascii?Q?GRR9Vk2U6x6V2IlRtvCaezTGQYQn+5ZTuGyF7Xn4UuybJRwTmZXUaoakgiZH?= =?us-ascii?Q?1mDZT9LXIJT4CkQOXZZG9EunJY7wIhiecAVFP9ayMT+JDkCitiBamPr5Q=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2690; 6:6zBUnE3pgRx7Y08XGnK0qWokXFM49i6Txpw9d5/5R3sF7Qx4X3rfnwGTlYr2Y+W12z5kVjBsunwn6Q4hwlisWbtraasa8T7EdnlS1YkgoR7F4XLo06M8yfwH6358zh/6LihJ/5fdP5lj1H71OWNh77+MTYngX7VQuSYPenyXT3pKwfuIyZauXi4VVTfZtrm5tI+xKoVoDqeLUMWU5FR9HIJiDxf1DMseEmfki09QLNiXMbYX2SuKfWT4fiygmio0MU6N7KU06aWNEa1KhgwkC/ooxoFIYKVxGEuGeQRiDpa8b4XExk5qtFS9g1xeym0JLIJjux3YbrO0o8TkIf4tiIGHxaaMQn7RunebSR9jzvM=; 5:XxLHoW06/y8bmJ5qKe9QaEkk/E3BUkB5v9a1JOujO4HfgCCzAUcXvQDVGAZGHxiQItFpraPLNBBUtySxyKYchQCuKecs2e8yNDlrGFwFQ41pbi3ebgK+c6UNxHjAStBWlwKbQb68+VdrjtBqDyGu5wO0ErYCphnfmLSSxfOxcBw=; 24:FBtaU43oBqYC8DUL+/AY72hfGcNIC6R6VTx3aTV6LtCY0AbSx5KT3K3Qx7Q5huKjDiJiK1GnedH2FFDRdDTmWnG/aknTb6dkKAsUDOk81d0=; 7:ic6jZU4/QhZ3rr0PFSMnFEsbMP2GWLSLQO2Vm/ADtDuG4pn3HFlmewsOSzqpn1H0AeNx5djUTFRLYlu7u9jUqYjbxc9g8prO9HndIMMfiNH54yxJgGA5+qRCjHvbil+Frq9MQE8v0aWS9kjLQF2oi2yXj17MaqKxyznC8Wkjhtf/8cHM1AeEb1cRkrSfYVw+e0XvCN3SOSaamRdLHsl4dtYsG1v4lJRQsWXzrmHnIDFzYapTTsqZjMlkG7Ww9RVR SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2018 10:35:45.3902 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e8a5774c-5567-485a-90b2-08d556839359 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2690 Subject: [edk2] [PATCH edk2-platforms 1/2] USB : Add DWC3 USB controller initialization driver. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add support of DWC3 controller driver which Performs DWC3 controller initialization and Register itself as NonDiscoverableMmioDevice Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Meenakshi Aggarwal --- Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c | 213 ++++++++++++++++++++++= ++++ Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h | 142 +++++++++++++++++ Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf | 48 ++++++ Platform/NXP/NxpQoriqLs.dsc | 9 ++ 4 files changed, 412 insertions(+) create mode 100644 Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c create mode 100644 Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h create mode 100644 Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf diff --git a/Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c b/Platform/NXP/Dri= vers/UsbHcdInitDxe/UsbHcd.c new file mode 100644 index 0000000..179e9b6 --- /dev/null +++ b/Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c @@ -0,0 +1,213 @@ +/** @file + + Copyright 2017 NXP + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include +#include +#include +#include + +#include "UsbHcd.h" + +VOID +XhciSetBeatBurstLength ( + IN UINTN UsbReg + ) +{ + Dwc3 *Dwc3Reg; + + Dwc3Reg =3D (VOID *)(UsbReg + DWC3_REG_OFFSET); + + MmioAndThenOr32 ((UINTN)&Dwc3Reg->GSBusCfg0, ~USB3_ENABLE_BEAT_BURST_MAS= K, + USB3_ENABLE_BEAT_BURST); + MmioOr32 ((UINTN)&Dwc3Reg->GSBusCfg1, USB3_SET_BEAT_BURST_LIMIT); + + return; +} + +VOID +Dwc3SetFladj ( + IN Dwc3 *Dwc3Reg, + IN UINT32 Val + ) +{ + MmioOr32 ((UINTN)&Dwc3Reg->GFLAdj, GFLADJ_30MHZ_REG_SEL | + GFLADJ_30MHZ(Val)); +} + +VOID +Dwc3SetMode ( + IN Dwc3 *Dwc3Reg, + IN UINT32 Mode + ) +{ + MmioAndThenOr32 ((UINTN)&Dwc3Reg->GCtl, + ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)), + DWC3_GCTL_PRTCAPDIR(Mode)); +} + +VOID +Dwc3CoreSoftReset ( + IN Dwc3 *Dwc3Reg + ) +{ + MmioOr32 ((UINTN)&Dwc3Reg->GCtl, DWC3_GCTL_CORESOFTRESET); + MmioOr32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST= ); + MmioOr32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, DWC3_GUSB2PHYCFG_PHYSOFTRST); + MmioAnd32 ((UINTN)&Dwc3Reg->GUsb3PipeCtl[0], ~DWC3_GUSB3PIPECTL_PHYSOFTR= ST); + MmioAnd32 ((UINTN)&Dwc3Reg->GUsb2PhyCfg, ~DWC3_GUSB2PHYCFG_PHYSOFTRST); + MmioAnd32 ((UINTN)&Dwc3Reg->GCtl, ~DWC3_GCTL_CORESOFTRESET); + + return; +} + +EFI_STATUS +Dwc3CoreInit ( + IN Dwc3 *Dwc3Reg + ) +{ + UINT32 Revision; + UINT32 Reg; + UINTN Dwc3Hwparams1; + + Revision =3D MmioRead32 ((UINTN)&Dwc3Reg->GSnpsId); + // + // This should read as U3 followed by revision number + // + if ((Revision & DWC3_GSNPSID_MASK) !=3D DWC3_SYNOPSIS_ID) { + DEBUG ((DEBUG_ERROR,"This is not a DesignWare USB3 DRD Core.\n")); + return EFI_NOT_FOUND; + } + + Dwc3CoreSoftReset (Dwc3Reg); + + Reg =3D MmioRead32 ((UINTN)&Dwc3Reg->GCtl); + Reg &=3D ~DWC3_GCTL_SCALEDOWN_MASK; + Reg &=3D ~DWC3_GCTL_DISSCRAMBLE; + + Dwc3Hwparams1 =3D MmioRead32 ((UINTN)&Dwc3Reg->GHwParams1); + + if (DWC3_GHWPARAMS1_EN_PWROPT(Dwc3Hwparams1) =3D=3D DWC3_GHWPARAMS1_EN_P= WROPT_CLK) { + Reg &=3D ~DWC3_GCTL_DSBLCLKGTNG; + } else { + DEBUG ((DEBUG_ERROR,"No power optimization available.\n")); + } + + if ((Revision & DWC3_RELEASE_MASK) < DWC3_RELEASE_190a) { + Reg |=3D DWC3_GCTL_U2RSTECN; + } + + MmioWrite32 ((UINTN)&Dwc3Reg->GCtl, Reg); + + return EFI_SUCCESS; +} + +EFI_STATUS +XhciCoreInit ( + IN UINTN UsbReg + ) +{ + EFI_STATUS Status; + Dwc3 *Dwc3Reg; + + Dwc3Reg =3D (VOID *)(UsbReg + DWC3_REG_OFFSET); + + Status =3D Dwc3CoreInit (Dwc3Reg); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Dwc3CoreInit Failed for controller 0x%x (0x%x) \= n", + UsbReg, Status)); + return Status; + } + + Dwc3SetMode (Dwc3Reg, DWC3_GCTL_PRTCAP_HOST); + + Dwc3SetFladj (Dwc3Reg, GFLADJ_30MHZ_DEFAULT); + + return Status; +} + +EFI_STATUS +EFIAPI +InitializeUsbController ( + IN UINTN UsbReg + ) +{ + EFI_STATUS Status; + + Status =3D XhciCoreInit (UsbReg); + + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Change beat burst and outstanding pipelined transfers requests + // + XhciSetBeatBurstLength (UsbReg); + + return Status; +} + +/** + The Entry Point of module. It follows the standard UEFI driver model. + + @param[in] ImageHandle The firmware allocated handle for the EFI image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The entry point is executed successfully. + @retval other Some error occurs when executing this entry poi= nt. + +**/ +EFI_STATUS +EFIAPI +InitializeUsbHcd ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + UINT32 NumUsbController; + UINT32 ControllerAddr; + + Status =3D EFI_SUCCESS; + NumUsbController =3D PcdGet32 (PcdNumUsbController); + + while (NumUsbController) { + NumUsbController--; + ControllerAddr =3D PcdGet32 (PcdUsbBaseAddr) + + (NumUsbController * PcdGet32 (PcdUsbSize)); + + Status =3D InitializeUsbController (ControllerAddr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "USB Controller initialization Failed for %d (0= x%x)\n", + ControllerAddr, Status)); + continue; + } + + Status =3D RegisterNonDiscoverableMmioDevice ( + NonDiscoverableDeviceTypeXhci, + NonDiscoverableDeviceDmaTypeNonCoherent, + NULL, + NULL, + 1, + ControllerAddr, PcdGet32 (PcdUsbSize) + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to register USB device (0x%x) with erro= r 0x%x \n", + ControllerAddr, Status)); + } + } + + return Status; +} diff --git a/Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h b/Platform/NXP/Dri= vers/UsbHcdInitDxe/UsbHcd.h new file mode 100644 index 0000000..3237f5d --- /dev/null +++ b/Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h @@ -0,0 +1,142 @@ +/** @file + + Copyright 2017 NXP + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#ifndef __USB_HCD__ +#define __USB_HCD__ + +/* Global constants */ +#define DWC3_GSNPSID_MASK 0xffff0000 +#define DWC3_SYNOPSIS_ID 0x55330000 +#define DWC3_RELEASE_MASK 0xffff +#define DWC3_REG_OFFSET 0xC100 +#define DWC3_RELEASE_190a 0x190a + +/* Global Configuration Register */ +#define DWC3_GCTL_U2RSTECN BIT(16) +#define DWC3_GCTL_PRTCAPDIR(n) ((n) << 12) +#define DWC3_GCTL_PRTCAP_HOST 1 +#define DWC3_GCTL_PRTCAP_OTG 3 +#define DWC3_GCTL_CORESOFTRESET BIT(11) +#define DWC3_GCTL_SCALEDOWN(n) ((n) << 4) +#define DWC3_GCTL_SCALEDOWN_MASK DWC3_GCTL_SCALEDOWN(3) +#define DWC3_GCTL_DISSCRAMBLE BIT(3) +#define DWC3_GCTL_DSBLCLKGTNG BIT(0) + +/* Global HWPARAMS1 Register */ +#define DWC3_GHWPARAMS1_EN_PWROPT(n) (((n) & (3 << 24)) >> 24) +#define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1 + +/* Global USB2 PHY Configuration Register */ +#define DWC3_GUSB2PHYCFG_PHYSOFTRST BIT(31) + +/* Global USB3 PIPE Control Register */ +#define DWC3_GUSB3PIPECTL_PHYSOFTRST BIT(31) + +/* Global Frame Length Adjustment Register */ +#define GFLADJ_30MHZ_REG_SEL BIT(7) +#define GFLADJ_30MHZ(n) ((n) & 0x3f) +#define GFLADJ_30MHZ_DEFAULT 0x20 + +/* Default to the FSL XHCI defines */ +#define USB3_ENABLE_BEAT_BURST 0xF +#define USB3_ENABLE_BEAT_BURST_MASK 0xFF +#define USB3_SET_BEAT_BURST_LIMIT 0xF00 + +typedef struct { + UINT32 GEvntAdrLo; + UINT32 GEvntAdrHi; + UINT32 GEvntSiz; + UINT32 GEvntCount; +} GEventBuffer; + +typedef struct { + UINT32 DDepCmdPar2; + UINT32 DDepCmdPar1; + UINT32 DDepCmdPar0; + UINT32 DDepCmd; +} DPhysicalEndpoint; + +typedef struct { + UINT32 GSBusCfg0; + UINT32 GSBusCfg1; + UINT32 GTxThrCfg; + UINT32 GRxThrCfg; + UINT32 GCtl; + UINT32 Res1; + UINT32 GSts; + UINT32 Res2; + UINT32 GSnpsId; + UINT32 GGpio; + UINT32 GUid; + UINT32 GUctl; + UINT64 GBusErrAddr; + UINT64 GPrtbImap; + UINT32 GHwParams0; + UINT32 GHwParams1; + UINT32 GHwParams2; + UINT32 GHwParams3; + UINT32 GHwParams4; + UINT32 GHwParams5; + UINT32 GHwParams6; + UINT32 GHwParams7; + UINT32 GDbgFifoSpace; + UINT32 GDbgLtssm; + UINT32 GDbgLnmcc; + UINT32 GDbgBmu; + UINT32 GDbgLspMux; + UINT32 GDbgLsp; + UINT32 GDbgEpInfo0; + UINT32 GDbgEpInfo1; + UINT64 GPrtbImapHs; + UINT64 GPrtbImapFs; + UINT32 Res3[28]; + UINT32 GUsb2PhyCfg[16]; + UINT32 GUsb2I2cCtl[16]; + UINT32 GUsb2PhyAcc[16]; + UINT32 GUsb3PipeCtl[16]; + UINT32 GTxFifoSiz[32]; + UINT32 GRxFifoSiz[32]; + GEventBuffer GEvntBuf[32]; + UINT32 GHwParams8; + UINT32 Res4[11]; + UINT32 GFLAdj; + UINT32 Res5[51]; + UINT32 DCfg; + UINT32 DCtl; + UINT32 DEvten; + UINT32 DSts; + UINT32 DGCmdPar; + UINT32 DGCmd; + UINT32 Res6[2]; + UINT32 DAlepena; + UINT32 Res7[55]; + DPhysicalEndpoint DPhyEpCmd[32]; + UINT32 Res8[128]; + UINT32 OCfg; + UINT32 OCtl; + UINT32 OEvt; + UINT32 OEvtEn; + UINT32 OSts; + UINT32 Res9[3]; + UINT32 AdpCfg; + UINT32 AdpCtl; + UINT32 AdpEvt; + UINT32 AdpEvten; + UINT32 BcCfg; + UINT32 Res10; + UINT32 BcEvt; + UINT32 BcEvten; +} Dwc3; + +#endif diff --git a/Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf b/Platform/NXP/D= rivers/UsbHcdInitDxe/UsbHcd.inf new file mode 100644 index 0000000..c463056 --- /dev/null +++ b/Platform/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf @@ -0,0 +1,48 @@ +# UsbHcd.inf +# +# Copyright 2017 NXP +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may b= e found +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +# + +[Defines] + INF_VERSION =3D 0x0001000A + BASE_NAME =3D UsbHcdDxe + FILE_GUID =3D 196e7c2a-37b2-4b85-8683-718588952449 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D InitializeUsbHcd + +[Sources.common] + UsbHcd.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Platform/NXP/NxpQoriqLs.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + IoLib + MemoryAllocationLib + NonDiscoverableDeviceRegistrationLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[FixedPcd] + gNxpQoriqLsTokenSpaceGuid.PcdNumUsbController + gNxpQoriqLsTokenSpaceGuid.PcdUsbBaseAddr + gNxpQoriqLsTokenSpaceGuid.PcdUsbSize + +[Depex] + TRUE diff --git a/Platform/NXP/NxpQoriqLs.dsc b/Platform/NXP/NxpQoriqLs.dsc index c3c0eb1..005a0e4 100644 --- a/Platform/NXP/NxpQoriqLs.dsc +++ b/Platform/NXP/NxpQoriqLs.dsc @@ -401,6 +401,15 @@ !endif =20 # + # Usb Support + # + MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf + MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf + MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf + MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf + MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf + + # # FAT filesystem + GPT/MBR partitioning # MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf --=20 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel