Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 2 | /* |
| 3 | * K2L EVM : Board initialization |
| 4 | * |
| 5 | * (C) Copyright 2014 |
| 6 | * Texas Instruments Incorporated, <www.ti.com> |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <asm/arch/ddr3.h> |
| 11 | #include <asm/arch/hardware.h> |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 12 | #include <asm/ti-common/keystone_net.h> |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 13 | |
Lokesh Vutla | a9a0e12 | 2017-05-03 16:58:26 +0530 | [diff] [blame] | 14 | unsigned int get_external_clk(u32 clk) |
| 15 | { |
| 16 | unsigned int clk_freq; |
| 17 | |
| 18 | switch (clk) { |
| 19 | case sys_clk: |
| 20 | clk_freq = 122880000; |
| 21 | break; |
| 22 | case alt_core_clk: |
| 23 | clk_freq = 100000000; |
| 24 | break; |
| 25 | case pa_clk: |
| 26 | clk_freq = 122880000; |
| 27 | break; |
| 28 | case tetris_clk: |
| 29 | clk_freq = 122880000; |
| 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 | c13cbcf | 2014-10-22 16:32:33 +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_799, |
| 44 | [SPD1000] = CORE_PLL_1000, |
Lokesh Vutla | b4a96bd | 2015-08-17 19:58:34 +0530 | [diff] [blame] | 45 | [SPD1200] = CORE_PLL_1198, |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 46 | }; |
| 47 | |
Lokesh Vutla | 70438fc | 2015-07-28 14:16:43 +0530 | [diff] [blame] | 48 | s16 divn_val[16] = { |
| 49 | 0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
| 50 | }; |
| 51 | |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 52 | static struct pll_init_data tetris_pll_config[] = { |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 53 | [SPD800] = TETRIS_PLL_799, |
| 54 | [SPD1000] = TETRIS_PLL_1000, |
| 55 | [SPD1200] = TETRIS_PLL_1198, |
| 56 | [SPD1350] = TETRIS_PLL_1352, |
| 57 | [SPD1400] = TETRIS_PLL_1401, |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | static struct pll_init_data pa_pll_config = |
| 61 | PASS_PLL_983; |
| 62 | |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 63 | struct pll_init_data *get_pll_init_data(int pll) |
| 64 | { |
| 65 | int speed; |
| 66 | struct pll_init_data *data; |
| 67 | |
| 68 | switch (pll) { |
| 69 | case MAIN_PLL: |
Lokesh Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 70 | speed = get_max_dev_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 71 | data = &core_pll_config[speed]; |
| 72 | break; |
| 73 | case TETRIS_PLL: |
Lokesh Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 74 | speed = get_max_arm_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 75 | data = &tetris_pll_config[speed]; |
| 76 | break; |
| 77 | case PASS_PLL: |
| 78 | data = &pa_pll_config; |
| 79 | break; |
| 80 | default: |
| 81 | data = NULL; |
| 82 | } |
| 83 | |
| 84 | return data; |
| 85 | } |
| 86 | |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 87 | #ifdef CONFIG_DRIVER_TI_KEYSTONE_NET |
| 88 | struct eth_priv_t eth_priv_cfg[] = { |
| 89 | { |
| 90 | .int_name = "K2L_EMAC", |
| 91 | .rx_flow = 0, |
| 92 | .phy_addr = 0, |
| 93 | .slave_port = 1, |
| 94 | .sgmii_link_type = SGMII_LINK_MAC_PHY, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 95 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 96 | }, |
| 97 | { |
| 98 | .int_name = "K2L_EMAC1", |
| 99 | .rx_flow = 8, |
| 100 | .phy_addr = 1, |
| 101 | .slave_port = 2, |
| 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 | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 104 | }, |
| 105 | { |
| 106 | .int_name = "K2L_EMAC2", |
| 107 | .rx_flow = 16, |
| 108 | .phy_addr = 2, |
| 109 | .slave_port = 3, |
| 110 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 111 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 112 | }, |
| 113 | { |
| 114 | .int_name = "K2L_EMAC3", |
| 115 | .rx_flow = 32, |
| 116 | .phy_addr = 3, |
| 117 | .slave_port = 4, |
| 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 | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 120 | }, |
| 121 | }; |
| 122 | |
| 123 | int get_num_eth_ports(void) |
| 124 | { |
| 125 | return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t); |
| 126 | } |
| 127 | #endif |
| 128 | |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 129 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 130 | int board_early_init_f(void) |
| 131 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 132 | init_plls(); |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 133 | |
| 134 | return 0; |
| 135 | } |
| 136 | #endif |
| 137 | |
Jean-Jacques Hiblot | 2037fa4 | 2017-09-15 12:57:24 +0200 | [diff] [blame] | 138 | #if defined(CONFIG_MULTI_DTB_FIT) |
Cooper Jr., Franklin | 43ff224 | 2017-06-16 17:25:16 -0500 | [diff] [blame] | 139 | int board_fit_config_name_match(const char *name) |
| 140 | { |
| 141 | if (!strcmp(name, "keystone-k2l-evm")) |
| 142 | return 0; |
| 143 | |
| 144 | return -1; |
| 145 | } |
| 146 | #endif |
| 147 | |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 148 | #ifdef CONFIG_SPL_BUILD |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 149 | void spl_init_keystone_plls(void) |
| 150 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 151 | init_plls(); |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 152 | } |
| 153 | #endif |