ti: k3: common: Add basic PSCI core on support
authorAndrew F. Davis <afd@ti.com>
Thu, 24 May 2018 16:15:42 +0000 (11:15 -0500)
committerAndrew F. Davis <afd@ti.com>
Wed, 22 Aug 2018 15:57:19 +0000 (10:57 -0500)
Use TI-SCI messages to request core start from system controller
firmware.

Signed-off-by: Andrew F. Davis <afd@ti.com>
plat/ti/k3/board/generic/include/board_def.h
plat/ti/k3/common/k3_psci.c

index fe0a062aec94560e8e55677bca28c0f624f0c6e0..1bf58eda82230b6c9f7453cd0ba13d06d88fc1a7 100644 (file)
@@ -32,4 +32,7 @@
 #define PLAT_MAX_OFF_STATE             U(2)
 #define PLAT_MAX_RET_STATE             U(1)
 
+#define PLAT_PROC_START_ID             32
+#define PLAT_PROC_DEVICE_START_ID      202
+
 #endif /* BOARD_DEF_H */
index 4d6428b5c61903b9211ec04c0af1abb476de565c..20d1ae6229d3f75bc633f3737e0b8d9a804bd84b 100644 (file)
@@ -9,8 +9,11 @@
 #include <debug.h>
 #include <k3_gicv3.h>
 #include <psci.h>
+#include <platform.h>
 #include <stdbool.h>
 
+#include <ti_sci.h>
+
 #define STUB() ERROR("stub %s called\n", __func__)
 
 uintptr_t k3_sec_entrypoint;
@@ -33,9 +36,40 @@ static void k3_cpu_standby(plat_local_state_t cpu_state)
 
 static int k3_pwr_domain_on(u_register_t mpidr)
 {
-       sev();
-
-       /* TODO: Indicate to System firmware about powering up */
+       int core_id, proc, device, ret;
+
+       core_id = plat_core_pos_by_mpidr(mpidr);
+       if (core_id < 0) {
+               ERROR("Could not get target core id: %d\n", core_id);
+               return PSCI_E_INTERN_FAIL;
+       }
+
+       proc = PLAT_PROC_START_ID + core_id;
+       device = PLAT_PROC_DEVICE_START_ID + core_id;
+
+       ret = ti_sci_proc_request(proc);
+       if (ret) {
+               ERROR("Request for processor failed: %d\n", ret);
+               return PSCI_E_INTERN_FAIL;
+       }
+
+       ret = ti_sci_proc_set_boot_cfg(proc, k3_sec_entrypoint, 0, 0);
+       if (ret) {
+               ERROR("Request to set core boot address failed: %d\n", ret);
+               return PSCI_E_INTERN_FAIL;
+       }
+
+       ret = ti_sci_device_get(device);
+       if (ret) {
+               ERROR("Request to start core failed: %d\n", ret);
+               return PSCI_E_INTERN_FAIL;
+       }
+
+       ret = ti_sci_proc_release(proc);
+       if (ret) {
+               /* this is not fatal */
+               WARN("Could not release processor control: %d\n", ret);
+       }
 
        return PSCI_E_SUCCESS;
 }