zorro.h 3.6 KB

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