From 478ab76ca300a60bf3533e9e1d815d896aa0a0d9 Mon Sep 17 00:00:00 2001 From: uch Date: Wed, 4 Oct 2000 13:53:54 +0000 Subject: [PATCH] experimental power management support for TX3912/TX3922 based model. --- sys/arch/hpcmips/conf/TX3912 | 6 +- sys/arch/hpcmips/conf/TX3922 | 11 +- sys/arch/hpcmips/conf/files.hpcmips | 4 +- sys/arch/hpcmips/dev/hpcapm.c | 10 +- sys/arch/hpcmips/dev/plumpcmcia.c | 51 ++++- sys/arch/hpcmips/dev/plumpcmciareg.h | 47 ++-- sys/arch/hpcmips/dev/plumpower.c | 104 ++++----- sys/arch/hpcmips/dev/plumpowerreg.h | 48 ++-- sys/arch/hpcmips/dev/plumpowervar.h | 50 ++-- sys/arch/hpcmips/dev/plumvideo.c | 274 ++++++++++++---------- sys/arch/hpcmips/dev/plumvideoreg.h | 40 ++-- sys/arch/hpcmips/tx/tx3912video.c | 195 +++++++++------- sys/arch/hpcmips/tx/tx39icu.c | 83 ++++--- sys/arch/hpcmips/tx/tx39icureg.h | 45 ++-- sys/arch/hpcmips/tx/tx39io.c | 116 +++++----- sys/arch/hpcmips/tx/tx39power.c | 326 +++++++++++++++++---------- sys/arch/hpcmips/tx/tx39powerreg.h | 45 ++-- sys/arch/hpcmips/tx/tx39var.h | 91 ++++---- 18 files changed, 919 insertions(+), 627 deletions(-) diff --git a/sys/arch/hpcmips/conf/TX3912 b/sys/arch/hpcmips/conf/TX3912 index 72f9e49d8481..90165c3b9f8c 100644 --- a/sys/arch/hpcmips/conf/TX3912 +++ b/sys/arch/hpcmips/conf/TX3912 @@ -2,7 +2,7 @@ # Distribution kernel (TOSHIBA TX3912 based model) kernel config file # -# $NetBSD: TX3912,v 1.26 2000/09/27 10:22:23 shin Exp $ +# $NetBSD: TX3912,v 1.27 2000/10/04 13:53:54 uch Exp $ # include "arch/hpcmips/conf/std.hpcmips" @@ -95,6 +95,10 @@ options NFS_BOOT_DHCP config netbsd root on ? type ? +# temporally power management +hpcapm0 at mainbus0 # power management +apmdev0 at hpcapm0 # APM + txsim* at mainbus0 # # System Internal Modules diff --git a/sys/arch/hpcmips/conf/TX3922 b/sys/arch/hpcmips/conf/TX3922 index 35a39cb1b73a..20b513056acc 100644 --- a/sys/arch/hpcmips/conf/TX3922 +++ b/sys/arch/hpcmips/conf/TX3922 @@ -1,7 +1,7 @@ # # Distribution kernel (TOSHIBA TX3922 based model) kernel config file # -# $NetBSD: TX3922,v 1.26 2000/09/27 10:22:23 shin Exp $ +# $NetBSD: TX3922,v 1.27 2000/10/04 13:53:54 uch Exp $ # include "arch/hpcmips/conf/std.hpcmips" @@ -89,6 +89,10 @@ options PPP_BSDCOMP # BSD-Compress compression support for PPP options PPP_DEFLATE # Deflate compression support for PPP options PPP_FILTER # Active filter support for PPP (requires bpf) +# temporally power management +hpcapm0 at mainbus0 # power management +apmdev0 at hpcapm0 # APM + txsim* at mainbus0 # # TX39 System Internal Modules @@ -113,14 +117,14 @@ options USE_POLL # m38813,tc5165 requires this # PHILIPS UCB1200 / TOSHIBA TC35413F modem/audio analog front-end ucb* at tx39sib? slot 0 -ucbtp* at ucb? +#ucbtp* at ucb? ucbsnd* at ucb? # PHILIPS 74ALVC*1624? / TOSHIBA TC5165BFTS buffer chip (keyboard) # chip select: CS1, IRQ: 3:12/4:12 tc5165buf* at txcsbus1 iocs 1 iocsbase 0 iocssize 0x100 iocswidth 16 hpckbd* at tc5165buf? -wsmouse* at ucbtp? mux 0 +#wsmouse* at ucbtp? mux 0 # VICTOR InterLink keyboard driver # chip select: CARD1 IRQ ??? @@ -138,7 +142,6 @@ plumvideo* at plum? plumpcmcia* at plum? #plumiobus* at plum? #plumisab0 at plumiobus? platform ? slot 0 -options PLUM_BIG_OHCI_BUFFER # reserve V-RAM area for OHCI module ohci* at plum? # USB bus support diff --git a/sys/arch/hpcmips/conf/files.hpcmips b/sys/arch/hpcmips/conf/files.hpcmips index cd453a100a93..8154f14c7a03 100644 --- a/sys/arch/hpcmips/conf/files.hpcmips +++ b/sys/arch/hpcmips/conf/files.hpcmips @@ -1,4 +1,4 @@ -# $NetBSD: files.hpcmips,v 1.39 2000/10/03 03:13:04 sato Exp $ +# $NetBSD: files.hpcmips,v 1.40 2000/10/04 13:53:54 uch Exp $ # maxpartitions must be first item in files.${ARCH}. maxpartitions 8 @@ -337,7 +337,7 @@ file arch/hpcmips/isa/plumisa_machdep.c plumisab # OHCI USB controller attach ohci at plumif with plumohci -file arch/hpcmips/dev/plumohci.c plumohci +file arch/hpcmips/dev/plumohci.c plumohci needs-flag #device txisab: isabus #attach txisab at txcsbus diff --git a/sys/arch/hpcmips/dev/hpcapm.c b/sys/arch/hpcmips/dev/hpcapm.c index d35533f97d39..6eb3069255f6 100644 --- a/sys/arch/hpcmips/dev/hpcapm.c +++ b/sys/arch/hpcmips/dev/hpcapm.c @@ -1,4 +1,4 @@ -/* $NetBSD: hpcapm.c,v 1.3 2000/07/30 04:41:15 takemura Exp $ */ +/* $NetBSD: hpcapm.c,v 1.4 2000/10/04 13:53:55 uch Exp $ */ /* * Copyright (c) 2000 Takemura Shin @@ -45,6 +45,11 @@ #include #endif +#include "opt_tx39xx.h" +#ifdef TX39XX +#include /* suspend CPU */ +#endif + #define HPCAPMDEBUG #ifdef HPCAPMDEBUG #ifndef HPCAPMDEBUG_CONF @@ -250,6 +255,9 @@ hpcapm_set_powstate(scx, devid, powstat) splhigh(); vrip_intr_resume(); } +#endif /* NVRIP > 0 */ +#ifdef TX39XX + tx39power_suspend_cpu(); #endif config_hook_call(CONFIG_HOOK_PMEVENT, CONFIG_HOOK_PMEVENT_HARDPOWER, diff --git a/sys/arch/hpcmips/dev/plumpcmcia.c b/sys/arch/hpcmips/dev/plumpcmcia.c index f3cf0a1e228a..8989d233c96e 100644 --- a/sys/arch/hpcmips/dev/plumpcmcia.c +++ b/sys/arch/hpcmips/dev/plumpcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: plumpcmcia.c,v 1.4 2000/09/27 17:32:34 uch Exp $ */ +/* $NetBSD: plumpcmcia.c,v 1.5 2000/10/04 13:53:55 uch Exp $ */ /* * Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved. @@ -38,6 +38,7 @@ #include #include +#include #include #include @@ -60,6 +61,8 @@ void plumpcmcia_attach(struct device *, struct device *, void *); int plumpcmcia_print(void *, const char *); int plumpcmcia_submatch(struct device *, struct cfdata *, void *); +int plumpcmcia_power(void *, int, long, void *); + struct plumpcmcia_softc; struct plumpcmcia_handle { @@ -119,11 +122,14 @@ struct plumpcmcia_event { struct plumpcmcia_softc { struct device sc_dev; plum_chipset_tag_t sc_pc; - + /* Register space */ bus_space_tag_t sc_regt; bus_space_handle_t sc_regh; + /* power management hook */ + void *sc_powerhook; + /* CSC event */ struct proc *sc_event_thread; SIMPLEQ_HEAD (, plumpcmcia_event) sc_event_head; @@ -211,11 +217,24 @@ plumpcmcia_attach(struct device *parent, struct device *self, void *aux) sc->sc_pc = pa->pa_pc; sc->sc_regt = pa->pa_regt; + + /* map register area */ if (bus_space_map(sc->sc_regt, PLUM_PCMCIA_REGBASE, PLUM_PCMCIA_REGSIZE, 0, &sc->sc_regh)) { printf(": register map failed\n"); } + /* power control */ + plumpcmcia_power(sc, 0, 0, (void *)PWR_RESUME); + /* Add a hard power hook to power saving */ +#if notyet + sc->sc_powerhook = config_hook(CONFIG_HOOK_PMEVENT, + CONFIG_HOOK_PMEVENT_HARDPOWER, + CONFIG_HOOK_SHARE, + plumpcmcia_power, sc); + if (sc->sc_powerhook == 0) + printf(": WARNING unable to establish hard power hook"); +#endif printf("\n"); /* Slot0/1 CSC event queue */ @@ -965,6 +984,34 @@ plumpcmcia_event_thread(void *arg) /* NOTREACHED */ } +/* power XXX notyet */ +int +plumpcmcia_power(void *ctx, int type, long id, void *msg) +{ + struct plumpcmcia_softc *sc = ctx; + bus_space_tag_t regt = sc->sc_regt; + bus_space_handle_t regh = sc->sc_regh; + int why = (int)msg; + + switch (why) { + case PWR_RESUME: + DPRINTF(("%s: ON\n", sc->sc_dev.dv_xname)); + /* power on */ + plum_conf_write(regt, regh, PLUM_PCMCIA_CARDPWRCTRL, + PLUM_PCMCIA_CARDPWRCTRL_ON); + break; + case PWR_SUSPEND: + /* FALLTHROUGH */ + case PWR_STANDBY: + plum_conf_write(regt, regh, PLUM_PCMCIA_CARDPWRCTRL, + PLUM_PCMCIA_CARDPWRCTRL_OFF); + DPRINTF(("%s: OFF\n", sc->sc_dev.dv_xname)); + break; + } + + return 0; +} + static void __ioareadump(plumreg_t reg) { diff --git a/sys/arch/hpcmips/dev/plumpcmciareg.h b/sys/arch/hpcmips/dev/plumpcmciareg.h index 5c507a02ebdf..02a458cf4deb 100644 --- a/sys/arch/hpcmips/dev/plumpcmciareg.h +++ b/sys/arch/hpcmips/dev/plumpcmciareg.h @@ -1,30 +1,41 @@ -/* $NetBSD: plumpcmciareg.h,v 1.2 2000/09/27 17:32:34 uch Exp $ */ +/* $NetBSD: plumpcmciareg.h,v 1.3 2000/10/04 13:53:55 uch Exp $ */ -/* - * Copyright (c) 1999, by UCHIYAMA Yasushi +/*- + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. The name of the developer may NOT be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + /* (CS3) */ #define PLUM_PCMCIA_REGBASE 0x5000 #define PLUM_PCMCIA_REGSIZE 0x1000 @@ -226,3 +237,5 @@ #define PLUM_PCMCIA_BUFOFF 0x104 #define PLUM_PCMCIA_CARDDETECTMODE 0x108 #define PLUM_PCMCIA_CARDPWRCTRL 0x10c +#define PLUM_PCMCIA_CARDPWRCTRL_OFF 1 +#define PLUM_PCMCIA_CARDPWRCTRL_ON 0 diff --git a/sys/arch/hpcmips/dev/plumpower.c b/sys/arch/hpcmips/dev/plumpower.c index 704b299dbecd..59b0e7f4e114 100644 --- a/sys/arch/hpcmips/dev/plumpower.c +++ b/sys/arch/hpcmips/dev/plumpower.c @@ -1,30 +1,41 @@ -/* $NetBSD: plumpower.c,v 1.4 2000/03/25 15:08:26 uch Exp $ */ +/* $NetBSD: plumpower.c,v 1.5 2000/10/04 13:53:55 uch Exp $ */ -/* - * Copyright (c) 1999, 2000, by UCHIYAMA Yasushi +/*- + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. The name of the developer may NOT be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + #undef PLUMPOWERDEBUG #include "opt_tx39_debug.h" @@ -50,8 +61,8 @@ int plumpower_debug = 1; #define DPRINTFN(n, arg) #endif -int plumpower_match __P((struct device*, struct cfdata*, void*)); -void plumpower_attach __P((struct device*, struct device*, void*)); +int plumpower_match(struct device *, struct cfdata *, void *); +void plumpower_attach(struct device *, struct device *, void *); struct plumpower_softc { struct device sc_dev; @@ -64,22 +75,18 @@ struct cfattach plumpower_ca = { sizeof(struct plumpower_softc), plumpower_match, plumpower_attach }; -void plumpower_dump __P((struct plumpower_softc*)); +#ifdef PLUMPOWERDEBUG +static void plumpower_dump(struct plumpower_softc *); +#endif int -plumpower_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +plumpower_match(struct device *parent, struct cfdata *cf, void *aux) { return 2; /* 1st attach group */ } void -plumpower_attach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; +plumpower_attach(struct device *parent, struct device *self, void *aux) { struct plum_attach_args *pa = aux; struct plumpower_softc *sc = (void*)self; @@ -102,7 +109,6 @@ plumpower_attach(parent, self, aux) PLUM_POWER_PWRCONT_REG, 0); plum_conf_write(sc->sc_regt, sc->sc_regh, PLUM_POWER_CLKCONT_REG, 0); - delay(300 * 1000); /* enable MCS interface from TX3922 */ plum_conf_write(sc->sc_regt, sc->sc_regh, PLUM_POWER_INPENA_REG, @@ -110,8 +116,7 @@ plumpower_attach(parent, self, aux) } void -plum_power_ioreset(pc) - plum_chipset_tag_t pc; +plum_power_ioreset(plum_chipset_tag_t pc) { struct plumpower_softc *sc = pc->pc_powert; bus_space_tag_t regt = sc->sc_regt; @@ -120,15 +125,11 @@ plum_power_ioreset(pc) plum_conf_write(regt, regh, PLUM_POWER_RESETC_REG, PLUM_POWER_RESETC_IO5CL1 | PLUM_POWER_RESETC_IO5CL1); - delay(100*1000); plum_conf_write(regt, regh, PLUM_POWER_RESETC_REG, 0); - delay(100*1000); } void* -plum_power_establish(pc, src) - plum_chipset_tag_t pc; - int src; +plum_power_establish(plum_chipset_tag_t pc, int src) { struct plumpower_softc *sc = pc->pc_powert; bus_space_tag_t regt = sc->sc_regt; @@ -147,7 +148,6 @@ plum_power_establish(pc, src) pwrreg |= PLUM_POWER_PWRCONT_LCDDSP; plum_conf_write(regt, regh, PLUM_POWER_PWRCONT_REG, pwrreg); pwrreg |= PLUM_POWER_PWRCONT_LCDOE; - plum_conf_write(regt, regh, PLUM_POWER_PWRCONT_REG, pwrreg); break; case PLUM_PWR_BKL: pwrreg |= PLUM_POWER_PWRCONT_BKLIGHT; @@ -159,7 +159,6 @@ plum_power_establish(pc, src) /* supply power */ pwrreg |= PLUM_POWER_PWRCONT_IO5PWR; plum_conf_write(regt, regh, PLUM_POWER_PWRCONT_REG, pwrreg); - delay(300*1000); /* output enable & supply clock */ pwrreg |= PLUM_POWER_PWRCONT_IO5OE; @@ -179,16 +178,11 @@ plum_power_establish(pc, src) pwrreg |= PLUM_POWER_PWRCONT_USBEN; /* supply clock to the USB host controller */ clkreg |= PLUM_POWER_CLKCONT_USBCLK1; -#if 1 /* * clock supply is adaptively controlled by hardware * (recommended) */ clkreg &= ~PLUM_POWER_CLKCONT_USBCLK2; -#else - /* clock is always supplied while USBCLK=1 */ - clkreg |= PLUM_POWER_CLKCONT_USBCLK2; -#endif break; case PLUM_PWR_SM: clkreg |= PLUM_POWER_CLKCONT_SMCLK; @@ -202,10 +196,7 @@ plum_power_establish(pc, src) } plum_conf_write(regt, regh, PLUM_POWER_PWRCONT_REG, pwrreg); - delay(300*1000); - plum_conf_write(regt, regh, PLUM_POWER_CLKCONT_REG, clkreg); - delay(300*1000); #ifdef PLUMPOWERDEBUG plumpower_dump(sc); #endif @@ -213,9 +204,7 @@ plum_power_establish(pc, src) } void -plum_power_disestablish(pc, ph) - plum_chipset_tag_t pc; - int ph; +plum_power_disestablish(plum_chipset_tag_t pc, int ph) { struct plumpower_softc *sc = pc->pc_powert; bus_space_tag_t regt = sc->sc_regt; @@ -230,9 +219,11 @@ plum_power_disestablish(pc, ph) default: panic("plum_power_disestablish: unknown power source"); case PLUM_PWR_LCD: - pwrreg &= ~(PLUM_POWER_PWRCONT_LCDOE | - PLUM_POWER_PWRCONT_LCDPWR | - PLUM_POWER_PWRCONT_LCDDSP); + pwrreg &= ~PLUM_POWER_PWRCONT_LCDOE; + plum_conf_write(regt, regh, PLUM_POWER_PWRCONT_REG, pwrreg); + pwrreg &= ~PLUM_POWER_PWRCONT_LCDDSP; + plum_conf_write(regt, regh, PLUM_POWER_PWRCONT_REG, pwrreg); + pwrreg &= ~PLUM_POWER_PWRCONT_LCDPWR; break; case PLUM_PWR_BKL: pwrreg &= ~PLUM_POWER_PWRCONT_BKLIGHT; @@ -274,12 +265,11 @@ plum_power_disestablish(pc, ph) #endif } +#ifdef PLUMPOWERDEBUG #define ISPOWERSUPPLY(r, m) __is_set_print(r, PLUM_POWER_PWRCONT_##m, #m) #define ISCLOCKSUPPLY(r, m) __is_set_print(r, PLUM_POWER_CLKCONT_##m, #m) - -void -plumpower_dump(sc) - struct plumpower_softc *sc; +static void +plumpower_dump(struct plumpower_softc *sc) { bus_space_tag_t regt = sc->sc_regt; bus_space_handle_t regh = sc->sc_regh; @@ -314,5 +304,5 @@ plumpower_dump(sc) reg & PLUM_POWER_RESETC_IO5CL1 ? "CLRH" : ""); printf("\n"); } - +#endif /* PLUMPOWERDEBUG */ diff --git a/sys/arch/hpcmips/dev/plumpowerreg.h b/sys/arch/hpcmips/dev/plumpowerreg.h index fcf8006ac8e5..70b7a179dc55 100644 --- a/sys/arch/hpcmips/dev/plumpowerreg.h +++ b/sys/arch/hpcmips/dev/plumpowerreg.h @@ -1,29 +1,39 @@ -/* $NetBSD: plumpowerreg.h,v 1.2 1999/12/07 17:21:45 uch Exp $ */ +/* $NetBSD: plumpowerreg.h,v 1.3 2000/10/04 13:53:55 uch Exp $ */ -/* - * Copyright (c) 1999, by UCHIYAMA Yasushi +/*- + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. The name of the developer may NOT be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ /* @@ -38,11 +48,9 @@ #define PLUM_POWER_PWRCONT_USBEN 0x00000400 #define PLUM_POWER_PWRCONT_IO5OE 0x00000200 #define PLUM_POWER_PWRCONT_LCDOE 0x00000100 -/* Enable signal of oscillator for the VRAM control */ +/* EXTPW[0:2] Platform dependent control signal */ #define PLUM_POWER_PWRCONT_EXTPW2 0x00000040 -/* Enable signal of the oscillator for LCD module */ #define PLUM_POWER_PWRCONT_EXTPW1 0x00000020 -/* FET Switch that gates power line for RAMDAC */ #define PLUM_POWER_PWRCONT_EXTPW0 0x00000010 #define PLUM_POWER_PWRCONT_IO5PWR 0x00000008 #define PLUM_POWER_PWRCONT_BKLIGHT 0x00000004 diff --git a/sys/arch/hpcmips/dev/plumpowervar.h b/sys/arch/hpcmips/dev/plumpowervar.h index 54e4def297de..9b4e77d7d9a9 100644 --- a/sys/arch/hpcmips/dev/plumpowervar.h +++ b/sys/arch/hpcmips/dev/plumpowervar.h @@ -1,29 +1,39 @@ -/* $NetBSD: plumpowervar.h,v 1.1 1999/11/21 06:50:26 uch Exp $ */ +/* $NetBSD: plumpowervar.h,v 1.2 2000/10/04 13:53:55 uch Exp $ */ -/* - * Copyright (c) 1999, by UCHIYAMA Yasushi +/*- + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. The name of the developer may NOT be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ /* Logical power source # */ @@ -38,7 +48,7 @@ #define PLUM_PWR_PCC1 8 #define PLUM_PWR_PCC2 9 -void* plum_power_establish __P((plum_chipset_tag_t, int)); -void plum_power_disestablish __P((plum_chipset_tag_t, int)); -void plum_power_ioreset __P((plum_chipset_tag_t)); +void *plum_power_establish(plum_chipset_tag_t, int); +void plum_power_disestablish(plum_chipset_tag_t, int); +void plum_power_ioreset(plum_chipset_tag_t); diff --git a/sys/arch/hpcmips/dev/plumvideo.c b/sys/arch/hpcmips/dev/plumvideo.c index 553ecf709c7c..db62907d7e50 100644 --- a/sys/arch/hpcmips/dev/plumvideo.c +++ b/sys/arch/hpcmips/dev/plumvideo.c @@ -1,7 +1,11 @@ -/* $NetBSD: plumvideo.c,v 1.13 2000/06/29 08:17:59 mrg Exp $ */ +/* $NetBSD: plumvideo.c,v 1.14 2000/10/04 13:53:55 uch Exp $ */ /*- - * Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved. + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,23 +15,30 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ -#define PLUMVIDEODEBUG +#define PLUMVIDEODEBUG #include "opt_tx39_debug.h" +#include "plumohci.h" /* Plum2 OHCI shared memory allocated on V-RAM */ #include #include @@ -41,6 +52,7 @@ #include #include +#include #include #include @@ -72,6 +84,8 @@ struct plumvideo_softc { tx_chipset_tag_t sc_tc; plum_chipset_tag_t sc_pc; + void *sc_powerhook; /* power management hook */ + /* control register */ bus_space_tag_t sc_regt; bus_space_handle_t sc_regh; @@ -90,11 +104,11 @@ struct plumvideo_softc { struct hpcfb_dspconf sc_dspconf; }; -int plumvideo_match __P((struct device*, struct cfdata*, void*)); -void plumvideo_attach __P((struct device*, struct device*, void*)); +int plumvideo_match(struct device*, struct cfdata*, void*); +void plumvideo_attach(struct device*, struct device*, void*); -int plumvideo_ioctl __P((void *, u_long, caddr_t, int, struct proc *)); -paddr_t plumvideo_mmap __P((void *, off_t, int)); +int plumvideo_ioctl(void *, u_long, caddr_t, int, struct proc *); +paddr_t plumvideo_mmap(void *, off_t, int); struct cfattach plumvideo_ca = { sizeof(struct plumvideo_softc), plumvideo_match, plumvideo_attach @@ -104,28 +118,27 @@ struct hpcfb_accessops plumvideo_ha = { plumvideo_ioctl, plumvideo_mmap }; -int plumvideo_init __P((struct plumvideo_softc*)); -void plumvideo_hpcfbinit __P((struct plumvideo_softc *)); +int plumvideo_power(void *, int, long, void *); -void plumvideo_clut_default __P((struct plumvideo_softc *)); -void plumvideo_clut_set __P((struct plumvideo_softc *, u_int32_t *, int, - int)); -void plumvideo_clut_get __P((struct plumvideo_softc *, u_int32_t *, int, - int)); -void __plumvideo_clut_access __P((struct plumvideo_softc *, - void (*) __P((bus_space_tag_t, - bus_space_handle_t)))); -static void _flush_cache __P((void)) __attribute__((__unused__)); /* !!! */ +int plumvideo_init(struct plumvideo_softc *, int *); +void plumvideo_hpcfbinit(struct plumvideo_softc *, int); + +void plumvideo_clut_default(struct plumvideo_softc *); +void plumvideo_clut_set(struct plumvideo_softc *, u_int32_t *, int, int); +void plumvideo_clut_get(struct plumvideo_softc *, u_int32_t *, int, int); +void __plumvideo_clut_access(struct plumvideo_softc *, + void (*)(bus_space_tag_t, bus_space_handle_t)); +static void _flush_cache(void) __attribute__((__unused__)); /* !!! */ #ifdef PLUMVIDEODEBUG -void plumvideo_dump __P((struct plumvideo_softc*)); +void plumvideo_dump(struct plumvideo_softc*); #endif +#define ON 1 +#define OFF 0 + int -plumvideo_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +plumvideo_match(struct device *parent, struct cfdata *cf, void *aux) { /* * VRAM area also uses as UHOSTC shared RAM. @@ -134,71 +147,54 @@ plumvideo_match(parent, cf, aux) } void -plumvideo_attach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; +plumvideo_attach(struct device *parent, struct device *self, void *aux) { struct plum_attach_args *pa = aux; struct plumvideo_softc *sc = (void*)self; struct hpcfb_attach_args ha; - int console; + int console, reverse_flag; sc->sc_pc = pa->pa_pc; sc->sc_regt = pa->pa_regt; sc->sc_fbiot = sc->sc_clutiot = sc->sc_bitbltt = pa->pa_iot; printf(": "); - /* - * map register area - */ + + /* map register area */ if (bus_space_map(sc->sc_regt, PLUM_VIDEO_REGBASE, PLUM_VIDEO_REGSIZE, 0, &sc->sc_regh)) { - printf(": register map failed\n"); + printf("register map failed\n"); return; } - /* - * Power control - */ + /* power control */ #ifndef PLUMVIDEODEBUG - if (bootinfo->bi_cnuse & BI_CNUSE_SERIAL) { - /* LCD power on and display off */ - plum_power_disestablish(sc->sc_pc, PLUM_PWR_LCD); - /* power off V-RAM */ - plum_power_disestablish(sc->sc_pc, PLUM_PWR_EXTPW2); - /* power off LCD */ - plum_power_disestablish(sc->sc_pc, PLUM_PWR_EXTPW1); - /* power off RAMDAC */ - plum_power_disestablish(sc->sc_pc, PLUM_PWR_EXTPW0); - /* back-light off */ - plum_power_disestablish(sc->sc_pc, PLUM_PWR_BKL); - } else + if (bootinfo->bi_cnuse & BI_CNUSE_SERIAL) + plumvideo_power(sc, 0, 0, (void *)PWR_SUSPEND); + else #endif - { - /* LCD power on and display on */ - plum_power_establish(sc->sc_pc, PLUM_PWR_LCD); - /* supply power to V-RAM */ - plum_power_establish(sc->sc_pc, PLUM_PWR_EXTPW2); - /* supply power to LCD */ - plum_power_establish(sc->sc_pc, PLUM_PWR_EXTPW1); - /* back-light on */ - plum_power_establish(sc->sc_pc, PLUM_PWR_BKL); - } - + plumvideo_power(sc, 0, 0, (void *)PWR_RESUME); + /* Add a hard power hook to power saving */ + sc->sc_powerhook = config_hook(CONFIG_HOOK_PMEVENT, + CONFIG_HOOK_PMEVENT_HARDPOWER, + CONFIG_HOOK_SHARE, + plumvideo_power, sc); + if (sc->sc_powerhook == 0) + printf("WARNING unable to establish hard power hook"); + /* * Initialize LCD controller * map V-RAM area. * reinstall bootinfo structure. * some OHCI shared-buffer hack. XXX */ - if (plumvideo_init(sc) != 0) + if (plumvideo_init(sc, &reverse_flag) != 0) return; printf("\n"); /* Attach frame buffer device */ - plumvideo_hpcfbinit(sc); + plumvideo_hpcfbinit(sc, reverse_flag); #ifdef PLUMVIDEODEBUG if (plumvideo_debug > 1) @@ -227,8 +223,7 @@ plumvideo_attach(parent, self, aux) } void -plumvideo_hpcfbinit(sc) - struct plumvideo_softc *sc; +plumvideo_hpcfbinit(struct plumvideo_softc *sc, int reverse_flag) { struct hpcfb_fbconf *fb = &sc->sc_fbconf; struct video_chip *chip = &sc->sc_chip; @@ -257,6 +252,8 @@ plumvideo_hpcfbinit(sc) fb->hf_access_flags |= HPCFB_ACCESS_BYTE; fb->hf_access_flags |= HPCFB_ACCESS_WORD; fb->hf_access_flags |= HPCFB_ACCESS_DWORD; + if (reverse_flag) + fb->hf_access_flags |= HPCFB_ACCESS_REVERSE; switch (depth) { default: @@ -297,15 +294,24 @@ plumvideo_hpcfbinit(sc) } int -plumvideo_init(sc) - struct plumvideo_softc *sc; +plumvideo_init(struct plumvideo_softc *sc, int *reverse) { + struct { + int reverse, normal; + } ctype[] = { + { BIFB_D2_M2L_3, BIFB_D2_M2L_0 }, + { BIFB_D2_M2L_3x2, BIFB_D2_M2L_0x2 }, + { BIFB_D8_FF, BIFB_D8_00 }, + { BIFB_D16_FFFF, BIFB_D16_0000, }, + { -1, -1 } /* terminator */ + }, *ctypep; + struct video_chip *chip = &sc->sc_chip; bus_space_tag_t regt = sc->sc_regt; bus_space_handle_t regh = sc->sc_regh; plumreg_t reg; size_t vram_size; int bpp, width, height, vram_pitch; - struct video_chip *chip = &sc->sc_chip; + u_int16_t fbtype; chip->vc_v = sc->sc_pc->pc_tc; #if notyet @@ -319,17 +325,32 @@ plumvideo_init(sc) } #endif reg = plum_conf_read(regt, regh, PLUM_VIDEO_PLGMD_REG); + + /* check reverse color */ + fbtype = bootinfo->fb_type; + for (ctypep = ctype; ctypep->normal != -1 ; ctypep++) { + if (fbtype == ctypep->normal) { + *reverse = 0; + goto fbtype_found; + } else if (fbtype == ctypep->reverse) { + *reverse = 1; + goto fbtype_found; + } + } + printf(": unknown frame buffer type 0x%04x. attach failed.\n", fbtype); + return (1); + fbtype_found: + switch (reg & PLUM_VIDEO_PLGMD_GMODE_MASK) { case PLUM_VIDEO_PLGMD_16BPP: -#ifdef PLUM_BIG_OHCI_BUFFER - printf("(16bpp disabled) "); +#if NPLUMOHCI > 0 /* reserve V-RAM for USB OHCI */ /* FALLTHROUGH */ -#else /* PLUM_BIG_OHCI_BUFFER */ +#else bpp = 16; break; -#endif /* PLUM_BIG_OHCI_BUFFER */ +#endif default: - bootinfo->fb_type = BIFB_D8_FF; /* over ride */ + bootinfo->fb_type = *reverse ? BIFB_D8_FF : BIFB_D8_00; reg &= ~PLUM_VIDEO_PLGMD_GMODE_MASK; plum_conf_write(regt, regh, PLUM_VIDEO_PLGMD_REG, reg); reg |= PLUM_VIDEO_PLGMD_8BPP; @@ -357,14 +378,12 @@ plumvideo_init(sc) /* * set line byte length to bootinfo and LCD controller. */ - bootinfo->fb_line_bytes = (width * bpp) / NBBY; - - vram_pitch = width / (8 / bpp); + vram_pitch = bootinfo->fb_line_bytes = (width * bpp) / NBBY; plum_conf_write(regt, regh, PLUM_VIDEO_PLPIT1_REG, vram_pitch); plum_conf_write(regt, regh, PLUM_VIDEO_PLPIT2_REG, vram_pitch & PLUM_VIDEO_PLPIT2_MASK); plum_conf_write(regt, regh, PLUM_VIDEO_PLOFS_REG, vram_pitch); - + /* * boot messages and map CLUT(if any). */ @@ -416,12 +435,7 @@ plumvideo_init(sc) } int -plumvideo_ioctl(v, cmd, data, flag, p) - void *v; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; +plumvideo_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) { struct plumvideo_softc *sc = (struct plumvideo_softc *)v; struct hpcfb_fbconf *fbconf; @@ -551,10 +565,7 @@ plumvideo_ioctl(v, cmd, data, flag, p) } paddr_t -plumvideo_mmap(ctx, offset, prot) - void *ctx; - off_t offset; - int prot; +plumvideo_mmap(void *ctx, off_t offset, int prot) { struct plumvideo_softc *sc = (struct plumvideo_softc *)ctx; @@ -567,13 +578,11 @@ plumvideo_mmap(ctx, offset, prot) } void -plumvideo_clut_get(sc, rgb, beg, cnt) - struct plumvideo_softc *sc; - u_int32_t *rgb; - int beg, cnt; +plumvideo_clut_get(struct plumvideo_softc *sc, u_int32_t *rgb, int beg, + int cnt) { - static void __plumvideo_clut_get __P((bus_space_tag_t, - bus_space_handle_t)); + static void __plumvideo_clut_get(bus_space_tag_t, + bus_space_handle_t); static void __plumvideo_clut_get(iot, ioh) bus_space_tag_t iot; bus_space_handle_t ioh; @@ -593,13 +602,11 @@ plumvideo_clut_get(sc, rgb, beg, cnt) } void -plumvideo_clut_set(sc, rgb, beg, cnt) - struct plumvideo_softc *sc; - u_int32_t *rgb; - int beg, cnt; +plumvideo_clut_set(struct plumvideo_softc *sc, u_int32_t *rgb, int beg, + int cnt) { - static void __plumvideo_clut_set __P((bus_space_tag_t, - bus_space_handle_t)); + static void __plumvideo_clut_set(bus_space_tag_t, + bus_space_handle_t); static void __plumvideo_clut_set(iot, ioh) bus_space_tag_t iot; bus_space_handle_t ioh; @@ -619,11 +626,10 @@ plumvideo_clut_set(sc, rgb, beg, cnt) } void -plumvideo_clut_default(sc) - struct plumvideo_softc *sc; +plumvideo_clut_default(struct plumvideo_softc *sc) { - static void __plumvideo_clut_default __P((bus_space_tag_t, - bus_space_handle_t)); + static void __plumvideo_clut_default(bus_space_tag_t, + bus_space_handle_t); static void __plumvideo_clut_default(iot, ioh) bus_space_tag_t iot; bus_space_handle_t ioh; @@ -668,9 +674,8 @@ plumvideo_clut_default(sc) } void -__plumvideo_clut_access(sc, palette_func) - struct plumvideo_softc *sc; - void (*palette_func) __P((bus_space_tag_t, bus_space_handle_t)); +__plumvideo_clut_access(struct plumvideo_softc *sc, void (*palette_func) + (bus_space_tag_t, bus_space_handle_t)) { bus_space_tag_t regt = sc->sc_regt; bus_space_handle_t regh = sc->sc_regh; @@ -713,10 +718,45 @@ _flush_cache() MachFlushCache(); } +int +plumvideo_power(void *ctx, int type, long id, void *msg) +{ + struct plumvideo_softc *sc = ctx; + plum_chipset_tag_t pc = sc->sc_pc; + bus_space_tag_t regt = sc->sc_regt; + bus_space_handle_t regh = sc->sc_regh; + int why = (int)msg; + + switch (why) { + case PWR_RESUME: + DPRINTF(("%s: ON\n", sc->sc_dev.dv_xname)); + /* power on */ + /* LCD power on and display on */ + plum_power_establish(pc, PLUM_PWR_LCD); + /* back-light on */ + plum_power_establish(pc, PLUM_PWR_BKL); + plum_conf_write(regt, regh, PLUM_VIDEO_PLLUM_REG, + PLUM_VIDEO_PLLUM_MAX); + break; + case PWR_SUSPEND: + /* FALLTHROUGH */ + case PWR_STANDBY: + DPRINTF(("%s: OFF\n", sc->sc_dev.dv_xname)); + /* back-light off */ + plum_conf_write(regt, regh, PLUM_VIDEO_PLLUM_REG, + PLUM_VIDEO_PLLUM_MIN); + plum_power_disestablish(pc, PLUM_PWR_BKL); + /* power down */ + plum_power_disestablish(pc, PLUM_PWR_LCD); + break; + } + + return 0; +} + #ifdef PLUMVIDEODEBUG void -plumvideo_dump(sc) - struct plumvideo_softc *sc; +plumvideo_dump(struct plumvideo_softc *sc) { bus_space_tag_t regt = sc->sc_regt; bus_space_handle_t regh = sc->sc_regh; diff --git a/sys/arch/hpcmips/dev/plumvideoreg.h b/sys/arch/hpcmips/dev/plumvideoreg.h index 48144c16cc57..1fca5e6def01 100644 --- a/sys/arch/hpcmips/dev/plumvideoreg.h +++ b/sys/arch/hpcmips/dev/plumvideoreg.h @@ -1,7 +1,11 @@ -/* $NetBSD: plumvideoreg.h,v 1.4 2000/05/08 21:57:57 uch Exp $ */ +/* $NetBSD: plumvideoreg.h,v 1.5 2000/10/04 13:53:55 uch Exp $ */ /*- - * Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved. + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,19 +15,25 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ /* (CS3) */ @@ -76,6 +86,8 @@ #define PLUM_VIDEO_PLLEV_REG 0x048 /* LCD Luminance control */ #define PLUM_VIDEO_PLLUM_REG 0x04c +#define PLUM_VIDEO_PLLUM_MAX 0x3 +#define PLUM_VIDEO_PLLUM_MIN 0x0 /* DSTN Dither Pattern base address */ #define PLUM_VIDEO_PLDPA_REG 0x050 /* DSTN VRAM Offscreen buffer address */ diff --git a/sys/arch/hpcmips/tx/tx3912video.c b/sys/arch/hpcmips/tx/tx3912video.c index 7adabb3317b8..ba2389c6edae 100644 --- a/sys/arch/hpcmips/tx/tx3912video.c +++ b/sys/arch/hpcmips/tx/tx3912video.c @@ -1,7 +1,11 @@ -/* $NetBSD: tx3912video.c,v 1.17 2000/06/29 08:18:00 mrg Exp $ */ +/* $NetBSD: tx3912video.c,v 1.18 2000/10/04 13:53:55 uch Exp $ */ /*- - * Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved. + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,20 +15,27 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + #define TX3912VIDEO_DEBUG #include "opt_tx39_debug.h" @@ -42,6 +53,7 @@ #include #include +#include #include #include @@ -56,8 +68,18 @@ #include #include +#ifdef TX3912VIDEO_DEBUG +int tx3912video_debug = 1; +#define DPRINTF(arg) if (tx3912video_debug) printf arg; +#define DPRINTFN(n, arg) if (tx3912video_debug > (n)) printf arg; +#else +#define DPRINTF(arg) +#define DPRINTFN(n, arg) +#endif + struct tx3912video_softc { struct device sc_dev; + void *sc_powerhook; /* power management hook */ struct hpcfb_fbconf sc_fbconf; struct hpcfb_dspconf sc_dspconf; struct video_chip *sc_chip; @@ -66,26 +88,25 @@ struct tx3912video_softc { /* TX3912 built-in video chip itself */ static struct video_chip tx3912video_chip; -void tx3912video_framebuffer_init __P((struct video_chip *)); -int tx3912video_framebuffer_alloc __P((struct video_chip *, - paddr_t, paddr_t *)); -void tx3912video_reset __P((struct video_chip *)); -void tx3912video_resolution_init __P((struct video_chip *)); +int tx3912video_power(void *, int, long, void *); +void tx3912video_framebuffer_init(struct video_chip *); +int tx3912video_framebuffer_alloc(struct video_chip *, paddr_t, paddr_t *); +void tx3912video_reset(struct video_chip *); +void tx3912video_resolution_init(struct video_chip *); +int tx3912video_match(struct device *, struct cfdata *, void *); +void tx3912video_attach(struct device *, struct device *, void *); +int tx3912video_print(void *, const char *); -int tx3912video_match __P((struct device *, struct cfdata *, void *)); -void tx3912video_attach __P((struct device *, struct device *, void *)); -int tx3912video_print __P((void *, const char *)); +void tx3912video_hpcfbinit(struct tx3912video_softc *); +int tx3912video_ioctl(void *, u_long, caddr_t, int, struct proc *); +paddr_t tx3912video_mmap(void *, off_t, int); -void tx3912video_hpcfbinit __P((struct tx3912video_softc *)); -int tx3912video_ioctl __P((void *, u_long, caddr_t, int, struct proc *)); -paddr_t tx3912video_mmap __P((void *, off_t, int)); - -void tx3912video_clut_init __P((struct tx3912video_softc *)); -void tx3912video_clut_install __P((void *, struct rasops_info *)); -void tx3912video_clut_get __P((struct tx3912video_softc *, - u_int32_t *, int, int)); -static int __get_color8 __P((int)); -static int __get_color4 __P((int)); +void tx3912video_clut_init(struct tx3912video_softc *); +void tx3912video_clut_install(void *, struct rasops_info *); +void tx3912video_clut_get(struct tx3912video_softc *, u_int32_t *, int, int); + +static int __get_color8(int); +static int __get_color4(int); struct cfattach tx3912video_ca = { sizeof(struct tx3912video_softc), tx3912video_match, @@ -98,19 +119,13 @@ struct hpcfb_accessops tx3912video_ha = { }; int -tx3912video_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +tx3912video_match(struct device *parent, struct cfdata *cf, void *aux) { return (1); } void -tx3912video_attach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; +tx3912video_attach(struct device *parent, struct device *self, void *aux) { struct tx3912video_softc *sc = (void *)self; struct video_chip *chip; @@ -144,14 +159,19 @@ tx3912video_attach(parent, self, aux) /* if serial console, power off video module */ #ifndef TX3912VIDEO_DEBUG - if (!console) { - printf("%s: power off\n", sc->sc_dev.dv_xname); - val = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG); - val &= ~(TX3912_VIDEOCTRL1_DISPON | - TX3912_VIDEOCTRL1_ENVID); - tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, val); - } + if (!console) + tx3912video_power(sc, 0, 0, (void *)PWR_SUSPEND); + else #endif /* TX3912VIDEO_DEBUG */ + tx3912video_power(sc, 0, 0, (void *)PWR_RESUME); + + /* Add a hard power hook to power saving */ + sc->sc_powerhook = config_hook(CONFIG_HOOK_PMEVENT, + CONFIG_HOOK_PMEVENT_HARDPOWER, + CONFIG_HOOK_SHARE, + tx3912video_power, sc); + if (sc->sc_powerhook == 0) + printf("WARNING unable to establish hard power hook"); #ifdef TX3912VIDEO_DEBUG /* attach debug draw routine (debugging use) */ @@ -179,6 +199,35 @@ tx3912video_attach(parent, self, aux) config_found(self, &ha, hpcfbprint); } +int +tx3912video_power(void *ctx, int type, long id, void *msg) +{ + struct tx3912video_softc *sc = ctx; + struct video_chip *chip = sc->sc_chip; + tx_chipset_tag_t tc = chip->vc_v; + int why = (int)msg; + txreg_t val; + + switch (why) { + case PWR_RESUME: + DPRINTF(("%s: ON\n", sc->sc_dev.dv_xname)); + val = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG); + val |= (TX3912_VIDEOCTRL1_DISPON | TX3912_VIDEOCTRL1_ENVID); + tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, val); + break; + case PWR_SUSPEND: + /* FALLTHROUGH */ + case PWR_STANDBY: + DPRINTF(("%s: OFF\n", sc->sc_dev.dv_xname)); + val = tx_conf_read(tc, TX3912_VIDEOCTRL1_REG); + val &= ~(TX3912_VIDEOCTRL1_DISPON | TX3912_VIDEOCTRL1_ENVID); + tx_conf_write(tc, TX3912_VIDEOCTRL1_REG, val); + break; + } + + return 0; +} + void tx3912video_hpcfbinit(sc) struct tx3912video_softc *sc; @@ -237,8 +286,7 @@ tx3912video_hpcfbinit(sc) } int -tx3912video_init(fb_start, fb_end) - paddr_t fb_start, *fb_end; +tx3912video_init(paddr_t fb_start, paddr_t *fb_end) { struct video_chip *chip = &tx3912video_chip; tx_chipset_tag_t tc; @@ -297,9 +345,8 @@ tx3912video_init(fb_start, fb_end) } int -tx3912video_framebuffer_alloc(chip, fb_start, fb_end) - struct video_chip *chip; - paddr_t fb_start, *fb_end; /* buffer allocation hint */ +tx3912video_framebuffer_alloc(struct video_chip *chip, paddr_t fb_start, + paddr_t *fb_end /* buffer allocation hint */) { struct extent_fixed ex_fixed[10]; struct extent *ex; @@ -337,9 +384,8 @@ tx3912video_framebuffer_alloc(chip, fb_start, fb_end) return (0); } - void -tx3912video_framebuffer_init(chip) - struct video_chip *chip; +void +tx3912video_framebuffer_init(struct video_chip *chip) { u_int32_t fb_addr, fb_size, vaddr, bank, base; txreg_t reg; @@ -379,9 +425,8 @@ tx3912video_framebuffer_init(chip) memset((void*)vaddr, 0, fb_size); } - void -tx3912video_resolution_init(chip) - struct video_chip *chip; +void +tx3912video_resolution_init(struct video_chip *chip) { int h, v, split, bit8, horzval, lineval; tx_chipset_tag_t tc = chip->vc_v; @@ -419,8 +464,7 @@ tx3912video_resolution_init(chip) } void -tx3912video_reset(chip) - struct video_chip *chip; +tx3912video_reset(struct video_chip *chip) { tx_chipset_tag_t tc = chip->vc_v; txreg_t reg; @@ -449,12 +493,7 @@ tx3912video_reset(chip) } int -tx3912video_ioctl(v, cmd, data, flag, p) - void *v; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; +tx3912video_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p) { struct tx3912video_softc *sc = (struct tx3912video_softc *)v; struct hpcfb_fbconf *fbconf; @@ -560,10 +599,7 @@ tx3912video_ioctl(v, cmd, data, flag, p) } paddr_t -tx3912video_mmap(ctx, offset, prot) - void *ctx; - off_t offset; - int prot; +tx3912video_mmap(void *ctx, off_t offset, int prot) { struct tx3912video_softc *sc = (struct tx3912video_softc *)ctx; @@ -618,8 +654,7 @@ static const int dither_level4[4] = { }; static int -__get_color8(luti) - int luti; +__get_color8(int luti) { KASSERT(luti >=0 && luti < 8); dlp = &dither_list[dither_level8[luti]]; @@ -628,8 +663,7 @@ __get_color8(luti) } static int -__get_color4(luti) - int luti; +__get_color4(int luti) { KASSERT(luti >=0 && luti < 4); dlp = &dither_list[dither_level4[luti]]; @@ -638,10 +672,8 @@ __get_color4(luti) } void -tx3912video_clut_get(sc, rgb, beg, cnt) - struct tx3912video_softc *sc; - u_int32_t *rgb; - int beg, cnt; +tx3912video_clut_get(struct tx3912video_softc *sc, u_int32_t *rgb, int beg, + int cnt) { int i; @@ -657,9 +689,7 @@ tx3912video_clut_get(sc, rgb, beg, cnt) } void -tx3912video_clut_install(ctx, ri) - void *ctx; - struct rasops_info *ri; +tx3912video_clut_install(void *ctx, struct rasops_info *ri) { struct tx3912video_softc *sc = ctx; const int system_cmap[0x10] = { @@ -690,8 +720,7 @@ tx3912video_clut_install(ctx, ri) } void -tx3912video_clut_init(sc) - struct tx3912video_softc *sc; +tx3912video_clut_init(struct tx3912video_softc *sc) { tx_chipset_tag_t tc = sc->sc_chip->vc_v; diff --git a/sys/arch/hpcmips/tx/tx39icu.c b/sys/arch/hpcmips/tx/tx39icu.c index a5925ff6b7c4..c34102340325 100644 --- a/sys/arch/hpcmips/tx/tx39icu.c +++ b/sys/arch/hpcmips/tx/tx39icu.c @@ -1,30 +1,41 @@ -/* $NetBSD: tx39icu.c,v 1.8 2000/07/20 03:44:46 deberg Exp $ */ +/* $NetBSD: tx39icu.c,v 1.9 2000/10/04 13:53:55 uch Exp $ */ -/* - * Copyright (c) 1999, 2000 by UCHIYAMA Yasushi +/*- + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. The name of the developer may NOT be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + #include "opt_tx39_debug.h" #include "opt_use_poll.h" #include "opt_tx39icudebug.h" @@ -191,21 +202,22 @@ tx39icu_attach(parent, self, aux) struct txsim_attach_args *ta = aux; struct tx39icu_softc *sc = (void*)self; tx_chipset_tag_t tc = ta->ta_tc; - txreg_t reg; + txreg_t reg, *regs; int i; printf("\n"); sc->sc_tc = ta->ta_tc; - sc->sc_regs[0] = tx_conf_read(tc, TX39_INTRSTATUS6_REG); - sc->sc_regs[1] = tx_conf_read(tc, TX39_INTRSTATUS1_REG); - sc->sc_regs[2] = tx_conf_read(tc, TX39_INTRSTATUS2_REG); - sc->sc_regs[3] = tx_conf_read(tc, TX39_INTRSTATUS3_REG); - sc->sc_regs[4] = tx_conf_read(tc, TX39_INTRSTATUS4_REG); - sc->sc_regs[5] = tx_conf_read(tc, TX39_INTRSTATUS5_REG); + regs = sc->sc_regs; + regs[0] = tx_conf_read(tc, TX39_INTRSTATUS6_REG); + regs[1] = tx_conf_read(tc, TX39_INTRSTATUS1_REG); + regs[2] = tx_conf_read(tc, TX39_INTRSTATUS2_REG); + regs[3] = tx_conf_read(tc, TX39_INTRSTATUS3_REG); + regs[4] = tx_conf_read(tc, TX39_INTRSTATUS4_REG); + regs[5] = tx_conf_read(tc, TX39_INTRSTATUS5_REG); #ifdef TX392X - sc->sc_regs[7] = tx_conf_read(tc, TX39_INTRSTATUS7_REG); - sc->sc_regs[8] = tx_conf_read(tc, TX39_INTRSTATUS8_REG); + regs[7] = tx_conf_read(tc, TX39_INTRSTATUS7_REG); + regs[8] = tx_conf_read(tc, TX39_INTRSTATUS8_REG); #endif #ifdef TX39ICUDEBUG printf("\t[Windows CE setting]\n"); @@ -274,7 +286,7 @@ tx39icu_intr(status, cause, pc, ipending) { struct tx39icu_softc *sc; tx_chipset_tag_t tc; - txreg_t reg, pend; + txreg_t reg, pend, *regs; int i, j; tc = tx_conf_get_tag(); @@ -282,15 +294,16 @@ tx39icu_intr(status, cause, pc, ipending) /* * Read regsiter ASAP */ - sc->sc_regs[0] = tx_conf_read(tc, TX39_INTRSTATUS6_REG); - sc->sc_regs[1] = tx_conf_read(tc, TX39_INTRSTATUS1_REG); - sc->sc_regs[2] = tx_conf_read(tc, TX39_INTRSTATUS2_REG); - sc->sc_regs[3] = tx_conf_read(tc, TX39_INTRSTATUS3_REG); - sc->sc_regs[4] = tx_conf_read(tc, TX39_INTRSTATUS4_REG); - sc->sc_regs[5] = tx_conf_read(tc, TX39_INTRSTATUS5_REG); + regs = sc->sc_regs; + regs[0] = tx_conf_read(tc, TX39_INTRSTATUS6_REG); + regs[1] = tx_conf_read(tc, TX39_INTRSTATUS1_REG); + regs[2] = tx_conf_read(tc, TX39_INTRSTATUS2_REG); + regs[3] = tx_conf_read(tc, TX39_INTRSTATUS3_REG); + regs[4] = tx_conf_read(tc, TX39_INTRSTATUS4_REG); + regs[5] = tx_conf_read(tc, TX39_INTRSTATUS5_REG); #ifdef TX392X - sc->sc_regs[7] = tx_conf_read(tc, TX39_INTRSTATUS7_REG); - sc->sc_regs[8] = tx_conf_read(tc, TX39_INTRSTATUS8_REG); + regs[7] = tx_conf_read(tc, TX39_INTRSTATUS7_REG); + regs[8] = tx_conf_read(tc, TX39_INTRSTATUS8_REG); #endif #ifdef TX39ICUDEBUG diff --git a/sys/arch/hpcmips/tx/tx39icureg.h b/sys/arch/hpcmips/tx/tx39icureg.h index 6552d01900ac..a899189d13de 100644 --- a/sys/arch/hpcmips/tx/tx39icureg.h +++ b/sys/arch/hpcmips/tx/tx39icureg.h @@ -1,30 +1,41 @@ -/* $NetBSD: tx39icureg.h,v 1.2 1999/12/26 17:05:28 uch Exp $ */ +/* $NetBSD: tx39icureg.h,v 1.3 2000/10/04 13:53:56 uch Exp $ */ -/* - * Copyright (c) 1999, by UCHIYAMA Yasushi +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. The name of the developer may NOT be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + /* * TOSHIBA TMPR3912/3922 interrupt module. */ diff --git a/sys/arch/hpcmips/tx/tx39io.c b/sys/arch/hpcmips/tx/tx39io.c index 8f1be1dc0540..0fa168e8bd2f 100644 --- a/sys/arch/hpcmips/tx/tx39io.c +++ b/sys/arch/hpcmips/tx/tx39io.c @@ -1,30 +1,41 @@ -/* $NetBSD: tx39io.c,v 1.5 2000/01/16 21:47:00 uch Exp $ */ +/* $NetBSD: tx39io.c,v 1.6 2000/10/04 13:53:56 uch Exp $ */ -/* - * Copyright (c) 1999, 2000, by UCHIYAMA Yasushi +/*- + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. The name of the developer may NOT be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + #include "opt_tx39_debug.h" #include "opt_tx39iodebug.h" @@ -41,13 +52,14 @@ #include +#undef TX39IODEBUG #define TX39IO_ATTACH_DUMMYHANDLER 0 #undef TX39IO_MFIOOUTPORT_ON #undef TX39IO_MFIOOUTPORT_OFF -int tx39io_match __P((struct device*, struct cfdata*, void*)); -void tx39io_attach __P((struct device*, struct device*, void*)); -int tx39io_print __P((void*, const char*)); +int tx39io_match(struct device *, struct cfdata *, void *); +void tx39io_attach(struct device *, struct device *, void *); +int tx39io_print(void *, const char *); struct tx39io_softc { struct device sc_dev; @@ -59,14 +71,13 @@ struct cfattach tx39io_ca = { }; #ifdef TX39IODEBUG -int tx39io_intr __P((void*)); -int tx39mfio_intr __P((void*)); -void tx39io_dump __P((struct tx39io_softc*)); -void tx39io_dump_and_attach_handler __P((struct tx39io_softc*, int)); -void __dump_and_attach_handler __P((tx_chipset_tag_t, u_int32_t, - u_int32_t, u_int32_t, u_int32_t, - int, int, int (*) __P((void*)), - void*, int)); +int tx39io_intr(void *); +int tx39mfio_intr(void *); +void tx39io_dump(struct tx39io_softc *); +void tx39io_dump_and_attach_handler(struct tx39io_softc *, int); +void __dump_and_attach_handler(tx_chipset_tag_t, u_int32_t, + u_int32_t, u_int32_t, u_int32_t, + int, int, int (*)(void *), void *, int); #endif /* TX39IODEBUG */ #define ISSET(x, s) ((x) & (1 << (s))) @@ -125,19 +136,13 @@ const struct { }; int -tx39io_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +tx39io_match(struct device *parent, struct cfdata *cf, void *aux) { return 2; /* 1st attach group of txsim */ } void -tx39io_attach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; +tx39io_attach(struct device *parent, struct device *self, void *aux) { struct txsim_attach_args *ta = aux; struct tx39io_softc *sc = (void*)self; @@ -158,17 +163,13 @@ tx39io_attach(parent, self, aux) } int -tx39io_print(aux, pnp) - void *aux; - const char *pnp; +tx39io_print(void *aux, const char *pnp) { return pnp ? QUIET : UNCONF; } void -tx39io_portout(tc, port, onoff) - tx_chipset_tag_t tc; - int port, onoff; +tx39io_portout(tx_chipset_tag_t tc, int port, int onoff) { txreg_t reg; @@ -203,8 +204,7 @@ tx39io_portout(tc, port, onoff) #ifdef TX39IODEBUG int -tx39io_intr(arg) - void *arg; +tx39io_intr(void *arg) { printf("io (%d:%d)\n", (tx39intrvec >> 16) & 0xffff, tx39intrvec & 0xfff); @@ -213,8 +213,7 @@ tx39io_intr(arg) } int -tx39mfio_intr(arg) - void *arg; +tx39mfio_intr(void *arg) { printf("mfio (%d:%d)\n", (tx39intrvec >> 16) & 0xffff, tx39intrvec & 0xfff); @@ -223,8 +222,7 @@ tx39mfio_intr(arg) } void -tx39io_dump(sc) - struct tx39io_softc *sc; +tx39io_dump(struct tx39io_softc *sc) { #ifdef COMPAQ_LOCAL_INTR /* for debug */ /* 2010c Rec button */ @@ -279,15 +277,13 @@ tx39io_dump(sc) } void -tx39io_dump_and_attach_handler(sc, dummy) - struct tx39io_softc *sc; - int dummy; +tx39io_dump_and_attach_handler(struct tx39io_softc *sc, int dummy) { tx_chipset_tag_t tc; u_int32_t reg, reg_out, reg_dir, reg_in, reg_sel, reg_pwr, reg_deb; int i; - int (*iointr) __P((void*)); - int (*mfiointr) __P((void*)); + int (*iointr)(void*); + int (*mfiointr)(void*); tc = sc->sc_tc; if (dummy) { @@ -346,14 +342,10 @@ tx39io_dump_and_attach_handler(sc, dummy) } void -__dump_and_attach_handler(tc, reg_dir, reg_out, reg_in, reg_pwr, - i, io, func, arg, mf) - tx_chipset_tag_t tc; - u_int32_t reg_dir, reg_out, reg_in, reg_pwr; - int i, io; - int (*func) __P((void*)); - void *arg; - int mf; +__dump_and_attach_handler(tx_chipset_tag_t tc, u_int32_t reg_dir, + u_int32_t reg_out, u_int32_t reg_in, + u_int32_t reg_pwr, int i, int io, + int (*func)(void*), void *arg, int mf) { int pset, nset, pofs, nofs; @@ -373,7 +365,7 @@ __dump_and_attach_handler(tc, reg_dir, reg_out, reg_in, reg_pwr, nset = 4; pofs = nofs = i; } - + if (ISSET(reg_dir, i)) { #if defined TX39IO_MFIOOUTPORT_ON || defined TX39IO_MFIOOUTPORT_OFF txreg_t reg; diff --git a/sys/arch/hpcmips/tx/tx39power.c b/sys/arch/hpcmips/tx/tx39power.c index df5c576ce1e7..4744cb1467ff 100644 --- a/sys/arch/hpcmips/tx/tx39power.c +++ b/sys/arch/hpcmips/tx/tx39power.c @@ -1,7 +1,11 @@ -/* $NetBSD: tx39power.c,v 1.6 2000/05/22 17:17:44 uch Exp $ */ +/* $NetBSD: tx39power.c,v 1.7 2000/10/04 13:53:56 uch Exp $ */ /*- - * Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved. + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,24 +15,29 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #include "opt_tx39_debug.h" #include "opt_tx39powerdebug.h" -#include "opt_ddb.h" #include #include @@ -36,49 +45,51 @@ #include #include +#include #include #include #include #include -#include +#define ISSET(x, v) ((x) & (v)) +#define ISSETPRINT(r, m) __is_set_print(r, TX39_POWERCTRL_##m, #m) -#undef POWERBUTTON_IS_DEBUGGER - -#define ISSET(x, v) ((x) & (v)) -#define ISSETPRINT(r, m) __is_set_print(r, TX39_POWERCTRL_##m, #m) - -int tx39power_match __P((struct device*, struct cfdata*, void*)); -void tx39power_attach __P((struct device*, struct device*, void*)); - -int tx39power_intr __P((void*)); -int tx39power_ok_intr __P((void*)); -int tx39power_button_intr __P((void*)); +int tx39power_match(struct device *, struct cfdata *, void *); +void tx39power_attach(struct device *, struct device *, void *); struct tx39power_softc { struct device sc_dev; tx_chipset_tag_t sc_tc; + + /* save interrupt status for resume */ + txreg_t sc_icu_state[TX39_INTRSET_MAX + 1]; }; struct cfattach tx39power_ca = { sizeof(struct tx39power_softc), tx39power_match, tx39power_attach }; +void tx39power_suspend_cpu(void); /* automatic hardware resume */ + +static int tx39power_intr_p(void *); +static int tx39power_intr_n(void *); +static int tx39power_ok_intr_p(void *); +static int tx39power_ok_intr_n(void *); +static int tx39power_button_intr_p(void *); +static int tx39power_button_intr_n(void *); +#ifdef TX39POWERDEBUG +static void tx39power_dump(struct tx39power_softc *); +#endif + int -tx39power_match(parent, cf, aux) - struct device *parent; - struct cfdata *cf; - void *aux; +tx39power_match(struct device *parent, struct cfdata *cf, void *aux) { return 2; /* 1st attach group of txsim */ } void -tx39power_attach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; +tx39power_attach(struct device *parent, struct device *self, void *aux) { struct txsim_attach_args *ta = aux; struct tx39power_softc *sc = (void*)self; @@ -90,6 +101,167 @@ tx39power_attach(parent, self, aux) printf("\n"); #ifdef TX39POWERDEBUG + __tx39power_dump (sc); +#endif + /* + * Disable SPI module + */ + reg = tx_conf_read(tc, TX39_SPICTRL_REG); + if (ISSET(reg, TX39_SPICTRL_ENSPI)) { + reg &= ~TX39_SPICTRL_ENSPI; + } + printf("SPI module disabled\n"); + + /* + * enable stop timer + */ + reg = tx_conf_read(tc, TX39_POWERCTRL_REG); + + reg &= ~(TX39_POWERCTRL_STPTIMERVAL_MASK << + TX39_POWERCTRL_STPTIMERVAL_SHIFT); + reg = TX39_POWERCTRL_STPTIMERVAL_SET(reg, 1); + + reg |= TX39_POWERCTRL_ENSTPTIMER; + tx_conf_write(tc, TX39_POWERCTRL_REG, reg); + + tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_POSPWRINT), + IST_EDGE, IPL_CLOCK, + tx39power_intr_p, sc); + tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_NEGPWRINT), + IST_EDGE, IPL_CLOCK, + tx39power_intr_n, sc); + tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_POSPWROKINT), + IST_EDGE, IPL_CLOCK, + tx39power_ok_intr_p, sc); + tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_NEGPWROKINT), + IST_EDGE, IPL_CLOCK, + tx39power_ok_intr_n, sc); + tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_POSONBUTNINT), + IST_EDGE, IPL_CLOCK, + tx39power_button_intr_p, sc); + tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_NEGONBUTNINT), + IST_EDGE, IPL_CLOCK, + tx39power_button_intr_n, sc); +} + +void +tx39power_suspend_cpu() /* I assume already splhigh */ +{ + tx_chipset_tag_t tc = tx_conf_get_tag(); + struct tx39power_softc *sc = tc->tc_powert; + txreg_t reg, *iregs = sc->sc_icu_state; + + printf ("%s: CPU sleep\n", sc->sc_dev.dv_xname); + __asm__ __volatile__(".set noreorder"); + reg = tx_conf_read(tc, TX39_POWERCTRL_REG); + reg |= TX39_POWERCTRL_STOPCPU; +#ifdef TX392X + reg |= TX39_POWERCTRL_WARMSTART; +#endif + /* save interrupt state */ + iregs[0] = tx_conf_read(tc, TX39_INTRENABLE6_REG); + iregs[1] = tx_conf_read(tc, TX39_INTRENABLE1_REG); + iregs[2] = tx_conf_read(tc, TX39_INTRENABLE2_REG); + iregs[3] = tx_conf_read(tc, TX39_INTRENABLE3_REG); + iregs[4] = tx_conf_read(tc, TX39_INTRENABLE4_REG); + iregs[5] = tx_conf_read(tc, TX39_INTRENABLE5_REG); +#ifdef TX392X + iregs[7] = tx_conf_read(tc, TX39_INTRENABLE7_REG); + iregs[8] = tx_conf_read(tc, TX39_INTRENABLE8_REG); +#endif + /* disable all interrupt (don't disable GLOBALEN) */ + tx_conf_write(tc, TX39_INTRENABLE6_REG, TX39_INTRENABLE6_GLOBALEN); + tx_conf_write(tc, TX39_INTRENABLE1_REG, 0); + tx_conf_write(tc, TX39_INTRENABLE2_REG, 0); + tx_conf_write(tc, TX39_INTRENABLE3_REG, 0); + tx_conf_write(tc, TX39_INTRENABLE4_REG, 0); + tx_conf_write(tc, TX39_INTRENABLE5_REG, 0); +#ifdef TX392X + tx_conf_write(tc, TX39_INTRENABLE7_REG, 0); + tx_conf_write(tc, TX39_INTRENABLE8_REG, 0); +#endif + /* enable power button interrupt only */ + tx_conf_write(tc, TX39_INTRCLEAR5_REG, TX39_INTRSTATUS5_NEGONBUTNINT); + tx_conf_write(tc, TX39_INTRENABLE5_REG, TX39_INTRSTATUS5_NEGONBUTNINT); + __asm__ __volatile__("sync"); + + /* stop CPU clock */ + tx_conf_write(tc, TX39_POWERCTRL_REG, reg); + __asm__ __volatile__("sync"); + /* wait until power button pressed */ + /* clear interrupt */ + tx_conf_write(tc, TX39_INTRCLEAR5_REG, TX39_INTRSTATUS5_NEGONBUTNINT); + + /* restore interrupt state */ + tx_conf_write(tc, TX39_INTRENABLE6_REG, iregs[0]); + tx_conf_write(tc, TX39_INTRENABLE1_REG, iregs[1]); + tx_conf_write(tc, TX39_INTRENABLE2_REG, iregs[2]); + tx_conf_write(tc, TX39_INTRENABLE3_REG, iregs[3]); + tx_conf_write(tc, TX39_INTRENABLE4_REG, iregs[4]); + tx_conf_write(tc, TX39_INTRENABLE5_REG, iregs[5]); +#ifdef TX392X + tx_conf_write(tc, TX39_INTRENABLE7_REG, iregs[7]); + tx_conf_write(tc, TX39_INTRENABLE8_REG, iregs[8]); +#endif + __asm__ __volatile__(".set reorder"); + + printf ("%s: CPU wakeup\n", sc->sc_dev.dv_xname); +} + +static int +tx39power_button_intr_p(void *arg) +{ + config_hook_call(CONFIG_HOOK_BUTTONEVENT, + CONFIG_HOOK_BUTTONEVENT_POWER, + (void *)1 /* on */); + return 0; +} + +static int +tx39power_button_intr_n(void *arg) +{ + config_hook_call(CONFIG_HOOK_BUTTONEVENT, + CONFIG_HOOK_BUTTONEVENT_POWER, + (void *)0 /* off */); + return 0; +} + +int +tx39power_intr_p(void *arg) +{ + printf("power_p\n"); + return 0; +} + +static int +tx39power_intr_n(void *arg) +{ + printf("power_n\n"); + return 0; +} + +static int +tx39power_ok_intr_p(void *arg) +{ + printf("power NG\n"); + config_hook_call(CONFIG_HOOK_PMEVENT, + CONFIG_HOOK_PMEVENT_SUSPENDREQ, NULL); + return 0; +} + +static int +tx39power_ok_intr_n(void *arg) +{ + printf("power OK\n"); + return 0; +} + +#ifdef TX39POWERDEBUG +static void +__tx39power_dump (struct tx39power_softc *sc) +{ + tx_chipset_tag_t tc = sc->sc_tc; + reg = tx_conf_read(tc, TX39_POWERCTRL_REG); ISSETPRINT(reg, ONBUTN); ISSETPRINT(reg, PWRINT); @@ -120,88 +292,6 @@ tx39power_attach(parent, self, aux) #endif /* TX391X */ printf("STPTIMERVAL=%d ", TX39_POWERCTRL_STPTIMERVAL(reg)); printf("\n"); +} #endif /* TX39POWERDEBUG */ -#ifdef DISABLE_SPI_AND_DOZE /* XXX test XXX */ - /* - * Disable SPI module - */ - reg = tx_conf_read(tc, TX39_SPICTRL_REG); - if (ISSET(reg, TX39_SPICTRL_ENSPI)) { - reg &= ~TX39_SPICTRL_ENSPI; - } - printf("SPI module disabled\n"); - /* - * Disable Stop timer (Doze CPU mode) - */ - reg = tx_conf_read(tc, TX39_POWERCTRL_REG); - printf("STPTIMER disabled.\n"); - reg &= ~TX39_POWERCTRL_ENSTPTIMER; - tx_conf_write(tc, TX39_POWERCTRL_REG, reg); -#endif /* DISABLE_SPI_AND_DOZE */ - - /* - * enable stop timer - */ - reg = tx_conf_read(tc, TX39_POWERCTRL_REG); - - reg &= ~(TX39_POWERCTRL_STPTIMERVAL_MASK << - TX39_POWERCTRL_STPTIMERVAL_SHIFT); - reg = TX39_POWERCTRL_STPTIMERVAL_SET(reg, 1); - - reg |= TX39_POWERCTRL_ENSTPTIMER; - tx_conf_write(tc, TX39_POWERCTRL_REG, reg); - - tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_POSPWRINT), - IST_EDGE, IPL_CLOCK, - tx39power_intr, sc); - tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_NEGPWRINT), - IST_EDGE, IPL_CLOCK, - tx39power_intr, sc); - tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_POSPWROKINT), - IST_EDGE, IPL_CLOCK, - tx39power_ok_intr, sc); - tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_NEGPWROKINT), - IST_EDGE, IPL_CLOCK, - tx39power_ok_intr, sc); -#if 0 - tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_POSONBUTNINT), - IST_EDGE, IPL_CLOCK, - tx39power_button_intr, sc); -#endif - tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_NEGONBUTNINT), - IST_EDGE, IPL_CLOCK, - tx39power_button_intr, sc); - -} - -int -tx39power_button_intr(arg) - void *arg; -{ - struct tx39power_softc *sc = arg; - - if (sc->sc_tc->tc_videot) - video_calibration_pattern(sc->sc_tc->tc_videot); /* debug */ - -#if defined DDB && defined POWERBUTTON_IS_DEBUGGER - cpu_Debugger(); -#endif - return 0; -} - -int -tx39power_intr(arg) - void *arg; -{ - printf("power\n"); - return 0; -} - -int -tx39power_ok_intr(arg) - void *arg; -{ - printf("power NG\n"); - return 0; -} diff --git a/sys/arch/hpcmips/tx/tx39powerreg.h b/sys/arch/hpcmips/tx/tx39powerreg.h index 15a3b7f582e3..8dff2b6f0493 100644 --- a/sys/arch/hpcmips/tx/tx39powerreg.h +++ b/sys/arch/hpcmips/tx/tx39powerreg.h @@ -1,30 +1,41 @@ -/* $NetBSD: tx39powerreg.h,v 1.1 1999/11/20 19:56:36 uch Exp $ */ +/* $NetBSD: tx39powerreg.h,v 1.2 2000/10/04 13:53:56 uch Exp $ */ -/* - * Copyright (c) 1999, by UCHIYAMA Yasushi +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * 2. The name of the developer may NOT be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + /* * TOSHIBA TX3912/3922 Power module */ diff --git a/sys/arch/hpcmips/tx/tx39var.h b/sys/arch/hpcmips/tx/tx39var.h index 6ec0c9776d8b..472ae79fe786 100644 --- a/sys/arch/hpcmips/tx/tx39var.h +++ b/sys/arch/hpcmips/tx/tx39var.h @@ -1,7 +1,11 @@ -/* $NetBSD: tx39var.h,v 1.6 2000/05/22 17:17:44 uch Exp $ */ +/* $NetBSD: tx39var.h,v 1.7 2000/10/04 13:53:56 uch Exp $ */ /*- - * Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved. + * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by UCHIYAMA Yasushi. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -11,19 +15,25 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ struct tx_chipset_tag { @@ -38,12 +48,12 @@ struct tx_chipset_tag { typedef struct tx_chipset_tag* tx_chipset_tag_t; typedef u_int32_t txreg_t; -void tx_conf_register_intr __P((tx_chipset_tag_t, void*)); -void tx_conf_register_power __P((tx_chipset_tag_t, void*)); -void tx_conf_register_clock __P((tx_chipset_tag_t, void*)); -void tx_conf_register_sound __P((tx_chipset_tag_t, void*)); -void tx_conf_register_ioman __P((tx_chipset_tag_t, void*)); -void tx_conf_register_video __P((tx_chipset_tag_t, void*)); +void tx_conf_register_intr(tx_chipset_tag_t, void *); +void tx_conf_register_power(tx_chipset_tag_t, void *); +void tx_conf_register_clock(tx_chipset_tag_t, void *); +void tx_conf_register_sound(tx_chipset_tag_t, void *); +void tx_conf_register_ioman(tx_chipset_tag_t, void *); +void tx_conf_register_video(tx_chipset_tag_t, void *); /* * TX39 Internal Function Register access @@ -51,21 +61,17 @@ void tx_conf_register_video __P((tx_chipset_tag_t, void*)); #define TX39_SYSADDR_CONFIG_REG_KSEG1 0xb0c00000 #ifdef TX39_PREFER_FUNCTION - -tx_chipset_tag_t tx_conf_get_tag __P((void)); -u_int32_t tx_conf_read __P((tx_chipset_tag_t, int)); -void tx_conf_write __P((tx_chipset_tag_t, int, txreg_t)); - +tx_chipset_tag_t tx_conf_get_tag(void); +u_int32_t tx_conf_read(tx_chipset_tag_t, int); +void tx_conf_write(tx_chipset_tag_t, int, txreg_t); #else /* TX39_PREFER_FUNCTION */ - extern struct tx_chipset_tag tx_chipset; -#define tx_conf_read(t, reg) ((void)(t), \ - (*((volatile txreg_t*)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))))) -#define tx_conf_write(t, reg, val) ((void)(t), \ - (*((volatile txreg_t*)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))) \ +#define tx_conf_read(t, reg) ((void)(t), \ + (*((volatile txreg_t *)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))))) +#define tx_conf_write(t, reg, val) ((void)(t), \ + (*((volatile txreg_t *)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))) \ = (val))) #define tx_conf_get_tag() (&tx_chipset) - #endif /* TX39_PREFER_FUNCTION */ /* @@ -85,22 +91,27 @@ struct txsim_attach_args { /* * Interrupt staff */ -#define MAKEINTR(s, b) ((s) * 32 + (ffs(b) - 1)) -void* tx_intr_establish __P((tx_chipset_tag_t, int, int, int, - int (*) __P((void*)), void*)); -void tx_intr_disestablish __P((tx_chipset_tag_t, void*)); +#define MAKEINTR(s, b) ((s) * 32 + (ffs(b) - 1)) +void* tx_intr_establish(tx_chipset_tag_t, int, int, int, int (*)(void *), + void *); +void tx_intr_disestablish(tx_chipset_tag_t, void *); #ifdef USE_POLL -void* tx39_poll_establish __P((tx_chipset_tag_t, int, int, - int (*) __P((void*)), void*)); -void tx39_poll_disestablish __P((tx_chipset_tag_t, void*)); +void* tx39_poll_establish(tx_chipset_tag_t, int, int, int (*)(void *), + void *); +void tx39_poll_disestablish(tx_chipset_tag_t, void *); #define POLL_CONT 0 #define POLL_END 1 #endif /* USE_POLL */ -u_int32_t tx_intr_status __P((tx_chipset_tag_t, int)); +u_int32_t tx_intr_status(tx_chipset_tag_t, int); extern u_int32_t tx39intrvec; +/* + * Power management staff + */ +void tx39power_suspend_cpu(void); + #ifdef TX39_DEBUG extern u_int32_t tx39debugflag; /* @@ -139,4 +150,4 @@ extern u_int32_t tx39debugflag; #define bitdisp(a) #endif /* TX39_DEBUG */ -int __is_set_print __P((u_int32_t, int, char*)); +int __is_set_print(u_int32_t, int, char *);