From nobody Tue Apr 23 07:46:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+66023+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+66023+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1602165289; cv=none; d=zohomail.com; s=zohoarc; b=WsYyIfwtamsg1hlG3iyFJKU9jL/nVfO+9x1lK9zI2sTmDeM3LGBLw4vLph2zOXGjCJPMuiIsuoGDXPccEHMV2IJushcgQNXeLN4kfbd2bkpA/6IoUBX39Rf42RXyj/+4s9L8YPWAtSSwvPO40DRCi/N1JkxJuw4UaOTGT5r3+1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602165289; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=iQhz5Gd31iCeUuLI2m8hzPHexBaiDjqBKpIj9XYGvNI=; b=YhCuK1KU4zxLiPFIIdkmfl7bxOb+8N9BEJGNJZC2HV+KTDV7c9Uk+G+AC7T3Ah35t0FoLbok1K546RY7X03MMcCkSfQ4hoJNbW2W4jyhTfu9lu9wzJSkfDIWRquR1OVCTi9zcfbhNBw+qs0pepaEAwRKAXxxFbHM2H9HCWfNpYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+66023+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1602165289603481.2096375073213; Thu, 8 Oct 2020 06:54:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 1F8RYY1788612xRqw8dTzmmG; Thu, 08 Oct 2020 06:54:48 -0700 X-Received: from mail-ot1-f97.google.com (mail-ot1-f97.google.com [209.85.210.97]) by mx.groups.io with SMTP id smtpd.web11.7587.1602146834146103748 for ; Thu, 08 Oct 2020 01:47:14 -0700 X-Received: by mail-ot1-f97.google.com with SMTP id f10so4814118otb.6 for ; Thu, 08 Oct 2020 01:47:14 -0700 (PDT) X-Gm-Message-State: z3ouGU82JIYHV7PgY82kVuFVx1787277AA= X-Google-Smtp-Source: ABdhPJzu+sKUwrhxWesn9vpsnbtklEM061J/vyviqXjEx7Ac/2GICMeUD4mg8KOTUx5SP+Y2jLiq9X3A+aPp X-Received: by 2002:a9d:6959:: with SMTP id p25mr4116520oto.96.1602146833099; Thu, 08 Oct 2020 01:47:13 -0700 (PDT) X-Received: from rbuild18.dhcp.broadcom.net ([192.19.234.250]) by smtp-relay.gmail.com with ESMTPS id r19sm681361ooj.9.2020.10.08.01.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 01:47:13 -0700 (PDT) X-Relaying-Domain: broadcom.com From: "rajesh.ravi via groups.io" To: devel@edk2.groups.io Cc: Rajesh Ravi , Leif Lindholm , Ard Biesheuvel Subject: [edk2-devel] [PATCH v1 1/1] ArmPkg/GenericWatchdogDxe: Add rev 1 support to ARM Generic Watchdog driver Date: Thu, 8 Oct 2020 14:16:36 +0530 Message-Id: <20201008084636.14782-2-rajesh.ravi@broadcom.com> In-Reply-To: <20201008084636.14782-1-rajesh.ravi@broadcom.com> References: <20201008084636.14782-1-rajesh.ravi@broadcom.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rajesh.ravi@broadcom.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1602165288; bh=3MoD3bNnj/niwkIXEzjZf2UqG4c7UxPy3ZEbF1JaGWY=; h=Cc:Date:From:Reply-To:Subject:To; b=rdQ2otWzsPO+Sgin4jub+PtKPylmGFOwy4/2CS4YI2Y5XiCxzvOoyX7Ho82nC19jrV5 YmIqLJmNaJ93qdjrwT9L6Bv6aFMkHng5ziXz+h4QzlR/JMQCWrkBg7skQgeSsRRaR9aSm X1IVm8P5jYogh4dbLegE3OWeaoXinE0/l0A= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Rajesh Ravi Add SBSA watchdog rev 1 support to ARM Generic Watchdog driver. Signed-off-by: Rajesh Ravi Cc: Leif Lindholm Cc: Ard Biesheuvel --- ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdog.h | 8 ++- ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c | 53 ++++++++++++++= ++++-- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdog.h b/ArmPkg/D= rivers/GenericWatchdogDxe/GenericWatchdog.h index c64bc5c4627d..ed74bcf95021 100644 --- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdog.h +++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdog.h @@ -13,12 +13,18 @@ =20 // Control Frame: #define GENERIC_WDOG_CONTROL_STATUS_REG ((UINTN)FixedPcdGet64 (PcdGe= nericWatchdogControlBase) + 0x000) -#define GENERIC_WDOG_OFFSET_REG ((UINTN)FixedPcdGet64 (PcdGe= nericWatchdogControlBase) + 0x008) +#define GENERIC_WDOG_OFFSET_REG_LOW ((UINTN)FixedPcdGet64 (PcdGe= nericWatchdogControlBase) + 0x008) +#define GENERIC_WDOG_OFFSET_REG_HIGH ((UINTN)FixedPcdGet64 (PcdGe= nericWatchdogControlBase) + 0x00C) #define GENERIC_WDOG_COMPARE_VALUE_REG_LOW ((UINTN)FixedPcdGet64 (PcdGe= nericWatchdogControlBase) + 0x010) #define GENERIC_WDOG_COMPARE_VALUE_REG_HIGH ((UINTN)FixedPcdGet64 (PcdGe= nericWatchdogControlBase) + 0x014) +#define GENERIC_WDOG_IIDR_REG ((UINTN)FixedPcdGet64 (PcdGe= nericWatchdogControlBase) + 0xFCC) =20 // Values of bit 0 of the Control/Status Register #define GENERIC_WDOG_ENABLED 1 #define GENERIC_WDOG_DISABLED 0 +#define GENERIC_WDOG_ARCH_REV_OFFSET 16 +#define GENERIC_WDOG_ARCH_REV_MASK 0xF +#define SBSA_WDOG_WOR_WIDTH 48 +#define MAX_OFFSET_REG_VAL (((UINT64)1 << 48) - 1) =20 #endif // __GENERIC_WATCHDOG_H__ diff --git a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c b/ArmPk= g/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c index f79cc9170f8a..7ef9b1ff08ab 100644 --- a/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c +++ b/ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c @@ -35,16 +35,53 @@ STATIC UINTN mTimerFrequencyHz =3D 0; It is therefore stored here. 0 means the timer is not running. */ STATIC UINT64 mNumTimerTicks =3D 0; =20 +STATIC UINT32 mWatchDogRev =3D 0; + +STATIC UINT64 mWatchdogMaxOffsetVal =3D MAX_UINT32; + STATIC EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol; STATIC EFI_WATCHDOG_TIMER_NOTIFY mWatchdogNotify; =20 +STATIC +inline +UINT32 +WatchdogReadRevisionRegister ( + VOID + ) +{ + return MmioRead32 (GENERIC_WDOG_IIDR_REG); +} + +STATIC +inline +UINT32 +WatchdogGetRevision ( + VOID + ) +{ + UINT32 IidrRegVal; + + IidrRegVal =3D WatchdogReadRevisionRegister(); + + return ((IidrRegVal >> GENERIC_WDOG_ARCH_REV_OFFSET) & GENERIC_WDOG_ARCH= _REV_MASK); +} + STATIC VOID WatchdogWriteOffsetRegister ( - UINT32 Value + UINT64 Value ) { - MmioWrite32 (GENERIC_WDOG_OFFSET_REG, Value); + if(Value >> SBSA_WDOG_WOR_WIDTH) { + return; + } + + MmioWrite32 (GENERIC_WDOG_OFFSET_REG_LOW, ((UINT32)Value & MAX_UINT32)); + if (mWatchDogRev) { + MmioWrite32 (GENERIC_WDOG_OFFSET_REG_HIGH, (Value >> 32) & MAX_UINT32); + } else { + MmioWrite32 (GENERIC_WDOG_OFFSET_REG_HIGH, 0); + } } =20 STATIC @@ -207,12 +244,12 @@ WatchdogSetTimerPeriod ( /* If the number of required ticks is greater than the max the watchdog's offset register (WOR) can hold, we need to manually compute and set the compare register (WCV) */ - if (mNumTimerTicks > MAX_UINT32) { + if (mNumTimerTicks > mWatchdogMaxOffsetVal) { /* We need to enable the watchdog *before* writing to the compare regi= ster, because enabling the watchdog causes an "explicit refresh", which clobbers the compare register (WCV). In order to make sure this doe= sn't trigger an interrupt, set the offset to max. */ - WatchdogWriteOffsetRegister (MAX_UINT32); + WatchdogWriteOffsetRegister (MAX_OFFSET_REG_VAL); WatchdogEnable (); SystemCount =3D ArmGenericTimerGetSystemCount (); WatchdogWriteCompareRegister (SystemCount + mNumTimerTicks); @@ -319,6 +356,14 @@ GenericWatchdogEntry ( mTimerFrequencyHz =3D ArmGenericTimerGetTimerFreq (); ASSERT (mTimerFrequencyHz !=3D 0); =20 + mWatchDogRev =3D WatchdogGetRevision(); + + if (mWatchDogRev) { + mWatchdogMaxOffsetVal =3D MAX_OFFSET_REG_VAL; + } else { + mWatchdogMaxOffsetVal =3D MAX_UINT32; + } + // Install interrupt handler Status =3D mInterruptProtocol->RegisterInterruptSource (mInterruptProtoc= ol, FixedPcdGet32 (PcdGenericWatchdogEl2IntrN= um), --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#66023): https://edk2.groups.io/g/devel/message/66023 Mute This Topic: https://groups.io/mt/77383837/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-