Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Add support for ISA, EISA and ISApnp cards



details:   https://anonhg.NetBSD.org/src/rev/a29a809326e1
branches:  trunk
changeset: 473519:a29a809326e1
user:      dante <dante%NetBSD.org@localhost>
date:      Sun Jun 06 17:33:18 1999 +0000

description:
Add support for ISA, EISA and ISApnp cards
Fixed a bus reset bug which shows on arm32

diffstat:

 sys/dev/ic/adv.c    |  17 +++++--------
 sys/dev/ic/advlib.c |  63 ++++++++++++++++++++++++++++++++--------------------
 sys/dev/ic/advlib.h |  14 ++++++-----
 3 files changed, 54 insertions(+), 40 deletions(-)

diffs (260 lines):

diff -r 405ff023221c -r a29a809326e1 sys/dev/ic/adv.c
--- a/sys/dev/ic/adv.c  Sun Jun 06 17:31:09 1999 +0000
+++ b/sys/dev/ic/adv.c  Sun Jun 06 17:33:18 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adv.c,v 1.11 1999/03/04 20:16:56 dante Exp $   */
+/*     $NetBSD: adv.c,v 1.12 1999/06/06 17:33:18 dante Exp $   */
 
 /*
  * Generic driver for the Advanced Systems Inc. Narrow SCSI controllers
@@ -111,11 +111,6 @@
 
 
 /******************************************************************************/
-/*                            scsipi_xfer queue routines                      */
-/******************************************************************************/
-
-
-/******************************************************************************/
 /*                             Control Blocks routines                        */
 /******************************************************************************/
 
