arch-arm, dev-arm: Autogen PSCI node in DTB
authorAdrian Herrera <adrian.herrera@arm.com>
Mon, 30 Mar 2020 16:35:34 +0000 (17:35 +0100)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Wed, 8 Apr 2020 15:05:30 +0000 (15:05 +0000)
This is controlled via the python only _have_psci parameter
This flag will be checked when auto-generarting a PSCI node. A client
(e.g Linux) would then be able to know if it can use the PSCI APIs

Change-Id: I16c4a67bd358eca3dfff6c98ab8a602a31e1c751
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27387
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/arm/ArmSystem.py
src/dev/arm/RealView.py

index 07fdad66302e4c6b033a104ad9c4657aeca36182..6555ea92ec535121fa5f88a55f0cd0ef546e6ff8 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2009, 2012-2013, 2015-2019 ARM Limited
+# Copyright (c) 2009, 2012-2013, 2015-2020 ARM Limited
 # All rights reserved.
 #
 # The license below extends only to copyright in the software and shall
@@ -83,6 +83,12 @@ class ArmSystem(System):
         "Base of the 64KiB PA range used for memory-mapped m5ops. Set to 0 "
         "to disable.")
 
+    # Set to true if simulation provides a PSCI implementation
+    # This flag will be checked when auto-generating
+    # a PSCI node. A client (e.g Linux) would then be able to
+    # know if it can use the PSCI APIs
+    _have_psci = False
+
     def generateDtb(self, filename):
         """
         Autogenerate DTB. Arguments are the folder where the DTB
index 4cd625859a02650a7348f7bc62cc2b87fe5b36ff..0a26a9414ca9092b83556f1d66ed8e40161ca3bc 100644 (file)
@@ -645,9 +645,13 @@ class RealView(Platform):
         yield node
 
     def annotateCpuDeviceNode(self, cpu, state):
-        cpu.append(FdtPropertyStrings("enable-method", "spin-table"))
-        cpu.append(FdtPropertyWords("cpu-release-addr", \
-                                    state.addrCells(0x8000fff8)))
+        system = self.system.unproxy(self)
+        if system._have_psci:
+            cpu.append(FdtPropertyStrings('enable-method', 'psci'))
+        else:
+            cpu.append(FdtPropertyStrings("enable-method", "spin-table"))
+            cpu.append(FdtPropertyWords("cpu-release-addr", \
+                                        state.addrCells(0x8000fff8)))
 
 class VExpress_EMM(RealView):
     _mem_regions = [ AddrRange('2GB', size='2GB') ]
@@ -1128,6 +1132,24 @@ Interrupts:
         node.append(FdtPropertyWords("arm,hbi", [0x0]))
         node.append(FdtPropertyWords("arm,vexpress,site", [0xf]))
 
+        system = self.system.unproxy(self)
+        if system._have_psci:
+            # PSCI functions exposed to the kernel
+            if not system.have_security:
+                raise AssertionError("PSCI requires EL3 (have_security)")
+
+            psci_node = FdtNode('psci')
+            psci_node.appendCompatible(['arm,psci-1.0', 'arm,psci-0.2',
+                                        'arm,psci'])
+            method = 'smc'
+            psci_node.append(FdtPropertyStrings('method', method))
+            psci_node.append(FdtPropertyWords('cpu_suspend', 0xc4000001))
+            psci_node.append(FdtPropertyWords('cpu_off', 0x84000002))
+            psci_node.append(FdtPropertyWords('cpu_on', 0xc4000003))
+            psci_node.append(FdtPropertyWords('sys_poweroff', 0x84000008))
+            psci_node.append(FdtPropertyWords('sys_reset', 0x84000009))
+            node.append(psci_node)
+
         yield node
 
 class VExpress_GEM5_V1_Base(VExpress_GEM5_Base):