From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=0sWsx1fS; spf=none, err=SPF record not found (domain: semihalf.com, ip: 209.85.167.65, mailfrom: mw@semihalf.com) Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by groups.io with SMTP; Tue, 16 Apr 2019 02:23:10 -0700 Received: by mail-lf1-f65.google.com with SMTP id z9so15415118lfh.6 for ; Tue, 16 Apr 2019 02:23:09 -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; bh=wufRUrK5O5YpQ6RBkUryNlr4VNlXpQgjTJsszKySxsE=; b=0sWsx1fScCkIQZuf9ozIiNiGBZ8fvvi3OpshmYVUY6V9JlB97FW8DRsvCaCEDl7qtH Y9n2qXkRvrXRh3k5RFhAb6teCpqafdWCfD3vnjV5ohfvL+trFPkKGUtodhyxZxTWvPoo CppIosjnHSY5g/devwJWVTun4wlxW2P5tvX9zMAwfNXJousH2IeqTtMeYBPt0tcsgYH+ g2pUGMndZJeRsauAjFVb8I8Nho0LE29ASHdwxuuXm928L8wpL1BMagPEXZAfC7cjA01B UbEHpFsukvrc9pIvdASBpMEr/YDS49Vt/qBT1TSK5hHnrKE+wjkQVk7CaaFDlXUqCRXr em0g== 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; bh=wufRUrK5O5YpQ6RBkUryNlr4VNlXpQgjTJsszKySxsE=; b=i1r94M4WsjhLR3ObhAsjibuzEK9Vepv18vCd16h39afASaQ2Mxj4EDJDgFNR1pssbD CH/Ac7zbVOCmVN+dBjBq1zhkXrxdNd7ShWExueQx3YpZsOpQE+AxkVEcf1LUrcbuKFZS kX33HsblVGtC4ERwTBP7/Led8DANSF3BXIdMDRHXAhJGHwaBN6bSwGMadZDoBPw6Bk46 fotmgzHXT79N7Z7g3KDFJJcizj5APz43FP3ixPGp/nfn50qFrhLIKGyU7U+2LyhyYWBg I4AsLOLh4cAnNDpECm8edAIyV7S92CPRlCKIfg1Oq4wNnsdrqbQIBBHLfB3uqGykOs77 rUaA== X-Gm-Message-State: APjAAAX+TfrG3jeUOpNYvPCeOg2DrC+xjrZRQeKzrfAvcK1WKp0P9gkf kKtZUnrCZKAiZY6azMOyrvmAEb01vOZqbQ== X-Google-Smtp-Source: APXvYqwMLqVGJxeBBfyVdsgkVf7ZJWDcqDH0FBPWFZT5BmIIeY8nO18R+jTtqozGhHIhCji+3Unnkw== X-Received: by 2002:ac2:54a9:: with SMTP id w9mr22641459lfk.125.1555406587857; Tue, 16 Apr 2019 02:23:07 -0700 (PDT) Return-Path: Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id v141sm2941504lfa.52.2019.04.16.02.23.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Apr 2019 02:23:07 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com, kostap@marvell.com, jeremy.linton@arm.com, Jici.Gao@arm.com Subject: [edk2-platforms: PATCH v2 3/6] Marvell/Armada7k8k: Implement PMU interrupt handling Date: Tue, 16 Apr 2019 11:22:23 +0200 Message-Id: <1555406546-5261-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555406546-5261-1-git-send-email-mw@semihalf.com> References: <1555406546-5261-1-git-send-email-mw@semihalf.com> Generic handling of the PMU interrupts in UEFI and Linux with ACPI require enabling a dedicated handler in the EL3. Extend the PlatInitDxe with enabler code. Because for DT world the EL3 service must remain disabled, switch it off in the ExitBootServicesEvent. Its execution depends on the gEdkiiPlatformHasAcpiGuid status check in the new gEfiEventReadyToBootGuid routine. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf | 6 ++ Silicon/Marvell/Include/IndustryStandard/MvSmc.h | 2 + Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.c | 82 ++++++++++++++++++++ 3 files changed, 90 insertions(+) diff --git a/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf b/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf index e707fe9..df10526 100644 --- a/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf +++ b/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.inf @@ -25,6 +25,7 @@ PlatInitDxe.c [Packages] + ArmPkg/ArmPkg.dec EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec @@ -32,6 +33,7 @@ [LibraryClasses] ArmadaIcuLib + ArmSmcLib ComPhyLib DebugLib MppLib @@ -40,6 +42,10 @@ UefiDriverEntryPoint UtmiPhyLib +[Guids] + gEdkiiPlatformHasAcpiGuid + gEfiEventReadyToBootGuid + [Protocols] gMarvellPlatformInitCompleteProtocolGuid ## PRODUCES diff --git a/Silicon/Marvell/Include/IndustryStandard/MvSmc.h b/Silicon/Marvell/Include/IndustryStandard/MvSmc.h index 0c90f11..e5c89d9 100644 --- a/Silicon/Marvell/Include/IndustryStandard/MvSmc.h +++ b/Silicon/Marvell/Include/IndustryStandard/MvSmc.h @@ -20,5 +20,7 @@ #define MV_SMC_ID_COMPHY_POWER_OFF 0x82000002 #define MV_SMC_ID_COMPHY_PLL_LOCK 0x82000003 #define MV_SMC_ID_DRAM_SIZE 0x82000010 +#define MV_SMC_ID_PMU_IRQ_ENABLE 0x82000012 +#define MV_SMC_ID_PMU_IRQ_DISABLE 0x82000013 #endif //__MV_SMC_H__ diff --git a/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.c b/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.c index 18b6783..4012fd7 100644 --- a/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.c +++ b/Silicon/Marvell/Armada7k8k/Drivers/PlatInitDxe/PlatInitDxe.c @@ -12,7 +12,12 @@ **/ +#include + +#include + #include +#include #include #include #include @@ -21,6 +26,62 @@ #include #include +STATIC EFI_EVENT mArmada7k8kExitBootServicesEvent; + +/** + Disable extra EL3 handling of the PMU interrupts for DT world. + + @param[in] Event Event structure + @param[in] Context Notification context + +**/ +STATIC +VOID +Armada7k8kExitBootServicesHandler ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + ARM_SMC_ARGS SmcRegs = {0}; + + SmcRegs.Arg0 = MV_SMC_ID_PMU_IRQ_DISABLE; + ArmCallSmc (&SmcRegs); + + return; +} + +/** + Check if we boot with DT and trigger EBS event in such case. + + @param[in] Event Event structure + @param[in] Context Notification context + +**/ +STATIC +VOID +Armada7k8kOnReadyToBootHandler ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + VOID *Interface; + + Status = gBS->LocateProtocol (&gEdkiiPlatformHasAcpiGuid, + NULL, + (VOID **)&Interface); + if (EFI_ERROR (Status)) { + Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_NOTIFY, + Armada7k8kExitBootServicesHandler, + NULL, + &mArmada7k8kExitBootServicesEvent); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Fail to register EBS event\n", __FUNCTION__)); + } + } +} + EFI_STATUS EFIAPI ArmadaPlatInitDxeEntryPoint ( @@ -28,7 +89,9 @@ ArmadaPlatInitDxeEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { + ARM_SMC_ARGS SmcRegs = {0}; EFI_STATUS Status; + EFI_EVENT Event; DEBUG ((DEBUG_ERROR, "\nArmada Platform Init\n\n")); @@ -43,5 +106,24 @@ ArmadaPlatInitDxeEntryPoint ( MppInitialize (); ArmadaIcuInitialize (); + /* + * Enable EL3 PMU interrupt handler and + * register the ReadyToBoot event. + */ + SmcRegs.Arg0 = MV_SMC_ID_PMU_IRQ_ENABLE; + ArmCallSmc (&SmcRegs); + + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + Armada7k8kOnReadyToBootHandler, + NULL, + &gEfiEventReadyToBootGuid, + &Event); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "%a: Fail to register OnReadyToBoot event\n", + __FUNCTION__)); + } + return EFI_SUCCESS; } -- 2.7.4