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