Home | History | Annotate | Line # | Download | only in sbus
sbusvar.h revision 1.26
      1 /*	$NetBSD: sbusvar.h,v 1.26 2008/05/17 18:09:03 macallan Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Paul Kranenburg.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _SBUS_VAR_H
     33 #define _SBUS_VAR_H
     34 
     35 #if defined(_KERNEL_OPT) && (defined(__sparc__) || defined(__sparc64__))
     36 #include "opt_sparc_arch.h"
     37 #endif
     38 
     39 #include <machine/bsd_openprom.h>
     40 
     41 struct sbus_softc;
     42 
     43 /*
     44  * S-bus variables.
     45  */
     46 struct sbusdev {
     47 	device_t sd_dev;		/* backpointer to generic */
     48 	struct	sbusdev *sd_bchain;	/* forward link in bus chain */
     49 	void	(*sd_reset)(device_t);
     50 };
     51 
     52 typedef u_int32_t sbus_slot_t;
     53 typedef u_int32_t sbus_offset_t;
     54 
     55 /*
     56  * Sbus driver attach arguments.
     57  */
     58 struct sbus_attach_args {
     59 	int		sa_placeholder;	/* for obio attach args sharing */
     60 	bus_space_tag_t	sa_bustag;
     61 	bus_dma_tag_t	sa_dmatag;
     62 	char		*sa_name;	/* PROM node name */
     63 	int		sa_node;	/* PROM handle */
     64 	struct openprom_addr *sa_reg;	/* Sbus register space for device */
     65 	int		sa_nreg;	/* Number of Sbus register spaces */
     66 #define sa_slot		sa_reg[0].oa_space
     67 #define sa_offset	sa_reg[0].oa_base
     68 #define sa_size		sa_reg[0].oa_size
     69 
     70 	struct openprom_intr *sa_intr;	/* Sbus interrupts for device */
     71 	int		sa_nintr;	/* Number of interrupts */
     72 #define sa_pri		sa_intr[0].oi_pri
     73 
     74 	u_int32_t	*sa_promvaddrs;/* PROM-supplied virtual addresses -- 32-bit */
     75 	int		sa_npromvaddrs;	/* Number of PROM VAs */
     76 #define sa_promvaddr	sa_promvaddrs[0]
     77 	int		sa_frequency;	/* SBus clockrate */
     78 };
     79 
     80 /* sbus_attach_internal() is also used from obio.c */
     81 void	sbus_attach_common(struct sbus_softc *, const char *, int,
     82 				const char * const *);
     83 int	sbus_print(void *, const char *);
     84 
     85 void	sbus_establish(struct sbusdev *, device_t);
     86 
     87 int	sbus_setup_attach_args(
     88 		struct sbus_softc *,
     89 		bus_space_tag_t,
     90 		bus_dma_tag_t,
     91 		int,			/*node*/
     92 		struct sbus_attach_args *);
     93 
     94 void	sbus_destroy_attach_args(struct sbus_attach_args *);
     95 
     96 #define sbus_bus_map(tag, slot, offset, sz, flags, hp) \
     97 	bus_space_map(tag, BUS_ADDR(slot,offset), sz, flags, hp)
     98 bus_addr_t	sbus_bus_addr(bus_space_tag_t, u_int, u_int);
     99 void	sbus_promaddr_to_handle(bus_space_tag_t, u_int,
    100 	bus_space_handle_t *);
    101 
    102 #if notyet
    103 /* variables per Sbus */
    104 struct sbus_softc {
    105 	device_t sc_dev;		/* base device */
    106 	bus_space_tag_t	sc_bustag;
    107 	bus_dma_tag_t	sc_dmatag;
    108 	int	sc_clockfreq;		/* clock frequency (in Hz) */
    109 	struct	sbusdev *sc_sbdev;	/* list of all children */
    110 	struct	openprom_range *sc_range;
    111 	int	sc_nrange;
    112 	int	sc_burst;		/* burst transfer sizes supported */
    113 	/* machdep stuff follows here */
    114 	int	*sc_intr2ipl;		/* Interrupt level translation */
    115 };
    116 #endif
    117 
    118 
    119 /*
    120  * PROM-reported DMA burst sizes for the SBus
    121  */
    122 #define SBUS_BURST_1	0x1
    123 #define SBUS_BURST_2	0x2
    124 #define SBUS_BURST_4	0x4
    125 #define SBUS_BURST_8	0x8
    126 #define SBUS_BURST_16	0x10
    127 #define SBUS_BURST_32	0x20
    128 #define SBUS_BURST_64	0x40
    129 
    130 /* We use #defined(SUN4*) here while the ports are in flux */
    131 #if defined(SUN4) || defined(SUN4C) || defined(SUN4M) || defined(SUN4D)
    132 #include <sparc/dev/sbusvar.h>
    133 #elif defined(SUN4U)
    134 #include <sparc64/dev/sbusvar.h>
    135 #endif
    136 
    137 #endif /* _SBUS_VAR_H */
    138