Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
module: timer: add API to update timer status without alarm
Browse files Browse the repository at this point in the history
Some devices need overflow interrupt to update internal status. Add new
driver API to handle this if there is no acitve alarm.

Change-Id: I6a3106beb8dce8de7de29dfa5ff5742a9fd9692b
Signed-off-by: Joe Zhu <chunguang.zhu@verisilicon.com>
  • Loading branch information
Joe-Zhucg authored and Joe Zhu committed Jan 10, 2024
1 parent a39e8ab commit f29ae1c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 8 additions & 1 deletion module/timer/include/mod_timer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Arm SCP/MCP Software
* Copyright (c) 2017-2022, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
Expand Down Expand Up @@ -120,6 +120,13 @@ struct mod_timer_driver_api {

/*! Get counter frequency */
int (*get_frequency)(fwk_id_t dev_id, uint32_t *value);

/*!
* Timer device may need to update internal status in alarm or overflow
* event. This handler is used to process overflow event when there is no
* active alarm. Optional
*/
void (*overflow_handler)(fwk_id_t dev_id);
};

/*!
Expand Down
13 changes: 10 additions & 3 deletions module/timer/src/mod_timer.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Arm SCP/MCP Software
* Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
Expand Down Expand Up @@ -557,8 +557,15 @@ static void timer_isr(uintptr_t ctx_ptr)
(struct alarm_sub_element_ctx *)fwk_list_pop_head(&ctx->alarms_active);

if (alarm == NULL) {
/* Timer interrupt triggered without any alarm in the active queue */
fwk_unexpected();
if (ctx->driver->overflow_handler != NULL) {
ctx->driver->overflow_handler(ctx->driver_dev_id);
} else {
/*
* Timer interrupt triggered without any alarm in the active queue nor an
* overflow handler provided.
*/
fwk_unexpected();
}
return;
}

Expand Down

0 comments on commit f29ae1c

Please sign in to comment.