1 /* $NetBSD: tcasic.c,v 1.42 2009/03/14 15:36:00 dsl Exp $ */ 2 3 /* 4 * Copyright (c) 1994, 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 #include "opt_dec_3000_300.h" 31 #include "opt_dec_3000_500.h" 32 33 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 34 35 __KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.42 2009/03/14 15:36:00 dsl Exp $"); 36 37 #include <sys/param.h> 38 #include <sys/systm.h> 39 #include <sys/device.h> 40 41 #include <machine/autoconf.h> 42 #include <machine/rpb.h> 43 #include <machine/alpha.h> 44 45 #include <dev/tc/tcvar.h> 46 #include <alpha/tc/tc_conf.h> 47 48 /* Definition of the driver for autoconfig. */ 49 int tcasicmatch(struct device *, struct cfdata *, void *); 50 void tcasicattach(struct device *, struct device *, void *); 51 52 CFATTACH_DECL(tcasic, sizeof (struct device), 53 tcasicmatch, tcasicattach, NULL, NULL); 54 55 extern struct cfdriver tcasic_cd; 56 57 int tcasicprint(void *, const char *); 58 59 /* There can be only one. */ 60 int tcasicfound; 61 62 int 63 tcasicmatch(struct device *parent, struct cfdata *cfdata, void *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 /* Make sure that the system supports a TurboChannel ASIC. */ 72 if ((cputype != ST_DEC_3000_500) && (cputype != ST_DEC_3000_300)) 73 return (0); 74 75 if (tcasicfound) 76 return (0); 77 78 return (1); 79 } 80 81 void 82 tcasicattach(struct device *parent, struct device *self, void *aux) 83 { 84 struct tcbus_attach_args tba; 85 void (*intr_setup)(void); 86 void (*iointr)(void *, unsigned long); 87 88 printf("\n"); 89 tcasicfound = 1; 90 91 switch (cputype) { 92 #ifdef DEC_3000_500 93 case ST_DEC_3000_500: 94 95 intr_setup = tc_3000_500_intr_setup; 96 iointr = tc_3000_500_iointr; 97 98 tba.tba_speed = TC_SPEED_25_MHZ; 99 tba.tba_nslots = tc_3000_500_nslots; 100 tba.tba_slots = tc_3000_500_slots; 101 if (hwrpb->rpb_variation & SV_GRAPHICS) { 102 tba.tba_nbuiltins = tc_3000_500_graphics_nbuiltins; 103 tba.tba_builtins = tc_3000_500_graphics_builtins; 104 } else { 105 tba.tba_nbuiltins = tc_3000_500_nographics_nbuiltins; 106 tba.tba_builtins = tc_3000_500_nographics_builtins; 107 } 108 tba.tba_intr_evcnt = tc_3000_500_intr_evcnt; 109 tba.tba_intr_establish = tc_3000_500_intr_establish; 110 tba.tba_intr_disestablish = tc_3000_500_intr_disestablish; 111 tba.tba_get_dma_tag = tc_dma_get_tag_3000_500; 112 113 /* Do 3000/500-specific DMA setup now. */ 114 tc_dma_init_3000_500(tc_3000_500_nslots); 115 break; 116 #endif /* DEC_3000_500 */ 117 118 #ifdef DEC_3000_300 119 case ST_DEC_3000_300: 120 121 intr_setup = tc_3000_300_intr_setup; 122 iointr = tc_3000_300_iointr; 123 124 tba.tba_speed = TC_SPEED_12_5_MHZ; 125 tba.tba_nslots = tc_3000_300_nslots; 126 tba.tba_slots = tc_3000_300_slots; 127 tba.tba_nbuiltins = tc_3000_300_nbuiltins; 128 tba.tba_builtins = tc_3000_300_builtins; 129 tba.tba_intr_evcnt = tc_3000_300_intr_evcnt; 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, IPL_VM); 149 150 config_found(self, &tba, tcasicprint); 151 } 152 153 int 154 tcasicprint(void *aux, const char *pnp) 155 { 156 157 /* only TCs can attach to tcasics; easy. */ 158 if (pnp) 159 aprint_normal("tc at %s", pnp); 160 return (UNCONF); 161 } 162 163 #include "wsdisplay.h" 164 165 #if NWSDISPLAY > 0 166 167 #include "sfb.h" 168 #include "sfbp.h" 169 #include "cfb.h" 170 #include "mfb.h" 171 #include "tfb.h" 172 #include "px.h" 173 #include "pxg.h" 174 175 extern void sfb_cnattach(tc_addr_t); 176 extern void sfbp_cnattach(tc_addr_t); 177 extern void cfb_cnattach(tc_addr_t); 178 extern void mfb_cnattach(tc_addr_t); 179 extern void tfb_cnattach(tc_addr_t); 180 extern void px_cnattach(tc_addr_t); 181 extern void pxg_cnattach(tc_addr_t); 182 extern int tc_checkslot(tc_addr_t, char *); 183 184 struct cnboards { 185 const char *cb_tcname; 186 void (*cb_cnattach)(tc_addr_t); 187 } static const cnboards[] = { 188 #if NSFB > 0 189 { "PMAGB-BA", sfb_cnattach }, 190 #endif 191 #if NSFBP > 0 192 { "PMAGD ", sfbp_cnattach }, 193 #endif 194 #if NCFB > 0 195 { "PMAG-BA ", cfb_cnattach }, 196 #endif 197 #if NMFB > 0 198 { "PMAG-AA ", mfb_cnattach }, 199 #endif 200 #if NTFB > 0 201 { "PMAG-JA ", tfb_cnattach }, 202 #endif 203 #if NPX > 0 204 { "PMAG-CA ", px_cnattach }, 205 #endif 206 #if NPXG > 0 207 { "PMAG-DA ", pxg_cnattach }, 208 { "PMAG-FA ", pxg_cnattach }, 209 { "PMAG-FB ", pxg_cnattach }, 210 { "PMAGB-FA", pxg_cnattach }, 211 { "PMAGB-FB", pxg_cnattach }, 212 #endif 213 }; 214 215 /* 216 * tc_fb_cnattach -- 217 * Attempt to attach the appropriate display driver to the 218 * output console. 219 */ 220 int 221 tc_fb_cnattach(tc_addr_t tcaddr) 222 { 223 char tcname[TC_ROM_LLEN]; 224 int i; 225 226 if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname) == 0)) 227 return (EINVAL); 228 229 for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++) 230 if (strncmp(tcname, cnboards[i].cb_tcname, TC_ROM_LLEN) == 0) 231 break; 232 233 if (i == sizeof(cnboards) / sizeof(cnboards[0])) 234 return (ENXIO); 235 236 (cnboards[i].cb_cnattach)(tcaddr); 237 return (0); 238 } 239 #endif /* if NWSDISPLAY > 0 */ 240