Back to home page

OSCL-LXR

 
 

    


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