blob: f58f62358d3efd62d06370d398dfaaf64d4dc534 [file] [log] [blame]
Hao Zhang82be0132014-07-16 00:59:27 +03001/*
2 * K2E 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 Zhang6d4ec892014-10-17 21:01:17 +030013#include <asm/ti-common/keystone_net.h>
Hao Zhang82be0132014-07-16 00:59:27 +030014
15DECLARE_GLOBAL_DATA_PTR;
16
17unsigned int external_clk[ext_clk_count] = {
18 [sys_clk] = 100000000,
19 [alt_core_clk] = 100000000,
20 [pa_clk] = 100000000,
Lokesh Vutlac40f81d2015-07-28 14:16:47 +053021 [ddr3a_clk] = 100000000,
Hao Zhang82be0132014-07-16 00:59:27 +030022};
23
Lokesh Vutla9da9afa2015-07-28 14:16:44 +053024static struct pll_init_data core_pll_config[NUM_SPDS] = {
25 [SPD800] = CORE_PLL_800,
26 [SPD850] = CORE_PLL_850,
27 [SPD1000] = CORE_PLL_1000,
28 [SPD1250] = CORE_PLL_1250,
29 [SPD1350] = CORE_PLL_1350,
30 [SPD1400] = CORE_PLL_1400,
31 [SPD1500] = CORE_PLL_1500,
32};
33
34/* DEV and ARM speed definitions as specified in DEVSPEED register */
35int speeds[DEVSPEED_NUMSPDS] = {
36 SPD850,
37 SPD1000,
38 SPD1250,
39 SPD1350,
40 SPD1400,
41 SPD1500,
42 SPD1400,
43 SPD1350,
44 SPD1250,
45 SPD1000,
46 SPD850,
47 SPD800,
Hao Zhang82be0132014-07-16 00:59:27 +030048};
49
Lokesh Vutla70438fc2015-07-28 14:16:43 +053050s16 divn_val[16] = {
51 0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
52};
53
Vitaly Andrianov047e7802014-07-25 22:23:19 +030054static struct pll_init_data pa_pll_config =
55 PASS_PLL_1000;
56
Lokesh Vutla79a94a22015-07-28 14:16:46 +053057struct pll_init_data *get_pll_init_data(int pll)
58{
59 int speed;
60 struct pll_init_data *data;
61
62 switch (pll) {
63 case MAIN_PLL:
64 speed = get_max_dev_speed();
65 data = &core_pll_config[speed];
66 break;
67 case PASS_PLL:
68 data = &pa_pll_config;
69 break;
70 default:
71 data = NULL;
72 }
73
74 return data;
75}
76
Hao Zhang6d4ec892014-10-17 21:01:17 +030077#ifdef CONFIG_DRIVER_TI_KEYSTONE_NET
78struct eth_priv_t eth_priv_cfg[] = {
79 {
80 .int_name = "K2E_EMAC0",
81 .rx_flow = 0,
82 .phy_addr = 0,
83 .slave_port = 1,
84 .sgmii_link_type = SGMII_LINK_MAC_PHY,
Mugunthan V Nd44bb342015-09-19 16:26:48 +053085 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang6d4ec892014-10-17 21:01:17 +030086 },
87 {
88 .int_name = "K2E_EMAC1",
89 .rx_flow = 8,
90 .phy_addr = 1,
91 .slave_port = 2,
92 .sgmii_link_type = SGMII_LINK_MAC_PHY,
Mugunthan V Nd44bb342015-09-19 16:26:48 +053093 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang6d4ec892014-10-17 21:01:17 +030094 },
95 {
96 .int_name = "K2E_EMAC2",
97 .rx_flow = 16,
98 .phy_addr = 2,
99 .slave_port = 3,
100 .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
Mugunthan V Nd44bb342015-09-19 16:26:48 +0530101 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang6d4ec892014-10-17 21:01:17 +0300102 },
103 {
104 .int_name = "K2E_EMAC3",
105 .rx_flow = 24,
106 .phy_addr = 3,
107 .slave_port = 4,
108 .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
Mugunthan V Nd44bb342015-09-19 16:26:48 +0530109 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang6d4ec892014-10-17 21:01:17 +0300110 },
111 {
112 .int_name = "K2E_EMAC4",
113 .rx_flow = 32,
114 .phy_addr = 4,
115 .slave_port = 5,
116 .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
Mugunthan V Nd44bb342015-09-19 16:26:48 +0530117 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang6d4ec892014-10-17 21:01:17 +0300118 },
119 {
120 .int_name = "K2E_EMAC5",
121 .rx_flow = 40,
122 .phy_addr = 5,
123 .slave_port = 6,
124 .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
Mugunthan V Nd44bb342015-09-19 16:26:48 +0530125 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang6d4ec892014-10-17 21:01:17 +0300126 },
127 {
128 .int_name = "K2E_EMAC6",
129 .rx_flow = 48,
130 .phy_addr = 6,
131 .slave_port = 7,
132 .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
Mugunthan V Nd44bb342015-09-19 16:26:48 +0530133 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang6d4ec892014-10-17 21:01:17 +0300134 },
135 {
136 .int_name = "K2E_EMAC7",
137 .rx_flow = 56,
138 .phy_addr = 7,
139 .slave_port = 8,
140 .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
Mugunthan V Nd44bb342015-09-19 16:26:48 +0530141 .phy_if = PHY_INTERFACE_MODE_SGMII,
Hao Zhang6d4ec892014-10-17 21:01:17 +0300142 },
143};
144
145int get_num_eth_ports(void)
146{
147 return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t);
148}
149#endif
150
Hao Zhang82be0132014-07-16 00:59:27 +0300151#if defined(CONFIG_BOARD_EARLY_INIT_F)
152int board_early_init_f(void)
153{
Lokesh Vutla79a94a22015-07-28 14:16:46 +0530154 init_plls();
Vitaly Andrianov047e7802014-07-25 22:23:19 +0300155
Hao Zhang82be0132014-07-16 00:59:27 +0300156 return 0;
157}
158#endif
Hao Zhang95948202014-10-22 16:32:31 +0300159
160#ifdef CONFIG_SPL_BUILD
Hao Zhang95948202014-10-22 16:32:31 +0300161void spl_init_keystone_plls(void)
162{
Lokesh Vutla79a94a22015-07-28 14:16:46 +0530163 init_plls();
Hao Zhang95948202014-10-22 16:32:31 +0300164}
165#endif