zorro.txt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. Writing Device Drivers for Zorro Devices
  2. ----------------------------------------
  3. Written by Geert Uytterhoeven <geert@linux-m68k.org>
  4. Last revised: September 5, 2003
  5. 1. Introduction
  6. ---------------
  7. The Zorro bus is the bus used in the Amiga family of computers. Thanks to
  8. AutoConfig(tm), it's 100% Plug-and-Play.
  9. There are two types of Zorro busses, Zorro II and Zorro III:
  10. - The Zorro II address space is 24-bit and lies within the first 16 MB of the
  11. Amiga's address map.
  12. - Zorro III is a 32-bit extension of Zorro II, which is backwards compatible
  13. with Zorro II. The Zorro III address space lies outside the first 16 MB.
  14. 2. Probing for Zorro Devices
  15. ----------------------------
  16. Zorro devices are found by calling `zorro_find_device()', which returns a
  17. pointer to the `next' Zorro device with the specified Zorro ID. A probe loop
  18. for the board with Zorro ID `ZORRO_PROD_xxx' looks like:
  19. struct zorro_dev *z = NULL;
  20. while ((z = zorro_find_device(ZORRO_PROD_xxx, z))) {
  21. if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
  22. "My explanation"))
  23. ...
  24. }
  25. `ZORRO_WILDCARD' acts as a wildcard and finds any Zorro device. If your driver
  26. supports different types of boards, you can use a construct like:
  27. struct zorro_dev *z = NULL;
  28. while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
  29. if (z->id != ZORRO_PROD_xxx1 && z->id != ZORRO_PROD_xxx2 && ...)
  30. continue;
  31. if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
  32. "My explanation"))
  33. ...
  34. }
  35. 3. Zorro Resources
  36. ------------------
  37. Before you can access a Zorro device's registers, you have to make sure it's
  38. not yet in use. This is done using the I/O memory space resource management
  39. functions:
  40. request_mem_region()
  41. release_mem_region()
  42. Shortcuts to claim the whole device's address space are provided as well:
  43. zorro_request_device
  44. zorro_release_device
  45. 4. Accessing the Zorro Address Space
  46. ------------------------------------
  47. The address regions in the Zorro device resources are Zorro bus address
  48. regions. Due to the identity bus-physical address mapping on the Zorro bus,
  49. they are CPU physical addresses as well.
  50. The treatment of these regions depends on the type of Zorro space:
  51. - Zorro II address space is always mapped and does not have to be mapped
  52. explicitly using z_ioremap().
  53. Conversion from bus/physical Zorro II addresses to kernel virtual addresses
  54. and vice versa is done using:
  55. virt_addr = ZTWO_VADDR(bus_addr);
  56. bus_addr = ZTWO_PADDR(virt_addr);
  57. - Zorro III address space must be mapped explicitly using z_ioremap() first
  58. before it can be accessed:
  59. virt_addr = z_ioremap(bus_addr, size);
  60. ...
  61. z_iounmap(virt_addr);
  62. 5. References
  63. -------------
  64. linux/include/linux/zorro.h
  65. linux/include/asm-{m68k,ppc}/zorro.h
  66. linux/include/linux/zorro_ids.h
  67. linux/drivers/zorro
  68. /proc/bus/zorro