blob: 1aa397c5e773d8403293786838df63c7b539fa94 [file] [log] [blame]
Simon Glass3d750d72011-09-26 14:10:39 +00001/*
2 * Copyright (c) 2011 The Chromium OS Authors.
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02003 * SPDX-License-Identifier: GPL-2.0+
Simon Glass3d750d72011-09-26 14:10:39 +00004 */
5
6#include <common.h>
Simon Glass19200512014-07-23 06:55:02 -06007#include <dm/root.h>
Simon Glasscd0684f2011-10-03 19:26:44 +00008#include <os.h>
Simon Glass9dd10bf2013-11-10 10:27:03 -07009#include <asm/state.h>
Simon Glass3d750d72011-09-26 14:10:39 +000010
11DECLARE_GLOBAL_DATA_PTR;
12
Simon Glassdc9f8cd2013-11-10 10:27:00 -070013void reset_cpu(ulong ignored)
Simon Glass3d750d72011-09-26 14:10:39 +000014{
Simon Glass9dd10bf2013-11-10 10:27:03 -070015 if (state_uninit())
16 os_exit(2);
17
Simon Glass19200512014-07-23 06:55:02 -060018 if (dm_uninit())
19 os_exit(2);
20
Simon Glasscd0684f2011-10-03 19:26:44 +000021 /* This is considered normal termination for now */
22 os_exit(0);
Simon Glassdc9f8cd2013-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 Glass3d750d72011-09-26 14:10:39 +000029 return 0;
30}
31
32/* delay x useconds */
33void __udelay(unsigned long usec)
34{
Matthias Weisser0d3dd142011-11-29 12:16:40 +010035 os_usleep(usec);
Simon Glass3d750d72011-09-26 14:10:39 +000036}
37
Simon Glasse7f1eb52013-06-11 11:14:44 -070038unsigned long __attribute__((no_instrument_function)) timer_get_us(void)
Simon Glass3d750d72011-09-26 14:10:39 +000039{
Matthias Weisser0d3dd142011-11-29 12:16:40 +010040 return os_get_nsec() / 1000;
Simon Glass3d750d72011-09-26 14:10:39 +000041}
42
43int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
44{
Simon Glassdc9f8cd2013-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 Glass3d750d72011-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 Glass64371472012-12-13 20:49:11 +000062 return (void *)(gd->arch.ram_buf + paddr);
Simon Glass3d750d72011-09-26 14:10:39 +000063}
64
Simon Glassf7c3f6f2014-02-27 13:25:55 -070065phys_addr_t map_to_sysmem(const void *ptr)
Simon Glasse23d2932013-04-20 08:42:37 +000066{
67 return (u8 *)ptr - gd->arch.ram_buf;
68}
69
Simon Glass3d750d72011-09-26 14:10:39 +000070void flush_dcache_range(unsigned long start, unsigned long stop)
71{
72}