1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * Copyright 2022 Microchip 4 */ 5 6 #include <assert.h> 7 #include <drivers/clk.h> 8 #include <drivers/clk_dt.h> 9 #include <kernel/boot.h> 10 #include <kernel/panic.h> 11 #include <libfdt.h> 12 13 static unsigned long freq; 14 get_freq_from_dt(void)15static TEE_Result get_freq_from_dt(void) 16 { 17 int node; 18 struct clk *clk; 19 const void *fdt = get_embedded_dt(); 20 21 if (!fdt) 22 panic(); 23 24 node = fdt_node_offset_by_compatible(fdt, -1, "arm,cortex-a5"); 25 if (!node) 26 panic(); 27 28 if (clk_dt_get_by_name(fdt, node, "cpu", &clk)) 29 panic(); 30 31 freq = clk_get_rate(clk); 32 33 return TEE_SUCCESS; 34 } 35 early_init_late(get_freq_from_dt); 36 plat_get_freq(void)37unsigned long plat_get_freq(void) 38 { 39 assert(freq); 40 41 return freq; 42 } 43