1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright (C) 2024, James Raphael Tiovalen <jamestiotio@gmail.com> 4 */ 5 #include <libcflat.h> 6 #include <devicetree.h> 7 #include <asm/setup.h> 8 #include <asm/timer.h> 9 10 void timer_get_frequency(void) 11 { 12 const struct fdt_property *prop; 13 u32 *data; 14 int cpus, len; 15 16 assert_msg(dt_available(), "ACPI not yet supported"); 17 18 const void *fdt = dt_fdt(); 19 20 cpus = fdt_path_offset(fdt, "/cpus"); 21 assert(cpus >= 0); 22 23 prop = fdt_get_property(fdt, cpus, "timebase-frequency", &len); 24 assert(prop != NULL && len == 4); 25 26 data = (u32 *)prop->data; 27 timebase_frequency = fdt32_to_cpu(*data); 28 } 29