1 /*
2 * Arm SCP/MCP Software
3 * Copyright (c) 2018-2021, Arm Limited and Contributors. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 #include "config_clock.h"
9 #include "n1sdp_scp_mmap.h"
10 #include "n1sdp_system_clock.h"
11
12 #include <mod_gtimer.h>
13 #include <mod_timer.h>
14
15 #include <fwk_element.h>
16 #include <fwk_id.h>
17 #include <fwk_module.h>
18 #include <fwk_module_idx.h>
19 #include <fwk_time.h>
20
21 #include <fmw_cmsis.h>
22
23 /*
24 * Generic timer driver config
25 */
26 static const struct fwk_element gtimer_dev_table[] = {
27 [0] = {
28 .name = "REFCLK",
29 .data = &((struct mod_gtimer_dev_config) {
30 .hw_timer = SCP_REFCLK_CNTBASE0_BASE,
31 .hw_counter = SCP_REFCLK_CNTCTL_BASE,
32 .control = SCP_REFCLK_CNTCONTROL_BASE,
33 .frequency = CLOCK_RATE_REFCLK,
34 .clock_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK,
35 CLOCK_IDX_INTERCONNECT)
36 })
37 },
38 [1] = { 0 },
39 };
40
41 const struct fwk_module_config config_gtimer = {
42 .elements = FWK_MODULE_STATIC_ELEMENTS_PTR(gtimer_dev_table),
43 };
44
fmw_time_driver(const void ** ctx)45 struct fwk_time_driver fmw_time_driver(const void **ctx)
46 {
47 return mod_gtimer_driver(ctx, config_gtimer.elements.table[0].data);
48 }
49
50 /*
51 * Timer HAL config
52 */
53 static const struct fwk_element timer_dev_table[] = {
54 [0] = {
55 .name = "REFCLK",
56 .data = &((struct mod_timer_dev_config) {
57 .id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_GTIMER, 0),
58 .timer_irq = TIMREFCLK_IRQ,
59 }),
60 .sub_element_count = 8, /* Number of alarms */
61 },
62 [1] = { 0 },
63 };
64
timer_get_dev_table(fwk_id_t module_id)65 static const struct fwk_element *timer_get_dev_table(fwk_id_t module_id)
66 {
67 return timer_dev_table;
68 }
69
70 const struct fwk_module_config config_timer = {
71 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(timer_get_dev_table),
72 };
73