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