Blame view

Documentation/zorro.txt 2.9 KB
998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
1
2
3
  ========================================
  Writing Device Drivers for Zorro Devices
  ========================================
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4

998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
5
6
  :Author: Written by Geert Uytterhoeven <geert@linux-m68k.org>
  :Last revised: September 5, 2003
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7

998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
8
9
  Introduction
  ------------
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
11
12
  
  The Zorro bus is the bus used in the Amiga family of computers. Thanks to
  AutoConfig(tm), it's 100% Plug-and-Play.
9bb0e9cb0   Stan Drozd   docs: Fix a coupl...
13
  There are two types of Zorro buses, Zorro II and Zorro III:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
16
17
18
19
  
    - 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.
998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
20
21
  Probing for Zorro Devices
  -------------------------
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22

998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
23
24
25
  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::
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
27
28
29
30
31
32
33
  
      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"))
  	...
      }
998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
34
35
  ``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::
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36
37
38
39
40
41
42
43
44
45
  
      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"))
  	...
      }
998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
46
47
  Zorro Resources
  ---------------
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
49
50
  
  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
998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
51
  functions::
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
52
53
54
  
      request_mem_region()
      release_mem_region()
998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
55
  Shortcuts to claim the whole device's address space are provided as well::
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56
57
58
  
      zorro_request_device
      zorro_release_device
998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
59
60
  Accessing the Zorro Address Space
  ---------------------------------
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
61
62
63
64
65
66
67
68
69
70
71
  
  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 z_ioremap().
      
      Conversion from bus/physical Zorro II addresses to kernel virtual addresses
998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
72
      and vice versa is done using::
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
73
74
75
76
77
  
  	virt_addr = ZTWO_VADDR(bus_addr);
  	bus_addr = ZTWO_PADDR(virt_addr);
  
    - Zorro III address space must be mapped explicitly using z_ioremap() first
998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
78
      before it can be accessed::
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
79
80
81
82
   
  	virt_addr = z_ioremap(bus_addr, size);
  	...
  	z_iounmap(virt_addr);
998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
83
84
  References
  ----------
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
85

998ff0b57   Mauro Carvalho Chehab   zorro.txt: standa...
86
87
88
89
90
91
  #. linux/include/linux/zorro.h
  #. linux/include/uapi/linux/zorro.h
  #. linux/include/uapi/linux/zorro_ids.h
  #. linux/arch/m68k/include/asm/zorro.h
  #. linux/drivers/zorro
  #. /proc/bus/zorro
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
92