zorro.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. extern struct bus_type zorro_bus_type;
  114. /*
  115. * Zorro device drivers
  116. */
  117. struct zorro_driver {
  118. struct list_head node;
  119. char *name;
  120. const struct zorro_device_id *id_table; /* NULL if wants all devices */
  121. int (*probe)(struct zorro_dev *z, const struct zorro_device_id *id); /* New device inserted */
  122. void (*remove)(struct zorro_dev *z); /* Device removed (NULL if not a hot-plug capable driver) */
  123. struct device_driver driver;
  124. };
  125. #define to_zorro_driver(drv) container_of(drv, struct zorro_driver, driver)
  126. #define zorro_for_each_dev(dev) \
  127. for (dev = &zorro_autocon[0]; dev < zorro_autocon+zorro_num_autocon; dev++)
  128. /* New-style probing */
  129. extern int zorro_register_driver(struct zorro_driver *);
  130. extern void zorro_unregister_driver(struct zorro_driver *);
  131. extern const struct zorro_device_id *zorro_match_device(const struct zorro_device_id *ids, const struct zorro_dev *z);
  132. static inline struct zorro_driver *zorro_dev_driver(const struct zorro_dev *z)
  133. {
  134. return z->driver;
  135. }
  136. extern unsigned int zorro_num_autocon; /* # of autoconfig devices found */
  137. extern struct zorro_dev zorro_autocon[ZORRO_NUM_AUTO];
  138. /*
  139. * Zorro Functions
  140. */
  141. extern struct zorro_dev *zorro_find_device(zorro_id id,
  142. struct zorro_dev *from);
  143. #define zorro_resource_start(z) ((z)->resource.start)
  144. #define zorro_resource_end(z) ((z)->resource.end)
  145. #define zorro_resource_len(z) (resource_size(&(z)->resource))
  146. #define zorro_resource_flags(z) ((z)->resource.flags)
  147. #define zorro_request_device(z, name) \
  148. request_mem_region(zorro_resource_start(z), zorro_resource_len(z), name)
  149. #define zorro_release_device(z) \
  150. release_mem_region(zorro_resource_start(z), zorro_resource_len(z))
  151. /* Similar to the helpers above, these manipulate per-zorro_dev
  152. * driver-specific data. They are really just a wrapper around
  153. * the generic device structure functions of these calls.
  154. */
  155. static inline void *zorro_get_drvdata (struct zorro_dev *z)
  156. {
  157. return dev_get_drvdata(&z->dev);
  158. }
  159. static inline void zorro_set_drvdata (struct zorro_dev *z, void *data)
  160. {
  161. dev_set_drvdata(&z->dev, data);
  162. }
  163. /*
  164. * Bitmask indicating portions of available Zorro II RAM that are unused
  165. * by the system. Every bit represents a 64K chunk, for a maximum of 8MB
  166. * (128 chunks, physical 0x00200000-0x009fffff).
  167. *
  168. * If you want to use (= allocate) portions of this RAM, you should clear
  169. * the corresponding bits.
  170. */
  171. extern DECLARE_BITMAP(zorro_unused_z2ram, 128);
  172. #define Z2RAM_START (0x00200000)
  173. #define Z2RAM_END (0x00a00000)
  174. #define Z2RAM_SIZE (0x00800000)
  175. #define Z2RAM_CHUNKSIZE (0x00010000)
  176. #define Z2RAM_CHUNKMASK (0x0000ffff)
  177. #define Z2RAM_CHUNKSHIFT (16)
  178. #endif /* __KERNEL__ */
  179. #endif /* _LINUX_ZORRO_H */