Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/shark - Introduce sequoiaLock() / sequoiaUnlock() f...



details:   https://anonhg.NetBSD.org/src/rev/00dac059db77
branches:  trunk
changeset: 962062:00dac059db77
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Apr 30 02:11:37 2021 +0000

description:
- Introduce sequoiaLock() / sequoiaUnlock() functions that hide away
  the details of what's going on (disable / restore interrupts), and
  use it consistently.
- Give "sequoia" a device_t in the system device tree, matching on
  the Shark's /vlbus/isa node, acting a subclass of ofisa (an "ofisa"
  will be attached to "sequoia").  This allows us to attach other logical
  device nodes to the "sequoia".

diffstat:

 sys/arch/shark/conf/GENERIC     |    8 +-
 sys/arch/shark/conf/files.shark |    6 +-
 sys/arch/shark/shark/hat.c      |   21 ++-
 sys/arch/shark/shark/sequoia.c  |  235 ++++++++++++++++++++++-----------------
 sys/arch/shark/shark/sequoia.h  |   18 +--
 5 files changed, 163 insertions(+), 125 deletions(-)

diffs (truncated from 674 to 300 lines):

diff -r 0b9ded6eafb3 -r 00dac059db77 sys/arch/shark/conf/GENERIC
--- a/sys/arch/shark/conf/GENERIC       Fri Apr 30 01:09:29 2021 +0000
+++ b/sys/arch/shark/conf/GENERIC       Fri Apr 30 02:11:37 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: GENERIC,v 1.138 2021/04/27 23:37:01 thorpej Exp $
+#      $NetBSD: GENERIC,v 1.139 2021/04/30 02:11:37 thorpej Exp $
 #
 # Generic Shark configuration.
 #
@@ -7,7 +7,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "GENERIC-$Revision: 1.138 $"
+#ident         "GENERIC-$Revision: 1.139 $"
 
 # estimated number of users
 maxusers       32
@@ -207,6 +207,10 @@
 
 ofisa*         at ofbus?
 
+# Sequoia core logic chipset
+sequoia*       at ofbus?
+ofisa*         at sequoia?
+
 # IDE/ATA disk
 wdc*           at ofisa?
 atabus*        at wdc? channel ?
diff -r 0b9ded6eafb3 -r 00dac059db77 sys/arch/shark/conf/files.shark
--- a/sys/arch/shark/conf/files.shark   Fri Apr 30 01:09:29 2021 +0000
+++ b/sys/arch/shark/conf/files.shark   Fri Apr 30 02:11:37 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.shark,v 1.22 2021/04/27 23:37:01 thorpej Exp $
+#      $NetBSD: files.shark,v 1.23 2021/04/30 02:11:37 thorpej Exp $
 #
 # First try for arm-specific configuration info
 #
@@ -56,6 +56,10 @@
 file   arch/shark/ofw/lpt_ofisa_machdep.c      lpt_ofisa | atppc_ofisa
 file   arch/shark/ofw/wdc_ofisa_machdep.c      wdc_ofisa
 
+# Sequoia core logic chipset (ofisa attaches to this)
+device sequoia { }: ofisa_subclass
+attach sequoia at ofbus
+
 # Glue for OFW ISA device attachment
 device ofisascr {}
 attach ofisascr at ofisa
diff -r 0b9ded6eafb3 -r 00dac059db77 sys/arch/shark/shark/hat.c
--- a/sys/arch/shark/shark/hat.c        Fri Apr 30 01:09:29 2021 +0000
+++ b/sys/arch/shark/shark/hat.c        Fri Apr 30 02:11:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hat.c,v 1.6 2007/10/17 19:57:10 garbled Exp $  */
+/*     $NetBSD: hat.c,v 1.7 2021/04/30 02:11:37 thorpej Exp $  */
 
 /*
  * Copyright 1997
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hat.c,v 1.6 2007/10/17 19:57:10 garbled Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hat.c,v 1.7 2021/04/30 02:11:37 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -88,11 +88,15 @@
        hatOn = 0;
        hatWedgeFn = NULL;
 
+       sequoiaLock();
+
         /* disable the SWTCH pin */
 
        sequoiaRead(PMC_PMCMCR2_REG, &seqReg);
         sequoiaWrite(PMC_PMCMCR2_REG, seqReg  | (PMCMCR2_M_SWTCHEN));
-        
+
+       sequoiaUnlock();
+
         /* turn off timer 2 */
         outb(ATSR_REG1_REG, 
             inb(ATSR_REG1_REG) & ~((REG1_M_TMR2EN) | (REG1_M_SPKREN)));
@@ -135,6 +139,8 @@
 
        fiq_setregs(&shark_fiqregs);
 
+       sequoiaLock();
+
        /* no debounce on SWTCH */
        sequoiaRead(PMC_DBCR_REG, &seqReg);
        sequoiaWrite(PMC_DBCR_REG, seqReg | DBCR_M_DBDIS0);
@@ -152,6 +158,8 @@
        sequoiaRead(PMC_PMCMCR2_REG, &seqReg);
         sequoiaWrite(PMC_PMCMCR2_REG, seqReg | (PMCMCR2_M_SWTCHEN));
 
+       sequoiaUnlock();
+
        hatOn = 1;
        return 0;
 }
@@ -164,7 +172,9 @@
                return -1;
 
        hatClkCount(count);
+       sequoiaLock();
        hatEnableSWTCH();
+       sequoiaUnlock();
 
        return 0;
 }
@@ -174,6 +184,8 @@
 {
        u_int16_t    seqReg;
 
+       KASSERT(sequoiaIsLocked());
+
        /* SWTCH input causes PMI, not automatic switch to standby mode! */
        /* clearing bit 9 is bad news.  seems to enable PMI from secondary
           activity timeout! */
@@ -195,7 +207,9 @@
                return;
 
        if (lastFiqsHappened == fiqs_happened) {
+               sequoiaLock();
                hatEnableSWTCH();
+               sequoiaUnlock();
                if (hatWedgeFn)
                        (*hatWedgeFn)(fiqs_happened);
        } else {
@@ -216,4 +230,3 @@
 
        restore_interrupts(savedints);
 }
-
diff -r 0b9ded6eafb3 -r 00dac059db77 sys/arch/shark/shark/sequoia.c
--- a/sys/arch/shark/shark/sequoia.c    Fri Apr 30 01:09:29 2021 +0000
+++ b/sys/arch/shark/shark/sequoia.c    Fri Apr 30 02:11:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sequoia.c,v 1.14 2016/10/20 09:53:08 skrll Exp $       */
+/*     $NetBSD: sequoia.c,v 1.15 2021/04/30 02:11:37 thorpej Exp $     */
 
 /*
  * Copyright 1997
@@ -40,27 +40,28 @@
 */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sequoia.c,v 1.14 2016/10/20 09:53:08 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sequoia.c,v 1.15 2021/04/30 02:11:37 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/callout.h>
+#include <sys/device.h>
 #include <sys/syslog.h>
 #include <sys/types.h>
 #include <sys/bus.h>
 #include <sys/time.h>
 #include <sys/kernel.h>
 
-
 #include <dev/isa/isareg.h>
+#include <dev/ofisa/ofisavar.h>
 #include <machine/isa_machdep.h>
 #include <shark/shark/sequoia.h>
 #include <shark/shark/shark_fiq.h>
 #include <arm/cpufunc.h>
 
-
+#include <dev/ofw/openfirm.h>
 
-
+
 
 /*
 ** 
@@ -135,6 +136,9 @@
 
 static callout_t led_timo_ch;
 
+static u_int sequoiaLock_savedints;
+static bool sequoiaLock_held;
+
 /*
 **
 ** FUNCITONAL PROTOTYPES
@@ -152,14 +156,14 @@
 {
     u_int16_t  seqReg;
 
-    callout_init(&led_timo_ch, 0);
-
-    /* map the sequoi registers */
+    /* map the sequoia registers */
     if (bus_space_map(&isa_io_bs_tag, SEQUOIA_BASE, SEQUOIA_NPORTS, 0,  &sequoia_ioh))
     {
         panic("SequoiaInit: io mapping failed");
     }
 
+    sequoiaLock();
+
     /*
     **
     ** setup the pins associated with the X server
@@ -191,13 +195,7 @@
     CLR(seqReg,LED_DEBUG_GREEN_BIT);
     sequoiaWrite(PMC_FOMPCR_REG, seqReg);
 
-    
-    /* setup the biled info */
-    ledColor = LED_BILED_GREEN;
-    ledLastActive.tv_usec = 0;
-    ledLastActive.tv_sec = 0;
-    ledBlockCount = 0;
-    callout_reset(&led_timo_ch, LED_TIMEOUT, ledTimeout, NULL);
+
     /* 
     ** 
     ** setup the pins associated with the smart card reader *
@@ -262,11 +260,38 @@
     sequoiaRead(PMC_SCCR_REG, &seqReg);
     sequoiaWrite(PMC_SCCR_REG, seqReg | SCCR_M_PCSTGDIS);
 
+    sequoiaUnlock();
+
+    /* setup the biled info */
+    ledColor = LED_BILED_GREEN;
+    ledLastActive.tv_usec = 0;
+    ledLastActive.tv_sec = 0;
+    ledBlockCount = 0;
+    callout_init(&led_timo_ch, 0);
+    callout_reset(&led_timo_ch, LED_TIMEOUT, ledTimeout, NULL);
 }
 
-
+void
+sequoiaLock(void)
+{
+    sequoiaLock_savedints = disable_interrupts(I32_bit | F32_bit);
+    KASSERT(!sequoiaLock_held);
+    sequoiaLock_held = true;
+}
 
+void
+sequoiaUnlock(void)
+{
+    KASSERT(sequoiaLock_held);
+    sequoiaLock_held = false;
+    restore_interrupts(sequoiaLock_savedints);
+}
 
+bool
+sequoiaIsLocked(void)
+{
+       return sequoiaLock_held;
+}
 
 /* X console functions */
 void consXTvOn(void)
@@ -278,12 +303,15 @@
     ** but we are currently hardwired to NTSC, so ignore it.
     */
 
+    sequoiaLock();
+
     sequoiaRead (SEQR_SEQPSR3_REG, &savedPSR3);
     sequoiaWrite(SEQR_SEQPSR3_REG, (savedPSR3 | SEQPSR3_M_PC3PINEN));
 
     sequoiaRead (PMC_FOMPCR_REG, &savedFMPCR);
     sequoiaWrite(PMC_FOMPCR_REG, (savedFMPCR | FOMPCR_M_PCON3));
 
+    sequoiaUnlock();
 }
 
 void consXTvOff(void)
@@ -293,12 +321,16 @@
     /* 
     ** Switch off TV output on the Seqoia 
     */
+
+    sequoiaLock();
+
     sequoiaRead (SEQR_SEQPSR3_REG, &savedPSR3);
     sequoiaWrite(SEQR_SEQPSR3_REG, (savedPSR3 & ~SEQPSR3_M_PC3PINEN));
 
     sequoiaRead (PMC_FOMPCR_REG, &savedFMPCR);
     sequoiaWrite(PMC_FOMPCR_REG, (savedFMPCR & ~FOMPCR_M_PCON3));
 
+    sequoiaUnlock();
 }
 
 
@@ -311,7 +343,9 @@
     int r;
     u_int16_t  seqReg;
 
+    sequoiaLock();
     sequoiaRead(PMC_GPIOCR2_REG,&seqReg);



Home | Main Index | Thread Index | Old Index