/* <:copyright-broadcom Copyright (c) 2002 Broadcom Corporation All Rights Reserved No portions of this material may be reproduced in any form without the written permission of: Broadcom Corporation 16215 Alton Parkway Irvine, California 92619 All information contained in this document is Broadcom Corporation company private, proprietary, and trade secret. :> */ //************************************************************************** // File Name : Adsl.c // // Description: This file contains API for ADSL PHY // //************************************************************************** #ifdef _WIN32_WCE #include <windows.h> #include <types.h> #include <ceddk.h> #include <memory.h> #include <linklist.h> #include <nkintr.h> #include <hwcomapi.h> #include <devload.h> #include <pm.h> #elif defined(_CFE_) #include "lib_types.h" #include "lib_string.h" #include "lib_printf.h" #include "boardparms.h" #elif defined(TARG_OS_RTEMS) #include <alloc.h> #include <xapi.h> #include "types.h" #include "bspcfg.h" #define ulong unsigned long #else #include <linux/version.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/wait.h> #include <linux/timer.h> #include <linux/interrupt.h> #include <linux/jiffies.h> #include "boardparms.h" #endif #ifndef _WIN32_WCE #include "bcmtypes.h" #endif #include "softdsl/AdslCoreDefs.h" #include "BcmOs.h" #include "board.h" #if defined(CONFIG_BCM96338) #include "6338_map.h" #endif #if defined(CONFIG_BCM96358) #include "6358_map.h" #endif #if defined(CONFIG_BCM96348) #include "6348_map.h" #endif #if !defined(TARG_OS_RTEMS) #include "bcm_intr.h" #endif #include "bcmadsl.h" #include "BcmAdslCore.h" #if !defined(__KERNEL__) #define KERNEL_VERSION(a,b,c) 0x7fffffff #endif extern void BcmAdslCoreDiagWriteStatusString(char *fmt, ...); #if !defined(TARG_OS_RTEMS) LOCAL void *g_TimerHandle; LOCAL void BcmAdsl_Status(void); LOCAL void BcmAdsl_Timer(void * arg); #else #define calloc(L,X) xmalloc(L) #define free(P) xfree(P) extern void AdslLinkReset(void); LOCAL OS_SEMID g_StatusSemId; LOCAL OS_TASKID g_StatusTid; LOCAL void StatusTask(void); #endif #ifdef VDF_SPAIN int g_ulAdslCuts = 0; int g_ulAdslOnLineStart = 0; #endif LOCAL void IdleNotifyCallback (ADSL_LINK_STATE AdslLinkState, UINT32 ulParm) { } #define ADSL_RJ11_INNER_PAIR 0 #define ADSL_RJ11_OUTER_PAIR 1 LOCAL void SetRj11Pair( UINT16 usPairToEnable, UINT16 usPairToDisable ); LOCAL ADSL_FN_NOTIFY_CB g_pFnNotifyCallback = IdleNotifyCallback; LOCAL UINT32 g_ulNotifyCallbackParm; ADSL_LINK_STATE g_LinkState; LOCAL unsigned short g_GpioInnerPair = 0xffff; LOCAL unsigned short g_GpioOuterPair = 0xffff; LOCAL unsigned short g_BoardType; LOCAL int g_RJ11Pair = ADSL_RJ11_INNER_PAIR; #ifndef DYING_GASP_API #if defined(__KERNEL__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) LOCAL irqreturn_t BcmDyingGaspIsr(int irq, void * dev_id, struct pt_regs * regs); #else LOCAL unsigned int BcmDyingGaspIsr( void ); #endif #endif int g_nAdslExit = 0; int g_nAdslInitialized = 0; //LGD_FOR_TR098 unsigned long g_ShowtimeStartTicks = 0; #ifdef _WIN32_WCE BCMADSL_STATUS BcmAdsl_Initialize(ADSL_FN_NOTIFY_CB pFnNotifyCb, UINT32 ulParm, adslCfgProfile *pAdslCfg) { DEBUGMSG (DBG_MSG, (TEXT("BcmAdsl_Initialize=0x%08X, &g_nAdslExit=0x%08X\n"), (int)BcmAdsl_Initialize, (int) &g_nAdslExit)); BcmOsInitialize (); g_pFnNotifyCallback = (pFnNotifyCb != NULL) ? pFnNotifyCb : IdleNotifyCallback; g_ulNotifyCallbackParm = ulParm; //BcmAdslCoreSetSDRAMBaseAddr((void *) (((ulong) kerSysGetSdramSize() - 0x40000) | 0xA0000000)); BcmAdslCoreSetSDRAMBaseAddr((void *) ((0x800000 - 0x40000) | 0xA0000000)); BcmAdslCoreConfigure(pAdslCfg); BcmAdslCoreInit(); g_LinkState = BCM_ADSL_LINK_DOWN; g_nAdslExit = 0; g_nAdslInitialized = 1; g_TimerHandle = bcmOsTimerCreate(BcmAdsl_Timer, NULL); if (NULL != g_TimerHandle) bcmOsTimerStart(g_TimerHandle, 1000); return BCMADSL_STATUS_SUCCESS; } #elif !defined(TARG_OS_RTEMS) //************************************************************************** // Function Name: BcmAdsl_Initialize // Description : Initializes ADSL PHY. // Returns : STS_SUCCESS if successful or error status. //************************************************************************** BCMADSL_STATUS BcmAdsl_Initialize(ADSL_FN_NOTIFY_CB pFnNotifyCb, UINT32 ulParm, adslCfgProfile *pAdslCfg) { printk("BcmAdsl_Initialize=0x%08X, g_pFnNotifyCallback=0x%08X\n", (int)BcmAdsl_Initialize, (int) &g_pFnNotifyCallback); if (g_nAdslInitialized != 0) { BcmAdslCoreConfigure(pAdslCfg); return BCMADSL_STATUS_SUCCESS; } BcmOsInitialize (); #ifndef DYING_GASP_API { unsigned long ulIntr; #if defined(CONFIG_BCM963x8) #if defined(__KERNEL__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) #endif { BcmHalMapInterrupt((void *)BcmDyingGaspIsr, 0, INTERRUPT_ID_DG); BcmHalInterruptEnable( INTERRUPT_ID_DG ); } #endif } #endif if( BpGetRj11InnerOuterPairGpios(&g_GpioInnerPair, &g_GpioOuterPair) == BP_SUCCESS ) { g_GpioInnerPair = GPIO_NUM_TO_MASK(g_GpioInnerPair); g_GpioOuterPair = GPIO_NUM_TO_MASK(g_GpioOuterPair); } else { g_GpioInnerPair = 0xffff; g_GpioOuterPair = 0xffff; } g_BoardType = 0; g_pFnNotifyCallback = (pFnNotifyCb != NULL) ? pFnNotifyCb : IdleNotifyCallback; g_ulNotifyCallbackParm = ulParm; BcmAdslCoreSetSDRAMBaseAddr((void *) (((unsigned long) kerSysGetSdramSize() - 0x40000) | 0xA0000000)); BcmAdslCoreConfigure(pAdslCfg); BcmAdslCoreInit(); g_LinkState = BCM_ADSL_LINK_DOWN; g_nAdslExit = 0; g_nAdslInitialized = 1; g_TimerHandle = bcmOsTimerCreate(BcmAdsl_Timer, NULL); if (NULL != g_TimerHandle) bcmOsTimerStart(g_TimerHandle, 1000); return BCMADSL_STATUS_SUCCESS; } #else /* defined(TARG_OS_RTEMS) */ BCMADSL_STATUS BcmAdsl_Initialize(ADSL_FN_NOTIFY_CB pFnNotifyCb, UINT32 ulParm, adslCfgProfile *pAdslCfg) { typedef void (*FN_HDLR) (unsigned long); BcmOsInitialize (); #if 0 /* The interrupt handling of the Dying gasp is controlled external */ BcmHalMapInterrupt((FN_HDLR)BcmDyingGaspIsr, 0, INTERRUPT_ID_DYING_GASP); BcmHalInterruptEnable( INTERRUPT_ID_DYING_GASP ); #if defined(BOARD_bcm96348) || defined(BOARD_bcm96338) BcmHalMapInterrupt((FN_HDLR)BcmDyingGaspIsr, 0, INTERRUPT_ID_DG); BcmHalInterruptEnable( INTERRUPT_ID_DG ); #endif #endif g_pFnNotifyCallback = (pFnNotifyCb != NULL) ? pFnNotifyCb : IdleNotifyCallback; g_BoardType = 0; g_ulNotifyCallbackParm = ulParm; bcmOsSemCreate(NULL, &g_StatusSemId); /* kerSysGetSdramSize subtracts the size reserved for the ADSL MIPS */ BcmAdslCoreSetSDRAMBaseAddr((void *) ((unsigned long) kerSysGetSdramSize() | 0xA0000000)); BcmAdslCoreConfigure(pAdslCfg); BcmAdslCoreInit(); g_LinkState = BCM_ADSL_LINK_DOWN; g_nAdslExit = 0; g_nAdslInitialized = 1; bcmOsTaskCreate("ADSL", 20*1024, 50, StatusTask, 0, &g_StatusTid); return BCMADSL_STATUS_SUCCESS; }
static int bcm63xx_init_rxdma_structures(BcmEnet_devctrl *pDevCtrl) { BcmEnet_RxDma *rxdma; /* init rx dma channel structures */ pDevCtrl->rxdma[0] = (BcmEnet_RxDma *) (kzalloc( sizeof(BcmEnet_RxDma), GFP_KERNEL)); if (pDevCtrl->rxdma[0] == NULL) { printk("Unable to allocate memory for rx dma rings \n"); return -ENXIO; } BCM_ENET_DEBUG("The rxdma is 0x%p \n", pDevCtrl->rxdma[0]); rxdma = pDevCtrl->rxdma[0]; /* init number of Rx BDs in each rx ring. */ rxdma->pktDmaRxInfo.numRxBds = bcmPktDma_EthGetRxBds(&rxdma->pktDmaRxInfo, pDevCtrl->vport_id); /* request IRQs only once at module init */ { /* Substitute channel parameter for enetcore number */ int rxIrq = bcmPktDma_EthSelectRxIrq(pDevCtrl->sw_port_id); /* disable the interrupts from device */ bcmPktDma_BcmHalInterruptDisable(0, rxIrq); /* a Host owned channel */ BcmHalMapInterrupt(bcmeapi_enet_isr, BUILD_CONTEXT(pDevCtrl, 0), rxIrq); } return 0; }
//************************************************************************** // Function Name: BcmAdsl_Initialize // Description : Initializes ADSL PHY. // Returns : STS_SUCCESS if successful or error status. //************************************************************************** BCMADSL_STATUS BcmAdsl_Initialize(ADSL_FN_NOTIFY_CB pFnNotifyCb, UINT32 ulParm, adslCfgProfile *pAdslCfg) { printk("BcmAdsl_Initialize=0x%08X, g_pFnNotifyCallback=0x%08X\n", (int)BcmAdsl_Initialize, (int) &g_pFnNotifyCallback); if (g_nAdslInitialized != 0) { BcmAdslCoreConfigure(pAdslCfg); return BCMADSL_STATUS_SUCCESS; } BcmOsInitialize (); #ifndef DYING_GASP_API { unsigned long ulIntr; #if defined(CONFIG_BCM963x8) #if defined(__KERNEL__) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) if( BpGetAdslDyingGaspExtIntr( &ulIntr ) == BP_SUCCESS ) #endif { BcmHalMapInterrupt((void *)BcmDyingGaspIsr, 0, INTERRUPT_ID_DG); BcmHalInterruptEnable( INTERRUPT_ID_DG ); } #endif } #endif if( BpGetRj11InnerOuterPairGpios(&g_GpioInnerPair, &g_GpioOuterPair) == BP_SUCCESS ) { g_GpioInnerPair = GPIO_NUM_TO_MASK(g_GpioInnerPair); g_GpioOuterPair = GPIO_NUM_TO_MASK(g_GpioOuterPair); } else { g_GpioInnerPair = 0xffff; g_GpioOuterPair = 0xffff; } g_BoardType = 0; g_pFnNotifyCallback = (pFnNotifyCb != NULL) ? pFnNotifyCb : IdleNotifyCallback; g_ulNotifyCallbackParm = ulParm; BcmAdslCoreSetSDRAMBaseAddr((void *) (((unsigned long) kerSysGetSdramSize() - 0x40000) | 0xA0000000)); BcmAdslCoreConfigure(pAdslCfg); BcmAdslCoreInit(); g_LinkState = BCM_ADSL_LINK_DOWN; g_nAdslExit = 0; g_nAdslInitialized = 1; g_TimerHandle = bcmOsTimerCreate(BcmAdsl_Timer, NULL); if (NULL != g_TimerHandle) bcmOsTimerStart(g_TimerHandle, 1000); return BCMADSL_STATUS_SUCCESS; }
int bcmeapi_map_interrupt(BcmEnet_devctrl *pDevCtrl) { BcmHalMapInterrupt(bcm63xx_gphy_isr, (unsigned int)pDevCtrl, INTERRUPT_ID_EPHY); return BCMEAPI_INT_MAPPED_INTPHY; }