xref: /openbmc/u-boot/board/ti/ks2_evm/board_k2e.c (revision 57efeb04)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * K2E EVM : Board initialization
4  *
5  * (C) Copyright 2014
6  *     Texas Instruments Incorporated, <www.ti.com>
7  */
8 
9 #include <common.h>
10 #include <asm/arch/ddr3.h>
11 #include <asm/arch/hardware.h>
12 #include <asm/ti-common/keystone_net.h>
13 
14 unsigned int get_external_clk(u32 clk)
15 {
16 	unsigned int clk_freq;
17 
18 	switch (clk) {
19 	case sys_clk:
20 		clk_freq = 100000000;
21 		break;
22 	case alt_core_clk:
23 		clk_freq = 100000000;
24 		break;
25 	case pa_clk:
26 		clk_freq = 100000000;
27 		break;
28 	case ddr3a_clk:
29 		clk_freq = 100000000;
30 		break;
31 	default:
32 		clk_freq = 0;
33 		break;
34 	}
35 
36 	return clk_freq;
37 }
38 
39 static struct pll_init_data core_pll_config[NUM_SPDS] = {
40 	[SPD800]	= CORE_PLL_800,
41 	[SPD850]	= CORE_PLL_850,
42 	[SPD1000]	= CORE_PLL_1000,
43 	[SPD1250]	= CORE_PLL_1250,
44 	[SPD1350]	= CORE_PLL_1350,
45 	[SPD1400]	= CORE_PLL_1400,
46 	[SPD1500]	= CORE_PLL_1500,
47 };
48 
49 /* DEV and ARM speed definitions as specified in DEVSPEED register */
50 int speeds[DEVSPEED_NUMSPDS] = {
51 	SPD850,
52 	SPD1000,
53 	SPD1250,
54 	SPD1350,
55 	SPD1400,
56 	SPD1500,
57 	SPD1400,
58 	SPD1350,
59 	SPD1250,
60 	SPD1000,
61 	SPD850,
62 	SPD800,
63 };
64 
65 s16 divn_val[16] = {
66 	0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
67 };
68 
69 static struct pll_init_data pa_pll_config =
70 	PASS_PLL_1000;
71 
72 struct pll_init_data *get_pll_init_data(int pll)
73 {
74 	int speed;
75 	struct pll_init_data *data;
76 
77 	switch (pll) {
78 	case MAIN_PLL:
79 		speed = get_max_dev_speed(speeds);
80 		data = &core_pll_config[speed];
81 		break;
82 	case PASS_PLL:
83 		data = &pa_pll_config;
84 		break;
85 	default:
86 		data = NULL;
87 	}
88 
89 	return data;
90 }
91 
92 #if defined(CONFIG_MULTI_DTB_FIT)
93 int board_fit_config_name_match(const char *name)
94 {
95 	if (!strcmp(name, "keystone-k2e-evm"))
96 		return 0;
97 
98 	return -1;
99 }
100 #endif
101 
102 #if defined(CONFIG_BOARD_EARLY_INIT_F)
103 int board_early_init_f(void)
104 {
105 	init_plls();
106 
107 	return 0;
108 }
109 #endif
110 
111 #ifdef CONFIG_SPL_BUILD
112 void spl_init_keystone_plls(void)
113 {
114 	init_plls();
115 }
116 #endif
117