]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
43bd194c SG |
2 | /* |
3 | * Copyright (c) 2011 The Chromium OS Authors. | |
43bd194c SG |
4 | */ |
5 | ||
6 | #include <common.h> | |
1eb69ae4 | 7 | #include <cpu_func.h> |
86bf601d | 8 | #include <cros_ec.h> |
e2d8a714 | 9 | #include <dm.h> |
5255932f | 10 | #include <init.h> |
17585e2d | 11 | #include <led.h> |
d99a6874 | 12 | #include <os.h> |
909bd6d9 | 13 | #include <asm/test.h> |
7d95f2a3 | 14 | #include <asm/u-boot-sandbox.h> |
d99a6874 | 15 | |
43bd194c SG |
16 | /* |
17 | * Pointer to initial global data area | |
18 | * | |
19 | * Here we initialize it. | |
20 | */ | |
21 | gd_t *gd; | |
22 | ||
e2d8a714 SG |
23 | /* Add a simple GPIO device */ |
24 | U_BOOT_DEVICE(gpio_sandbox) = { | |
e3e2470f | 25 | .name = "sandbox_gpio", |
e2d8a714 SG |
26 | }; |
27 | ||
43bd194c SG |
28 | void flush_cache(unsigned long start, unsigned long size) |
29 | { | |
30 | } | |
31 | ||
9961a0b6 | 32 | #ifndef CONFIG_TIMER |
909bd6d9 JH |
33 | /* system timer offset in ms */ |
34 | static unsigned long sandbox_timer_offset; | |
35 | ||
d0a9b82b | 36 | void timer_test_add_offset(unsigned long offset) |
909bd6d9 JH |
37 | { |
38 | sandbox_timer_offset += offset; | |
39 | } | |
40 | ||
28c860b2 | 41 | unsigned long timer_read_counter(void) |
6994ccf8 | 42 | { |
909bd6d9 | 43 | return os_get_nsec() / 1000 + sandbox_timer_offset * 1000; |
43bd194c | 44 | } |
9961a0b6 | 45 | #endif |
43bd194c | 46 | |
43bd194c SG |
47 | int dram_init(void) |
48 | { | |
a733b06b | 49 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; |
43bd194c SG |
50 | return 0; |
51 | } | |
86bf601d | 52 | |
17585e2d PD |
53 | int board_init(void) |
54 | { | |
55 | if (IS_ENABLED(CONFIG_LED)) | |
56 | led_default_state(); | |
57 | ||
58 | return 0; | |
59 | } | |
60 | ||
1c0bc80a HS |
61 | int ft_board_setup(void *fdt, bd_t *bd) |
62 | { | |
63 | /* Create an arbitrary reservation to allow testing OF_BOARD_SETUP.*/ | |
64 | return fdt_add_mem_rsv(fdt, 0x00d02000, 0x4000); | |
65 | } | |
66 | ||
86bf601d SG |
67 | #ifdef CONFIG_BOARD_LATE_INIT |
68 | int board_late_init(void) | |
69 | { | |
a2a63a35 SG |
70 | struct udevice *dev; |
71 | int ret; | |
72 | ||
73 | ret = uclass_first_device_err(UCLASS_CROS_EC, &dev); | |
74 | if (ret && ret != -ENODEV) { | |
86bf601d SG |
75 | /* Force console on */ |
76 | gd->flags &= ~GD_FLG_SILENT; | |
77 | ||
a2a63a35 | 78 | printf("cros-ec communications failure %d\n", ret); |
86bf601d SG |
79 | puts("\nPlease reset with Power+Refresh\n\n"); |
80 | panic("Cannot init cros-ec device"); | |
81 | return -1; | |
82 | } | |
83 | return 0; | |
84 | } | |
85 | #endif |