blob: 6891e3800b3db1a4574a54f3ce60eb8dd898255b [file] [log] [blame]
Stephan Gerhold14fdf072021-12-01 20:01:11 +01001/*
2 * Copyright (c) 2021, Stephan Gerhold <stephan@gerhold.net>
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <common/debug.h>
Stephan Gerhold765e8592021-12-01 20:04:44 +01009#include <drivers/arm/gicv2.h>
Stephan Gerhold14fdf072021-12-01 20:01:11 +010010#include <drivers/delay_timer.h>
11#include <lib/mmio.h>
12#include <lib/psci/psci.h>
13#include <plat/common/platform.h>
14
15#include <msm8916_mmap.h>
Stephan Gerhold765e8592021-12-01 20:04:44 +010016#include "msm8916_pm.h"
17
18static int msm8916_pwr_domain_on(u_register_t mpidr)
19{
20 unsigned int core = MPIDR_AFFLVL0_VAL(mpidr);
21
22 VERBOSE("PSCI: Booting CPU %d\n", core);
23 msm8916_cpu_boot(core);
24
25 return PSCI_E_SUCCESS;
26}
27
28static void msm8916_pwr_domain_on_finish(const psci_power_state_t *target_state)
29{
30 gicv2_pcpu_distif_init();
31 gicv2_cpuif_enable();
32}
Stephan Gerhold14fdf072021-12-01 20:01:11 +010033
34static void __dead2 msm8916_system_reset(void)
35{
36 mmio_write_32(MPM_PS_HOLD, 0);
37 mdelay(1000);
38
39 ERROR("PSCI: System reset failed\n");
40 panic();
41}
42
43static const plat_psci_ops_t msm8916_psci_ops = {
Stephan Gerhold765e8592021-12-01 20:04:44 +010044 .pwr_domain_on = msm8916_pwr_domain_on,
45 .pwr_domain_on_finish = msm8916_pwr_domain_on_finish,
Stephan Gerhold14fdf072021-12-01 20:01:11 +010046 .system_off = msm8916_system_reset,
47 .system_reset = msm8916_system_reset,
48};
49
50/* Defined and used in msm8916_helpers.S */
51extern uintptr_t msm8916_entry_point;
52
53int plat_setup_psci_ops(uintptr_t sec_entrypoint,
54 const plat_psci_ops_t **psci_ops)
55{
56 msm8916_entry_point = sec_entrypoint;
57 *psci_ops = &msm8916_psci_ops;
58 return 0;
59}