Home | History | Annotate | Line # | Download | only in rmi
rmixlvar.h revision 1.3
      1  1.3  matt /*	$NetBSD: rmixlvar.h,v 1.3 2011/02/20 07:48:37 matt Exp $	*/
      2  1.2  matt 
      3  1.2  matt /*
      4  1.2  matt  * Copyright 2002 Wasabi Systems, Inc.
      5  1.2  matt  * All rights reserved.
      6  1.2  matt  *
      7  1.2  matt  * Written by Simon Burge for Wasabi Systems, Inc.
      8  1.2  matt  *
      9  1.2  matt  * Redistribution and use in source and binary forms, with or without
     10  1.2  matt  * modification, are permitted provided that the following conditions
     11  1.2  matt  * are met:
     12  1.2  matt  * 1. Redistributions of source code must retain the above copyright
     13  1.2  matt  *    notice, this list of conditions and the following disclaimer.
     14  1.2  matt  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.2  matt  *    notice, this list of conditions and the following disclaimer in the
     16  1.2  matt  *    documentation and/or other materials provided with the distribution.
     17  1.2  matt  * 3. All advertising materials mentioning features or use of this software
     18  1.2  matt  *    must display the following acknowledgement:
     19  1.2  matt  *      This product includes software developed for the NetBSD Project by
     20  1.2  matt  *      Wasabi Systems, Inc.
     21  1.2  matt  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22  1.2  matt  *    or promote products derived from this software without specific prior
     23  1.2  matt  *    written permission.
     24  1.2  matt  *
     25  1.2  matt  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26  1.2  matt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  1.2  matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  1.2  matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29  1.2  matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  1.2  matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  1.2  matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  1.2  matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  1.2  matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  1.2  matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  1.2  matt  * POSSIBILITY OF SUCH DAMAGE.
     36  1.2  matt  */
     37  1.2  matt 
     38  1.2  matt #ifndef _MIPS_RMI_RMIXLVAR_H_
     39  1.2  matt #define _MIPS_RMI_RMIXLVAR_H_
     40  1.2  matt 
     41  1.2  matt #include <mips/cpu.h>
     42  1.3  matt #include <mips/locore.h>
     43  1.3  matt #include <mips/rmi/rmixl_firmware.h>
     44  1.3  matt 
     45  1.3  matt #include <machine/bus.h>
     46  1.3  matt 
     47  1.2  matt #include <dev/pci/pcivar.h>
     48  1.3  matt 
     49  1.3  matt extern void rmixl_pcr_init_core(void);
     50  1.2  matt 
     51  1.2  matt static inline bool
     52  1.2  matt cpu_rmixl(const struct pridtab *ct)
     53  1.2  matt {
     54  1.2  matt 	if (ct->cpu_cid == MIPS_PRID_CID_RMI)
     55  1.2  matt 		return true;
     56  1.2  matt 	return false;
     57  1.2  matt }
     58  1.2  matt 
     59  1.2  matt static inline bool
     60  1.2  matt cpu_rmixlr(const struct pridtab *ct)
     61  1.2  matt {
     62  1.2  matt 	u_int type = ct->cpu_cidflags & MIPS_CIDFL_RMI_TYPE;
     63  1.2  matt 	if (cpu_rmixl(ct) && type == CIDFL_RMI_TYPE_XLR)
     64  1.2  matt 		return true;
     65  1.2  matt 	return false;
     66  1.2  matt }
     67  1.2  matt 
     68  1.2  matt static inline bool
     69  1.2  matt cpu_rmixls(const struct pridtab *ct)
     70  1.2  matt {
     71  1.2  matt 	u_int type = ct->cpu_cidflags & MIPS_CIDFL_RMI_TYPE;
     72  1.2  matt 	if (cpu_rmixl(ct) && type == CIDFL_RMI_TYPE_XLS)
     73  1.2  matt 		return true;
     74  1.2  matt 	return false;
     75  1.2  matt }
     76  1.2  matt 
     77  1.2  matt static inline bool
     78  1.2  matt cpu_rmixlp(const struct pridtab *ct)
     79  1.2  matt {
     80  1.2  matt 	u_int type = ct->cpu_cidflags & MIPS_CIDFL_RMI_TYPE;
     81  1.2  matt 	if (cpu_rmixl(ct) && type == CIDFL_RMI_TYPE_XLP)
     82  1.2  matt 		return true;
     83  1.2  matt 	return false;
     84  1.2  matt }
     85  1.2  matt 
     86  1.3  matt static inline int
     87  1.3  matt cpu_rmixl_chip_type(const struct pridtab *ct)
     88  1.3  matt {
     89  1.3  matt 	return ct->cpu_cidflags & MIPS_CIDFL_RMI_TYPE;
     90  1.3  matt }
     91  1.2  matt 
     92  1.2  matt typedef enum {
     93  1.3  matt 	PSB_TYPE_UNKNOWN=0,
     94  1.3  matt 	PSB_TYPE_RMI,
     95  1.3  matt 	PSB_TYPE_DELL,
     96  1.3  matt } rmixlfw_psb_type_t;
     97  1.2  matt 
     98  1.3  matt static inline const char *
     99  1.3  matt rmixlfw_psb_type_name(rmixlfw_psb_type_t type)
    100  1.3  matt {
    101  1.3  matt 	switch(type) {
    102  1.3  matt 	case PSB_TYPE_UNKNOWN:
    103  1.3  matt 		return "unknown";
    104  1.3  matt 	case PSB_TYPE_RMI:
    105  1.3  matt 		return "RMI";
    106  1.3  matt 	case PSB_TYPE_DELL:
    107  1.3  matt 		return "DELL";
    108  1.3  matt 	default:
    109  1.3  matt 		return "undefined";
    110  1.3  matt 	}
    111  1.3  matt }
    112  1.2  matt 
    113  1.2  matt struct rmixl_config {
    114  1.2  matt 	uint64_t		 rc_io_pbase;
    115  1.3  matt 	bus_addr_t		 rc_pci_cfg_pbase;
    116  1.3  matt 	bus_size_t		 rc_pci_cfg_size;
    117  1.3  matt 	bus_addr_t		 rc_pci_ecfg_pbase;
    118  1.3  matt 	bus_size_t		 rc_pci_ecfg_size;
    119  1.2  matt 	bus_addr_t		 rc_pci_mem_pbase;
    120  1.2  matt 	bus_size_t		 rc_pci_mem_size;
    121  1.2  matt 	bus_addr_t		 rc_pci_io_pbase;
    122  1.2  matt 	bus_size_t		 rc_pci_io_size;
    123  1.3  matt 	struct mips_bus_space	 rc_obio_eb_memt; 	/* DEVIO -eb */
    124  1.3  matt 	struct mips_bus_space	 rc_obio_el_memt; 	/* DEVIO -el */
    125  1.3  matt 	struct mips_bus_space	 rc_pci_cfg_memt; 	/* PCI CFG  */
    126  1.3  matt 	struct mips_bus_space	 rc_pci_ecfg_memt; 	/* PCI ECFG */
    127  1.2  matt 	struct mips_bus_space	 rc_pci_memt; 		/* PCI MEM */
    128  1.2  matt 	struct mips_bus_space	 rc_pci_iot; 		/* PCI IO  */
    129  1.3  matt 	struct mips_bus_dma_tag	 rc_dma_tag;
    130  1.3  matt 	bus_dma_tag_t		 rc_64bit_dmat;
    131  1.3  matt 	bus_dma_tag_t		 rc_32bit_dmat;
    132  1.3  matt 	bus_dma_tag_t		 rc_29bit_dmat;
    133  1.2  matt 	struct extent		*rc_phys_ex;	/* Note: MB units */
    134  1.3  matt 	struct extent		*rc_obio_eb_ex;
    135  1.3  matt 	struct extent		*rc_obio_el_ex;
    136  1.3  matt 	struct extent		*rc_pci_cfg_ex;
    137  1.3  matt 	struct extent		*rc_pci_ecfg_ex;
    138  1.3  matt 	struct extent		*rc_pci_mem_ex;
    139  1.3  matt 	struct extent		*rc_pci_io_ex;
    140  1.2  matt 	int			 rc_mallocsafe;
    141  1.3  matt 	rmixlfw_info_t 		 rc_psb_info;
    142  1.3  matt 	rmixlfw_psb_type_t	 rc_psb_type;
    143  1.3  matt 	volatile struct rmixlfw_cpu_wakeup_info
    144  1.3  matt 				*rc_cpu_wakeup_info;
    145  1.3  matt 	const void		*rc_cpu_wakeup_end;
    146  1.2  matt };
    147  1.2  matt 
    148  1.2  matt extern struct rmixl_config rmixl_configuration;
    149  1.2  matt 
    150  1.3  matt extern void rmixl_obio_eb_bus_mem_init(bus_space_tag_t, void *);
    151  1.3  matt extern void rmixl_obio_el_bus_mem_init(bus_space_tag_t, void *);
    152  1.3  matt extern void rmixl_pci_cfg_bus_mem_init(bus_space_tag_t, void *);
    153  1.3  matt extern void rmixl_pci_ecfg_bus_mem_init(bus_space_tag_t, void *);
    154  1.3  matt extern void rmixl_pci_bus_mem_init(bus_space_tag_t, void *);
    155  1.3  matt extern void rmixl_pci_bus_io_init(bus_space_tag_t, void *);
    156  1.2  matt 
    157  1.2  matt extern void rmixl_addr_error_init(void);
    158  1.2  matt extern int  rmixl_addr_error_check(void);
    159  1.2  matt 
    160  1.2  matt extern uint64_t rmixl_mfcr(u_int);
    161  1.2  matt extern void rmixl_mtcr(uint64_t, u_int);
    162  1.2  matt 
    163  1.3  matt 
    164  1.3  matt /*
    165  1.3  matt  * rmixl_cache_err_dis:
    166  1.3  matt  * - disable Cache, Data ECC, Snoop Tag Parity, Tag Parity errors
    167  1.3  matt  * - clear the cache error log
    168  1.3  matt  * - return previous value from RMIXL_PCR_L1D_CONFIG0
    169  1.3  matt  */
    170  1.3  matt static inline uint64_t
    171  1.3  matt rmixl_cache_err_dis(void)
    172  1.3  matt {
    173  1.3  matt 	uint64_t r;
    174  1.3  matt 
    175  1.3  matt 	r = rmixl_mfcr(RMIXL_PCR_L1D_CONFIG0);
    176  1.3  matt 	rmixl_mtcr(RMIXL_PCR_L1D_CONFIG0, r & ~0x2e);
    177  1.3  matt 	rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG, 0);
    178  1.3  matt 	return r;
    179  1.3  matt }
    180  1.3  matt 
    181  1.3  matt /*
    182  1.3  matt  * rmixl_cache_err_restore:
    183  1.3  matt  * - clear the cache error log, cache error overflow log,
    184  1.3  matt  *   and cache interrupt registers
    185  1.3  matt  * - restore previous value to RMIXL_PCR_L1D_CONFIG0
    186  1.3  matt  */
    187  1.3  matt static inline void
    188  1.3  matt rmixl_cache_err_restore(uint64_t r)
    189  1.3  matt {
    190  1.3  matt 	rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG, 0);
    191  1.3  matt 	rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_OVF_LO, 0);
    192  1.3  matt 	rmixl_mtcr(RMIXL_PCR_L1D_CACHE_INTERRUPT, 0);
    193  1.3  matt 	rmixl_mtcr(RMIXL_PCR_L1D_CONFIG0, r);
    194  1.3  matt }
    195  1.3  matt 
    196  1.3  matt static inline uint64_t
    197  1.3  matt rmixl_cache_err_check(void)
    198  1.3  matt {
    199  1.3  matt 	return rmixl_mfcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG);
    200  1.3  matt }
    201  1.3  matt 
    202  1.3  matt static inline int
    203  1.3  matt rmixl_probe_4(volatile uint32_t *va)
    204  1.3  matt {
    205  1.3  matt 	uint32_t tmp;
    206  1.3  matt 	uint32_t r;
    207  1.3  matt 	int err;
    208  1.3  matt 	int s;
    209  1.3  matt 
    210  1.3  matt 	s = splhigh();
    211  1.3  matt 	r = rmixl_cache_err_dis();
    212  1.3  matt 	tmp = *va;			/* probe */
    213  1.3  matt 	err = rmixl_cache_err_check();
    214  1.3  matt 	rmixl_cache_err_restore(r);
    215  1.3  matt 	splx(s);
    216  1.3  matt 
    217  1.3  matt 	return (err == 0);
    218  1.3  matt }
    219  1.3  matt 
    220  1.2  matt #endif	/* _MIPS_RMI_RMIXLVAR_H_ */
    221