Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc/sparc Add enable/disable and power management...
details: https://anonhg.NetBSD.org/src/rev/aa5ec7c8a842
branches: trunk
changeset: 483638:aa5ec7c8a842
user: jdc <jdc%NetBSD.org@localhost>
date: Tue Mar 14 21:18:27 2000 +0000
description:
Add enable/disable and power management hooks for serial ports.
Port states : always on / on when open (default) / always off
diffstat:
sys/arch/sparc/sparc/auxiotwo.c | 92 ++++++++++++++++++++++++++++++++++------
sys/arch/sparc/sparc/auxiotwo.h | 16 +++++-
2 files changed, 91 insertions(+), 17 deletions(-)
diffs (158 lines):
diff -r 2660f74a4569 -r aa5ec7c8a842 sys/arch/sparc/sparc/auxiotwo.c
--- a/sys/arch/sparc/sparc/auxiotwo.c Tue Mar 14 20:17:46 2000 +0000
+++ b/sys/arch/sparc/sparc/auxiotwo.c Tue Mar 14 21:18:27 2000 +0000
@@ -1,7 +1,7 @@
-/* $NetBSD: auxiotwo.c,v 1.1 2000/02/25 18:17:24 jdc Exp $ */
+/* $NetBSD: auxiotwo.c,v 1.2 2000/03/14 21:18:27 jdc Exp $ */
/*
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -48,8 +48,12 @@
#include <machine/autoconf.h>
+#include <sparc/include/tctrl.h>
+#include <sparc/sparc/auxiotwo.h>
#include <sparc/sparc/vaddrs.h>
-#include <sparc/sparc/auxiotwo.h>
+
+static int serial_refcount;
+static int serial_power;
static int auxiotwomatch __P((struct device *, struct cfdata *, void *));
@@ -97,18 +101,9 @@
auxiotwo_reg = (volatile u_char *)bh;
auxiotwo_regval = *auxiotwo_reg;
+ serial_refcount = 0;
+ serial_power = PORT_PWR_STANDBY;
printf("\n");
-
- /*
- * This powers on the serial ports
- * XXX: this should probably be in the serial attach code.
- */
- auxiotwobisc(AUXIOTWO_SON, 0);
-
- /*
- * This powers them off :
- * auxiotwobisc(AUXIOTWO_SOF, 1);
- */
}
unsigned int
@@ -130,3 +125,72 @@
splx(s);
return (auxiotwo_regval);
}
+
+/*
+ * Serial port state - called from zs_enable()/zs_disable()
+ */
+void
+auxiotwoserialendis (state)
+ int state;
+{
+ switch (state) {
+
+ case ZS_ENABLE:
+ /* Power on the serial ports? */
+ serial_refcount++;
+ if (serial_refcount == 1 && serial_power == PORT_PWR_STANDBY)
+ auxiotwobisc(AUXIOTWO_SON, 0);
+ break;
+ case ZS_DISABLE:
+ /* Power off the serial ports? */
+ serial_refcount--;
+ if (!serial_refcount && serial_power == PORT_PWR_STANDBY)
+ auxiotwobisc(AUXIOTWO_SOF, 1);
+ break;
+ }
+}
+
+/*
+ * Set power management - called by tctrl
+ */
+void
+auxiotwoserialsetapm (state)
+ int state;
+{
+ switch (state) {
+
+ case PORT_PWR_ON:
+ /* Change to: power always on */
+ if (serial_power == PORT_PWR_OFF ||
+ (serial_power == PORT_PWR_STANDBY && !serial_refcount))
+ auxiotwobisc(AUXIOTWO_SON, 0);
+ serial_power = PORT_PWR_ON;
+ break;
+
+ case PORT_PWR_STANDBY:
+ /* Change to: power on if open */
+ if (serial_power == PORT_PWR_ON && !serial_refcount)
+ auxiotwobisc(AUXIOTWO_SOF, 1);
+ if (serial_power == PORT_PWR_OFF && serial_refcount)
+ auxiotwobisc(AUXIOTWO_SON, 0);
+ serial_power = PORT_PWR_STANDBY;
+ break;
+
+ case PORT_PWR_OFF:
+ /* Change to: power always off */
+ if (serial_power == PORT_PWR_ON ||
+ (serial_power == PORT_PWR_STANDBY && serial_refcount))
+ auxiotwobisc(AUXIOTWO_SOF, 1);
+ serial_power = PORT_PWR_OFF;
+ break;
+ }
+}
+
+/*
+ * Get power management - called by tctrl
+ */
+int
+auxiotwoserialgetapm ()
+{
+ return (serial_power);
+}
diff -r 2660f74a4569 -r aa5ec7c8a842 sys/arch/sparc/sparc/auxiotwo.h
--- a/sys/arch/sparc/sparc/auxiotwo.h Tue Mar 14 20:17:46 2000 +0000
+++ b/sys/arch/sparc/sparc/auxiotwo.h Tue Mar 14 21:18:27 2000 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: auxiotwo.h,v 1.1 2000/02/25 18:17:24 jdc Exp $ */
+/* $NetBSD: auxiotwo.h,v 1.2 2000/03/14 21:18:27 jdc Exp $ */
/*
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
- * by Julian Coleman, Waldi Ravens and Leo Weppelman.
+ * by Julian Coleman.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -54,8 +54,18 @@
#define AUXIOTWO_CPF 0x02 /* Clear Power Fail Detect */
#define AUXIOTWO_SON 0x01 /* Serial ports on (when cleared) */
+/*
+ * Serial port open/close
+ */
+
+#define ZS_ENABLE 0
+#define ZS_DISABLE 1
+
#ifndef _LOCORE
volatile u_char *auxiotwo_reg;
u_char auxiotwo_regval;
unsigned int auxiotwobisc __P((int, int));
+void auxiotwoserialendis __P((int));
+void auxiotwoserialsetapm __P((int));
+int auxiotwoserialgetapm __P((void));
#endif
Home |
Main Index |
Thread Index |
Old Index