Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / acorn32 / podulebus / netslot.c
blob96381bd864440170561681a0a62f2e4f63183fc3
1 /* $NetBSD: netslot.c,v 1.7 2009/03/14 14:45:52 dsl Exp $ */
3 /*
4 * Copyright (c) 1994-1996 Mark Brinicombe.
5 * Copyright (c) 1994 Brini.
6 * All rights reserved.
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.
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.
36 #include <sys/param.h>
38 __KERNEL_RCSID(1, "$NetBSD: netslot.c,v 1.7 2009/03/14 14:45:52 dsl Exp $");
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 <arm/iomd/iomdreg.h>
51 #include <arm/iomd/iomdvar.h>
52 #include <dev/podulebus/podulebus.h>
53 #include <dev/podulebus/podules.h>
55 u_int netslotread(u_int, int);
57 u_int
58 netslotread(u_int address, int offset)
60 static int netslotoffset = -1;
62 offset = offset >> 2;
63 if (netslotoffset == -1 || offset < netslotoffset) {
64 WriteByte(address, 0);
65 netslotoffset = 0;
67 while (netslotoffset < offset) {
68 (void)ReadByte(address);
69 ++netslotoffset;
71 ++netslotoffset;
72 return(ReadByte(address));
75 void
76 netslotscan(struct device *dev)
78 podule_t *podule;
79 volatile u_char *address;
81 /* Only one netslot atm */
83 /* Reset the address counter */
85 WriteByte(NETSLOT_BASE, 0x00);
87 address = (u_char *)NETSLOT_BASE;
89 podule = &podules[MAX_PODULES];
91 podule->fast_base = NETSLOT_BASE;
92 podule->medium_base = NETSLOT_BASE;
93 podule->slow_base = NETSLOT_BASE;
94 podule->sync_base = NETSLOT_BASE;
95 podule->mod_base = NETSLOT_BASE;
96 podule->easi_base = 0;
97 podule->attached = 0;
98 podule->slottype = SLOT_NONE;
99 podule->podulenum = MAX_PODULES;
100 podule->interrupt = IRQ_NETSLOT;
101 podule->read_rom = netslotread;
102 podule->dma_channel = -1;
103 podule->dma_interrupt = -1;
104 podule->description[0] = 0;
106 /* XXX - Really needs to be linked to a DMA manager */
107 if (IOMD_ID == RPC600_IOMD_ID)
108 podule->dma_channel = 0;
110 /* Get information from the podule header */
112 podule->flags0 = *address;
113 podule->flags1 = *address;
114 podule->reserved = *address;
115 podule->product = *address;
116 podule->product += (*address << 8);
117 podule->manufacturer = *address;
118 podule->manufacturer += (*address << 8);
119 podule->country = *address;
120 if (podule->flags1 & PODULE_FLAGS_IS) {
121 podule->irq_mask = *address;
122 podule->irq_addr = *address;
123 podule->irq_addr += (*address << 8);
124 podule->irq_addr += (*address << 16);
125 podule->irq_addr += podule->slow_base;
126 if (podule->irq_mask == 0)
127 podule->irq_mask = 0x01;
128 podule->fiq_mask = *address;
129 podule->fiq_addr = *address;
130 podule->fiq_addr += (*address << 8);
131 podule->fiq_addr += (*address << 16);
132 podule->fiq_addr += podule->slow_base;
133 if (podule->fiq_mask == 0)
134 podule->fiq_mask = 0x04;
135 } else {
136 podule->irq_addr = podule->slow_base;
137 podule->irq_mask = 0x01;
138 podule->fiq_addr = podule->slow_base;
139 podule->fiq_mask = 0x04;
142 poduleexamine(podule, dev, SLOT_NET);
145 void
146 netslot_ea(u_int8_t *buffer)
148 /* Build station address from machine ID */
149 buffer[0] = 0x00;
150 buffer[1] = 0x00;
151 buffer[2] = 0xa4;
152 buffer[3] = bootconfig.machine_id[2] + 0x10;
153 buffer[4] = bootconfig.machine_id[1];
154 buffer[5] = bootconfig.machine_id[0];