blob: c65f33131da0cf21f4a654fac81188004b7581fc [file] [log] [blame]
Hao Zhangc13cbcf2014-10-22 16:32:33 +03001/*
2 * K2L EVM : Board initialization
3 *
4 * (C) Copyright 2014
5 * Texas Instruments Incorporated, <www.ti.com>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9
10#include <common.h>
11#include <asm/arch/ddr3.h>
12#include <asm/arch/hardware.h>
Hao Zhang7874b8a2014-10-29 13:09:34 +020013#include <asm/ti-common/keystone_net.h>
Hao Zhangc13cbcf2014-10-22 16:32:33 +030014
15DECLARE_GLOBAL_DATA_PTR;
16
Lokesh Vutlaa9a0e122017-05-03 16:58:26 +053017unsigned int get_external_clk(u32 clk)
18{
19 unsigned int clk_freq;
20
21 switch (clk) {
22 case sys_clk:
23 clk_freq = 122880000;
24 break;
25 case alt_core_clk:
26 clk_freq = 100000000;
27 break;
28 case pa_clk:
29 clk_freq = 122880000;
30 break;
31 case tetris_clk:
32 clk_freq = 122880000;
33 break;
34 case ddr3a_clk:
35 clk_freq = 100000000;
36 break;
37 default:
38 clk_freq = 0;
39 break;
40 }
41
42 return clk_freq;
43}
Hao Zhangc13cbcf2014-10-22 16:32:33 +030044
Lokesh Vutla9da9afa2015-07-28 14:16:44 +053045static struct pll_init_data core_pll_config[NUM_SPDS] = {
46 [SPD800] = CORE_PLL_799,
47 [SPD1000] = CORE_PLL_1000,
Lokesh Vutlab4a96bd2015-08-17 19:58:34 +053048 [SPD1200] = CORE_PLL_1198,
Hao Zhangc13cbcf2014-10-22 16:32:33 +030049};
50
Lokesh Vutla70438fc2015-07-28 14:16:43 +053051s16 divn_val[16] = {
52 0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
53};
54
Hao Zhangc13cbcf2014-10-22 16:32:33 +030055static struct pll_init_data tetris_pll_config[] = {
Lokesh Vutla9da9afa2015-07-28 14:16:44 +053056 [SPD800] = TETRIS_PLL_799,
57 [SPD1000] = TETRIS_PLL_1000,
58 [SPD1200] = TETRIS_PLL_1198,
59 [SPD1350] = TETRIS_PLL_1352,
60 [SPD1400] = TETRIS_PLL_1401,
Hao Zhangc13cbcf2014-10-22 16:32:33 +030061};
62
63static struct pll_init_data pa_pll_config =
64 PASS_PLL_983;
65
Lokesh Vutla79a94a22015-07-28 14:16:46 +053066struct pll_init_data *get_pll_init_data(int pll)
67{
68 int speed;
69 struct pll_init_data *data;
70
71 switch (pll) {
72 case MAIN_PLL:
Lokesh Vutlab35410e2016-03-04 10:36:40 -060073 speed = get_max_dev_speed(speeds);
Lokesh Vutla79a94a22015-07-28 14:16:46 +053074 data = &core_pll_config[speed];
75 break;
76 case TETRIS_PLL:
Lokesh Vutlab35410e2016-03-04 10:36:40 -060077 speed = get_max_arm_speed(speeds);
Lokesh Vutla79a94a22015-07-28 14:16:46 +053078 data = &tetris_pll_config[speed];
79 break;
80 case PASS_PLL:
81 data = &pa_pll_config;
82 break;
83 default:
84 data = NULL;
85 }
86
87 return data;
88}
89
Hao Zhang7874b8a2014-10-29 13:09:34 +020090#ifdef CONFIG_DRIVER_TI_KEYSTONE_NET
91struct eth_priv_t eth_priv_cfg[] = {
92 {
93 .int_name = "K2L_EMAC",
94 .rx_flow = 0,
95 .phy_addr = 0,
96 .slave_port = 1,
97 .sgmii_link_type = SGMII_LINK_MAC_PHY,
Mugunthan V Nd44bb342015-09-19 16:26:48 +053098 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang7874b8a2014-10-29 13:09:34 +020099 },
100 {
101 .int_name = "K2L_EMAC1",
102 .rx_flow = 8,
103 .phy_addr = 1,
104 .slave_port = 2,
105 .sgmii_link_type = SGMII_LINK_MAC_PHY,
Mugunthan V Nd44bb342015-09-19 16:26:48 +0530106 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang7874b8a2014-10-29 13:09:34 +0200107 },
108 {
109 .int_name = "K2L_EMAC2",
110 .rx_flow = 16,
111 .phy_addr = 2,
112 .slave_port = 3,
113 .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
Mugunthan V Nd44bb342015-09-19 16:26:48 +0530114 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang7874b8a2014-10-29 13:09:34 +0200115 },
116 {
117 .int_name = "K2L_EMAC3",
118 .rx_flow = 32,
119 .phy_addr = 3,
120 .slave_port = 4,
121 .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
Mugunthan V Nd44bb342015-09-19 16:26:48 +0530122 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang7874b8a2014-10-29 13:09:34 +0200123 },
124};
125
126int get_num_eth_ports(void)
127{
128 return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t);
129}
130#endif
131
Hao Zhangc13cbcf2014-10-22 16:32:33 +0300132#ifdef CONFIG_BOARD_EARLY_INIT_F
133int board_early_init_f(void)
134{
Lokesh Vutla79a94a22015-07-28 14:16:46 +0530135 init_plls();
Hao Zhangc13cbcf2014-10-22 16:32:33 +0300136
137 return 0;
138}
139#endif
140
Jean-Jacques Hiblot2037fa42017-09-15 12:57:24 +0200141#if defined(CONFIG_MULTI_DTB_FIT)
Cooper Jr., Franklin43ff2242017-06-16 17:25:16 -0500142int board_fit_config_name_match(const char *name)
143{
144 if (!strcmp(name, "keystone-k2l-evm"))
145 return 0;
146
147 return -1;
148}
149#endif
150
Hao Zhangc13cbcf2014-10-22 16:32:33 +0300151#ifdef CONFIG_SPL_BUILD
Hao Zhangc13cbcf2014-10-22 16:32:33 +0300152void spl_init_keystone_plls(void)
153{
Lokesh Vutla79a94a22015-07-28 14:16:46 +0530154 init_plls();
Hao Zhangc13cbcf2014-10-22 16:32:33 +0300155}
156#endif