/* SPDX-License-Identifier: GPL-2.0 */ /* esp_scsi.h: Defines and structures for the ESP driver. * * Copyright (C) 2007 David S. Miller (davem@davemloft.net)
*/
#ifndef _ESP_SCSI_H #define _ESP_SCSI_H
/* Access Description Offset */ #define ESP_TCLOW 0x00UL /* rw Low bits transfer count 0x00 */ #define ESP_TCMED 0x01UL /* rw Mid bits transfer count 0x04 */ #define ESP_FDATA 0x02UL /* rw FIFO data bits 0x08 */ #define ESP_CMD 0x03UL /* rw SCSI command bits 0x0c */ #define ESP_STATUS 0x04UL /* ro ESP status register 0x10 */ #define ESP_BUSID ESP_STATUS /* wo BusID for sel/resel 0x10 */ #define ESP_INTRPT 0x05UL /* ro Kind of interrupt 0x14 */ #define ESP_TIMEO ESP_INTRPT /* wo Timeout for sel/resel 0x14 */ #define ESP_SSTEP 0x06UL /* ro Sequence step register 0x18 */ #define ESP_STP ESP_SSTEP /* wo Transfer period/sync 0x18 */ #define ESP_FFLAGS 0x07UL /* ro Bits current FIFO info 0x1c */ #define ESP_SOFF ESP_FFLAGS /* wo Sync offset 0x1c */ #define ESP_CFG1 0x08UL /* rw First cfg register 0x20 */ #define ESP_CFACT 0x09UL /* wo Clock conv factor 0x24 */ #define ESP_STATUS2 ESP_CFACT /* ro HME status2 register 0x24 */ #define ESP_CTEST 0x0aUL /* wo Chip test register 0x28 */ #define ESP_CFG2 0x0bUL /* rw Second cfg register 0x2c */ #define ESP_CFG3 0x0cUL /* rw Third cfg register 0x30 */ #define ESP_CFG4 0x0dUL /* rw Fourth cfg register 0x34 */ #define ESP_TCHI 0x0eUL /* rw High bits transf count 0x38 */ #define ESP_UID ESP_TCHI /* ro Unique ID code 0x38 */ #define FAS_RLO ESP_TCHI /* rw HME extended counter 0x38 */ #define ESP_FGRND 0x0fUL /* rw Data base for fifo 0x3c */ #define FAS_RHI ESP_FGRND /* rw HME extended counter 0x3c */
#define SBUS_ESP_REG_SIZE 0x40UL
/* Bitfield meanings for the above registers. */
/* ESP config reg 1, read-write, found on all ESP chips */ #define ESP_CONFIG1_ID 0x07 /* My BUS ID bits */ #define ESP_CONFIG1_CHTEST 0x08 /* Enable ESP chip tests */ #define ESP_CONFIG1_PENABLE 0x10 /* Enable parity checks */ #define ESP_CONFIG1_PARTEST 0x20 /* Parity test mode enabled? */ #define ESP_CONFIG1_SRRDISAB 0x40 /* Disable SCSI reset reports */ #define ESP_CONFIG1_SLCABLE 0x80 /* Enable slow cable mode */
/* ESP command register read-write */ /* Group 1 commands: These may be sent at any point in time to the ESP * chip. None of them can generate interrupts 'cept * the "SCSI bus reset" command if you have not disabled * SCSI reset interrupts in the config1 ESP register.
*/ #define ESP_CMD_NULL 0x00 /* Null command, ie. a nop */ #define ESP_CMD_FLUSH 0x01 /* FIFO Flush */ #define ESP_CMD_RC 0x02 /* Chip reset */ #define ESP_CMD_RS 0x03 /* SCSI bus reset */
/* Group 2 commands: ESP must be an initiator and connected to a target * for these commands to work.
*/ #define ESP_CMD_TI 0x10 /* Transfer Information */ #define ESP_CMD_ICCSEQ 0x11 /* Initiator cmd complete sequence */ #define ESP_CMD_MOK 0x12 /* Message okie-dokie */ #define ESP_CMD_TPAD 0x18 /* Transfer Pad */ #define ESP_CMD_SATN 0x1a /* Set ATN */ #define ESP_CMD_RATN 0x1b /* De-assert ATN */
/* Group 3 commands: ESP must be in the MSGOUT or MSGIN state and be connected * to a target as the initiator for these commands to work.
*/ #define ESP_CMD_SMSG 0x20 /* Send message */ #define ESP_CMD_SSTAT 0x21 /* Send status */ #define ESP_CMD_SDATA 0x22 /* Send data */ #define ESP_CMD_DSEQ 0x23 /* Discontinue Sequence */ #define ESP_CMD_TSEQ 0x24 /* Terminate Sequence */ #define ESP_CMD_TCCSEQ 0x25 /* Target cmd cmplt sequence */ #define ESP_CMD_DCNCT 0x27 /* Disconnect */ #define ESP_CMD_RMSG 0x28 /* Receive Message */ #define ESP_CMD_RCMD 0x29 /* Receive Command */ #define ESP_CMD_RDATA 0x2a /* Receive Data */ #define ESP_CMD_RCSEQ 0x2b /* Receive cmd sequence */
/* Group 4 commands: The ESP must be in the disconnected state and must * not be connected to any targets as initiator for * these commands to work.
*/ #define ESP_CMD_RSEL 0x40 /* Reselect */ #define ESP_CMD_SEL 0x41 /* Select w/o ATN */ #define ESP_CMD_SELA 0x42 /* Select w/ATN */ #define ESP_CMD_SELAS 0x43 /* Select w/ATN & STOP */ #define ESP_CMD_ESEL 0x44 /* Enable selection */ #define ESP_CMD_DSEL 0x45 /* Disable selections */ #define ESP_CMD_SA3 0x46 /* Select w/ATN3 */ #define ESP_CMD_RSEL3 0x47 /* Reselect3 */
/* This bit enables the ESP's DMA on the SBus */ #define ESP_CMD_DMA 0x80 /* Do DMA? */
/* ESP status register read-only */ #define ESP_STAT_PIO 0x01 /* IO phase bit */ #define ESP_STAT_PCD 0x02 /* CD phase bit */ #define ESP_STAT_PMSG 0x04 /* MSG phase bit */ #define ESP_STAT_PMASK 0x07 /* Mask of phase bits */ #define ESP_STAT_TDONE 0x08 /* Transfer Completed */ #define ESP_STAT_TCNT 0x10 /* Transfer Counter Is Zero */ #define ESP_STAT_PERR 0x20 /* Parity error */ #define ESP_STAT_SPAM 0x40 /* Real bad error */ /* This indicates the 'interrupt pending' condition on esp236, it is a reserved * bit on other revs of the ESP.
*/ #define ESP_STAT_INTR 0x80 /* Interrupt */
/* The status register can be masked with ESP_STAT_PMASK and compared * with the following values to determine the current phase the ESP * (at least thinks it) is in. For our purposes we also add our own * software 'done' bit for our phase management engine.
*/ #define ESP_DOP (0) /* Data Out */ #define ESP_DIP (ESP_STAT_PIO) /* Data In */ #define ESP_CMDP (ESP_STAT_PCD) /* Command */ #define ESP_STATP (ESP_STAT_PCD|ESP_STAT_PIO) /* Status */ #define ESP_MOP (ESP_STAT_PMSG|ESP_STAT_PCD) /* Message Out */ #define ESP_MIP (ESP_STAT_PMSG|ESP_STAT_PCD|ESP_STAT_PIO) /* Message In */
/* HME only: status 2 register */ #define ESP_STAT2_SCHBIT 0x01 /* Upper bits 3-7 of sstep enabled */ #define ESP_STAT2_FFLAGS 0x02 /* The fifo flags are now latched */ #define ESP_STAT2_XCNT 0x04 /* The transfer counter is latched */ #define ESP_STAT2_CREGA 0x08 /* The command reg is active now */ #define ESP_STAT2_WIDE 0x10 /* Interface on this adapter is wide */ #define ESP_STAT2_F1BYTE 0x20 /* There is one byte at top of fifo */ #define ESP_STAT2_FMSB 0x40 /* Next byte in fifo is most significant */ #define ESP_STAT2_FEMPTY 0x80 /* FIFO is empty */
/* ESP fifo flags register read-only */ /* Note that the following implies a 16 byte FIFO on the ESP. */ #define ESP_FF_FBYTES 0x1f /* Num bytes in FIFO */ #define ESP_FF_ONOTZERO 0x20 /* offset ctr not zero (esp100) */ #define ESP_FF_SSTEP 0xe0 /* Sequence step */
/* For slow to medium speed input clock rates we shoot for 5mb/s, but for high * input clock rates we try to do 10mb/s although I don't think a transfer can * even run that fast with an ESP even with DMA2 scatter gather pipelining.
*/ #define SYNC_DEFP_SLOW 0x32 /* 5mb/s */ #define SYNC_DEFP_FAST 0x19 /* 10mb/s */
struct esp_cmd_priv { int num_sg; int cur_residue; struct scatterlist *prv_sg; struct scatterlist *cur_sg; int tot_residue;
};
struct esp_lun_data { struct esp_cmd_entry *non_tagged_cmd; int num_tagged; int hold; struct esp_cmd_entry *tagged_cmds[ESP_MAX_TAG];
};
struct esp_target_data { /* These are the ESP_STP, ESP_SOFF, and ESP_CFG3 register values which * match the currently negotiated settings for this target. The SCSI * protocol values are maintained in spi_{offset,period,wide}(starget).
*/
u8 esp_period;
u8 esp_offset;
u8 esp_config3;
/* When ESP_TGT_CHECK_NEGO is set, on the next scsi command to this * device we will try to negotiate the following parameters.
*/
u8 nego_goal_period;
u8 nego_goal_offset;
u8 nego_goal_width;
u8 nego_goal_tags;
struct esp; struct esp_driver_ops { /* Read and write the ESP 8-bit registers. On some * applications of the ESP chip the registers are at 4-byte * instead of 1-byte intervals.
*/ void (*esp_write8)(struct esp *esp, u8 val, unsignedlong reg);
u8 (*esp_read8)(struct esp *esp, unsignedlong reg);
/* Return non-zero if there is an IRQ pending. Usually this * status bit lives in the DMA controller sitting in front of * the ESP. This has to be accurate or else the ESP interrupt * handler will not run.
*/ int (*irq_pending)(struct esp *esp);
/* Return the maximum allowable size of a DMA transfer for a * given buffer.
*/
u32 (*dma_length_limit)(struct esp *esp, u32 dma_addr,
u32 dma_len);
/* Reset the DMA engine entirely. On return, ESP interrupts * should be enabled. Often the interrupt enabling is * controlled in the DMA engine.
*/ void (*reset_dma)(struct esp *esp);
/* Drain any pending DMA in the DMA engine after a transfer. * This is for writes to memory.
*/ void (*dma_drain)(struct esp *esp);
/* Invalidate the DMA engine after a DMA transfer. */ void (*dma_invalidate)(struct esp *esp);
/* Setup an ESP command that will use a DMA transfer. * The 'esp_count' specifies what transfer length should be * programmed into the ESP transfer counter registers, whereas * the 'dma_count' is the length that should be programmed into * the DMA controller. Usually they are the same. If 'write' * is non-zero, this transfer is a write into memory. 'cmd' * holds the ESP command that should be issued by calling * scsi_esp_cmd() at the appropriate time while programming * the DMA hardware.
*/ void (*send_dma_cmd)(struct esp *esp, u32 dma_addr, u32 esp_count,
u32 dma_count, int write, u8 cmd);
/* Return non-zero if the DMA engine is reporting an error * currently.
*/ int (*dma_error)(struct esp *esp);
};
/* The following are used to determine the cause of an IRQ. Upon every * IRQ entry we synchronize these with the hardware registers.
*/
u8 sreg;
u8 seqreg;
u8 sreg2;
u8 ireg;
/* ESP_CMD_SELAS command state */
u8 *cmd_bytes_ptr; int cmd_bytes_left;
struct completion *eh_reset;
void *dma; int dmarev;
/* These are used by esp_send_pio_cmd() */
u8 __iomem *fifo_reg; int send_cmd_error;
u32 send_cmd_residual;
};
/* A front-end driver for the ESP chip should do the following in * it's device probe routine: * 1) Allocate the host and private area using scsi_host_alloc() * with size 'sizeof(struct esp)'. The first argument to * scsi_host_alloc() should be &scsi_esp_template. * 2) Set host->max_id as appropriate. * 3) Set esp->host to the scsi_host itself, and esp->dev * to the device object pointer. * 4) Hook up esp->ops to the front-end implementation. * 5) If the ESP chip supports wide transfers, set ESP_FLAG_WIDE_CAPABLE * in esp->flags. * 6) Map the DMA and ESP chip registers. * 7) DMA map the ESP command block, store the DMA address * in esp->command_block_dma. * 8) Register the scsi_esp_intr() interrupt handler. * 9) Probe for and provide the following chip properties: * esp->scsi_id (assign to esp->host->this_id too) * esp->scsi_id_mask * If ESP bus is differential, set ESP_FLAG_DIFFERENTIAL * esp->cfreq * DMA burst bit mask in esp->bursts, if necessary * 10) Perform any actions necessary before the ESP device can * be programmed for the first time. On some configs, for * example, the DMA engine has to be reset before ESP can * be programmed. * 11) If necessary, call dev_set_drvdata() as needed. * 12) Call scsi_esp_register() with prepared 'esp' structure. * 13) Check scsi_esp_register() return value, release all resources * if an error was returned.
*/ externconststruct scsi_host_template scsi_esp_template; externint scsi_esp_register(struct esp *);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.