rmixlvar.h revision 1.4 1 1.4 cliff /* $NetBSD: rmixlvar.h,v 1.4 2011/03/18 00:58:54 cliff 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.4 cliff uint64_t rc_flash_pbase; /* FLASH_BAR */
116 1.4 cliff uint64_t rc_flash_mask; /* FLASH_BAR */
117 1.3 matt bus_addr_t rc_pci_cfg_pbase;
118 1.3 matt bus_size_t rc_pci_cfg_size;
119 1.3 matt bus_addr_t rc_pci_ecfg_pbase;
120 1.3 matt 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.3 matt struct mips_bus_space rc_obio_eb_memt; /* DEVIO -eb */
126 1.3 matt struct mips_bus_space rc_obio_el_memt; /* DEVIO -el */
127 1.4 cliff struct mips_bus_space rc_iobus_memt; /* Peripherals IO Bus */
128 1.3 matt struct mips_bus_space rc_pci_cfg_memt; /* PCI CFG */
129 1.3 matt 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.3 matt struct mips_bus_dma_tag rc_dma_tag;
133 1.3 matt bus_dma_tag_t rc_64bit_dmat;
134 1.3 matt bus_dma_tag_t rc_32bit_dmat;
135 1.3 matt bus_dma_tag_t rc_29bit_dmat;
136 1.2 matt struct extent *rc_phys_ex; /* Note: MB units */
137 1.3 matt struct extent *rc_obio_eb_ex;
138 1.3 matt struct extent *rc_obio_el_ex;
139 1.4 cliff struct extent *rc_iobus_ex;
140 1.3 matt struct extent *rc_pci_cfg_ex;
141 1.3 matt struct extent *rc_pci_ecfg_ex;
142 1.3 matt struct extent *rc_pci_mem_ex;
143 1.3 matt struct extent *rc_pci_io_ex;
144 1.2 matt int rc_mallocsafe;
145 1.3 matt rmixlfw_info_t rc_psb_info;
146 1.3 matt rmixlfw_psb_type_t rc_psb_type;
147 1.3 matt volatile struct rmixlfw_cpu_wakeup_info
148 1.3 matt *rc_cpu_wakeup_info;
149 1.3 matt 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.3 matt extern void rmixl_obio_eb_bus_mem_init(bus_space_tag_t, void *);
155 1.3 matt extern void rmixl_obio_el_bus_mem_init(bus_space_tag_t, void *);
156 1.4 cliff extern void rmixl_iobus_bus_mem_init(bus_space_tag_t, void *);
157 1.3 matt extern void rmixl_pci_cfg_bus_mem_init(bus_space_tag_t, void *);
158 1.3 matt extern void rmixl_pci_ecfg_bus_mem_init(bus_space_tag_t, void *);
159 1.3 matt extern void rmixl_pci_bus_mem_init(bus_space_tag_t, void *);
160 1.3 matt 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 matt
168 1.3 matt
169 1.3 matt /*
170 1.3 matt * rmixl_cache_err_dis:
171 1.3 matt * - disable Cache, Data ECC, Snoop Tag Parity, Tag Parity errors
172 1.3 matt * - clear the cache error log
173 1.3 matt * - return previous value from RMIXL_PCR_L1D_CONFIG0
174 1.3 matt */
175 1.3 matt static inline uint64_t
176 1.3 matt rmixl_cache_err_dis(void)
177 1.3 matt {
178 1.3 matt uint64_t r;
179 1.3 matt
180 1.3 matt r = rmixl_mfcr(RMIXL_PCR_L1D_CONFIG0);
181 1.3 matt rmixl_mtcr(RMIXL_PCR_L1D_CONFIG0, r & ~0x2e);
182 1.3 matt rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG, 0);
183 1.3 matt return r;
184 1.3 matt }
185 1.3 matt
186 1.3 matt /*
187 1.3 matt * rmixl_cache_err_restore:
188 1.3 matt * - clear the cache error log, cache error overflow log,
189 1.3 matt * and cache interrupt registers
190 1.3 matt * - restore previous value to RMIXL_PCR_L1D_CONFIG0
191 1.3 matt */
192 1.3 matt static inline void
193 1.3 matt rmixl_cache_err_restore(uint64_t r)
194 1.3 matt {
195 1.3 matt rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG, 0);
196 1.3 matt rmixl_mtcr(RMIXL_PCR_L1D_CACHE_ERROR_OVF_LO, 0);
197 1.3 matt rmixl_mtcr(RMIXL_PCR_L1D_CACHE_INTERRUPT, 0);
198 1.3 matt rmixl_mtcr(RMIXL_PCR_L1D_CONFIG0, r);
199 1.3 matt }
200 1.3 matt
201 1.3 matt static inline uint64_t
202 1.3 matt rmixl_cache_err_check(void)
203 1.3 matt {
204 1.3 matt return rmixl_mfcr(RMIXL_PCR_L1D_CACHE_ERROR_LOG);
205 1.3 matt }
206 1.3 matt
207 1.3 matt static inline int
208 1.3 matt rmixl_probe_4(volatile uint32_t *va)
209 1.3 matt {
210 1.3 matt uint32_t tmp;
211 1.3 matt uint32_t r;
212 1.3 matt int err;
213 1.3 matt int s;
214 1.3 matt
215 1.3 matt s = splhigh();
216 1.3 matt r = rmixl_cache_err_dis();
217 1.3 matt tmp = *va; /* probe */
218 1.3 matt err = rmixl_cache_err_check();
219 1.3 matt rmixl_cache_err_restore(r);
220 1.3 matt splx(s);
221 1.3 matt
222 1.3 matt return (err == 0);
223 1.3 matt }
224 1.3 matt
225 1.2 matt #endif /* _MIPS_RMI_RMIXLVAR_H_ */
226