📄 syscon_platform.c
字号:
/************************************************************************
*
* syscon_platform.c
*
* Platform specific parts of SYSCON module (except TTY related parts)
*
*
* ######################################################################
*
* Copyright (c) 1999-2000 MIPS Technologies, Inc. All rights reserved.
*
* Unpublished rights reserved under the Copyright Laws of the United States of
* America.
*
* This document contains information that is proprietary to MIPS Technologies,
* Inc. ("MIPS Technologies"). Any copying, modifying or use of this information
* (in whole or in part) which is not expressly permitted in writing by MIPS
* Technologies or a contractually-authorized third party is strictly
* prohibited. At a minimum, this information is protected under unfair
* competition laws and the expression of the information contained herein is
* protected under federal copyright laws. Violations thereof may result in
* criminal penalties and fines.
* MIPS Technologies or any contractually-authorized third party reserves the
* right to change the information contained in this document to improve
* function, design or otherwise. MIPS Technologies does not assume any
* liability arising out of the application or use of this information. Any
* license under patent rights or any other intellectual property rights owned
* by MIPS Technologies or third parties shall be conveyed by MIPS Technologies
* or any contractually-authorized third party in a separate license agreement
* between the parties.
* The information contained in this document constitutes one or more of the
* following: commercial computer software, commercial computer software
* documentation or other commercial items. If the user of this information, or
* any related documentation of any kind, including related technical data or
* manuals, is an agency, department, or other entity of the United States
* government ("Government"), the use, duplication, reproduction, release,
* modification, disclosure, or transfer of this information, or any related
* documentation of any kind, is restricted in accordance with Federal
* Acquisition Regulation 12.212 for civilian agencies and Defense Federal
* Acquisition Regulation Supplement 227.7202 for military agencies. The use of
* this information by the Government is further restricted in accordance with
* the terms of the license agreement(s) and/or applicable contract terms and
* conditions covering this information from MIPS Technologies or any
* contractually-authorized third party.
*
************************************************************************/
/************************************************************************
* Include files
************************************************************************/
#include <sysdefs.h>
#include <sysdev.h>
#include <syscon_api.h>
#include <syscon.h>
#include <sys_api.h>
#include <pci_api.h>
#include <io_api.h>
#include <eeprom_nm24c09_layout.h>
#include <eeprom_api.h>
#include <string.h>
#include <spd.h>
#include <product.h>
#include <atlas.h>
#include <sead.h>
#include <malta.h>
#include <pb1000.h>
#include <tmra.h> /* Atlas specific */
#include <icta.h> /* Atlas specific */
#include <piix4.h> /* Malta specific */
/* to check INCLUDE_ macros */
#include <initswitch.h>
#include <env_api.h>
/************************************************************************
* Definitions
************************************************************************/
#define WORD0_OFS 0x00000 /* Word0: */
#define WORD1_OFS 0x00004 /* Word1: */
/************************************************************************
* Public variables
************************************************************************/
/************************************************************************
* Static variables
************************************************************************/
/* Names of boards/RTL */
static char *name_atlas = "Atlas";
static char *name_sead = "SEAD";
static char *name_sead2 = "SEAD-2";
static char *name_malta = "Malta";
static char *name_qed_rm5261 = "QED RM5261 Board";
static char *name_core_lv = "CoreLV";
static char *name_basic_rtl = "Basic RTL";
static char *name_Pb1500 = "Pb1500";
/* Pointer to array of objects */
static t_syscon_obj *syscon_objects;
/* Size of ASCII display (if any) on platform */
static UINT32 alpha_display_size;
/* Addresses of individual ASCII charactes on ASCII display */
static volatile UINT32 *alpha_io[8];
/* Mapping between hex digit and ASCII character (e.g 0-> ASCII(0x30)) */
static const UINT8 bin2char[16] = { 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x41, 0x42,
0x43, 0x44, 0x45, 0x46 };
/* Register size */
static UINT8 size8 = sizeof(UINT8);
static UINT8 size32 = sizeof(UINT32);
/* MAC address and Serial Number */
static UINT8 amd_mac_addr[8];
static t_sn_bcd sn_buffer;
static t_mac_addr mac_addr_buffer;
static t_mac_addr *mac_addr_read = NULL;
static t_sn_bcd *sn_read = NULL;
/************************************************************************
* Static function prototypes
************************************************************************/
static INT32
eeprom_read(
UINT32 minor, /* Minor device number */
UINT32 offset, /* Byte position */
UINT32 length, /* Byte count */
void *user_variable ); /* Buffer for data */
/************************************************************************
* Implementation : Static functions registered for handling particular
* SYSCON objects for particular platform(s)
************************************************************************/
/************************************************************************
* com_en0_major_device_atlas_read
************************************************************************/
static UINT32
com_en0_major_device_atlas_read(
void *param,
void *data )
{
/* On Atlas, the Philips SAA9730 IO controller, implements
* the LAN device; however 10 MBit/s only
*/
*(UINT32 *)param = SYS_MAJOR_LAN_SAA9730;
return OK;
}
/************************************************************************
* com_en0_major_device_malta_read
************************************************************************/
static UINT32
com_en0_major_device_malta_read(
void *param,
void *data )
{
/* On Malta, the AMD 79C973 controller, implements
* the LAN device; speed and duplex mode are autonegotiated
*/
*(UINT32 *)param = SYS_MAJOR_LAN_AM79C973;
return OK;
}
/************************************************************************
* com_en0_major_device_pb1000_read
************************************************************************/
static UINT32
com_en0_major_device_pb1000_read(
void *param,
void *data )
{
/* PB1000 major device number */
#if defined(INCLUDE_LAN_LAN91C111)
*(UINT32 *)param = SYS_MAJOR_LAN_LAN91C111;
#else
*(UINT32 *)param = SYS_MAJOR_MAC_AU1000;
#endif
return OK;
}
/************************************************************************
* com_en0_minor_device_pb1000_read
************************************************************************/
static UINT32
com_en0_minor_device_pb1000_read(
void *param,
void *data )
{
/* PB1000 minor device number (a sysenv variable) */
if(!env_get( "MAC", NULL, param, sizeof(UINT32) ))
*(UINT32 *)param = 0;
return OK;
}
/************************************************************************
* com_en0_intline_atlas_read
************************************************************************/
static UINT32
com_en0_intline_atlas_read(
void *param,
void *data )
{
/* Return interrupt line used for EN0 on Atlas interrupt controller */
*(UINT32 *)param = ICTA_INTSTATUS_CONINTBN_SHF;
return OK;
}
/************************************************************************
* com_en0_intline_malta_read
************************************************************************/
static UINT32
com_en0_intline_malta_read(
void *param,
void *data )
{
/* Return interrupt line used for EN0 on Malta interrupt controller */
*(UINT32 *)param = MALTA_INTLINE_79C973;
return OK;
}
/************************************************************************
* board_productname_read
************************************************************************/
static UINT32
board_productname_read(
void *param,
void *data )
{
*(char **)param = (char *)data;
return OK;
}
/************************************************************************
* board_nmi_werr_atlas_malta_read
************************************************************************/
static UINT32
board_nmi_werr_atlas_malta_read(
void *param,
void *data )
{
*(UINT32 *)param = 0; /* no WERR bit on Atlas */
return OK;
}
/************************************************************************
* board_nmi_werr_sead_read
************************************************************************/
static UINT32
board_nmi_werr_sead_read(
void *param,
void *data )
{
*(UINT32 *)param = REGPRD( KSEG1BASE, SEAD_NMISTATUS, WERR);
return OK;
}
/************************************************************************
* board_nmi_status_atlas_read
************************************************************************/
static UINT32
board_nmi_status_atlas_read(
void *param,
void *data )
{
*(bool *)param = REGPRD(KSEG1BASE, ATLAS_NMISTATUS, ONNMI) ? TRUE : FALSE;
return OK;
}
/************************************************************************
* board_nmi_status_malta_read
************************************************************************/
static UINT32
board_nmi_status_malta_read(
void *param,
void *data )
{
*(bool *)param =
(
(REGPRD(KSEG1BASE, MALTA_NMISTATUS, SB)) ||
(REGPRD(KSEG1BASE, MALTA_NMISTATUS, ONNMI))
) ?
TRUE : FALSE;
return OK;
}
/************************************************************************
* board_nmi_status_sead_read
************************************************************************/
static UINT32
board_nmi_status_sead_read(
void *param,
void *data )
{
*(bool *)param = REGPRD(KSEG1BASE, SEAD_NMISTATUS, FLAG) ? TRUE : FALSE;
return OK;
}
/************************************************************************
* board_corecardid_atlas_malta_read
************************************************************************/
static UINT32
board_corecardid_atlas_malta_read(
void *param,
void *data )
{
/* Shared between Atlas and Malta */
*(UINT32 *)param = REGPRD(KSEG1BASE, ATLAS_REVISION, CORID);
return OK;
}
/************************************************************************
* board_corecardrev_atlas_malta_read
************************************************************************/
static UINT32
board_corecardrev_atlas_malta_read(
void *param,
void *data )
{
/* Shared between Atlas and Malta */
*(UINT32 *)param = REGPRD(KSEG1BASE, ATLAS_REVISION, CORRV);
return OK;
}
/************************************************************************
* board_fpgarev_atlas_malta_read
************************************************************************/
static UINT32
board_fpgarev_atlas_malta_read(
void *param,
void *data )
{
/* Shared between Atlas and Malta */
*(UINT32 *)param = REGPRD(KSEG1BASE, ATLAS_REVISION, FPGRV);
return OK;
}
/************************************************************************
* board_corecard_name_atlas_malta_read
************************************************************************/
static UINT32
board_corecard_name_atlas_malta_read(
void *param,
void *data )
{
#if 0
switch( REGPRD(KSEG1BASE, MIPS_REVISION, CORID) )
{
case MIPS_REVISION_CORID_QED_RM5261 :
*(char **)param = name_qed_rm5261;
break;
case MIPS_REVISION_CORID_CORE_LV :
*(char **)param = name_core_lv;
break;
default :
return ERROR_SYSCON_UNKNOWN_PARAM;
}
#endif
return OK;
}
/************************************************************************
* board_rtl_sead_read
************************************************************************/
static UINT32
board_rtl_sead_read(
void *param,
void *data )
{
*(UINT32 *)param = REGPRD(KSEG1BASE, SEAD_REVISION, RTLID);
}
/************************************************************************
* board_rtl_name_sead_read
************************************************************************/
static UINT32
board_rtl_name_sead_read(
void *param,
void *data )
{
switch( REGPRD(KSEG1BASE,SEAD_REVISION,RTLID) )
{
case SEAD_REVISION_RTLID_BASIC :
*(char **)param = name_basic_rtl;
break;
default :
return ERROR_SYSCON_UNKNOWN_PARAM;
}
return OK;
}
/************************************************************************
* board_rtlrev_major_sead_read
************************************************************************/
static UINT32
board_rtlrev_major_sead_read(
void *param,
void *data )
{
*(UINT32 *)param = REGPRD(KSEG1BASE, SEAD_REVISION, RTLMAJ);
return OK;
}
/************************************************************************
* board_rtlrev_minor_sead_read
************************************************************************/
static UINT32
board_rtlrev_minor_sead_read(
void *param,
void *data )
{
*(UINT32 *)param = REGPRD(KSEG1BASE, SEAD_REVISION, RTLMIN);
return OK;
}
/************************************************************************
* board_use_default_atlas_malta_read
************************************************************************/
static UINT32
board_use_default_atlas_malta_read(
void *param,
void *data )
{
/* Read S5-4 switch */
*(UINT32 *)param = REGPRD( KSEG1BASE, ATLAS_STATUS, S54 );
return OK;
}
/************************************************************************
* board_use_default_sead_read
************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -