Back to home page

LXR

 
 

    


0001                 Writing Device Drivers for Zorro Devices
0002                 ----------------------------------------
0003 
0004 Written by Geert Uytterhoeven <geert@linux-m68k.org>
0005 Last revised: September 5, 2003
0006 
0007 
0008 1. Introduction
0009 ---------------
0010 
0011 The Zorro bus is the bus used in the Amiga family of computers. Thanks to
0012 AutoConfig(tm), it's 100% Plug-and-Play.
0013 
0014 There are two types of Zorro busses, Zorro II and Zorro III:
0015 
0016   - The Zorro II address space is 24-bit and lies within the first 16 MB of the
0017     Amiga's address map.
0018 
0019   - Zorro III is a 32-bit extension of Zorro II, which is backwards compatible
0020     with Zorro II. The Zorro III address space lies outside the first 16 MB.
0021 
0022 
0023 2. Probing for Zorro Devices
0024 ----------------------------
0025 
0026 Zorro devices are found by calling `zorro_find_device()', which returns a
0027 pointer to the `next' Zorro device with the specified Zorro ID. A probe loop
0028 for the board with Zorro ID `ZORRO_PROD_xxx' looks like:
0029 
0030     struct zorro_dev *z = NULL;
0031 
0032     while ((z = zorro_find_device(ZORRO_PROD_xxx, z))) {
0033         if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
0034                                   "My explanation"))
0035         ...
0036     }
0037 
0038 `ZORRO_WILDCARD' acts as a wildcard and finds any Zorro device. If your driver
0039 supports different types of boards, you can use a construct like:
0040 
0041     struct zorro_dev *z = NULL;
0042 
0043     while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
0044         if (z->id != ZORRO_PROD_xxx1 && z->id != ZORRO_PROD_xxx2 && ...)
0045             continue;
0046         if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
0047                                   "My explanation"))
0048         ...
0049     }
0050 
0051 
0052 3. Zorro Resources
0053 ------------------
0054 
0055 Before you can access a Zorro device's registers, you have to make sure it's
0056 not yet in use. This is done using the I/O memory space resource management
0057 functions:
0058 
0059     request_mem_region()
0060     release_mem_region()
0061 
0062 Shortcuts to claim the whole device's address space are provided as well:
0063 
0064     zorro_request_device
0065     zorro_release_device
0066 
0067 
0068 4. Accessing the Zorro Address Space
0069 ------------------------------------
0070 
0071 The address regions in the Zorro device resources are Zorro bus address
0072 regions. Due to the identity bus-physical address mapping on the Zorro bus,
0073 they are CPU physical addresses as well.
0074 
0075 The treatment of these regions depends on the type of Zorro space:
0076 
0077   - Zorro II address space is always mapped and does not have to be mapped
0078     explicitly using z_ioremap().
0079     
0080     Conversion from bus/physical Zorro II addresses to kernel virtual addresses
0081     and vice versa is done using:
0082 
0083         virt_addr = ZTWO_VADDR(bus_addr);
0084         bus_addr = ZTWO_PADDR(virt_addr);
0085 
0086   - Zorro III address space must be mapped explicitly using z_ioremap() first
0087     before it can be accessed:
0088  
0089         virt_addr = z_ioremap(bus_addr, size);
0090         ...
0091         z_iounmap(virt_addr);
0092 
0093 
0094 5. References
0095 -------------
0096 
0097 linux/include/linux/zorro.h
0098 linux/include/uapi/linux/zorro.h
0099 linux/include/uapi/linux/zorro_ids.h
0100 linux/arch/m68k/include/asm/zorro.h
0101 linux/drivers/zorro
0102 /proc/bus/zorro
0103