]> git.ipfire.org Git - people/ms/u-boot.git/blame - arch/sandbox/cpu/cpu.c
dm: core: Drop device removal error path when not supported
[people/ms/u-boot.git] / arch / sandbox / cpu / cpu.c
CommitLineData
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
11DECLARE_GLOBAL_DATA_PTR;
12
9569c406
SG
13/* Enable access to PCI memory with map_sysmem() */
14static bool enable_pci_map;
15
16#ifdef CONFIG_PCI
17/* Last device that was mapped into memory, and length of mapping */
18static struct udevice *map_dev;
19unsigned long map_len;
20#endif
21
88bd0e9d 22void 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
34int 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 */
42void __udelay(unsigned long usec)
43{
d99a6874 44 os_usleep(usec);
4b0730d2
SG
45}
46
e2ee100f 47unsigned long __attribute__((no_instrument_function)) timer_get_us(void)
4b0730d2 48{
d99a6874 49 return os_get_nsec() / 1000;
4b0730d2
SG
50}
51
4b0730d2
SG
52int cleanup_before_linux(void)
53{
54 return 0;
55}
56
57void *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
77void 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
87void sandbox_set_enable_pci_map(int enable)
88{
89 enable_pci_map = enable;
90}
91
66bd1cff 92phys_addr_t map_to_sysmem(const void *ptr)
781adb57
SG
93{
94 return (u8 *)ptr - gd->arch.ram_buf;
95}
96
4b0730d2
SG
97void flush_dcache_range(unsigned long start, unsigned long stop)
98{
99}