Home | History | Annotate | Line # | Download | only in dev
      1  1.8  tsutsui /*	$NetBSD: dioreg.h,v 1.8 2011/03/06 14:51:21 tsutsui Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej /*-
      4  1.1  thorpej  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5  1.1  thorpej  * All rights reserved.
      6  1.1  thorpej  *
      7  1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  thorpej  * by Jason R. Thorpe.
      9  1.1  thorpej  *
     10  1.1  thorpej  * Portions of this file are derived from software contributed to Berkeley
     11  1.1  thorpej  * by the Systems Programming Group of the University of Utah Computer
     12  1.1  thorpej  * Science Department.
     13  1.1  thorpej  *
     14  1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     15  1.1  thorpej  * modification, are permitted provided that the following conditions
     16  1.1  thorpej  * are met:
     17  1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     18  1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     19  1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     20  1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     21  1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     22  1.1  thorpej  *
     23  1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     24  1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     25  1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     26  1.8  tsutsui  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     27  1.4      jtc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28  1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29  1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30  1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31  1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32  1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33  1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     34  1.1  thorpej  */
     35  1.1  thorpej 
     36  1.1  thorpej /*
     37  1.1  thorpej  * Register definitions for the DIO and DIO-II bus.
     38  1.1  thorpej  */
     39  1.1  thorpej 
     40  1.1  thorpej /*
     41  1.1  thorpej  * DIO/DIO-II device registers, offsets from base of device.  All
     42  1.1  thorpej  * registers are 8-bit.
     43  1.1  thorpej  */
     44  1.1  thorpej #define	DIO_IDOFF		0x01	/* primary device id */
     45  1.1  thorpej #define	DIO_IPLOFF		0x03	/* interrupt level */
     46  1.1  thorpej #define DIO_SECIDOFF		0x15	/* secondary device id */
     47  1.1  thorpej #define	DIOII_SIZEOFF		0x101	/* device size */
     48  1.1  thorpej 
     49  1.1  thorpej /*
     50  1.1  thorpej  * System physical addresses of some `special' DIO devices.
     51  1.1  thorpej  */
     52  1.1  thorpej #define	DIO_IHPIBADDR		0x478000 /* internal HP-IB; select code 7 */
     53  1.1  thorpej 
     54  1.1  thorpej /*
     55  1.1  thorpej  * DIO ranges from select codes 0-63 at physical addresses given by:
     56  1.1  thorpej  *	0x600000 + (sc - 32) * 0x10000
     57  1.1  thorpej  * DIO cards are addressed in the range 0-31 [0x600000-0x800000) for
     58  1.1  thorpej  * their control space and the remaining areas, [0x200000-0x400000) and
     59  1.1  thorpej  * [0x800000-0x1000000), are for additional space required by a card;
     60  1.1  thorpej  * e.g. a display framebuffer.
     61  1.1  thorpej  *
     62  1.1  thorpej  * DIO-II ranges from select codes 132-255 at physical addresses given by:
     63  1.8  tsutsui  *	0x1000000 + (sc - 132) * 0x400000
     64  1.1  thorpej  * The address range of DIO-II space is thus [0x1000000-0x20000000).
     65  1.8  tsutsui  *
     66  1.1  thorpej  * DIO/DIO-II space is too large to map in its entirety, instead devices
     67  1.1  thorpej  * are mapped into kernel virtual address space allocated from a range
     68  1.1  thorpej  * of EIOMAPSIZE pages (vmparam.h) starting at ``extiobase''.
     69  1.1  thorpej  */
     70  1.1  thorpej #define	DIO_BASE		0x600000	/* start of DIO space */
     71  1.1  thorpej #define	DIO_END			0x1000000	/* end of DIO space */
     72  1.1  thorpej #define	DIO_DEVSIZE		0x10000		/* size of a DIO device */
     73  1.1  thorpej 
     74  1.1  thorpej #define	DIOII_BASE		0x01000000	/* start of DIO-II space */
     75  1.1  thorpej #define	DIOII_END		0x20000000	/* end of DIO-II space */
     76  1.1  thorpej #define	DIOII_DEVSIZE		0x00400000	/* size of a DIO-II device */
     77  1.1  thorpej 
     78  1.1  thorpej /*
     79  1.1  thorpej  * Find the highest select code for a given machine; HP320 doesn't
     80  1.1  thorpej  * have DIO-II.
     81  1.1  thorpej  */
     82  1.1  thorpej #define	DIO_SCMAX(machineid)	((machineid) == HP_320 ? 32 : 256)
     83  1.1  thorpej 
     84  1.1  thorpej /*
     85  1.2  thorpej  * Base of DIO-II select codes.
     86  1.2  thorpej  */
     87  1.2  thorpej #define	DIOII_SCBASE		132
     88  1.2  thorpej 
     89  1.2  thorpej /*
     90  1.1  thorpej  * Macro that returns true if a select code lies within
     91  1.1  thorpej  * the select code `hole'.
     92  1.1  thorpej  */
     93  1.1  thorpej #define	DIO_INHOLE(scode)	((scode) >= 32 && (scode) < 132)
     94  1.1  thorpej 
     95  1.1  thorpej /*
     96  1.1  thorpej  * Macros to determine if device is DIO or DIO-II.
     97  1.1  thorpej  */
     98  1.1  thorpej #define	DIO_ISDIO(scode)	((scode) >= 0 && (scode) < 32)
     99  1.2  thorpej #define	DIO_ISDIOII(scode)	((scode) >= DIOII_SCBASE && (scode) < 256)
    100  1.1  thorpej 
    101  1.1  thorpej /*
    102  1.1  thorpej  * Macro to determine if device is a framebuffer, given the
    103  1.1  thorpej  * primary id of the device.  We key off this to determine if
    104  1.1  thorpej  * we should look at secondary id and ignore interrupt level.
    105  1.1  thorpej  */
    106  1.1  thorpej #define	DIO_ISFRAMEBUFFER(id)		\
    107  1.1  thorpej 	((id) == DIO_DEVICE_ID_FRAMEBUFFER)
    108  1.1  thorpej 
    109  1.1  thorpej /*
    110  1.1  thorpej  * Macro to extract primary and decondary device ids, given
    111  1.1  thorpej  * the base address of the device.
    112  1.1  thorpej  */
    113  1.1  thorpej #define	DIO_ID(base)			\
    114  1.5  tsutsui 	(*((uint8_t *)((u_long)(base) + DIO_IDOFF)))
    115  1.1  thorpej #define	DIO_SECID(base)			\
    116  1.5  tsutsui 	(*((uint8_t *)((u_long)(base) + DIO_SECIDOFF)))
    117  1.1  thorpej 
    118  1.1  thorpej /*
    119  1.1  thorpej  * Macro to extract the interrupt level, given the
    120  1.1  thorpej  * base address of the device.
    121  1.1  thorpej  */
    122  1.1  thorpej #define	DIO_IPL(base)			\
    123  1.5  tsutsui 	((((*((uint8_t *)((u_long)(base) + DIO_IPLOFF))) >> 4) & 0x03) + 3)
    124  1.1  thorpej 
    125  1.1  thorpej /*
    126  1.1  thorpej  * Macro to compute the size of a DIO-II device's address
    127  1.1  thorpej  * space, given the base address of the device.
    128  1.1  thorpej  */
    129  1.1  thorpej #define DIOII_SIZE(base)		\
    130  1.5  tsutsui 	((int)((*((uint8_t *)((u_long)(base) + DIOII_SIZEOFF)) + 1)	\
    131  1.1  thorpej 	    * 0x100000))
    132  1.1  thorpej 
    133  1.1  thorpej /*
    134  1.1  thorpej  * Given a select code and device base address, compute
    135  1.1  thorpej  * the size of the DIO/DIO-II device.
    136  1.1  thorpej  */
    137  1.1  thorpej #define	DIO_SIZE(scode, base)		\
    138  1.1  thorpej 	(DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE)
    139