summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Drivers/GenericWatchdogDxe
diff options
context:
space:
mode:
authorMarcin Wojtas <mw@semihalf.com>2018-08-02 22:50:54 +0200
committerArd Biesheuvel <ard.biesheuvel@linaro.org>2018-08-03 09:29:14 +0200
commitdd4cae4d82c7477273f3da455084844db5cca0c0 (patch)
tree36cec36eefe204f864b3f9011b2cccfa07a0fa29 /ArmPkg/Drivers/GenericWatchdogDxe
parent1d802e234e813a6726f4c6fd161ae9bd146bc552 (diff)
downloadedk2-dd4cae4d82c7477273f3da455084844db5cca0c0.tar.gz
edk2-dd4cae4d82c7477273f3da455084844db5cca0c0.tar.bz2
edk2-dd4cae4d82c7477273f3da455084844db5cca0c0.zip
ArmPkg/GenericWatchdogDxe: Split 64bit register write to 2x32bit
According to the SBSA specification the Watchdog Compare Register is split into two separate 32bit registers. EDK2 code uses a single 64bit transaction to update them, which can be problematic, depending on the SoC implementation and could result in unpredictable behavior. Fix this by modifying WatchdogWriteCompareRegister routine to use two consecutive 32bit writes to the Watchdog Compare Register Low and High, using new dedicated macros. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas <mw@semihalf.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'ArmPkg/Drivers/GenericWatchdogDxe')
-rw-r--r--ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdog.h3
-rw-r--r--ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdog.h b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdog.h
index 9e2aebcfd5..4f42c56a48 100644
--- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdog.h
+++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdog.h
@@ -20,7 +20,8 @@
// Control Frame:
#define GENERIC_WDOG_CONTROL_STATUS_REG ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x000)
#define GENERIC_WDOG_OFFSET_REG ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x008)
-#define GENERIC_WDOG_COMPARE_VALUE_REG ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x010)
+#define GENERIC_WDOG_COMPARE_VALUE_REG_LOW ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x010)
+#define GENERIC_WDOG_COMPARE_VALUE_REG_HIGH ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x014)
// Values of bit 0 of the Control/Status Register
#define GENERIC_WDOG_ENABLED 1
diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c
index 3180f01125..8ccf15366d 100644
--- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c
+++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c
@@ -56,7 +56,8 @@ WatchdogWriteCompareRegister (
UINT64 Value
)
{
- MmioWrite64 (GENERIC_WDOG_COMPARE_VALUE_REG, Value);
+ MmioWrite32 (GENERIC_WDOG_COMPARE_VALUE_REG_LOW, Value & MAX_UINT32);
+ MmioWrite32 (GENERIC_WDOG_COMPARE_VALUE_REG_HIGH, (Value >> 32) & MAX_UINT32);
}
VOID