1*1a59d1b8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
41da177e4SLinus Torvalds * of PCI-SCSI IO processors.
51da177e4SLinus Torvalds *
61da177e4SLinus Torvalds * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
71da177e4SLinus Torvalds *
81da177e4SLinus Torvalds * This driver is derived from the Linux sym53c8xx driver.
91da177e4SLinus Torvalds * Copyright (C) 1998-2000 Gerard Roudier
101da177e4SLinus Torvalds *
111da177e4SLinus Torvalds * The sym53c8xx driver is derived from the ncr53c8xx driver that had been
121da177e4SLinus Torvalds * a port of the FreeBSD ncr driver to Linux-1.2.13.
131da177e4SLinus Torvalds *
141da177e4SLinus Torvalds * The original ncr driver has been written for 386bsd and FreeBSD by
151da177e4SLinus Torvalds * Wolfgang Stanglmeier <wolf@cologne.de>
161da177e4SLinus Torvalds * Stefan Esser <se@mi.Uni-Koeln.de>
171da177e4SLinus Torvalds * Copyright (C) 1994 Wolfgang Stanglmeier
181da177e4SLinus Torvalds *
191da177e4SLinus Torvalds * Other major contributions:
201da177e4SLinus Torvalds *
211da177e4SLinus Torvalds * NVRAM detection and reading.
221da177e4SLinus Torvalds * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
231da177e4SLinus Torvalds *
241da177e4SLinus Torvalds *-----------------------------------------------------------------------------
251da177e4SLinus Torvalds */
261da177e4SLinus Torvalds
271da177e4SLinus Torvalds #ifndef SYM_NVRAM_H
281da177e4SLinus Torvalds #define SYM_NVRAM_H
291da177e4SLinus Torvalds
301da177e4SLinus Torvalds #include "sym53c8xx.h"
311da177e4SLinus Torvalds
321da177e4SLinus Torvalds /*
331da177e4SLinus Torvalds * Symbios NVRAM data format
341da177e4SLinus Torvalds */
351da177e4SLinus Torvalds #define SYMBIOS_NVRAM_SIZE 368
361da177e4SLinus Torvalds #define SYMBIOS_NVRAM_ADDRESS 0x100
371da177e4SLinus Torvalds
381da177e4SLinus Torvalds struct Symbios_nvram {
391da177e4SLinus Torvalds /* Header 6 bytes */
401da177e4SLinus Torvalds u_short type; /* 0x0000 */
411da177e4SLinus Torvalds u_short byte_count; /* excluding header/trailer */
421da177e4SLinus Torvalds u_short checksum;
431da177e4SLinus Torvalds
441da177e4SLinus Torvalds /* Controller set up 20 bytes */
451da177e4SLinus Torvalds u_char v_major; /* 0x00 */
461da177e4SLinus Torvalds u_char v_minor; /* 0x30 */
471da177e4SLinus Torvalds u32 boot_crc;
481da177e4SLinus Torvalds u_short flags;
491da177e4SLinus Torvalds #define SYMBIOS_SCAM_ENABLE (1)
501da177e4SLinus Torvalds #define SYMBIOS_PARITY_ENABLE (1<<1)
511da177e4SLinus Torvalds #define SYMBIOS_VERBOSE_MSGS (1<<2)
521da177e4SLinus Torvalds #define SYMBIOS_CHS_MAPPING (1<<3)
531da177e4SLinus Torvalds #define SYMBIOS_NO_NVRAM (1<<3) /* ??? */
541da177e4SLinus Torvalds u_short flags1;
551da177e4SLinus Torvalds #define SYMBIOS_SCAN_HI_LO (1)
561da177e4SLinus Torvalds u_short term_state;
571da177e4SLinus Torvalds #define SYMBIOS_TERM_CANT_PROGRAM (0)
581da177e4SLinus Torvalds #define SYMBIOS_TERM_ENABLED (1)
591da177e4SLinus Torvalds #define SYMBIOS_TERM_DISABLED (2)
601da177e4SLinus Torvalds u_short rmvbl_flags;
611da177e4SLinus Torvalds #define SYMBIOS_RMVBL_NO_SUPPORT (0)
621da177e4SLinus Torvalds #define SYMBIOS_RMVBL_BOOT_DEVICE (1)
631da177e4SLinus Torvalds #define SYMBIOS_RMVBL_MEDIA_INSTALLED (2)
641da177e4SLinus Torvalds u_char host_id;
651da177e4SLinus Torvalds u_char num_hba; /* 0x04 */
661da177e4SLinus Torvalds u_char num_devices; /* 0x10 */
671da177e4SLinus Torvalds u_char max_scam_devices; /* 0x04 */
681da177e4SLinus Torvalds u_char num_valid_scam_devices; /* 0x00 */
691da177e4SLinus Torvalds u_char flags2;
701da177e4SLinus Torvalds #define SYMBIOS_AVOID_BUS_RESET (1<<2)
711da177e4SLinus Torvalds
721da177e4SLinus Torvalds /* Boot order 14 bytes * 4 */
731da177e4SLinus Torvalds struct Symbios_host{
741da177e4SLinus Torvalds u_short type; /* 4:8xx / 0:nok */
751da177e4SLinus Torvalds u_short device_id; /* PCI device id */
761da177e4SLinus Torvalds u_short vendor_id; /* PCI vendor id */
771da177e4SLinus Torvalds u_char bus_nr; /* PCI bus number */
781da177e4SLinus Torvalds u_char device_fn; /* PCI device/function number << 3*/
791da177e4SLinus Torvalds u_short word8;
801da177e4SLinus Torvalds u_short flags;
811da177e4SLinus Torvalds #define SYMBIOS_INIT_SCAN_AT_BOOT (1)
821da177e4SLinus Torvalds u_short io_port; /* PCI io_port address */
831da177e4SLinus Torvalds } host[4];
841da177e4SLinus Torvalds
851da177e4SLinus Torvalds /* Targets 8 bytes * 16 */
861da177e4SLinus Torvalds struct Symbios_target {
871da177e4SLinus Torvalds u_char flags;
881da177e4SLinus Torvalds #define SYMBIOS_DISCONNECT_ENABLE (1)
891da177e4SLinus Torvalds #define SYMBIOS_SCAN_AT_BOOT_TIME (1<<1)
901da177e4SLinus Torvalds #define SYMBIOS_SCAN_LUNS (1<<2)
911da177e4SLinus Torvalds #define SYMBIOS_QUEUE_TAGS_ENABLED (1<<3)
921da177e4SLinus Torvalds u_char rsvd;
931da177e4SLinus Torvalds u_char bus_width; /* 0x08/0x10 */
941da177e4SLinus Torvalds u_char sync_offset;
951da177e4SLinus Torvalds u_short sync_period; /* 4*period factor */
961da177e4SLinus Torvalds u_short timeout;
971da177e4SLinus Torvalds } target[16];
981da177e4SLinus Torvalds /* Scam table 8 bytes * 4 */
991da177e4SLinus Torvalds struct Symbios_scam {
1001da177e4SLinus Torvalds u_short id;
1011da177e4SLinus Torvalds u_short method;
1021da177e4SLinus Torvalds #define SYMBIOS_SCAM_DEFAULT_METHOD (0)
1031da177e4SLinus Torvalds #define SYMBIOS_SCAM_DONT_ASSIGN (1)
1041da177e4SLinus Torvalds #define SYMBIOS_SCAM_SET_SPECIFIC_ID (2)
1051da177e4SLinus Torvalds #define SYMBIOS_SCAM_USE_ORDER_GIVEN (3)
1061da177e4SLinus Torvalds u_short status;
1071da177e4SLinus Torvalds #define SYMBIOS_SCAM_UNKNOWN (0)
1081da177e4SLinus Torvalds #define SYMBIOS_SCAM_DEVICE_NOT_FOUND (1)
1091da177e4SLinus Torvalds #define SYMBIOS_SCAM_ID_NOT_SET (2)
1101da177e4SLinus Torvalds #define SYMBIOS_SCAM_ID_VALID (3)
1111da177e4SLinus Torvalds u_char target_id;
1121da177e4SLinus Torvalds u_char rsvd;
1131da177e4SLinus Torvalds } scam[4];
1141da177e4SLinus Torvalds
1151da177e4SLinus Torvalds u_char spare_devices[15*8];
1161da177e4SLinus Torvalds u_char trailer[6]; /* 0xfe 0xfe 0x00 0x00 0x00 0x00 */
1171da177e4SLinus Torvalds };
1181da177e4SLinus Torvalds typedef struct Symbios_nvram Symbios_nvram;
1191da177e4SLinus Torvalds typedef struct Symbios_host Symbios_host;
1201da177e4SLinus Torvalds typedef struct Symbios_target Symbios_target;
1211da177e4SLinus Torvalds typedef struct Symbios_scam Symbios_scam;
1221da177e4SLinus Torvalds
1231da177e4SLinus Torvalds /*
1241da177e4SLinus Torvalds * Tekram NvRAM data format.
1251da177e4SLinus Torvalds */
1261da177e4SLinus Torvalds #define TEKRAM_NVRAM_SIZE 64
1271da177e4SLinus Torvalds #define TEKRAM_93C46_NVRAM_ADDRESS 0
1281da177e4SLinus Torvalds #define TEKRAM_24C16_NVRAM_ADDRESS 0x40
1291da177e4SLinus Torvalds
1301da177e4SLinus Torvalds struct Tekram_nvram {
1311da177e4SLinus Torvalds struct Tekram_target {
1321da177e4SLinus Torvalds u_char flags;
1331da177e4SLinus Torvalds #define TEKRAM_PARITY_CHECK (1)
1341da177e4SLinus Torvalds #define TEKRAM_SYNC_NEGO (1<<1)
1351da177e4SLinus Torvalds #define TEKRAM_DISCONNECT_ENABLE (1<<2)
1361da177e4SLinus Torvalds #define TEKRAM_START_CMD (1<<3)
1371da177e4SLinus Torvalds #define TEKRAM_TAGGED_COMMANDS (1<<4)
1381da177e4SLinus Torvalds #define TEKRAM_WIDE_NEGO (1<<5)
1391da177e4SLinus Torvalds u_char sync_index;
1401da177e4SLinus Torvalds u_short word2;
1411da177e4SLinus Torvalds } target[16];
1421da177e4SLinus Torvalds u_char host_id;
1431da177e4SLinus Torvalds u_char flags;
1441da177e4SLinus Torvalds #define TEKRAM_MORE_THAN_2_DRIVES (1)
1451da177e4SLinus Torvalds #define TEKRAM_DRIVES_SUP_1GB (1<<1)
1461da177e4SLinus Torvalds #define TEKRAM_RESET_ON_POWER_ON (1<<2)
1471da177e4SLinus Torvalds #define TEKRAM_ACTIVE_NEGATION (1<<3)
1481da177e4SLinus Torvalds #define TEKRAM_IMMEDIATE_SEEK (1<<4)
1491da177e4SLinus Torvalds #define TEKRAM_SCAN_LUNS (1<<5)
1501da177e4SLinus Torvalds #define TEKRAM_REMOVABLE_FLAGS (3<<6) /* 0: disable; */
1511da177e4SLinus Torvalds /* 1: boot device; 2:all */
1521da177e4SLinus Torvalds u_char boot_delay_index;
1531da177e4SLinus Torvalds u_char max_tags_index;
1541da177e4SLinus Torvalds u_short flags1;
1551da177e4SLinus Torvalds #define TEKRAM_F2_F6_ENABLED (1)
1561da177e4SLinus Torvalds u_short spare[29];
1571da177e4SLinus Torvalds };
1581da177e4SLinus Torvalds typedef struct Tekram_nvram Tekram_nvram;
1591da177e4SLinus Torvalds typedef struct Tekram_target Tekram_target;
1601da177e4SLinus Torvalds
1611da177e4SLinus Torvalds #ifndef CONFIG_PARISC
1621da177e4SLinus Torvalds struct pdc_initiator { int dummy; };
1631da177e4SLinus Torvalds #endif
1641da177e4SLinus Torvalds
1651da177e4SLinus Torvalds /*
1661da177e4SLinus Torvalds * Union of supported NVRAM formats.
1671da177e4SLinus Torvalds */
1681da177e4SLinus Torvalds struct sym_nvram {
1691da177e4SLinus Torvalds int type;
1701da177e4SLinus Torvalds #define SYM_SYMBIOS_NVRAM (1)
1711da177e4SLinus Torvalds #define SYM_TEKRAM_NVRAM (2)
1721da177e4SLinus Torvalds #define SYM_PARISC_PDC (3)
1731da177e4SLinus Torvalds #if SYM_CONF_NVRAM_SUPPORT
1741da177e4SLinus Torvalds union {
1751da177e4SLinus Torvalds Symbios_nvram Symbios;
1761da177e4SLinus Torvalds Tekram_nvram Tekram;
1771da177e4SLinus Torvalds struct pdc_initiator parisc;
1781da177e4SLinus Torvalds } data;
1791da177e4SLinus Torvalds #endif
1801da177e4SLinus Torvalds };
1811da177e4SLinus Torvalds
1821da177e4SLinus Torvalds #if SYM_CONF_NVRAM_SUPPORT
1831da177e4SLinus Torvalds void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram);
184b37df489SMatthew Wilcox void sym_nvram_setup_target (struct sym_tcb *tp, int target, struct sym_nvram *nvp);
1851da177e4SLinus Torvalds int sym_read_nvram (struct sym_device *np, struct sym_nvram *nvp);
1861da177e4SLinus Torvalds char *sym_nvram_type(struct sym_nvram *nvp);
1871da177e4SLinus Torvalds #else
sym_nvram_setup_host(struct Scsi_Host * shost,struct sym_hcb * np,struct sym_nvram * nvram)1881da177e4SLinus Torvalds static inline void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram) { }
sym_nvram_setup_target(struct sym_tcb * tp,struct sym_nvram * nvram)189b37df489SMatthew Wilcox static inline void sym_nvram_setup_target(struct sym_tcb *tp, struct sym_nvram *nvram) { }
sym_read_nvram(struct sym_device * np,struct sym_nvram * nvp)1901da177e4SLinus Torvalds static inline int sym_read_nvram(struct sym_device *np, struct sym_nvram *nvp)
1911da177e4SLinus Torvalds {
1921da177e4SLinus Torvalds nvp->type = 0;
1931da177e4SLinus Torvalds return 0;
1941da177e4SLinus Torvalds }
sym_nvram_type(struct sym_nvram * nvp)1951da177e4SLinus Torvalds static inline char *sym_nvram_type(struct sym_nvram *nvp)
1961da177e4SLinus Torvalds {
1971da177e4SLinus Torvalds return "No NVRAM";
1981da177e4SLinus Torvalds }
1991da177e4SLinus Torvalds #endif
2001da177e4SLinus Torvalds
2011da177e4SLinus Torvalds #endif /* SYM_NVRAM_H */
202