⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mdio_diag.c

📁 开发Inetl IXP2400平台所必须的硬件诊断和测试程序。该软件包支持的功能包括CPU基本功能检测
💻 C
字号:
/* mdio_diag.c
 *
 *-------------------------------------------------------------------------------
 *                                                                      
 *                  I N T E L   P R O P R I E T A R Y                   
 *                                                                      
 *     COPYRIGHT (c)  2002 BY  INTEL  CORPORATION.  ALL RIGHTS          
 *     RESERVED.   NO  PART  OF THIS PROGRAM  OR  PUBLICATION  MAY      
 *     BE  REPRODUCED,   TRANSMITTED,   TRANSCRIBED,   STORED  IN  A    
 *     RETRIEVAL SYSTEM, OR TRANSLATED INTO ANY LANGUAGE OR COMPUTER    
 *     LANGUAGE IN ANY FORM OR BY ANY MEANS, ELECTRONIC, MECHANICAL,    
 *     MAGNETIC,  OPTICAL,  CHEMICAL, MANUAL, OR OTHERWISE,  WITHOUT    
 *     THE PRIOR WRITTEN PERMISSION OF :                                
 *                                                                      
 *                        INTEL  CORPORATION                            
 *                                                                     
 *                     2200 MISSION COLLEGE BLVD                        
 *                                                                      
 *               SANTA  CLARA,  CALIFORNIA  95052-8119                  
 *                                                                      
 *-------------------------------------------------------------------------------
 *
 *
 *  system: IXDP2400
 *  subsystem: DIAG
 *  author: chinmay, DECEMBER, 2002
 * 
 * 
 * ------------------------------------------------------------------------------
 */

typedef unsigned long ulong;
typedef unsigned short ushort;

/**
 * User defined include files required.
 */
#include "common.h"
#include "memory.h"
#include "msf_common.h"
#include "diagstruct.h"
#include "led.h"
#include "uc_load.h"
#include "pci_diag.h"
#include "pci.h"
#include "hal_ixdp2400.h"
#include "memory.h"
#include "syslog.h"
#include "uart.h"
#include "msf_init.h"
#include "diag_utils.h"

#include "error_code.h"
#include "error_map.h"
#include "reg_api.h"
#include "register_map.h"
#include "diag.h"
#include "dp_proto.h"
#include "mac_util.h"
#include "mac_init.h"

#define MEDIA_IF_EEPROM_ADDR    0xa4
#define SF_IF_EEPROM_ADDR       0xa6

#define EEPROM_DEV_ID_OFF       0x01
#define PT_LONE_DEVICE_ID       0x6

/* 
** PHY register offsets.
*/

#define PHY_REG_0	0x0
#define PHY_REG_4	0x4
#define PHY_REG_12	0x12
#define PHY_REG_17	0x17


#define aphy_reg_arraySz (sizeof(aphy_reg_array)/sizeof(aphy_reg_array[0]))

extern pci_device slave_dev_info;		// for slave npu info.

extern UINT32 total_args,loop,ports,speed;  
extern char channel,test_opt;
extern UINT8 test_param;

/* extern functions */
extern UINT32 init_mac_dev(UINT32);
extern void set_dcache_off(void);

extern void gbe_mac_phy_write( UINT32 arg_PhyAddress,
                               UINT32 arg_RegAddress,
                               UINT32 arg_WriteValue
                              );

extern UINT32 gbe_mac_phy_read( UINT32 arg_PhyAddress,
                         UINT32 arg_RegAddress);

UINT32 aphy_reg_array[4][2] =	{	{PHY_REG_0,  0x2040},
									{PHY_REG_4,  0x08F0},
									{PHY_REG_12, 0x0001},
									{PHY_REG_17, 0x1000}
								};; 

/**
 * Static function prototypes.
 */

static void configure_mdio_command(void);
static UINT32 read_mdio(void);

