zorro.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 <uapi/linux/zorro.h>
  13. #include <linux/device.h>
  14. #include <linux/init.h>
  15. #include <linux/ioport.h>
  16. #include <linux/mod_devicetable.h>
  17. #include <asm/zorro.h>
  18. /*
  19. * Zorro devices
  20. */
  21. struct zorro_dev {
  22. struct ExpansionRom rom;
  23. zorro_id id;
  24. struct zorro_driver *driver; /* which driver has allocated this device */
  25. struct device dev; /* Generic device interface */
  26. u16 slotaddr;
  27. u16 slotsize;
  28. char name[64];
  29. struct resource resource;
  30. };
  31. #define to_zorro_dev(n) container_of(n, struct zorro_dev, dev)
  32. /*
  33. * Zorro bus
  34. */
  35. extern struct bus_type zorro_bus_type;
  36. /*
  37. * Zorro device drivers
  38. */
  39. struct zorro_driver {
  40. struct list_head node;
  41. char *name;
  42. const struct zorro_device_id *id_table; /* NULL if wants all devices */
  43. int (*probe)(struct zorro_dev *z, const struct zorro_device_id *id); /* New device inserted */
  44. void (*remove)(struct zorro_dev *z); /* Device removed (NULL if not a hot-plug capable driver) */
  45. struct device_driver driver;
  46. };
  47. #define to_zorro_driver(drv) container_of(drv, struct zorro_driver, driver)
  48. #define zorro_for_each_dev(dev) \
  49. for (dev = &zorro_autocon[0]; dev < zorro_autocon+zorro_num_autocon; dev++)
  50. /* New-style probing */
  51. extern int zorro_register_driver(struct zorro_driver *);
  52. extern void zorro_unregister_driver(struct zorro_driver *);
  53. extern const struct zorro_device_id *zorro_match_device(const struct zorro_device_id *ids, const struct zorro_dev *z);
  54. static inline struct zorro_driver *zorro_dev_driver(const struct zorro_dev *z)
  55. {
  56. return z->driver;
  57. }
  58. extern unsigned int zorro_num_autocon; /* # of autoconfig devices found */
  59. extern struct zorro_dev *zorro_autocon;
  60. /*
  61. * Minimal information about a Zorro device, passed from bootinfo
  62. * Only available temporarily, i.e. until initmem has been freed!
  63. */
  64. struct zorro_dev_init {
  65. struct ExpansionRom rom;
  66. u16 slotaddr;
  67. u16 slotsize;
  68. u32 boardaddr;
  69. u32 boardsize;
  70. };
  71. extern struct zorro_dev_init zorro_autocon_init[ZORRO_NUM_AUTO] __initdata;
  72. /*
  73. * Zorro Functions
  74. */
  75. extern struct zorro_dev *zorro_find_device(zorro_id id,
  76. struct zorro_dev *from);
  77. #define zorro_resource_start(z) ((z)->resource.start)
  78. #define zorro_resource_end(z) ((z)->resource.end)
  79. #define zorro_resource_len(z) (resource_size(&(z)->resource))
  80. #define zorro_resource_flags(z) ((z)->resource.flags)
  81. #define zorro_request_device(z, name) \
  82. request_mem_region(zorro_resource_start(z), zorro_resource_len(z), name)
  83. #define zorro_release_device(z) \
  84. release_mem_region(zorro_resource_start(z), zorro_resource_len(z))
  85. /* Similar to the helpers above, these manipulate per-zorro_dev
  86. * driver-specific data. They are really just a wrapper around
  87. * the generic device structure functions of these calls.
  88. */
  89. static inline void *zorro_get_drvdata (struct zorro_dev *z)
  90. {
  91. return dev_get_drvdata(&z->dev);
  92. }
  93. static inline void zorro_set_drvdata (struct zorro_dev *z, void *data)
  94. {
  95. dev_set_drvdata(&z->dev, data);
  96. }
  97. /*
  98. * Bitmask indicating portions of available Zorro II RAM that are unused
  99. * by the system. Every bit represents a 64K chunk, for a maximum of 8MB
  100. * (128 chunks, physical 0x00200000-0x009fffff).
  101. *
  102. * If you want to use (= allocate) portions of this RAM, you should clear
  103. * the corresponding bits.
  104. */
  105. extern DECLARE_BITMAP(zorro_unused_z2ram, 128);
  106. #define Z2RAM_START (0x00200000)
  107. #define Z2RAM_END (0x00a00000)
  108. #define Z2RAM_SIZE (0x00800000)
  109. #define Z2RAM_CHUNKSIZE (0x00010000)
  110. #define Z2RAM_CHUNKMASK (0x0000ffff)
  111. #define Z2RAM_CHUNKSHIFT (16)
  112. #endif /* _LINUX_ZORRO_H */