1 /* $OpenBSD: sbusvar.h,v 1.7 2003/02/17 01:29:21 henric Exp $ */ 2 /* $NetBSD: sbusvar.h,v 1.11 2000/11/01 06:18:45 eeh Exp $ */ 3 4 /*- 5 * Copyright (c) 1998 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Paul Kranenburg. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the NetBSD 22 * Foundation, Inc. and its contributors. 23 * 4. Neither the name of The NetBSD Foundation nor the names of its 24 * contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 */ 39 40 #ifndef _SBUS_VAR_H 41 #define _SBUS_VAR_H 42 43 struct sbus_softc; 44 45 /* 46 * S-bus variables. 47 */ 48 struct sbusdev { 49 struct device *sd_dev; /* backpointer to generic */ 50 struct sbusdev *sd_bchain; /* forward link in bus chain */ 51 void (*sd_reset)(struct device *); 52 }; 53 54 55 /* Device register space description */ 56 struct sbus_reg { 57 u_int32_t sbr_slot; 58 u_int32_t sbr_offset; 59 u_int32_t sbr_size; 60 }; 61 62 /* Interrupt information */ 63 struct sbus_intr { 64 u_int32_t sbi_pri; /* priority (IPL) */ 65 u_int32_t sbi_vec; /* vector (always 0?) */ 66 }; 67 68 /* Address translation across busses */ 69 struct sbus_range { 70 u_int32_t cspace; /* Client space */ 71 u_int32_t coffset; /* Client offset */ 72 u_int32_t pspace; /* Parent space */ 73 u_int32_t poffset; /* Parent offset */ 74 u_int32_t size; /* Size in bytes of this range */ 75 }; 76 77 /* 78 * Sbus driver attach arguments. 79 */ 80 struct sbus_attach_args { 81 int sa_placeholder; /* for obio attach args sharing */ 82 bus_space_tag_t sa_bustag; 83 bus_dma_tag_t sa_dmatag; 84 char *sa_name; /* PROM node name */ 85 int sa_node; /* PROM handle */ 86 struct sbus_reg *sa_reg; /* Sbus register space for device */ 87 int sa_nreg; /* Number of Sbus register spaces */ 88 #define sa_slot sa_reg[0].sbr_slot 89 #define sa_offset sa_reg[0].sbr_offset 90 #define sa_size sa_reg[0].sbr_size 91 92 struct sbus_intr *sa_intr; /* Sbus interrupts for device */ 93 int sa_nintr; /* Number of interrupts */ 94 #define sa_pri sa_intr[0].sbi_pri 95 96 u_int32_t *sa_promvaddrs;/* PROM-supplied virtual addresses -- 32-bit */ 97 int sa_npromvaddrs; /* Number of PROM VAs */ 98 #define sa_promvaddr sa_promvaddrs[0] 99 int sa_frequency; /* SBus clockrate */ 100 }; 101 102 /* sbus_attach_internal() is also used from obio.c */ 103 void sbus_attach_common(struct sbus_softc *, char *, int, 104 const char * const *); 105 int sbus_print(void *, const char *); 106 107 void sbus_establish(struct sbusdev *, struct device *); 108 109 int sbus_setup_attach_args( 110 struct sbus_softc *, 111 bus_space_tag_t, 112 bus_dma_tag_t, 113 int, /*node*/ 114 struct sbus_attach_args *); 115 116 void sbus_destroy_attach_args(struct sbus_attach_args *); 117 118 #define sbus_bus_map(t, slot, offset, sz, flags, unused, hp) \ 119 bus_space_map(t, BUS_ADDR(slot, offset), sz, flags, hp) 120 121 #if notyet 122 /* variables per Sbus */ 123 struct sbus_softc { 124 struct device sc_dev; /* base device */ 125 bus_space_tag_t sc_bustag; 126 bus_dma_tag_t sc_dmatag; 127 int sc_clockfreq; /* clock frequency (in Hz) */ 128 struct sbusdev *sc_sbdev; /* list of all children */ 129 struct sbus_range *sc_range; 130 int sc_nrange; 131 int sc_burst; /* burst transfer sizes supported */ 132 /* machdep stuff follows here */ 133 int *sc_intr2ipl; /* Interrupt level translation */ 134 int *sc_intr_compat; /* `intr' property to sbus compat */ 135 }; 136 #endif 137 138 139 /* 140 * PROM-reported DMA burst sizes for the SBus 141 */ 142 #define SBUS_BURST_1 0x1 143 #define SBUS_BURST_2 0x2 144 #define SBUS_BURST_4 0x4 145 #define SBUS_BURST_8 0x8 146 #define SBUS_BURST_16 0x10 147 #define SBUS_BURST_32 0x20 148 #define SBUS_BURST_64 0x40 149 150 /* We use #defined(SUN4*) here while the ports are in flux */ 151 #if defined(SUN4) || defined(SUN4C) || defined(SUN4M) 152 #include <sparc/dev/sbusvar.h> 153 #elif defined(SUN4U) 154 #include <sparc64/dev/sbusvar.h> 155 #endif 156 157 #endif /* _SBUS_VAR_H */ 158