From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by mx.groups.io with SMTP id smtpd.web08.19185.1621834180641212617 for ; Sun, 23 May 2021 22:29:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=pyjmy+OJ; spf=none, err=SPF record not found (domain: semihalf.com, ip: 209.85.208.179, mailfrom: mw@semihalf.com) Received: by mail-lj1-f179.google.com with SMTP id c15so31915027ljr.7 for ; Sun, 23 May 2021 22:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2rMsPFFZYVTVpgEzU6wfjnyAOWoVTrk14XEtgwqbi5c=; b=pyjmy+OJw832D8UYcKBl/smFFi2HjNfWSh0W/mP1odm3LzcafcM4LgoK0wMKnxwlXV 33O0Jf9np6/Lqvc3XC6B4Ajzx9fyNFyV2mHfTKOgXXe6xZ+xngtRqn4muX0s8V6Z7ihB uqHV7m2hVcZ7L6BDSzloJ/d3aLGtXRkD8zjziX1EH3eRHB4g0VXyPHF8oe3GSbJbQFnp MP0gOU1/MpDg0i6nDEqbicQfplDNcrK4ohXzp9ETd/5mYieIH5qfwLJ8lCCtczaw15Wp AMESz2LtLecU6LVj2gLp9gjRAuVXwYRx7JZIRf+7/ar+tXBPfmunQeAofK45asuoHpKa UK2g== 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:mime-version:content-transfer-encoding; bh=2rMsPFFZYVTVpgEzU6wfjnyAOWoVTrk14XEtgwqbi5c=; b=SqJwrLtJwB++PRdYbqSnn4NKtPSrPz2NXME1wHiXGxZLoAfkG8dwV23wiuzeYoWEnI i6yUaIbx6UuBgwPUHVNgEVwbnmAZ5bjuQAZSFPm091WhEkNu63XVpFkNqfLdUshTQMCR dVMWklg+0q2m52V1E1k+MCz5WSL5BQnzgauj+1prgUTtrcS42bhBx//JbXJm8QNTfhG2 brAGKnB3+oQMZzSornIgh4+JbGWUO4M53tj8JKb19xNG7pPjSbAMFVyoMDxbNVOs9aDO D+rGkiKlMUGemSb1v1KR8vTTiW2u0QMEXJh9Hw0wp8o9oIRtyafb/3bFFXzbpzms3RKk OYZw== X-Gm-Message-State: AOAM530qTj3zIKKSj1xQmRupK66q2gkAOrzaBKpNdSZYtHd24yNjndcQ DOFKP4KRBMtYPENoRjyP7p8e9objoa7DbqvZ X-Google-Smtp-Source: ABdhPJxQipLBEQTwDd9GXG6bNWmeJ5UHg/qvfH0mmCpUAEdYGQ2GH2Do4GabeccHmc7Eel0AGzS0ug== X-Received: by 2002:a05:651c:1063:: with SMTP id y3mr15410659ljm.183.1621834178965; Sun, 23 May 2021 22:29:38 -0700 (PDT) Return-Path: Received: from gilgamesh.semihalf.com (host-193.106.246.138.static.3s.pl. [193.106.246.138]) by smtp.gmail.com with ESMTPSA id w17sm90739lfp.300.2021.05.23.22.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 May 2021 22:29:38 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: leif@nuviainc.com, ardb+tianocore@kernel.org, Samer.El-Haj-Mahmoud@arm.com, sunny.Wang@arm.com, gjb@semihalf.com, upstream@semihalf.com, Marcin Wojtas Subject: [edk2-platforms PATCH 6/6] Marvell: RealTimeClockLib: Rework LibGetWakeupTime/LibSetWakeupTime Date: Mon, 24 May 2021 07:29:19 +0200 Message-Id: <20210524052919.2496579-7-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210524052919.2496579-1-mw@semihalf.com> References: <20210524052919.2496579-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Apply multiple fixes to the Marvell RealTimeClockLib wakeup library callbacks. LibGetWakeupTime: * Add input parameters validation * Fix 'Pending' value check LibSetWakeupTime: * Allow disabling the wakeup timer regardless the input 'Time' value * Use more generic 'Time' value verification, which is more strict than the replaced custom one. * Use proper alarm mask for 'Pending' signalling With above the ACS3.0 FWTS and SCT timer tests pass cleanly. Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.h | = 2 +- Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c | 2= 9 ++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeCl= ockLib.h b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeCloc= kLib.h index 7fa1d092e4..c33e63d107 100644 --- a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.h +++ b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.h @@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define RTC_BRIDGE_TIMING_CTRL0_REG_OFFS 0x80=0D #define RTC_BRIDGE_TIMING_CTRL1_REG_OFFS 0x84=0D #define RTC_IRQ_STATUS_REG 0x90=0D -#define RTC_IRQ_ALARM_MASK 0x1=0D +#define RTC_IRQ_ALARM_MASK 0x2=0D #define RTC_WRITE_PERIOD_DELAY_MASK 0xFFFF=0D #define RTC_WRITE_PERIOD_DELAY_DEFAULT 0x3FF=0D #define RTC_WRITE_SETUP_DELAY_MASK (0xFFFF << 16)=0D diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeCl= ockLib.c b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeCloc= kLib.c index a48d44ed83..49c9385d53 100644 --- a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c +++ b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c @@ -140,11 +140,15 @@ LibGetWakeupTime ( {=0D UINT32 WakeupSeconds;=0D =0D + if (Time =3D=3D NULL || Enabled =3D=3D NULL || Pending =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D *Enabled =3D MmioRead32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG) & RTC_IR= Q_ALARM_EN;=0D =0D *Pending =3D MmioRead32 (mArmadaRtcBase + RTC_IRQ_STATUS_REG) & RTC_IRQ_= ALARM_MASK;=0D // Ack pending alarm=0D - if (Pending) {=0D + if (*Pending) {=0D MmioWrite32 (mArmadaRtcBase + RTC_IRQ_STATUS_REG, RTC_IRQ_ALARM_MASK);= =0D }=0D =0D @@ -176,14 +180,14 @@ LibSetWakeupTime ( {=0D UINTN WakeupSeconds;=0D =0D - //=0D - // Because the Armada RTC uses a 32-bit counter for seconds,=0D - // the maximum time span is just over 136 years.=0D - // Time is stored in Unix Epoch format, so it starts in 1970,=0D - // Therefore it can not exceed the year 2106.=0D - //=0D - if ((Time->Year < 1970) || (Time->Year >=3D 2106)) {=0D - return EFI_UNSUPPORTED;=0D + // Handle timer disabling case=0D + if (!Enabled) {=0D + RtcDelayedWrite (RTC_IRQ_2_CONFIG_REG, 0);=0D + return EFI_SUCCESS;=0D + }=0D +=0D + if (Time =3D=3D NULL || !IsTimeValid (Time)) {=0D + return EFI_INVALID_PARAMETER;=0D }=0D =0D // Convert time to raw seconds=0D @@ -195,11 +199,8 @@ LibSetWakeupTime ( // Issue delayed write to alarm register=0D RtcDelayedWrite (RTC_ALARM_2_REG, (UINT32)WakeupSeconds);=0D =0D - if (Enabled) {=0D - MmioWrite32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG, RTC_IRQ_ALARM_EN);= =0D - } else {=0D - MmioWrite32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG, 0);=0D - }=0D + // Enable wakeup timer=0D + RtcDelayedWrite (RTC_IRQ_2_CONFIG_REG, RTC_IRQ_ALARM_EN);=0D =0D return EFI_SUCCESS;=0D }=0D --=20 2.29.0