1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
/*
* $Id: zorro.c,v 1.1.2.1 1998/06/07 23:21:02 geert Exp $
*
* Zorro Bus Services
*
* Copyright (C) 1995-2000 Geert Uytterhoeven
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/zorro.h>
#include <asm/setup.h>
#include <asm/bitops.h>
#include <asm/amigahw.h>
extern void zorro_namedevice(struct zorro_dev *dev);
/*
* Zorro Expansion Devices
*/
u_int zorro_num_autocon = 0;
struct zorro_dev zorro_autocon[ZORRO_NUM_AUTO];
#if 0
/*
* Zorro Bus Resources
* Order _does_ matter! (see code below)
*/
static struct resource zorro_res[4] = {
{ "Zorro II exp", 0x00e80000, 0x00efffff },
{ "Zorro II mem", 0x00200000, 0x009fffff },
{ "Zorro III exp", 0xff000000, 0xffffffff },
{ "Zorro III cfg", 0x40000000, 0x7fffffff }
};
#endif
/*
* Find Zorro Devices
*/
struct zorro_dev *zorro_find_device(zorro_id id, struct zorro_dev *from)
{
struct zorro_dev *dev;
if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
return NULL;
dev = from ? from+1 : &zorro_autocon[0];
for (; dev < zorro_autocon+zorro_num_autocon; dev++)
if (id == ZORRO_WILDCARD || id == dev->id)
return dev;
return NULL;
}
/*
* Bitmask indicating portions of available Zorro II RAM that are unused
* by the system. Every bit represents a 64K chunk, for a maximum of 8MB
* (128 chunks, physical 0x00200000-0x009fffff).
*
* If you want to use (= allocate) portions of this RAM, you should clear
* the corresponding bits.
*
* Possible uses:
* - z2ram device
* - SCSI DMA bounce buffers
*
* FIXME: use the normal resource management
*/
u32 zorro_unused_z2ram[4] = { 0, 0, 0, 0 };
static void __init mark_region(unsigned long start, unsigned long end,
int flag)
{
if (flag)
start += Z2RAM_CHUNKMASK;
else
end += Z2RAM_CHUNKMASK;
start &= ~Z2RAM_CHUNKMASK;
end &= ~Z2RAM_CHUNKMASK;
if (end <= Z2RAM_START || start >= Z2RAM_END)
return;
start = start < Z2RAM_START ? 0x00000000 : start-Z2RAM_START;
end = end > Z2RAM_END ? Z2RAM_SIZE : end-Z2RAM_START;
while (start < end) {
u32 chunk = start>>Z2RAM_CHUNKSHIFT;
if (flag)
set_bit(chunk, zorro_unused_z2ram);
else
clear_bit(chunk, zorro_unused_z2ram);
start += Z2RAM_CHUNKSIZE;
}
}
/*
* Initialization
*/
void __init zorro_init(void)
{
struct zorro_dev *dev;
u_int i;
if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
return;
printk("Zorro: Probing AutoConfig expansion devices: %d device%s\n",
zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
/* Request the resources */
#if 0
for (i = 0; i < (AMIGAHW_PRESENT(ZORRO3) ? 4 : 2); i++)
request_resource(&iomem_resource, &zorro_res[i]);
#endif
for (i = 0; i < zorro_num_autocon; i++) {
dev = &zorro_autocon[i];
dev->id = (dev->rom.er_Manufacturer<<16) | (dev->rom.er_Product<<8);
if (dev->id == ZORRO_PROD_GVP_EPC_BASE) {
/* GVP quirk */
unsigned long magic = dev->resource.start+0x8000;
dev->id |= *(u16 *)ZTWO_VADDR(magic) & GVP_PRODMASK;
}
dev->resource.name = dev->name;
zorro_namedevice(dev);
if (request_resource(&iomem_resource, &dev->resource))
printk("zorro_init: cannot request resource for board %d\n", i);
}
/* Mark all available Zorro II memory */
for (i = 0; i < zorro_num_autocon; i++) {
dev = &zorro_autocon[i];
if (dev->rom.er_Type & ERTF_MEMLIST)
mark_region(dev->resource.start, dev->resource.end+1, 1);
}
/* Unmark all used Zorro II memory */
for (i = 0; i < m68k_num_memory; i++)
if (m68k_memory[i].addr < 16*1024*1024)
mark_region(m68k_memory[i].addr,
m68k_memory[i].addr+m68k_memory[i].size, 0);
}
EXPORT_SYMBOL(zorro_find_device);
EXPORT_SYMBOL(zorro_unused_z2ram);
|