Home | History | Annotate | Line # | Download | only in dev
intiovar.h revision 1.1.2.1
      1 /*	$NetBSD: intiovar.h,v 1.1.2.1 1998/12/23 16:47:29 minoura Exp $	*/
      2 
      3 /*
      4  *
      5  * Copyright (c) 1998 NetBSD Foundation, Inc.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *      This product includes software developed by Charles D. Cranor and
     19  *      Washington University.
     20  * 4. The name of the author may not be used to endorse or promote products
     21  *    derived from this software without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  */
     34 
     35 /*
     36  * NetBSD/x68k internal I/O virtual bus.
     37  */
     38 
     39 #ifndef _INTIOVAR_H_
     40 #define _INTIOVAR_H_
     41 
     42 #include <machine/frame.h>
     43 #include <sys/malloc.h>
     44 #include <sys/extent.h>
     45 #include "locators.h"
     46 
     47 #define cf_addr		cf_loc[INTIOCF_ADDR]
     48 #define cf_intr		cf_loc[INTIOCF_INTR]
     49 #define cf_errintr	cf_loc[INTIOCF_ERRINTR]
     50 #define cf_dma		cf_loc[INTIOCF_DMA]
     51 
     52 
     53 struct intio_attach_args {
     54 	bus_space_tag_t	ia_bst;	/* bus_space tag */
     55 	bus_dma_tag_t	ia_dmat; /* bus_dma tag */
     56 
     57 	int		ia_addr; /* addr */
     58 	int		ia_size;
     59 	int		ia_intr; /* interrupt vector */
     60 	int		ia_errintr; /* interrupt vector for device error */
     61 	int		ia_dma;	/* dma channel */
     62 };
     63 
     64 struct intio_softc {
     65 	struct device	sc_dev;
     66 	bus_space_tag_t	sc_bst;
     67 	bus_dma_tag_t	sc_dmat;
     68 	struct extent	*sc_map;
     69 };
     70 
     71 enum intio_map_flag {
     72 	INTIO_MAP_ALLOCATE = 0,
     73 	INTIO_MAP_TESTONLY = 1
     74 };
     75 int intio_map_allocate_region __P((struct device*, struct intio_attach_args*, enum intio_map_flag));
     76 int intio_map_free_region __P((struct device*, struct intio_attach_args*));
     77 
     78 
     79 typedef int (*intio_intr_handler_t) __P((void*));
     80 
     81 int intio_intr_establish __P((int, const char *, intio_intr_handler_t, void *));
     82 int intio_intr_disestablish __P((int, void *));
     83 int intio_intr __P((struct frame *));
     84 
     85 
     86 #define PHYS_INTIODEV 0x00c00000
     87 
     88 extern u_int8_t *intiobase;
     89 
     90 #define INTIO_ADDR(a)	((volatile u_int8_t *) (((u_int32_t) (a)) - (PHYS_INTIODEV) + intiobase))
     91 
     92 #define INTIO_SYSPORT		(0x00e8e000)
     93 #define intio_sysport		INTIO_ADDR(INTIO_SYSPORT)
     94 #define sysport_contrast	1
     95 #define sysport_tvctrl		3
     96 #define sysport_imageunit	5
     97 #define sysport_keyctrl		7
     98 #define sysport_waitctrl	9
     99 #define sysport_mpustat		11
    100 #define sysport_sramwp		13
    101 #define sysport_powoff		15
    102 
    103 #define intio_set_sysport_contrast(a) \
    104 	intio_sysport[sysport_contrast] = (a) /* 0-15 */
    105 #define intio_set_sysport_tvctrl(a) \
    106 	intio_sysport[sysport_tvctrl] = (a)
    107 #define INTIO_SYSPORT_TVCTRL	0x08
    108 #define intio_set_sysport_imageunit(a) \
    109 	intio_sysport[sysport_imageunit] = (a)
    110 #define intio_set_sysport_keyctrl(a) \
    111 	intio_sysport[sysport_keyctrl] = (a)
    112 #define INTIO_SYSPORT_KBENABLE	0x08
    113 #define intio_set_sysport_waitctrl(a) \
    114 	intio_sysport[sysport_waitctrl] = (a) /* X68030 only */
    115 #define intio_set_sysport_sramwp(a) \
    116 	intio_sysport[sysport_sramwp] = (a)
    117 #define INTIO_SYSPORT_SRAMWP	0x31
    118 #define intio_set_sysport_powoff(a) \
    119 	intio_sysport[sysport_powoff] = (a)
    120 
    121 #define intio_get_sysport_contrast() \
    122 	(intio_sysport[sysport_contrast])
    123 #define intio_get_sysport_tvctrl() \
    124 	(intio_sysport[sysport_tvctrl])
    125 #define INTIO_SYSPORT_TVSTAT	0x08
    126 #define intio_get_sysport_keyctrl() \
    127 	(intio_sysport[sysport_keyctrl])
    128 #define INTIO_SYSPORT_KBEXIST	0x08
    129 #define intio_get_sysport_waitctrl() \
    130 	(intio_sysport[sysport_waitctrl])
    131 #define intio_get_sysport_mpustat() \
    132 	(intio_sysport[sysport_mpustat])
    133 
    134 #endif
    135