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