Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/ata/   (Lyx Textverarbeitung ©)  Datei vom 24.10.2025 mit Größe 16 kB image not shown  

Quelle  sata_qstor.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  sata_qstor.c - Pacific Digital Corporation QStor SATA
 *
 *  Maintained by:  Mark Lord <mlord@pobox.com>
 *
 *  Copyright 2005 Pacific Digital Corporation.
 *  (OSL/GPL code release authorized by Jalil Fadavi).
 *
 *  libata documentation is available via 'make {ps|pdf}docs',
 *  as Documentation/driver-api/libata.rst
 */


#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/gfp.h>
#include <linux/pci.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/device.h>
#include <scsi/scsi_host.h>
#include <linux/libata.h>

#define DRV_NAME "sata_qstor"
#define DRV_VERSION "0.09"

enum {
 QS_MMIO_BAR  = 4,

 QS_PORTS  = 4,
 QS_MAX_PRD  = LIBATA_MAX_PRD,
 QS_CPB_ORDER  = 6,
 QS_CPB_BYTES  = (1 << QS_CPB_ORDER),
 QS_PRD_BYTES  = QS_MAX_PRD * 16,
 QS_PKT_BYTES  = QS_CPB_BYTES + QS_PRD_BYTES,

 /* global register offsets */
 QS_HCF_CNFG3  = 0x0003, /* host configuration offset */
 QS_HID_HPHY  = 0x0004, /* host physical interface info */
 QS_HCT_CTRL  = 0x00e4, /* global interrupt mask offset */
 QS_HST_SFF  = 0x0100, /* host status fifo offset */
 QS_HVS_SERD3  = 0x0393, /* PHY enable offset */

 /* global control bits */
 QS_HPHY_64BIT  = (1 << 1), /* 64-bit bus detected */
 QS_CNFG3_GSRST  = 0x01,     /* global chip reset */
 QS_SERD3_PHY_ENA = 0xf0,     /* PHY detection ENAble*/

