]>
Commit | Line | Data |
---|---|---|
4b0730d2 SG |
1 | /* |
2 | * Copyright (c) 2011 The Chromium OS Authors. | |
1a459660 | 3 | * SPDX-License-Identifier: GPL-2.0+ |
4b0730d2 | 4 | */ |
9569c406 | 5 | #define DEBUG |
4b0730d2 | 6 | #include <common.h> |
61336833 | 7 | #include <dm/root.h> |
7a9219c1 | 8 | #include <os.h> |
5c2859cd | 9 | #include <asm/state.h> |
4b0730d2 SG |
10 | |
11 | DECLARE_GLOBAL_DATA_PTR; | |
12 | ||
9569c406 SG |
13 | /* Enable access to PCI memory with map_sysmem() */ |
14 | static bool enable_pci_map; | |
15 | ||
16 | #ifdef CONFIG_PCI | |
17 | /* Last device that was mapped into memory, and length of mapping */ | |
18 | static struct udevice *map_dev; | |
19 | unsigned long map_len; | |
20 | #endif | |
21 | ||
88bd0e9d | 22 | void reset_cpu(ulong ignored) |
4b0730d2 | 23 | { |
5c2859cd SG |
24 | if (state_uninit()) |
25 | os_exit(2); | |
26 | ||
61336833 SG |
27 | if (dm_uninit()) |
28 | os_exit(2); | |
29 | ||
7a9219c1 SG |
30 | /* This is considered normal termination for now */ |
31 | os_exit(0); | |
88bd0e9d SG |
32 | } |
33 | ||
34 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) | |
35 | { | |
36 | reset_cpu(0); | |
37 | ||
4b0730d2 SG |
38 | return 0; |
39 | } | |
40 | ||
41 | /* delay x useconds */ | |
42 | void __udelay(unsigned long usec) | |
43 | { | |
d99a6874 | 44 | os_usleep(usec); |
4b0730d2 SG |
45 | } |
46 | ||
e2ee100f | 47 | unsigned long __attribute__((no_instrument_function)) timer_get_us(void) |
4b0730d2 | 48 | { |
d99a6874 | 49 | return os_get_nsec() / 1000; |
4b0730d2 SG |
50 | } |
51 | ||
4b0730d2 SG |
52 | int cleanup_before_linux(void) |
53 | { | |
54 | return 0; | |
55 | } | |
56 | ||
57 | void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) | |
58 | { | |
9569c406 SG |
59 | #ifdef CONFIG_PCI |
60 | unsigned long plen = len; | |
61 | void *ptr; | |
62 | ||
63 | map_dev = NULL; | |
64 | if (enable_pci_map && !pci_map_physmem(paddr, &len, &map_dev, &ptr)) { | |
65 | if (plen != len) { | |
66 | printf("%s: Warning: partial map at %x, wanted %lx, got %lx\n", | |
67 | __func__, paddr, len, plen); | |
68 | } | |
69 | map_len = len; | |
70 | return ptr; | |
71 | } | |
72 | #endif | |
73 | ||
8ee666a7 | 74 | return (void *)(gd->arch.ram_buf + paddr); |
4b0730d2 SG |
75 | } |
76 | ||
9569c406 SG |
77 | void unmap_physmem(const void *vaddr, unsigned long flags) |
78 | { | |
79 | #ifdef CONFIG_PCI | |
80 | if (map_dev) { | |
81 | pci_unmap_physmem(vaddr, map_len, map_dev); | |
82 | map_dev = NULL; | |
83 | } | |
84 | #endif | |
85 | } | |
86 | ||
87 | void sandbox_set_enable_pci_map(int enable) | |
88 | { | |
89 | enable_pci_map = enable; | |
90 | } | |
91 | ||
66bd1cff | 92 | phys_addr_t map_to_sysmem(const void *ptr) |
781adb57 SG |
93 | { |
94 | return (u8 *)ptr - gd->arch.ram_buf; | |
95 | } | |
96 | ||
4b0730d2 SG |
97 | void flush_dcache_range(unsigned long start, unsigned long stop) |
98 | { | |
99 | } |