/* Copyright (c) 2015 Broadcom Corporation All Rights Reserved <:label-BRCM:2015:DUAL/GPL:standard Unless you and Broadcom execute a separate written software license agreement governing use of this software, this software is licensed to you under the terms of the GNU General Public License version 2 (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, with the following added to such license: As a special exception, the copyright holders of this software give you permission to link this software with independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from this software. The special exception does not apply to any modifications of the software. Not withstanding the above, under no circumstances may you combine this software in any way with any other Broadcom software provided under a license other than the GPL, without Broadcom's express prior written consent. :> */ #include "merlin16_shortfin_pwr_mgt.h" #include "merlin16_shortfin_common.h" #include "merlin16_shortfin_functions.h" #include "merlin16_shortfin_internal.h" #include "merlin16_shortfin_internal_error.h" #include "merlin16_shortfin_select_defns.h" #include "merlin16_shortfin_config.h" /***************************/ /* Configure Serdes IDDQ */ /***************************/ err_code_t merlin16_shortfin_core_config_for_iddq(srds_access_t *sa__) { UNUSED(sa__); EFUN(wrc_ams_pll_pwrdn(0x1)); return (ERR_CODE_NONE); } err_code_t merlin16_shortfin_lane_config_for_iddq(srds_access_t *sa__) { /* Use frc/frc_val to force all RX and TX clk_vld signals to 0 */ EFUN(wr_pmd_rx_clk_vld_frc_val(0x0)); EFUN(wr_pmd_rx_clk_vld_frc(0x1)); EFUN(wr_pmd_tx_clk_vld_frc_val(0x0)); EFUN(wr_pmd_tx_clk_vld_frc(0x1)); /* Use frc/frc_val to force all pmd_rx_lock signals to 0 */ EFUN(wr_rx_dsc_lock_frc_val(0x0)); EFUN(wr_rx_dsc_lock_frc(0x1)); /* Switch all the lane clocks to comclk by writing to RX/TX comclk_sel registers */ EFUN(wr_ln_rx_s_comclk_sel(0x1)); EFUN(wr_ln_tx_s_comclk_sel(0x1)); /* Assert all the AFE pwrdn/reset pins using frc/frc_val to make sure AFE is in lowest possible power mode */ EFUN(wr_afe_tx_pwrdn_frc_val(0x1)); EFUN(wr_afe_tx_pwrdn_frc(0x1)); EFUN(wr_afe_rx_pwrdn_frc_val(0x1)); EFUN(wr_afe_rx_pwrdn_frc(0x1)); EFUN(wr_afe_tx_reset_frc_val(0x1)); EFUN(wr_afe_tx_reset_frc(0x1)); EFUN(wr_afe_rx_reset_frc_val(0x1)); EFUN(wr_afe_rx_reset_frc(0x1)); /* Set pmd_iddq pin to enable IDDQ */ return (ERR_CODE_NONE); } /****************************************************/ /* Serdes Powerdown, ClockGate and Deep_Powerdown */ /****************************************************/ err_code_t merlin16_shortfin_core_pwrdn(srds_access_t *sa__, enum srds_core_pwrdn_mode_enum mode) { switch(mode) { case PWR_ON: EFUN(merlin16_shortfin_INTERNAL_core_clkgate(sa__, 0)); EFUN(wrc_ams_pll_pwrdn(0x0)); EFUN(wrc_afe_s_pll_pwrdn(0x0)); EFUN(merlin16_shortfin_core_dp_reset(sa__, 0x0)); break; case PWRDN: EFUN(merlin16_shortfin_core_dp_reset(sa__, 1)); EFUN(USR_DELAY_NS(500)); /* wait >50 comclk cycles */ EFUN(wrc_afe_s_pll_pwrdn(0x1)); EFUN(USR_DELAY_NS(500)); /* wait >50 comclk cycles */ EFUN(wrc_ams_pll_pwrdn(0x1)); break; case PWRDN_DEEP: EFUN(merlin16_shortfin_core_dp_reset(sa__, 1)); EFUN(USR_DELAY_NS(500)); /* wait >50 comclk cycles */ EFUN(wrc_afe_s_pll_pwrdn(0x1)); EFUN(USR_DELAY_NS(500)); /* wait >50 comclk cycles */ EFUN(wrc_ams_pll_pwrdn(0x1)); EFUN(merlin16_shortfin_INTERNAL_core_clkgate(sa__, 1)); break; default: EFUN(merlin16_shortfin_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); break; } return ERR_CODE_NONE; } err_code_t merlin16_shortfin_lane_pwrdn(srds_access_t *sa__, enum srds_core_pwrdn_mode_enum mode) { switch(mode) { case PWR_ON: EFUN(wr_ln_tx_s_pwrdn(0x0)); EFUN(wr_ln_rx_s_pwrdn(0x0)); EFUN(merlin16_shortfin_INTERNAL_lane_clkgate(sa__, 0)); break; case PWRDN: /* do the RX first, since that is what is most users care about */ EFUN(wr_ln_rx_s_pwrdn(0x1)); EFUN(wr_ln_tx_s_pwrdn(0x1)); break; case PWRDN_DEEP: /* do the RX first, since that is what is most users care about */ EFUN(wr_ln_rx_s_pwrdn(0x1)); EFUN(wr_ln_tx_s_pwrdn(0x1)); EFUN(merlin16_shortfin_INTERNAL_lane_clkgate(sa__, 1)); EFUN(wr_ln_dp_s_rstb(0x0)); break; case PWRDN_TX: EFUN(wr_ln_tx_s_pwrdn(0x1)); break; case PWRDN_RX: EFUN(wr_ln_rx_s_pwrdn(0x1)); break; default : return(merlin16_shortfin_error(sa__, ERR_CODE_BAD_PTR_OR_INVALID_INPUT)); } return (ERR_CODE_NONE); }