netslot.c revision 1.4 1 /* $NetBSD: netslot.c,v 1.4 2001/11/27 00:53:12 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1994-1996 Mark Brinicombe.
5 * Copyright (c) 1994 Brini.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Brini.
19 * 4. The name of the company nor the name of the author may be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #include <sys/param.h>
37
38 __KERNEL_RCSID(1, "$Id: netslot.c,v 1.4 2001/11/27 00:53:12 thorpej Exp $");
39
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
42 #include <sys/conf.h>
43 #include <sys/malloc.h>
44 #include <sys/device.h>
45 #include <uvm/uvm_extern.h>
46 #include <machine/io.h>
47 #include <arm/arm32/katelib.h>
48 #include <machine/intr.h>
49 #include <machine/bootconfig.h>
50 #include <machine/pmap.h>
51 #include <arm/iomd/iomdreg.h>
52 #include <arm/iomd/iomdvar.h>
53 #include <dev/podulebus/podulebus.h>
54 #include <dev/podulebus/podules.h>
55
56 u_int netslotread __P((u_int, int));
57
58 u_int
59 netslotread(address, offset)
60 u_int address;
61 int offset;
62 {
63 static int netslotoffset = -1;
64
65 offset = offset >> 2;
66 if (netslotoffset == -1 || offset < netslotoffset) {
67 WriteByte(address, 0);
68 netslotoffset = 0;
69 }
70 while (netslotoffset < offset) {
71 (void)ReadByte(address);
72 ++netslotoffset;
73 }
74 ++netslotoffset;
75 return(ReadByte(address));
76 }
77
78 void
79 netslotscan(dev)
80 struct device *dev;
81 {
82 podule_t *podule;
83 volatile u_char *address;
84
85 /* Only one netslot atm */
86
87 /* Reset the address counter */
88
89 WriteByte(NETSLOT_BASE, 0x00);
90
91 address = (u_char *)NETSLOT_BASE;
92
93 podule = &podules[MAX_PODULES];
94
95 podule->fast_base = NETSLOT_BASE;
96 podule->medium_base = NETSLOT_BASE;
97 podule->slow_base = NETSLOT_BASE;
98 podule->sync_base = NETSLOT_BASE;
99 podule->mod_base = NETSLOT_BASE;
100 podule->easi_base = 0;
101 podule->attached = 0;
102 podule->slottype = SLOT_NONE;
103 podule->podulenum = MAX_PODULES;
104 podule->interrupt = IRQ_NETSLOT;
105 podule->read_rom = netslotread;
106 podule->dma_channel = -1;
107 podule->dma_interrupt = -1;
108 podule->description[0] = 0;
109
110 /* XXX - Really needs to be linked to a DMA manager */
111 if (IOMD_ID == RPC600_IOMD_ID)
112 podule->dma_channel = 0;
113
114 /* Get information from the podule header */
115
116 podule->flags0 = *address;
117 podule->flags1 = *address;
118 podule->reserved = *address;
119 podule->product = *address;
120 podule->product += (*address << 8);
121 podule->manufacturer = *address;
122 podule->manufacturer += (*address << 8);
123 podule->country = *address;
124 if (podule->flags1 & PODULE_FLAGS_IS) {
125 podule->irq_mask = *address;
126 podule->irq_addr = *address;
127 podule->irq_addr += (*address << 8);
128 podule->irq_addr += (*address << 16);
129 podule->irq_addr += podule->slow_base;
130 if (podule->irq_mask == 0)
131 podule->irq_mask = 0x01;
132 podule->fiq_mask = *address;
133 podule->fiq_addr = *address;
134 podule->fiq_addr += (*address << 8);
135 podule->fiq_addr += (*address << 16);
136 podule->fiq_addr += podule->slow_base;
137 if (podule->fiq_mask == 0)
138 podule->fiq_mask = 0x04;
139 } else {
140 podule->irq_addr = podule->slow_base;
141 podule->irq_mask = 0x01;
142 podule->fiq_addr = podule->slow_base;
143 podule->fiq_mask = 0x04;
144 }
145
146 poduleexamine(podule, dev, SLOT_NET);
147 }
148
149 void
150 netslot_ea(buffer)
151 u_int8_t *buffer;
152 {
153 /* Build station address from machine ID */
154 buffer[0] = 0x00;
155 buffer[1] = 0x00;
156 buffer[2] = 0xa4;
157 buffer[3] = bootconfig.machine_id[2] + 0x10;
158 buffer[4] = bootconfig.machine_id[1];
159 buffer[5] = bootconfig.machine_id[0];
160 }
161