Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 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> |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 13 | #include <asm/ti-common/keystone_net.h> |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
Lokesh Vutla | a9a0e12 | 2017-05-03 16:58:26 +0530 | [diff] [blame] | 17 | unsigned int get_external_clk(u32 clk) |
| 18 | { |
| 19 | unsigned int clk_freq; |
| 20 | |
| 21 | switch (clk) { |
| 22 | case sys_clk: |
| 23 | clk_freq = 100000000; |
| 24 | break; |
| 25 | case alt_core_clk: |
| 26 | clk_freq = 100000000; |
| 27 | break; |
| 28 | case pa_clk: |
| 29 | clk_freq = 100000000; |
| 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 Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 41 | |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 42 | static struct pll_init_data core_pll_config[NUM_SPDS] = { |
| 43 | [SPD800] = CORE_PLL_800, |
| 44 | [SPD850] = CORE_PLL_850, |
| 45 | [SPD1000] = CORE_PLL_1000, |
| 46 | [SPD1250] = CORE_PLL_1250, |
| 47 | [SPD1350] = CORE_PLL_1350, |
| 48 | [SPD1400] = CORE_PLL_1400, |
| 49 | [SPD1500] = CORE_PLL_1500, |
| 50 | }; |
| 51 | |
| 52 | /* DEV and ARM speed definitions as specified in DEVSPEED register */ |
| 53 | int speeds[DEVSPEED_NUMSPDS] = { |
| 54 | SPD850, |
| 55 | SPD1000, |
| 56 | SPD1250, |
| 57 | SPD1350, |
| 58 | SPD1400, |
| 59 | SPD1500, |
| 60 | SPD1400, |
| 61 | SPD1350, |
| 62 | SPD1250, |
| 63 | SPD1000, |
| 64 | SPD850, |
| 65 | SPD800, |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 66 | }; |
| 67 | |
Lokesh Vutla | 70438fc | 2015-07-28 14:16:43 +0530 | [diff] [blame] | 68 | s16 divn_val[16] = { |
| 69 | 0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
| 70 | }; |
| 71 | |
Vitaly Andrianov | 047e780 | 2014-07-25 22:23:19 +0300 | [diff] [blame] | 72 | static struct pll_init_data pa_pll_config = |
| 73 | PASS_PLL_1000; |
| 74 | |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 75 | struct pll_init_data *get_pll_init_data(int pll) |
| 76 | { |
| 77 | int speed; |
| 78 | struct pll_init_data *data; |
| 79 | |
| 80 | switch (pll) { |
| 81 | case MAIN_PLL: |
Lokesh Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 82 | speed = get_max_dev_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 83 | data = &core_pll_config[speed]; |
| 84 | break; |
| 85 | case PASS_PLL: |
| 86 | data = &pa_pll_config; |
| 87 | break; |
| 88 | default: |
| 89 | data = NULL; |
| 90 | } |
| 91 | |
| 92 | return data; |
| 93 | } |
| 94 | |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 95 | #ifdef CONFIG_DRIVER_TI_KEYSTONE_NET |
| 96 | struct eth_priv_t eth_priv_cfg[] = { |
| 97 | { |
| 98 | .int_name = "K2E_EMAC0", |
| 99 | .rx_flow = 0, |
| 100 | .phy_addr = 0, |
| 101 | .slave_port = 1, |
| 102 | .sgmii_link_type = SGMII_LINK_MAC_PHY, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 103 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 104 | }, |
| 105 | { |
| 106 | .int_name = "K2E_EMAC1", |
| 107 | .rx_flow = 8, |
| 108 | .phy_addr = 1, |
| 109 | .slave_port = 2, |
| 110 | .sgmii_link_type = SGMII_LINK_MAC_PHY, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 111 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 112 | }, |
| 113 | { |
| 114 | .int_name = "K2E_EMAC2", |
| 115 | .rx_flow = 16, |
| 116 | .phy_addr = 2, |
| 117 | .slave_port = 3, |
| 118 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 119 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 120 | }, |
| 121 | { |
| 122 | .int_name = "K2E_EMAC3", |
| 123 | .rx_flow = 24, |
| 124 | .phy_addr = 3, |
| 125 | .slave_port = 4, |
| 126 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 127 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 128 | }, |
| 129 | { |
| 130 | .int_name = "K2E_EMAC4", |
| 131 | .rx_flow = 32, |
| 132 | .phy_addr = 4, |
| 133 | .slave_port = 5, |
| 134 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 135 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 136 | }, |
| 137 | { |
| 138 | .int_name = "K2E_EMAC5", |
| 139 | .rx_flow = 40, |
| 140 | .phy_addr = 5, |
| 141 | .slave_port = 6, |
| 142 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 143 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 144 | }, |
| 145 | { |
| 146 | .int_name = "K2E_EMAC6", |
| 147 | .rx_flow = 48, |
| 148 | .phy_addr = 6, |
| 149 | .slave_port = 7, |
| 150 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 151 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 152 | }, |
| 153 | { |
| 154 | .int_name = "K2E_EMAC7", |
| 155 | .rx_flow = 56, |
| 156 | .phy_addr = 7, |
| 157 | .slave_port = 8, |
| 158 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 159 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 6d4ec89 | 2014-10-17 21:01:17 +0300 | [diff] [blame] | 160 | }, |
| 161 | }; |
| 162 | |
| 163 | int get_num_eth_ports(void) |
| 164 | { |
| 165 | return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t); |
| 166 | } |
| 167 | #endif |
| 168 | |
Jean-Jacques Hiblot | 2037fa4 | 2017-09-15 12:57:24 +0200 | [diff] [blame^] | 169 | #if defined(CONFIG_MULTI_DTB_FIT) |
Cooper Jr., Franklin | 43ff224 | 2017-06-16 17:25:16 -0500 | [diff] [blame] | 170 | int board_fit_config_name_match(const char *name) |
| 171 | { |
| 172 | if (!strcmp(name, "keystone-k2e-evm")) |
| 173 | return 0; |
| 174 | |
| 175 | return -1; |
| 176 | } |
| 177 | #endif |
| 178 | |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 179 | #if defined(CONFIG_BOARD_EARLY_INIT_F) |
| 180 | int board_early_init_f(void) |
| 181 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 182 | init_plls(); |
Vitaly Andrianov | 047e780 | 2014-07-25 22:23:19 +0300 | [diff] [blame] | 183 | |
Hao Zhang | 82be013 | 2014-07-16 00:59:27 +0300 | [diff] [blame] | 184 | return 0; |
| 185 | } |
| 186 | #endif |
Hao Zhang | 9594820 | 2014-10-22 16:32:31 +0300 | [diff] [blame] | 187 | |
| 188 | #ifdef CONFIG_SPL_BUILD |
Hao Zhang | 9594820 | 2014-10-22 16:32:31 +0300 | [diff] [blame] | 189 | void spl_init_keystone_plls(void) |
| 190 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 191 | init_plls(); |
Hao Zhang | 9594820 | 2014-10-22 16:32:31 +0300 | [diff] [blame] | 192 | } |
| 193 | #endif |