Simon Glass | 8fbf992 | 2019-01-21 14:53:36 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2018 Google |
| 4 | */ |
| 5 | |
Alper Nebi Yasak | f55f388 | 2020-10-28 00:15:11 +0300 | [diff] [blame] | 6 | #include <dm.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 7 | #include <init.h> |
Alper Nebi Yasak | 437fa8d | 2021-12-24 16:43:43 +0300 | [diff] [blame] | 8 | #include <asm/arch-rockchip/clock.h> |
Simon Glass | 8fbf992 | 2019-01-21 14:53:36 -0700 | [diff] [blame] | 9 | |
Kever Yang | b22e9fd | 2019-07-22 19:59:41 +0800 | [diff] [blame] | 10 | #ifdef CONFIG_SPL_BUILD |
Simon Glass | 8fbf992 | 2019-01-21 14:53:36 -0700 | [diff] [blame] | 11 | /* provided to defeat compiler optimisation in board_init_f() */ |
| 12 | void gru_dummy_function(int i) |
| 13 | { |
| 14 | } |
Kever Yang | b22e9fd | 2019-07-22 19:59:41 +0800 | [diff] [blame] | 15 | |
| 16 | int board_early_init_f(void) |
| 17 | { |
Marty E. Plummer | b20a8dac | 2021-12-24 16:43:46 +0300 | [diff] [blame] | 18 | # if defined(CONFIG_TARGET_CHROMEBOOK_BOB) || defined(CONFIG_TARGET_CHROMEBOOK_KEVIN) |
Kever Yang | b22e9fd | 2019-07-22 19:59:41 +0800 | [diff] [blame] | 19 | int sum, i; |
| 20 | |
| 21 | /* |
| 22 | * Add a delay and ensure that the compiler does not optimise this out. |
| 23 | * This is needed since the power rails tail a while to turn on, and |
| 24 | * we get garbage serial output otherwise. |
| 25 | */ |
| 26 | sum = 0; |
| 27 | for (i = 0; i < 150000; i++) |
| 28 | sum += i; |
| 29 | gru_dummy_function(sum); |
| 30 | #endif /* CONFIG_TARGET_CHROMEBOOK_BOB */ |
| 31 | |
| 32 | return 0; |
| 33 | } |
| 34 | #endif |
Alper Nebi Yasak | f55f388 | 2020-10-28 00:15:11 +0300 | [diff] [blame] | 35 | |
| 36 | #ifndef CONFIG_SPL_BUILD |
| 37 | int board_early_init_r(void) |
| 38 | { |
| 39 | struct udevice *clk; |
| 40 | int ret; |
| 41 | |
| 42 | /* |
| 43 | * This init is done in SPL, but when chain-loading U-Boot SPL will |
| 44 | * have been skipped. Allow the clock driver to check if it needs |
| 45 | * setting up. |
| 46 | */ |
| 47 | ret = uclass_get_device_by_driver(UCLASS_CLK, |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 48 | DM_DRIVER_GET(clk_rk3399), &clk); |
Alper Nebi Yasak | f55f388 | 2020-10-28 00:15:11 +0300 | [diff] [blame] | 49 | if (ret) { |
| 50 | debug("%s: CLK init failed: %d\n", __func__, ret); |
| 51 | return ret; |
| 52 | } |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | #endif |