1 /* $OpenBSD: tcasic.c,v 1.16 2010/11/11 17:54:52 miod Exp $ */ 2 /* $NetBSD: tcasic.c,v 1.36 2001/08/23 01:16:52 nisimura Exp $ */ 3 4 /* 5 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. 6 * All rights reserved. 7 * 8 * Author: Chris G. Demetriou 9 * 10 * Permission to use, copy, modify and distribute this software and 11 * its documentation is hereby granted, provided that both the copyright 12 * notice and this permission notice appear in all copies of the 13 * software, derivative works or modified versions, and any portions 14 * thereof, and that both notices appear in supporting documentation. 15 * 16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 19 * 20 * Carnegie Mellon requests users of this software to return to 21 * 22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 23 * School of Computer Science 24 * Carnegie Mellon University 25 * Pittsburgh PA 15213-3890 26 * 27 * any improvements or extensions that they make and grant Carnegie the 28 * rights to redistribute these changes. 29 */ 30 31 #include <sys/param.h> 32 #include <sys/systm.h> 33 #include <sys/device.h> 34 35 #include <machine/autoconf.h> 36 #include <machine/rpb.h> 37 #include <machine/cpu.h> 38 39 #include <dev/tc/tcvar.h> 40 #include <alpha/tc/tc_conf.h> 41 42 /* Definition of the driver for autoconfig. */ 43 int tcasicmatch(struct device *, void *, void *); 44 void tcasicattach(struct device *, struct device *, void *); 45 46 struct cfattach tcasic_ca = { 47 sizeof (struct device), tcasicmatch, tcasicattach, 48 }; 49 50 struct cfdriver tcasic_cd = { 51 NULL, "tcasic", DV_DULL, 52 }; 53 54 55 int tcasicprint(void *, const char *); 56 57 /* There can be only one. */ 58 int tcasicfound; 59 60 int 61 tcasicmatch(parent, cfdata, aux) 62 struct device *parent; 63 void *cfdata, *aux; 64 { 65 struct mainbus_attach_args *ma = aux; 66 67 /* Make sure that we're looking for a TurboChannel ASIC. */ 68 if (strcmp(ma->ma_name, tcasic_cd.cd_name)) 69 return (0); 70 71 if (tcasicfound) 72 return (0); 73 74 return (1); 75 } 76 77 void 78 tcasicattach(parent, self, aux) 79 struct device *parent; 80 struct device *self; 81 void *aux; 82 { 83 struct tcbus_attach_args tba; 84 void (*intr_setup)(void); 85 void (*iointr)(void *, unsigned long); 86 87 printf("\n"); 88 tcasicfound = 1; 89 90 switch (cputype) { 91 #ifdef DEC_3000_500 92 case ST_DEC_3000_500: 93 94 intr_setup = tc_3000_500_intr_setup; 95 iointr = tc_3000_500_iointr; 96 97 if ((hwrpb->rpb_type & SV_ST_MASK) == SV_ST_SANDPIPER) 98 tba.tba_speed = TC_SPEED_22_5_MHZ; 99 else 100 tba.tba_speed = TC_SPEED_25_MHZ; 101 tba.tba_nslots = tc_3000_500_nslots; 102 tba.tba_slots = tc_3000_500_slots; 103 if (hwrpb->rpb_variation & SV_GRAPHICS) { 104 tba.tba_nbuiltins = tc_3000_500_graphics_nbuiltins; 105 tba.tba_builtins = tc_3000_500_graphics_builtins; 106 } else { 107 tba.tba_nbuiltins = tc_3000_500_nographics_nbuiltins; 108 tba.tba_builtins = tc_3000_500_nographics_builtins; 109 } 110 tba.tba_intr_establish = tc_3000_500_intr_establish; 111 tba.tba_intr_disestablish = tc_3000_500_intr_disestablish; 112 tba.tba_get_dma_tag = tc_dma_get_tag_3000_500; 113 114 /* Do 3000/500-specific DMA setup now. */ 115 tc_dma_init_3000_500(tc_3000_500_nslots); 116 break; 117 #endif /* DEC_3000_500 */ 118 119 #ifdef DEC_3000_300 120 case ST_DEC_3000_300: 121 122 intr_setup = tc_3000_300_intr_setup; 123 iointr = tc_3000_300_iointr; 124 125 tba.tba_speed = TC_SPEED_12_5_MHZ; 126 tba.tba_nslots = tc_3000_300_nslots; 127 tba.tba_slots = tc_3000_300_slots; 128 tba.tba_nbuiltins = tc_3000_300_nbuiltins; 129 tba.tba_builtins = tc_3000_300_builtins; 130 tba.tba_intr_establish = tc_3000_300_intr_establish; 131 tba.tba_intr_disestablish = tc_3000_300_intr_disestablish; 132 tba.tba_get_dma_tag = tc_dma_get_tag_3000_300; 133 break; 134 #endif /* DEC_3000_300 */ 135 136 default: 137 panic("tcasicattach: bad cputype"); 138 } 139 140 tba.tba_busname = "tc"; 141 tba.tba_memt = tc_bus_mem_init(NULL); 142 143 tc_dma_init(); 144 145 (*intr_setup)(); 146 147 /* They all come in at 0x800. */ 148 scb_set(0x800, iointr, NULL); 149 150 config_found(self, &tba, tcasicprint); 151 } 152 153 int 154 tcasicprint(aux, pnp) 155 void *aux; 156 const char *pnp; 157 { 158 159 /* only TCs can attach to tcasics; easy. */ 160 if (pnp) 161 printf("tc at %s", pnp); 162 return (UNCONF); 163 } 164 165 #ifdef notyet 166 167 #include "wsdisplay.h" 168 169 #if NWSDISPLAY > 0 170 171 #include "sfb.h" 172 #include "sfbp.h" 173 #include "cfb.h" 174 #include "mfb.h" 175 #include "tfb.h" 176 #include "px.h" 177 #include "pxg.h" 178 179 extern void sfb_cnattach(tc_addr_t); 180 extern void sfbp_cnattach(tc_addr_t); 181 extern void cfb_cnattach(tc_addr_t); 182 extern void mfb_cnattach(tc_addr_t); 183 extern void tfb_cnattach(tc_addr_t); 184 extern void px_cnattach(tc_addr_t); 185 extern void pxg_cnattach(tc_addr_t); 186 extern int tc_checkslot(tc_addr_t, char *); 187 188 struct cnboards { 189 const char *cb_tcname; 190 void (*cb_cnattach)(tc_addr_t); 191 } static const cnboards[] = { 192 #if NSFB > 0 193 { "PMAGB-BA", sfb_cnattach }, 194 #endif 195 #if NSFBP > 0 196 { "PMAGD ", sfbp_cnattach }, 197 #endif 198 #if NCFB > 0 199 { "PMAG-BA ", cfb_cnattach }, 200 #endif 201 #if NMFB > 0 202 { "PMAG-AA ", mfb_cnattach }, 203 #endif 204 #if NTFB > 0 205 { "PMAG-JA ", tfb_cnattach }, 206 #endif 207 #if NPX > 0 208 { "PMAG-CA ", px_cnattach }, 209 #endif 210 #if NPXG > 0 211 { "PMAG-DA ", pxg_cnattach }, 212 { "PMAG-FA ", pxg_cnattach }, 213 { "PMAG-FB ", pxg_cnattach }, 214 { "PMAGB-FA", pxg_cnattach }, 215 { "PMAGB-FB", pxg_cnattach }, 216 #endif 217 }; 218 219 /* 220 * tc_fb_cnattach -- 221 * Attempt to attach the appropriate display driver to the 222 * output console. 223 */ 224 int 225 tc_fb_cnattach(tcaddr) 226 tc_addr_t tcaddr; 227 { 228 char tcname[TC_ROM_LLEN]; 229 int i; 230 231 if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname) == 0)) 232 return (EINVAL); 233 234 for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++) 235 if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0) 236 break; 237 238 if (i == sizeof(cnboards) / sizeof(cnboards[0])) 239 return (ENXIO); 240 241 (cnboards[i].cb_cnattach)(tcaddr); 242 return (0); 243 } 244 #endif /* if NWSDISPLAY > 0 */ 245 246 #else 247 248 int 249 tc_fb_cnattach(tcaddr) 250 tc_addr_t tcaddr; 251 { 252 return (ENXIO); 253 } 254 #endif 255