Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 1 | /* |
| 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 Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 13 | #include <asm/ti-common/keystone_net.h> |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +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 = 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 Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 44 | |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 45 | static struct pll_init_data core_pll_config[NUM_SPDS] = { |
| 46 | [SPD800] = CORE_PLL_799, |
| 47 | [SPD1000] = CORE_PLL_1000, |
Lokesh Vutla | b4a96bd | 2015-08-17 19:58:34 +0530 | [diff] [blame] | 48 | [SPD1200] = CORE_PLL_1198, |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 49 | }; |
| 50 | |
Lokesh Vutla | 70438fc | 2015-07-28 14:16:43 +0530 | [diff] [blame] | 51 | s16 divn_val[16] = { |
| 52 | 0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
| 53 | }; |
| 54 | |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 55 | static struct pll_init_data tetris_pll_config[] = { |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 56 | [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 Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | static struct pll_init_data pa_pll_config = |
| 64 | PASS_PLL_983; |
| 65 | |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 66 | struct 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 Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 73 | speed = get_max_dev_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 74 | data = &core_pll_config[speed]; |
| 75 | break; |
| 76 | case TETRIS_PLL: |
Lokesh Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 77 | speed = get_max_arm_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 78 | 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 Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 90 | #ifdef CONFIG_DRIVER_TI_KEYSTONE_NET |
| 91 | struct 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 N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 98 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 99 | }, |
| 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 N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 106 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 107 | }, |
| 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 N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 114 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 115 | }, |
| 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 N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 122 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 123 | }, |
| 124 | }; |
| 125 | |
| 126 | int get_num_eth_ports(void) |
| 127 | { |
| 128 | return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t); |
| 129 | } |
| 130 | #endif |
| 131 | |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 132 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 133 | int board_early_init_f(void) |
| 134 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 135 | init_plls(); |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 136 | |
| 137 | return 0; |
| 138 | } |
| 139 | #endif |
| 140 | |
Jean-Jacques Hiblot | 2037fa4 | 2017-09-15 12:57:24 +0200 | [diff] [blame] | 141 | #if defined(CONFIG_MULTI_DTB_FIT) |
Cooper Jr., Franklin | 43ff224 | 2017-06-16 17:25:16 -0500 | [diff] [blame] | 142 | int 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 Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 151 | #ifdef CONFIG_SPL_BUILD |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 152 | void spl_init_keystone_plls(void) |
| 153 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 154 | init_plls(); |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 155 | } |
| 156 | #endif |