From patchwork Wed Nov 15 13:06:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118947 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4288454qgn; Wed, 15 Nov 2017 05:06:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMaeMytQ0ukNZbmHfOI12Xdkj83vUCtMcIFy7UGke7ezeQCFBhIpUawef/XCcHMzmtwFzaCE X-Received: by 10.98.109.134 with SMTP id i128mr17759398pfc.66.1510751216221; Wed, 15 Nov 2017 05:06:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510751216; cv=none; d=google.com; s=arc-20160816; b=Kxk5R1Nrw2d0aUIlbw8shH0xNCoWGGuw0N9xn3rVxcT/+xYmT5r+0icJ6zkF7o2Euv t4CCwSfg4VYhpnMpM/ca2w6YD6WH9gEtww16cv7oLKCK2tiy9sz3CeKHa3VBU/U/ZOqA xUIpxrNfm4m+Yh0M8HHVLeh0v8e3XyehQobSUtwzm2jcd3KkWt7AfHKS97AvxzehKUZQ Yj7SapBtwBPBJYI6fGgHy8EcBjoBDE++s+0UZC1iEPDgMB106/l4OyLzWPbXu/qRGEBR 4sntHMFhFgg2kwp12K1BHWUbLI5NC42atUwygSx4t44YHOCqLC8/xaD0+hjT9RhgwXrY XN0Q== 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:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=KQLcJXV2rQTfitNq2Mh0vdEip+yiv4n2Pk6MohJaguc=; b=WKq5/dor1kFL/1pK+0hW1BtTlpYdIELorvb4EkoLoy2gCEQxbxKIuMGWOsYcjc1a3D WVvhZP5DDeKM3vp0WWGcj4EK7DIVgUqdnIE2a7TYnYRuilXqe5hLxeIhPA9Z5gXClf9i ugMC7ecbrPXvESMccGkAs00JMC/3gFM1iUJj5YrJvTSQ3OwPbug4N+F6YsqemTUvifrJ Vs04goh40Jv0YgxXHqMxYtXz8ta4TCUr0/NL8BPu29MrTPDYh6Er3yQfg1j7JqIL+w3x BP0n/+9Qip8V8sFWooZweva0jO9W1Yd6Gms1DCPDlIrO+n2bYsMQ22jahbOrBTpc3pfJ rSSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TSspYkp5; 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 64si17987600plk.144.2017.11.15.05.06.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 05:06:56 -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=TSspYkp5; 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 875D220355209; Wed, 15 Nov 2017 05:02: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:c09::22a; helo=mail-wm0-x22a.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x22a.google.com (mail-wm0-x22a.google.com [IPv6:2a00:1450:400c:c09::22a]) (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 684622034EE30 for ; Wed, 15 Nov 2017 05:02:44 -0800 (PST) Received: by mail-wm0-x22a.google.com with SMTP id 9so2857390wme.4 for ; Wed, 15 Nov 2017 05:06:53 -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; bh=NW9unjsl6uO3y8YoRXX4gOukWiSiHibEJOJlOlaGyhw=; b=TSspYkp58JOt8uxyD6q2EygR+l4l3KDEMvfo6g2LZ/VAI1NZokQGgWATwxLYhpZljo J7jfClv8I0hBZMISykPBPLpLE25lnsGKcEHtrp2tUmhT7kS1NmUwt0U+OcAw9ls9kDUd nQns+8tb0b0PaBrenkwtQf5/asOSXezzSgRs4= 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; bh=NW9unjsl6uO3y8YoRXX4gOukWiSiHibEJOJlOlaGyhw=; b=ltksVrTY1ub7h+uSzUpuuYlg94P6jUAFFhMdsPVO4k5p+xfYDDPSa5T9nvzCO/2s2E 1TUjG9WnTHMCHs+bqsajaNRyAZfEk/osrJ6hB59Y0jpicEKcBU4ZzOqydMwZeZljdM6Q G2Edinua6gn43D48suW0G6Wr8hIUEu2PRoir/jX+x2A1e+BhxNUX85q0nCbQIlvRakie v6xBxz7c+HQG2LQuSS0iS8F7UGktU24jWeOwkoKvXLt2hdvzS8WfSABz4aIo8c0dH/+c EDe4i+Ncc2D7x5bFunu8pPBXRrp4ZQNvOBLhNw48rPjlzRX8cKdR5e2gWODps+z3kFBC 3tAQ== X-Gm-Message-State: AJaThX6GSFmpRLwtorLSGQr3c32bBXAOYvDLHtV/ttBiFVYn2q9mjvp/ rnsxyaq1mqChTPBWgbWJmCGuytbhlw8= X-Received: by 10.28.209.77 with SMTP id i74mr1174221wmg.53.1510751211366; Wed, 15 Nov 2017 05:06:51 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id s12sm50867809wrc.89.2017.11.15.05.06.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 05:06:50 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Wed, 15 Nov 2017 13:06:45 +0000 Message-Id: <20171115130645.31738-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [edk2] [PATCH] ArmPlatformPkg/PL031RealTimeClockLib: drop ArmPlatformSysConfigLib reference 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: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The PL031 driver implements a VExpress/Juno specific hack to set the battery backed clock in addition to the PL031. However, none of the remaining VExpress based hardware we support in EDK2 actuall implements this feature so we can just remove it, and get rid of the cumbersome dependency on ArmPlatform.h. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c | 43 +++----------------- 1 file changed, 6 insertions(+), 37 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/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c index 459dcc0a0519..1334ad446cd9 100644 --- a/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c +++ b/ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -38,8 +37,6 @@ #include -#include - STATIC BOOLEAN mPL031Initialized = FALSE; STATIC EFI_EVENT mRtcVirtualAddrChangeEvent; STATIC UINTN mPL031RtcBase; @@ -133,6 +130,11 @@ LibGetTime ( EFI_STATUS Status = EFI_SUCCESS; UINT32 EpochSeconds; + // Ensure Time is a valid pointer + if (Time == NULL) { + return EFI_INVALID_PARAMETER; + } + // Initialize the hardware if not already done if (!mPL031Initialized) { Status = InitializePL031 (); @@ -141,27 +143,7 @@ LibGetTime ( } } - // Snapshot the time as early in the function call as possible - // On some platforms we may have access to a battery backed up hardware clock. - // If such RTC exists try to use it first. - Status = ArmPlatformSysConfigGet (SYS_CFG_RTC, &EpochSeconds); - if (Status == EFI_UNSUPPORTED) { - // Battery backed up hardware RTC does not exist, revert to PL031 - EpochSeconds = MmioRead32 (mPL031RtcBase + PL031_RTC_DR_DATA_REGISTER); - Status = EFI_SUCCESS; - } else if (EFI_ERROR (Status)) { - // Battery backed up hardware RTC exists but could not be read due to error. Abort. - return Status; - } else { - // Battery backed up hardware RTC exists and we read the time correctly from it. - // Now sync the PL031 to the new time. - MmioWrite32 (mPL031RtcBase + PL031_RTC_LR_LOAD_REGISTER, EpochSeconds); - } - - // Ensure Time is a valid pointer - if (Time == NULL) { - return EFI_INVALID_PARAMETER; - } + EpochSeconds = MmioRead32 (mPL031RtcBase + PL031_RTC_DR_DATA_REGISTER); // Adjust for the correct time zone // The timezone setting also reflects the DST setting of the clock @@ -235,19 +217,6 @@ LibSetTime ( EpochSeconds -= SEC_PER_HOUR; } - // On some platforms we may have access to a battery backed up hardware clock. - // - // If such RTC exists then it must be updated first, before the PL031, - // to minimise any time drift. This is important because the battery backed-up - // RTC maintains the master time for the platform across reboots. - // - // If such RTC does not exist then the following function returns UNSUPPORTED. - Status = ArmPlatformSysConfigSet (SYS_CFG_RTC, EpochSeconds); - if ((EFI_ERROR (Status)) && (Status != EFI_UNSUPPORTED)){ - // Any status message except SUCCESS and UNSUPPORTED indicates a hardware failure. - return Status; - } - // Set the PL031 MmioWrite32 (mPL031RtcBase + PL031_RTC_LR_LOAD_REGISTER, EpochSeconds);