blob: 1aa397c5e773d8403293786838df63c7b539fa94 [file] [log] [blame]
Simon Glass4b0730d2011-09-26 14:10:39 +00001/*
2 * Copyright (c) 2011 The Chromium OS Authors.
Wolfgang Denk1a459662013-07-08 09:37:19 +02003 * SPDX-License-Identifier: GPL-2.0+
Simon Glass4b0730d2011-09-26 14:10:39 +00004 */
5
6#include <common.h>
Simon Glass61336832014-07-23 06:55:02 -06007#include <dm/root.h>
Simon Glass7a9219c2011-10-03 19:26:44 +00008#include <os.h>
Simon Glass5c2859c2013-11-10 10:27:03 -07009#include <asm/state.h>
Simon Glass4b0730d2011-09-26 14:10:39 +000010
11DECLARE_GLOBAL_DATA_PTR;
12
Simon Glass88bd0e92013-11-10 10:27:00 -070013void reset_cpu(ulong ignored)
Simon Glass4b0730d2011-09-26 14:10:39 +000014{
Simon Glass5c2859c2013-11-10 10:27:03 -070015 if (state_uninit())
16 os_exit(2);
17
Simon Glass61336832014-07-23 06:55:02 -060018 if (dm_uninit())
19 os_exit(2);
20
Simon Glass7a9219c2011-10-03 19:26:44 +000021 /* This is considered normal termination for now */
22 os_exit(0);
Simon Glass88bd0e92013-11-10 10:27:00 -070023}
24
25int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
26{
27 reset_cpu(0);
28
Simon Glass4b0730d2011-09-26 14:10:39 +000029 return 0;
30}
31
32/* delay x useconds */
33void __udelay(unsigned long usec)
34{
Matthias Weisserd99a6872011-11-29 12:16:40 +010035 os_usleep(usec);
Simon Glass4b0730d2011-09-26 14:10:39 +000036}
37
Simon Glasse2ee1002013-06-11 11:14:44 -070038unsigned long __attribute__((no_instrument_function)) timer_get_us(void)
Simon Glass4b0730d2011-09-26 14:10:39 +000039{
Matthias Weisserd99a6872011-11-29 12:16:40 +010040 return os_get_nsec() / 1000;
Simon Glass4b0730d2011-09-26 14:10:39 +000041}
42
43int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
44{
Simon Glass88bd0e92013-11-10 10:27:00 -070045 if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
46 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
47 printf("## Transferring control to Linux (at address %08lx)...\n",
48 images->ep);
49 reset_cpu(0);
50 }
51
52 return 0;
Simon Glass4b0730d2011-09-26 14:10:39 +000053}
54
55int cleanup_before_linux(void)
56{
57 return 0;
58}
59
60void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
61{
Simon Glass8ee666a2012-12-13 20:49:11 +000062 return (void *)(gd->arch.ram_buf + paddr);
Simon Glass4b0730d2011-09-26 14:10:39 +000063}
64
Simon Glass66bd1cf2014-02-27 13:25:55 -070065phys_addr_t map_to_sysmem(const void *ptr)
Simon Glass781adb52013-04-20 08:42:37 +000066{
67 return (u8 *)ptr - gd->arch.ram_buf;
68}
69
Simon Glass4b0730d2011-09-26 14:10:39 +000070void flush_dcache_range(unsigned long start, unsigned long stop)
71{
72}