xref: /openbmc/u-boot/board/ti/ks2_evm/board_k2e.c (revision 4dd02a75)
1 /*
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>
13 #include <asm/ti-common/keystone_net.h>
14 
15 DECLARE_GLOBAL_DATA_PTR;
16 
17 unsigned int external_clk[ext_clk_count] = {
18 	[sys_clk]	= 100000000,
19 	[alt_core_clk]	= 100000000,
20 	[pa_clk]	= 100000000,
21 	[ddr3a_clk]	= 100000000,
22 };
23 
24 static 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 */
35 int 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,
48 };
49 
50 s16 divn_val[16] = {
51 	0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
52 };
53 
54 static struct pll_init_data pa_pll_config =
55 	PASS_PLL_1000;
56 
57 struct 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 
77 #ifdef CONFIG_DRIVER_TI_KEYSTONE_NET
78 struct 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,
85 	},
86 	{
87 		.int_name        = "K2E_EMAC1",
88 		.rx_flow         = 8,
89 		.phy_addr        = 1,
90 		.slave_port      = 2,
91 		.sgmii_link_type = SGMII_LINK_MAC_PHY,
92 	},
93 	{
94 		.int_name        = "K2E_EMAC2",
95 		.rx_flow         = 16,
96 		.phy_addr        = 2,
97 		.slave_port      = 3,
98 		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
99 	},
100 	{
101 		.int_name        = "K2E_EMAC3",
102 		.rx_flow         = 24,
103 		.phy_addr        = 3,
104 		.slave_port      = 4,
105 		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
106 	},
107 	{
108 		.int_name        = "K2E_EMAC4",
109 		.rx_flow         = 32,
110 		.phy_addr        = 4,
111 		.slave_port      = 5,
112 		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
113 	},
114 	{
115 		.int_name        = "K2E_EMAC5",
116 		.rx_flow         = 40,
117 		.phy_addr        = 5,
118 		.slave_port      = 6,
119 		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
120 	},
121 	{
122 		.int_name        = "K2E_EMAC6",
123 		.rx_flow         = 48,
124 		.phy_addr        = 6,
125 		.slave_port      = 7,
126 		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
127 	},
128 	{
129 		.int_name        = "K2E_EMAC7",
130 		.rx_flow         = 56,
131 		.phy_addr        = 7,
132 		.slave_port      = 8,
133 		.sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED,
134 	},
135 };
136 
137 int get_num_eth_ports(void)
138 {
139 	return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t);
140 }
141 #endif
142 
143 #if defined(CONFIG_BOARD_EARLY_INIT_F)
144 int board_early_init_f(void)
145 {
146 	init_plls();
147 
148 	return 0;
149 }
150 #endif
151 
152 #ifdef CONFIG_SPL_BUILD
153 void spl_init_keystone_plls(void)
154 {
155 	init_plls();
156 }
157 #endif
158