📄 syscon_platform.c
字号:
/************************************************************************ * * syscon_platform.c * * Platform specific parts of SYSCON module (except TTY related parts) * * ###################################################################### * * mips_start_of_legal_notice * * Copyright (c) 2004 MIPS Technologies, Inc. All rights reserved. * * * Unpublished rights (if any) reserved under the copyright laws of the * United States of America and other countries. * * This code is proprietary to MIPS Technologies, Inc. ("MIPS * Technologies"). Any copying, reproducing, modifying or use of this code * (in whole or in part) that is not expressly permitted in writing by MIPS * Technologies or an authorized third party is strictly prohibited. At a * minimum, this code is protected under unfair competition and copyright * laws. Violations thereof may result in criminal penalties and fines. * * MIPS Technologies reserves the right to change this code to improve * function, design or otherwise. MIPS Technologies does not assume any * liability arising out of the application or use of this code, or of any * error or omission in such code. Any warranties, whether express, * statutory, implied or otherwise, including but not limited to the implied * warranties of merchantability or fitness for a particular purpose, are * excluded. Except as expressly provided in any written license agreement * from MIPS Technologies or an authorized third party, the furnishing of * this code does not give recipient any license to any intellectual * property rights, including any patent rights, that cover this code. * * This code shall not be exported, reexported, transferred, or released, * directly or indirectly, in violation of the law of any country or * international law, regulation, treaty, Executive Order, statute, * amendments or supplements thereto. Should a conflict arise regarding the * export, reexport, transfer, or release of this code, the laws of the * United States of America shall be the governing law. * * This code constitutes one or more of the following: commercial computer * software, commercial computer software documentation or other commercial * items. If the user of this code, 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 code, 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 code 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 code from MIPS Technologies or an authorized * third party. * * * * * mips_end_of_legal_notice * * ************************************************************************//************************************************************************ * Include files ************************************************************************/#include <sysdefs.h>#include <sysdev.h>#include <syscon_api.h>#include <syscon.h>#include <sys_api.h>#include <string.h>#include <excep_api.h>#include <pci_api.h>#include <io_api.h>#include <eeprom_nm24c09_layout.h>#include <eeprom_api.h>#include <spd.h>#include <product.h>#include <atlas.h>#include <sead.h>#include <malta.h>#include <tmra.h> /* Atlas specific */#include <icta.h> /* Atlas specific */#include <piix4.h> /* Malta specific *//************************************************************************ * 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_basic_rtl = "Basic RTL";/* 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;/* EEPROM definitions */static UINT8 eeprom_count;static t_syscon_eeprom_def eeprom_def[2];static char *eeprom_system_name = "sys";static char *eeprom_system_descr = "Device for storing system data";static char *eeprom_spd0_name = "spd0";static char *eeprom_spd0_descr = "Device used for SDRAM parameters (SPD)";/************************************************************************ * 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) ************************************************************************//************************************************************************ * board_productid_generic_read ************************************************************************/static UINT32board_productid_generic_read( void *param, void *data, UINT32 size ){ /* Determine PRODUCT ID using MIPS_REVISION register * (special hw address reserved on Atlas, Malta, SEAD, SEAD-2 * boards). */ *(UINT32 *)param = (REGP(KSEG1BASE, MIPS_REVISION) & MIPS_REVISION_PROID_MSK) >> MIPS_REVISION_PROID_SHF; return OK;}/************************************************************************ * board_productrev_generic_read ************************************************************************/static UINT32board_productrev_generic_read( void *param, void *data, UINT32 size ){ /* Determine PRODUCT ID using MIPS_REVISION register * (special hw address reserved on Atlas, Malta, SEAD, SEAD-2 * boards). */ *(UINT32 *)param = (REGP(KSEG1BASE, MIPS_REVISION) & MIPS_REVISION_PRORV_MSK) >> MIPS_REVISION_PRORV_SHF; return OK;}/************************************************************************ * board_revision_generic_read ************************************************************************/static UINT32board_revision_generic_read( void *param, void *data, UINT32 size ){ /* Determine PRODUCT ID using MIPS_REVISION register * (special hw address reserved on Atlas, Malta, SEAD, SEAD-2 * boards). */ *(UINT32 *)param = REGP(KSEG1BASE, MIPS_REVISION); return OK;}/************************************************************************ * board_systemram_refresh_ns_sead_read ************************************************************************/static UINT32board_systemram_refresh_ns_sead_read( void *param, void *data, UINT32 size ){ UINT32 regval; regval = REG32(KSEG1(SEAD_SD_TREFRESH)); *(UINT32 *)param = CYCLES2NS( REGFIELD(regval, SEAD_SD_TREFRESH_TREF) ); return OK;}/************************************************************************ * board_systemram_refresh_ns_sead_write ************************************************************************/static UINT32board_systemram_refresh_ns_sead_write( void *param, void *data, UINT32 size ){ UINT32 refcount; NS2COUNT_ROUND_DOWN( *(UINT32 *)param, refcount ); REG32(KSEG1(SEAD_SD_TREFRESH)) = refcount; return OK;}/************************************************************************ * board_systemram_srasprchg_cycles_sead_read ************************************************************************/static UINT32board_systemram_srasprchg_cycles_sead_read( void *param, void *data, UINT32 size ){ UINT32 regval; regval = REG32(KSEG1(SEAD_SD_LATENCIES)); *(UINT32 *)param = REGFIELD(regval, SEAD_SD_LATENCIES_TRP); return OK;}/************************************************************************ * board_systemram_srasprchg_cycles_sead_write ************************************************************************/static UINT32board_systemram_srasprchg_cycles_sead_write( void *param, void *data, UINT32 size ){ UINT32 regval, trp; regval = REG32(KSEG1(SEAD_SD_LATENCIES)); if( *(UINT32 *)param < SEAD_SD_LATENCIES_TRP_MIN ) trp = SEAD_SD_LATENCIES_TRP_MIN; else if( *(UINT32 *)param > SEAD_SD_LATENCIES_TRP_MAX ) trp = SEAD_SD_LATENCIES_TRP_MAX; else trp = *(UINT32 *)param; regval &= ~SEAD_SD_LATENCIES_TRP_MSK; regval |= (trp << SEAD_SD_LATENCIES_TRP_SHF); REG32(KSEG1(SEAD_SD_LATENCIES)) = regval; return OK;}/************************************************************************ * board_systemram_sras2scas_cycles_sead_read ************************************************************************/static UINT32board_systemram_sras2scas_cycles_sead_read( void *param, void *data, UINT32 size ){ UINT32 regval; regval = REG32(KSEG1(SEAD_SD_LATENCIES)); *(UINT32 *)param = REGFIELD(regval, SEAD_SD_LATENCIES_TRCD); return OK;}/************************************************************************ * board_systemram_sras2scas_cycles_sead_write ************************************************************************/static UINT32board_systemram_sras2scas_cycles_sead_write( void *param, void *data, UINT32 size ){ UINT32 regval, trcd; regval = REG32(KSEG1(SEAD_SD_LATENCIES)); if( *(UINT32 *)param < SEAD_SD_LATENCIES_TRCD_MIN ) trcd = SEAD_SD_LATENCIES_TRCD_MIN; else if( *(UINT32 *)param > SEAD_SD_LATENCIES_TRCD_MAX ) trcd = SEAD_SD_LATENCIES_TRCD_MAX; else trcd = *(UINT32 *)param; regval &= ~SEAD_SD_LATENCIES_TRCD_MSK; regval |= (trcd << SEAD_SD_LATENCIES_TRCD_SHF); REG32(KSEG1(SEAD_SD_LATENCIES)) = regval; return OK;}/************************************************************************ * board_systemram_caslat_cycles_sead_read ************************************************************************/static UINT32board_systemram_caslat_cycles_sead_read( void *param, void *data, UINT32 size ){ UINT32 regval; regval = REG32(KSEG1(SEAD_SD_MRSCODE)); *(UINT32 *)param = REGFIELD(regval, SEAD_SD_MRSCODE_CL); return OK;}/************************************************************************ * board_systemram_read_burstlen_sead_read ************************************************************************/static UINT32board_systemram_read_burstlen_sead_read( void *param, void *data, UINT32 size ){ UINT32 regval; regval = REG32(KSEG1(SEAD_SD_MRSCODE)); switch( REGFIELD(regval, SEAD_SD_MRSCODE_BL ) ) { case 0 : *(UINT32 *)param = 1; break; case 1 : *(UINT32 *)param = 2; break; case 2 : *(UINT32 *)param = 4; break; case 3 : *(UINT32 *)param = 8; break; default : /* Should not happen */ return ERROR_SYSCON_UNKNOWN_PARAM; } return OK;}/************************************************************************ * board_systemram_write_burstlen_sead_read ************************************************************************/static UINT32board_systemram_write_burstlen_sead_read( void *param, void *data, UINT32 size ){ UINT32 regval; regval = REG32(KSEG1(SEAD_SD_MRSCODE)); switch( REGFIELD(regval, SEAD_SD_MRSCODE_WBL) ) { case 0 : return board_systemram_read_burstlen_sead_read( param, data, size ); case 1 : *(UINT32 *)param = 1; break; default : /* Should not happen */ return ERROR_SYSCON_UNKNOWN_PARAM; } return OK;}/************************************************************************ * com_en0_major_device_atlas_read ************************************************************************/static UINT32com_en0_major_device_atlas_read( void *param, void *data, UINT32 size ){ /* 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 UINT32com_en0_major_device_malta_read( void *param, void *data, UINT32 size ){ /* 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_intline_atlas_read ************************************************************************/static UINT32com_en0_intline_atlas_read( void *param, void *data, UINT32 size )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -