From: "Marcin Wojtas" <mw@semihalf.com>
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 <mw@semihalf.com>
Subject: [edk2-platforms PATCH 6/6] Marvell: RealTimeClockLib: Rework LibGetWakeupTime/LibSetWakeupTime
Date: Mon, 24 May 2021 07:29:19 +0200 [thread overview]
Message-ID: <20210524052919.2496579-7-mw@semihalf.com> (raw)
In-Reply-To: <20210524052919.2496579-1-mw@semihalf.com>
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 <mw@semihalf.com>
---
Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.h | 2 +-
Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c | 29 ++++++++++----------
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.h b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.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
#define RTC_BRIDGE_TIMING_CTRL1_REG_OFFS 0x84
#define RTC_IRQ_STATUS_REG 0x90
-#define RTC_IRQ_ALARM_MASK 0x1
+#define RTC_IRQ_ALARM_MASK 0x2
#define RTC_WRITE_PERIOD_DELAY_MASK 0xFFFF
#define RTC_WRITE_PERIOD_DELAY_DEFAULT 0x3FF
#define RTC_WRITE_SETUP_DELAY_MASK (0xFFFF << 16)
diff --git a/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.c b/Silicon/Marvell/Armada7k8k/Library/RealTimeClockLib/RealTimeClockLib.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 (
{
UINT32 WakeupSeconds;
+ if (Time == NULL || Enabled == NULL || Pending == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
*Enabled = MmioRead32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG) & RTC_IRQ_ALARM_EN;
*Pending = MmioRead32 (mArmadaRtcBase + RTC_IRQ_STATUS_REG) & RTC_IRQ_ALARM_MASK;
// Ack pending alarm
- if (Pending) {
+ if (*Pending) {
MmioWrite32 (mArmadaRtcBase + RTC_IRQ_STATUS_REG, RTC_IRQ_ALARM_MASK);
}
@@ -176,14 +180,14 @@ LibSetWakeupTime (
{
UINTN WakeupSeconds;
- //
- // Because the Armada RTC uses a 32-bit counter for seconds,
- // the maximum time span is just over 136 years.
- // Time is stored in Unix Epoch format, so it starts in 1970,
- // Therefore it can not exceed the year 2106.
- //
- if ((Time->Year < 1970) || (Time->Year >= 2106)) {
- return EFI_UNSUPPORTED;
+ // Handle timer disabling case
+ if (!Enabled) {
+ RtcDelayedWrite (RTC_IRQ_2_CONFIG_REG, 0);
+ return EFI_SUCCESS;
+ }
+
+ if (Time == NULL || !IsTimeValid (Time)) {
+ return EFI_INVALID_PARAMETER;
}
// Convert time to raw seconds
@@ -195,11 +199,8 @@ LibSetWakeupTime (
// Issue delayed write to alarm register
RtcDelayedWrite (RTC_ALARM_2_REG, (UINT32)WakeupSeconds);
- if (Enabled) {
- MmioWrite32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG, RTC_IRQ_ALARM_EN);
- } else {
- MmioWrite32 (mArmadaRtcBase + RTC_IRQ_2_CONFIG_REG, 0);
- }
+ // Enable wakeup timer
+ RtcDelayedWrite (RTC_IRQ_2_CONFIG_REG, RTC_IRQ_ALARM_EN);
return EFI_SUCCESS;
}
--
2.29.0
next prev parent reply other threads:[~2021-05-24 5:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-24 5:29 [edk2-platforms PATCH 0/6] Marvell ACS fixes Marcin Wojtas
2021-05-24 5:29 ` [edk2-platforms PATCH 1/6] Marvell/Drivers: SmbiosPlatformDxe: Align Type17 to SMBIOS v3.2 Marcin Wojtas
2021-05-24 11:09 ` Samer El-Haj-Mahmoud
2021-05-24 5:29 ` [edk2-platforms PATCH 2/6] Marvell: Armada7k8k/OcteonTx: Fix RT debug prints Marcin Wojtas
2021-05-24 10:59 ` Samer El-Haj-Mahmoud
2021-05-25 11:50 ` Sunny Wang
2021-05-24 5:29 ` [edk2-platforms PATCH 3/6] Marvell: Armada7k8k/OcteonTx: Switch SPCR UART subtype to 0x1 Marcin Wojtas
2021-05-24 11:06 ` Samer El-Haj-Mahmoud
[not found] ` <1681FC02AF1B6E10.27195@groups.io>
2021-05-24 15:04 ` [edk2-devel] " Samer El-Haj-Mahmoud
2021-05-25 11:53 ` Sunny Wang
2021-05-24 5:29 ` [edk2-platforms PATCH 4/6] Marvell/Cn913xDbA: AcpiTables: Use unique UID's Marcin Wojtas
2021-05-24 11:00 ` Samer El-Haj-Mahmoud
2021-05-25 13:52 ` Sunny Wang
2021-05-24 5:29 ` [edk2-platforms PATCH 5/6] Marvell: RealTimeClockLib: Fix daylight and timezone handling Marcin Wojtas
2021-05-24 11:08 ` Samer El-Haj-Mahmoud
2021-05-24 5:29 ` Marcin Wojtas [this message]
2021-06-02 6:53 ` [edk2-platforms PATCH 6/6] Marvell: RealTimeClockLib: Rework LibGetWakeupTime/LibSetWakeupTime Ard Biesheuvel
2021-06-02 7:06 ` [edk2-platforms PATCH 0/6] Marvell ACS fixes Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210524052919.2496579-7-mw@semihalf.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox