• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2011 The Chromium OS Authors.
4  */
5 
6 #include <common.h>
7 #include <cpu_func.h>
8 #include <cros_ec.h>
9 #include <dm.h>
10 #include <init.h>
11 #include <led.h>
12 #include <os.h>
13 #include <asm/test.h>
14 #include <asm/u-boot-sandbox.h>
15 
16 /*
17  * Pointer to initial global data area
18  *
19  * Here we initialize it.
20  */
21 gd_t *gd;
22 
23 /* Add a simple GPIO device */
24 U_BOOT_DEVICE(gpio_sandbox) = {
25 	.name = "gpio_sandbox",
26 };
27 
flush_cache(unsigned long start,unsigned long size)28 void flush_cache(unsigned long start, unsigned long size)
29 {
30 }
31 
32 #ifndef CONFIG_TIMER
33 /* system timer offset in ms */
34 static unsigned long sandbox_timer_offset;
35 
timer_test_add_offset(unsigned long offset)36 void timer_test_add_offset(unsigned long offset)
37 {
38 	sandbox_timer_offset += offset;
39 }
40 
timer_read_counter(void)41 unsigned long timer_read_counter(void)
42 {
43 	return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
44 }
45 #endif
46 
dram_init(void)47 int dram_init(void)
48 {
49 	gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
50 	return 0;
51 }
52 
board_init(void)53 int board_init(void)
54 {
55 	if (IS_ENABLED(CONFIG_LED))
56 		led_default_state();
57 
58 	return 0;
59 }
60 
61 #ifdef CONFIG_BOARD_LATE_INIT
board_late_init(void)62 int board_late_init(void)
63 {
64 	struct udevice *dev;
65 	int ret;
66 
67 	ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
68 	if (ret && ret != -ENODEV) {
69 		/* Force console on */
70 		gd->flags &= ~GD_FLG_SILENT;
71 
72 		printf("cros-ec communications failure %d\n", ret);
73 		puts("\nPlease reset with Power+Refresh\n\n");
74 		panic("Cannot init cros-ec device");
75 		return -1;
76 	}
77 	return 0;
78 }
79 #endif
80