Home | History | Annotate | Line # | Download | only in dev
intiovar.h revision 1.9
      1 /*	$NetBSD: intiovar.h,v 1.9 2007/10/17 19:58:02 garbled 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 the NetBSD
     19  *        Foundation, Inc. and its contributors.
     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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     24  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     25  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     26  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     27  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33  * POSSIBILITY OF SUCH DAMAGE.
     34  */
     35 
     36 /*
     37  * NetBSD/x68k internal I/O virtual bus.
     38  */
     39 
     40 #ifndef _INTIOVAR_H_
     41 #define _INTIOVAR_H_
     42 
     43 #include <machine/frame.h>
     44 #include <sys/malloc.h>
     45 #include <sys/extent.h>
     46 #include "locators.h"
     47 
     48 #define cf_addr		cf_loc[INTIOCF_ADDR]
     49 #define cf_intr		cf_loc[INTIOCF_INTR]
     50 #define cf_dma		cf_loc[INTIOCF_DMA]
     51 #define cf_dmaintr	cf_loc[INTIOCF_DMAINTR]
     52 
     53 
     54 struct intio_attach_args {
     55 	bus_space_tag_t	ia_bst;	/* bus_space tag */
     56 	bus_dma_tag_t	ia_dmat; /* bus_dma tag */
     57 
     58 	const char	*ia_name; /* device name */
     59 	int		ia_addr; /* addr */
     60 	int		ia_size;
     61 	int		ia_intr; /* interrupt vector */
     62 	int		ia_dma;	/* dma channel */
     63 	int		ia_dmaintr; /* interrupt vector for dmac */
     64 };
     65 
     66 struct intio_softc {
     67 	struct device	sc_dev;
     68 	bus_space_tag_t	sc_bst;
     69 	bus_dma_tag_t	sc_dmat;
     70 	struct extent	*sc_map;
     71 	struct device	*sc_dmac;
     72 };
     73 
     74 enum intio_map_flag {
     75 	INTIO_MAP_ALLOCATE = 0,
     76 	INTIO_MAP_TESTONLY = 1
     77 };
     78 int intio_map_allocate_region(struct device *, struct intio_attach_args *,
     79 	enum intio_map_flag);
     80 int intio_map_free_region(struct device *, struct intio_attach_args *);
     81 
     82 typedef int (*intio_intr_handler_t)(void *);
     83 
     84 int intio_intr_establish(int, const char *, intio_intr_handler_t, void *);
     85 int intio_intr_disestablish(int, void *);
     86 int intio_intr(struct frame *);
     87 
     88 
     89 #define PHYS_INTIODEV 0x00c00000
     90 
     91 extern u_int8_t *intiobase;
     92 
     93 #define INTIO_ADDR(a)	((volatile u_int8_t *) (((u_int32_t) (a)) - (PHYS_INTIODEV) + intiobase))
     94 
     95 #define INTIO_SYSPORT		(0x00e8e000)
     96 #define intio_sysport		INTIO_ADDR(INTIO_SYSPORT)
     97 #define sysport_contrast	1
     98 #define sysport_tvctrl		3
     99 #define sysport_imageunit	5
    100 #define sysport_keyctrl		7
    101 #define sysport_waitctrl	9
    102 #define sysport_mpustat		11
    103 #define sysport_sramwp		13
    104 #define sysport_powoff		15
    105 
    106 #define intio_set_sysport_contrast(a) \
    107 	intio_sysport[sysport_contrast] = (a) /* 0-15 */
    108 #define intio_set_sysport_tvctrl(a) \
    109 	intio_sysport[sysport_tvctrl] = (a)
    110 #define INTIO_SYSPORT_TVCTRL	0x08
    111 #define intio_set_sysport_imageunit(a) \
    112 	intio_sysport[sysport_imageunit] = (a)
    113 #define intio_set_sysport_keyctrl(a) \
    114 	intio_sysport[sysport_keyctrl] = (a)
    115 #define INTIO_SYSPORT_KBENABLE	0x08
    116 #define intio_set_sysport_waitctrl(a) \
    117 	intio_sysport[sysport_waitctrl] = (a) /* X68030 only */
    118 #define intio_set_sysport_sramwp(a) \
    119 	intio_sysport[sysport_sramwp] = (a)
    120 #define INTIO_SYSPORT_SRAMWP	0x31
    121 #define intio_set_sysport_powoff(a) \
    122 	intio_sysport[sysport_powoff] = (a)
    123 
    124 #define intio_get_sysport_contrast() \
    125 	(intio_sysport[sysport_contrast])
    126 #define intio_get_sysport_tvctrl() \
    127 	(intio_sysport[sysport_tvctrl])
    128 #define INTIO_SYSPORT_TVSTAT	0x08
    129 #define intio_get_sysport_keyctrl() \
    130 	(intio_sysport[sysport_keyctrl])
    131 #define INTIO_SYSPORT_KBEXIST	0x08
    132 #define intio_get_sysport_waitctrl() \
    133 	(intio_sysport[sysport_waitctrl])
    134 #define intio_get_sysport_mpustat() \
    135 	(intio_sysport[sysport_mpustat])
    136 
    137 /* I/O controller (sicilian/pluto) */
    138 #define INTIO_SICILIAN		(0x00e9c000)
    139 #define intio_sicilian		INTIO_ADDR(INTIO_SICILIAN)
    140 #define sicilian_intr		1
    141 #define sicilian_ivec		3
    142 
    143 #define intio_get_sicilian_intr() \
    144 	(intio_sicilian[sicilian_intr])
    145 #define intio_set_sicilian_intr(a) \
    146 	intio_sicilian[sicilian_intr] = (a)
    147 #define SICILIAN_INTR_PAR 0x01
    148 #define SICILIAN_INTR_FDD 0x02
    149 #define SICILIAN_INTR_FDC 0x04
    150 #define SICILIAN_INTR_HDD 0x08
    151 #define SICILIAN_STAT_HDD 0x10
    152 #define SICILIAN_STAT_PAR 0x20
    153 #define SICILIAN_STAT_FDD 0x40
    154 #define SICILIAN_STAT_FDC 0x80
    155 
    156 #define intio_enable_intr(a) \
    157 	intio_sicilian[sicilian_intr] = ((a) | intio_sicilian[sicilian_intr])
    158 #define intio_disable_intr(a) \
    159 	intio_sicilian[sicilian_intr] = (~(a) & intio_sicilian[sicilian_intr])
    160 
    161 #define intio_set_sicilian_ivec(a) \
    162 	intio_sicilian[sicilian_ivec] = (a)
    163 void intio_set_ivec(int);
    164 
    165 struct intio_dma_cookie {
    166 	int	id_flags;		/* flags; see below */
    167 
    168 	/*
    169 	 * Information about the original buffer used during
    170 	 * DMA map syncs.  Note that origibuflen is only used
    171 	 * for ID_BUFTYPE_LINEAR.
    172 	 */
    173 	void	*id_origbuf;		/* pointer to orig buffer if
    174 					   bouncing */
    175 	bus_size_t id_origbuflen;	/* ...and size */
    176 	int	id_buftype;		/* type of buffer */
    177 
    178 	void	*id_bouncebuf;		/* pointer to the bounce buffer */
    179 	bus_size_t id_bouncebuflen;	/* ...and size */
    180 	int	id_nbouncesegs;		/* number of valid bounce segs */
    181 	bus_dma_segment_t id_bouncesegs[0]; /* array of bounce buffer
    182 					       physical memory segments */
    183 };
    184 
    185 /* id_flags */
    186 #define	ID_MIGHT_NEED_BOUNCE	0x01	/* map could need bounce buffers */
    187 #define	ID_HAS_BOUNCE		0x02	/* map currently has bounce buffers */
    188 #define	ID_IS_BOUNCING		0x04	/* map is bouncing current xfer */
    189 
    190 /* id_buftype */
    191 #define	ID_BUFTYPE_INVALID	0
    192 #define	ID_BUFTYPE_LINEAR	1
    193 #define	ID_BUFTYPE_MBUF		2
    194 #define	ID_BUFTYPE_UIO		3
    195 #define	ID_BUFTYPE_RAW		4
    196 
    197 #endif
    198