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