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 | |
| 17 | unsigned int external_clk[ext_clk_count] = { |
| 18 | [sys_clk] = 122880000, |
| 19 | [alt_core_clk] = 100000000, |
| 20 | [pa_clk] = 122880000, |
| 21 | [tetris_clk] = 122880000, |
Lokesh Vutla | c40f81d | 2015-07-28 14:16:47 +0530 | [diff] [blame] | 22 | [ddr3a_clk] = 100000000, |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 23 | }; |
| 24 | |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 25 | static struct pll_init_data core_pll_config[NUM_SPDS] = { |
| 26 | [SPD800] = CORE_PLL_799, |
| 27 | [SPD1000] = CORE_PLL_1000, |
Lokesh Vutla | b4a96bd | 2015-08-17 19:58:34 +0530 | [diff] [blame] | 28 | [SPD1200] = CORE_PLL_1198, |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 29 | }; |
| 30 | |
Lokesh Vutla | 70438fc | 2015-07-28 14:16:43 +0530 | [diff] [blame] | 31 | s16 divn_val[16] = { |
| 32 | 0, 0, 1, 4, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 |
| 33 | }; |
| 34 | |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 35 | static struct pll_init_data tetris_pll_config[] = { |
Lokesh Vutla | 9da9afa | 2015-07-28 14:16:44 +0530 | [diff] [blame] | 36 | [SPD800] = TETRIS_PLL_799, |
| 37 | [SPD1000] = TETRIS_PLL_1000, |
| 38 | [SPD1200] = TETRIS_PLL_1198, |
| 39 | [SPD1350] = TETRIS_PLL_1352, |
| 40 | [SPD1400] = TETRIS_PLL_1401, |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | static struct pll_init_data pa_pll_config = |
| 44 | PASS_PLL_983; |
| 45 | |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 46 | struct pll_init_data *get_pll_init_data(int pll) |
| 47 | { |
| 48 | int speed; |
| 49 | struct pll_init_data *data; |
| 50 | |
| 51 | switch (pll) { |
| 52 | case MAIN_PLL: |
Lokesh Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 53 | speed = get_max_dev_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 54 | data = &core_pll_config[speed]; |
| 55 | break; |
| 56 | case TETRIS_PLL: |
Lokesh Vutla | b35410e | 2016-03-04 10:36:40 -0600 | [diff] [blame] | 57 | speed = get_max_arm_speed(speeds); |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 58 | data = &tetris_pll_config[speed]; |
| 59 | break; |
| 60 | case PASS_PLL: |
| 61 | data = &pa_pll_config; |
| 62 | break; |
| 63 | default: |
| 64 | data = NULL; |
| 65 | } |
| 66 | |
| 67 | return data; |
| 68 | } |
| 69 | |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 70 | #ifdef CONFIG_DRIVER_TI_KEYSTONE_NET |
| 71 | struct eth_priv_t eth_priv_cfg[] = { |
| 72 | { |
| 73 | .int_name = "K2L_EMAC", |
| 74 | .rx_flow = 0, |
| 75 | .phy_addr = 0, |
| 76 | .slave_port = 1, |
| 77 | .sgmii_link_type = SGMII_LINK_MAC_PHY, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 78 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 79 | }, |
| 80 | { |
| 81 | .int_name = "K2L_EMAC1", |
| 82 | .rx_flow = 8, |
| 83 | .phy_addr = 1, |
| 84 | .slave_port = 2, |
| 85 | .sgmii_link_type = SGMII_LINK_MAC_PHY, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 86 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 87 | }, |
| 88 | { |
| 89 | .int_name = "K2L_EMAC2", |
| 90 | .rx_flow = 16, |
| 91 | .phy_addr = 2, |
| 92 | .slave_port = 3, |
| 93 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 94 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 95 | }, |
| 96 | { |
| 97 | .int_name = "K2L_EMAC3", |
| 98 | .rx_flow = 32, |
| 99 | .phy_addr = 3, |
| 100 | .slave_port = 4, |
| 101 | .sgmii_link_type = SGMII_LINK_MAC_MAC_FORCED, |
Mugunthan V N | d44bb34 | 2015-09-19 16:26:48 +0530 | [diff] [blame] | 102 | .phy_if = PHY_INTERFACE_MODE_SGMII, |
Hao Zhang | 7874b8a | 2014-10-29 13:09:34 +0200 | [diff] [blame] | 103 | }, |
| 104 | }; |
| 105 | |
| 106 | int get_num_eth_ports(void) |
| 107 | { |
| 108 | return sizeof(eth_priv_cfg) / sizeof(struct eth_priv_t); |
| 109 | } |
| 110 | #endif |
| 111 | |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 112 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 113 | int board_early_init_f(void) |
| 114 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 115 | init_plls(); |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 116 | |
| 117 | return 0; |
| 118 | } |
| 119 | #endif |
| 120 | |
| 121 | #ifdef CONFIG_SPL_BUILD |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 122 | void spl_init_keystone_plls(void) |
| 123 | { |
Lokesh Vutla | 79a94a2 | 2015-07-28 14:16:46 +0530 | [diff] [blame] | 124 | init_plls(); |
Hao Zhang | c13cbcf | 2014-10-22 16:32:33 +0300 | [diff] [blame] | 125 | } |
| 126 | #endif |