Home | History | Annotate | Line # | Download | only in dev
psychovar.h revision 1.10
      1 /*	$NetBSD: psychovar.h,v 1.10 2003/04/21 12:14:20 martin Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1999, 2000 Matthew R. Green
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. The name of the author may not be used to endorse or promote products
     16  *    derived from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  * SUCH DAMAGE.
     29  */
     30 
     31 #ifndef _SPARC64_DEV_PSYCHOVAR_H_
     32 #define _SPARC64_DEV_PSYCHOVAR_H_
     33 
     34 #include <dev/sysmon/sysmonvar.h>
     35 
     36 /* per real PCI bus info */
     37 struct psycho_softc;
     38 
     39 struct psycho_pbm {
     40 	/* link to mum */
     41 	struct psycho_softc		*pp_sc;
     42 
     43 	/*
     44 	 * note that the sabre really only has one ranges property,
     45 	 * used for both simba a and simba b (but the ranges for
     46 	 * real psychos are the same for PCI A and PCI B anyway).
     47 	 */
     48 	struct psycho_registers		*pp_regs;
     49 	struct psycho_ranges		*pp_range;
     50 
     51 	/* counts of above */
     52 	int				pp_nregs;
     53 	int				pp_nrange;
     54 	int				pp_nintmap;
     55 
     56 	/* extents for free bus space */
     57 	struct extent			*pp_exmem;
     58 	struct extent			*pp_exio;
     59 
     60 	/* chipset tag for this instance */
     61 	pci_chipset_tag_t		pp_pc;
     62 
     63 	/* our tags */
     64 	bus_space_tag_t			pp_memt;
     65 	bus_space_tag_t			pp_iot;
     66 	bus_dma_tag_t			pp_dmat;
     67 	int				pp_bus;
     68 	int				pp_busmax;
     69 	struct pp_busnode {
     70 		int	node;
     71 		int	(*valid) __P((void *));
     72 		void	*arg;
     73 	}				(*pp_busnode)[256];
     74 	int				pp_flags;
     75 
     76 	/* and pointers into the psycho regs for our bits */
     77 	bus_space_handle_t		pp_pcictl;
     78 	struct strbuf_ctl		pp_sb;
     79 	/* area we can use for flushing our streaming buffer */
     80 	char				pp_flush[0x80];
     81 };
     82 
     83 /*
     84  * per-PCI bus on mainbus softc structure; one for sabre, or two
     85  * per pair of psycho's.
     86  */
     87 struct psycho_softc {
     88 	struct	device			sc_dev;
     89 
     90 	/*
     91 	 * one sabre has two simba's.  psycho's are separately attached,
     92 	 * with the `other' psycho_pbm allocated at the first's attach.
     93 	 */
     94 	struct psycho_pbm		*__sc_psycho_this;
     95 	struct psycho_pbm		*__sc_psycho_other;
     96 #define	sc_psycho_this	__sc_psycho_this
     97 #define	sc_psycho_other	__sc_psycho_other
     98 
     99 	/*
    100 	 * PSYCHO register.  we record the base physical address of these
    101 	 * also as it is the base of the entire PSYCHO
    102 	 */
    103 	struct psychoreg		*sc_regs;
    104 	paddr_t				sc_basepaddr;
    105 
    106 	/* Interrupt Group Number for this device */
    107 	int				sc_ign;
    108 
    109 	/* our tags (from parent) */
    110 	bus_space_tag_t			sc_bustag;
    111 	bus_dma_tag_t			sc_dmatag;
    112 
    113 	bus_space_handle_t		sc_bh;
    114 
    115 	/* config space */
    116 	bus_space_tag_t			sc_configtag;
    117 	bus_space_handle_t		sc_configaddr;
    118 
    119 	int				sc_clockfreq;
    120 	int				sc_node;	/* prom node */
    121 	int				sc_mode;	/* (whatareya?) */
    122 #define	PSYCHO_MODE_SABRE	1	/* i'm a sabre (yob) */
    123 #define	PSYCHO_MODE_PSYCHO	2	/* i'm a psycho (w*nker) */
    124 
    125 	struct iommu_state		*sc_is;
    126 
    127 	struct sysmon_pswitch		*sc_smcontext;	/* power switch definition */
    128 	int				sc_powerpressed;/* already signaled */
    129 };
    130 
    131 /* get a PCI offset address from bus_space_handle_t */
    132 bus_addr_t psycho_bus_offset __P((bus_space_tag_t, bus_space_handle_t *));
    133 
    134 /* config space is per-psycho.  mem/io/dma are per-pci bus */
    135 bus_dma_tag_t psycho_alloc_dma_tag __P((struct psycho_pbm *));
    136 bus_space_tag_t psycho_alloc_bus_tag __P((struct psycho_pbm *, int));
    137 
    138 #define psycho_alloc_config_tag(pp) psycho_alloc_bus_tag((pp), PCI_CONFIG_BUS_SPACE)
    139 #define psycho_alloc_mem_tag(pp) psycho_alloc_bus_tag((pp), PCI_MEMORY_BUS_SPACE)
    140 #define psycho_alloc_io_tag(pp) psycho_alloc_bus_tag((pp), PCI_IO_BUS_SPACE)
    141 
    142 #endif /* _SPARC64_DEV_PSYCHOVAR_H_ */
    143