/******************************************************************************
 *
 *	AM160ED (SHARK CCA) DEFINTION FILE
 *
 * @(#)Copyright (C) 1991 National Semiconductor Corp.
 *
 * This module contains the constants which define the AM160ED board.
 *
 * NOTE: It should not contain definition of any variables, since it is 
 *       included by the drivers too!
 *
 * History:
 *   +----------+------------+------------------------------------------------+
 *   |   Date   |     by     |     Description                                |
 *   +----------+------------+------------------------------------------------+
 *   |          | Gary       | Written                                        |
 *   +----------+------------+------------------------------------------------+
 *
 *****************************************************************************/
/*****************************************************************************
 *
 *  The following definition are used in CMON.
 *  They MUST apear in any board definition file.
 *
 *****************************************************************************/
 
#   define CPU_TYPE NS32AM160
#   define FPU_TYPE NOFPU
#   define ICU_TYPE PARROT_ICU
#   define BUSWIDTH	2	    /* bytes */
#   define ROM_BUSWIDTH	2
#   define MON_NAME "CMONAM160"
#   define VERSION  "4"
#   define REVISION "4"
#   define BOARD AM160ED


#   define UART_TYPE      NS16550
#ifndef DEBUG
#   define UART_0_ADDR    0x3F880
#   define UART_1_ADDR    0x3F800
#else
#   define UART_0_ADDR    0x3F800
#   define UART_1_ADDR    0x3F880
#endif

#   define SERIAL_FILE    "ns16550.h"
#   define UART_BUS_OFFSET   16
#   define DRAM_START     0x2000000
#   define DRAM_OFFSET    2

#   define LAST_ELEMENT   0x969696
#   define SRAM_START     0x0 
#   define SRAM_START1    LAST_ELEMENT
#   define SRAM_START2    LAST_ELEMENT
#   define SRAM_START3    LAST_ELEMENT


#   define DEMO_ON          (BIT_ON(6,  DIP_SWITCH)) 
#   define DEMO_ADDR        0x48000

#   define   ROM_START 0x40000  /* begin address of rom */
#   define   ROM_SIZE  0x40000	   /*  for 2 128k EPROMs  */



/****************************************************************************
 *
 *  Assembly macroes
 *
 ****************************************************************************/

#   define SHADOW_SELECT                     0x3F000
#ifdef ASEM
   .macro TURN_OFF_SHADOW	   
	movqw	    $0x0, SHADOW_SELECT
	movd $100000,   r7               # Wait after reset
        delay0: acbd $-1,   r7,   delay0
   .endm
#endif
#   define JMP_TO_DIAGNOS	bne _start_pu__

/*
 *  Baud rate conversion table.  Setting of SW1 bits 0-3 serve
 *  as index into table.  Table holds value to be loaded into 
 *  16552 divisor latches.  UART master clock = 18.432 MHz.
 *  divisor # = (Frequency input) / baud-rate * 16
 *  For example :    divisor # =	( 18432000 ) /	9600 * 16 = 120
 *
 *  The setting of '0000' in the least significant bits of the
 *  configuration switch is a special case.  This will indicate
 *  that the ethernet board is active and the two serial channels
 *  are set for 9600 baud operation.
 */

#   define BOARD_COM_MODE	RS232
#   define UART_DIVISOR  uart_table[ \
                            ((unsigned int) DIP_SWITCH) & 0x7].divisor
#   define UART_INIT_TABLE const uart_table_entry uart_table[] = \
                            { {9600, 120} \
			    , {9600, 120} \
			    , {38400, 30}\
			    , {19200, 60}\
			    , {9600, 120} \
			    , {4800, 240}\
			    , {2400, 480}\
			    , {1200, 920}\
			    , {0, 0} }; 
 

/****************************************************************************
 *
 * Diagnostic macros and definitions 
 *  This part is  ifdefed DIAG 
 *
 ****************************************************************************/

#	define INIT_LCD
#	define PRINT_LCD(str)     /* macro to output string to LCD or alike. */
#	define PRINT_LED(num)     /* macro to output number to 7-SEGMENT-LED */
                                  /* or a like				     */

/**************************************************************************
 *
 * initialized const data definitions
 *
 *************************************************************************/
 
#ifdef DIAG_MAIN

extern	char *test_cpu__(), *test_16550__(), *test_eprom__(), 
	     *test_dram__(),*test_sram__(),*test_led__();

const struct diag_desc diag_test_list__[] = {
		{" CPU TEST",		test_cpu__,	TRUE},
		{" SRAM TEST",		test_sram__,	TRUE},
		{" DRAM TEST",		test_dram__,	TRUE},
		{" SERIAL I/O TEST", 	test_16550__,	TRUE},
		{" EPROM TEST",		test_eprom__,	TRUE},
		{" LED TEST",		test_led__,	FALSE},
		{0, 0, 0}
		};


#endif /* DIAG_MAIN */

/****************************************************************************
 *
 *  misc. I/O in register 
 *
 ****************************************************************************/

#   define   NO_UART_INT 		/* uart interrupt test disable	*/

#   define   DIP_SWITCH_ADD  0x3F900 	/* configuration dip switch	*/ 
#   define   DIP_SWITCH        (*((volatile byte *) DIP_SWITCH_ADD))	

#    define   LED_PORT_ADD   0x3F700 	/* seven segment LED		*/ 
#    define   LED_PORT          (*((volatile byte *) LED_PORT_ADD))	

#    define   IMASK_ADD		   
#    define   IMASK		(* ((volatile byte  *) IMASK_ADD))


/****************************************************************************
 *
 * Board intialization and interface  macros.
 *
 ****************************************************************************/

#ifdef ASEM
#    define LED(X)	movb	$X, 	@LED_PORT_ADD
#else
#    define LED(X)	LED_PORT = (X)
#endif


#   define    LED_0	0xc0            /*       0	*/
#   define    LED_1	0xf9            /*       1	*/
#   define    LED_2	0xa4            /*       2	*/
#   define    LED_3	0xb0            /*       3	*/
#   define    LED_4	0x99            /*       4	*/
#   define    LED_5	0x92            /*       5	*/
#   define    LED_6	0x82            /*       6	*/
#   define    LED_7	0xf8            /*       7	*/
#   define    LED_8	0x80            /*       8	*/
#   define    LED_9	0x90            /*       9	*/
#   define    LED_A	0x88            /*       A	*/
#   define    LED_B	0x83            /*       B	*/
#   define    LED_C	0xc6            /*       C	*/
#   define    LED_D	0xa1            /*       D	*/
#   define    LED_E	0x86            /*       E	*/
#   define    LED_F	0x8e            /*       F	*/
#   define    LED_P     0x8c            /*       P      */
