zorro.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /*
  2. * linux/zorro.h -- Amiga AutoConfig (Zorro) Bus Definitions
  3. *
  4. * Copyright (C) 1995--2003 Geert Uytterhoeven
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file COPYING in the main directory of this archive
  8. * for more details.
  9. */
  10. #ifndef _LINUX_ZORRO_H
  11. #define _LINUX_ZORRO_H
  12. #include <linux/device.h>
  13. /*
  14. * Each Zorro board has a 32-bit ID of the form
  15. *
  16. * mmmmmmmmmmmmmmmmppppppppeeeeeeee
  17. *
  18. * with
  19. *
  20. * mmmmmmmmmmmmmmmm 16-bit Manufacturer ID (assigned by CBM (sigh))
  21. * pppppppp 8-bit Product ID (assigned by manufacturer)
  22. * eeeeeeee 8-bit Extended Product ID (currently only used
  23. * for some GVP boards)
  24. */
  25. #define ZORRO_MANUF(id) ((id) >> 16)
  26. #define ZORRO_PROD(id) (((id) >> 8) & 0xff)
  27. #define ZORRO_EPC(id) ((id) & 0xff)
  28. #define ZORRO_ID(manuf, prod, epc) \
  29. ((ZORRO_MANUF_##manuf << 16) | ((prod) << 8) | (epc))
  30. typedef __u32 zorro_id;
  31. /* Include the ID list */
  32. #include <linux/zorro_ids.h>
  33. /*
  34. * GVP identifies most of its products through the 'extended product code'
  35. * (epc). The epc has to be ANDed with the GVP_PRODMASK before the
  36. * identification.
  37. */
  38. #define GVP_PRODMASK (0xf8)
  39. #define GVP_SCSICLKMASK (0x01)
  40. enum GVP_flags {
  41. GVP_IO = 0x01,
  42. GVP_ACCEL = 0x02,
  43. GVP_SCSI = 0x04,
  44. GVP_24BITDMA = 0x08,
  45. GVP_25BITDMA = 0x10,
  46. GVP_NOBANK = 0x20,
  47. GVP_14MHZ = 0x40,
  48. };
  49. struct Node {
  50. struct Node *ln_Succ; /* Pointer to next (successor) */
  51. struct Node *ln_Pred; /* Pointer to previous (predecessor) */
  52. __u8 ln_Type;
  53. __s8 ln_Pri; /* Priority, for sorting */
  54. __s8 *ln_Name; /* ID string, null terminated */
  55. } __attribute__ ((packed));
  56. struct ExpansionRom {
  57. /* -First 16 bytes of the expansion ROM */
  58. __u8 er_Type; /* Board type, size and flags */
  59. __u8 er_Product; /* Product number, assigned by manufacturer */
  60. __u8 er_Flags; /* Flags */
  61. __u8 er_Reserved03; /* Must be zero ($ff inverted) */
  62. __u16 er_Manufacturer; /* Unique ID, ASSIGNED BY COMMODORE-AMIGA! */
  63. __u32 er_SerialNumber; /* Available for use by manufacturer */
  64. __u16 er_InitDiagVec; /* Offset to optional "DiagArea" structure */
  65. __u8 er_Reserved0c;
  66. __u8 er_Reserved0d;
  67. __u8 er_Reserved0e;
  68. __u8 er_Reserved0f;
  69. } __attribute__ ((packed));
  70. /* er_Type board type bits */
  71. #define ERT_TYPEMASK 0xc0
  72. #define ERT_ZORROII 0xc0
  73. #define ERT_ZORROIII 0x80
  74. /* other bits defined in er_Type */
  75. #define ERTB_MEMLIST 5 /* Link RAM into free memory list */
  76. #define ERTF_MEMLIST (1<<5)
  77. struct ConfigDev {
  78. struct Node cd_Node;
  79. __u8 cd_Flags; /* (read/write) */
  80. __u8 cd_Pad; /* reserved */
  81. struct ExpansionRom cd_Rom; /* copy of board's expansion ROM */
  82. void *cd_BoardAddr; /* where in memory the board was placed */
  83. __u32 cd_BoardSize; /* size of board in bytes */
  84. __u16 cd_SlotAddr; /* which slot number (PRIVATE) */
  85. __u16 cd_SlotSize; /* number of slots (PRIVATE) */
  86. void *cd_Driver; /* pointer to node of driver */
  87. struct ConfigDev *cd_NextCD; /* linked list of drivers to config */
  88. __u32 cd_Unused[4]; /* for whatever the driver wants */
  89. } __attribute__ ((packed));
  90. #define ZORRO_NUM_AUTO 16
  91. #ifdef __KERNEL__
  92. #include <linux/init.h>
  93. #include <linux/ioport.h>
  94. #include <linux/mod_devicetable.h>
  95. #include <asm/zorro.h>
  96. /*
  97. * Zorro devices
  98. */
  99. struct zorro_dev {
  100. struct ExpansionRom rom;
  101. zorro_id id;
  102. struct zorro_driver *driver; /* which driver has allocated this device */
  103. struct device dev; /* Generic device interface */
  104. u16 slotaddr;
  105. u16 slotsize;
  106. char name[64];
  107. struct resource resource;
  108. };
  109. #define to_zorro_dev(n) container_of(n, struct zorro_dev, dev)
  110. /*
  111. * Zorro bus
  112. */
  113. struct zorro_bus {
  114. struct list_head devices; /* list of devices on this bus */
  115. unsigned int num_resources; /* number of resources */
  116. struct resource resources[4]; /* address space routed to this bus */
  117. struct device dev;
  118. char name[10];
  119. };
  120. extern struct zorro_bus zorro_bus; /* single Zorro bus */
  121. extern struct bus_type zorro_bus_type;
  122. /*
  123. * Zorro device drivers
  124. */
  125. struct zorro_driver {
  126. struct list_head node;
  127. char *name;
  128. const struct zorro_device_id *id_table; /* NULL if wants all devices */
  129. int (*probe)(struct zorro_dev *z, const struct zorro_device_id *id); /* New device inserted */
  130. void (*remove)(struct zorro_dev *z); /* Device removed (NULL if not a hot-plug capable driver) */
  131. struct device_driver driver;
  132. };
  133. #define to_zorro_driver(drv) container_of(drv, struct zorro_driver, driver)
  134. #define zorro_for_each_dev(dev) \
  135. for (dev = &zorro_autocon[0]; dev < zorro_autocon+zorro_num_autocon; dev++)
  136. /* New-style probing */
  137. extern int zorro_register_driver(struct zorro_driver *);
  138. extern void zorro_unregister_driver(struct zorro_driver *);
  139. extern const struct zorro_device_id *zorro_match_device(const struct zorro_device_id *ids, const struct zorro_dev *z);
  140. static inline struct zorro_driver *zorro_dev_driver(const struct zorro_dev *z)
  141. {
  142. return z->driver;
  143. }
  144. extern unsigned int zorro_num_autocon; /* # of autoconfig devices found */
  145. extern struct zorro_dev zorro_autocon[ZORRO_NUM_AUTO];
  146. /*
  147. * Zorro Functions
  148. */
  149. extern struct zorro_dev *zorro_find_device(zorro_id id,
  150. struct zorro_dev *from);
  151. #define zorro_resource_start(z) ((z)->resource.start)
  152. #define zorro_resource_end(z) ((z)->resource.end)
  153. #define zorro_resource_len(z) ((z)->resource.end-(z)->resource.start+1)
  154. #define zorro_resource_flags(z) ((z)->resource.flags)
  155. #define zorro_request_device(z, name) \
  156. request_mem_region(zorro_resource_start(z), zorro_resource_len(z), name)
  157. #define zorro_release_device(z) \
  158. release_mem_region(zorro_resource_start(z), zorro_resource_len(z))
  159. /* Similar to the helpers above, these manipulate per-zorro_dev
  160. * driver-specific data. They are really just a wrapper around
  161. * the generic device structure functions of these calls.
  162. */
  163. static inline void *zorro_get_drvdata (struct zorro_dev *z)
  164. {
  165. return dev_get_drvdata(&z->dev);
  166. }
  167. static inline void zorro_set_drvdata (struct zorro_dev *z, void *data)
  168. {
  169. dev_set_drvdata(&z->dev, data);
  170. }
  171. /*
  172. * Bitmask indicating portions of available Zorro II RAM that are unused
  173. * by the system. Every bit represents a 64K chunk, for a maximum of 8MB
  174. * (128 chunks, physical 0x00200000-0x009fffff).
  175. *
  176. * If you want to use (= allocate) portions of this RAM, you should clear
  177. * the corresponding bits.
  178. */
  179. extern DECLARE_BITMAP(zorro_unused_z2ram, 128);
  180. #define Z2RAM_START (0x00200000)
  181. #define Z2RAM_END (0x00a00000)
  182. #define Z2RAM_SIZE (0x00800000)
  183. #define Z2RAM_CHUNKSIZE (0x00010000)
  184. #define Z2RAM_CHUNKMASK (0x0000ffff)
  185. #define Z2RAM_CHUNKSHIFT (16)
  186. #endif /* __KERNEL__ */
  187. #endif /* _LINUX_ZORRO_H */