/******************************************************************************/
/*                 Copyright C 1998-2004 Broadcom Corporation                 */
/*                                                                            */
/* This material is the confidential trade secret and proprietary information */
/* of Broadcom Corporation.  It may not be reproduced, used, sold or          */
/* transferred to any third party without the prior written consent of        */
/* Broadcom Corporation.   All rights reserved.                               */
/******************************************************************************/
/*   FileName        : bcm_genericDef.h                                       */
/*   Purpose         : some BCM6410 related parameters                        */
/*   Limitations     : None                                                   */
/*   Author          : Emmanuel Hanssens                                      */
/*   Creation Date   : 22-Jun-2004                                            */
/*   History         : Compiled by CVS                                        */
/******************************************************************************/
/*   $Id: bcm_genericDef.h,v 1.9 2004/11/18 15:31:37 hanssens Exp $  */
/******************************************************************************/

#ifndef BCM_GENERIC_DEF_H
# define BCM_GENERIC_DEF_H

/* generic error report */
# define BCM_SUCCESS 0
# define BCM_FAILURE 2

# define BCM_UNUSED_PARAMETER(a) (a = a)

/* BCM6410/6411/6510 related stuff */
# ifdef BCM_USE_BCM6510
//#  define BCM_DEV_NB_LINES     16
# elif !defined(BCM_ADSLPLUS_ON_6410)
#  define BCM_DEV_NB_LINES     12
# else
//#  define BCM_DEV_NB_LINES      6
# endif
# define BCM_DEV_NB_BONDGRP    (BCM_DEV_NB_LINES/2)
# define NB_BCM_DEV            ((NB_LINES+BCM_DEV_NB_LINES-1)/BCM_DEV_NB_LINES)
# ifndef NB_HMIDEV
#  define NB_HMIDEV            NB_BCM_DEV
# endif

# if (NB_HMIDEV<NB_BCM_DEV) 
#  error "inconsistent configuration of NB_HMIDEV and NB_LINES"
# endif

# define BCM_DEV_LINE_ID(line)      ((line) % BCM_DEV_NB_LINES)
# define BCM_LINE_2_DEV(line)       ((line) / BCM_DEV_NB_LINES)
# define BCM_CORE_2_DEV(coreId)     ((coreId)/2)
# define BCM_DEV_BONDGRP_ID(group)  ((group) % BCM_DEV_NB_BONDGRP)
# define BCM_BONDGRP_2_DEV(group)   ((group) / BCM_DEV_NB_BONDGRP)
# ifndef BCM6410_SPECIAL_CORE_MAPPING
#  define BCM_CORE_LINE_ID(line)    ((line) % (BCM_DEV_NB_LINES/2))
#  define BCM_LINE_2_CORE(line)     ((line) / (BCM_DEV_NB_LINES/2))
#  define BCM_BONDGRP_2_CORE(group) ((group) / (BCM_DEV_NB_BONDGRP/2))
# endif

# define BCM_PAGE_SIZE      0x4000            /* 16kB page */
# define BCM_MAX_PAGE       31                /* 5 bit page */
# define MAX_HMI_FIFO_SIZE  (BCM_PAGE_SIZE/2) /* 2 fifo's  */
# define MAX_HMI_PACKET_SIZE 512
# ifndef MAX_BOOT_PACKET_SIZE
#  define MAX_BOOT_PACKET_SIZE MAX_HMI_PACKET_SIZE
# endif

/* booter and firmware time out */
# ifndef BOOTER_TIMEOUT_MS
#  define BOOTER_TIMEOUT_MS   1000
# endif
# ifndef FIRMWARE_TIMEOUT_MS
#  define FIRMWARE_TIMEOUT_MS 4000
# endif
/* QA time out */
# ifndef BCM_QA_TIMEOUT_MS
#  define BCM_QA_TIMEOUT_MS 100
# endif

# ifdef NO_PRINT_INFO
#  define NO_STDOUT_PRINT
#  define NO_STDERR_PRINT
# endif

# ifndef TRUE
#  define TRUE 1
# endif
# ifndef FALSE
#  define FALSE 0
# endif

# ifndef min
#  define min(a,b) ((a)<(b)? (a):(b))
# endif
# ifndef max
#  define max(a,b) ((a)>(b)? (a):(b))
# endif

/* range check for parameters */
# ifndef IN_RANGE
#  define IN_RANGE(data, min, max) ((data) >= (min) && (data) <= (max))
# endif

/* line driver usage */
# ifdef BCM_IPDSLAM_V2
#  define BCM_SPECIAL_LINE_DRIVER_SETTING BCM_SET_AD8390_POWER_MODES
# endif

/* power calibration */
# ifndef BCM_TX_POWER_CALIBRATION
#  ifdef BCM_USE_3_3_VOLT_ANALOG
#   define BCM_TX_POWER_CALIBRATION  -68
#  elif defined(BCM_IPDSLAM_V2)
#   define BCM_TX_POWER_CALIBRATION  -256
#  else
#   define BCM_TX_POWER_CALIBRATION  0
#  endif
# endif

# ifndef BCM_RX_POWER_CALIBRATION
#  define BCM_RX_POWER_CALIBRATION  256
# endif

/* default BCM6510 afe config -- only necessary if using BCM6510 */
# ifndef BCM6510_AFE_CONFIG
#  define BCM6510_AFE_CONFIG BCM6510_AFE_CONFIG_16
# endif

/* packing attribute may be defined for some processors */
# ifndef BCM_PACKING_ATTRIBUTE
#  define BCM_PACKING_ATTRIBUTE
# endif
#endif