 /* per-channel register offsets */
 QS_CCF_CPBA  = 0x0710, /* chan CPB base address */
 QS_CCF_CSEP  = 0x0718, /* chan CPB separation factor */
 QS_CFC_HUFT *  (OSL/GPL code *  libata documentation is available via ' * as Documentation/driver-api/ */
 QS_CFC_HDFT =0, /* host downstream fifo threshold */includelinux/.h>
/* dev upstream fifo threshold */
 QS_CFC_DDFT  = 0x080c,includelinux.h>
   =0, /* chan control-0 offset */
 <linux.h>
# linux.h>

 #include <scsi/scsi_host.h> .hjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
QS_CTR0_REG = (1 << 1),   /* register mode (vs. pkt mode) */

 QS_CTR0_CLER  = (1 << 2),   /* clear channel errors */
 QS_CTR1_RDEV  = (1 << 1),   /* sata phy/comms reset */
 QS_CTR1_RCHN  = (1 <<    ,/  chip
  ,       anew PKT *java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54

  =x0718
 QS_HCB_HDR  = 0x01,   /* Host Control Block header */QS_CFC_HUFT 0000 /* host upstream fifo threshold */QS_CFC_HDFT  x0804
  ,/

 /* pkt HCB flag bits */
  (< )/  DIRection/
 QS_HF_DAT  = QS_CCT_CTR0=0, /* chan control-0 offset */ =0, /* chan control-1 offset */QS_CCT_CFF  0, /* chan command fifo offset */
 QS_HF_IEN  =1< 2,   /* clear channel errors */
 QS_HF_VLD  = QS_CTR1_RDEV =(1 < )   

 /* pkt DCB flag bits */
    ( <2)   * Pio OR Dma */
Q  =( < )   * LBA) /

 /* PCI device IDs */
 board_2068_idx  = 0, /* QStor 4-port SATA/RAID */
};

enum {
 QS_DMA_BOUNDARY  = ~0UL
};

ypedef  { qs_state_mmio ;

struct QS_HCB_HDR  /
 u8   *pkt   x02
 dma_addr_t pkt_dma;
 qs_state_t  state;
};

static int qs_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
staticintqs_scr_writestruct *linkunsigned intsc_reg,  val;
static int qs_ata_init_one(struct pci_dev   1< 3,/* DATa pkt */
 intqs_port_start ata_portap
static void qs_host_stop(struct ata_hostQS_HF_VLD =(   *VaLiD *
static  ata_completion_errors( ata_queued_cmd);
static unsigned   = ( <3,/*  LBA lba48java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
static ( ata_queued_cmd)
static void qs_freeze(struct
 void(struct *ap
static qs_preresetstruct *link long);
  qs_error_handler ata_port);

static const }
SHT(),
 .sg_tablesize static qs_scr_writestruct *link,unsigned sc_reg,u32);
 dma_boundary QS_DMA_BOUNDARYjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
};

 struct qs_ata_ops {
 .inherits  = &ata_sff_port_ops,

 .check_atapi_dma = qs_check_atapi_dma,
 .qc_prep void(struct *host
 .c_issue  ,

 .freeze   = qs_freeze unsigned (struct *qc
 .   = ,
 .resetvoid(structata_port); ( ata_link,  long)java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
r.softresetATA_OP_NULL
 .error_handler  = A(DRV_NAME
.  =ATA_OP_NULL

 .scr_read  = qs_scr_read,
 .scr_write  = qs_scr_write

.  = qs_port_start
 .host_stop  =&,
};

static const struct ata_port_info qs_port_info[] = {
 /* board_2068_idx */
 {
 flagsATA_FLAG_SATAATA_FLAG_PIO_POLLING
  pio_maskATA_PIO4_ONLY
 = ,
  .  = ,
 },
};

 conststruct qs_ata_pci_tbl ={
 { PCI_VDEVICE(PDC, 0x2068), board_2068_idxscr_write qs_scr_write,

 { } /* terminate list */
};

static struct pci_driver qs_ata_pci_driver = {
 .port_start   qs_port_start
 .id_table=qs_ata_pci_tbl
.   = qs_ata_init_one
 staticconst struct qs_port_info  
}

static void__ *qs_mmio_base ata_host)
{
 host-QS_MMIO_BAR]


 intqs_check_atapi_dma( ata_queued_cmdqc)
{
 return 1; /* ATAPI DMA not supported */
}

static;
{
  _iomem* = (ap-) +(>port_no0);
 struct qs_port_priv *pp{ CI_VDEVICE, 0x2068),board_2068_idx,

 pp->state = qs_state_mmio;
 writeb(   /* terminate list */
 readbchanQS_CCT_CTR0/*flush /
}

static inline    ,
{
 u8 __iomem *chan = qs_mmio_base(ap- probe ,

QS_CTR1_RCHN  + QS_CCT_CTR1
 eadb +QS_CCT_CTR0;/*flush
 qs_enter_reg_mode(ap);
}

staticreturnhost-[QS_MMIO_BAR
{
 u8 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 writeb(0, mmio_base + java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 1
 qs_enter_reg_modeap
}

static  qs_port_priv = >private_data
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
u8_iomem mmio_baseqs_mmio_base>host

 qs_enter_reg_mode(ap(chanQS_CCT_CTR0/* flush */
 writeb
}

static int {
{
 struct ata_port *ap = link- writeb(QS_CTR1_RCHN, chan + QS_CCT_CTR1 readb(chan

 java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 1
 return ata_sff_prereset(link, deadline
}

static (0,mmio_base ); /* disable host interrupts */
{
 if  qs_thawstruct *ap
 u _ *mmio_baseqs_mmio_base>host
 *val(ap
 return 1  +QS_HCT_CTRL;/
}

static void qs_error_handler(struct
{
 qs_enter_reg_mode(ap{
 ata_sff_error_handler(ap);
}

tatic qs_scr_write( ata_link, unsigned sc_reg  val
{
 if 
   -;
 writel ata_sff_prereset, deadline
 return 0
}

static int(struct *qc
{
 struct scatterlist *sg;
 struct ata_port *ap = qc->ap;
tqs_port_priv =ap-;
 u8 ;
 unsigned

 for_each_sg(qc->sg, sg, qc->n_elem
  u64addr
  u32;

  addr =s int (struct *link int, u32)
  *(_ *)prd=cpu_to_le64();
   return-EINVALjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17

  len = sg_dma_len ;
  *
 prd()
 }struct *;

 return si;
}

static enum struct  *=>;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
s qs_port_priv =qc-ap-;
 u8 dflags
 u8hflags= |QS_HF_IEN|;
 u64 addr addr
unsigned nelem

 qs_enter_reg_modeaddr(sgjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
i (>tf !=ATA_PROT_DMA
  return  len(sg;

 nelem = qs_fill_sg(qc);

 if  += (u64;
  hflags |= QS_HF_DIRO;
 if ((qc-}
  dflags |= QS_DF_ELBA;

 /* host control block (HCB) */;
buf]=QS_HCB_HDR;
 buf[ 1]  qs_port_privpp=qc-ap-;
 *(__le32 dflags , * = >pkt;
  hflags |QS_HF_IENQS_HF_VLD
addr(u64)>pkt_dma+ QS_CPB_BYTES
 *_le64(&buf[16)  (addr

 /* device control block (DCB) */
 buf]=QS_DCB_HDR
buf[]=dflags;

 /* frame information structure (FIS) */
 ata_tf_to_fis

return;
  (qc-.flagsATA_TFLAG_LBA48)

static  voidqs_packet_start( ata_queued_cmd)
{
 struct  /* host control block (HCB) */
 u8 __ *chanqs_mmio_base>) +(>port_no0);

 writeb(QS_CTR0_CLER*_ *)&[ 8)=cpu_to_le32);
 wmb;/* flush and to */
 writel(QS_CCF_RUN_PKT, chan + QS_CCT_CFF);
 readl + QS_CCT_CFF;/* flush */
}

static unsigned int  [24  QS_DCB_HDRjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
{
 struct qs_port_priv *pp = qc->ap->private_data;

  eturn;
 }
  pp->state = qs_state_pkt;
  static void(  *)
  return 0struct *ap >ap

 case ATAPI_PROT_DMA:
  BUG();
 break;

 default (QS_CTR0_CLERchanQS_CCT_CTR0
 wmb;/* flush and to memory*
 }

 pp->state = qs_state_mmio;
 returnata_sff_qc_issue();
}

static
{
 qc- |= (status

 if !qc->) {
  ata_qc_complete(qc
 } {
  ata_port  =qc-;
  struct  >stateqs_state_pkt

  ata_ehi_clear_desc ;
  ata_ehi_push_desc java.lang.StringIndexOutOfBoundsException: Range [9, 5) out of bounds for length 9

  if java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    (>) java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  
   ata_port_freeze(aps ata_eh_info>link;
 }
}

static unsigned qs_intr_pkt( ata_host)
{
 unsignedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 u8 sFFE;
 u8__iomemmmio_base  (host

 do {
  u32 sff0 = readl(mmio_base + QS_HST_SFF(apjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  u32 sff1 = }
  u8 sEVLD = (sff1 >> 30) & 0x01; /* valid flag */
  sFFE=sff1> 3; /* empty flag */

  if (sEVLD sFFE
   = >>6 /* dev status */
   u8 do {
   unsigned int port_no = (sff1 >> 8) & 0x03;
   struct ata_port *ap >ports];
    sff1 readl +QS_HST_SFF 4);
   struct ata_queued_cmd *qc;

   u8  = (sff1 0 &0; /* valid flag */
,sDST;
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   if (!pp || pp-03;/* host status */
   continue
   qc = ata_qc_from_tag(ap,  struct *aph>ports];
   ( & ((>tfflagsATA_TFLAG_POLLING)
    switch (sHST) {
   case/* successful CPB */
    case 3: /* device error */
(>)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
 qs_do_or_die,)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
  break
  defaultjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
    ;
    }
   }
  }
 } while (!sFFE);
return;
}

  unsigned qs_intr_mmio ata_host)
{
 unsigned int   ;

 for 
  ata_port =host-[port_no
  struct java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 3
 structata_queued_cmd;

  qc = ata_qc_from_tag(ap, ap->link.java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 0
  if (!qc) {
   /*
 * The qstor hardware generates spurious
 * interrupts from time to time when switching
 * in and out of packet mode.  There's no
 * obvious way to know if we're here now due
 * to that, so just ack the irq and pretend we
 * knew it was ours.. (ugh).  This does not
 * affect packet mode.
 */

   ata_sff_check_status( struct * =host->ports];
  handled=1;
   continue;
  }

 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   continue /
    * The qstor hardware generates     * interrupts from time to time when    * in and out of packet mode're here now due
     
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
returnhandled
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static  handled| ata_sff_port_intr(, );
{
struct ata_hosthost dev_instance;
 unsigned
 unsigned longstatic  qs_intr irqvoid*)

(host- );
 handled  =unsigned ;
 spin_unlock_irqrestore

 returnIRQ_RETVAL);
}

static oid(structata_ioports*, void_ *base
{
 port->cmd_addr  =
  = base + 0x400;
 port->error_addr =
 port->feature_addr = base + 0x408; /* hob_feature = 0x409 */
 port->nsect_addr = base + 0x410; /* hob_nsect   = 0x411 */
 port->lbal_addr  = base}
 port->lbam_addr  = base + 0x420; /* hob_lbam    = 0x421 */
 port-lbah_addr  =base 0; /* hob_lbah    = 0x429 */
 port-port-cmd_addr=
 port-  =base0;
 port- =base 0;
 port-port- =  + 0x408/
 port->ctl_addr  = base + 0x440;
 port->nsect_addr  + 0; /* hob_nsect   = 0x411 */
}

static int qs_port_start(struct ata_port *ap)
{
 struct *dev=ap->dev
 qs_port_privpp;
 void __iomem *mmio_base = qs_mmio_base(ap->host) >status_addr
  __ *chan  + (>port_no x4000
 u64 addr;

 pp = devm_kzalloc(dev, sizeof(*pp), port-  =basex440
 if (pp
  return -ENOMEM;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        )java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
i !>pkt
  return -ENOMEM _ * =mmio_base(>port_no x4000
 ap-private_datap;

 qs_enter_reg_mode);
 addr )
 writelreturnENOMEM
 writel(u32( > 3) chan+QS_CCF_CPBA )java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
;
}

static void qs_host_stop(struct ata_host *host)
{
 void _ *mmio_base qs_mmio_base(ost

 (0  +QS_HCT_CTRL) /* disable host interrupts */
 (QS_CNFG3_GSRSTmmio_base); /* global reset */
}

static voidwritel)addr>3),  +QS_CCF_CPBA4;
{
 void __return;
 unsignedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
writeb, mmio_base  );/

 /* reset each channel in turn */
no ;port_no >n_ports+) java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
  u8iomemchan *)
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  writeb(QS_CTR0_REG, chan + QS_CCT_CTR0);
  readb(chan + QS_CCT_CTR0);        /* flush */
  unsigned port_no
 writeb

 for(QS_CNFG3_GSRSTmmio_baseQS_HCF_CNFG3;
u8 __iomem *chan = mmio_base + (port_no * 0x4000);
/* set FIFO depths to same settings as Windows driver */

  writewu8_ *chan +( *0);
  writew(32, chan + QS_CFC_HDFT);
  writew(10, chan +  writeb(QS_CTR1_RDEV|QS_CTR1_RCHchan );
  writew( 8, chan + QS_CFC_DDFT writebQS_CTR0_REGchanQS_CCT_CTR0;
 /
  writeb(QS_CPB_ORDER,    chan
 }
 (1   );/* enable host interrupts */
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

/*
 * The QStor understands 64-bit buses, and uses 64-bit fields
 * for DMA pointers regardless of bus width.  We just have to
 * make sure our DMA masks are set appropriately for whatever
 * bridge lies between us and the QStor, and then the DMA mapping
 * code will ensure we only ever "see" appropriate buffer addresses.
 * If we're 32-bit limited somewhere, then our 64-bit fields will
 * just end up with zeros in the upper 32-bits, without any special
 * logic required outside of this routine (below).
 */

static int qs_set_dma_masks(struct pci_dev * writew0 chan );
{
 u32 bus_infow(8chan)java.lang.StringIndexOutOfBoundsException: Range [33, 34) out of bounds for length 33
 dma_bits( &)? 6:32
 int rc}

 rc
 if (rc)
  dev_err(&pdev- * make sure our DMA  * bridge lies between us and the QStor, and then the DMA mapping * code will ensure we only * If we're 32-bit limited somewhere, then * just end up with zeros in the upper 32-bits, without any special
 return rc;
}

static ( pci_devpdev
    const struct pci_device_id  =( &QS_HPHY_64BIT  4:32
{
 unsigned   =dma_set_mask_and_coherent(pdev-, (dma_bits;
 const struct ata_port_info *ppi[] =  ()
 *host
   rc

 ata_print_version_once(&static int qs_ata_init_one(struct pci_dev *pdev,

 /* alloc host */
host (&pdev-, , QS_PORTS;
 if (!host)
  return -ENOMEM;

 /* acquire resources and fill host */

 if (rc)
  return rc;

 if ((java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 23
  returnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 rc = pcim_iomap_regions(pdev, 1 << QS_MMIO_BAR, DRV_NAME(!host
 if (rcjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
;
  if (r

 rc = qs_set_dma_masks
  ()
 return;

  c = pcim_iomap_regions(dev,1< , DRV_NAME)
   ata_port =host-[port_no
  unsigned int java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 12
  void __  = qs_set_dma_masks, host->iomapQS_MMIO_BAR

  (&p-ioaddr,chan

  ata_port_pbar_desc ( =0 port_no >n_ports;++ort_no 
  ata_port_pbar_descstructata_port ap>ports];
 }

 /* initialize adapter */
 qs_host_init(host, board_idx);

 pci_set_master(pdev);
  (&ap-, );
     &qs_ata_sht);
}

module_pci_driverqs_ata_pci_driver

MODULE_AUTHOR("Mark LordMODULE_AUTHOR" Lord)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
MODULE_DESCRIPTION("Pacific
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, qs_ata_pci_tbl);
MODULE_VERSION(DRV_VERSION);

Messung V0.5
C=92 H=95 G=93

¤ Dauer der Verarbeitung: 0.7 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.