From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from zg8tmja5ljk3lje4ms43mwaa.icoremail.net (zg8tmja5ljk3lje4ms43mwaa.icoremail.net [209.97.181.73]) by mx.groups.io with SMTP id smtpd.web10.9228.1688725287118926383 for ; Fri, 07 Jul 2023 03:21:27 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: phytium.com.cn, ip: 209.97.181.73, mailfrom: wangyuquan1236@phytium.com.cn) Received: from prodtpl.icoremail.net (unknown [10.12.1.20]) by hzbj-icmmx-6 (Coremail) with SMTP id AQAAfwBXkUdP6KdkQJxOAg--.63148S2; Fri, 07 Jul 2023 18:26:23 +0800 (CST) Received: from phytium.com.cn (unknown [123.150.8.50]) by mail (Coremail) with SMTP id AQAAfwAHJ5wf56dkS4IAAA--.1411S5; Fri, 07 Jul 2023 18:21:23 +0800 (CST) From: "Yuquan Wang" To: devel@edk2.groups.io Cc: chenbaozi@phytium.com.cn, Yuquan Wang Subject: [PATCH edk2-platforms v2 2/3] SbsaQemu: Drivers: Add initial support for XHCI Date: Fri, 7 Jul 2023 18:20:41 +0800 Message-Id: <20230707102042.409842-3-wangyuquan1236@phytium.com.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707102042.409842-1-wangyuquan1236@phytium.com.cn> References: <20230707102042.409842-1-wangyuquan1236@phytium.com.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAfwAHJ5wf56dkS4IAAA--.1411S5 X-CM-SenderInfo: 5zdqw5pxtxt0arstlqxsk13x1xpou0fpof0/1tbiAQANAWSnEikEjgAAs- Authentication-Results: hzbj-icmmx-6; spf=neutral smtp.mail=wangyuquan 1236@phytium.com.cn; X-Coremail-Antispam: 1Uk129KBjvJXoWxXFWrCF4kZryrGFWDuF18uFg_yoW5tFyxpF 10vFZ7ur17G3yayw43G3WrXr4YkFyfKrWUGrsxXF40kwsxXF1UXw4aqF18Z3srJFn8Xw4D Ar10ya4UZan3ur7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj DUYxn0WfASr-VFAU7a7-sFnT9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUU UUUUU Content-Transfer-Encoding: 8bit This registers the non-discoverable XHCI for sbsa-ref. Signed-off-by: Yuquan Wang --- .../SbsaQemuPlatformDxe.inf | 2 + .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 41 +++++++++++++++---- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf index 545794a8c7ff..06700331efea 100644 --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf @@ -37,6 +37,8 @@ [LibraryClasses] [Pcd] gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformXhciBase + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformXhciSize gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c index f6a3e84483fe..969c25ae0e17 100644 --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c @@ -26,22 +26,23 @@ InitializeSbsaQemuPlatformDxe ( ) { EFI_STATUS Status; - UINTN Size; - VOID* Base; UINTN Arg0; UINTN Arg1; UINTN SmcResult; RETURN_STATUS Result; + UINTN AhciSize, XhciSize; + VOID* AhciBase; + VOID* XhciBase; DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FUNCTION__)); - Base = (VOID*)(UINTN)PcdGet64 (PcdPlatformAhciBase); - ASSERT (Base != NULL); - Size = (UINTN)PcdGet32 (PcdPlatformAhciSize); - ASSERT (Size != 0); + AhciBase = (VOID*)(UINTN)PcdGet64 (PcdPlatformAhciBase); + ASSERT (AhciBase != NULL); + AhciSize = (UINTN)PcdGet32 (PcdPlatformAhciSize); + ASSERT (AhciSize != 0); DEBUG ((DEBUG_INFO, "%a: Got platform AHCI %llx %u\n", - __FUNCTION__, Base, Size)); + __FUNCTION__, AhciBase, AhciSize)); Status = RegisterNonDiscoverableMmioDevice ( NonDiscoverableDeviceTypeAhci, @@ -49,11 +50,33 @@ InitializeSbsaQemuPlatformDxe ( NULL, NULL, 1, - Base, Size); + AhciBase, AhciSize); if (EFI_ERROR(Status)) { DEBUG ((DEBUG_ERROR, "%a: NonDiscoverable: Cannot install AHCI device @%p (Staus == %r)\n", - __FUNCTION__, Base, Status)); + __FUNCTION__, AhciBase, Status)); + return Status; + } + + XhciBase = (VOID*)(UINTN)PcdGet64 (PcdPlatformXhciBase); + ASSERT (XhciBase != NULL); + XhciSize = (UINTN)PcdGet32 (PcdPlatformXhciSize); + ASSERT (XhciSize != 0); + + DEBUG ((DEBUG_INFO, "%a: Got platform XHCI %llx %u\n", + __FUNCTION__, XhciBase, XhciSize)); + + Status = RegisterNonDiscoverableMmioDevice ( + NonDiscoverableDeviceTypeXhci, + NonDiscoverableDeviceDmaTypeCoherent, + NULL, + NULL, + 1, + XhciBase, XhciSize); + + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "%a: NonDiscoverable: Cannot install XHCI device @%p (Staus == %r)\n", + __FUNCTION__, XhciBase, Status)); return Status; } -- 2.34.1