From patchwork Tue Dec 12 10:38:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 121503 Delivered-To: patch@linaro.org Received: by 10.80.152.193 with SMTP id j59csp3890638edb; Tue, 12 Dec 2017 02:38:27 -0800 (PST) X-Google-Smtp-Source: ACJfBos+ugvXuOH2MCKp0jnt58kkHhqazavdIpyvsYezmrvBWMl3UEIUoCkbwhVaIVBlUtYr06WK X-Received: by 10.98.8.210 with SMTP id 79mr1856116pfi.204.1513075107226; Tue, 12 Dec 2017 02:38:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513075107; cv=none; d=google.com; s=arc-20160816; b=Agj4vd/7kiVNN0wFiqbOHmSQkY3uK62pK8DX1xmsn0/DoJllSiggcX7HFBp3JieLF6 S5sZIQ6IiGtmrxU7y1kVSaNArGWoT+Aju/Rnvx6qrGOc6UFtoIYwXkef7pFkamt+/veP Cww5TrPPUNOAKqs0uN29WBKAyR0ZjmX+020ljW2IZiNyDhQBJAKFsUEO/qwI5YUSFEln 2lyvRHbwTlVBGTcF3sn9wTAKZwNWnSPolaDttZhEzYEE6N6PbD7qg24jbjuMqWQEXM0u 3PwKiunZMcfhj59DiaEL4akWEbFKt7o+1CG5ePzBvIU91CjhSVvLrvBwKSTJZS2xsDiW rDvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=APMJwyyghovOKVQLN7Bur/Itzi7T9Hvf23dLhhLuI1A=; b=hNpFGDO0bxLgIwPZ4Buy7VeVbOtefu32n1wedwlpMGGl7nkwqjzk83i8X+iZ/ctk6l IkGT36uEbn1hX6aXdZ2oXFlQ30iPutbneZVFfQGdoCYI8vTsCO1uGUN46cDfERLs2HGR WJX2M8xeXz8QkfZ36ZEBU9czxz4B0U0ZyyK7RKmHpbCXglgf98HIIBKUQs0sThc2NqbZ W6IsFeZF9eLwA/9FZSl0kJDBEnl4Q+bbwCwHVxpURelSsPpn6J6siOYq22mCAeGJfhNv u22tnzxcyJnELbwu8zq1k+BplZUwtSYO10VGhNSEClO7FMwOuggp/8HcfPxmhwA4FTmr AXjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V76rLpFz; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id x6si11256797pgp.181.2017.12.12.02.38.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 02:38:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V76rLpFz; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 07899220EE111; Tue, 12 Dec 2017 02:33:46 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::242; helo=mail-wr0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 167D621B02832 for ; Tue, 12 Dec 2017 02:33:44 -0800 (PST) Received: by mail-wr0-x242.google.com with SMTP id q9so20586997wre.7 for ; Tue, 12 Dec 2017 02:38:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KSsqfg8scmXSSTjNPYjvYQRQBTDdn798CCzXzjKRz1A=; b=V76rLpFzrLbqwjRVFGpH647CQ9PpSP7JdZcdJcosC7vh0fFWIiWuwse1sgP+Dd3jtx r1deuKI3yUiLfVyO5fJ9Al0ixVnlJuDPJVKiFrlYWm+LGd3eDs9SUxKalYpfMfZ37jU8 ZLvxaaZKUMbzasQQGpggL6RLec9Eif5+PVlAE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KSsqfg8scmXSSTjNPYjvYQRQBTDdn798CCzXzjKRz1A=; b=OV4TrV9G6reN4A/rJRxieqxhwbyjHSz4tFetddDca1WmXWC3tMe8QvugYTuiCm6yNs IlILNss1tn/d1qDedeWS5SHoQ5/RDmx25BJI0g4TRE6a7J54G7x/WBZLMSm0qj+vlvgW RVvuDuugdLAhY0QcHrKa2b/XgNPflCf0PrtgfglwLVWiQt4b8/IcdAmc9rI/ilyVDyc2 Gbsm67WcABYDfvX6j8GgmYzGxdBbgpxpDoOscvn5bk9uf5h0rdnGrbySkGw8qVmaGen/ sJqxyJG9kSeOpvEIsO4ZFQs/pI/ooZN+r66VQqX/dFz65EOCJLzKXKR8JnLPXPl4k1xr W5wA== X-Gm-Message-State: AKGB3mLtOdAK6COmya9ALLDffPmMCkHrK0GZEmtgSShChhNC/o5eGqLS yeaLYoLWVtGySjD+kjxurrN8hZKdZ+g= X-Received: by 10.223.136.38 with SMTP id d35mr3439705wrd.36.1513075101897; Tue, 12 Dec 2017 02:38:21 -0800 (PST) Received: from localhost.localdomain ([160.171.158.223]) by smtp.gmail.com with ESMTPSA id b16sm21279762wrd.69.2017.12.12.02.38.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 02:38:21 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 12 Dec 2017 10:38:02 +0000 Message-Id: <20171212103807.18836-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171212103807.18836-1-ard.biesheuvel@linaro.org> References: <20171212103807.18836-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms 3/8] Silicon/SynQuacerPciHostBridgeLib: stall for 150 ms during PERST# X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.thompson@linaro.org, masami.hiramatsu@linaro.org, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Attempt to adhere more closely to the PCIe spec by ensuring that PERST# remains asserted for at least 100 ms. Give it a good margin, and delay for 150 ms; the additional boot time delay is not going to be noticeable by anyone anyway. So split the init routine in a pre and post part, and put the delay in the middle so we only need to do it once. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf | 1 + Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c | 46 +++++++++++++++----- 2 files changed, 36 insertions(+), 11 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf index 08484f4f8b1a..5d87727c73ba 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLib.inf @@ -45,6 +45,7 @@ [LibraryClasses] DebugLib DevicePathLib MemoryAllocationLib + UefiBootServicesTableLib [FixedPcd] gArmTokenSpaceGuid.PcdPciIoTranslation diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c index e63b3a4bb23b..3da94945f96a 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPciHostBridgeLib/SynQuacerPciHostBridgeLibConstructor.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -176,6 +177,8 @@ SnPcieSetData ( } MmioWrite32 (Base + Offset, Data); + + ArmDataMemoryBarrier (); } STATIC @@ -194,6 +197,8 @@ SnPcieReadData ( Shift++; } + ArmDataMemoryBarrier (); + return (MmioRead32 (Base + Offset) >> Shift) & Mask; } @@ -219,12 +224,8 @@ SnDbiRoWrEn ( STATIC VOID -PciInitController ( - IN EFI_PHYSICAL_ADDRESS ExsBase, - IN EFI_PHYSICAL_ADDRESS DbiBase, - IN EFI_PHYSICAL_ADDRESS ConfigBase, - IN EFI_PHYSICAL_ADDRESS IoMemBase, - IN CONST PCI_ROOT_BRIDGE *RootBridge +PciInitControllerPre ( + IN EFI_PHYSICAL_ADDRESS ExsBase ) { SnPcieSetData (ExsBase, EM_SELECT, PRE_DET_STT_SEL, 0); @@ -256,7 +257,18 @@ PciInitController ( // 3: Set device_type (RC) SnPcieSetData (ExsBase, CORE_CONTROL, DEVICE_TYPE, 4); +} +STATIC +VOID +PciInitControllerPost ( + IN EFI_PHYSICAL_ADDRESS ExsBase, + IN EFI_PHYSICAL_ADDRESS DbiBase, + IN EFI_PHYSICAL_ADDRESS ConfigBase, + IN EFI_PHYSICAL_ADDRESS IoMemBase, + IN CONST PCI_ROOT_BRIDGE *RootBridge + ) +{ // 4: Set Bifurcation 1=disable 4=able // 5: Supply Reference (It has executed) // 6: Wait for 10usec (Reference Clocks is stable) @@ -389,11 +401,23 @@ SynQuacerPciHostBridgeLibConstructor ( } for (Idx = 0; Idx < Count; Idx++) { - PciInitController (mBaseAddresses[Idx].ExsBase, - mBaseAddresses[Idx].DbiBase, - mBaseAddresses[Idx].ConfigBase, - mBaseAddresses[Idx].IoMemBase, - &RootBridges[Idx]); + PciInitControllerPre (mBaseAddresses[Idx].ExsBase); + } + + // + // The PCIe spec requires that PERST# is asserted for at least 100 ms after + // the power and clocks have become stable. So let's give a bit or margin, + // and stall for 150 ms between asserting PERST# on both controllers and + // de-asserting it again. + // + gBS->Stall (150 * 1000); + + for (Idx = 0; Idx < Count; Idx++) { + PciInitControllerPost (mBaseAddresses[Idx].ExsBase, + mBaseAddresses[Idx].DbiBase, + mBaseAddresses[Idx].ConfigBase, + mBaseAddresses[Idx].IoMemBase, + &RootBridges[Idx]); } return EFI_SUCCESS;