falcon_dpll.c (4680B)
1 /* 2 * 3 * 4 * 5 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 6 * 7 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 8 */ 9 10 #include <phymod/phymod.h> 11 #include <phymod/phymod_system.h> 12 #include <phymod/phymod_dispatch.h> 13 #include "falcon_dpll/tier1/falcon2_monterey_interface.h" 14 #include "falcon_dpll/tier1/falcon_dpll_cfg_seq.h" 15 16 #ifdef PHYMOD_FALCON_DPLL_SUPPORT 17 18 19 int falcon_dpll_phy_tx_set(const phymod_phy_access_t* phy, const phymod_tx_t* tx) 20 { 21 PHYMOD_IF_ERR_RETURN 22 (falcon2_monterey_write_tx_afe(&phy->access, TX_AFE_PRE, (int8_t)tx->pre)); 23 PHYMOD_IF_ERR_RETURN 24 (falcon2_monterey_write_tx_afe(&phy->access, TX_AFE_MAIN, (int8_t)tx->main)); 25 PHYMOD_IF_ERR_RETURN 26 (falcon2_monterey_write_tx_afe(&phy->access, TX_AFE_POST1, (int8_t)tx->post)); 27 PHYMOD_IF_ERR_RETURN 28 (falcon2_monterey_write_tx_afe(&phy->access, TX_AFE_POST2, (int8_t)tx->post2)); 29 PHYMOD_IF_ERR_RETURN 30 (falcon2_monterey_write_tx_afe(&phy->access, TX_AFE_POST3, (int8_t)tx->post3)); 31 PHYMOD_IF_ERR_RETURN 32 (falcon2_monterey_write_tx_afe(&phy->access, TX_AFE_AMP, (int8_t)tx->amp)); 33 if((tx->drivermode != -1) && 34 (phy->device_op_mode & PHYMOD_INTF_CONFIG_TX_FIR_DRIVERMODE_ENABLE)) { 35 PHYMOD_IF_ERR_RETURN 36 (falcon2_monterey_write_tx_afe(&phy->access, TX_AFE_DRIVERMODE, (int8_t)tx->drivermode)); 37 } 38 39 return PHYMOD_E_NONE; 40 } 41 42 int falcon_dpll_phy_tx_get(const phymod_phy_access_t* phy, phymod_tx_t* tx) 43 { 44 int8_t value = 0; 45 46 PHYMOD_IF_ERR_RETURN 47 (falcon2_monterey_read_tx_afe(&phy->access, TX_AFE_PRE, &value)); 48 tx->pre = value; 49 PHYMOD_IF_ERR_RETURN 50 (falcon2_monterey_read_tx_afe(&phy->access, TX_AFE_MAIN, &value)); 51 tx->main = value; 52 PHYMOD_IF_ERR_RETURN 53 (falcon2_monterey_read_tx_afe(&phy->access, TX_AFE_POST1, &value)); 54 tx->post = value; 55 PHYMOD_IF_ERR_RETURN 56 (falcon2_monterey_read_tx_afe(&phy->access, TX_AFE_POST2, &value)); 57 tx->post2 = value; 58 PHYMOD_IF_ERR_RETURN 59 (falcon2_monterey_read_tx_afe(&phy->access, TX_AFE_POST3, &value)); 60 tx->post3 = value; 61 PHYMOD_IF_ERR_RETURN 62 (falcon2_monterey_read_tx_afe(&phy->access, TX_AFE_AMP, &value)); 63 tx->amp = value; 64 PHYMOD_IF_ERR_RETURN 65 (falcon2_monterey_read_tx_afe(&phy->access, TX_AFE_DRIVERMODE, &value)); 66 tx->drivermode = value; 67 68 return PHYMOD_E_NONE; 69 } 70 71 72 /* NEED TO REVISIT: need to update these settings */ 73 int falcon_dpll_phy_media_type_tx_get(const phymod_phy_access_t* phy, phymod_media_typed_t media, phymod_tx_t* tx) 74 { 75 switch (media) { 76 case phymodMediaTypeChipToChip: 77 tx->pre = 0xc; 78 tx->main = 0x66; 79 tx->post = 0x0; 80 tx->post2 = 0x0; 81 tx->post3 = 0x0; 82 tx->amp = 0xc; 83 break; 84 case phymodMediaTypeShort: 85 tx->pre = 0xc; 86 tx->main = 0x66; 87 tx->post = 0x0; 88 tx->post2 = 0x0; 89 tx->post3 = 0x0; 90 tx->amp = 0xc; 91 break; 92 case phymodMediaTypeMid: 93 tx->pre = 0xc; 94 tx->main = 0x66; 95 tx->post = 0x0; 96 tx->post2 = 0x0; 97 tx->post3 = 0x0; 98 tx->amp = 0xc; 99 break; 100 case phymodMediaTypeLong: 101 tx->pre = 0xc; 102 tx->main = 0x66; 103 tx->post = 0x0; 104 tx->post2 = 0x0; 105 tx->post3 = 0x0; 106 tx->amp = 0xc; 107 break; 108 default: 109 tx->pre = 0xc; 110 tx->main = 0x66; 111 tx->post = 0x0; 112 tx->post2 = 0x0; 113 tx->post3 = 0x0; 114 tx->amp = 0xc; 115 break; 116 } 117 118 return PHYMOD_E_NONE; 119 } 120 121 int falcon_dpll_phy_txpi_config_set(const phymod_phy_access_t* phy, const phymod_txpi_config_t* config) 122 { 123 phymod_phy_access_t phy_copy; 124 125 PHYMOD_MEMCPY(&phy_copy, phy, sizeof(phy_copy)); 126 127 PHYMOD_IF_ERR_RETURN 128 (falcon2_monterey_tx_pi_enable_set(&phy_copy.access, config->enable)); 129 130 PHYMOD_IF_ERR_RETURN 131 (falcon2_monterey_tx_pi_ext_pd_select_set(&phy_copy.access, config->mode == PHYMOD_TXPI_EXT_PD_MODE ? 1 : 0)); 132 133 return PHYMOD_E_NONE; 134 } 135 136 int falcon_dpll_phy_txpi_config_get(const phymod_phy_access_t* phy, phymod_txpi_config_t* config) 137 { 138 phymod_phy_access_t phy_copy; 139 uint32_t ext_pd; 140 141 PHYMOD_MEMCPY(&phy_copy, phy, sizeof(phy_copy)); 142 143 PHYMOD_IF_ERR_RETURN 144 (falcon2_monterey_tx_pi_enable_get(&phy_copy.access, &config->enable)); 145 146 PHYMOD_IF_ERR_RETURN 147 (falcon2_monterey_tx_pi_ext_pd_select_get(&phy_copy.access, &ext_pd)); 148 149 config->mode = ext_pd ? PHYMOD_TXPI_EXT_PD_MODE : PHYMOD_TXPI_NORMAL_MODE; 150 151 return PHYMOD_E_NONE; 152 } 153 154 #endif /* PHYMOD_FALCON_DPLL_SUPPORT */