Gregory CLEMENT | dd1033e | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| 2 | /* |
| 3 | * Copyright (c) 2018 Microsemi Corporation |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 7 | #include <init.h> |
Gregory CLEMENT | dd1033e | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 8 | |
| 9 | #include <asm/io.h> |
| 10 | #include <asm/types.h> |
| 11 | |
| 12 | #include <mach/tlb.h> |
| 13 | #include <mach/ddr.h> |
| 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | static inline int vcoreiii_train_bytelane(void) |
| 18 | { |
| 19 | int ret; |
| 20 | |
| 21 | ret = hal_vcoreiii_train_bytelane(0); |
| 22 | |
Horatiu Vultur | 0551251 | 2019-01-17 15:33:27 +0100 | [diff] [blame] | 23 | #if defined(CONFIG_SOC_OCELOT) || defined(CONFIG_SOC_JR2) || \ |
Horatiu Vultur | 1895b87 | 2019-01-23 16:39:42 +0100 | [diff] [blame] | 24 | defined(CONFIG_SOC_SERVALT) || defined(CONFIG_SOC_SERVAL) |
Gregory CLEMENT | dd1033e | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 25 | if (ret) |
| 26 | return ret; |
| 27 | ret = hal_vcoreiii_train_bytelane(1); |
Gregory CLEMENT | 6bd8231 | 2018-12-14 16:16:48 +0100 | [diff] [blame] | 28 | #endif |
Gregory CLEMENT | dd1033e | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 29 | |
| 30 | return ret; |
| 31 | } |
| 32 | |
| 33 | int vcoreiii_ddr_init(void) |
| 34 | { |
Lars Povlsen | 7048bb1 | 2020-02-06 10:45:40 +0100 | [diff] [blame] | 35 | register int res; |
Gregory CLEMENT | dd1033e | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 36 | |
| 37 | if (!(readl(BASE_CFG + ICPU_MEMCTRL_STAT) |
| 38 | & ICPU_MEMCTRL_STAT_INIT_DONE)) { |
| 39 | hal_vcoreiii_init_memctl(); |
| 40 | hal_vcoreiii_wait_memctl(); |
| 41 | if (hal_vcoreiii_init_dqs() || vcoreiii_train_bytelane()) |
| 42 | hal_vcoreiii_ddr_failed(); |
| 43 | } |
Lars Povlsen | 7048bb1 | 2020-02-06 10:45:40 +0100 | [diff] [blame] | 44 | |
Gregory CLEMENT | dd1033e | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 45 | res = dram_check(); |
| 46 | if (res == 0) |
| 47 | hal_vcoreiii_ddr_verified(); |
| 48 | else |
| 49 | hal_vcoreiii_ddr_failed(); |
| 50 | |
Lars Povlsen | 7048bb1 | 2020-02-06 10:45:40 +0100 | [diff] [blame] | 51 | /* Remap DDR to kuseg: Clear boot-mode */ |
Gregory CLEMENT | dd1033e | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 52 | clrbits_le32(BASE_CFG + ICPU_GENERAL_CTRL, |
| 53 | ICPU_GENERAL_CTRL_BOOT_MODE_ENA); |
Lars Povlsen | 7048bb1 | 2020-02-06 10:45:40 +0100 | [diff] [blame] | 54 | /* - and read-back to activate/verify */ |
Gregory CLEMENT | dd1033e | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 55 | readl(BASE_CFG + ICPU_GENERAL_CTRL); |
Lars Povlsen | 7048bb1 | 2020-02-06 10:45:40 +0100 | [diff] [blame] | 56 | |
Gregory CLEMENT | dd1033e | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 57 | return res; |
| 58 | } |
| 59 | |
| 60 | int print_cpuinfo(void) |
| 61 | { |
| 62 | printf("MSCC VCore-III MIPS 24Kec\n"); |
| 63 | |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | int dram_init(void) |
| 68 | { |
Gregory CLEMENT | dd1033e | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 69 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; |
| 70 | return 0; |
| 71 | } |