1 /* $NetBSD: emmem.c,v 1.4 2013/01/29 00:49:43 rkujawa 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 #include <sys/malloc.h> 43 #include <sys/extent.h> 44 45 #include <uvm/uvm_extern.h> 46 47 #include <machine/bus.h> 48 #include <machine/cpu.h> 49 50 #include <amiga/dev/zbusvar.h> 51 #include <amiga/pci/empbreg.h> 52 #include <amiga/pci/emmemvar.h> 53 54 static int emmem_match(device_t, cfdata_t, void *); 55 static void emmem_attach(device_t, device_t, void *); 56 57 CFATTACH_DECL_NEW(emmem, sizeof(struct emmem_softc), 58 emmem_match, emmem_attach, NULL, NULL); 59 60 static int 61 emmem_match(device_t parent, cfdata_t cf, void *aux) 62 { 63 struct zbus_args *zap; 64 65 zap = aux; 66 67 if (zap->manid != ZORRO_MANID_ELBOX) 68 return 0; 69 70 switch (zap->prodid) { 71 case ZORRO_PRODID_MED1K2_MEM: /* Mediator 1200 family */ 72 case ZORRO_PRODID_MED1K2SX_MEM: 73 case ZORRO_PRODID_MED1K2LT2_MEM: 74 case ZORRO_PRODID_MED1K2LT4_MEM: 75 case ZORRO_PRODID_MED1K2TX_MEM: 76 case ZORRO_PRODID_MEDZIV_MEM: /* Mediator ZIV, not really yet */ 77 case ZORRO_PRODID_MED4K_MEM: /* Mediator 4000 family */ 78 case ZORRO_PRODID_MED4KMKII_MEM: 79 return 1; 80 } 81 82 return 0; 83 } 84 85 static void 86 emmem_attach(device_t parent, device_t self, void *aux) 87 { 88 struct zbus_args *zap; 89 struct emmem_softc *sc; 90 91 sc = device_private(self); 92 zap = aux; 93 94 sc->sc_dev = self; 95 sc->sc_base = zap->va; 96 sc->sc_size = zap->size; 97 98 aprint_normal(": ELBOX Mediator PCI memory window, %d kB\n", 99 zap->size / 1024); 100 101 /* 102 * Do nothing here, empb or em4k should find the emmem devices 103 * and do the right(tm) thing. 104 */ 105 106 } 107 108