// ******************************************************************************
// Function: UINT32 mdio_config_test(void)
//
//     This file  defines the mac diagnostics routine for MDIO operation.
//     It consists of :mdio_config_test 
// ******************************************************************************
UINT32 mdio_config_test(void)
{
	UINT32 status;
	UINT32 scratch_ring_tx_count, scratch_ring_rx;
	register PDiagCommon acL = (PDiagCommon) ACADDRESS;
	UINT32 test_passed;
	
	scratch_ring_rx = SCR_RING_INSTR_ADDR + (5 << 2);
	scratch_ring_tx_count = SCR_RING_INSTR_ADDR + (4 << 2);

	test_opt = acL->argv[2][0];
	test_param = acL->argv[3][0];

	MSG("test param = %c\n",test_param,0,0);
	if(acL->HostType == MASTER)		// if master NPU
	{
		Msf_OutOfReset();
		status = Msf_PLL();
		if (status == ERROR)
		{
			return ABORT;
		}

		eprintf("Initialising media card. Please wait...\n");
		status = init_mac_dev(0);	
		if (status != DONE)
		{
			eprintf("Aborting Test\n");
			return ABORT;
		}
		eprintf("Media card initialisation completed.\n");

		spConfig();

		if (test_param == 'a')
		{
			/** enable autoscan **/
			reg_write(AS_PHY_ADDR,0xf);
			reg_write(MDIO_CTL,0x6);
		}
		/*
	    ** configure external PHY registers to some dummy values
	    */
		configure_mdio_command();

		/*
		** read PHY registers via MDIO interface.
		*/
		test_passed=read_mdio();
		if (test_passed)
		{
			if (test_param=='a')
				eprintf("\nAutoscan test passed. \n");
			else if (test_param=='s')
				eprintf("\nMDC Speed Selection test passed. \n");
			else
				eprintf("\nMDIO configuration test passed. \n");

			Set_LED("PASS");
			slowport_code[0] = SP_XSC;
			slowport_code[1] = SP_PASS;
			dump_slowport(slowport_code, 2, SP_NON_FATAL);
		} else
		{
			
			// prepare structure for dumping
			syslog.type = TYPE_ERROR;
			syslog.source_comp = MASTER_DIAG;       // Determine master/slave
			if (test_param == 'a')
				strcpy(syslog.desc, ERR_STR(AUTOSCAN_ERR));
			else if (test_param == 's')
				strcpy(syslog.desc, "MDIO Access failed at 18MHz.");
			else
				strcpy(syslog.desc, ERR_STR(MDIO_ERR));
			
			// write to syslog
			syslog_dump(&syslog, sizeof(SYSLOG_DATA));
			
			if (test_param == 'a')
				eprintf("\n%s\n",ERR_STR(AUTOSCAN_ERR));
			else if (test_param == 's')
				eprintf("MDIO Access failed at 18MHz.");
			else
				eprintf("\n%s\n"	, ERR_STR(MDIO_ERR));
			
			Set_LED("FAIL");
			slowport_code[0] = SP_XSC;
			slowport_code[1] = SP_FAIL;
			dump_slowport(slowport_code, 2, SP_NON_FATAL);
		}
		
		spRestore();

		return DONE;
	}
	else
	{
		eprintf("\nThis test cannot be run directly on the Slave console\n");
		return DONE; // To indicate that the slave does not do this.
	}
}

static void configure_mdio_command(void)
{
	UINT32 i=0;
    short port =0;

    for (port=0;port<NUM_PORTS;port++)
    {
		for(i=0;i<aphy_reg_arraySz;i++)
        {
			MSG("writing to phy reg : 0x%x  value : 0x%x\n",aphy_reg_array[i][0],aphy_reg_array[i][1],0);
			gbe_mac_phy_write(port, aphy_reg_array[i][0], aphy_reg_array[i][1]);
        }            
    }
        
}
     
static UINT32 read_mdio(void)
{
	UINT32 i=0;
    UINT32 regVal=0;
    UINT32 passed = 1,as_offset=0x60;
	short port =0;

	for (port=0;port<NUM_PORTS;port++)
	{
        for(i=0;i<aphy_reg_arraySz;i++)
		{
			if (test_param != 'a')
			{
				regVal = gbe_mac_phy_read(port,aphy_reg_array[i][0]);
			}
			else
			{
				regVal = reg_read(aphy_reg_array[i][0]+as_offset+(port*0x80));
			}

			MSG("reading from phy reg : 0x%x  value : 0x%x\n",aphy_reg_array[i][0],regVal,0);	
			/*
            ** Verify that the read value is same as configured.
            */
            if (regVal != aphy_reg_array[i][1])
            {
    
				MSG("Register Value: %x \t Expected Value:%x \n",regVal,aphy_reg_array[i][1],0);
				eprintf("Test failed\n",0,0,0);
    
                passed = 0;
                break;
            }
        }
		if (!passed)
			break; 	 
    }
    //MSG("Return value: passed = %d\n",passed,0,0);

    return passed;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -