Source-Changes-HG archive

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

[src/trunk]: src/sys Add power management hooks.



details:   https://anonhg.NetBSD.org/src/rev/1aee2129e8ea
branches:  trunk
changeset: 483639:1aee2129e8ea
user:      jdc <jdc%NetBSD.org@localhost>
date:      Tue Mar 14 21:20:51 2000 +0000

description:
Add power management hooks.

diffstat:

 sys/arch/sparc/dev/zs.c |  43 ++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/ic/z8530sc.h    |   8 +++++++-
 sys/dev/ic/z8530tty.c   |  27 +++++++++++++++++++++++++--
 3 files changed, 74 insertions(+), 4 deletions(-)

diffs (159 lines):

diff -r aa5ec7c8a842 -r 1aee2129e8ea sys/arch/sparc/dev/zs.c
--- a/sys/arch/sparc/dev/zs.c   Tue Mar 14 21:18:27 2000 +0000
+++ b/sys/arch/sparc/dev/zs.c   Tue Mar 14 21:20:51 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zs.c,v 1.74 2000/03/06 21:36:11 thorpej Exp $  */
+/*     $NetBSD: zs.c,v 1.75 2000/03/14 21:20:51 jdc Exp $      */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -71,6 +71,7 @@
 
 #include <sparc/sparc/vaddrs.h>
 #include <sparc/sparc/auxreg.h>
+#include <sparc/sparc/auxiotwo.h>
 #include <sparc/dev/cons.h>
 
 #include "kbd.h"       /* NKBD */
@@ -186,6 +187,10 @@
 
 static int zs_get_speed __P((struct zs_chanstate *));
 
+/* Power management hooks */
+int  zs_enable __P((struct zs_chanstate *));
+void zs_disable __P((struct zs_chanstate *));
+
 
 /*
  * Is the zs chip present?
@@ -258,6 +263,8 @@
        if (uoba->uoba_isobio4 == 0) {
                struct sbus_attach_args *sa = &uoba->uoba_sbus;
                void *va;
+               struct zs_chanstate *cs;
+               int channel;
 
                if (sa->sa_nintr == 0) {
                        printf(" no interrupt lines\n");
@@ -284,6 +291,19 @@
                        va = (void *)bh;
                }
 
+               /*
+                * Check if power state can be set, e.g. Tadpole 3GX
+                */
+               if (getpropint(sa->sa_node, "pwr-on-auxio2", 0))
+               {
+                       printf (" powered via auxio2");
+                       for (channel = 0; channel < 2; channel++) {
+                               cs = &zsc->zsc_cs_store[channel];
+                               cs->enable = zs_enable;
+                               cs->disable = zs_disable;
+                       }
+               }
+
                zsc->zsc_bustag = sa->sa_bustag;
                zsc->zsc_dmatag = sa->sa_dmatag;
                zs_attach(zsc, va, sa->sa_pri);
@@ -1074,3 +1094,24 @@
        zs_kgdb_init();
 #endif
 }
+
+/*
+ * Power management hooks for zsopen() and zsclose().
+ * We use them to power on/off the ports, if necessary.
+ */
+int
+zs_enable(cs)
+       struct zs_chanstate *cs;
+{
+       auxiotwoserialendis (ZS_ENABLE);
+       cs->enabled = 1;
+       return(0);
+}
+
+void
+zs_disable(cs)
+       struct zs_chanstate *cs;
+{
+       auxiotwoserialendis (ZS_DISABLE);
+       cs->enabled = 0;
+}
diff -r aa5ec7c8a842 -r 1aee2129e8ea sys/dev/ic/z8530sc.h
--- a/sys/dev/ic/z8530sc.h      Tue Mar 14 21:18:27 2000 +0000
+++ b/sys/dev/ic/z8530sc.h      Tue Mar 14 21:20:51 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: z8530sc.h,v 1.12 1999/03/27 01:22:36 wrstuden Exp $    */
+/*     $NetBSD: z8530sc.h,v 1.13 2000/03/14 21:20:52 jdc Exp $ */
 
 /*
  * Copyright (c) 1994 Gordon W. Ross
@@ -113,6 +113,12 @@
 
        char    cs_softreq;             /* need soft interrupt call */
        char    cs_spare1;      /* (for skippy :) */
+
+       /* power management hooks */
+       int     (*enable) __P((struct zs_chanstate *));
+       void    (*disable) __P((struct zs_chanstate *));
+       int     enabled;
+
        /* MD code might define a larger variant of this. */
 };
 
diff -r aa5ec7c8a842 -r 1aee2129e8ea sys/dev/ic/z8530tty.c
--- a/sys/dev/ic/z8530tty.c     Tue Mar 14 21:18:27 2000 +0000
+++ b/sys/dev/ic/z8530tty.c     Tue Mar 14 21:20:51 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: z8530tty.c,v 1.62 1999/11/04 05:33:59 jonathan Exp $   */
+/*     $NetBSD: z8530tty.c,v 1.63 2000/03/14 21:20:52 jdc Exp $        */
 
 /*-
  * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999
@@ -325,7 +325,10 @@
        zst->zst_rbget = zst->zst_rbput = zst->zst_rbuf;
        zst->zst_rbavail = zstty_rbuf_size;
 
-       /* XXX - Do we need an MD hook here? */
+       /* if there are no enable/disable functions, assume the device
+          is always enabled */
+       if (!cs->enable)
+               cs->enabled = 1;
 
        /*
         * Hardware init
@@ -435,6 +438,15 @@
                zs_write_reg(cs, 1, cs->cs_creg[1]);
        }
 
+       /* Call the power management hook. */
+       if (cs->disable) {
+#ifdef DIAGNOSTIC
+               if (!cs->enabled)
+                       panic("zs_shutdown: not enabled?");
+#endif
+               (*cs->disable)(zst->zst_cs);
+       }
+
        splx(s);
 }
 
@@ -482,6 +494,17 @@
 
                tp->t_dev = dev;
 
+               /* Call the power management hook. */
+               if (cs->enable) {
+                       if ((*cs->enable)(cs)) {
+                               splx(s2);
+                               splx(s);
+                               printf("%s: device enable failed\n",
+                               zst->zst_dev.dv_xname);
+                               return (EIO);
+                       }
+               }
+
                /*
                 * Initialize the termios status to the defaults.  Add in the
                 * sticky bits from TIOCSFLAGS.



Home | Main Index | Thread Index | Old Index