/* <:copyright-BRCM:2013:DUAL/GPL:standard Copyright (c) 2013 Broadcom All Rights Reserved This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation (the "GPL"). This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A copy of the GPL is available at http://www.broadcom.com/licenses/GPLv2.php, or by writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. :> */ /* *************************************************************************** * File Name :bcm_misc_hw_init_impl3.c * * Description: This file contains the flash device driver APIs for bcm63xx board. * * Created on : 7/23/2014 yonatani * ***************************************************************************/ #include "pmc_drv.h" #include "clk_rst.h" #include "boardparms.h" #include "rdp_drv_bbh.h" #include "rdpa_types.h" #include "bcm_map_part.h" #include "access_macros.h" #include "bl_os_wraper.h" #ifndef _CFE_ #include "board.h" #endif #include "bcm_misc_hw_init.h" #define SHIFTL(_a) ( 1 << _a) #define PBCM_RESET 0 #define PBCM_UNRESET 1 #define BPCM_SRESET_CNTL_REG 8 //0x20 in words offset /*BPCM-RDP*/ #define RDP_S_RST_UBUS_DBR 0// (dma ubus bridge) #define RDP_S_RST_UBUS_RABR 1//(rnrA ubus bridge) #define RDP_S_RST_UBUS_RBBR 2// (rnrB ubus bridge) #define RDP_S_RST_UBUS_VPBR 3//(vpb ubus bridge) #define RDP_S_RST_RNR_0 4// #define RDP_S_RST_RNR_1 5// #define RDP_S_RST_IPSEC_RNR 6// #define RDP_S_RST_IPSEC_RNG 7// #define RDP_S_RST_IPSEC_MAIN 8 #define RDP_S_RST_RNR_SUB 9 #define RDP_S_RST_IH_RNR 10 #define RDP_S_RST_BB_RNR 11 #define RDP_S_RST_GEN_MAIN 12// (main tm) #define RDP_S_RST_VDSL 13 #define RDP_S_RST_E0_MAIN 14// (mac0) #define RDP_S_RST_E0_RST_L 15// (mac0) #define RDP_S_RST_E1_MAIN 16// (mac1) #define RDP_S_RST_E1_RST_L 17// (mac1) #define RDP_S_RST_E2_MAIN 18// (mac2) #define RDP_S_RST_E2_RST_L 19// (mac2) #define RDP_S_RST_E3_MAIN 20// (mac3) #define RDP_S_RST_E3_RST_L 21// (mac3) #define RDP_S_RST_E4_MAIN 22// (mac4) #define RDP_S_RST_E4_RST_L 23// (mac4) #define EGPHY_RGMII_OUT_PORT_MODE_MII 2 #define EGPHY_RGMII_OUT_PORT_MODE_RGMII 3 #define EGPHY_RGMII_OUT_PORT_MODE_RVMII 4 #define EGPHY_RGMII_OUT_REF_25_MHZ 0 #define EGPHY_RGMII_OUT_REF_50_MHZ 1 #define EGPHY_RGMII_OUT_REF_OFFSET 3 #define EGPHY_RGMII_OUT_PORT_ID_OFFSET 4 static const ETHERNET_MAC_INFO* pBoardInfo; int rdp_pre_init(void); int rdp_post_init(void); int rdp_post_init_fiber(void); int rdp_shut_down(void); int bcm_misc_g9991_debug_port_get(void); #if !defined(_CFE_) int init_serdes_proc(void); void cleanup_serdes_proc(void); #endif /*pmcSetModuleResetState used to set the reset state of * each rdp block module, the state is (1) - in reset state, un-oprational. * (0) - out of reset state - operational. */ static void pmcSetModuleResetState(uint32_t rdpModule,uint32_t state) { uint32_t bpcmResReg; uint32_t error; error = ReadBPCMRegister(PMB_ADDR_RDP, BPCM_SRESET_CNTL_REG, (uint32*)&bpcmResReg); if( error ) { printk("Failed to ReadBPCMRegister RDP block BPCM_SRESET_CNTL_REG error = %d\n",error); } if ( state ) { bpcmResReg |= SHIFTL(rdpModule); } else { bpcmResReg &= ~SHIFTL(rdpModule); } error = WriteBPCMRegister(PMB_ADDR_RDP, BPCM_SRESET_CNTL_REG, bpcmResReg); if( error ) { printk("Failed to WriteBPCMRegister RDP block BPCM_SRESET_CNTL_REG error = %d\n",error); } } static void pmcPutAllRdpModulesInReset(void) { uint32_t bpcmResReg = 0; uint32_t error; error = WriteBPCMRegister(PMB_ADDR_RDP, BPCM_SRESET_CNTL_REG, bpcmResReg); if( error ) { printk("Failed to WriteBPCMRegister RDP block BPCM_SRESET_CNTL_REG\n"); } } static void f_enable_ubus_masters(void) { uint32_t reg; /*first Ubus Master*/ READ_32(UBUS_MASTER_1_RDP_UBUS_MASTER_BRDG_REG_EN,reg); reg |= 1; // bit 0 is the enable bit WRITE_32(UBUS_MASTER_1_RDP_UBUS_MASTER_BRDG_REG_EN,reg); /*second Ubus Master*/ READ_32(UBUS_MASTER_2_RDP_UBUS_MASTER_BRDG_REG_EN,reg); reg |= 1; // bit 0 is the enable bit WRITE_32(UBUS_MASTER_2_RDP_UBUS_MASTER_BRDG_REG_EN,reg); /*third Ubus Master*/ READ_32(UBUS_MASTER_3_RDP_UBUS_MASTER_BRDG_REG_EN,reg); reg |= 1; // bit 0 is the enable bit WRITE_32(UBUS_MASTER_3_RDP_UBUS_MASTER_BRDG_REG_EN,reg); READ_32(UBUS_MASTER_3_RDP_UBUS_MASTER_BRDG_REG_HP,reg); reg |= 0xf0e01; // allow forwarding of Urgent to High priority on UBUS WRITE_32(UBUS_MASTER_3_RDP_UBUS_MASTER_BRDG_REG_HP,reg); } static void ResetUnresetRdpBlock(void) { /*put all RDP modules in reset state*/ pmcPutAllRdpModulesInReset(); /*when Oren is out of reset, RDP block reset bits are all set to reset, * first we have to take out of reset the Broadbus and VPB*/ pmcSetModuleResetState(RDP_S_RST_UBUS_DBR,PBCM_UNRESET); pmcSetModuleResetState(RDP_S_RST_UBUS_RABR,PBCM_UNRESET); pmcSetModuleResetState(RDP_S_RST_UBUS_RBBR,PBCM_UNRESET); pmcSetModuleResetState(RDP_S_RST_UBUS_VPBR,PBCM_UNRESET); f_enable_ubus_masters(); } int rdp_pre_init(void) { uint32_t macIter; if ( (pBoardInfo = BpGetEthernetMacInfoArrayPtr()) == NULL ) { printk("ERROR:BoardID not Set in BoardParams\n"); return -1; } ResetUnresetRdpBlock(); pmcSetModuleResetState(RDP_S_RST_BB_RNR,PBCM_UNRESET); udelay(100); /*take out of reset Runners 0 and 1*/ pmcSetModuleResetState(RDP_S_RST_RNR_SUB,PBCM_UNRESET); pmcSetModuleResetState(RDP_S_RST_RNR_1,PBCM_UNRESET); pmcSetModuleResetState(RDP_S_RST_RNR_0,PBCM_UNRESET); pmcSetModuleResetState(RDP_S_RST_IPSEC_RNR,PBCM_UNRESET); pmcSetModuleResetState(RDP_S_RST_IPSEC_RNG,PBCM_UNRESET); pmcSetModuleResetState(RDP_S_RST_IPSEC_MAIN,PBCM_UNRESET); pmcSetModuleResetState(RDP_S_RST_GEN_MAIN,PBCM_UNRESET); /*take IH out of*/ pmcSetModuleResetState(RDP_S_RST_IH_RNR,PBCM_UNRESET); /*take TM out of reset*/ pmcSetModuleResetState(RDP_S_RST_BB_RNR,PBCM_UNRESET); for (macIter = DRV_BBH_EMAC_0; macIter <= DRV_BBH_EMAC_4; macIter++) { if(pBoardInfo[0].sw.port_map & (1<