zorro.h 3.6 KB

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