1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #include "clock_soc.h"
9 #include "scp_css_mmap.h"
10 
11 #include <mod_gtimer.h>
12 #include <mod_timer.h>
13 
14 #include <fwk_id.h>
15 #include <fwk_module.h>
16 #include <fwk_module_idx.h>
17 #include <fwk_time.h>
18 
19 /*
20  * Generic timer driver config
21  */
22 static const struct fwk_element gtimer_dev_table[] = {
23     [0] = { .name = "REFCLK",
24             .data = &((struct mod_gtimer_dev_config){
25                 .hw_timer = SCP_REFCLK_CNTBASE0_BASE,
26                 .hw_counter = SCP_REFCLK_CNTCTL_BASE,
27                 .control = SCP_REFCLK_CNTCONTROL_BASE,
28                 .frequency = CLOCK_RATE_REFCLK,
29                 .clock_id = FWK_ID_ELEMENT_INIT(
30                     FWK_MODULE_IDX_CLOCK,
31                     CLOCK_IDX_CPU_GROUP_KLEIN) }) },
32     [1] = { 0 },
33 };
34 
35 const struct fwk_module_config config_gtimer = {
36     .elements = FWK_MODULE_STATIC_ELEMENTS_PTR(gtimer_dev_table),
37 };
38 
fmw_time_driver(const void ** ctx)39 struct fwk_time_driver fmw_time_driver(const void **ctx)
40 {
41     return mod_gtimer_driver(ctx, config_gtimer.elements.table[0].data);
42 }
43