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