From nobody Mon Dec 23 18:01:53 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 1515406046802567.302870189891; Mon, 8 Jan 2018 02:07:26 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3E0F8222A54D4; Mon, 8 Jan 2018 02:02:13 -0800 (PST) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0076.outbound.protection.outlook.com [104.47.37.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E6717222275A3 for ; Mon, 8 Jan 2018 02:02:11 -0800 (PST) Received: from BN6PR03CA0024.namprd03.prod.outlook.com (10.168.230.162) by CO2PR03MB2358.namprd03.prod.outlook.com (10.166.93.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Mon, 8 Jan 2018 10:07:20 +0000 Received: from BL2FFO11OLC009.protection.gbl (2a01:111:f400:7c09::102) by BN6PR03CA0024.outlook.office365.com (2603:10b6:404:23::34) 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:07:19 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11OLC009.mail.protection.outlook.com (10.173.160.145) 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:06:50 +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 w08A7CjO014903; Mon, 8 Jan 2018 03:07:17 -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.76; 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:25:11 +0530 Message-ID: <1515426912-13557-2-git-send-email-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1515426912-13557-1-git-send-email-meenakshi.aggarwal@nxp.com> References: <1513945005-30002-1-git-send-email-meenakshi.aggarwal@nxp.com> <1515426912-13557-1-git-send-email-meenakshi.aggarwal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131598796104777669; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(346002)(396003)(376002)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(97736004)(36756003)(305945005)(51416003)(68736007)(53936002)(77096006)(5660300001)(105606002)(106466001)(966005)(47776003)(59450400001)(498600001)(76176011)(48376002)(356003)(50466002)(15188155005)(16586007)(316002)(104016004)(2201001)(16799955002)(110136005)(54906003)(50226002)(85426001)(8936002)(81156014)(81166006)(8676002)(53376002)(4326008)(6306002)(2950100002)(6666003)(86362001)(575784001)(8656006)(2906002)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR03MB2358; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC009; 1:g8W1o0dHQHw+LEabJesihHYei0KaCJKAXqbn1CjjWC4LjkyjJlHQhxzAbmYzJTo0SuLl7XQC+gIYdaxUUyFbbF+pYNhyrGb2OXZCZQPGQJxO4Qw/UnFkevbRQxFuvCeD MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: af143977-191f-469f-5e6c-08d5567f8926 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603307); SRVR:CO2PR03MB2358; X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2358; 3:w70vT8DoCaBy7MDLTCV0blJCtoQ84zJ9iNmUSj0qgQ1jQbg7LG6+kJ2uenXP2VsdcfDWnaIOpPJmOgvbkl0vjo3PxpjF5BaVdfH66x5m5y4OIU3Prz0DIrIqhp2Dbb9CKR3ie9CUWRjjjDDGPXW4cX01JfSVIJYiTFhifh+CoQcnJ9DReR6bqZbLY7wm2p34nl7HYpFa69S/Jlkc5VrInJ6NaEdfMvqKSyCe2Iu7QR0F0ftCGkQ0aJsERrRLP1++MK3nIagu3QvuqB4JHVifTJ4pUPUfROfKmiuTzJKWeOOV/wGRm6jB12kbcSHDRAHBzTfty/6jOb2EbL4WZPTS80FhECu4TEgtV7XRtFjMw1o=; 25:0r8AIdgu8JDT05XtOnsNh/CIw7lN2+qHD1F4xY7nw7kRqxupRw4yAz9ccH+SPOBGO1C1WlESQYJo+h+krMdEKG99fHL2a7ZGFToyKQTPZGo5qQNjxSJeFUGDqBa0pKruRxFWVO7H8LEHs/tIS2aflwGe4snBYImgf/Ayd4t7bJP4lUVick9xPfQOKQDitS+vS8PStFYi+NlHHL8hX0538+QCbRwKsLiQbZ0osEs432wprJFlykHq948B2SLIYQetZLcU500J68WAV5vz3HGKRNR6ZW9wb/xCFBnH5g+e/UmZERE+pPibM99lI2z3V9cdB02/ldwYGlMOg1/3BpmWpg== X-MS-TrafficTypeDiagnostic: CO2PR03MB2358: X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2358; 31:99IExBKwrzUagLxiYgt2Z40PFqqcs2dHQqKmPmdBPHJbnZoQocsuFy+5IzR7vKE3akXRz2OPigU3KuG1a9epSLWeIb69fHwcmgoaH9w2NubGSvXp7x0fzzEwCgeBlC6AT0ZcRA92RI+YQemGgV+//6XuubIkuTJAWcverA7cce/7TAIbSTfeqRyEz9QJ99KA4fwr6YWC7+qYOreOUIbrRxNTJnjkcmkzblBghmYcHT4=; 4:WMK1SZT/l54C2qjDU9ae1t+56FM51RVJsfLeNMG+y9lJkrn5UyslNfYajAnggcsZZy1NT/Mn3gbHUTW//c/QGk3pVmty9k9tIuQR+ltnAr1u0wVDY7cdgXAlbHuBJdzRL267dZl4aJ4QarLhe9Q7oeJNmwyzq26Z+FcGsEaro6k+nVvZJ5sKWKYrVJ5je9avf6YIGxEaMKHwwqXliMesLpio/qWqd2vd9zEcJFlPgCm5WQaeujhbRu4Ge77LRxd93f/uS8YOfhJF1lm+Q26Y0KCk64Bo1IscDC32KS4x1FbB56wlk59HQllRoe34XdvyiLT04Yq8opWQn3zAkuBCcdNwv+/QHqcC+SdXgdW7tDE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(21532816269658); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(3231023)(944510075)(944921075)(946801075)(946901075)(10201501046)(6055026)(6096035)(20161123563025)(20161123565025)(20161123556025)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123561025)(20161123559100)(201708071742011); SRVR:CO2PR03MB2358; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:CO2PR03MB2358; X-Forefront-PRVS: 054642504A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR03MB2358; 23:C9/NYXwLpuakKwbAJ9GeUM0XoVQIyYufMl9zx9MBF?= =?us-ascii?Q?45MD9cI0bji0V33GajpsJkAHoBhzz9sloHvJQzHZ2k/5Bac0FuPE+59+NnF7?= =?us-ascii?Q?5l79Hq+TG4jUufB/7QNqrEuDrlPH0dtnjShy0pjMYhKj0jveYo0D65SccWZE?= =?us-ascii?Q?/fnmvWay3bMNUELGwlu6yD97Qmrk2JE9DB1f5vkdGoX1m9WgFfH4mp9HoSpN?= =?us-ascii?Q?tXboF+B+Xjbi+pnmwobOPnhrIf0o4t6OpZqFTlg7l8SXRt5UTA2VTGM2Pgsd?= =?us-ascii?Q?DFh4LC8g/995d39hQD0QM5gQjB6err/WhyI5znLowQ2ffncm2v09L/MeC2aI?= =?us-ascii?Q?/ZGd9lVztB8+RA9RBnScFndD2SooxeZ681Qm3GCMPsbQH+GpB4YPTr7FyME+?= =?us-ascii?Q?VTNZWGZs//kD0MfCznPAaWX2CfFEV+fFsxioAYwpUPGYx0pr8kwsuVBMFC4S?= =?us-ascii?Q?REsRo5Qs2qMy5XicIEdQBRfFar3oBNQwYBV3IX6Jy0rfp8rCK1c9nUySl6TU?= =?us-ascii?Q?OsRb9Sytcx4R+hgT8GGYBkdOpR045xkOkNfXJQGQK98rz0D+igXjKdaZo9l0?= =?us-ascii?Q?XBjoE2gyDM6AeSksdPNWpLIGYE+CbiltZoI+fkABRFZUnpnr07iZgsNWzKaE?= =?us-ascii?Q?pui9NlUWY6OqXT+QqQMe/uHJnhELkVC10MogA+/qmo47DPFmU1OuNZpsw2/r?= =?us-ascii?Q?32wStSflxKNqhGn3qk+6V3fbOX661PMoeDoacP4gmyGaVLEmWYJr4fSwkyt0?= =?us-ascii?Q?n3MXGglsnDT+GNPIzmpTW/0kpZXrpZ5QpnQT2WELitjVw4rolFFpOxd6TRGo?= =?us-ascii?Q?QB3Pb+CT+1uHqdmyyddhlUR8x6lpEWTzNNXu/j8/Mf2KlUqnHpk2qmRVbOhi?= =?us-ascii?Q?Ie1cFVHMRl3vB7voU9tMAOzzdrOgVOeNmkgKUzBVkUQTZbFsKGtlNyCrFqPR?= =?us-ascii?Q?GQvgSITcScaUmtaNOZ0cwONa6BNFeXTAJMJsIBZvMYzPthrlbDijElEnnXEr?= =?us-ascii?Q?RfcivdD5HpRj09UYpBS3ZVQT8MsHN7l/nAKlwJmyT1sHemc6WyPUfBiU+k1L?= =?us-ascii?Q?Sxv+0xIRRXzMn4clnSexLzhN1AU3zYxYjPyVrJb7Nkja3maN0gMyf0RItUYO?= =?us-ascii?Q?zlQwnRcPtCBPnI9wzoh7N3Ez5b8vVhmJHvfOnS6g/LXo51GZgWzddqmtgpSK?= =?us-ascii?Q?nHtgLNlrCSxRAppR/HmvirQ5gl6dcuD0Y12Mm/vUMaZLJSCU4QkLStvz4Way?= =?us-ascii?Q?9HYDiu5zqCVCEbjcpI=3D?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2358; 6:zp+j15LlY/p/ClCXkE9vyeol99/r30YWTN5G3msS1BX/2cOZo7cF1Ev3TzgmVGfGRXmxIfjg94AMI2p7W8oOwdq17UHDLwocT0YmNObMrwgOGfOUePXAOfKvBLaMVF7KPChY4c8E1v0cZ9kS36G89KPt5+6KMqHbdcE8ABnO9xFVW6NOvCmcQLYlBHTSS3BNoBL30ck2ag6SivnAG1AgmsfurafwRTCqNZ7igCfQycHSv8EkxWe5rG3RX1c+34TYMsMpLC1OAD/CGAK7JsDr7Nk2sBBv/KOkYLPJio3EUaL9QLcc8nLzDTNRBdZYkI0cQUE31l1Nh3AlIzm3d3vZp6L6JfJy6I/avqaGR9GC2LQ=; 5:9GVUa5pDFi3q4miYvu7TDcSmjHDBCKiU8HxOCY3OacX0anSGJ+l80NzJZcxn1yLXwCYDc3IzBD1TPOE9nzPteuEL8S4r8HWDbLuCz8uIKlOO5vgY3dBpZxJeVIxWmfnuHzpV8ppFQNQ/VTp5USgFdulB9+VSZ/oGAE87CUAWz4c=; 24:B7e++svtNbAiHDWBBrjPZdFuuQRAnchgH2FzQB0SJ04V53dKkPsH/KdIKobRL6K5G3yeX5NJPpj58ms3iIEU7Lx5pc/+Z4yCLMT4sYz4uNQ=; 7:nlfxSXSKiqXPAcwA8Jv4z7RC6kfha726wmR3+MQDl6FixJki1iHxAXpPEkjVHYXljSx76x9K9uLfXIqvaLYcTYt+tvjFx+nSL5guXPjwLrrbnI1CMKqRaLfa1gR83tn06SSbSv+YncqBG8cIBeSnfmIspYMz1xLbRIbHtGe+9Ewf/Nyp2smcR/uP+rqQCEGqEMAEamFuwyvqm4DZTe/B3ImciAT4iDTI4sfeke/7uS1SXIjKauO7NfUOHW09OCyF SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2018 10:06:50.3061 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: af143977-191f-469f-5e6c-08d5567f8926 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: CO2PR03MB2358 Subject: [edk2] [PATCH edk2-platforms v2 1/2] SATA : Added SATA controller 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" This patch adds support of SATA controller, which Initialize SATA controller, apply platform specific errata and Register itself as NonDiscoverableMmioDevice Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Meenakshi Aggarwal --- Platform/NXP/Drivers/SataInitDxe/SataInit.c | 285 +++++++++++++++++++= ++++ Platform/NXP/Drivers/SataInitDxe/SataInit.h | 36 +++ Platform/NXP/Drivers/SataInitDxe/SataInitDxe.inf | 52 +++++ Platform/NXP/NxpQoriqLs.dec | 14 +- Platform/NXP/NxpQoriqLs.dsc | 13 ++ 5 files changed, 398 insertions(+), 2 deletions(-) create mode 100644 Platform/NXP/Drivers/SataInitDxe/SataInit.c create mode 100644 Platform/NXP/Drivers/SataInitDxe/SataInit.h create mode 100644 Platform/NXP/Drivers/SataInitDxe/SataInitDxe.inf diff --git a/Platform/NXP/Drivers/SataInitDxe/SataInit.c b/Platform/NXP/Dri= vers/SataInitDxe/SataInit.c new file mode 100644 index 0000000..bac390b --- /dev/null +++ b/Platform/NXP/Drivers/SataInitDxe/SataInit.c @@ -0,0 +1,285 @@ +/** @file + This driver module adds SATA controller support. + + 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 be= 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 IMP= LIED. + + **/ + +#include +#include +#include +#include +#include +#include +#include + +#include "SataInit.h" + +STATIC VOID *mDriverEventRegistration; + +/** + Read AHCI Operation register. + + @param PciIo The PCI IO protocol instance. + @param Offset The operation register offset. + + @return The register content read. +**/ + +UINT32 +EFIAPI +AhciReadReg ( + IN EFI_PCI_IO_PROTOCOL *PciIo, + IN UINT32 Offset + ) +{ + UINT32 Data; + + ASSERT (PciIo !=3D NULL); + + Data =3D 0; + + PciIo->Mem.Read ( + PciIo, + EfiPciIoWidthUint32, + AHCI_BAR_INDEX, + (UINT64) Offset, + 1, + &Data + ); + + return Data; +} + +/** + Write AHCI Operation register. + + @param PciIo The PCI IO protocol instance. + @param Offset The operation register offset. + @param Data The data used to write down. + +**/ +VOID +EFIAPI +AhciWriteReg ( + IN EFI_PCI_IO_PROTOCOL *PciIo, + IN UINT32 Offset, + IN UINT32 Data + ) +{ + ASSERT (PciIo !=3D NULL); + + PciIo->Mem.Write ( + PciIo, + EfiPciIoWidthUint32, + AHCI_BAR_INDEX, + (UINT64) Offset, + 1, + &Data + ); + + return; +} + +STATIC +VOID +PciIoRegistrationEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + UINTN HandleCount; + UINTN Address; + UINT32 Count; + UINT32 Data; + UINT8 PciClass; + UINT8 PciSubClass; + EFI_PCI_IO_PROTOCOL *PciIo; + EFI_HANDLE *HandleBuf; + + PciIo =3D NULL; + + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiPciIoProtocolGuid, + NULL, + &HandleCount, + &HandleBuf); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Sata controller is not able to locate gEfiPciIoP= rotocolGuid 0x%x\n", + Status)); + return; + } + + for (Count =3D 0; Count < HandleCount; Count++) { + Status =3D gBS->OpenProtocol ( + HandleBuf[Count], + &gEfiPciIoProtocolGuid, + (VOID **) &PciIo, + NULL, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (EFI_ERROR (Status)) { + continue; + } + + // + // Now further check the PCI header: Base class (offset 0x0B) and + // Sub Class (offset 0x0A). This controller should be an Ide controller + // + Status =3D PciIo->Pci.Read ( + PciIo, + EfiPciIoWidthUint8, + PCI_CLASSCODE_OFFSET + 2, + 1, + &PciClass + ); + if (EFI_ERROR (Status)) { + continue; + } + + Status =3D PciIo->Pci.Read ( + PciIo, + EfiPciIoWidthUint8, + PCI_CLASSCODE_OFFSET + 1, + 1, + &PciSubClass + ); + if (EFI_ERROR (Status)) { + continue; + } + + // + // Examine Ide PCI Configuration table fields + // + if ((PciClass !=3D PCI_CLASS_MASS_STORAGE) || + (PciSubClass !=3D PCI_CLASS_MASS_STORAGE_SATADPA)) { + continue; + } + + Status =3D PciIo->Pci.Read ( + PciIo, + EfiPciIoWidthUint32, + PCI_AHCI_BASE_ADDRESS, + 1, + &Address + ); + if (EFI_ERROR (Status)) { + continue; + } else if (Address =3D=3D (UINTN)Context) { + gBS->CloseEvent (Event); + + // + // configuring Physical Control Layer parameters for Port 0 + // + AhciWriteReg (PciIo, SATA_PPCFG, PORT_PHYSICAL); + + // + // This register controls the configuration of the + // Transport Layer for Port 0 + // Errata Description : The default Rx watermark value may be insuff= icient for some + // hard drives and result in a false CRC or internal errors. + // Workaround: Change PTC[RXWM] field at offset 0xC8 to 0x29. Do not= change + // the other reserved fields of the register. + // + + Data =3D AhciReadReg (PciIo, SATA_PTC); + if (PcdGetBool (PcdSataErratumA009185)) { + Data |=3D PORT_RXWM; + } else { + Data |=3D PORT_TRANSPORT; + } + AhciWriteReg (PciIo, SATA_PTC, Data); + + break; + } + } + + gBS->FreePool (HandleBuf); + + return; +} + +/** + 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 +InitializeSataController ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + UINT32 NumSataController; + UINTN ControllerAddr; + + Status =3D EFI_SUCCESS; + NumSataController =3D PcdGet32 (PcdNumSataController); + + // + // Impact : The SATA controller does not detect some hard drives reliabl= y with + // the default SerDes register setting. + // Workaround : write value 0x80104e20 to 0x1eb1300 (serdes 2) + // + if (PcdGetBool (PcdSataErratumA010554)) { + BeMmioWrite32 ((UINTN)SERDES2_SATA_ERRATA, 0x80104e20); + } + + // + // Impact : Device may see false CRC errors causing unreliable SATA oper= ation. + // Workaround : write 0x80000000 to the address 0x20140520 (dcsr). + // + if (PcdGetBool (PcdSataErratumA010635)) { + BeMmioWrite32 ((UINTN)DCSR_SATA_ERRATA, 0x80000000); + } + + while (NumSataController) { + NumSataController--; + ControllerAddr =3D PcdGet32 (PcdSataBaseAddr) + + (NumSataController * PcdGet32 (PcdSataSize)); + + Status =3D RegisterNonDiscoverableMmioDevice ( + NonDiscoverableDeviceTypeAhci, + NonDiscoverableDeviceDmaTypeNonCoherent, + NULL, + NULL, + 1, + ControllerAddr, PcdGet32 (PcdSataSize) + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to register SATA device (0x%x) with err= or 0x%x \n", + ControllerAddr, Status)); + } else { + // + // Register a protocol registration notification callback on the dri= ver + // binding protocol so we can attempt to connect to it as soon as it= appears. + // + EfiCreateProtocolNotifyEvent ( + &gEfiPciIoProtocolGuid, + TPL_CALLBACK, + PciIoRegistrationEvent, + (VOID *)ControllerAddr, + &mDriverEventRegistration); + } + } + + return Status; +} diff --git a/Platform/NXP/Drivers/SataInitDxe/SataInit.h b/Platform/NXP/Dri= vers/SataInitDxe/SataInit.h new file mode 100644 index 0000000..7fe6273 --- /dev/null +++ b/Platform/NXP/Drivers/SataInitDxe/SataInit.h @@ -0,0 +1,36 @@ +/** @file + Header file for Sata Controller initialization driver. + + 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 be= 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 IMP= LIED. + + **/ + +#ifndef _SATA_INIT_H_ +#define _SATA_INIT_H_ + + +#define AHCI_BAR_INDEX 0x05 +// +// Offset for AHCI base address in PCI Header +// +#define PCI_AHCI_BASE_ADDRESS 0x24 + +#define SATA_PPCFG 0xA8 +#define SATA_PTC 0xC8 + +#define PORT_PHYSICAL 0xA003FFFE +#define PORT_TRANSPORT 0x08000025 +#define PORT_RXWM 0x08000029 + +#define DCSR_SATA_ERRATA 0x20140520 +#define SERDES2_SATA_ERRATA 0x01eb1300 + +#endif diff --git a/Platform/NXP/Drivers/SataInitDxe/SataInitDxe.inf b/Platform/NX= P/Drivers/SataInitDxe/SataInitDxe.inf new file mode 100644 index 0000000..82535f4 --- /dev/null +++ b/Platform/NXP/Drivers/SataInitDxe/SataInitDxe.inf @@ -0,0 +1,52 @@ +## @file +# Component description file for the Sata Controller initialization driver +# +# 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 SataInit + FILE_GUID =3D 021722D8-522B-4079-852A-FE44C2C13F49 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D InitializeSataController + +[Sources] + SataInit.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Platform/NXP/NxpQoriqLs.dec + +[LibraryClasses] + BeIoLib + DebugLib + NonDiscoverableDeviceRegistrationLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + +[FixedPcd] + gNxpQoriqLsTokenSpaceGuid.PcdNumSataController + gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr + gNxpQoriqLsTokenSpaceGuid.PcdSataSize + gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185 + gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA010554 + gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA010635 + +[Protocols] + gEfiPciIoProtocolGuid + +[Depex] + TRUE diff --git a/Platform/NXP/NxpQoriqLs.dec b/Platform/NXP/NxpQoriqLs.dec index bd4273f..65d659e 100644 --- a/Platform/NXP/NxpQoriqLs.dec +++ b/Platform/NXP/NxpQoriqLs.dec @@ -52,8 +52,8 @@ gNxpQoriqLsTokenSpaceGuid.PcdI2c1BaseAddr|0|UINT64|0x0000010E gNxpQoriqLsTokenSpaceGuid.PcdI2c2BaseAddr|0|UINT64|0x0000010F gNxpQoriqLsTokenSpaceGuid.PcdI2c3BaseAddr|0|UINT64|0x00000110 - gNxpQoriqLsTokenSpaceGuid.PcdSataController1BaseAddress|0x0|UINT32|0x000= 00111 - gNxpQoriqLsTokenSpaceGuid.PcdSataController2BaseAddress|0x0|UINT32|0x000= 00112 + gNxpQoriqLsTokenSpaceGuid.PcdSataBaseAddr|0x0|UINT32|0x00000111 + gNxpQoriqLsTokenSpaceGuid.PcdSataSize|0x0|UINT32|0x00000112 gNxpQoriqLsTokenSpaceGuid.PcdQmanSwpBaseAddr|0x0500000000|UINT64|0x00000= 113 gNxpQoriqLsTokenSpaceGuid.PcdQmanSwpSize|0x0080000000|UINT64|0x00000114 gNxpQoriqLsTokenSpaceGuid.PcdBmanSwpBaseAddr|0x0508000000|UINT64|0x00000= 115 @@ -83,6 +83,8 @@ gNxpQoriqLsTokenSpaceGuid.PcdCcsrBaseAddr|0x01000000|UINT64|0x0000012D gNxpQoriqLsTokenSpaceGuid.PcdCcsrSize|0x0F000000|UINT64|0x0000012E gNxpQoriqLsTokenSpaceGuid.PcdDramMemSize|0x0|UINT64|0x0000012F + gNxpQoriqLsTokenSpaceGuid.PcdDcsrBaseAddr|0x0|UINT64|0x00000130 + gNxpQoriqLsTokenSpaceGuid.PcdDcsrSize|0x0|UINT64|0x00000131 =20 # # DSPI Pcds @@ -156,6 +158,9 @@ gNxpQoriqLsTokenSpaceGuid.PcdErratumA008514|FALSE|BOOLEAN|0x00000275 gNxpQoriqLsTokenSpaceGuid.PcdErratumA008336|FALSE|BOOLEAN|0x00000276 gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA009185|FALSE|BOOLEAN|0x00000277 + gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA010554|FALSE|BOOLEAN|0x00000278 + gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA010635|FALSE|BOOLEAN|0x00000279 + gNxpQoriqLsTokenSpaceGuid.PcdSataErratumA008402|FALSE|BOOLEAN|0x0000027A =20 # # Test PCDs @@ -249,3 +254,8 @@ # gNxpQoriqLsTokenSpaceGuid.PcdSysEepromI2cBus|0|UINT32|0x0000330 gNxpQoriqLsTokenSpaceGuid.PcdSysEepromI2cAddress|0|UINT32|0x0000331 + + # + # SATA Pcds + # + gNxpQoriqLsTokenSpaceGuid.PcdNumSataController|0x0|UINT32|0x00000340 diff --git a/Platform/NXP/NxpQoriqLs.dsc b/Platform/NXP/NxpQoriqLs.dsc index 10eff06..c3c0eb1 100644 --- a/Platform/NXP/NxpQoriqLs.dsc +++ b/Platform/NXP/NxpQoriqLs.dsc @@ -99,6 +99,8 @@ VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf + UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf + NonDiscoverableDeviceRegistrationLib|MdeModulePkg/Library/NonDiscoverabl= eDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf =20 [LibraryClasses.common.SEC] PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf @@ -144,6 +146,7 @@ SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS= ecurityManagementLib.inf PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.= inf MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf + NonDiscoverableDeviceRegistrationLib|MdeModulePkg/Library/NonDiscoverabl= eDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf =20 [LibraryClasses.common.UEFI_APPLICATION] PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf @@ -334,6 +337,16 @@ } =20 # + # AHCI Support + # + MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf + MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf + MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf + MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDevic= eDxe.inf + + # # Architectural Protocols # ArmPkg/Drivers/CpuDxe/CpuDxe.inf --=20 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel