blob: d530971beb0037560471c35d38a8fefc86b587ca [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001 Writing Device Drivers for Zorro Devices
2 ----------------------------------------
3
4Written by Geert Uytterhoeven <geert@linux-m68k.org>
5Last revised: September 5, 2003
6
7
81. Introduction
9---------------
10
11The Zorro bus is the bus used in the Amiga family of computers. Thanks to
12AutoConfig(tm), it's 100% Plug-and-Play.
13
Stan Drozd9bb0e9c2017-04-21 13:16:03 +020014There are two types of Zorro buses, Zorro II and Zorro III:
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16 - The Zorro II address space is 24-bit and lies within the first 16 MB of the
17 Amiga's address map.
18
19 - Zorro III is a 32-bit extension of Zorro II, which is backwards compatible
20 with Zorro II. The Zorro III address space lies outside the first 16 MB.
21
22
232. Probing for Zorro Devices
24----------------------------
25
26Zorro devices are found by calling `zorro_find_device()', which returns a
27pointer to the `next' Zorro device with the specified Zorro ID. A probe loop
28for the board with Zorro ID `ZORRO_PROD_xxx' looks like:
29
30 struct zorro_dev *z = NULL;
31
32 while ((z = zorro_find_device(ZORRO_PROD_xxx, z))) {
33 if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
34 "My explanation"))
35 ...
36 }
37
38`ZORRO_WILDCARD' acts as a wildcard and finds any Zorro device. If your driver
39supports different types of boards, you can use a construct like:
40
41 struct zorro_dev *z = NULL;
42
43 while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
44 if (z->id != ZORRO_PROD_xxx1 && z->id != ZORRO_PROD_xxx2 && ...)
45 continue;
46 if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
47 "My explanation"))
48 ...
49 }
50
51
523. Zorro Resources
53------------------
54
55Before you can access a Zorro device's registers, you have to make sure it's
56not yet in use. This is done using the I/O memory space resource management
57functions:
58
59 request_mem_region()
60 release_mem_region()
61
62Shortcuts to claim the whole device's address space are provided as well:
63
64 zorro_request_device
65 zorro_release_device
66
67
684. Accessing the Zorro Address Space
69------------------------------------
70
71The address regions in the Zorro device resources are Zorro bus address
72regions. Due to the identity bus-physical address mapping on the Zorro bus,
73they are CPU physical addresses as well.
74
75The treatment of these regions depends on the type of Zorro space:
76
77 - Zorro II address space is always mapped and does not have to be mapped
78 explicitly using z_ioremap().
79
80 Conversion from bus/physical Zorro II addresses to kernel virtual addresses
81 and vice versa is done using:
82
83 virt_addr = ZTWO_VADDR(bus_addr);
84 bus_addr = ZTWO_PADDR(virt_addr);
85
86 - Zorro III address space must be mapped explicitly using z_ioremap() first
87 before it can be accessed:
88
89 virt_addr = z_ioremap(bus_addr, size);
90 ...
91 z_iounmap(virt_addr);
92
93
945. References
95-------------
96
97linux/include/linux/zorro.h
Geert Uytterhoeven986ea582013-10-03 10:45:36 +020098linux/include/uapi/linux/zorro.h
99linux/include/uapi/linux/zorro_ids.h
Geert Uytterhoeven1ea636e2012-08-16 17:05:43 +0200100linux/arch/m68k/include/asm/zorro.h
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101linux/drivers/zorro
102/proc/bus/zorro
103