Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /***************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)                           dpti.h  -  description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)                              -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)     begin                : Thu Sep 7 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)     copyright            : (C) 2001 by Adaptec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)     See Documentation/scsi/dpti.rst for history, notes, license info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)     and credits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  ***************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) /***************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *                                                                         *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *                                                                         *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  ***************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #ifndef _DPT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define _DPT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define MAX_TO_IOP_MESSAGES   (255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define MAX_FROM_IOP_MESSAGES (255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * SCSI interface function Prototypes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static int adpt_detect(struct scsi_host_template * sht);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) static int adpt_queue(struct Scsi_Host *h, struct scsi_cmnd * cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) static int adpt_abort(struct scsi_cmnd * cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static int adpt_reset(struct scsi_cmnd* cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) static int adpt_slave_configure(struct scsi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) static const char *adpt_info(struct Scsi_Host *pSHost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) static int adpt_bios_param(struct scsi_device * sdev, struct block_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		sector_t, int geom[]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static int adpt_bus_reset(struct scsi_cmnd* cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static int adpt_device_reset(struct scsi_cmnd* cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * struct scsi_host_template (see scsi/scsi_host.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define DPT_DRIVER_NAME	"Adaptec I2O RAID"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #ifndef HOSTS_C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #include "dpt/sys_info.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #include "dpt/dpti_i2o.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #include "dpt/dpti_ioctl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define DPT_I2O_VERSION "2.4 Build 5go"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define DPT_VERSION     2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define DPT_REVISION    '4'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define DPT_SUBREVISION '5'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define DPT_BETA	""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define DPT_MONTH      8 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define DPT_DAY        7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #define DPT_YEAR        (2001-1980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define DPT_DRIVER	"dpt_i2o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define DPTI_I2O_MAJOR	(151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define DPT_ORGANIZATION_ID (0x1B)        /* For Private Messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define DPTI_MAX_HBA	(16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #define MAX_CHANNEL     (5)	// Maximum Channel # Supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define MAX_ID        	(128)	// Maximum Target ID Supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) /* Sizes in 4 byte words */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #define REPLY_FRAME_SIZE  (17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #define MAX_MESSAGE_SIZE  (128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) #define SG_LIST_ELEMENTS  (56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #define EMPTY_QUEUE           0xffffffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) #define I2O_INTERRUPT_PENDING_B   (0x08)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) #define PCI_DPT_VENDOR_ID         (0x1044)	// DPT PCI Vendor ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #define PCI_DPT_DEVICE_ID         (0xA501)	// DPT PCI I2O Device ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) #define PCI_DPT_RAPTOR_DEVICE_ID  (0xA511)	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) /* Debugging macro from Linux Device Drivers - Rubini */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) #undef PDEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) //TODO add debug level switch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #  define PDEBUG(fmt, args...)  printk(KERN_DEBUG "dpti: " fmt, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) #  define PDEBUGV(fmt, args...) printk(KERN_DEBUG "dpti: " fmt, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) # define PDEBUG(fmt, args...) /* not debugging: nothing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) # define PDEBUGV(fmt, args...) /* not debugging: nothing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #define PERROR(fmt, args...) printk(KERN_ERR fmt, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) #define PWARN(fmt, args...) printk(KERN_WARNING fmt, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #define PINFO(fmt, args...) printk(KERN_INFO fmt, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) #define PCRIT(fmt, args...) printk(KERN_CRIT fmt, ##args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #define SHUTDOWN_SIGS	(sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) // Command timeouts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define FOREVER			(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define TMOUT_INQUIRY 		(20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define TMOUT_FLUSH		(360/45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define TMOUT_ABORT		(30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define TMOUT_SCSI		(300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define TMOUT_IOPRESET		(360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define TMOUT_GETSTATUS		(15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define TMOUT_INITOUTBOUND	(15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define TMOUT_LCT		(360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define I2O_SCSI_DEVICE_DSC_MASK                0x00FF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define I2O_DETAIL_STATUS_UNSUPPORTED_FUNCTION  0x000A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define I2O_SCSI_DSC_MASK                   0xFF00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define I2O_SCSI_DSC_SUCCESS                0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define I2O_SCSI_DSC_REQUEST_ABORTED        0x0200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define I2O_SCSI_DSC_UNABLE_TO_ABORT        0x0300
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define I2O_SCSI_DSC_COMPLETE_WITH_ERROR    0x0400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define I2O_SCSI_DSC_ADAPTER_BUSY           0x0500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define I2O_SCSI_DSC_REQUEST_INVALID        0x0600
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define I2O_SCSI_DSC_PATH_INVALID           0x0700
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define I2O_SCSI_DSC_DEVICE_NOT_PRESENT     0x0800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define I2O_SCSI_DSC_UNABLE_TO_TERMINATE    0x0900
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #define I2O_SCSI_DSC_SELECTION_TIMEOUT      0x0A00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define I2O_SCSI_DSC_COMMAND_TIMEOUT        0x0B00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #define I2O_SCSI_DSC_MR_MESSAGE_RECEIVED    0x0D00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define I2O_SCSI_DSC_SCSI_BUS_RESET         0x0E00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define I2O_SCSI_DSC_PARITY_ERROR_FAILURE   0x0F00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define I2O_SCSI_DSC_AUTOSENSE_FAILED       0x1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define I2O_SCSI_DSC_NO_ADAPTER             0x1100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #define I2O_SCSI_DSC_DATA_OVERRUN           0x1200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define I2O_SCSI_DSC_UNEXPECTED_BUS_FREE    0x1300
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define I2O_SCSI_DSC_SEQUENCE_FAILURE       0x1400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define I2O_SCSI_DSC_REQUEST_LENGTH_ERROR   0x1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #define I2O_SCSI_DSC_PROVIDE_FAILURE        0x1600
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #define I2O_SCSI_DSC_BDR_MESSAGE_SENT       0x1700
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define I2O_SCSI_DSC_REQUEST_TERMINATED     0x1800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #define I2O_SCSI_DSC_IDE_MESSAGE_SENT       0x3300
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #define I2O_SCSI_DSC_RESOURCE_UNAVAILABLE   0x3400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define I2O_SCSI_DSC_UNACKNOWLEDGED_EVENT   0x3500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #define I2O_SCSI_DSC_MESSAGE_RECEIVED       0x3600
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) #define I2O_SCSI_DSC_INVALID_CDB            0x3700
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define I2O_SCSI_DSC_LUN_INVALID            0x3800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #define I2O_SCSI_DSC_SCSI_TID_INVALID       0x3900
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define I2O_SCSI_DSC_FUNCTION_UNAVAILABLE   0x3A00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define I2O_SCSI_DSC_NO_NEXUS               0x3B00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #define I2O_SCSI_DSC_SCSI_IID_INVALID       0x3C00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #define I2O_SCSI_DSC_CDB_RECEIVED           0x3D00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define I2O_SCSI_DSC_LUN_ALREADY_ENABLED    0x3E00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) #define I2O_SCSI_DSC_BUS_BUSY               0x3F00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #define I2O_SCSI_DSC_QUEUE_FROZEN           0x4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #ifndef TRUE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #define TRUE                  1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #define FALSE                 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #define HBA_FLAGS_INSTALLED_B       0x00000001	// Adapter Was Installed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #define HBA_FLAGS_BLINKLED_B        0x00000002	// Adapter In Blink LED State
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) #define HBA_FLAGS_IN_RESET	0x00000040	/* in reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #define HBA_HOSTRESET_FAILED	0x00000080	/* adpt_resethost failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) // Device state flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) #define DPTI_DEV_ONLINE    0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #define DPTI_DEV_UNSCANNED 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #define DPTI_DEV_RESET	   0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #define DPTI_DEV_OFFLINE   0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct adpt_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	struct adpt_device* next_lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	u32	flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	u32	type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	u32	capacity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	u32	block_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	u8	scsi_channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	u8	scsi_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	u64	scsi_lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	u8	state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	u16	tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct i2o_device* pI2o_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	struct scsi_device *pScsi_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) struct adpt_channel {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	struct adpt_device* device[MAX_ID];	/* used as an array of 128 scsi ids */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	u8	scsi_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	u8	type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	u16	tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	u32	state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	struct i2o_device* pI2o_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) // HBA state flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define DPTI_STATE_RESET	(0x01)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) typedef struct _adpt_hba {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	struct _adpt_hba *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	struct pci_dev *pDev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	struct Scsi_Host *host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	u32 state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	spinlock_t state_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	int unit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	int host_no;		/* SCSI host number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	u8 initialized;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	u8 in_use;		/* is the management node open*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	char name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	char detail[55];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	void __iomem *base_addr_virt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	void __iomem *msg_addr_virt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	ulong base_addr_phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	void __iomem *post_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	void __iomem *reply_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	void __iomem *irq_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	u16  post_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	u32  post_fifo_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	u32  reply_fifo_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	u32* reply_pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	dma_addr_t reply_pool_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	u32  sg_tablesize;	// Scatter/Gather List Size.       
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	u8  top_scsi_channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	u8  top_scsi_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	u64  top_scsi_lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	u8  dma64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	i2o_status_block* status_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	dma_addr_t status_block_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	i2o_hrt* hrt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	dma_addr_t hrt_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	i2o_lct* lct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	dma_addr_t lct_pa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	uint lct_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	struct i2o_device* devices;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	struct adpt_channel channel[MAX_CHANNEL];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	struct proc_dir_entry* proc_entry;	/* /proc dir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	void __iomem *FwDebugBuffer_P;	// Virtual Address Of FW Debug Buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	u32   FwDebugBufferSize;	// FW Debug Buffer Size In Bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	void __iomem *FwDebugStrLength_P;// Virtual Addr Of FW Debug String Len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	void __iomem *FwDebugFlags_P;	// Virtual Address Of FW Debug Flags 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	void __iomem *FwDebugBLEDflag_P;// Virtual Addr Of FW Debug BLED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	void __iomem *FwDebugBLEDvalue_P;// Virtual Addr Of FW Debug BLED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	u32 FwDebugFlags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	u32 *ioctl_reply_context[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) } adpt_hba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) struct sg_simple_element {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)    u32  flag_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)    u32 addr_bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }; 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)  * Function Prototypes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) static void adpt_i2o_sys_shutdown(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) static int adpt_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static int adpt_i2o_build_sys_table(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static irqreturn_t adpt_isr(int irq, void *dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) static void adpt_i2o_report_hba_unit(adpt_hba* pHba, struct i2o_device *d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid, 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 			int group, int field, void *buf, int buflen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) static const char *adpt_i2o_get_class_name(int class);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid, 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		  void *opblk, dma_addr_t opblk_pa, int oplen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		  void *resblk, dma_addr_t resblk_pa, int reslen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) static int adpt_i2o_lct_get(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) static int adpt_i2o_parse_lct(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) static int adpt_i2o_activate_hba(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) static int adpt_i2o_enable_hba(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) static s32 adpt_i2o_post_this(adpt_hba* pHba, u32* data, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) static s32 adpt_i2o_quiesce_hba(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) static s32 adpt_i2o_status_get(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static s32 adpt_i2o_hrt_get(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) static void adpt_i2o_scsi_complete(void __iomem *reply, struct scsi_cmnd *cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static s32 adpt_scsi_host_alloc(adpt_hba* pHba,struct scsi_host_template * sht);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) static s32 adpt_hba_reset(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) static s32 adpt_i2o_reset_hba(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) static s32 adpt_rescan(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) static s32 adpt_i2o_reparse_lct(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) static s32 adpt_send_nop(adpt_hba*pHba,u32 m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) static void adpt_i2o_delete_hba(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) static void adpt_inquiry(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u64 lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) static int adpt_i2o_online_hba(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) static void adpt_i2o_post_wait_complete(u32, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) static int adpt_i2o_systab_send(adpt_hba* pHba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static int adpt_open(struct inode *inode, struct file *file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) static int adpt_close(struct inode *inode, struct file *file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) #ifdef UARTDELAY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) static void adpt_delay(int millisec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) #define PRINT_BUFFER_SIZE     512
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) #define HBA_FLAGS_DBG_FLAGS_MASK         0xffff0000	// Mask for debug flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #define HBA_FLAGS_DBG_KERNEL_PRINT_B     0x00010000	// Kernel Debugger Print
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) #define HBA_FLAGS_DBG_FW_PRINT_B         0x00020000	// Firmware Debugger Print
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) #define HBA_FLAGS_DBG_FUNCTION_ENTRY_B   0x00040000	// Function Entry Point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) #define HBA_FLAGS_DBG_FUNCTION_EXIT_B    0x00080000	// Function Exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) #define HBA_FLAGS_DBG_ERROR_B            0x00100000	// Error Conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) #define HBA_FLAGS_DBG_INIT_B             0x00200000	// Init Prints
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) #define HBA_FLAGS_DBG_OS_COMMANDS_B      0x00400000	// OS Command Info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) #define HBA_FLAGS_DBG_SCAN_B             0x00800000	// Device Scan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) #define FW_DEBUG_STR_LENGTH_OFFSET 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) #define FW_DEBUG_FLAGS_OFFSET      4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) #define FW_DEBUG_BLED_OFFSET       8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) #define FW_DEBUG_FLAGS_NO_HEADERS_B    0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) #endif				/* !HOSTS_C */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) #endif				/* _DPT_H */