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