Home | History | Annotate | Line # | Download | only in alpha
      1 /* $NetBSD: dec_1000a.c,v 1.36 2025/03/09 01:06:41 thorpej Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is based on dec_kn20aa.c, written by Chris G. Demetriou at
      8  * Carnegie-Mellon University. Platform support for Noritake, Pintake, and
      9  * Corelle by Ross Harvey with copyright assignment by permission of Avalon
     10  * Computer Systems, Inc.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31  * POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /*
     35  * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
     36  * All rights reserved.
     37  *
     38  * Author: Chris G. Demetriou
     39  *
     40  * Permission to use, copy, modify and distribute this software and
     41  * its documentation is hereby granted, provided that both the copyright
     42  * notice and this permission notice appear in all copies of the
     43  * software, derivative works or modified versions, and any portions
     44  * thereof, and that both notices appear in supporting documentation.
     45  *
     46  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     47  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     48  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     49  *
     50  * Carnegie Mellon requests users of this software to return to
     51  *
     52  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     53  *  School of Computer Science
     54  *  Carnegie Mellon University
     55  *  Pittsburgh PA 15213-3890
     56  *
     57  * any improvements or extensions that they make and grant Carnegie the
     58  * rights to redistribute these changes.
     59  */
     60 /*
     61  * Additional Copyright (c) 1997 by Matthew Jacob for NASA/Ames Research Center
     62  */
     63 
     64 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     65 
     66 __KERNEL_RCSID(0, "$NetBSD: dec_1000a.c,v 1.36 2025/03/09 01:06:41 thorpej Exp $");
     67 
     68 #include <sys/param.h>
     69 #include <sys/systm.h>
     70 #include <sys/device.h>
     71 
     72 #include <machine/rpb.h>
     73 #include <machine/autoconf.h>
     74 #include <machine/cpuconf.h>
     75 
     76 #include <dev/pci/pcivar.h>
     77 
     78 #include <alpha/pci/apecsreg.h>
     79 #include <alpha/pci/apecsvar.h>
     80 #include <alpha/pci/ciareg.h>
     81 #include <alpha/pci/ciavar.h>
     82 
     83 void _dec_1000a_init(void);
     84 static void dec_1000a_cons_init(void);
     85 static void dec_1000a_device_register(device_t, void *);
     86 
     87 static const struct alpha_variation_table dec_1000_variations[] = {
     88 	{ 0, "AlphaServer 1000" },
     89 	{ 0, NULL },
     90 };
     91 
     92 static const struct alpha_variation_table dec_1000a_variations[] = {
     93 	{ 0, "AlphaServer 1000A" },
     94 	{ 0, NULL },
     95 };
     96 
     97 void
     98 _dec_1000a_init(void)
     99 {
    100 	uint64_t variation;
    101 
    102 	platform.family = "AlphaServer 1000/1000A";
    103 
    104 	if ((platform.model = alpha_dsr_sysname()) == NULL) {
    105 		variation = hwrpb->rpb_variation & SV_ST_MASK;
    106 		if ((platform.model = alpha_variation_name(variation,
    107 		    cputype == ST_DEC_1000 ? dec_1000_variations
    108 					   : dec_1000a_variations)) == NULL)
    109 			platform.model = alpha_unknown_sysname();
    110 	}
    111 
    112 	switch(PCS_CPU_MAJORTYPE(LOCATE_PCS(hwrpb, 0))) {
    113 	    case PCS_PROC_EV4:
    114 	    case PCS_PROC_EV45:
    115 		platform.iobus = "apecs";
    116 		break;
    117 	    default:
    118 		platform.iobus = "cia";
    119 		break;
    120 	}
    121 	platform.cons_init = dec_1000a_cons_init;
    122 	platform.device_register = dec_1000a_device_register;
    123 }
    124 
    125 static void
    126 dec_1000a_cons_init(void)
    127 {
    128 	struct ctb *ctb;
    129 	struct cia_config *ccp;
    130 	struct apecs_config *acp;
    131 	extern struct cia_config cia_configuration;
    132 	extern struct apecs_config apecs_configuration;
    133 	bus_space_tag_t iot, memt;
    134 	struct alpha_pci_chipset *pcichipset;
    135 	uint64_t saveslot;
    136 
    137 	if (strcmp(platform.iobus, "cia") == 0) {
    138 		ccp = &cia_configuration;
    139 		cia_init(ccp);
    140 		iot = &ccp->cc_iot;
    141 		memt = &ccp->cc_memt;
    142 		pcichipset = &ccp->cc_pc;
    143 	} else {
    144 		acp = &apecs_configuration;
    145 		apecs_init(acp);
    146 		iot = &acp->ac_iot;
    147 		memt = &acp->ac_memt;
    148 		pcichipset = &acp->ac_pc;
    149 	}
    150 
    151 	ctb = (struct ctb *)(((char *)hwrpb) + hwrpb->rpb_ctb_off);
    152 
    153 	saveslot = ctb->ctb_turboslot;
    154 
    155 	if (ctb->ctb_term_type == CTB_GRAPHICS &&
    156 	    CTB_TURBOSLOT_TYPE(ctb->ctb_turboslot) != CTB_TURBOSLOT_TYPE_PCI) {
    157 		/*
    158 		 * AlphaServer 1000s have a firmware bug whereby the
    159 		 * built-in ISA VGA is reported incorrectly -- ctb_turboslot
    160 		 * is mostly 0.  Patch it up to what the common code expects.
    161 		 * We'll restore it at the end in case the firmware is picky.
    162 		 */
    163 		ctb->ctb_turboslot = CTB_TURBOSLOT_TYPE_ISA << 16;
    164 	}
    165 
    166 	pci_consinit(pcichipset, iot, memt, iot, memt);
    167 
    168 	ctb->ctb_turboslot = saveslot;
    169 }
    170 
    171 static void
    172 dec_1000a_device_register(device_t dev, void *aux)
    173 {
    174 	pci_find_bootdev(NULL, dev, aux);
    175 }
    176