📄 init.c
字号:
/*
** WASABI-Hot! version 1.2c
**
**
** -- copyright (c) 2001-2004 by Philips Japan, Ltd. -- All rights reserved --
**
**
** ** This code has been made to check/learn **
** ** the ISP1362/ISP1363 functionalities **
** ** Release 06-Aug-2004 **
**
** OKANO, Akifumi
**
** Application Laboratory, Mobile and Connectivity
** Semiconductors Div, Philips Japan Ltd.
** akifumi.okano@philips.com
** +81-3-3740-4668
*/
// 02-Sep-2003 : ISP1363 support added
/****************************************************************************/
/* includes */
/****************************************************************************/
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include "general.h"
#include "ui.h"
#include "_hc_core/atl_mix.h"
#include "_hc_core/init.h"
#include "_hc_core/isr.h"
#include "_hc_core/port_ctl.h"
#include "_hc_hw/hc_comm.h"
#include "_hc_hw/hw_acces.h"
#include "_hc_cls/cls_hndl.h"
#include "_dc/dc_comm.h"
/****************************************************************************/
/* constants */
/****************************************************************************/
#define ISP1362_REVISION_ID_ES1 0x21
#define ISP1362_REVISION_ID_ES2 0x22
#define ISP1362_REVISION_ID_ES3 0x23
#define ISP1362_REVISION_ID_ES4 0x30 //
#define ISP1362_REVISION_ID_ES5 0x31
//#define ISP1362_REVISION_ID_ES5 0x30 // ES6 has same ID as ES4
#define ISP1363_REVISION_ID_ES1 1
#define ISP1362_NO_VERSION_DISPLAY 6
#define ISP1363_NO_VERSION_DISPLAY 10
/****************************************************************************/
/* global vars */
/****************************************************************************/
char *gp_host_name[] = {
"ISP1362 ver ? ", // 0
"ISP1362 ES1 ", // 1
"ISP1362 ES2 ", // 2
"ISP1362 ES3 ", // 3
"ISP1362 ES4/ES6", // 4 and 6 (ES6 has same ID as ES4)
"ISP1362 ES5 ", // 5
"ISP1362 ", // 6
"", // 7
"ISP1363 ver ? ", // 8
"ISP1363 ES1 ", // 9
"ISP1363 " // 10
};
unsigned char gp_chip_version_index;
unsigned char gp_version_display = Disabled;
unsigned char gp_is_in_DOS_environment = Enabled;
isrPtr old_vector;
/****************************************************************************/
/* function prototypes */
/****************************************************************************/
void software_reset( void );
unsigned char detect_1362_connected( unsigned short *chip_id_ptr );
void set_register_values( void );
void set_1362_interrupt_start( void );
void quit( void );
/****************************************************************************/
/* function definitions */
/****************************************************************************/
void init_HC_initialize( void ) // HC initializations
{
//
// Software internal initializations
//
clshndl_initialization_method_install(); // Install class drivers
devep_device_list_linitialize(); // Clear the list that holds device information
//
// Hardware related initializations
//
software_reset(); // Reset HC
atlmix_buffer_setting( InitVal_HcISTLBufferSize, InitVal_HcINTLBlkSize, INTL_NUM_OF_BLKs, InitVal_HcATLBlkSize );
// Set 1362 internal RAM configurations
set_register_values(); // Set all registers for operation
old_vector = hwacces_install_isr( gp_Hc_IRQ_num, isr_isr_USB_Hc ); // Install ISR
set_1362_interrupt_start(); // Start HC operation
}
void software_reset( void ) // Reset HC
{
write_register16( Com16_HcSoftwareReset, 0x00F6 );
}
void init_chip_software_reset( void ) // Reset whole 1362 (HC and DC)
{
write_register16( Com16_HcSoftwareReset, 0x00F6 );
Comm_w16( Unlock_Device, 0xAA37);
Comm(Reset_Device);
}
void init_check_1362_connection( void ) // Check 1362 is present
{
unsigned short chip_id;
//
// Check 1362 register access
//
if ( !detect_1362_connected( &chip_id ) )
{
mprintf( LIGHTRED, CONTINUE, "\r\n\r\nError @ chip detection : " );
mprintf( LIGHTCYAN, CONTINUE, "This may not be ISP1362 or ISP1363.\r\n" );
mprintf( LIGHTCYAN, CONTINUE, " (detected ChipID = 0x%04X)\r\n\r\n", chip_id );
mprintf( LIGHTRED, CONTINUE, " IO-base = 0x%04X\r\n\r\n", (unsigned short)(gp_ISA_base_address & 0x0000FFFF) );
mprintf( LIGHTGRAY, ABORT, "1362/1363 is not present!\r\n" );
}
//
// Show the hardware information on the screen
//
if ( gp_version_display )
{
mprintf( LIGHTGRAY, CONTINUE, " >>> ChipID = 0x%04X : ", chip_id );
}
else
{
if ( !(gp_chip_version_index & 0x8) )
{
//
// For ISP1362
//
gp_chip_version_index = ISP1362_NO_VERSION_DISPLAY;
mprintf( LIGHTGRAY, CONTINUE, " >>> ChipID = 0x%02XXX : ", chip_id >> 8 );
}
else
{
//
// For ISP1363
//
gp_chip_version_index = ISP1363_NO_VERSION_DISPLAY;
mprintf( LIGHTGRAY, CONTINUE, " >>> ChipID = 0xX%03X : ", chip_id & 0x0FFF );
}
}
mprintf( LIGHTCYAN, CONTINUE, "%s", gp_host_name[ gp_chip_version_index ] );
mprintf( LIGHTGRAY, CONTINUE, " <<<\r\n" );
mprintf( LIGHTGRAY, CONTINUE, " 1362 I/O base address=0x%04X (on %s) ", hwacces_get_ISA_base_address(), gp_is_PCI ? "PCI" : "ISA" );
mprintf( LIGHTGRAY, CONTINUE, "Hc-IRQ=%d ", gp_Hc_IRQ_num );
mprintf( LIGHTGRAY, CONTINUE, "Dc-IRQ=%d\r\n", gp_Dc_IRQ_num );
mprintf( LIGHTGRAY, CONTINUE, "\r\n" );
}
unsigned char detect_1362_connected( unsigned short *chip_id_ptr ) // Check 1362 register access
{
unsigned short tmp;
////////////////////////////////////////////////////
// Chip ID detection for "ISP1362" and "ISP1363" //
////////////////////////////////////////////////////
//
// For ISP1362 : ChipID value should be 0x36XX
//
*chip_id_ptr = read_register16( Com16_HcChipID );
if ( (*chip_id_ptr & 0xFF00) == 0x3600 )
{
if ( (*chip_id_ptr & 0x00FF) == ISP1362_REVISION_ID_ES1 )
gp_chip_version_index = 1;
else if ( (*chip_id_ptr & 0x00FF) == ISP1362_REVISION_ID_ES2 )
gp_chip_version_index = 2;
else if ( (*chip_id_ptr & 0x00FF) == ISP1362_REVISION_ID_ES3 )
gp_chip_version_index = 3;
else if ( (*chip_id_ptr & 0x00FF) == ISP1362_REVISION_ID_ES4 )
gp_chip_version_index = 4;
else if ( (*chip_id_ptr & 0x00FF) == ISP1362_REVISION_ID_ES5 )
gp_chip_version_index = 5;
else
gp_chip_version_index = 0;
}
//
// For ISP1363 : ChipID value should be 0xX363
//
else if ( (*chip_id_ptr & 0x0FFF) == 0x0363 )
{
if ( (*chip_id_ptr >> 12) == ISP1363_REVISION_ID_ES1 )
gp_chip_version_index = 1;
else
gp_chip_version_index = 0;
gp_chip_version_index |= 0x8;
}
else
{
return ( False );
}
if ( gp_chip_version_index <= 2 )
mprintf( LIGHTRED, CONTINUE, " *** Warning : This code may have problem with ES2 or earlier chip. *** \r\n" );
//
// write-read test using scratch register
//
tmp = 0x55AA; // pattern of "0101 1010"
write_register16( Com16_HcScratch, tmp );
if ( tmp != read_register16( Com16_HcScratch ) )
return ( False );
tmp = ~tmp; // check again with inverted pattern
write_register16( Com16_HcScratch, tmp );
if ( tmp != read_register16( Com16_HcScratch ) )
return ( False );
//
// chip exists!
//
return ( True );
}
void set_register_values( void ) // Set all registers for operation
{
////////////////////////////////////////////////////////////////////////////////
// //
// The values difined as "InitVal_Hc..." can be found in "_hc_core/init.h" //
// //
////////////////////////////////////////////////////////////////////////////////
unsigned short init_value_for_HcHardwareConfiguration;
init_value_for_HcHardwareConfiguration = InitVal_HcHardwareConfiguration & (gp_is_PCI ? ~0x4 : ~0x0 );
//
// disable and clear host controller interrupts
//
write_register32( Com32_HcInterruptDisable, InitVal_HcInterruptDisable );
write_register32( Com32_HcInterruptStatus, InitVal_HcHcInterruptStatus );
//
// set hardware configurations
//
write_register32( Com32_HcFmInterval, InitVal_HcFmInterval );
write_register16( Com16_HcHardwareConfiguration, init_value_for_HcHardwareConfiguration );
write_register16( 0x62, 0x00C0 );
//
// put host controller into USB_RESET state
//
write_register32( Com32_HcControl, InitVal_HcControl );
//
// enable interrupt
//
write_register16( Com16_HcuPInterruptEnable, InitVal_HcuPInterruptEnable );
write_register32( Com32_HcInterruptEnable, InitVal_HcInterruptEnable );
//
// enter to USB_OPERATIONAL state
//
write_register32( Com32_HcControl, InitVal_HcControl | 0x680 );
//
// set root hub registers
//
write_register32( Com32_HcRhDescriptorA, InitVal_HcRhDescriptorA );
write_register32( Com32_HcRhDescriptorB, InitVal_HcRhDescriptorB );
write_register32( Com32_HcRhStatus, InitVal_HcRhStatus );
write_register32( Com32_HcRhPortStatus1, InitVal_HcRhPortStatus1 );
write_register32( Com32_HcRhPortStatus2, InitVal_HcRhPortStatus2 );
}
void set_1362_interrupt_start( void ) // HC interrupt enable
{
gp_hardware_configuration_setting = read_register16( Com16_HcHardwareConfiguration );
write_register32( Com32_HcInterruptEnable, InitVal_HcInterruptEnable );
write_register16( Com16_HcuPInterruptEnable, InitVal_HcuPInterruptEnable );
write_register16( Com16_HcHardwareConfiguration, ( gp_hardware_configuration_setting | 0x0001 ) );
gp_isr_flag = 0x0000 | RHSC;
}
void quit( void ) // Processing for quitting application
{
hwacces_restore_isr( gp_Hc_IRQ_num, (void interrupt (*)())old_vector );
mprintf( LIGHTGRAY, CONTINUE, "\r\n\r\nWASABI-Hot! \r\n" );
mprintf( LIGHTGRAY, CONTINUE, "\r\n" );
mprintf( LIGHTGRAY, CONTINUE, "\r\n" );
mprintf( LIGHTCYAN, CONTINUE, " ..........bye!" );
mprintf( LIGHTGRAY, CONTINUE, "\r\n" );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -