1 /* $NetBSD: dec_3000_300.c,v 1.50 2025/03/09 01:06:41 thorpej Exp $ */
2 
3 /*
4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29 
30 /*
31  * Additional Copyright (c) 1997 by Matthew Jacob for NASA/Ames Research Center
32  */
33 
34 #include <sys/cdefs.h>                            /* RCS ID & Copyright macro defns */
35 
36 __KERNEL_RCSID(0, "$NetBSD: dec_3000_300.c,v 1.50 2025/03/09 01:06:41 thorpej Exp $");
37 
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/device.h>
41 #include <sys/termios.h>
42 #include <sys/conf.h>
43 
44 #include <machine/rpb.h>
45 #include <machine/autoconf.h>
46 #include <machine/cpuconf.h>
47 
48 #include <dev/tc/tcvar.h>
49 #include <dev/tc/tcdsvar.h>
50 #include <alpha/tc/tc_3000_300.h>
51 
52 #include <machine/z8530var.h>
53 #include <dev/tc/zs_ioasicvar.h>
54 
55 #include "wsdisplay.h"
56 
57 void dec_3000_300_init(void);
58 static void dec_3000_300_cons_init(void);
59 static void dec_3000_300_device_register(device_t, void *);
60 
61 const struct alpha_variation_table dec_3000_300_variations[] = {
62           { SV_ST_PELICAN, "DEC 3000/300 (\"Pelican\")" },
63           { SV_ST_PELICA, "DEC 3000/300L (\"Pelica\")" },
64           { SV_ST_PELICANPLUS, "DEC 3000/300X (\"Pelican+\")" },
65           { SV_ST_PELICAPLUS, "DEC 3000/300LX (\"Pelica+\")" },
66           { 0, NULL },
67 };
68 
69 void
dec_3000_300_init(void)70 dec_3000_300_init(void)
71 {
72           uint64_t variation;
73 
74           platform.family = "DEC 3000/300 (\"Pelican\")";
75 
76           if ((platform.model = alpha_dsr_sysname()) == NULL) {
77                     variation = hwrpb->rpb_variation & SV_ST_MASK;
78                     if ((platform.model = alpha_variation_name(variation,
79                         dec_3000_300_variations)) == NULL)
80                               platform.model = alpha_unknown_sysname();
81           }
82 
83           platform.iobus = "tcasic";
84           platform.cons_init = dec_3000_300_cons_init;
85           platform.device_register = dec_3000_300_device_register;
86 }
87 
88 static void
dec_3000_300_cons_init(void)89 dec_3000_300_cons_init(void)
90 {
91           struct ctb *ctb;
92 
93           ctb = (struct ctb *)(((char *)hwrpb) + hwrpb->rpb_ctb_off);
94 
95           switch (ctb->ctb_term_type) {
96           case CTB_GRAPHICS:
97 #if NWSDISPLAY > 0
98                     /* display console ... */
99                     if (zs_ioasic_lk201_cnattach(0x1a0000000, 0x00180000, 0) == 0 &&
100                         tc_3000_300_fb_cnattach(
101                          CTB_TURBOSLOT_SLOT(ctb->ctb_turboslot)) == 0) {
102                               break;
103                     }
104 #endif
105                     printf("consinit: Unable to init console on keyboard and ");
106                     printf("TURBOchannel slot 0x%lx.\n", ctb->ctb_turboslot);
107                     printf("Using serial console.\n");
108                     /* FALLTHROUGH */
109 
110           case CTB_PRINTERPORT:
111                     /* serial console ... */
112                     /*
113                      * XXX This could stand some cleanup...
114                      */
115                     {
116                               /*
117                                * Delay to allow PROM putchars to complete.
118                                * FIFO depth * character time.
119                                * character time = (1000000 / (defaultrate / 10))
120                                */
121                               DELAY(160000000 / 9600);      /* XXX */
122 
123                               /*
124                                * Console is channel B of the first SCC.
125                                * XXX Should use ctb_line_off to get the
126                                * XXX line parameters.
127                                */
128                               zs_ioasic_cnattach(0x1a0000000, 0x00100000, 1);
129                               break;
130                     }
131 
132           default:
133                     printf("ctb->ctb_term_type = 0x%lx\n", ctb->ctb_term_type);
134                     printf("ctb->ctb_turboslot = 0x%lx\n", ctb->ctb_turboslot);
135                     panic("consinit: unknown console type %lu",
136                         ctb->ctb_term_type);
137                     /* NOTREACHED */
138           }
139 }
140 
141 static void
dec_3000_300_device_register(device_t dev,void * aux)142 dec_3000_300_device_register(device_t dev, void *aux)
143 {
144           tc_find_bootdev(dev, aux);
145 }
146