Home | History | Annotate | Line # | Download | only in isa
      1 /*	$NetBSD: weaselreg.h,v 1.8 2022/04/11 20:57:38 andvar Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2000 Zembu Labs, Inc.
      5  * All rights reserved.
      6  *
      7  * Author: Jason R. Thorpe <thorpej (at) zembu.com>
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *	This product includes software developed by Zembu Labs, Inc.
     20  * 4. Neither the name of Zembu Labs nor the names of its employees may
     21  *    be used to endorse or promote products derived from this software
     22  *    without specific prior written permission.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY ZEMBU LABS, INC. ``AS IS'' AND ANY EXPRESS
     25  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR-
     26  * RANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS-
     27  * CLAIMED.  IN NO EVENT SHALL ZEMBU LABS BE LIABLE FOR ANY DIRECT, INDIRECT,
     28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     29  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     33  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     34  */
     35 
     36 /*
     37  * Register and firmware communication definitions for the
     38  * Middle Digital, Inc. PC-Weasel serial console board.
     39  */
     40 
     41 /*
     42  * Current versions of the PC-Weasel emulate a Monochrome Display
     43  * Adapter.  The framebuffer is at the standard ISA framebuffer
     44  * location (0xb0000).  At the end of the viewable framebuffer area
     45  * is a control register space.
     46  */
     47 
     48 #define	WEASEL_WDT_SEMAPHORE		0x0fa0
     49 
     50 #define	WEASEL_CONFIG_BLOCK		0x0fa1
     51 
     52 #define WEASEL_WDT_TICKLE		0x0fa2
     53 
     54 #define	WEASEL_MISC_COMMAND		0x0fcd
     55 
     56 #define	WEASEL_MISC_RESPONSE		0x0fce
     57 
     58 /*
     59  * Layout of the PC-Weasel configuration block.  This is taken
     60  * more or less right out of the PC-Weasel manual, page 52.
     61  */
     62 struct weasel_config_block {
     63 	u_int8_t	cfg_version;	/* configuration version */
     64 
     65 #define	CFG_VERSION_1_0		0x01
     66 #define	CFG_VERSION_1_1		0x02
     67 
     68 	u_int8_t	weasel_attn;	/* Weasel attention character */
     69 	u_int8_t	debug;		/* debug level */
     70 	u_int8_t	reset_pc_on_boot;/* reset PC on Weasel boot */
     71 	u_int8_t	duart_baud;	/* baud rate of DUART */
     72 	u_int8_t	duart_parity;	/* 0 none, 1 even, 2 odd */
     73 	u_int8_t	duart_bits;	/* 7 or 8 */
     74 
     75 	/*
     76 	 * Unfortunately, between cfg_version 1 and 2, the semantics
     77 	 * of this variable changed.
     78 	 *
     79 	 *	cfg_version 1:
     80 	 *
     81 	 *		0 == always emulate
     82 	 *		1 == autoswitch
     83 	 *
     84 	 *	cfg_version 2:
     85 	 *
     86 	 *		0 == always emulate
     87 	 *		1 == always serial
     88 	 *		2 == autoswitch
     89 	 */
     90 	u_int8_t	enable_duart_switching;
     91 	u_int8_t	wdt_allow;	/* 0 disable, 1 allow */
     92 	u_int16_t	wdt_msec;	/* watchdog timer period */
     93 	u_int8_t	duart_flow;	/* 1 rts/cts, 0 none */
     94 	u_int8_t	break_passthru;	/* BREAK is passed through */
     95 	u_int8_t	obsolete[30];	/* reserved for future use */
     96 	u_int8_t	cksum;		/* arithmetic sum -> reserved */
     97 } __packed;
     98 
     99 /*
    100  * Commands that can be written to the MISC_COMMAND register.
    101  */
    102 
    103 #define	OS_READY	0x00		/* ready for commands */
    104 
    105 #define	OS_UART_CLEAR	0x01		/* clear response for OS_UART_QUERY */
    106 
    107 #define	OS_UART_QUERY	0x02		/* query Weasel UART setting */
    108 #define	UART_QUERY_DIS	0x00		/* UART is disabled */
    109 #define	UART_QUERY_3f8	0x01		/* UART at 0x3f8 */
    110 #define	UART_QUERY_2F8	0x02		/* UART at 0x2f8 */
    111 #define	UART_QUERY_3e8	0x03		/* UART at 0x3e8 */
    112 #define	UART_QUERY_2e8	0x04		/* UART at 0x2e8 */
    113 
    114 #define	OS_CONFIG_COPY	0x03		/* copy config to offscreen space */
    115 #define OS_WDT_QUERY    0x04		/* query watchdog state. 0=off 1=on */
    116 
    117 #define	OS_NOP		0x07
    118 
    119 /*
    120  * The watchdog timer on the PC-Weasel is enabled/disabled (it's a toggle)
    121  * using the WDT_SEMAPHORE register in the offscreen area.  The semaphore
    122  * is also used to service the watchdog.
    123  *
    124  * To toggle the watchdog:
    125  *
    126  *	for (new_state = old_state; new_state == old_state;) {
    127  *		WDT_SEMAPHORE = 0x22;
    128  *		delay(1500);
    129  *		if (WDT_SEMAPHORE == 0xea) {
    130  *			WDT_SEMAPHORE = 0x2f;
    131  *			delay(1500);
    132  *			if (WDT_SEMAPHORE == 0xae) {
    133  *				WDT_SEMAPHORE = 0x37;
    134  *				delay(1500);
    135  *				new_state = WDT_SEMAPHORE;
    136  *			}
    137  *		}
    138  *	}
    139  *
    140  * To service the watchdog when armed:
    141  *
    142  *	tmp = WDT_SEMPAPHORE;
    143  *	WDT_SEMAPHORE ~= tmp;
    144  */
    145 #define WDT_ATTENTION   0x22    /* get the attention of the WDT state engine */
    146 #define WDT_OK          0xae    /* we get back an acknowledgement */
    147 #define WDT_ENABLE      0xf1    /* the command to arm to watchdog. */
    148 #define WDT_DISABLE     0xf4    /* the command to disarm the watchdog. */
    149 
    150