Home | History | Annotate | Line # | Download | only in sparc
      1 /*	$NetBSD: auxreg.h,v 1.14 2012/07/29 00:04:05 matt Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1992, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This software was developed by the Computer Systems Engineering group
      8  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      9  * contributed to Berkeley.
     10  *
     11  * All advertising materials mentioning features or use of this software
     12  * must display the following acknowledgement:
     13  *	This product includes software developed by the University of
     14  *	California, Lawrence Berkeley Laboratory.
     15  *
     16  * Redistribution and use in source and binary forms, with or without
     17  * modification, are permitted provided that the following conditions
     18  * are met:
     19  * 1. Redistributions of source code must retain the above copyright
     20  *    notice, this list of conditions and the following disclaimer.
     21  * 2. Redistributions in binary form must reproduce the above copyright
     22  *    notice, this list of conditions and the following disclaimer in the
     23  *    documentation and/or other materials provided with the distribution.
     24  * 3. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  *	@(#)auxreg.h	8.1 (Berkeley) 6/11/93
     41  */
     42 
     43 /*
     44  * Sun-4c Auxiliary I/O register.  This register talks to the floppy
     45  * (if it exists) and the front-panel LED.
     46  */
     47 
     48 #define	AUXIO4C_MB1	0xf0		/* must be set on write */
     49 #define	AUXIO4C_FHD	0x20		/* floppy: high density (unreliable?)*/
     50 #define	AUXIO4C_FDC	0x10		/* floppy: diskette was changed */
     51 #define	AUXIO4C_FDS	0x08		/* floppy: drive select */
     52 #define	AUXIO4C_FTC	0x04		/* floppy: drives Terminal Count pin */
     53 #define	AUXIO4C_FEJ	0x02		/* floppy: eject disk */
     54 #define	AUXIO4C_LED	0x01		/* front panel LED */
     55 
     56 #define	AUXIO4M_MB1	0xc0		/* must be set on write? */
     57 #define	AUXIO4M_FHD	0x20		/* floppy: high density (unreliable?)*/
     58 #define	AUXIO4M_LTE	0x08		/* link-test enable */
     59 					/* power up modem in SPARCbook 3GX */
     60 
     61 #define	AUXIO4M_MMX	0x04		/* Monitor/Mouse MUX; what is it? */
     62 					/* power up DBRI in SPARCbook 3GX */
     63 
     64 #define	AUXIO4M_FTC	0x02		/* floppy: drives Terminal Count pin */
     65 #define	AUXIO4M_LED	0x01		/* front panel LED */
     66 
     67 /*
     68  * We use a fixed virtual address for the register because we use it for
     69  * timing short sections of code (via external hardware attached to the LED).
     70  */
     71 #define	AUXIO4C_REG	((volatile u_char *)(AUXREG_VA + 3))
     72 #define	AUXIO4M_REG	((volatile u_char *)(AUXREG_VA))
     73 
     74 #define LED_ON		do {						\
     75 	if (CPU_ISSUN4M) {						\
     76 		auxio_regval |= AUXIO4M_LED;				\
     77 		*AUXIO4M_REG = auxio_regval;				\
     78 	} else {							\
     79 		auxio_regval |= AUXIO4C_LED;				\
     80 		*AUXIO4C_REG = auxio_regval;				\
     81 	}								\
     82 } while(0)
     83 
     84 #define LED_OFF		do {						\
     85 	if (CPU_ISSUN4M) {						\
     86 		auxio_regval &= ~AUXIO4M_LED;				\
     87 		*AUXIO4M_REG = auxio_regval;				\
     88 	} else {							\
     89 		auxio_regval &= ~AUXIO4C_LED;				\
     90 		*AUXIO4C_REG = auxio_regval;				\
     91 	}								\
     92 } while(0)
     93 
     94 #define LED_FLIP	do {						\
     95 	if (CPU_ISSUN4M) {						\
     96 		auxio_regval ^= AUXIO4M_LED;				\
     97 		*AUXIO4M_REG = auxio_regval;				\
     98 	} else {							\
     99 		auxio_regval ^= AUXIO4C_LED;				\
    100 		*AUXIO4C_REG = auxio_regval;				\
    101 	}								\
    102 } while(0)
    103 
    104 #define FTC_FLIP	do {						\
    105 	if (CPU_ISSUN4M) {						\
    106 		/* AUXIO4M_FTC bit is auto-clear */			\
    107 		*AUXIO4M_REG = auxio_regval | AUXIO4M_FTC;		\
    108 		/* XXX we need to clear it on hyperSPARC SS20 */	\
    109 		DELAY(10);						\
    110 		*AUXIO4M_REG = auxio_regval;				\
    111 	} else {							\
    112 		auxio_regval |= AUXIO4C_FTC;				\
    113 		*AUXIO4C_REG = auxio_regval;				\
    114 		DELAY(10);						\
    115 		auxio_regval &= ~AUXIO4C_FTC;				\
    116 		*AUXIO4C_REG = auxio_regval;				\
    117 	}								\
    118 } while(0)
    119 
    120 #define	AUXIO_BITS	(						\
    121 	CPU_ISSUN4M							\
    122 		? "\20\6FHD\4LTE\3MMX\2FTC\1LED"			\
    123 		: "\20\6FHD\5FDC\4FDS\3FTC\2FEJ\1LED"			\
    124 )
    125 
    126 #ifndef _LOCORE
    127 extern volatile u_char *auxio_reg;	/* Copy of AUXIO_REG */
    128 extern u_char auxio_regval;
    129 unsigned int auxregbisc(int, int);
    130 #endif
    131