D02/D03: workaround to fix timer interrupt issue

Timer interrupt cannot be reported after EDK2 commit 7989300, for GIC
on D02/D03 is not fully ARM GIC compliant. The issue has been fixed on
newer chips so we use a workaround for D02 and D03 only.
On D02 and D03, IRQ will be latched in GIC logic except virtual timer
interrupt IRQ #27, so we change to use virtual timer instead of physical
in UEFI.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
diff --git a/Platforms/Hisilicon/D02/Pv660D02.dsc b/Platforms/Hisilicon/D02/Pv660D02.dsc
index d025bdd..2228e51 100644
--- a/Platforms/Hisilicon/D02/Pv660D02.dsc
+++ b/Platforms/Hisilicon/D02/Pv660D02.dsc
@@ -72,6 +72,13 @@
   PlatformBdsLib|OpenPlatformPkg/Chips/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf

   CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf

 

+## GIC on D02/D03 is not fully ARM GIC compatible: IRQ cannot be cancelled when

+## input signal is de-asserted, except for virtual timer interrupt IRQ #27.

+## So we choose to use virtual timer instead of physical one as a workaround.

+## This library instance is to override the original define in LibraryClasses.AARCH64 in Pv660.dsc.inc.

+[LibraryClasses.AARCH64]

+  ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.inf

+

 [LibraryClasses.common.SEC]

   ArmPlatformLib|OpenPlatformPkg/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibSec.inf

 

@@ -341,8 +348,7 @@
 

   ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

 

-  #ArmPkg/Drivers/TimerDxe/TimerDxe

-  ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf

+  ArmPkg/Drivers/TimerDxe/TimerDxe.inf

   ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf

 

   IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf

diff --git a/Platforms/Hisilicon/D02/Pv660D02.fdf b/Platforms/Hisilicon/D02/Pv660D02.fdf
index 69be1f1..fa0dc2d 100644
--- a/Platforms/Hisilicon/D02/Pv660D02.fdf
+++ b/Platforms/Hisilicon/D02/Pv660D02.fdf
@@ -195,7 +195,7 @@
   #INF EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf

 

   INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

-  INF ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf

+  INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf

   INF ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf

 

   #

diff --git a/Platforms/Hisilicon/D03/D03.dsc b/Platforms/Hisilicon/D03/D03.dsc
index 83a18b1..6d82627 100644
--- a/Platforms/Hisilicon/D03/D03.dsc
+++ b/Platforms/Hisilicon/D03/D03.dsc
@@ -81,6 +81,14 @@
 

   LpcLib|OpenPlatformPkg/Chips/Hisilicon/Binary/Hi1610/Library/LpcLib/LpcLib.inf

   SerialPortLib|OpenPlatformPkg/Chips/Hisilicon/Binary/Hi1610/Library/Uart/LpcSerialPortLib/LpcSerialPortLib.inf

+

+## GIC on D02/D03 is not fully ARM GIC compatible: IRQ cannot be cancelled when

+## input signal is de-asserted, except for virtual timer interrupt IRQ #27.

+## So we choose to use virtual timer instead of physical one as a workaround.

+## This library instance is to override the original define in LibraryClasses.AARCH64 in Pv660.dsc.inc.

+[LibraryClasses.AARCH64]

+  ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerVirtCounterLib/ArmGenericTimerVirtCounterLib.inf

+

 [LibraryClasses.common.SEC]

   ArmPlatformLib|OpenPlatformPkg/Chips/Hisilicon/Library/ArmPlatformLibPv660/ArmPlatformLibSec.inf

 

@@ -396,7 +404,7 @@
 

   ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

 

-  ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf

+  ArmPkg/Drivers/TimerDxe/TimerDxe.inf

 

   ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf

   IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf

diff --git a/Platforms/Hisilicon/D03/D03.fdf b/Platforms/Hisilicon/D03/D03.fdf
index 8144151..8ba3bd0 100644
--- a/Platforms/Hisilicon/D03/D03.fdf
+++ b/Platforms/Hisilicon/D03/D03.fdf
@@ -187,7 +187,7 @@
   # Simple TextIn/TextOut for UEFI Terminal

 

   INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

-  INF ArmPlatformPkg/Drivers/SP804TimerDxe/SP804TimerDxe.inf

+  INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf

 

   INF ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf