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