huang lin | a6dbfb5 | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2016 Rockchip Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | */ |
| 16 | |
Lin Huang | fe7aa20 | 2016-03-19 22:44:39 +0800 | [diff] [blame] | 17 | #include <arch/mmu.h> |
Julius Werner | 5d6593a | 2018-08-10 16:13:26 -0700 | [diff] [blame] | 18 | #include <arch/stages.h> |
Derek Basehore | 38bee53 | 2016-09-21 17:42:26 -0700 | [diff] [blame] | 19 | #include <delay.h> |
Lin Huang | fe7aa20 | 2016-03-19 22:44:39 +0800 | [diff] [blame] | 20 | #include <soc/mmu_operations.h> |
Shunqian Zheng | f4181ce | 2016-05-06 16:50:48 +0800 | [diff] [blame] | 21 | #include <soc/tsadc.h> |
Lin Huang | c4cbf48 | 2016-03-17 15:28:33 +0800 | [diff] [blame] | 22 | #include <soc/sdram.h> |
Vadim Bendebury | 04884b6 | 2016-04-12 16:06:31 -0700 | [diff] [blame] | 23 | #include <symbols.h> |
Liangfeng Wu | 76655cb | 2016-05-26 16:06:58 +0800 | [diff] [blame] | 24 | #include <soc/usb.h> |
Lin Huang | fe7aa20 | 2016-03-19 22:44:39 +0800 | [diff] [blame] | 25 | |
Julius Werner | 6486e78 | 2017-07-14 14:30:29 -0700 | [diff] [blame] | 26 | #include "board.h" |
Eric Gao | 61e6c44 | 2016-07-29 12:34:32 +0800 | [diff] [blame] | 27 | #include "pwm_regulator.h" |
| 28 | |
Vadim Bendebury | 04884b6 | 2016-04-12 16:06:31 -0700 | [diff] [blame] | 29 | static void init_dvs_outputs(void) |
| 30 | { |
Eric Gao | 61e6c44 | 2016-07-29 12:34:32 +0800 | [diff] [blame] | 31 | pwm_regulator_configure(PWM_REGULATOR_GPU, 900); |
| 32 | pwm_regulator_configure(PWM_REGULATOR_BIG, 900); |
Douglas Anderson | 992c7db | 2017-04-17 13:18:11 -0700 | [diff] [blame] | 33 | |
Philip Chen | a061820 | 2017-08-23 18:02:25 -0700 | [diff] [blame] | 34 | /* |
| 35 | * Kevin's logic rail has some ripple, so up the voltage a bit. Newer |
| 36 | * boards use a fixed 900mV regulator for centerlogic. |
| 37 | */ |
Douglas Anderson | 992c7db | 2017-04-17 13:18:11 -0700 | [diff] [blame] | 38 | if (IS_ENABLED(CONFIG_BOARD_GOOGLE_KEVIN)) |
| 39 | pwm_regulator_configure(PWM_REGULATOR_CENTERLOG, 925); |
Philip Chen | a061820 | 2017-08-23 18:02:25 -0700 | [diff] [blame] | 40 | else if (IS_ENABLED(CONFIG_GRU_HAS_CENTERLOG_PWM)) |
Douglas Anderson | 992c7db | 2017-04-17 13:18:11 -0700 | [diff] [blame] | 41 | pwm_regulator_configure(PWM_REGULATOR_CENTERLOG, 900); |
| 42 | |
Derek Basehore | 38bee53 | 2016-09-21 17:42:26 -0700 | [diff] [blame] | 43 | /* Allow time for the regulators to settle */ |
| 44 | udelay(500); |
Vadim Bendebury | 04884b6 | 2016-04-12 16:06:31 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Caesar Wang | 01cbe3b | 2017-02-27 17:55:39 +0800 | [diff] [blame] | 47 | static void prepare_sdmmc(void) |
| 48 | { |
Julius Werner | 6486e78 | 2017-07-14 14:30:29 -0700 | [diff] [blame] | 49 | /* Enable main SD rail early to allow ramp time before powering SDIO. */ |
| 50 | gpio_output(GPIO_SDMMC_PWR, 1); |
Caesar Wang | 01cbe3b | 2017-02-27 17:55:39 +0800 | [diff] [blame] | 51 | } |
| 52 | |
Liangfeng Wu | 76655cb | 2016-05-26 16:06:58 +0800 | [diff] [blame] | 53 | static void prepare_usb(void) |
| 54 | { |
| 55 | /* |
| 56 | * Do dwc3 core soft reset and phy reset. Kick these resets |
| 57 | * off early so they get at least 100ms to settle. |
| 58 | */ |
Julius Werner | 785ff1b | 2016-08-03 19:18:39 -0700 | [diff] [blame] | 59 | reset_usb_otg0(); |
| 60 | reset_usb_otg1(); |
Liangfeng Wu | 76655cb | 2016-05-26 16:06:58 +0800 | [diff] [blame] | 61 | } |
| 62 | |
Julius Werner | 5d6593a | 2018-08-10 16:13:26 -0700 | [diff] [blame] | 63 | void platform_romstage_main(void) |
huang lin | a6dbfb5 | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 64 | { |
Shunqian Zheng | f4181ce | 2016-05-06 16:50:48 +0800 | [diff] [blame] | 65 | tsadc_init(TSHUT_POL_HIGH); |
Lin Huang | fe7aa20 | 2016-03-19 22:44:39 +0800 | [diff] [blame] | 66 | |
Vadim Bendebury | 04884b6 | 2016-04-12 16:06:31 -0700 | [diff] [blame] | 67 | /* Init DVS to conservative values. */ |
| 68 | init_dvs_outputs(); |
| 69 | |
Caesar Wang | 01cbe3b | 2017-02-27 17:55:39 +0800 | [diff] [blame] | 70 | prepare_sdmmc(); |
Liangfeng Wu | 76655cb | 2016-05-26 16:06:58 +0800 | [diff] [blame] | 71 | prepare_usb(); |
| 72 | |
Lin Huang | c4cbf48 | 2016-03-17 15:28:33 +0800 | [diff] [blame] | 73 | sdram_init(get_sdram_config()); |
Lin Huang | fe7aa20 | 2016-03-19 22:44:39 +0800 | [diff] [blame] | 74 | |
Lin Huang | f00af58 | 2016-11-15 11:40:58 +0800 | [diff] [blame] | 75 | mmu_config_range((void *)0, (uintptr_t)sdram_size_mb() * MiB, |
| 76 | CACHED_MEM); |
Julius Werner | 7e0dea6 | 2019-02-20 18:39:22 -0800 | [diff] [blame] | 77 | mmu_config_range(_dma_coherent, REGION_SIZE(dma_coherent), |
| 78 | UNCACHED_MEM); |
huang lin | a6dbfb5 | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 79 | } |