sym_nvram.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
  3. * of PCI-SCSI IO processors.
  4. *
  5. * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
  6. *
  7. * This driver is derived from the Linux sym53c8xx driver.
  8. * Copyright (C) 1998-2000 Gerard Roudier
  9. *
  10. * The sym53c8xx driver is derived from the ncr53c8xx driver that had been
  11. * a port of the FreeBSD ncr driver to Linux-1.2.13.
  12. *
  13. * The original ncr driver has been written for 386bsd and FreeBSD by
  14. * Wolfgang Stanglmeier <wolf@cologne.de>
  15. * Stefan Esser <se@mi.Uni-Koeln.de>
  16. * Copyright (C) 1994 Wolfgang Stanglmeier
  17. *
  18. * Other major contributions:
  19. *
  20. * NVRAM detection and reading.
  21. * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
  22. *
  23. *-----------------------------------------------------------------------------
  24. *
  25. * This program is free software; you can redistribute it and/or modify
  26. * it under the terms of the GNU General Public License as published by
  27. * the Free Software Foundation; either version 2 of the License, or
  28. * (at your option) any later version.
  29. *
  30. * This program is distributed in the hope that it will be useful,
  31. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. * GNU General Public License for more details.
  34. *
  35. * You should have received a copy of the GNU General Public License
  36. * along with this program; if not, write to the Free Software
  37. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  38. */
  39. #ifndef SYM_NVRAM_H
  40. #define SYM_NVRAM_H
  41. #include "sym53c8xx.h"
  42. /*
  43. * Symbios NVRAM data format
  44. */
  45. #define SYMBIOS_NVRAM_SIZE 368
  46. #define SYMBIOS_NVRAM_ADDRESS 0x100
  47. struct Symbios_nvram {
  48. /* Header 6 bytes */
  49. u_short type; /* 0x0000 */
  50. u_short byte_count; /* excluding header/trailer */
  51. u_short checksum;
  52. /* Controller set up 20 bytes */
  53. u_char v_major; /* 0x00 */
  54. u_char v_minor; /* 0x30 */
  55. u32 boot_crc;
  56. u_short flags;
  57. #define SYMBIOS_SCAM_ENABLE (1)
  58. #define SYMBIOS_PARITY_ENABLE (1<<1)
  59. #define SYMBIOS_VERBOSE_MSGS (1<<2)
  60. #define SYMBIOS_CHS_MAPPING (1<<3)
  61. #define SYMBIOS_NO_NVRAM (1<<3) /* ??? */
  62. u_short flags1;
  63. #define SYMBIOS_SCAN_HI_LO (1)
  64. u_short term_state;
  65. #define SYMBIOS_TERM_CANT_PROGRAM (0)
  66. #define SYMBIOS_TERM_ENABLED (1)
  67. #define SYMBIOS_TERM_DISABLED (2)
  68. u_short rmvbl_flags;
  69. #define SYMBIOS_RMVBL_NO_SUPPORT (0)
  70. #define SYMBIOS_RMVBL_BOOT_DEVICE (1)
  71. #define SYMBIOS_RMVBL_MEDIA_INSTALLED (2)
  72. u_char host_id;
  73. u_char num_hba; /* 0x04 */
  74. u_char num_devices; /* 0x10 */
  75. u_char max_scam_devices; /* 0x04 */
  76. u_char num_valid_scam_devices; /* 0x00 */
  77. u_char flags2;
  78. #define SYMBIOS_AVOID_BUS_RESET (1<<2)
  79. /* Boot order 14 bytes * 4 */
  80. struct Symbios_host{
  81. u_short type; /* 4:8xx / 0:nok */
  82. u_short device_id; /* PCI device id */
  83. u_short vendor_id; /* PCI vendor id */
  84. u_char bus_nr; /* PCI bus number */
  85. u_char device_fn; /* PCI device/function number << 3*/
  86. u_short word8;
  87. u_short flags;
  88. #define SYMBIOS_INIT_SCAN_AT_BOOT (1)
  89. u_short io_port; /* PCI io_port address */
  90. } host[4];
  91. /* Targets 8 bytes * 16 */
  92. struct Symbios_target {
  93. u_char flags;
  94. #define SYMBIOS_DISCONNECT_ENABLE (1)
  95. #define SYMBIOS_SCAN_AT_BOOT_TIME (1<<1)
  96. #define SYMBIOS_SCAN_LUNS (1<<2)
  97. #define SYMBIOS_QUEUE_TAGS_ENABLED (1<<3)
  98. u_char rsvd;
  99. u_char bus_width; /* 0x08/0x10 */
  100. u_char sync_offset;
  101. u_short sync_period; /* 4*period factor */
  102. u_short timeout;
  103. } target[16];
  104. /* Scam table 8 bytes * 4 */
  105. struct Symbios_scam {
  106. u_short id;
  107. u_short method;
  108. #define SYMBIOS_SCAM_DEFAULT_METHOD (0)
  109. #define SYMBIOS_SCAM_DONT_ASSIGN (1)
  110. #define SYMBIOS_SCAM_SET_SPECIFIC_ID (2)
  111. #define SYMBIOS_SCAM_USE_ORDER_GIVEN (3)
  112. u_short status;
  113. #define SYMBIOS_SCAM_UNKNOWN (0)
  114. #define SYMBIOS_SCAM_DEVICE_NOT_FOUND (1)
  115. #define SYMBIOS_SCAM_ID_NOT_SET (2)
  116. #define SYMBIOS_SCAM_ID_VALID (3)
  117. u_char target_id;
  118. u_char rsvd;
  119. } scam[4];
  120. u_char spare_devices[15*8];
  121. u_char trailer[6]; /* 0xfe 0xfe 0x00 0x00 0x00 0x00 */
  122. };
  123. typedef struct Symbios_nvram Symbios_nvram;
  124. typedef struct Symbios_host Symbios_host;
  125. typedef struct Symbios_target Symbios_target;
  126. typedef struct Symbios_scam Symbios_scam;
  127. /*
  128. * Tekram NvRAM data format.
  129. */
  130. #define TEKRAM_NVRAM_SIZE 64
  131. #define TEKRAM_93C46_NVRAM_ADDRESS 0
  132. #define TEKRAM_24C16_NVRAM_ADDRESS 0x40
  133. struct Tekram_nvram {
  134. struct Tekram_target {
  135. u_char flags;
  136. #define TEKRAM_PARITY_CHECK (1)
  137. #define TEKRAM_SYNC_NEGO (1<<1)
  138. #define TEKRAM_DISCONNECT_ENABLE (1<<2)
  139. #define TEKRAM_START_CMD (1<<3)
  140. #define TEKRAM_TAGGED_COMMANDS (1<<4)
  141. #define TEKRAM_WIDE_NEGO (1<<5)
  142. u_char sync_index;
  143. u_short word2;
  144. } target[16];
  145. u_char host_id;
  146. u_char flags;
  147. #define TEKRAM_MORE_THAN_2_DRIVES (1)
  148. #define TEKRAM_DRIVES_SUP_1GB (1<<1)
  149. #define TEKRAM_RESET_ON_POWER_ON (1<<2)
  150. #define TEKRAM_ACTIVE_NEGATION (1<<3)
  151. #define TEKRAM_IMMEDIATE_SEEK (1<<4)
  152. #define TEKRAM_SCAN_LUNS (1<<5)
  153. #define TEKRAM_REMOVABLE_FLAGS (3<<6) /* 0: disable; */
  154. /* 1: boot device; 2:all */
  155. u_char boot_delay_index;
  156. u_char max_tags_index;
  157. u_short flags1;
  158. #define TEKRAM_F2_F6_ENABLED (1)
  159. u_short spare[29];
  160. };
  161. typedef struct Tekram_nvram Tekram_nvram;
  162. typedef struct Tekram_target Tekram_target;
  163. #ifndef CONFIG_PARISC
  164. struct pdc_initiator { int dummy; };
  165. #endif
  166. /*
  167. * Union of supported NVRAM formats.
  168. */
  169. struct sym_nvram {
  170. int type;
  171. #define SYM_SYMBIOS_NVRAM (1)
  172. #define SYM_TEKRAM_NVRAM (2)
  173. #define SYM_PARISC_PDC (3)
  174. #if SYM_CONF_NVRAM_SUPPORT
  175. union {
  176. Symbios_nvram Symbios;
  177. Tekram_nvram Tekram;
  178. struct pdc_initiator parisc;
  179. } data;
  180. #endif
  181. };
  182. #if SYM_CONF_NVRAM_SUPPORT
  183. void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram);
  184. void sym_nvram_setup_target (struct sym_tcb *tp, int target, struct sym_nvram *nvp);
  185. int sym_read_nvram (struct sym_device *np, struct sym_nvram *nvp);
  186. char *sym_nvram_type(struct sym_nvram *nvp);
  187. #else
  188. static inline void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram) { }
  189. static inline void sym_nvram_setup_target(struct sym_tcb *tp, struct sym_nvram *nvram) { }
  190. static inline int sym_read_nvram(struct sym_device *np, struct sym_nvram *nvp)
  191. {
  192. nvp->type = 0;
  193. return 0;
  194. }
  195. static inline char *sym_nvram_type(struct sym_nvram *nvp)
  196. {
  197. return "No NVRAM";
  198. }
  199. #endif
  200. #endif /* SYM_NVRAM_H */