blob: e49d8b348236e3542a5aadb8fd84672c786e6f3b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Hao Zhangc13cbcf2014-10-22 16:32:33 +03002/*
3 * K2L EVM : Board initialization
4 *
5 * (C) Copyright 2014
6 * Texas Instruments Incorporated, <www.ti.com>
Hao Zhangc13cbcf2014-10-22 16:32:33 +03007 */
8
9#include <common.h>
10#include <asm/arch/ddr3.h>
11#include <asm/arch/hardware.h>
Hao Zhang7874b8a2014-10-29 13:09:34 +020012#include <asm/ti-common/keystone_net.h>
Hao Zhangc13cbcf2014-10-22 16:32:33 +030013
Lokesh Vutlaa9a0e122017-05-03 16:58:26 +053014unsigned int get_external_clk(u32 clk)
15{
16 unsigned int clk_freq;
17
18 switch (clk) {
19 case sys_clk:
20 clk_freq = 122880000;
21 break;
22 case alt_core_clk:
23 clk_freq = 100000000;
24 break;
25 case pa_clk:
26 clk_freq = 122880000;
27 break;
28 case tetris_clk:
29 clk_freq = 122880000;
30 break;
31 case ddr3a_clk:
32 clk_freq = 100000000;
33 break;
34 default:
35 clk_freq = 0;
36 break;
37 }
38
39 return clk_freq;
40}
Hao Zhangc13cbcf2014-10-22 16:32:33 +030041
Lokesh Vutla9da9afa2015-07-28 14:16:44 +053042static struct pll_init_data core_pll_config[NUM_SPDS] = {
43 [SPD800] = CORE_PLL_799,
44 [SPD1000] = CORE_PLL_1000,
Lokesh Vutlab4a96bd2015-08-17 19:58:34 +053045 [SPD1200] = CORE_PLL_1198,
Hao Zhangc13cbcf2014-10-22 16:32:33 +030046};
47
Lokesh Vutla70438fc2015-07-28 14:16:43 +053048s16 divn_val[16] = {
49 0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
50};
51
Hao Zhangc13cbcf2014-10-22 16:32:33 +030052static struct pll_init_data tetris_pll_config[] = {
Lokesh Vutla9da9afa2015-07-28 14:16:44 +053053 [SPD800] = TETRIS_PLL_799,
54 [SPD1000] = TETRIS_PLL_1000,
55 [SPD1200] = TETRIS_PLL_1198,
56 [SPD1350] = TETRIS_PLL_1352,
57 [SPD1400] = TETRIS_PLL_1401,
Hao Zhangc13cbcf2014-10-22 16:32:33 +030058};
59
60static struct pll_init_data pa_pll_config =
61 PASS_PLL_983;
62
Lokesh Vutla79a94a22015-07-28 14:16:46 +053063struct pll_init_data *get_pll_init_data(int pll)
64{
65 int speed;
66 struct pll_init_data *data;
67
68 switch (pll) {
69 case MAIN_PLL:
Lokesh Vutlab35410e2016-03-04 10:36:40 -060070 speed = get_max_dev_speed(speeds);
Lokesh Vutla79a94a22015-07-28 14:16:46 +053071 data = &core_pll_config[speed];
72 break;
73 case TETRIS_PLL:
Lokesh Vutlab35410e2016-03-04 10:36:40 -060074 speed = get_max_arm_speed(speeds);
Lokesh Vutla79a94a22015-07-28 14:16:46 +053075 data = &tetris_pll_config[speed];
76 break;
77 case PASS_PLL:
78 data = &pa_pll_config;
79 break;
80 default:
81 data = NULL;
82 }
83
84 return data;
85}
86
Hao Zhangc13cbcf2014-10-22 16:32:33 +030087#ifdef CONFIG_BOARD_EARLY_INIT_F
88int board_early_init_f(void)
89{
Lokesh Vutla79a94a22015-07-28 14:16:46 +053090 init_plls();
Hao Zhangc13cbcf2014-10-22 16:32:33 +030091
92 return 0;
93}
94#endif
95
Jean-Jacques Hiblot2037fa42017-09-15 12:57:24 +020096#if defined(CONFIG_MULTI_DTB_FIT)
Cooper Jr., Franklin43ff2242017-06-16 17:25:16 -050097int board_fit_config_name_match(const char *name)
98{
99 if (!strcmp(name, "keystone-k2l-evm"))
100 return 0;
101
102 return -1;
103}
104#endif
105
Hao Zhangc13cbcf2014-10-22 16:32:33 +0300106#ifdef CONFIG_SPL_BUILD
Hao Zhangc13cbcf2014-10-22 16:32:33 +0300107void spl_init_keystone_plls(void)
108{
Lokesh Vutla79a94a22015-07-28 14:16:46 +0530109 init_plls();
Hao Zhangc13cbcf2014-10-22 16:32:33 +0300110}
111#endif