Home | History | Annotate | Line # | Download | only in pci
      1 /*	$NetBSD: emmem.c,v 1.6 2023/12/20 00:40:42 thorpej Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2012 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Radoslaw Kujawa.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Handle (optional) PCI memory space on Elbox Mediator bridges.
     34  */
     35 
     36 #include <sys/types.h>
     37 #include <sys/param.h>
     38 #include <sys/time.h>
     39 #include <sys/systm.h>
     40 #include <sys/errno.h>
     41 #include <sys/device.h>
     42 
     43 #include <uvm/uvm_extern.h>
     44 
     45 #include <machine/bus.h>
     46 #include <machine/cpu.h>
     47 
     48 #include <amiga/dev/zbusvar.h>
     49 #include <amiga/pci/empbreg.h>
     50 #include <amiga/pci/emmemvar.h>
     51 
     52 static int	emmem_match(device_t, cfdata_t, void *);
     53 static void	emmem_attach(device_t, device_t, void *);
     54 
     55 CFATTACH_DECL_NEW(emmem, sizeof(struct emmem_softc),
     56     emmem_match, emmem_attach, NULL, NULL);
     57 
     58 static int
     59 emmem_match(device_t parent, cfdata_t cf, void *aux)
     60 {
     61 	struct zbus_args *zap;
     62 
     63 	zap = aux;
     64 
     65 	if (zap->manid != ZORRO_MANID_ELBOX)
     66 		return 0;
     67 
     68 	switch (zap->prodid) {
     69 	case ZORRO_PRODID_MED1K2_MEM:	/* Mediator 1200 family */
     70 	case ZORRO_PRODID_MED1K2SX_MEM:
     71 	case ZORRO_PRODID_MED1K2LT2_MEM:
     72 	case ZORRO_PRODID_MED1K2LT4_MEM:
     73 	case ZORRO_PRODID_MED1K2TX_MEM:
     74 	case ZORRO_PRODID_MEDZIV_MEM:	/* Mediator ZIV, not really yet */
     75 	case ZORRO_PRODID_MED4K_MEM:	/* Mediator 4000 family */
     76 	case ZORRO_PRODID_MED4KMKII_MEM:
     77 		return 1;
     78 	}
     79 
     80 	return 0;
     81 }
     82 
     83 static void
     84 emmem_attach(device_t parent, device_t self, void *aux)
     85 {
     86 	struct zbus_args *zap;
     87 	struct emmem_softc *sc;
     88 
     89 	sc = device_private(self);
     90 	zap = aux;
     91 
     92 	sc->sc_dev = self;
     93 	sc->sc_base = zap->va;
     94 	sc->sc_size = zap->size;
     95 
     96 	aprint_normal(": ELBOX Mediator PCI memory window, %d kB\n",
     97 	    zap->size / 1024);
     98 
     99 	/*
    100 	 * Do nothing here, empb or em4k should find the emmem devices
    101 	 * and do the right(tm) thing.
    102 	 */
    103 
    104 }
    105 
    106