Home | History | Annotate | Line # | Download | only in rmi
rmixlvar.h revision 1.2.8.1
      1  1.2.8.1  jruoho /*	$NetBSD: rmixlvar.h,v 1.2.8.1 2011/06/06 09:06:11 jruoho 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.2.8.1  jruoho #include <mips/locore.h>
     43  1.2.8.1  jruoho #include <mips/rmi/rmixl_firmware.h>
     44  1.2.8.1  jruoho 
     45      1.2    matt #include <machine/bus.h>
     46      1.2    matt 
     47  1.2.8.1  jruoho #include <dev/pci/pcivar.h>
     48  1.2.8.1  jruoho 
     49  1.2.8.1  jruoho extern void rmixl_pcr_init_core(void);
     50  1.2.8.1  jruoho 
     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.2.8.1  jruoho static inline int
     87  1.2.8.1  jruoho cpu_rmixl_chip_type(const struct pridtab *ct)
     88  1.2.8.1  jruoho {
     89  1.2.8.1  jruoho 	return ct->cpu_cidflags & MIPS_CIDFL_RMI_TYPE;
     90  1.2.8.1  jruoho }
     91      1.2    matt 
     92      1.2    matt typedef enum {
     93  1.2.8.1  jruoho 	PSB_TYPE_UNKNOWN=0,
     94  1.2.8.1  jruoho 	PSB_TYPE_RMI,
     95  1.2.8.1  jruoho 	PSB_TYPE_DELL,
     96  1.2.8.1  jruoho } rmixlfw_psb_type_t;
     97      1.2    matt 
     98  1.2.8.1  jruoho static inline const char *
     99  1.2.8.1  jruoho rmixlfw_psb_type_name(rmixlfw_psb_type_t type)
    100  1.2.8.1  jruoho {
    101  1.2.8.1  jruoho 	switch(type) {
    102  1.2.8.1  jruoho 	case PSB_TYPE_UNKNOWN:
    103  1.2.8.1  jruoho 		return "unknown";
    104  1.2.8.1  jruoho 	case PSB_TYPE_RMI:
    105  1.2.8.1  jruoho 		return "RMI";
    106  1.2.8.1  jruoho 	case PSB_TYPE_DELL:
    107  1.2.8.1  jruoho 		return "DELL";
    108  1.2.8.1  jruoho 	default:
    109  1.2.8.1  jruoho 		return "undefined";
    110  1.2.8.1  jruoho 	}
    111  1.2.8.1  jruoho }
    112      1.2    matt 
    113      1.2    matt struct rmixl_config {
    114      1.2    matt 	uint64_t		 rc_io_pbase;
    115  1.2.8.1  jruoho 	uint64_t		 rc_flash_pbase;	/* FLASH_BAR */
    116  1.2.8.1  jruoho 	uint64_t		 rc_flash_mask;		/* FLASH_BAR */
    117  1.2.8.1  jruoho 	bus_addr_t		 rc_pci_cfg_pbase;
    118  1.2.8.1  jruoho 	bus_size_t		 rc_pci_cfg_size;
    119  1.2.8.1  jruoho 	bus_addr_t		 rc_pci_ecfg_pbase;
    120  1.2.8.1  jruoho 	bus_size_t		 rc_pci_ecfg_size;
    121      1.2    matt 	bus_addr_t		 rc_pci_mem_pbase;
    122      1.2    matt 	bus_size_t		 rc_pci_mem_size;
    123      1.2    matt 	bus_addr_t		 rc_pci_io_pbase;
    124      1.2    matt 	bus_size_t		 rc_pci_io_size;
    125  1.2.8.1  jruoho 	struct mips_bus_space	 rc_obio_eb_memt; 	/* DEVIO -eb */
    126  1.2.8.1  jruoho 	struct mips_bus_space	 rc_obio_el_memt; 	/* DEVIO -el */
    127  1.2.8.1  jruoho 	struct mips_bus_space	 rc_iobus_memt; 	/* Peripherals IO Bus */
    128  1.2.8.1  jruoho 	struct mips_bus_space	 rc_pci_cfg_memt; 	/* PCI CFG  */
    129  1.2.8.1  jruoho 	struct mips_bus_space	 rc_pci_ecfg_memt; 	/* PCI ECFG */
    130      1.2    matt 	struct mips_bus_space	 rc_pci_memt; 		/* PCI MEM */
    131      1.2    matt 	struct mips_bus_space	 rc_pci_iot; 		/* PCI IO  */
    132  1.2.8.1  jruoho 	struct mips_bus_dma_tag	 rc_dma_tag;
    133  1.2.8.1  jruoho 	bus_dma_tag_t		 rc_64bit_dmat;
    134  1.2.8.1  jruoho 	bus_dma_tag_t		 rc_32bit_dmat;
    135  1.2.8.1  jruoho 	bus_dma_tag_t		 rc_29bit_dmat;
    136      1.2    matt 	struct extent		*rc_phys_ex;	/* Note: MB units */
    137  1.2.8.1  jruoho 	struct extent		*rc_obio_eb_ex;
    138  1.2.8.1  jruoho 	struct extent		*rc_obio_el_ex;
    139  1.2.8.1  jruoho 	struct extent		*rc_iobus_ex;
    140  1.2.8.1  jruoho 	struct extent		*rc_pci_cfg_ex;
    141  1.2.8.1  jruoho 	struct extent		*rc_pci_ecfg_ex;
    142  1.2.8.1  jruoho 	struct extent		*rc_pci_mem_ex;
    143  1.2.8.1  jruoho 	struct extent		*rc_pci_io_ex;
    144      1.2    matt 	int			 rc_mallocsafe;
    145  1.2.8.1  jruoho 	rmixlfw_info_t 		 rc_psb_info;
    146  1.2.8.1  jruoho 	rmixlfw_psb_type_t	 rc_psb_type;
    147  1.2.8.1  jruoho 	volatile struct rmixlfw_cpu_wakeup_info
    148  1.2.8.1  jruoho 				*rc_cpu_wakeup_info;
    149  1.2.8.1  jruoho 	const void		*rc_cpu_wakeup_end;
    150      1.2    matt };
    151      1.2    matt 
    152      1.2    matt extern struct rmixl_config rmixl_configuration;
    153      1.2    matt 
    154  1.2.8.1  jruoho extern void rmixl_obio_eb_bus_mem_init(bus_space_tag_t, void *);
    155  1.2.8.1  jruoho extern void rmixl_obio_el_bus_mem_init(bus_space_tag_t, void *);
    156  1.2.8.1  jruoho extern void rmixl_iobus_bus_mem_init(bus_space_tag_t, void *);
    157  1.2.8.1  jruoho extern void rmixl_pci_cfg_bus_mem_init(bus_space_tag_t, void *);
    158  1.2.8.1  jruoho extern void rmixl_pci_ecfg_bus_mem_init(bus_space_tag_t, void *);
    159  1.2.8.1  jruoho extern void rmixl_pci_bus_mem_init(bus_space_tag_t, void *);
    160  1.2.8.1  jruoho extern void rmixl_pci_bus_io_init(bus_space_tag_t, void *);
    161      1.2    matt 
    162      1.2    matt extern void rmixl_addr_error_init(void);
    163      1.2    matt extern int  rmixl_addr_error_check(void);
    164      1.2    matt 
    165      1.2    matt extern uint64_t rmixl_mfcr(u_int);
    166      1.2    matt extern void rmixl_mtcr(uint64_t, u_int);
    167  1.2.8.1  jruoho extern void rmixl_eirr_ack(uint64_t, uint64_t, uint64_t);
    168  1.2.8.1  jruoho 
    169  1.2.8.1  jruoho 
    170  1.2.8.1  jruoho /*
    171  1.2.8.1  jruoho  * rmixl_cache_err_dis:
    172  1.2.8.1  jruoho  * - disable Cache, Data ECC, Snoop Tag Parity, Tag Parity errors
    173  1.2.8.1  jruoho  * - clear the cache error log
    174  1.2.8.1  jruoho  * - return previous value from RMIXL_PCR_L1D_CONFIG0
    175  1.2.8.1  jruoho  */
    176  1.2.8.1  jruoho static inline uint64_t
    177  1.2.8.1  jruoho rmixl_cache_err_dis(void)
    178  1.2.8.1  jruoho {
    179  1.2.8.1  jruoho 	uint64_t r;
    180  1.2.8.1  jruoho 
    181  1.2.8.1  jruoho 	r = rmixl_mfcr(RMIXL_PCR_L1D_CONFIG0);
    182  1.2.8.1  jruoho 	rmixl_mtcr(RMIXL_PCR_L1D_CONFIG0, r & ~0x2e);
    183  1.2.8.1  jruoho 	rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG, 0);
    184  1.2.8.1  jruoho 	return r;
    185  1.2.8.1  jruoho }
    186  1.2.8.1  jruoho 
    187  1.2.8.1  jruoho /*
    188  1.2.8.1  jruoho  * rmixl_cache_err_restore:
    189  1.2.8.1  jruoho  * - clear the cache error log, cache error overflow log,
    190  1.2.8.1  jruoho  *   and cache interrupt registers
    191  1.2.8.1  jruoho  * - restore previous value to RMIXL_PCR_L1D_CONFIG0
    192  1.2.8.1  jruoho  */
    193  1.2.8.1  jruoho static inline void
    194  1.2.8.1  jruoho rmixl_cache_err_restore(uint64_t r)
    195  1.2.8.1  jruoho {
    196  1.2.8.1  jruoho 	rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG, 0);
    197  1.2.8.1  jruoho 	rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_OVF_LO, 0);
    198  1.2.8.1  jruoho 	rmixl_mtcr(RMIXL_PCR_L1D_CACHE_INTERRUPT, 0);
    199  1.2.8.1  jruoho 	rmixl_mtcr(RMIXL_PCR_L1D_CONFIG0, r);
    200  1.2.8.1  jruoho }
    201  1.2.8.1  jruoho 
    202  1.2.8.1  jruoho static inline uint64_t
    203  1.2.8.1  jruoho rmixl_cache_err_check(void)
    204  1.2.8.1  jruoho {
    205  1.2.8.1  jruoho 	return rmixl_mfcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG);
    206  1.2.8.1  jruoho }
    207  1.2.8.1  jruoho 
    208  1.2.8.1  jruoho static inline int
    209  1.2.8.1  jruoho rmixl_probe_4(volatile uint32_t *va)
    210  1.2.8.1  jruoho {
    211  1.2.8.1  jruoho 	uint32_t tmp;
    212  1.2.8.1  jruoho 	uint32_t r;
    213  1.2.8.1  jruoho 	int err;
    214  1.2.8.1  jruoho 	int s;
    215  1.2.8.1  jruoho 
    216  1.2.8.1  jruoho 	s = splhigh();
    217  1.2.8.1  jruoho 	r = rmixl_cache_err_dis();
    218  1.2.8.1  jruoho 	tmp = *va;			/* probe */
    219  1.2.8.1  jruoho 	err = rmixl_cache_err_check();
    220  1.2.8.1  jruoho 	rmixl_cache_err_restore(r);
    221  1.2.8.1  jruoho 	splx(s);
    222  1.2.8.1  jruoho 
    223  1.2.8.1  jruoho 	return (err == 0);
    224  1.2.8.1  jruoho }
    225      1.2    matt 
    226      1.2    matt #endif	/* _MIPS_RMI_RMIXLVAR_H_ */
    227