Home | History | Annotate | Line # | Download | only in dev
gvpbus.c revision 1.25.12.1
      1  1.25.12.1       tls /*	$NetBSD: gvpbus.c,v 1.25.12.1 2012/11/20 03:00:58 tls Exp $ */
      2        1.4       cgd 
      3        1.1    chopps /*
      4        1.1    chopps  * Copyright (c) 1994 Christian E. Hopps
      5        1.1    chopps  * All rights reserved.
      6        1.1    chopps  *
      7        1.1    chopps  * Redistribution and use in source and binary forms, with or without
      8        1.1    chopps  * modification, are permitted provided that the following conditions
      9        1.1    chopps  * are met:
     10        1.1    chopps  * 1. Redistributions of source code must retain the above copyright
     11        1.1    chopps  *    notice, this list of conditions and the following disclaimer.
     12        1.1    chopps  * 2. Redistributions in binary form must reproduce the above copyright
     13        1.1    chopps  *    notice, this list of conditions and the following disclaimer in the
     14        1.1    chopps  *    documentation and/or other materials provided with the distribution.
     15        1.1    chopps  * 3. All advertising materials mentioning features or use of this software
     16        1.1    chopps  *    must display the following acknowledgement:
     17        1.1    chopps  *      This product includes software developed by Christian E. Hopps.
     18        1.1    chopps  * 4. The name of the author may not be used to endorse or promote products
     19        1.1    chopps  *    derived from this software without specific prior written permission
     20        1.1    chopps  *
     21        1.1    chopps  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22        1.1    chopps  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23        1.1    chopps  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24        1.1    chopps  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25        1.1    chopps  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26        1.1    chopps  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27        1.1    chopps  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28        1.1    chopps  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29        1.1    chopps  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30        1.1    chopps  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31        1.1    chopps  */
     32       1.19   aymeric 
     33       1.19   aymeric #include <sys/cdefs.h>
     34  1.25.12.1       tls __KERNEL_RCSID(0, "$NetBSD: gvpbus.c,v 1.25.12.1 2012/11/20 03:00:58 tls Exp $");
     35       1.19   aymeric 
     36        1.1    chopps #include <sys/param.h>
     37        1.1    chopps #include <sys/device.h>
     38       1.11     veego #include <sys/systm.h>
     39        1.1    chopps #include <amiga/amiga/device.h>
     40        1.6    chopps #include <amiga/dev/zbusvar.h>
     41        1.1    chopps #include <amiga/dev/gvpbusvar.h>
     42        1.1    chopps 
     43       1.25      matt void gvpbusattach(device_t, device_t, void *);
     44       1.25      matt int gvpbusmatch(device_t, cfdata_t, void *);
     45  1.25.12.1       tls int gvpbusprint(void *, const char *);
     46        1.1    chopps 
     47        1.7    chopps extern int sbic_no_dma;		/* Kludge for A1291 - mlh */
     48        1.7    chopps 
     49       1.25      matt CFATTACH_DECL_NEW(gvpbus, 0,
     50       1.21   thorpej     gvpbusmatch, gvpbusattach, NULL, NULL);
     51        1.1    chopps 
     52        1.1    chopps int
     53  1.25.12.1       tls gvpbusmatch(device_t parent, cfdata_t cf, void *aux)
     54        1.1    chopps {
     55        1.6    chopps 	struct zbus_args *zap;
     56        1.1    chopps 
     57  1.25.12.1       tls 	zap = aux;
     58        1.1    chopps 
     59        1.1    chopps 	/*
     60        1.1    chopps 	 * Check manufacturer and product id.
     61        1.1    chopps 	 */
     62        1.3    chopps #if 0
     63        1.2    chopps 	if (zap->manid == 2017 && (zap->prodid == 11 || zap->prodid == 2))
     64        1.3    chopps #else
     65        1.3    chopps 	if (zap->manid == 2017 && zap->prodid == 11)
     66        1.3    chopps #endif
     67        1.1    chopps 		return(1);
     68        1.1    chopps 	return(0);
     69        1.1    chopps }
     70        1.1    chopps 
     71        1.1    chopps void
     72  1.25.12.1       tls gvpbusattach(device_t parent, device_t self, void *aux)
     73        1.1    chopps {
     74        1.6    chopps 	struct zbus_args *zap;
     75        1.1    chopps 	struct gvpbus_args ga;
     76       1.18        is 	int flags0, flags;
     77        1.1    chopps 
     78  1.25.12.1       tls 	zap = aux;
     79       1.24    cegger 	memcpy(&ga.zargs, zap, sizeof(struct zbus_args));
     80       1.18        is 	flags = 0;
     81       1.18        is 
     82        1.1    chopps 	/*
     83        1.2    chopps 	 * grab secondary type (or fake it if we have a series I)
     84        1.1    chopps 	 */
     85        1.9    chopps 	if (zap->prodid != 9) {
     86        1.2    chopps 		ga.prod = *((u_char *)zap->va + 0x8001) & 0xf8;
     87        1.9    chopps 		if (*((u_char *)zap->va + 0x8001) & 0x01)
     88       1.18        is 			flags |= GVP_14MHZ;
     89       1.18        is 	printf(": subprod %02x flags %02x", *((u_char *)zap->va + 0x8001), flags);
     90        1.3    chopps #if 0
     91        1.9    chopps 	} else {
     92        1.2    chopps 		ga.prod = GVP_SERIESII;		/* really a series I */
     93       1.18        is 		flags |= GVP_NOBANK;
     94        1.9    chopps #endif
     95        1.2    chopps 	}
     96       1.17   aymeric 
     97        1.2    chopps 
     98        1.1    chopps 	switch (ga.prod) {
     99        1.1    chopps 	/* no scsi */
    100        1.1    chopps 	case GVP_GFORCE_040:
    101        1.1    chopps 	case GVP_GFORCE_030:
    102       1.18        is 		flags = GVP_IO;
    103        1.1    chopps 		/*FALLTHROUGH*/
    104        1.1    chopps 	case GVP_COMBO_R4:
    105        1.1    chopps 	case GVP_COMBO_R3:
    106       1.18        is 		flags |= GVP_ACCEL;
    107        1.1    chopps 		break;
    108        1.1    chopps 	/* scsi */
    109        1.7    chopps 	case GVP_A1291_SCSI:
    110       1.18        is 		flags |= GVP_SCSI | GVP_ACCEL;
    111        1.7    chopps 		sbic_no_dma = 1;	/* Kludge !!!!!!! mlh */
    112        1.7    chopps 		break;
    113        1.1    chopps 	case GVP_GFORCE_040_SCSI:
    114       1.18        is 		flags |= GVP_SCSI | GVP_IO | GVP_ACCEL;
    115        1.1    chopps 		break;
    116        1.1    chopps 	case GVP_GFORCE_030_SCSI:
    117       1.18        is 		flags |= GVP_SCSI | GVP_IO | GVP_ACCEL | GVP_25BITDMA;
    118        1.1    chopps 		break;
    119        1.8    chopps 	case GVP_A530_SCSI:
    120        1.1    chopps 	case GVP_COMBO_R4_SCSI:
    121       1.18        is 		flags |= GVP_SCSI | GVP_ACCEL | GVP_25BITDMA;
    122        1.9    chopps 		if (ga.prod == GVP_COMBO_R4_SCSI)
    123       1.18        is 			flags ^= GVP_14MHZ;
    124        1.1    chopps 		break;
    125        1.1    chopps 	case GVP_COMBO_R3_SCSI:
    126       1.18        is 		flags |= GVP_SCSI | GVP_ACCEL | GVP_24BITDMA;
    127       1.18        is 		flags ^= GVP_14MHZ;
    128        1.1    chopps 		break;
    129        1.1    chopps 	case GVP_SERIESII:
    130       1.18        is 		flags |= GVP_SCSI | GVP_24BITDMA;
    131        1.1    chopps 		break;
    132        1.1    chopps 	/* misc */
    133        1.1    chopps 	case GVP_IOEXTEND:
    134       1.18        is 		flags |= GVP_IO;
    135        1.1    chopps 		break;
    136        1.1    chopps 	default:
    137       1.14  christos 		printf(": unknown Series II %x", ga.prod);
    138        1.1    chopps 	}
    139       1.14  christos 	printf("\n");
    140        1.1    chopps 	/*
    141        1.1    chopps 	 * attempt to configure the board.
    142        1.1    chopps 	 */
    143       1.18        is 
    144       1.18        is 	flags0 = flags & ~(GVP_IO|GVP_SCSI);
    145       1.18        is 
    146       1.18        is 	if (flags & GVP_SCSI) {
    147       1.18        is 		ga.flags = flags0 | GVP_SCSI;
    148  1.25.12.1       tls 		config_found(self, &ga, gvpbusprint);
    149       1.18        is 	}
    150       1.18        is 	if (flags & GVP_IO) {
    151       1.18        is 		ga.flags = flags0 | GVP_IO;
    152  1.25.12.1       tls 		config_found(self, &ga, gvpbusprint);
    153       1.18        is 	}
    154        1.1    chopps }
    155        1.1    chopps 
    156        1.1    chopps int
    157  1.25.12.1       tls gvpbusprint(void *aux, const char *pnp)
    158        1.1    chopps {
    159        1.1    chopps 	struct gvpbus_args *gap;
    160        1.1    chopps 
    161  1.25.12.1       tls 	gap = aux;
    162        1.1    chopps 	if (pnp == NULL)
    163        1.1    chopps 		return(QUIET);
    164        1.1    chopps 	/*
    165        1.1    chopps 	 * doesn't support io yet.
    166        1.1    chopps 	 */
    167       1.17   aymeric 	if (gap->prod == GVP_IOEXTEND)
    168       1.22   thorpej 		aprint_normal("gio at %s", pnp);
    169        1.1    chopps 	else
    170       1.22   thorpej 		aprint_normal("gtsc at %s", pnp);
    171        1.1    chopps 	return(UNCONF);
    172        1.1    chopps }
    173