tc.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Interface to the TURBOchannel related routines.
  3. *
  4. * Copyright (c) 1998 Harald Koerfgen
  5. * Copyright (c) 2005 James Simmons
  6. * Copyright (c) 2006 Maciej W. Rozycki
  7. *
  8. * Based on:
  9. *
  10. * "TURBOchannel Firmware Specification", EK-TCAAD-FS-004
  11. *
  12. * from Digital Equipment Corporation.
  13. *
  14. * This file is subject to the terms and conditions of the GNU
  15. * General Public License. See the file "COPYING" in the main
  16. * directory of this archive for more details.
  17. */
  18. #ifndef _LINUX_TC_H
  19. #define _LINUX_TC_H
  20. #include <linux/compiler.h>
  21. #include <linux/device.h>
  22. #include <linux/ioport.h>
  23. #include <linux/types.h>
  24. /*
  25. * Offsets for the ROM header locations for TURBOchannel cards.
  26. */
  27. #define TC_OLDCARD 0x3c0000
  28. #define TC_NEWCARD 0x000000
  29. #define TC_ROM_WIDTH 0x3e0
  30. #define TC_ROM_STRIDE 0x3e4
  31. #define TC_ROM_SIZE 0x3e8
  32. #define TC_SLOT_SIZE 0x3ec
  33. #define TC_PATTERN0 0x3f0
  34. #define TC_PATTERN1 0x3f4
  35. #define TC_PATTERN2 0x3f8
  36. #define TC_PATTERN3 0x3fc
  37. #define TC_FIRM_VER 0x400
  38. #define TC_VENDOR 0x420
  39. #define TC_MODULE 0x440
  40. #define TC_FIRM_TYPE 0x460
  41. #define TC_FLAGS 0x470
  42. #define TC_ROM_OBJECTS 0x480
  43. /*
  44. * Information obtained through the get_tcinfo() PROM call.
  45. */
  46. struct tcinfo {
  47. s32 revision; /* Hardware revision level. */
  48. s32 clk_period; /* Clock period in nanoseconds. */
  49. s32 slot_size; /* Slot size in megabytes. */
  50. s32 io_timeout; /* I/O timeout in cycles. */
  51. s32 dma_range; /* DMA address range in megabytes. */
  52. s32 max_dma_burst; /* Maximum DMA burst length. */
  53. s32 parity; /* System module supports TC parity. */
  54. s32 reserved[4];
  55. };
  56. /*
  57. * TURBOchannel bus.
  58. */
  59. struct tc_bus {
  60. struct list_head devices; /* List of devices on this bus. */
  61. struct resource resource[2]; /* Address space routed to this bus. */
  62. struct device dev;
  63. char name[13];
  64. resource_size_t slot_base;
  65. resource_size_t ext_slot_base;
  66. resource_size_t ext_slot_size;
  67. int num_tcslots;
  68. struct tcinfo info;
  69. };
  70. /*
  71. * TURBOchannel device.
  72. */
  73. struct tc_dev {
  74. struct list_head node; /* Node in list of all TC devices. */
  75. struct tc_bus *bus; /* Bus this device is on. */
  76. struct tc_driver *driver; /* Which driver has allocated this
  77. device. */
  78. struct device dev; /* Generic device interface. */
  79. struct resource resource; /* Address space of this device. */
  80. u64 dma_mask; /* DMA addressable range. */
  81. char vendor[9];
  82. char name[9];
  83. char firmware[9];
  84. int interrupt;
  85. int slot;
  86. };
  87. #define to_tc_dev(n) container_of(n, struct tc_dev, dev)
  88. struct tc_device_id {
  89. char vendor[9];
  90. char name[9];
  91. };
  92. /*
  93. * TURBOchannel driver.
  94. */
  95. struct tc_driver {
  96. struct list_head node;
  97. const struct tc_device_id *id_table;
  98. struct device_driver driver;
  99. };
  100. #define to_tc_driver(drv) container_of(drv, struct tc_driver, driver)
  101. /*
  102. * Return TURBOchannel clock frequency in Hz.
  103. */
  104. static inline unsigned long tc_get_speed(struct tc_bus *tbus)
  105. {
  106. return 100000 * (10000 / (unsigned long)tbus->info.clk_period);
  107. }
  108. #ifdef CONFIG_TC
  109. extern struct bus_type tc_bus_type;
  110. extern int tc_register_driver(struct tc_driver *tdrv);
  111. extern void tc_unregister_driver(struct tc_driver *tdrv);
  112. #else /* !CONFIG_TC */
  113. static inline int tc_register_driver(struct tc_driver *tdrv) { return 0; }
  114. static inline void tc_unregister_driver(struct tc_driver *tdrv) { }
  115. #endif /* CONFIG_TC */
  116. /*
  117. * These have to be provided by the architecture.
  118. */
  119. extern int tc_preadb(u8 *valp, void __iomem *addr);
  120. extern int tc_bus_get_info(struct tc_bus *tbus);
  121. extern void tc_device_get_irq(struct tc_dev *tdev);
  122. #endif /* _LINUX_TC_H */