@@ -437,8 +432,10 @@
 {
        int             warn;
 
-       if (!AscFindSignature(sc->sc_iot, sc->sc_ioh))
-               panic("adv_init: adv_find_signature failed");
+       if (!AscFindSignature(sc->sc_iot, sc->sc_ioh)) {
+               printf("adv_init: failed to find signature\n");
+               return (1);
+       }
 
        /*
          * Read the board configuration
@@ -507,7 +504,7 @@
 
        if (!(sc->overrun_buf = adv_alloc_overrunbuf(sc->sc_dev.dv_xname,
                                                     sc->sc_dmat))) {
-               return (1);
+               panic("adv_init: adv_alloc_overrunbuf failed");
        }
 
        return (0);
@@ -577,7 +574,7 @@
          */
        error = adv_alloc_ccbs(sc);
        if (error)
-               return; /* (error) */ ;
+               return; /* (error) */
 
        /*
          * Create and initialize the Control Blocks.
diff -r 405ff023221c -r a29a809326e1 sys/dev/ic/advlib.c
--- a/sys/dev/ic/advlib.c       Sun Jun 06 17:31:09 1999 +0000
+++ b/sys/dev/ic/advlib.c       Sun Jun 06 17:33:18 1999 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: advlib.c,v 1.8 1999/02/25 20:21:33 dante Exp $        */
+/*      $NetBSD: advlib.c,v 1.9 1999/06/06 17:33:18 dante Exp $        */
 
 /*
  * Low level routines for the Advanced Systems Inc. SCSI controllers chips
@@ -89,6 +89,7 @@
 static void AscInitQLinkVar __P((ASC_SOFTC *));
 static int AscResetChipAndScsiBus __P((bus_space_tag_t, bus_space_handle_t));
 static u_int16_t AscGetChipBusType __P((bus_space_tag_t, bus_space_handle_t));
+static u_int16_t AscGetEisaChipCfg __P((bus_space_tag_t, bus_space_handle_t));
 
 /* Chip register routines */
 static void AscSetBank __P((bus_space_tag_t, bus_space_handle_t, u_int8_t));
@@ -174,13 +175,10 @@
 static void AscToggleIRQAct __P((bus_space_tag_t, bus_space_handle_t));
 static void AscDisableInterrupt __P((bus_space_tag_t, bus_space_handle_t));
 static void AscEnableInterrupt __P((bus_space_tag_t, bus_space_handle_t));
-static u_int8_t AscGetChipIRQ __P((bus_space_tag_t, bus_space_handle_t,
-                                       u_int16_t));
 static u_int8_t AscSetChipIRQ __P((bus_space_tag_t, bus_space_handle_t,
                                        u_int8_t, u_int16_t));
 static void AscAckInterrupt __P((bus_space_tag_t, bus_space_handle_t));
 static u_int32_t AscGetMaxDmaCount __P((u_int16_t));
-static u_int16_t AscGetIsaDmaChannel __P((bus_space_tag_t, bus_space_handle_t));
 static u_int16_t AscSetIsaDmaChannel __P((bus_space_tag_t, bus_space_handle_t,
                                        u_int16_t));
 static u_int8_t AscGetIsaDmaSpeed __P((bus_space_tag_t, bus_space_handle_t));
@@ -350,7 +348,7 @@
  * This function initialize some ASC_SOFTC fields with values read from
  * on-board EEProm.
  */
-u_int16_t
+int16_t
 AscInitFromEEP(sc)
        ASC_SOFTC      *sc;
 {
@@ -368,6 +366,11 @@
        warn_code = 0;
        AscWriteLramWord(iot, ioh, ASCV_HALTCODE_W, 0x00FE);
        AscStopQueueExe(iot, ioh);
+
+       AscStopChip(iot, ioh);
+       AscResetChipAndScsiBus(iot, ioh);
+       DvcSleepMilliSecond(sc->scsi_reset_wait * 1000);
+
        if ((AscStopChip(iot, ioh) == FALSE) ||
            (AscGetChipScsiCtrl(iot, ioh) != 0)) {
                AscResetChipAndScsiBus(iot, ioh);
@@ -742,11 +745,12 @@
        chip_ver = ASC_GET_CHIP_VER_NO(iot, ioh);
        if ((chip_ver >= ASC_CHIP_MIN_VER_VL) &&
            (chip_ver <= ASC_CHIP_MAX_VER_VL)) {
-               /*
-                * if(((iop_base & 0x0C30) == 0x0C30) || ((iop_base & 0x0C50)
-                * == 0x0C50)) return (ASC_IS_EISA);
-                */
-               return (ASC_IS_VL);
+               if(((ioh & 0x0C30) == 0x0C30) || ((ioh & 0x0C50) == 0x0C50)) {
+                       return (ASC_IS_EISA);
+               }
+               else {
+                       return (ASC_IS_VL);
+               }
        }
        if ((chip_ver >= ASC_CHIP_MIN_VER_ISA) &&
            (chip_ver <= ASC_CHIP_MAX_VER_ISA)) {
@@ -762,6 +766,18 @@
 }
 
 
+static u_int16_t
+AscGetEisaChipCfg(iot, ioh)
+       bus_space_tag_t iot;
+       bus_space_handle_t ioh;
+{
+       int     eisa_cfg_iop;
+
+       eisa_cfg_iop = ASC_GET_EISA_SLOT(ioh) | (ASC_EISA_CFG_IOP_MASK);
+       return (inw(eisa_cfg_iop));
+}
+
+
 /******************************************************************************/
 /*                             Chip register routines                         */
 /******************************************************************************/
@@ -841,14 +857,13 @@
        bus_space_handle_t ioh;
        u_int16_t       bus_type;
 {
+       u_int16_t       eisa_iop;
+       u_int8_t        revision;
+               
        if (bus_type & ASC_IS_EISA) {
-               /*
-                * u_int16_t    eisa_iop; u_int8_t      revision;
-                *
-                * eisa_iop = ASC_GET_EISA_SLOT(iop_base) |
-                * ASC_EISA_REV_IOP_MASK; revision = inp(eisa_iop);
-                * return((ASC_CHIP_MIN_VER_EISA - 1) + revision);
-                */
+               eisa_iop = ASC_GET_EISA_SLOT(ioh) | ASC_EISA_REV_IOP_MASK;
+               revision = inb(eisa_iop);
+               return((ASC_CHIP_MIN_VER_EISA - 1) + revision);
        }
        return (ASC_GET_CHIP_VER_NO(iot, ioh));
 }
@@ -2081,7 +2096,7 @@
 }
 
 
-static u_int8_t
+u_int8_t
 AscGetChipIRQ(iot, ioh, bus_type)
        bus_space_tag_t iot;
        bus_space_handle_t ioh;
@@ -2092,11 +2107,11 @@
 
 
        if (bus_type & ASC_IS_EISA) {
-               /*
-                * cfg_lsw = AscGetEisaChipCfg(iot, ioh); chip_irq =
-                * ((cfg_lsw >> 8) & 0x07) + 10; if((chip_irq == 13) ||
-                * (chip_irq > 15)) return (0); return(chip_irq);
-                */
+               cfg_lsw = AscGetEisaChipCfg(iot, ioh);
+               chip_irq = ((cfg_lsw >> 8) & 0x07) + 10;
+               if((chip_irq == 13) || (chip_irq > 15))
+                       return (0);
+               return(chip_irq);
        }
        if ((bus_type & ASC_IS_VL) != 0) {
                cfg_lsw = ASC_GET_CHIP_CFG_LSW(iot, ioh);
@@ -2205,7 +2220,7 @@
 }
 
 
-static u_int16_t
+u_int16_t
 AscGetIsaDmaChannel(iot, ioh)
        bus_space_tag_t iot;
        bus_space_handle_t ioh;
diff -r 405ff023221c -r a29a809326e1 sys/dev/ic/advlib.h
--- a/sys/dev/ic/advlib.h       Sun Jun 06 17:31:09 1999 +0000
+++ b/sys/dev/ic/advlib.h       Sun Jun 06 17:33:18 1999 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: advlib.h,v 1.9 1999/03/04 20:16:56 dante Exp $        */
+/*      $NetBSD: advlib.h,v 1.10 1999/06/06 17:33:18 dante Exp $        */
 
 /*
  * Definitions for low level routines and data structures
@@ -845,11 +845,11 @@
        bus_dmamap_t            sc_dmamap_control; /* maps the control structures */
        void                    *sc_ih;
 
-       struct adv_control      *sc_control; /* control structures */
+       struct adv_control      *sc_control;    /* control structures */
 
        struct adv_ccb          *sc_ccbhash[CCB_HASH_SIZE];
        TAILQ_HEAD(, adv_ccb)   sc_free_ccb, sc_waiting_ccb;
-       struct scsipi_link      sc_link;     /* prototype for devs */
+       struct scsipi_link      sc_link;        /* prototype for devs */
        struct scsipi_adapter   sc_adapter;
 
        TAILQ_HEAD(, scsipi_xfer) sc_queue;
@@ -875,6 +875,7 @@
        ASC_SCSI_BIT_ID_TYPE    cmd_qng_enabled;
        ASC_SCSI_BIT_ID_TYPE    disc_enable;
        ASC_SCSI_BIT_ID_TYPE    sdtr_enable;
+       u_int8_t                irq_no;
        u_int8_t                chip_scsi_id;
        u_int8_t                isa_dma_speed;
        u_int8_t                isa_dma_channel;
@@ -891,7 +892,6 @@
        u_int8_t                scsi_reset_wait;
        u_int8_t                max_total_qng;
        u_int8_t                cur_total_qng;
-       u_int8_t                irq_no;
        u_int8_t                last_q_shortage;
 
        u_int8_t                cur_dvc_qng[ASC_MAX_TID + 1];
@@ -1224,7 +1224,7 @@
 #define ASC_EISA_PID_IOP_MASK  (0x0C80)
 #define ASC_EISA_CFG_IOP_MASK  (0x0C86)
 
-#define ASC_GET_EISA_SLOT(iop) ((iop) & 0xF000)
+#define ASC_GET_EISA_SLOT(port_base)   ((port_base) & 0xF000)
 
 #define ASC_EISA_ID_740        0x01745004UL
 #define ASC_EISA_ID_750        0x01755004UL
@@ -1326,11 +1326,13 @@
 
 
 void AscInitASC_SOFTC __P((ASC_SOFTC *));
-u_int16_t AscInitFromEEP __P((ASC_SOFTC *));
+int16_t AscInitFromEEP __P((ASC_SOFTC *));
 u_int16_t AscInitFromASC_SOFTC __P((ASC_SOFTC *));
 int AscInitDriver __P((ASC_SOFTC *));
 void AscReInitLram __P((ASC_SOFTC *));
 int AscFindSignature __P((bus_space_tag_t, bus_space_handle_t));
+u_int8_t AscGetChipIRQ __P((bus_space_tag_t, bus_space_handle_t, u_int16_t));
+u_int16_t AscGetIsaDmaChannel __P((bus_space_tag_t, bus_space_handle_t));
 int AscISR __P((ASC_SOFTC *));
 int AscExeScsiQueue __P((ASC_SOFTC *, ASC_SCSI_Q *));
 void AscInquiryHandling __P((ASC_SOFTC *, u_int8_t, ASC_SCSI_INQUIRY *));



Home | Main Index | Thread Index | Old Index