sym_nvram.h 5.6 KB

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