lib/powerpc: Implement generic delay function for use in unit tests
It would be nice if we had a generic delay function which could be used
in unit tests, add one.
Add the variable tb_hz used to store the time base frequency which is read
from the device tree on setup.
Add functions mdelay, udelay and delay in processor.c to delay for a given
number of milliseconds, microseconds and time base ticks respectively.
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c
index e3d2afa..9153f7b 100644
--- a/lib/powerpc/setup.c
+++ b/lib/powerpc/setup.c
@@ -24,6 +24,7 @@
u32 cpus[NR_CPUS] = { [0 ... NR_CPUS-1] = (~0U) };
int nr_cpus;
+uint64_t tb_hz;
struct mem_region mem_regions[NR_MEM_REGIONS];
phys_addr_t __physical_start, __physical_end;
@@ -32,6 +33,7 @@
struct cpu_set_params {
unsigned icache_bytes;
unsigned dcache_bytes;
+ uint64_t tb_hz;
};
#define EXCEPTION_STACK_SIZE (32*1024) /* 32kB */
@@ -72,6 +74,12 @@
data = (u32 *)prop->data;
params->dcache_bytes = fdt32_to_cpu(*data);
+ prop = fdt_get_property(dt_fdt(), fdtnode,
+ "timebase-frequency", NULL);
+ assert(prop != NULL);
+ data = (u32 *)prop->data;
+ params->tb_hz = fdt32_to_cpu(*data);
+
read_common_info = true;
}
}
@@ -86,6 +94,7 @@
assert(ret == 0);
__icache_bytes = params.icache_bytes;
__dcache_bytes = params.dcache_bytes;
+ tb_hz = params.tb_hz;
/* Interrupt Endianness */