Lines Matching refs:hal
15 void systimer_hal_init(systimer_hal_context_t *hal) in systimer_hal_init() argument
17 hal->dev = &SYSTIMER; in systimer_hal_init()
18 systimer_ll_enable_clock(hal->dev, true); in systimer_hal_init()
24 void systimer_hal_deinit(systimer_hal_context_t *hal) in systimer_hal_deinit() argument
29 systimer_ll_enable_clock(hal->dev, false); in systimer_hal_deinit()
30 hal->dev = NULL; in systimer_hal_deinit()
33 void systimer_hal_set_clock_source(systimer_hal_context_t *hal, systimer_clock_source_t clk_src) in systimer_hal_set_clock_source() argument
35 (void)hal; in systimer_hal_set_clock_source()
39 systimer_clock_source_t systimer_hal_get_clock_source(systimer_hal_context_t *hal) in systimer_hal_get_clock_source() argument
41 (void)hal; in systimer_hal_get_clock_source()
45 void systimer_hal_set_tick_rate_ops(systimer_hal_context_t *hal, systimer_hal_tick_rate_ops_t *ops) in systimer_hal_set_tick_rate_ops() argument
47 hal->ticks_to_us = ops->ticks_to_us; in systimer_hal_set_tick_rate_ops()
48 hal->us_to_ticks = ops->us_to_ticks; in systimer_hal_set_tick_rate_ops()
51 uint64_t systimer_hal_get_counter_value(systimer_hal_context_t *hal, uint32_t counter_id) in systimer_hal_get_counter_value() argument
55 systimer_ll_counter_snapshot(hal->dev, counter_id); in systimer_hal_get_counter_value()
56 while (!systimer_ll_is_counter_value_valid(hal->dev, counter_id)); in systimer_hal_get_counter_value()
62 lo_start = systimer_ll_get_counter_value_low(hal->dev, counter_id); in systimer_hal_get_counter_value()
65 hi = systimer_ll_get_counter_value_high(hal->dev, counter_id); in systimer_hal_get_counter_value()
66 lo_start = systimer_ll_get_counter_value_low(hal->dev, counter_id); in systimer_hal_get_counter_value()
77 uint64_t systimer_hal_get_time(systimer_hal_context_t *hal, uint32_t counter_id) in systimer_hal_get_time() argument
79 return hal->ticks_to_us(systimer_hal_get_counter_value(hal, counter_id)); in systimer_hal_get_time()
83 void systimer_hal_set_alarm_target(systimer_hal_context_t *hal, uint32_t alarm_id, uint64_t target) in systimer_hal_set_alarm_target() argument
86 .val = hal->us_to_ticks(target), in systimer_hal_set_alarm_target()
88 systimer_ll_enable_alarm(hal->dev, alarm_id, false); in systimer_hal_set_alarm_target()
89 systimer_ll_set_alarm_target(hal->dev, alarm_id, alarm.val); in systimer_hal_set_alarm_target()
90 systimer_ll_apply_alarm_value(hal->dev, alarm_id); in systimer_hal_set_alarm_target()
91 systimer_ll_enable_alarm(hal->dev, alarm_id, true); in systimer_hal_set_alarm_target()
96 void systimer_hal_set_alarm_target(systimer_hal_context_t *hal, uint32_t alarm_id, uint64_t timesta… in systimer_hal_set_alarm_target() argument
98 int64_t offset = hal->us_to_ticks(1) * 2; in systimer_hal_set_alarm_target()
99 uint64_t now_time = systimer_hal_get_counter_value(hal, 0); in systimer_hal_set_alarm_target()
100 systimer_counter_value_t alarm = { .val = MAX(hal->us_to_ticks(timestamp), now_time + offset) }; in systimer_hal_set_alarm_target()
102 systimer_ll_enable_alarm(hal->dev, alarm_id, false); in systimer_hal_set_alarm_target()
103 systimer_ll_set_alarm_target(hal->dev, alarm_id, alarm.val); in systimer_hal_set_alarm_target()
104 systimer_ll_enable_alarm(hal->dev, alarm_id, true); in systimer_hal_set_alarm_target()
105 now_time = systimer_hal_get_counter_value(hal, 0); in systimer_hal_set_alarm_target()
107 if (delta <= 0 && !systimer_ll_is_alarm_int_fired(hal->dev, alarm_id)) { in systimer_hal_set_alarm_target()
109 offset += -1 * delta + hal->us_to_ticks(1) * 2; in systimer_hal_set_alarm_target()
119 void systimer_hal_set_alarm_period(systimer_hal_context_t *hal, uint32_t alarm_id, uint32_t period) in systimer_hal_set_alarm_period() argument
121 systimer_ll_enable_alarm(hal->dev, alarm_id, false); in systimer_hal_set_alarm_period()
122 systimer_ll_set_alarm_period(hal->dev, alarm_id, hal->us_to_ticks(period)); in systimer_hal_set_alarm_period()
123 systimer_ll_apply_alarm_value(hal->dev, alarm_id); in systimer_hal_set_alarm_period()
124 systimer_ll_enable_alarm(hal->dev, alarm_id, true); in systimer_hal_set_alarm_period()
127 uint64_t systimer_hal_get_alarm_value(systimer_hal_context_t *hal, uint32_t alarm_id) in systimer_hal_get_alarm_value() argument
129 return systimer_ll_get_alarm_target(hal->dev, alarm_id); in systimer_hal_get_alarm_value()
132 void systimer_hal_enable_alarm_int(systimer_hal_context_t *hal, uint32_t alarm_id) in systimer_hal_enable_alarm_int() argument
134 systimer_ll_enable_alarm_int(hal->dev, alarm_id, true); in systimer_hal_enable_alarm_int()
137 void systimer_hal_counter_value_advance(systimer_hal_context_t *hal, uint32_t counter_id, int64_t t… in systimer_hal_counter_value_advance() argument
140 .val = systimer_hal_get_counter_value(hal, counter_id) + hal->us_to_ticks(time_us), in systimer_hal_counter_value_advance()
142 systimer_ll_set_counter_value(hal->dev, counter_id, new_count.val); in systimer_hal_counter_value_advance()
143 systimer_ll_apply_counter_value(hal->dev, counter_id); in systimer_hal_counter_value_advance()
146 void systimer_hal_enable_counter(systimer_hal_context_t *hal, uint32_t counter_id) in systimer_hal_enable_counter() argument
148 systimer_ll_enable_counter(hal->dev, counter_id, true); in systimer_hal_enable_counter()
151 void systimer_hal_select_alarm_mode(systimer_hal_context_t *hal, uint32_t alarm_id, systimer_alarm_… in systimer_hal_select_alarm_mode() argument
155 systimer_ll_enable_alarm_oneshot(hal->dev, alarm_id); in systimer_hal_select_alarm_mode()
158 systimer_ll_enable_alarm_period(hal->dev, alarm_id); in systimer_hal_select_alarm_mode()
165 void systimer_hal_connect_alarm_counter(systimer_hal_context_t *hal, uint32_t alarm_id, uint32_t co… in systimer_hal_connect_alarm_counter() argument
167 systimer_ll_connect_alarm_counter(hal->dev, alarm_id, counter_id); in systimer_hal_connect_alarm_counter()
170 void systimer_hal_counter_can_stall_by_cpu(systimer_hal_context_t *hal, uint32_t counter_id, uint32… in systimer_hal_counter_can_stall_by_cpu() argument
172 systimer_ll_counter_can_stall_by_cpu(hal->dev, counter_id, cpu_id, can); in systimer_hal_counter_can_stall_by_cpu()
177 void systimer_hal_set_steps_per_tick(systimer_hal_context_t *hal, int clock_source, uint32_t steps) in systimer_hal_set_steps_per_tick() argument
189 systimer_ll_set_step_for_xtal(hal->dev, steps); in systimer_hal_set_steps_per_tick()
192 systimer_ll_set_step_for_pll(hal->dev, steps); in systimer_hal_set_steps_per_tick()
198 void systimer_hal_on_apb_freq_update(systimer_hal_context_t *hal, uint32_t apb_ticks_per_us) in systimer_hal_on_apb_freq_update() argument
205 if (apb_ticks_per_us != hal->us_to_ticks(1)) { in systimer_hal_on_apb_freq_update()
206 …HAL_ASSERT((hal->us_to_ticks(1) % apb_ticks_per_us) == 0 && "TICK_PER_US should be divisible by AP… in systimer_hal_on_apb_freq_update()
207 systimer_ll_set_step_for_xtal(hal->dev, hal->us_to_ticks(1) / apb_ticks_per_us); in systimer_hal_on_apb_freq_update()