xref: /rk3399_rockchip-uboot/arch/sandbox/cpu/cpu.c (revision 91b136c7989e763b01632ca3de6fca8ead0b847b)
1 /*
2  * Copyright (c) 2011 The Chromium OS Authors.
3  * SPDX-License-Identifier:	GPL-2.0+
4  */
5 
6 #include <common.h>
7 #include <os.h>
8 
9 DECLARE_GLOBAL_DATA_PTR;
10 
11 void reset_cpu(ulong ignored)
12 {
13 	/* This is considered normal termination for now */
14 	os_exit(0);
15 }
16 
17 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
18 {
19 	reset_cpu(0);
20 
21 	return 0;
22 }
23 
24 /* delay x useconds */
25 void __udelay(unsigned long usec)
26 {
27 	os_usleep(usec);
28 }
29 
30 unsigned long __attribute__((no_instrument_function)) timer_get_us(void)
31 {
32 	return os_get_nsec() / 1000;
33 }
34 
35 int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
36 {
37 	if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
38 		bootstage_mark(BOOTSTAGE_ID_RUN_OS);
39 		printf("## Transferring control to Linux (at address %08lx)...\n",
40 		       images->ep);
41 		reset_cpu(0);
42 	}
43 
44 	return 0;
45 }
46 
47 int cleanup_before_linux(void)
48 {
49 	return 0;
50 }
51 
52 void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
53 {
54 	return (void *)(gd->arch.ram_buf + paddr);
55 }
56 
57 phys_addr_t map_to_sysmem(void *ptr)
58 {
59 	return (u8 *)ptr - gd->arch.ram_buf;
60 }
61 
62 void flush_dcache_range(unsigned long start, unsigned long stop)
63 {
64 }
65