Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 2 | /* |
| 3 | * K2L EVM : Board initialization |
| 4 | * |
| 5 | * (C) Copyright 2014 |
| 6 | * Texas Instruments Incorporated, <www.ti.com> |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +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 | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 12 | #include <asm/arch/ddr3.h> |
| 13 | #include <asm/arch/hardware.h> |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 14 | #include <asm/ti-common/keystone_net.h> |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +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 = 122880000; |
| 23 | break; |
| 24 | case alt_core_clk: |
| 25 | clk_freq = 100000000; |
| 26 | break; |
| 27 | case pa_clk: |
| 28 | clk_freq = 122880000; |
| 29 | break; |
| 30 | case tetris_clk: |
| 31 | clk_freq = 122880000; |
| 32 | break; |
| 33 | case ddr3a_clk: |
| 34 | clk_freq = 100000000; |
| 35 | break; |
| 36 | default: |
| 37 | clk_freq = 0; |
| 38 | break; |
| 39 | } |
| 40 | |
| 41 | return clk_freq; |
| 42 | } |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 43 | |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 44 | static struct pll_init_data core_pll_config[NUM_SPDS] = { |
| 45 | [SPD800] = CORE_PLL_799, |
| 46 | [SPD1000] = CORE_PLL_1000, |
Lokesh Vutla | b4a96bd | 2015-08-17 19:58:34 +0530 | [diff] [blame] | 47 | [SPD1200] = CORE_PLL_1198, |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 48 | }; |
| 49 | |
Lokesh Vutla | 70438fc | 2015-07-28 14:16:43 +0530 | [diff] [blame] | 50 | s16 divn_val[16] = { |
| 51 | 0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
| 52 | }; |
| 53 | |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 54 | static struct pll_init_data tetris_pll_config[] = { |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 55 | [SPD800] = TETRIS_PLL_799, |
| 56 | [SPD1000] = TETRIS_PLL_1000, |
| 57 | [SPD1200] = TETRIS_PLL_1198, |
| 58 | [SPD1350] = TETRIS_PLL_1352, |
| 59 | [SPD1400] = TETRIS_PLL_1401, |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | static struct pll_init_data pa_pll_config = |
| 63 | PASS_PLL_983; |
| 64 | |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 65 | struct pll_init_data *get_pll_init_data(int pll) |
| 66 | { |
| 67 | int speed; |
| 68 | struct pll_init_data *data; |
| 69 | |
| 70 | switch (pll) { |
| 71 | case MAIN_PLL: |
Lokesh Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 72 | speed = get_max_dev_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 73 | data = &core_pll_config[speed]; |
| 74 | break; |
| 75 | case TETRIS_PLL: |
Lokesh Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 76 | speed = get_max_arm_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 77 | data = &tetris_pll_config[speed]; |
| 78 | break; |
| 79 | case PASS_PLL: |
| 80 | data = &pa_pll_config; |
| 81 | break; |
| 82 | default: |
| 83 | data = NULL; |
| 84 | } |
| 85 | |
| 86 | return data; |
| 87 | } |
| 88 | |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 89 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 90 | int board_early_init_f(void) |
| 91 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 92 | init_plls(); |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 93 | |
| 94 | return 0; |
| 95 | } |
| 96 | #endif |
| 97 | |
Jean-Jacques Hiblot | 2037fa4 | 2017-09-15 12:57:24 +0200 | [diff] [blame] | 98 | #if defined(CONFIG_MULTI_DTB_FIT) |
Cooper Jr., Franklin | 43ff224 | 2017-06-16 17:25:16 -0500 | [diff] [blame] | 99 | int board_fit_config_name_match(const char *name) |
| 100 | { |
| 101 | if (!strcmp(name, "keystone-k2l-evm")) |
| 102 | return 0; |
| 103 | |
| 104 | return -1; |
| 105 | } |
| 106 | #endif |
| 107 | |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 108 | #ifdef CONFIG_SPL_BUILD |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 109 | void spl_init_keystone_plls(void) |
| 110 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 111 | init_plls(); |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 112 | } |
| 113 | #endif |