From nobody Thu Apr 18 09:53:50 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+66026+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+66026+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1602169473; cv=none; d=zohomail.com; s=zohoarc; b=Z99lno6emnHvQ/je5xsQ/vy2lHDuYpheTynrcDUbgcz/iUvYqD3M9TtDN9aQ6vOmOWbnPDeBmNn9gJfAAR3TGKuK+SzHC9UqXGHByacM9aFovHnfPHn9H2ONmM3HrecxMY61gagaLhzWqRX86JhAbZug5Q+rkb6Ghlh+1r1lvI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602169473; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=olRjuCqLf/xrD8vf4BExFKeVtPkhb4ZvnFt5C+K2Nf0=; b=VvdJWhlDIjKtWGhPoe18U+vV5IDYI/tl/yCjtHxIrSlj18e78cUEMzC5DSPIxYzfOfXuAVNlnssb9tKifjLAu8TFj42F7awrjCwfnvxIpDfJqF6lwReS2BUuj4F41JpyduA4nZfr/LqfSoOHsYofkEkKmF7vj8iyAvrNTVbjWxw= 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+66026+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1602169473026700.3838414168076; Thu, 8 Oct 2020 08:04:33 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RVpKYY1788612xGWVW8Sf2sk; Thu, 08 Oct 2020 08:04:32 -0700 X-Received: from mail-pf1-f228.google.com (mail-pf1-f228.google.com [209.85.210.228]) by mx.groups.io with SMTP id smtpd.web12.14034.1602168996975445529 for ; Thu, 08 Oct 2020 07:56:37 -0700 X-Received: by mail-pf1-f228.google.com with SMTP id g10so4207449pfc.8 for ; Thu, 08 Oct 2020 07:56:36 -0700 (PDT) X-Gm-Message-State: mABdcZdoC3MEsVRo22figuJVx1787277AA= X-Google-Smtp-Source: ABdhPJxQBG/DMDPGhx/OBIHsUQ4R7irb5e8/5gdoRk3LIVPNCpO82PoBaPjNYiEX93fIhz07Swj+Kfco2ZTq X-Received: by 2002:a17:90a:6a4f:: with SMTP id d15mr8696875pjm.80.1602168996063; Thu, 08 Oct 2020 07:56:36 -0700 (PDT) X-Received: from rbuild18.dhcp.broadcom.net ([192.19.234.250]) by smtp-relay.gmail.com with ESMTPS id bb23sm439479pjb.5.2020.10.08.07.56.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2020 07:56:36 -0700 (PDT) X-Relaying-Domain: broadcom.com From: "rajesh.ravi@broadcom.com 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 20:26:08 +0530 Message-Id: <20201008145608.15737-2-rajesh.ravi@broadcom.com> In-Reply-To: <20201008145608.15737-1-rajesh.ravi@broadcom.com> References: <20201008145608.15737-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=1602169472; bh=rj/4h55PnIvZzT7ttG4N5DO6Psrb0D8SdKTVPa7P96o=; h=Cc:Date:From:Reply-To:Subject:To; b=GT1vz66W/Ymsnlsj8lN0ILMLazZBr3COUvL565oz1lo7/sj0bSa1W9ivyUOjOspld9C IDfHR/1wz0J57Vz1H0/BaNXxsj3fiDmYFME/RApC3DE1aeMdZed983DCVT02WU1Y1iw48 eC4IQ8WzftD7JzZn8MC8HJh4OyNCle13q8c= 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 (#66026): https://edk2.groups.io/g/devel/message/66026 Mute This Topic: https://groups.io/mt/77385190/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-