zorro.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. #define ZORRO_WILDCARD (0xffffffff) /* not official */
  32. /* Include the ID list */
  33. #include <linux/zorro_ids.h>
  34. /*
  35. * GVP identifies most of its products through the 'extended product code'
  36. * (epc). The epc has to be ANDed with the GVP_PRODMASK before the
  37. * identification.
  38. */
  39. #define GVP_PRODMASK (0xf8)
  40. #define GVP_SCSICLKMASK (0x01)
  41. enum GVP_flags {
  42. GVP_IO = 0x01,
  43. GVP_ACCEL = 0x02,
  44. GVP_SCSI = 0x04,
  45. GVP_24BITDMA = 0x08,
  46. GVP_25BITDMA = 0x10,
  47. GVP_NOBANK = 0x20,
  48. GVP_14MHZ = 0x40,
  49. };
  50. struct Node {
  51. struct Node *ln_Succ; /* Pointer to next (successor) */
  52. struct Node *ln_Pred; /* Pointer to previous (predecessor) */
  53. __u8 ln_Type;
  54. __s8 ln_Pri; /* Priority, for sorting */
  55. __s8 *ln_Name; /* ID string, null terminated */
  56. } __attribute__ ((packed));
  57. struct ExpansionRom {
  58. /* -First 16 bytes of the expansion ROM */
  59. __u8 er_Type; /* Board type, size and flags */
  60. __u8 er_Product; /* Product number, assigned by manufacturer */
  61. __u8 er_Flags; /* Flags */
  62. __u8 er_Reserved03; /* Must be zero ($ff inverted) */
  63. __u16 er_Manufacturer; /* Unique ID, ASSIGNED BY COMMODORE-AMIGA! */
  64. __u32 er_SerialNumber; /* Available for use by manufacturer */
  65. __u16 er_InitDiagVec; /* Offset to optional "DiagArea" structure */
  66. __u8 er_Reserved0c;
  67. __u8 er_Reserved0d;
  68. __u8 er_Reserved0e;
  69. __u8 er_Reserved0f;
  70. } __attribute__ ((packed));
  71. /* er_Type board type bits */
  72. #define ERT_TYPEMASK 0xc0
  73. #define ERT_ZORROII 0xc0
  74. #define ERT_ZORROIII 0x80
  75. /* other bits defined in er_Type */
  76. #define ERTB_MEMLIST 5 /* Link RAM into free memory list */
  77. #define ERTF_MEMLIST (1<<5)
  78. struct ConfigDev {
  79. struct Node cd_Node;
  80. __u8 cd_Flags; /* (read/write) */
  81. __u8 cd_Pad; /* reserved */
  82. struct ExpansionRom cd_Rom; /* copy of board's expansion ROM */
  83. void *cd_BoardAddr; /* where in memory the board was placed */
  84. __u32 cd_BoardSize; /* size of board in bytes */
  85. __u16 cd_SlotAddr; /* which slot number (PRIVATE) */
  86. __u16 cd_SlotSize; /* number of slots (PRIVATE) */
  87. void *cd_Driver; /* pointer to node of driver */
  88. struct ConfigDev *cd_NextCD; /* linked list of drivers to config */
  89. __u32 cd_Unused[4]; /* for whatever the driver wants */
  90. } __attribute__ ((packed));
  91. #define ZORRO_NUM_AUTO 16
  92. #ifdef __KERNEL__
  93. #include <linux/init.h>
  94. #include <linux/ioport.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 IDs
  124. */
  125. struct zorro_device_id {
  126. zorro_id id; /* Device ID or ZORRO_WILDCARD */
  127. unsigned long driver_data; /* Data private to the driver */
  128. };
  129. /*
  130. * Zorro device drivers
  131. */
  132. struct zorro_driver {
  133. struct list_head node;
  134. char *name;
  135. const struct zorro_device_id *id_table; /* NULL if wants all devices */
  136. int (*probe)(struct zorro_dev *z, const struct zorro_device_id *id); /* New device inserted */
  137. void (*remove)(struct zorro_dev *z); /* Device removed (NULL if not a hot-plug capable driver) */
  138. struct device_driver driver;
  139. };
  140. #define to_zorro_driver(drv) container_of(drv, struct zorro_driver, driver)
  141. #define zorro_for_each_dev(dev) \
  142. for (dev = &zorro_autocon[0]; dev < zorro_autocon+zorro_num_autocon; dev++)
  143. /* New-style probing */
  144. extern int zorro_register_driver(struct zorro_driver *);
  145. extern void zorro_unregister_driver(struct zorro_driver *);
  146. extern const struct zorro_device_id *zorro_match_device(const struct zorro_device_id *ids, const struct zorro_dev *z);
  147. static inline struct zorro_driver *zorro_dev_driver(const struct zorro_dev *z)
  148. {
  149. return z->driver;
  150. }
  151. extern unsigned int zorro_num_autocon; /* # of autoconfig devices found */
  152. extern struct zorro_dev zorro_autocon[ZORRO_NUM_AUTO];
  153. /*
  154. * Zorro Functions
  155. */
  156. extern struct zorro_dev *zorro_find_device(zorro_id id,
  157. struct zorro_dev *from);
  158. #define zorro_resource_start(z) ((z)->resource.start)
  159. #define zorro_resource_end(z) ((z)->resource.end)
  160. #define zorro_resource_len(z) ((z)->resource.end-(z)->resource.start+1)
  161. #define zorro_resource_flags(z) ((z)->resource.flags)
  162. #define zorro_request_device(z, name) \
  163. request_mem_region(zorro_resource_start(z), zorro_resource_len(z), name)
  164. #define zorro_release_device(z) \
  165. release_mem_region(zorro_resource_start(z), zorro_resource_len(z))
  166. /* Similar to the helpers above, these manipulate per-zorro_dev
  167. * driver-specific data. They are really just a wrapper around
  168. * the generic device structure functions of these calls.
  169. */
  170. static inline void *zorro_get_drvdata (struct zorro_dev *z)
  171. {
  172. return dev_get_drvdata(&z->dev);
  173. }
  174. static inline void zorro_set_drvdata (struct zorro_dev *z, void *data)
  175. {
  176. dev_set_drvdata(&z->dev, data);
  177. }
  178. /*
  179. * Bitmask indicating portions of available Zorro II RAM that are unused
  180. * by the system. Every bit represents a 64K chunk, for a maximum of 8MB
  181. * (128 chunks, physical 0x00200000-0x009fffff).
  182. *
  183. * If you want to use (= allocate) portions of this RAM, you should clear
  184. * the corresponding bits.
  185. */
  186. extern DECLARE_BITMAP(zorro_unused_z2ram, 128);
  187. #define Z2RAM_START (0x00200000)
  188. #define Z2RAM_END (0x00a00000)
  189. #define Z2RAM_SIZE (0x00800000)
  190. #define Z2RAM_CHUNKSIZE (0x00010000)
  191. #define Z2RAM_CHUNKMASK (0x0000ffff)
  192. #define Z2RAM_CHUNKSHIFT (16)
  193. #endif /* __KERNEL__ */
  194. #endif /* _LINUX_ZORRO_H */