Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 2 | /* |
| 3 | * K2E EVM : Board initialization |
| 4 | * |
| 5 | * (C) Copyright 2014 |
| 6 | * Texas Instruments Incorporated, <www.ti.com> |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 10 | #include <image.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 11 | #include <init.h> |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 12 | #include <asm/arch/ddr3.h> |
| 13 | #include <asm/arch/hardware.h> |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 14 | #include <asm/ti-common/keystone_net.h> |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 15 | |
Lokesh Vutla | a9a0e12 | 2017-05-03 16:58:26 +0530 | [diff] [blame] | 16 | unsigned int get_external_clk(u32 clk) |
| 17 | { |
| 18 | unsigned int clk_freq; |
| 19 | |
| 20 | switch (clk) { |
| 21 | case sys_clk: |
| 22 | clk_freq = 100000000; |
| 23 | break; |
| 24 | case alt_core_clk: |
| 25 | clk_freq = 100000000; |
| 26 | break; |
| 27 | case pa_clk: |
| 28 | clk_freq = 100000000; |
| 29 | break; |
| 30 | case ddr3a_clk: |
| 31 | clk_freq = 100000000; |
| 32 | break; |
| 33 | default: |
| 34 | clk_freq = 0; |
| 35 | break; |
| 36 | } |
| 37 | |
| 38 | return clk_freq; |
| 39 | } |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 40 | |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 41 | static struct pll_init_data core_pll_config[NUM_SPDS] = { |
| 42 | [SPD800] = CORE_PLL_800, |
| 43 | [SPD850] = CORE_PLL_850, |
| 44 | [SPD1000] = CORE_PLL_1000, |
| 45 | [SPD1250] = CORE_PLL_1250, |
| 46 | [SPD1350] = CORE_PLL_1350, |
| 47 | [SPD1400] = CORE_PLL_1400, |
| 48 | [SPD1500] = CORE_PLL_1500, |
| 49 | }; |
| 50 | |
| 51 | /* DEV and ARM speed definitions as specified in DEVSPEED register */ |
| 52 | int speeds[DEVSPEED_NUMSPDS] = { |
| 53 | SPD850, |
| 54 | SPD1000, |
| 55 | SPD1250, |
| 56 | SPD1350, |
| 57 | SPD1400, |
| 58 | SPD1500, |
| 59 | SPD1400, |
| 60 | SPD1350, |
| 61 | SPD1250, |
| 62 | SPD1000, |
| 63 | SPD850, |
| 64 | SPD800, |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 65 | }; |
| 66 | |
Lokesh Vutla | 70438fc | 2015-07-28 14:16:43 +0530 | [diff] [blame] | 67 | s16 divn_val[16] = { |
| 68 | 0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
| 69 | }; |
| 70 | |
Vitaly Andrianov | 047e780 | 2014-07-25 22:23:19 +0300 | [diff] [blame] | 71 | static struct pll_init_data pa_pll_config = |
| 72 | PASS_PLL_1000; |
| 73 | |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 74 | struct pll_init_data *get_pll_init_data(int pll) |
| 75 | { |
| 76 | int speed; |
| 77 | struct pll_init_data *data; |
| 78 | |
| 79 | switch (pll) { |
| 80 | case MAIN_PLL: |
Lokesh Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 81 | speed = get_max_dev_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 82 | data = &core_pll_config[speed]; |
| 83 | break; |
| 84 | case PASS_PLL: |
| 85 | data = &pa_pll_config; |
| 86 | break; |
| 87 | default: |
| 88 | data = NULL; |
| 89 | } |
| 90 | |
| 91 | return data; |
| 92 | } |
| 93 | |
Jean-Jacques Hiblot | 2037fa4 | 2017-09-15 12:57:24 +0200 | [diff] [blame] | 94 | #if defined(CONFIG_MULTI_DTB_FIT) |
Cooper Jr., Franklin | 43ff224 | 2017-06-16 17:25:16 -0500 | [diff] [blame] | 95 | int board_fit_config_name_match(const char *name) |
| 96 | { |
| 97 | if (!strcmp(name, "keystone-k2e-evm")) |
| 98 | return 0; |
| 99 | |
| 100 | return -1; |
| 101 | } |
| 102 | #endif |
| 103 | |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 104 | #if defined(CONFIG_BOARD_EARLY_INIT_F) |
| 105 | int board_early_init_f(void) |
| 106 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 107 | init_plls(); |
Vitaly Andrianov | 047e780 | 2014-07-25 22:23:19 +0300 | [diff] [blame] | 108 | |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 109 | return 0; |
| 110 | } |
| 111 | #endif |
Hao Zhang | 9594820 | 2014-10-22 16:32:31 +0300 | [diff] [blame] | 112 | |
| 113 | #ifdef CONFIG_SPL_BUILD |
Hao Zhang | 9594820 | 2014-10-22 16:32:31 +0300 | [diff] [blame] | 114 | void spl_init_keystone_plls(void) |
| 115 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 116 | init_plls(); |
Hao Zhang | 9594820 | 2014-10-22 16:32:31 +0300 | [diff] [blame] | 117 | } |
| 118 | #endif |