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 "clock_devices.h"
9
10 #include <mod_clock.h>
11 #include <mod_css_clock.h>
12 #include <mod_msys_rom.h>
13 #include <mod_pik_clock.h>
14 #include <mod_system_pll.h>
15
16 #include <fwk_element.h>
17 #include <fwk_id.h>
18 #include <fwk_module.h>
19 #include <fwk_module_idx.h>
20
21 static const struct fwk_element clock_dev_desc_table[] = {
22 [CLOCK_DEV_IDX_BIG] = {
23 .name = "CPU_GROUP_BIG",
24 .data = &((struct mod_clock_dev_config) {
25 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CSS_CLOCK, 0),
26 .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_CSS_CLOCK,
27 MOD_CSS_CLOCK_API_TYPE_CLOCK),
28 .pd_source_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_MSYS_ROM),
29 }),
30 },
31 [CLOCK_DEV_IDX_LITTLE] = {
32 .name = "CPU_GROUP_LITTLE",
33 .data = &((struct mod_clock_dev_config) {
34 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CSS_CLOCK, 1),
35 .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_CSS_CLOCK,
36 MOD_CSS_CLOCK_API_TYPE_CLOCK),
37 .pd_source_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_MSYS_ROM),
38 }),
39 },
40 [CLOCK_DEV_IDX_GPU] = {
41 .name = "GPU",
42 .data = &((struct mod_clock_dev_config) {
43 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CSS_CLOCK, 2),
44 .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_CSS_CLOCK,
45 MOD_CSS_CLOCK_API_TYPE_CLOCK),
46 .pd_source_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_MSYS_ROM),
47 }),
48 },
49 [CLOCK_DEV_IDX_SYS_NOCMEMCLK] = {
50 .name = "SYS_NOCMEMCLK",
51 .data = &((struct mod_clock_dev_config) {
52 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, 0),
53 .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PIK_CLOCK,
54 MOD_PIK_CLOCK_API_TYPE_CLOCK),
55 .pd_source_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_MSYS_ROM),
56 }),
57 },
58 [CLOCK_DEV_IDX_SYS_FCMCLK] = {
59 .name = "SYS_FCMCLK",
60 .data = &((struct mod_clock_dev_config) {
61 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, 1),
62 .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PIK_CLOCK,
63 MOD_PIK_CLOCK_API_TYPE_CLOCK),
64 .pd_source_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_MSYS_ROM),
65 }),
66 },
67 [CLOCK_DEV_IDX_SYS_GICCLK] = {
68 .name = "SYS_GICCLK",
69 .data = &((struct mod_clock_dev_config) {
70 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, 2),
71 .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PIK_CLOCK,
72 MOD_PIK_CLOCK_API_TYPE_CLOCK),
73 .pd_source_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_MSYS_ROM),
74 }),
75 },
76 [CLOCK_DEV_IDX_SYS_PCLKSCP] = {
77 .name = "SYS_PCLKSCP",
78 .data = &((struct mod_clock_dev_config) {
79 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, 3),
80 .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PIK_CLOCK,
81 MOD_PIK_CLOCK_API_TYPE_CLOCK),
82 .pd_source_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_MSYS_ROM),
83 }),
84 },
85 [CLOCK_DEV_IDX_SYS_SYSPERCLK] = {
86 .name = "SYS_SYSPERCLK",
87 .data = &((struct mod_clock_dev_config) {
88 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_PIK_CLOCK, 4),
89 .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_PIK_CLOCK,
90 MOD_PIK_CLOCK_API_TYPE_CLOCK),
91 .pd_source_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_MSYS_ROM),
92 }),
93 },
94 [CLOCK_DEV_IDX_PLL_SYSTEM] = {
95 .name = "PLL_SYSTEM",
96 .data = &((struct mod_clock_dev_config) {
97 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_SYSTEM_PLL, 3),
98 .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_SYSTEM_PLL,
99 MOD_SYSTEM_PLL_API_TYPE_DEFAULT),
100 .pd_source_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_MSYS_ROM),
101 }),
102 },
103 [CLOCK_DEV_IDX_COUNT] = { 0 }, /* Termination description. */
104 };
105
clock_get_dev_desc_table(fwk_id_t module_id)106 static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id)
107 {
108 return clock_dev_desc_table;
109 }
110
111 const struct fwk_module_config config_clock = {
112 .data =
113 &(struct mod_clock_config){
114 .pd_transition_notification_id = FWK_ID_NOTIFICATION_INIT(
115 FWK_MODULE_IDX_MSYS_ROM,
116 MOD_MSYS_ROM_NOTIFICATION_IDX_POWER_SYSTOP),
117 .pd_pre_transition_notification_id = FWK_ID_NONE_INIT,
118 },
119
120 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(clock_get_dev_desc_table),
121 };
122