driver: timer: npcx: add check for system kernel timer frequency
In npcx series, we use ITIM64 as system kernel timer. Its source clock frequency must equal to CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC. This CL added check during initialization to prevent ambiguous condition. Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
This commit is contained in:
parent
009388a321
commit
6885afe432
1 changed files with 18 additions and 0 deletions
|
@ -271,6 +271,7 @@ int sys_clock_driver_init(const struct device *dev)
|
|||
{
|
||||
ARG_UNUSED(dev);
|
||||
int ret;
|
||||
uint32_t sys_tmr_rate;
|
||||
const struct device *const clk_dev =
|
||||
device_get_binding(NPCX_CLK_CTRL_NAME);
|
||||
|
||||
|
@ -284,6 +285,23 @@ int sys_clock_driver_init(const struct device *dev)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* In npcx series, we use ITIM64 as system kernel timer. Its source
|
||||
* clock frequency must equal to CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC.
|
||||
*/
|
||||
ret = clock_control_get_rate(clk_dev, (clock_control_subsys_t *)
|
||||
&itim_clk_cfg[1], &sys_tmr_rate);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Get ITIM64 clock rate failed %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (sys_tmr_rate != CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) {
|
||||
LOG_ERR("CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC doesn't match "
|
||||
"ITIM64 clock frequency %d", sys_tmr_rate);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Step 1. Use a ITIM64 timer as system kernel timer for counting.
|
||||
* Configure 64-bit timer counter and its prescaler to 1 first.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue