diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2005-07-08 12:38:32 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2005-07-08 12:38:32 +0000 |
commit | f08d380d55a7938afb7492a7a8bd7501a51fb5a5 (patch) | |
tree | 6e5ba82faf3ae32d41782690063cd8c3eac13f89 /sys | |
parent | 21702b31450d01b80d8baa0d1f752135a65f4a04 (diff) |
Add power hooks to the zs devices on sun4m if they have a pwr-on-auxio2
property (as found on sparcbooks). If so, frob the appropriate auxio2 bit
to enable and disable the port as necessary.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc/dev/zs.c | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/sys/arch/sparc/dev/zs.c b/sys/arch/sparc/dev/zs.c index 233679fe18e..b3d8d3059de 100644 --- a/sys/arch/sparc/dev/zs.c +++ b/sys/arch/sparc/dev/zs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zs.c,v 1.41 2005/04/19 21:30:19 miod Exp $ */ +/* $OpenBSD: zs.c,v 1.42 2005/07/08 12:38:31 miod Exp $ */ /* $NetBSD: zs.c,v 1.50 1997/10/18 00:00:40 gwr Exp $ */ /*- @@ -204,7 +204,11 @@ zs_get_chan_addr(zs_unit, channel) /* Definition of the driver for autoconfig. */ int zs_match(struct device *, void *, void *); void zs_attach(struct device *, struct device *, void *); -int zs_print(void *, const char *nam); +int zs_print(void *, const char *nam); + +/* Power management hooks (for Tadpole SPARCbooks) */ +void zs_disable(struct zs_chanstate *); +int zs_enable(struct zs_chanstate *); struct cfattach zs_ca = { sizeof(struct zsc_softc), zs_match, zs_attach @@ -379,6 +383,19 @@ zs_attach(parent, self, aux) zs_write_reg(cs, 9, zs_init_reg[9]); splx(s); +#ifdef SUN4M + /* register power management routines if necessary */ + if (CPU_ISSUN4M) { + if (getpropint(ra->ra_node, "pwr-on-auxio2", 0)) + for (channel = 0; channel < 2; channel++) { + cs = &zsc->zsc_cs[channel]; + cs->disable = zs_disable; + cs->enable = zs_enable; + cs->enabled = 0; + } + } +#endif + #if 0 /* * XXX: L1A hack - We would like to be able to break into @@ -648,6 +665,46 @@ void zs_write_data(cs, val) ZS_DELAY(); } +#ifdef SUN4M +/* + * Power management hooks for zsopen() and zsclose(). + * We use them to power on/off the ports on the Tadpole SPARCbook machines + * (on other sun4m machines, this is a no-op). + */ + +/* + * Since the serial power control is global, we need to remember which channels + * have their ports open, so as not to power off when closing one channel if + * both were open. Simply xor'ing the zs_chanstate pointers is enough to let us + * know if the serial lines are used or not. + */ +static vaddr_t zs_sb_enable = 0; + +int +zs_enable(struct zs_chanstate *cs) +{ + if (cs->enabled == 0) { + if (zs_sb_enable == 0) + sb_auxregbisc(1, AUXIO2_SERIAL, 0); + zs_sb_enable ^= (vaddr_t)cs; + cs->enabled = 1; + } + return (0); +} + +void +zs_disable(struct zs_chanstate *cs) +{ + if (cs->enabled != 0) { + cs->enabled = 0; + zs_sb_enable ^= (vaddr_t)cs; + if (zs_sb_enable == 0) + sb_auxregbisc(1, 0, AUXIO2_SERIAL); + } +} + +#endif /* SUN4M */ + /**************************************************************** * Console support functions (Sun specific!) * Note: this code is allowed to know about the layout of |