1 /* $NetBSD: if_cs_ofisa_machdep.c,v 1.5 2005/12/11 12:19:04 christos Exp $ */ 2 3 /* 4 * Copyright 1998 5 * Digital Equipment Corporation. All rights reserved. 6 * 7 * This software is furnished under license and may be used and 8 * copied only in accordance with the following terms and conditions. 9 * Subject to these conditions, you may download, copy, install, 10 * use, modify and distribute this software in source and/or binary 11 * form. No title or ownership is transferred hereby. 12 * 13 * 1) Any source code used, modified or distributed must reproduce 14 * and retain this copyright notice and list of conditions as 15 * they appear in the source file. 16 * 17 * 2) No right is granted to use any trade name, trademark, or logo of 18 * Digital Equipment Corporation. Neither the "Digital Equipment 19 * Corporation" name nor any trademark or logo of Digital Equipment 20 * Corporation may be used to endorse or promote products derived 21 * from this software without the prior written permission of 22 * Digital Equipment Corporation. 23 * 24 * 3) This software is provided "AS-IS" and any express or implied 25 * warranties, including but not limited to, any implied warranties 26 * of merchantability, fitness for a particular purpose, or 27 * non-infringement are disclaimed. In no event shall DIGITAL be 28 * liable for any damages whatsoever, and in particular, DIGITAL 29 * shall not be liable for special, indirect, consequential, or 30 * incidental damages or damages for lost profits, loss of 31 * revenue or loss of use, whether such damages arise in contract, 32 * negligence, tort, under statute, in equity, at law or otherwise, 33 * even if advised of the possibility of such damage. 34 */ 35 36 /* 37 * WARNING: THIS FILE IS VERY SHARK-SPECIFIC! 38 */ 39 40 #include <sys/cdefs.h> 41 __KERNEL_RCSID(0, "$NetBSD: if_cs_ofisa_machdep.c,v 1.5 2005/12/11 12:19:04 christos Exp $"); 42 43 #include "opt_compat_old_ofw.h" 44 45 #include <sys/param.h> 46 #include <sys/device.h> 47 #include <sys/systm.h> 48 #include <sys/malloc.h> 49 #include <sys/socket.h> 50 51 #include <net/if.h> 52 #include <net/if_ether.h> 53 #include <net/if_media.h> 54 55 #include <machine/bus.h> 56 #include <machine/intr.h> 57 58 #include <dev/ofw/openfirm.h> 59 #include <dev/isa/isavar.h> 60 #include <dev/ofisa/ofisavar.h> 61 62 #include <dev/ic/cs89x0reg.h> 63 #include <dev/ic/cs89x0var.h> 64 65 #ifdef COMPAT_OLD_OFW 66 67 int 68 cs_ofisa_md_match(parent, cf, aux) 69 struct device *parent; 70 struct cfdata *cf; 71 void *aux; 72 { 73 struct ofisa_attach_args *aa = aux; 74 char type[64]; 75 char name[64]; 76 char model[64]; 77 char compatible[64]; 78 int rv; 79 80 rv = 0; 81 if (1) { /* XXX old firmware compat enabled */ 82 /* At a minimum, must match type and name properties. */ 83 if (OF_getprop(aa->oba.oba_phandle, "device_type", type, 84 sizeof(type)) < 0 || strcmp(type, "network") != 0 || 85 OF_getprop(aa->oba.oba_phandle, "name", name, 86 sizeof(name)) < 0 || strcmp(name, "ethernet") != 0) 87 return (0); 88 89 /* Full match on model. */ 90 if (OF_getprop(aa->oba.oba_phandle, "model", model, 91 sizeof(model)) > 0 && strcmp(model, "CS8900") == 0) 92 rv = 3; 93 94 /* Check for compatible match. */ 95 if (OF_getprop(aa->oba.oba_phandle, "compatible", compatible, 96 sizeof(compatible)) > 0 && pmatch(compatible, "*CS8900*", 97 NULL) > 0) 98 rv = 2; 99 } 100 return (rv); 101 } 102 103 int 104 cs_ofisa_md_reg_fixup(parent, self, aux, descp, ndescs, ndescsfilled) 105 struct device *parent, *self; 106 void *aux; 107 struct ofisa_reg_desc *descp; 108 int ndescs, ndescsfilled; 109 { 110 111 if (1) { /* XXX old firmware compat enabled */ 112 /* We can't provide it. */ 113 if (ndescs != 2) 114 return (ndescsfilled); 115 116 /* Firmware provided it. */ 117 if (ndescsfilled == 2) 118 return (ndescsfilled); 119 120 descp[0].type = OFISA_REG_TYPE_IO; 121 descp[0].addr = 0x300; 122 descp[0].len = CS8900_IOSIZE; 123 124 descp[1].type = OFISA_REG_TYPE_MEM; 125 descp[1].addr = 0xd0000; 126 descp[1].len = 4096; 127 } 128 return (ndescsfilled); 129 } 130 131 int 132 cs_ofisa_md_intr_fixup(parent, self, aux, descp, ndescs, ndescsfilled) 133 struct device *parent, *self; 134 void *aux; 135 struct ofisa_intr_desc *descp; 136 int ndescs, ndescsfilled; 137 { 138 139 if (1) /* XXX old firmware compat enabled */ 140 if (ndescs > 0 && ndescsfilled > 0) 141 descp[0].share = IST_LEVEL; 142 return (ndescsfilled); 143 } 144 145 int * 146 cs_ofisa_md_media_fixup(parent, self, aux, media, nmediap, defmediap) 147 struct device *parent, *self; 148 void *aux; 149 int *media, *nmediap, *defmediap; 150 { 151 152 if (1) { /* XXX old firmware compat enabled */ 153 if (media == NULL) { 154 media = malloc(2 * sizeof(int), M_TEMP, M_NOWAIT); 155 if (media == NULL) 156 return (NULL); 157 media[0] = IFM_ETHER|IFM_10_T; 158 media[1] = IFM_ETHER|IFM_10_T|IFM_FDX; 159 *nmediap = 2; 160 *defmediap = media[0]; 161 } 162 } 163 return (media); 164 } 165 166 int 167 cs_ofisa_md_dma_fixup(parent, self, aux, descp, ndescs, ndescsfilled) 168 struct device *parent, *self; 169 void *aux; 170 struct ofisa_dma_desc *descp; 171 int ndescs, ndescsfilled; 172 { 173 struct ofisa_attach_args *aa = aux; 174 175 if (ndescs > 0 && ndescsfilled > 0) { 176 if (OF_getproplen(aa->oba.oba_phandle, "no-dma") >= 0) 177 descp[0].drq = -1; 178 } 179 return (ndescsfilled); 180 } 181 182 #endif /* COMPAT_OLD_OFW */ 183 184 int 185 cs_ofisa_md_cfgflags_fixup(parent, self, aux) 186 struct device *parent, *self; 187 void *aux; 188 { 189 190 return (CFGFLG_USE_SA|CFGFLG_IOCHRDY|CFGFLG_NOT_EEPROM); 191 } 192