Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 2 | /* |
| 3 | * K2HK EVM : Board initialization |
| 4 | * |
| 5 | * (C) Copyright 2012-2014 |
| 6 | * Texas Instruments Incorporated, <www.ti.com> |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Vitaly Andrianov | 047e780 | 2014-07-25 22:23:19 +0300 | [diff] [blame] | 10 | #include <asm/arch/clock.h> |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 11 | #include <asm/arch/hardware.h> |
Khoronzhuk, Ivan | f2c13ba | 2014-09-29 22:17:22 +0300 | [diff] [blame] | 12 | #include <asm/ti-common/keystone_net.h> |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 13 | |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 14 | unsigned int external_clk[ext_clk_count] = { |
| 15 | [sys_clk] = 122880000, |
| 16 | [alt_core_clk] = 125000000, |
| 17 | [pa_clk] = 122880000, |
| 18 | [tetris_clk] = 125000000, |
| 19 | [ddr3a_clk] = 100000000, |
| 20 | [ddr3b_clk] = 100000000, |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 21 | }; |
| 22 | |
Lokesh Vutla | a9a0e12 | 2017-05-03 16:58:26 +0530 | [diff] [blame] | 23 | unsigned int get_external_clk(u32 clk) |
| 24 | { |
| 25 | unsigned int clk_freq; |
| 26 | |
| 27 | switch (clk) { |
| 28 | case sys_clk: |
| 29 | clk_freq = 122880000; |
| 30 | break; |
| 31 | case alt_core_clk: |
| 32 | clk_freq = 125000000; |
| 33 | break; |
| 34 | case pa_clk: |
| 35 | clk_freq = 122880000; |
| 36 | break; |
| 37 | case tetris_clk: |
| 38 | clk_freq = 125000000; |
| 39 | break; |
| 40 | case ddr3a_clk: |
| 41 | clk_freq = 100000000; |
| 42 | break; |
| 43 | case ddr3b_clk: |
| 44 | clk_freq = 100000000; |
| 45 | break; |
| 46 | default: |
| 47 | clk_freq = 0; |
| 48 | break; |
| 49 | } |
| 50 | |
| 51 | return clk_freq; |
| 52 | } |
| 53 | |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 54 | static struct pll_init_data core_pll_config[NUM_SPDS] = { |
| 55 | [SPD800] = CORE_PLL_799, |
| 56 | [SPD1000] = CORE_PLL_999, |
| 57 | [SPD1200] = CORE_PLL_1200, |
Vitaly Andrianov | 047e780 | 2014-07-25 22:23:19 +0300 | [diff] [blame] | 58 | }; |
| 59 | |
Lokesh Vutla | 70438fc | 2015-07-28 14:16:43 +0530 | [diff] [blame] | 60 | s16 divn_val[16] = { |
| 61 | 0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
| 62 | }; |
| 63 | |
Vitaly Andrianov | 047e780 | 2014-07-25 22:23:19 +0300 | [diff] [blame] | 64 | static struct pll_init_data tetris_pll_config[] = { |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 65 | [SPD800] = TETRIS_PLL_800, |
| 66 | [SPD1000] = TETRIS_PLL_1000, |
| 67 | [SPD1200] = TETRIS_PLL_1200, |
| 68 | [SPD1350] = TETRIS_PLL_1350, |
| 69 | [SPD1400] = TETRIS_PLL_1400, |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 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_983; |
| 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 TETRIS_PLL: |
Lokesh Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 86 | speed = get_max_arm_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 87 | data = &tetris_pll_config[speed]; |
| 88 | break; |
| 89 | case PASS_PLL: |
| 90 | data = &pa_pll_config; |
| 91 | break; |
| 92 | default: |
| 93 | data = NULL; |
| 94 | } |
| 95 | |
| 96 | return data; |
| 97 | } |
| 98 | |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 99 | #ifdef CONFIG_DRIVER_TI_KEYSTONE_NET |
| 100 | struct eth_priv_t eth_priv_cfg[] = { |
| 101 | { |
| 102 | .int_name = "K2HK_EMAC", |
| 103 | .rx_flow = 22, |
| 104 | .phy_addr = 0, |
| 105 | .slave_port = 1, |
| 106 | .sgmii_link_type = SGMII_LINK_MAC_PHY, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 107 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 108 | }, |
| 109 | { |
| 110 | .int_name = "K2HK_EMAC1", |
| 111 | .rx_flow = 23, |
| 112 | .phy_addr = 1, |
| 113 | .slave_port = 2, |
| 114 | .sgmii_link_type = SGMII_LINK_MAC_PHY, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 115 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 116 | }, |
| 117 | { |
| 118 | .int_name = "K2HK_EMAC2", |
| 119 | .rx_flow = 24, |
| 120 | .phy_addr = 2, |
| 121 | .slave_port = 3, |
| 122 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 123 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 124 | }, |
| 125 | { |
| 126 | .int_name = "K2HK_EMAC3", |
| 127 | .rx_flow = 25, |
| 128 | .phy_addr = 3, |
| 129 | .slave_port = 4, |
| 130 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 131 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 132 | }, |
| 133 | }; |
| 134 | |
| 135 | int get_num_eth_ports(void) |
| 136 | { |
| 137 | return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t); |
| 138 | } |
| 139 | #endif |
| 140 | |
| 141 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 142 | int board_early_init_f(void) |
| 143 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 144 | init_plls(); |
Vitaly Andrianov | 047e780 | 2014-07-25 22:23:19 +0300 | [diff] [blame] | 145 | |
Hao Zhang | 8e697a0 | 2014-07-09 23:44:46 +0300 | [diff] [blame] | 146 | return 0; |
| 147 | } |
| 148 | #endif |
Hao Zhang | 9594820 | 2014-10-22 16:32:31 +0300 | [diff] [blame] | 149 | |
Jean-Jacques Hiblot | 2037fa4 | 2017-09-15 12:57:24 +0200 | [diff] [blame] | 150 | #if defined(CONFIG_MULTI_DTB_FIT) |
Cooper Jr., Franklin | 43ff224 | 2017-06-16 17:25:16 -0500 | [diff] [blame] | 151 | int board_fit_config_name_match(const char *name) |
| 152 | { |
| 153 | if (!strcmp(name, "keystone-k2hk-evm")) |
| 154 | return 0; |
| 155 | |
| 156 | return -1; |
| 157 | } |
| 158 | #endif |
| 159 | |
Hao Zhang | 9594820 | 2014-10-22 16:32:31 +0300 | [diff] [blame] | 160 | #ifdef CONFIG_SPL_BUILD |
Hao Zhang | 9594820 | 2014-10-22 16:32:31 +0300 | [diff] [blame] | 161 | void spl_init_keystone_plls(void) |
| 162 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 163 | init_plls(); |
Hao Zhang | 9594820 | 2014-10-22 16:32:31 +0300 | [diff] [blame] | 164 | } |
| 165 | #endif |