| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: machdep.c,v 1.1.2.25 2010/03/21 21:22:28 cliff Exp $ */ | | 1 | /* $NetBSD: machdep.c,v 1.1.2.26 2010/03/29 23:32:02 cliff Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2001, 2002 Wasabi Systems, Inc. | | 4 | * Copyright 2001, 2002 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Jason R. Thorpe and Simon Burge for Wasabi Systems, Inc. | | 7 | * Written by Jason R. Thorpe and Simon Burge for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -102,27 +102,27 @@ | | | @@ -102,27 +102,27 @@ |
102 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 102 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
103 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 103 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
104 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 104 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
105 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 105 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
106 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 106 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
107 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 107 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
108 | * SUCH DAMAGE. | | 108 | * SUCH DAMAGE. |
109 | * | | 109 | * |
110 | * @(#)machdep.c 8.3 (Berkeley) 1/12/94 | | 110 | * @(#)machdep.c 8.3 (Berkeley) 1/12/94 |
111 | * from: Utah Hdr: machdep.c 1.63 91/04/24 | | 111 | * from: Utah Hdr: machdep.c 1.63 91/04/24 |
112 | */ | | 112 | */ |
113 | | | 113 | |
114 | #include <sys/cdefs.h> | | 114 | #include <sys/cdefs.h> |
115 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1.2.25 2010/03/21 21:22:28 cliff Exp $"); | | 115 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1.2.26 2010/03/29 23:32:02 cliff Exp $"); |
116 | | | 116 | |
117 | #define __INTR_PRIVATE | | 117 | #define __INTR_PRIVATE |
118 | | | 118 | |
119 | #include "opt_ddb.h" | | 119 | #include "opt_ddb.h" |
120 | #include "opt_com.h" | | 120 | #include "opt_com.h" |
121 | #include "opt_execfmt.h" | | 121 | #include "opt_execfmt.h" |
122 | #include "opt_memsize.h" | | 122 | #include "opt_memsize.h" |
123 | | | 123 | |
124 | #include <sys/param.h> | | 124 | #include <sys/param.h> |
125 | #include <sys/systm.h> | | 125 | #include <sys/systm.h> |
126 | #include <sys/kernel.h> | | 126 | #include <sys/kernel.h> |
127 | #include <sys/buf.h> | | 127 | #include <sys/buf.h> |
128 | #include <sys/reboot.h> | | 128 | #include <sys/reboot.h> |
| @@ -156,27 +156,29 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v | | | @@ -156,27 +156,29 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v |
156 | #error no serial console | | 156 | #error no serial console |
157 | #endif | | 157 | #endif |
158 | | | 158 | |
159 | #include <dev/ic/comreg.h> | | 159 | #include <dev/ic/comreg.h> |
160 | #include <dev/ic/comvar.h> | | 160 | #include <dev/ic/comvar.h> |
161 | | | 161 | |
162 | #include <mips/include/intr.h> | | 162 | #include <mips/include/intr.h> |
163 | | | 163 | |
164 | #include <mips/rmi/rmixlreg.h> | | 164 | #include <mips/rmi/rmixlreg.h> |
165 | #include <mips/rmi/rmixlvar.h> | | 165 | #include <mips/rmi/rmixlvar.h> |
166 | #include <mips/rmi/rmixl_intr.h> | | 166 | #include <mips/rmi/rmixl_intr.h> |
167 | #include <mips/rmi/rmixl_firmware.h> | | 167 | #include <mips/rmi/rmixl_firmware.h> |
168 | #include <mips/rmi/rmixl_comvar.h> | | 168 | #include <mips/rmi/rmixl_comvar.h> |
| | | 169 | #include <mips/rmi/rmixl_pcievar.h> |
169 | | | 170 | |
| | | 171 | #define MACHDEP_DEBUG 1 /* XXX TMP FIXME */ |
170 | #ifdef MACHDEP_DEBUG | | 172 | #ifdef MACHDEP_DEBUG |
171 | int machdep_debug=MACHDEP_DEBUG; | | 173 | int machdep_debug=MACHDEP_DEBUG; |
172 | # define DPRINTF(x) do { if (machdep_debug) printf x ; } while(0) | | 174 | # define DPRINTF(x) do { if (machdep_debug) printf x ; } while(0) |
173 | #else | | 175 | #else |
174 | # define DPRINTF(x) | | 176 | # define DPRINTF(x) |
175 | #endif | | 177 | #endif |
176 | | | 178 | |
177 | #ifndef CONSFREQ | | 179 | #ifndef CONSFREQ |
178 | # define CONSFREQ 66000000 | | 180 | # define CONSFREQ 66000000 |
179 | #endif | | 181 | #endif |
180 | #ifndef CONSPEED | | 182 | #ifndef CONSPEED |
181 | # define CONSPEED 38400 | | 183 | # define CONSPEED 38400 |
182 | #endif | | 184 | #endif |
| @@ -196,28 +198,29 @@ struct rmixl_config rmixl_configuration; | | | @@ -196,28 +198,29 @@ struct rmixl_config rmixl_configuration; |
196 | | | 198 | |
197 | | | 199 | |
198 | /* | | 200 | /* |
199 | * array of tested firmware versions | | 201 | * array of tested firmware versions |
200 | * if you find new ones and they work | | 202 | * if you find new ones and they work |
201 | * please add them | | 203 | * please add them |
202 | */ | | 204 | */ |
203 | typedef struct rmiclfw_psb_id { | | 205 | typedef struct rmiclfw_psb_id { |
204 | uint64_t psb_version; | | 206 | uint64_t psb_version; |
205 | rmixlfw_psb_type_t psb_type; | | 207 | rmixlfw_psb_type_t psb_type; |
206 | } rmiclfw_psb_id_t; | | 208 | } rmiclfw_psb_id_t; |
207 | static rmiclfw_psb_id_t rmiclfw_psb_id[] = { | | 209 | static rmiclfw_psb_id_t rmiclfw_psb_id[] = { |
208 | { 0x4958d4fb00000056ULL, PSB_TYPE_RMI }, | | 210 | { 0x4958d4fb00000056ULL, PSB_TYPE_RMI }, |
209 | { 0x49a5a8fa00000056ULL, PSB_TYPE_DELL }, | | | |
210 | { 0x4aacdb6a00000056ULL, PSB_TYPE_RMI }, | | 211 | { 0x4aacdb6a00000056ULL, PSB_TYPE_RMI }, |
| | | 212 | { 0x49a5a8fa00000056ULL, PSB_TYPE_DELL }, |
| | | 213 | { 0x4b8ead3100000056ULL, PSB_TYPE_DELL }, |
211 | }; | | 214 | }; |
212 | #define RMICLFW_PSB_VERSIONS_LEN \ | | 215 | #define RMICLFW_PSB_VERSIONS_LEN \ |
213 | (sizeof(rmiclfw_psb_id)/sizeof(rmiclfw_psb_id[0])) | | 216 | (sizeof(rmiclfw_psb_id)/sizeof(rmiclfw_psb_id[0])) |
214 | | | 217 | |
215 | /* | | 218 | /* |
216 | * storage for fixed extent used to allocate physical address regions | | 219 | * storage for fixed extent used to allocate physical address regions |
217 | * because extent(9) start and end values are u_long, they are only | | 220 | * because extent(9) start and end values are u_long, they are only |
218 | * 32 bits on a 32 bit kernel, which is insuffucuent since XLS physical | | 221 | * 32 bits on a 32 bit kernel, which is insuffucuent since XLS physical |
219 | * address is 40 bits wide. So the "physaddr" map stores regions | | 222 | * address is 40 bits wide. So the "physaddr" map stores regions |
220 | * in units of megabytes. | | 223 | * in units of megabytes. |
221 | */ | | 224 | */ |
222 | static u_long rmixl_physaddr_storage[ | | 225 | static u_long rmixl_physaddr_storage[ |
223 | EXTENT_FIXED_STORAGE_SIZE(32)/sizeof(u_long) | | 226 | EXTENT_FIXED_STORAGE_SIZE(32)/sizeof(u_long) |
| @@ -598,73 +601,38 @@ rmixl_physaddr_init(void) | | | @@ -598,73 +601,38 @@ rmixl_physaddr_init(void) |
598 | if ((r & RMIXL_DRAM_BAR_STATUS) == 0) | | 601 | if ((r & RMIXL_DRAM_BAR_STATUS) == 0) |
599 | continue; /* not enabled */ | | 602 | continue; /* not enabled */ |
600 | base = (u_long)(DRAM_BAR_TO_BASE((uint64_t)r) / (1024 * 1024)); | | 603 | base = (u_long)(DRAM_BAR_TO_BASE((uint64_t)r) / (1024 * 1024)); |
601 | size = (u_long)(DRAM_BAR_TO_SIZE((uint64_t)r) / (1024 * 1024)); | | 604 | size = (u_long)(DRAM_BAR_TO_SIZE((uint64_t)r) / (1024 * 1024)); |
602 | | | 605 | |
603 | DPRINTF(("%s: %d: %d: 0x%08x -- 0x%010lx:%lu MB\n", | | 606 | DPRINTF(("%s: %d: %d: 0x%08x -- 0x%010lx:%lu MB\n", |
604 | __func__, __LINE__, i, r, base * (1024 * 1024), size)); | | 607 | __func__, __LINE__, i, r, base * (1024 * 1024), size)); |
605 | if (extent_alloc_region(ext, base, size, EX_NOWAIT) != 0) | | 608 | if (extent_alloc_region(ext, base, size, EX_NOWAIT) != 0) |
606 | panic("%s: extent_alloc_region(%p, %#lx, %#lx, %#x) " | | 609 | panic("%s: extent_alloc_region(%p, %#lx, %#lx, %#x) " |
607 | "failed", __func__, ext, base, size, EX_NOWAIT); | | 610 | "failed", __func__, ext, base, size, EX_NOWAIT); |
608 | } | | 611 | } |
609 | | | 612 | |
610 | /* | | 613 | /* |
611 | * grab regions per PCIe CFG, ECFG, IO, MEM BARs | | 614 | * get chip-dependent physaddr regions |
612 | */ | | 615 | */ |
613 | r = RMIXL_IOREG_READ(RMIXL_SBC_PCIE_CFG_BAR); | | 616 | switch(cpu_rmixl_chip_type(mips_options.mips_cpu)) { |
614 | if ((r & RMIXL_PCIE_CFG_BAR_ENB) != 0) { | | 617 | case CIDFL_RMI_TYPE_XLR: |
615 | base = (u_long)(RMIXL_PCIE_CFG_BAR_TO_BA((uint64_t)r) | | 618 | /* XXX TBD */ |
616 | / (1024 * 1024)); | | 619 | break; |
617 | size = (u_long)RMIXL_PCIE_CFG_SIZE / (1024 * 1024); | | 620 | case CIDFL_RMI_TYPE_XLS: |
618 | DPRINTF(("%s: %d: %s: 0x%08x -- 0x%010lx:%ld MB\n", __func__, | | 621 | rmixl_physaddr_init_pcie(ext); |
619 | __LINE__, "CFG", r, base * 1024 * 1024, size)); | | 622 | break; |
620 | if (extent_alloc_region(ext, base, size, EX_NOWAIT) != 0) | | 623 | case CIDFL_RMI_TYPE_XLP: |
621 | panic("%s: extent_alloc_region(%p, %#lx, %#lx, %#x) " | | 624 | /* XXX TBD */ |
622 | "failed", __func__, ext, base, size, EX_NOWAIT); | | 625 | panic("%s: RMI XLP not yet supported", __func__); |
623 | } | | | |
624 | r = RMIXL_IOREG_READ(RMIXL_SBC_PCIE_ECFG_BAR); | | | |
625 | if ((r & RMIXL_PCIE_ECFG_BAR_ENB) != 0) { | | | |
626 | base = (u_long)(RMIXL_PCIE_ECFG_BAR_TO_BA((uint64_t)r) | | | |
627 | / (1024 * 1024)); | | | |
628 | size = (u_long)RMIXL_PCIE_ECFG_SIZE / (1024 * 1024); | | | |
629 | DPRINTF(("%s: %d: %s: 0x%08x -- 0x%010lx:%ld MB\n", __func__, | | | |
630 | __LINE__, "ECFG", r, base * 1024 * 1024, size)); | | | |
631 | if (extent_alloc_region(ext, base, size, EX_NOWAIT) != 0) | | | |
632 | panic("%s: extent_alloc_region(%p, %#lx, %#lx, %#x) " | | | |
633 | "failed", __func__, ext, base, size, EX_NOWAIT); | | | |
634 | } | | | |
635 | r = RMIXL_IOREG_READ(RMIXL_SBC_PCIE_MEM_BAR); | | | |
636 | if ((r & RMIXL_PCIE_MEM_BAR_ENB) != 0) { | | | |
637 | base = (u_long)(RMIXL_PCIE_MEM_BAR_TO_BA((uint64_t)r) | | | |
638 | / (1024 * 1024)); | | | |
639 | size = (u_long)(RMIXL_PCIE_MEM_BAR_TO_SIZE((uint64_t)r) | | | |
640 | / (1024 * 1024)); | | | |
641 | DPRINTF(("%s: %d: %s: 0x%08x -- 0x%010lx:%ld MB\n", __func__, | | | |
642 | __LINE__, "MEM", r, base * 1024 * 1024, size)); | | | |
643 | if (extent_alloc_region(ext, base, size, EX_NOWAIT) != 0) | | | |
644 | panic("%s: extent_alloc_region(%p, %#lx, %#lx, %#x) " | | | |
645 | "failed", __func__, ext, base, size, EX_NOWAIT); | | | |
646 | } | | | |
647 | r = RMIXL_IOREG_READ(RMIXL_SBC_PCIE_IO_BAR); | | | |
648 | if ((r & RMIXL_PCIE_IO_BAR_ENB) != 0) { | | | |
649 | base = (u_long)(RMIXL_PCIE_IO_BAR_TO_BA((uint64_t)r) | | | |
650 | / (1024 * 1024)); | | | |
651 | size = (u_long)(RMIXL_PCIE_IO_BAR_TO_SIZE((uint64_t)r) | | | |
652 | / (1024 * 1024)); | | | |
653 | DPRINTF(("%s: %d: %s: 0x%08x -- 0x%010lx:%ld MB\n", __func__, | | | |
654 | __LINE__, "IO", r, base * 1024 * 1024, size)); | | | |
655 | if (extent_alloc_region(ext, base, size, EX_NOWAIT) != 0) | | | |
656 | panic("%s: extent_alloc_region(%p, %#lx, %#lx, %#x) " | | | |
657 | "failed", __func__, ext, base, size, EX_NOWAIT); | | | |
658 | } | | 626 | } |
659 | | | 627 | |
660 | /* | | 628 | /* |
661 | * at this point all regions left in "physaddr" extent | | 629 | * at this point all regions left in "physaddr" extent |
662 | * are unused holes in the physical adress space | | 630 | * are unused holes in the physical adress space |
663 | * available for use as needed. | | 631 | * available for use as needed. |
664 | */ | | 632 | */ |
665 | rmixl_configuration.rc_phys_ex = ext; | | 633 | rmixl_configuration.rc_phys_ex = ext; |
666 | #ifdef MACHDEP_DEBUG | | 634 | #ifdef MACHDEP_DEBUG |
667 | extent_print(ext); | | 635 | extent_print(ext); |
668 | #endif | | 636 | #endif |
669 | } | | 637 | } |
670 | | | 638 | |