xref: /netbsd-src/sys/dev/sbus/sbusvar.h (revision 12ad76b18c6a1b98ee0c961fbee99f5e1641b691)
1*12ad76b1Stsutsui /*	$NetBSD: sbusvar.h,v 1.27 2009/09/17 16:28:12 tsutsui Exp $ */
2e68ada23Spk 
3e68ada23Spk /*-
4e68ada23Spk  * Copyright (c) 1998 The NetBSD Foundation, Inc.
5e68ada23Spk  * All rights reserved.
6e68ada23Spk  *
7e68ada23Spk  * This code is derived from software contributed to The NetBSD Foundation
8e68ada23Spk  * by Paul Kranenburg.
9e68ada23Spk  *
10e68ada23Spk  * Redistribution and use in source and binary forms, with or without
11e68ada23Spk  * modification, are permitted provided that the following conditions
12e68ada23Spk  * are met:
13e68ada23Spk  * 1. Redistributions of source code must retain the above copyright
14e68ada23Spk  *    notice, this list of conditions and the following disclaimer.
15e68ada23Spk  * 2. Redistributions in binary form must reproduce the above copyright
16e68ada23Spk  *    notice, this list of conditions and the following disclaimer in the
17e68ada23Spk  *    documentation and/or other materials provided with the distribution.
18e68ada23Spk  *
19e68ada23Spk  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20e68ada23Spk  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21e68ada23Spk  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22e68ada23Spk  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23e68ada23Spk  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24e68ada23Spk  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25e68ada23Spk  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26e68ada23Spk  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27e68ada23Spk  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28e68ada23Spk  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29e68ada23Spk  * POSSIBILITY OF SUCH DAMAGE.
30e68ada23Spk  */
31e68ada23Spk 
329a7ffd57Spk #ifndef _SBUS_VAR_H
339a7ffd57Spk #define _SBUS_VAR_H
349a7ffd57Spk 
351ff5e232Sdarrenr #if defined(_KERNEL_OPT) && (defined(__sparc__) || defined(__sparc64__))
361ff5e232Sdarrenr #include "opt_sparc_arch.h"
371ff5e232Sdarrenr #endif
381ff5e232Sdarrenr 
3990817e31Sthorpej #include <machine/bsd_openprom.h>
4090817e31Sthorpej 
419a7ffd57Spk struct sbus_softc;
429a7ffd57Spk 
43f61bdee8Spk typedef u_int32_t sbus_slot_t;
44f61bdee8Spk typedef u_int32_t sbus_offset_t;
459a7ffd57Spk 
469a7ffd57Spk /*
479a7ffd57Spk  * Sbus driver attach arguments.
489a7ffd57Spk  */
499a7ffd57Spk struct sbus_attach_args {
509a7ffd57Spk 	int		sa_placeholder;	/* for obio attach args sharing */
519a7ffd57Spk 	bus_space_tag_t	sa_bustag;
529a7ffd57Spk 	bus_dma_tag_t	sa_dmatag;
539a7ffd57Spk 	char		*sa_name;	/* PROM node name */
549a7ffd57Spk 	int		sa_node;	/* PROM handle */
5590817e31Sthorpej 	struct openprom_addr *sa_reg;	/* Sbus register space for device */
569a7ffd57Spk 	int		sa_nreg;	/* Number of Sbus register spaces */
5790817e31Sthorpej #define sa_slot		sa_reg[0].oa_space
5890817e31Sthorpej #define sa_offset	sa_reg[0].oa_base
5990817e31Sthorpej #define sa_size		sa_reg[0].oa_size
609a7ffd57Spk 
6190817e31Sthorpej 	struct openprom_intr *sa_intr;	/* Sbus interrupts for device */
629a7ffd57Spk 	int		sa_nintr;	/* Number of interrupts */
6390817e31Sthorpej #define sa_pri		sa_intr[0].oi_pri
649a7ffd57Spk 
65484ce048Seeh 	u_int32_t	*sa_promvaddrs;/* PROM-supplied virtual addresses -- 32-bit */
669a7ffd57Spk 	int		sa_npromvaddrs;	/* Number of PROM VAs */
67c5b834a5Seeh #define sa_promvaddr	sa_promvaddrs[0]
6855fd5a2fSeeh 	int		sa_frequency;	/* SBus clockrate */
699a7ffd57Spk };
709a7ffd57Spk 
71c05097f9Seeh /* sbus_attach_internal() is also used from obio.c */
725304f91eStsutsui void	sbus_attach_common(struct sbus_softc *, const char *, int,
7318db93c7Sperry 				const char * const *);
7418db93c7Sperry int	sbus_print(void *, const char *);
759a7ffd57Spk 
7618db93c7Sperry int	sbus_setup_attach_args(
779a7ffd57Spk 		struct sbus_softc *,
789a7ffd57Spk 		bus_space_tag_t,
799a7ffd57Spk 		bus_dma_tag_t,
809a7ffd57Spk 		int,			/*node*/
8118db93c7Sperry 		struct sbus_attach_args *);
829a7ffd57Spk 
8318db93c7Sperry void	sbus_destroy_attach_args(struct sbus_attach_args *);
849a7ffd57Spk 
85f61bdee8Spk #define sbus_bus_map(tag, slot, offset, sz, flags, hp) \
86f61bdee8Spk 	bus_space_map(tag, BUS_ADDR(slot,offset), sz, flags, hp)
8718db93c7Sperry bus_addr_t	sbus_bus_addr(bus_space_tag_t, u_int, u_int);
8818db93c7Sperry void	sbus_promaddr_to_handle(bus_space_tag_t, u_int,
8918db93c7Sperry 	bus_space_handle_t *);
909a7ffd57Spk 
919a7ffd57Spk #if notyet
929a7ffd57Spk /* variables per Sbus */
939a7ffd57Spk struct sbus_softc {
9484e564d3Smacallan 	device_t sc_dev;		/* base device */
959a7ffd57Spk 	bus_space_tag_t	sc_bustag;
969a7ffd57Spk 	bus_dma_tag_t	sc_dmatag;
979a7ffd57Spk 	int	sc_clockfreq;		/* clock frequency (in Hz) */
9890817e31Sthorpej 	struct	openprom_range *sc_range;
999a7ffd57Spk 	int	sc_nrange;
1009a7ffd57Spk 	int	sc_burst;		/* burst transfer sizes supported */
101a2dd74edSeeh 	/* machdep stuff follows here */
1029a7ffd57Spk 	int	*sc_intr2ipl;		/* Interrupt level translation */
1039a7ffd57Spk };
1049a7ffd57Spk #endif
1059a7ffd57Spk 
106e68ada23Spk 
107e68ada23Spk /*
108e68ada23Spk  * PROM-reported DMA burst sizes for the SBus
109e68ada23Spk  */
110e68ada23Spk #define SBUS_BURST_1	0x1
111e68ada23Spk #define SBUS_BURST_2	0x2
112e68ada23Spk #define SBUS_BURST_4	0x4
113e68ada23Spk #define SBUS_BURST_8	0x8
114e68ada23Spk #define SBUS_BURST_16	0x10
115e68ada23Spk #define SBUS_BURST_32	0x20
116e68ada23Spk #define SBUS_BURST_64	0x40
1179a7ffd57Spk 
11842ebb851Spk /* We use #defined(SUN4*) here while the ports are in flux */
119184c0df1Spk #if defined(SUN4) || defined(SUN4C) || defined(SUN4M) || defined(SUN4D)
12042ebb851Spk #include <sparc/dev/sbusvar.h>
12142ebb851Spk #elif defined(SUN4U)
12242ebb851Spk #include <sparc64/dev/sbusvar.h>
12342ebb851Spk #endif
12442ebb851Spk 
1259a7ffd57Spk #endif /* _SBUS_VAR_H */
126