1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2015-2021, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #include "juno_ppu_idx.h"
9 
10 #include <mod_juno_ppu.h>
11 #include <mod_power_domain.h>
12 #include <mod_system_power.h>
13 
14 #include <fwk_element.h>
15 #include <fwk_id.h>
16 #include <fwk_module.h>
17 #include <fwk_module_idx.h>
18 
19 #include <fmw_cmsis.h>
20 
21 #include <stdint.h>
22 
23 static const uint8_t system_power_to_sys_ppu_state[] = {
24     [MOD_PD_STATE_ON]                     = (uint8_t)MOD_PD_STATE_ON,
25     [MOD_SYSTEM_POWER_POWER_STATE_SLEEP0] =
26         (uint8_t)MOD_SYSTEM_POWER_POWER_STATE_SLEEP0,
27     [MOD_PD_STATE_OFF]                    = (uint8_t)MOD_PD_STATE_OFF,
28 };
29 
30 static const struct fwk_element system_power_element_table[] = {
31     [0] = {
32         .name = "",
33         .data = &((struct mod_system_power_dev_config) {
34             .sys_ppu_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_JUNO_PPU,
35                 JUNO_PPU_DEV_IDX_SYSTOP),
36             .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_JUNO_PPU,
37                 MOD_JUNO_PPU_API_IDX_PD),
38             .sys_state_table = system_power_to_sys_ppu_state,
39         }),
40     },
41 
42     [1] = { 0 }, /* Termination description */
43 };
44 
system_power_get_element_table(fwk_id_t module_id)45 static const struct fwk_element *system_power_get_element_table(
46     fwk_id_t module_id)
47 {
48     return system_power_element_table;
49 }
50 
51 const struct fwk_module_config config_system_power = {
52     .data =
53         &(struct mod_system_power_config){
54             .soc_wakeup_irq = (unsigned int)EXT_WAKEUP_IRQ,
55             .driver_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_JUNO_SYSTEM),
56             .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_JUNO_SYSTEM, 0),
57             .initial_system_power_state = MOD_PD_STATE_ON,
58         },
59 
60     .elements = FWK_MODULE_DYNAMIC_ELEMENTS(system_power_get_element_table),
61 };
62