Loading...
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 | Writing Device Drivers for Zorro Devices ---------------------------------------- Written by Geert Uytterhoeven <geert@linux-m68k.org> Last revised: February 27, 2000 1. Introduction --------------- The Zorro bus is the bus used in the Amiga family of computers. Thanks to AutoConfig(tm), it's is 100% Plug-and-Play. There are two types of Zorro busses, Zorro II and Zorro III: - The Zorro II address space is 24-bit and lies within the first 16 MB of the Amiga's address map. - Zorro III is a 32-bit extension of Zorro II, which is backwards compatible with Zorro II. The Zorro III address space lies outside the first 16 MB. 2. Probing for Zorro Devices ---------------------------- Zorro devices are found by calling `zorro_find_device()', which returns a pointer to the `next' Zorro device with the specified Zorro ID. A probe loop for the board with Zorro ID `ZORRO_PROD_xxx' looks like: struct zorro_dev *z = NULL; while ((z = zorro_find_device(ZORRO_PROD_xxx, z))) { if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE, "My explanation")) strcpy(z->name, "My board name"); ... } `ZORRO_WILDCARD' acts as a wildcard and finds any Zorro device. If your driver supports different types of boards, you can use a construct like: struct zorro_dev *z = NULL; while ((z = zorro_find_device(ZORRO_WILDCARD, z))) { if (z->id != ZORRO_PROD_xxx1 && z->id != ZORRO_PROD_xxx2 && ...) continue; if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE, "My explanation")) ... } 3. Zorro Resources ------------------ Before you can access a Zorro device's registers, you have to make sure it's not yet in use. This is done using the I/O memory space resource management functions: request_mem_region() check_mem_region() (deprecated) release_mem_region() Shortcuts to claim the whole device's address space are provided as well: zorro_request_device zorro_check_device (deprecated) zorro_release_device 4. Accessing the Zorro Address Space ------------------------------------ The address regions in the Zorro device resources are Zorro bus address regions. Due to the identity bus-physical address mapping on the Zorro bus, they are CPU physical addresses as well. The treatment of these regions depends on the type of Zorro space: - Zorro II address space is always mapped and does not have to be mapped explicitly using ioremap(). Conversion from bus/physical Zorro II addresses to kernel virtual addresses and vice versa is done using: virt_addr = ZTWO_VADDR(bus_addr); bus_addr = ZTWO_PADDR(virt_addr); - Zorro III address space must be mapped explicitly using ioremap() first before it can be accessed: virt_addr = ioremap(bus_addr, size); ... iounmap(virt_addr); 5. Zorro Device Naming ---------------------- Since we think generic device naming is something for userspace (zorroutils), we don't keep a Zorro device name database in the kernel. However, device drivers are allowed to store the expansion board name in struct zorro_dev. 6. References ------------- linux/include/linux/zorro.h linux/include/linux/ioport.h linux/include/asm-m68k/io.h linux/include/asm-m68k/amigahw.h linux/include/asm-ppc/io.h linux/driver/zorro /proc/bus/zorro |