1 /* $NetBSD: dec_2100_a500.c,v 1.27 2025/03/09 01:06:41 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 1999 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 /* 33 * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University. 34 * All rights reserved. 35 * 36 * Author: Chris G. Demetriou 37 * 38 * Permission to use, copy, modify and distribute this software and 39 * its documentation is hereby granted, provided that both the copyright 40 * notice and this permission notice appear in all copies of the 41 * software, derivative works or modified versions, and any portions 42 * thereof, and that both notices appear in supporting documentation. 43 * 44 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 45 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 46 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 47 * 48 * Carnegie Mellon requests users of this software to return to 49 * 50 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU 51 * School of Computer Science 52 * Carnegie Mellon University 53 * Pittsburgh PA 15213-3890 54 * 55 * any improvements or extensions that they make and grant Carnegie the 56 * rights to redistribute these changes. 57 */ 58 59 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 60 61 __KERNEL_RCSID(0, "$NetBSD: dec_2100_a500.c,v 1.27 2025/03/09 01:06:41 thorpej Exp $"); 62 63 #include <sys/param.h> 64 #include <sys/systm.h> 65 #include <sys/device.h> 66 #include <sys/lwp.h> 67 68 #include <machine/rpb.h> 69 #include <machine/autoconf.h> 70 #include <machine/cpuconf.h> 71 #include <machine/alpha.h> 72 73 #include <dev/pci/pcivar.h> 74 75 #include <alpha/pci/ttwogareg.h> 76 #include <alpha/pci/ttwogavar.h> 77 78 #define DR_VERBOSE(f) while (0) 79 80 void _dec_2100_a500_init(void); 81 static void dec_2100_a500_cons_init(void); 82 static void dec_2100_a500_device_register(device_t, void *); 83 static void dec_2100_a500_machine_check(unsigned long, struct trapframe *, 84 unsigned long, unsigned long); 85 86 void 87 _dec_2100_a500_init(void) 88 { 89 90 switch (cputype) { 91 case ST_DEC_2100_A500: 92 if (alpha_implver() == ALPHA_IMPLVER_EV5) 93 platform.family = "AlphaServer 2100 (\"Sable-Gamma\")"; 94 else 95 platform.family = "AlphaServer 2100 (\"Sable\")"; 96 break; 97 98 case ST_DEC_2100A_A500: 99 platform.family = "AlphaServer 2100A (\"Lynx\")"; 100 break; 101 102 default: 103 panic("dec_2100_a500_init: Not a Sable, Sable-Gamma, or Lynx?"); 104 } 105 106 if ((platform.model = alpha_dsr_sysname()) == NULL) { 107 /* XXX don't know variations yet */ 108 platform.model = alpha_unknown_sysname(); 109 } 110 111 platform.iobus = "ttwoga"; 112 platform.cons_init = dec_2100_a500_cons_init; 113 platform.device_register = dec_2100_a500_device_register; 114 platform.mcheck_handler = dec_2100_a500_machine_check; 115 } 116 117 static void 118 dec_2100_a500_cons_init(void) 119 { 120 struct ctb *ctb; 121 uint64_t ctbslot; 122 struct ttwoga_config *tcp; 123 bus_space_tag_t isa_iot, isa_memt; 124 125 ctb = (struct ctb *)(((char *)hwrpb) + hwrpb->rpb_ctb_off); 126 ctbslot = ctb->ctb_turboslot; 127 128 tcp = ttwoga_init(0); 129 130 isa_iot = &tcp->tc_iot; 131 isa_memt = &tcp->tc_memt; 132 133 switch (ctb->ctb_term_type) { 134 case CTB_PRINTERPORT: 135 /* serial console ... */ 136 assert(CTB_TURBOSLOT_HOSE(ctbslot) == 0); 137 break; 138 139 case CTB_GRAPHICS: 140 /* PCI display might be on a different hose. */ 141 if (CTB_TURBOSLOT_TYPE(ctbslot) == CTB_TURBOSLOT_TYPE_PCI) { 142 tcp = ttwoga_init(CTB_TURBOSLOT_HOSE(ctbslot)); 143 } 144 break; 145 146 default: 147 /* Let pci_consinit() handle it. */ 148 break; 149 } 150 151 pci_consinit(&tcp->tc_pc, &tcp->tc_iot, &tcp->tc_memt, 152 isa_iot, isa_memt); 153 } 154 155 static void 156 dec_2100_a500_device_register(device_t dev, void *aux) 157 { 158 static device_t primarydev; 159 struct bootdev_data *b = bootdev_data; 160 161 if (booted_device != NULL || b == NULL) { 162 return; 163 } 164 165 if (primarydev == NULL) { 166 if (device_is_a(dev, "ttwopci")) { 167 struct pcibus_attach_args *pba = aux; 168 169 if (b->bus == pba->pba_bus) { 170 primarydev = dev; 171 DR_VERBOSE(printf("\nprimarydev = %s\n", 172 device_xname(dev))); 173 } 174 } 175 return; 176 } 177 178 pci_find_bootdev(primarydev, dev, aux); 179 } 180 181 /* 182 * Sable, Sable-Gamma, and Lynx machine check handlers. 183 */ 184 185 static void 186 dec_2100_a500_machine_check(unsigned long mces, struct trapframe *framep, 187 unsigned long vector, unsigned long param) 188 { 189 struct mchkinfo *mcp = &curcpu()->ci_mcinfo; 190 191 /* 192 * This is a work-around for a T2 core logic bug. See 193 * alpha/pci/ttwoga_pci.c. 194 */ 195 196 if (ttwoga_conf_cpu == cpu_number()) 197 mcp->mc_expected = 1; 198 199 machine_check(mces, framep, vector, param); 200 } 201