summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/arm/arm/arm32_machdep.c158
-rw-r--r--sys/arch/arm/include/cpu.h10
-rw-r--r--sys/arch/zaurus/dev/zaurus_kbd.c12
3 files changed, 33 insertions, 147 deletions
diff --git a/sys/arch/arm/arm/arm32_machdep.c b/sys/arch/arm/arm/arm32_machdep.c
index a8ea8ba2fd3..a7069903e59 100644
--- a/sys/arch/arm/arm/arm32_machdep.c
+++ b/sys/arch/arm/arm/arm32_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arm32_machdep.c,v 1.16 2005/12/20 19:23:57 drahn Exp $ */
+/* $OpenBSD: arm32_machdep.c,v 1.17 2005/12/21 20:36:00 deraadt Exp $ */
/* $NetBSD: arm32_machdep.c,v 1.42 2003/12/30 12:33:15 pk Exp $ */
/*
@@ -129,6 +129,7 @@ int allowaperture = 0;
#if defined(__zaurus__)
/* Permit console keyboard to do a nice halt. */
int kbd_reset;
+int lid_suspend;
/* Touch pad scaling disable flag and scaling parameters. */
extern int zts_rawmode;
@@ -425,14 +426,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
case CPU_DEBUG:
return(sysctl_int(oldp, oldlenp, newp, newlen, &kernel_debug));
-#if 0
- case CPU_BOOTED_DEVICE:
- if (booted_device != NULL)
- return (sysctl_rdstring(oldp, oldlenp, newp,
- booted_device->dv_xname));
- return (EOPNOTSUPP);
-#endif
-
case CPU_CONSDEV: {
dev_t consdev;
if (cn_tab != NULL)
@@ -473,7 +466,23 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
kbd_reset));
return (sysctl_int(oldp, oldlenp, newp, newlen,
&kbd_reset));
+ case CPU_LIDSUSPEND:
+ return (sysctl_int(oldp, oldlenp, newp, newlen,
+ &lid_suspend));
+ case CPU_MAXSPEED:
+ {
+ extern void pxa2x0_maxspeed(int *);
+ int err = EINVAL;
+ if (!newp && newlen == 0)
+ return (sysctl_int(oldp, oldlenp, 0, 0,
+ &xscale_maxspeed));
+ err = (sysctl_int(oldp, oldlenp, newp, newlen,
+ &xscale_maxspeed));
+ pxa2x0_maxspeed(&xscale_maxspeed);
+ return err;
+ }
+
case CPU_ZTSRAWMODE:
#if NZTS > 0
return (sysctl_int(oldp, oldlenp, newp, newlen,
@@ -513,20 +522,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
return (err);
}
#endif
-#ifdef __zaurus__ /* ??? */
- case CPU_MAXSPEED:
- {
- int err = EINVAL;
- void pxa2x0_maxspeed(int *);
- if (!newp && newlen == 0)
- return (sysctl_int(oldp, oldlenp, 0, 0,
- &xscale_maxspeed));
- err = (sysctl_int(oldp, oldlenp, newp, newlen,
- &xscale_maxspeed));
- pxa2x0_maxspeed(&xscale_maxspeed);
- return err;
- }
-#endif
default:
return (EOPNOTSUPP);
@@ -534,123 +529,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
/* NOTREACHED */
}
-#if 0
-/*
- * machine dependent system variables.
- */
-static int
-sysctl_machdep_booted_device(SYSCTLFN_ARGS)
-{
- struct sysctlnode node;
-
- if (booted_device == NULL)
- return (EOPNOTSUPP);
-
- node = *rnode;
- node.sysctl_data = booted_device->dv_xname;
- node.sysctl_size = strlen(booted_device->dv_xname) + 1;
- return (sysctl_lookup(SYSCTLFN_CALL(&node)));
-}
-
-static int
-sysctl_machdep_booted_kernel(SYSCTLFN_ARGS)
-{
- struct sysctlnode node;
-
- if (booted_kernel == NULL || booted_kernel[0] == '\0')
- return (EOPNOTSUPP);
-
- node = *rnode;
- node.sysctl_data = booted_kernel;
- node.sysctl_size = strlen(booted_kernel) + 1;
- return (sysctl_lookup(SYSCTLFN_CALL(&node)));
-}
-
-static int
-sysctl_machdep_powersave(SYSCTLFN_ARGS)
-{
- struct sysctlnode node = *rnode;
- int error, newval;
-
- newval = cpu_do_powersave;
- node.sysctl_data = &newval;
- if (cpufuncs.cf_sleep == (void *) cpufunc_nullop)
- node.sysctl_flags &= ~SYSCTL_READWRITE;
- error = sysctl_lookup(SYSCTLFN_CALL(&node));
- if (error || newp == NULL || newval == cpu_do_powersave)
- return (error);
-
- if (newval < 0 || newval > 1)
- return (EINVAL);
- cpu_do_powersave = newval;
-
- return (0);
-}
-
-SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
-{
-
- sysctl_createv(SYSCTL_PERMANENT,
- CTLTYPE_NODE, "machdep", NULL,
- NULL, 0, NULL, 0,
- CTL_MACHDEP, CTL_EOL);
-
- sysctl_createv(SYSCTL_PERMANENT|SYSCTL_READWRITE,
- CTLTYPE_INT, "debug", NULL,
- NULL, 0, &kernel_debug, 0,
- CTL_MACHDEP, CPU_DEBUG, CTL_EOL);
- sysctl_createv(SYSCTL_PERMANENT,
- CTLTYPE_STRING, "booted_device", NULL,
- sysctl_machdep_booted_device, 0, NULL, 0,
- CTL_MACHDEP, CPU_BOOTED_DEVICE, CTL_EOL);
- sysctl_createv(SYSCTL_PERMANENT,
- CTLTYPE_STRING, "booted_kernel", NULL,
- sysctl_machdep_booted_kernel, 0, NULL, 0,
- CTL_MACHDEP, CPU_BOOTED_KERNEL, CTL_EOL);
- sysctl_createv(SYSCTL_PERMANENT,
- CTLTYPE_STRUCT, "console_device", NULL,
- sysctl_consdev, 0, NULL, sizeof(dev_t),
- CTL_MACHDEP, CPU_CONSDEV, CTL_EOL);
- sysctl_createv(SYSCTL_PERMANENT|SYSCTL_READWRITE,
- CTLTYPE_INT, "powersave", NULL,
- sysctl_machdep_powersave, 0, &cpu_do_powersave, 0,
- CTL_MACHDEP, CPU_POWERSAVE, CTL_EOL);
-}
-#endif
-
-#if 0
-void
-parse_mi_bootargs(args)
- char *args;
-{
- int integer;
-
- if (get_bootconf_option(args, "single", BOOTOPT_TYPE_BOOLEAN, &integer)
- || get_bootconf_option(args, "-s", BOOTOPT_TYPE_BOOLEAN, &integer))
- if (integer)
- boothowto |= RB_SINGLE;
- if (get_bootconf_option(args, "kdb", BOOTOPT_TYPE_BOOLEAN, &integer)
- || get_bootconf_option(args, "-k", BOOTOPT_TYPE_BOOLEAN, &integer))
- if (integer)
- boothowto |= RB_KDB;
- if (get_bootconf_option(args, "ask", BOOTOPT_TYPE_BOOLEAN, &integer)
- || get_bootconf_option(args, "-a", BOOTOPT_TYPE_BOOLEAN, &integer))
- if (integer)
- boothowto |= RB_ASKNAME;
-
-#ifdef PMAP_DEBUG
- if (get_bootconf_option(args, "pmapdebug", BOOTOPT_TYPE_INT, &integer)) {
- pmap_debug_level = integer;
- pmap_debug(pmap_debug_level);
- }
-#endif /* PMAP_DEBUG */
-
-/* if (get_bootconf_option(args, "nbuf", BOOTOPT_TYPE_INT, &integer))
- bufpages = integer;*/
-
-}
-#endif
-
/*
* Allocate space for system data structures. We are given
* a starting virtual address and we return a final virtual
diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h
index 016b6b4f6f6..74626c507ed 100644
--- a/sys/arch/arm/include/cpu.h
+++ b/sys/arch/arm/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.10 2005/12/20 19:23:57 drahn Exp $ */
+/* $OpenBSD: cpu.h,v 1.11 2005/12/21 20:36:02 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */
/*
@@ -64,8 +64,9 @@
#define CPU_KBDRESET 8 /* int: console keyboard reset */
#define CPU_ZTSRAWMODE 9 /* int: zts returns unscaled x/y */
#define CPU_ZTSSCALE 10 /* struct: zts scaling parameters */
-#define CPU_MAXSPEED 11 /* number of valid machdep ids */
-#define CPU_MAXID 12 /* number of valid machdep ids */
+#define CPU_MAXSPEED 11 /* int: number of valid machdep ids */
+#define CPU_LIDSUSPEND 12 /* int: closing lid causes suspend */
+#define CPU_MAXID 13 /* number of valid machdep ids */
#define CTL_MACHDEP_NAMES { \
{ 0, 0 }, \
@@ -79,7 +80,8 @@
{ "kbdreset", CTLTYPE_INT }, \
{ "ztsrawmode", CTLTYPE_INT }, \
{ "ztsscale", CTLTYPE_STRUCT }, \
- { "maxspeed", CTLTYPE_INT } \
+ { "maxspeed", CTLTYPE_INT }, \
+ { "lidsuspend", CTLTYPE_INT } \
}
#ifdef _KERNEL
diff --git a/sys/arch/zaurus/dev/zaurus_kbd.c b/sys/arch/zaurus/dev/zaurus_kbd.c
index 00e7fc16ccc..594055ba5c1 100644
--- a/sys/arch/zaurus/dev/zaurus_kbd.c
+++ b/sys/arch/zaurus/dev/zaurus_kbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zaurus_kbd.c,v 1.27 2005/12/20 18:53:09 deraadt Exp $ */
+/* $OpenBSD: zaurus_kbd.c,v 1.28 2005/12/21 20:36:03 deraadt Exp $ */
/*
* Copyright (c) 2005 Dale Rahn <drahn@openbsd.org>
*
@@ -443,6 +443,7 @@ static int zkbdondown; /* on key is pressed */
static struct timeval zkbdontv = { 0, 0 }; /* last on key event */
const struct timeval zkbdhalttv = { 3, 0 }; /* 3s for safe shutdown */
const struct timeval zkbdsleeptv = { 0, 250000 }; /* .25s for suspend */
+extern int lid_suspend;
#endif
int
@@ -497,11 +498,16 @@ zkbd_hinge(void *v)
sc->sc_hinge = a | b;
- if (sc->sc_hinge == 3)
+ if (sc->sc_hinge == 3) {
+#if NAPM > 0
+ if (lid_suspend)
+ apm_suspends++;
+#endif
lcd_blank(1);
- else
+ } else
lcd_blank(0);
+
return 1;
}