diff --git a/sys/dev/pcmcia/com_pcmcia.c b/sys/dev/pcmcia/com_pcmcia.c index f4d93ea6d0a5..57cd2d78546b 100644 --- a/sys/dev/pcmcia/com_pcmcia.c +++ b/sys/dev/pcmcia/com_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: com_pcmcia.c,v 1.42 2004/08/09 17:00:53 mycroft Exp $ */ +/* $NetBSD: com_pcmcia.c,v 1.43 2004/08/09 18:30:51 mycroft Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: com_pcmcia.c,v 1.42 2004/08/09 17:00:53 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: com_pcmcia.c,v 1.43 2004/08/09 18:30:51 mycroft Exp $"); #include #include @@ -116,8 +116,6 @@ void com_pcmcia_cleanup __P((void *)); int com_pcmcia_enable __P((struct com_softc *)); void com_pcmcia_disable __P((struct com_softc *)); -int com_pcmcia_enable1 __P((struct com_softc *)); -void com_pcmcia_disable1 __P((struct com_softc *)); struct com_pcmcia_softc { struct com_softc sc_com; /* real "com" softc */ @@ -340,42 +338,28 @@ com_pcmcia_enable(sc) if (psc->sc_ih == NULL) { printf("%s: couldn't establish interrupt\n", sc->sc_dev.dv_xname); - return 1; + return (1); } - if ((error = com_pcmcia_enable1(sc)) != 0) { + if ((error = pcmcia_function_enable(pf)) != 0) { pcmcia_intr_disestablish(pf, psc->sc_ih); - return error; + return (error); } - return 0; -} - -int -com_pcmcia_enable1(sc) - struct com_softc *sc; -{ - struct com_pcmcia_softc *psc = (struct com_pcmcia_softc *) sc; - struct pcmcia_function *pf = psc->sc_pf; - int ret; - - if ((ret = pcmcia_function_enable(pf)) != 0) - return ret; - if ((psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3C562) || (psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3CXEM556) || (psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3CXEM556INT)) { int reg; /* turn off the ethernet-disable bit */ - reg = pcmcia_ccr_read(pf, PCMCIA_CCR_OPTION); if (reg & 0x08) { reg &= ~0x08; pcmcia_ccr_write(pf, PCMCIA_CCR_OPTION, reg); } } - return ret; + + return (0); } void @@ -384,15 +368,6 @@ com_pcmcia_disable(sc) { struct com_pcmcia_softc *psc = (struct com_pcmcia_softc *) sc; - pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); - com_pcmcia_disable1(sc); -} - -void -com_pcmcia_disable1(sc) - struct com_softc *sc; -{ - struct com_pcmcia_softc *psc = (struct com_pcmcia_softc *) sc; - pcmcia_function_disable(psc->sc_pf); + pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); } diff --git a/sys/dev/pcmcia/if_ep_pcmcia.c b/sys/dev/pcmcia/if_ep_pcmcia.c index 6fde4e0010e5..658f55f904ef 100644 --- a/sys/dev/pcmcia/if_ep_pcmcia.c +++ b/sys/dev/pcmcia/if_ep_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ep_pcmcia.c,v 1.45 2004/08/09 18:11:01 mycroft Exp $ */ +/* $NetBSD: if_ep_pcmcia.c,v 1.46 2004/08/09 18:30:51 mycroft Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ep_pcmcia.c,v 1.45 2004/08/09 18:11:01 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ep_pcmcia.c,v 1.46 2004/08/09 18:30:51 mycroft Exp $"); #include #include @@ -105,7 +105,6 @@ int ep_pcmcia_get_enaddr __P((struct pcmcia_tuple *, void *)); int ep_pcmcia_enable __P((struct ep_softc *)); void ep_pcmcia_disable __P((struct ep_softc *)); -int ep_pcmcia_enable1 __P((struct ep_softc *)); void ep_pcmcia_disable1 __P((struct ep_softc *)); struct ep_pcmcia_softc { @@ -188,25 +187,11 @@ ep_pcmcia_enable(sc) return (1); } - if ((error = ep_pcmcia_enable1(sc)) != 0) { + if ((error = pcmcia_function_enable(pf))) { pcmcia_intr_disestablish(pf, sc->sc_ih); - return error; + return (error); } - return 0; -} - -int -ep_pcmcia_enable1(sc) - struct ep_softc *sc; -{ - struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc; - struct pcmcia_function *pf = psc->sc_pf; - int ret; - - if ((ret = pcmcia_function_enable(pf))) - return (ret); - if ((psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3C562) || (psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3CXEM556) || (psc->sc_pf->sc->card.product == PCMCIA_PRODUCT_3COM_3CXEM556INT)) { @@ -222,7 +207,7 @@ ep_pcmcia_enable1(sc) } - return (ret); + return (0); } void @@ -231,22 +216,8 @@ ep_pcmcia_disable(sc) { struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc; - /* - * We must disestablish the interrupt before disabling the function, - * because on a multifunction card the interrupt disestablishment - * accesses CCR registers. - */ - pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih); - ep_pcmcia_disable1(sc); -} - -void -ep_pcmcia_disable1(sc) - struct ep_softc *sc; -{ - struct ep_pcmcia_softc *psc = (struct ep_pcmcia_softc *) sc; - pcmcia_function_disable(psc->sc_pf); + pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih); } void diff --git a/sys/dev/pcmcia/if_sm_pcmcia.c b/sys/dev/pcmcia/if_sm_pcmcia.c index eca30dea6c1a..b20def820c02 100644 --- a/sys/dev/pcmcia/if_sm_pcmcia.c +++ b/sys/dev/pcmcia/if_sm_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_sm_pcmcia.c,v 1.36 2004/08/08 23:17:13 mycroft Exp $ */ +/* $NetBSD: if_sm_pcmcia.c,v 1.37 2004/08/09 18:30:51 mycroft Exp $ */ /*- * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_sm_pcmcia.c,v 1.36 2004/08/08 23:17:13 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_sm_pcmcia.c,v 1.37 2004/08/09 18:30:51 mycroft Exp $"); #include #include @@ -285,10 +285,6 @@ sm_pcmcia_enable(sc) struct sm_pcmcia_softc *psc = (struct sm_pcmcia_softc *)sc; int rv; - rv = pcmcia_function_enable(psc->sc_pf); - if (rv != 0) - return (rv); - /* Establish the interrupt handler. */ psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, smc91cxx_intr, sc); @@ -297,6 +293,13 @@ sm_pcmcia_enable(sc) sc->sc_dev.dv_xname); return (1); } + + rv = pcmcia_function_enable(psc->sc_pf); + if (rv != 0) { + pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); + return (rv); + } + return (0); } @@ -306,6 +309,6 @@ sm_pcmcia_disable(sc) { struct sm_pcmcia_softc *psc = (struct sm_pcmcia_softc *)sc; - pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); pcmcia_function_disable(psc->sc_pf); + pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih); } diff --git a/sys/dev/pcmcia/if_wi_pcmcia.c b/sys/dev/pcmcia/if_wi_pcmcia.c index a11da60f0545..451e61c02a7f 100644 --- a/sys/dev/pcmcia/if_wi_pcmcia.c +++ b/sys/dev/pcmcia/if_wi_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wi_pcmcia.c,v 1.50 2004/08/09 18:11:01 mycroft Exp $ */ +/* $NetBSD: if_wi_pcmcia.c,v 1.51 2004/08/09 18:30:51 mycroft Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wi_pcmcia.c,v 1.50 2004/08/09 18:11:01 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wi_pcmcia.c,v 1.51 2004/08/09 18:30:51 mycroft Exp $"); #include #include @@ -314,8 +314,8 @@ wi_pcmcia_disable(sc) { struct wi_pcmcia_softc *psc = (struct wi_pcmcia_softc *)sc; - pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih); pcmcia_function_disable(psc->sc_pf); + pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih); } static void diff --git a/sys/dev/pcmcia/mhzc.c b/sys/dev/pcmcia/mhzc.c index f9c8712168b0..55b1aee29071 100644 --- a/sys/dev/pcmcia/mhzc.c +++ b/sys/dev/pcmcia/mhzc.c @@ -1,4 +1,4 @@ -/* $NetBSD: mhzc.c,v 1.21 2004/08/09 18:11:01 mycroft Exp $ */ +/* $NetBSD: mhzc.c,v 1.22 2004/08/09 18:30:51 mycroft Exp $ */ /*- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. @@ -46,7 +46,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mhzc.c,v 1.21 2004/08/09 18:11:01 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mhzc.c,v 1.22 2004/08/09 18:30:51 mycroft Exp $"); #include "opt_inet.h" #include "opt_ns.h" @@ -504,8 +504,8 @@ mhzc_disable(sc, flag) if ((sc->sc_flags & (MHZC_MODEM_ENABLED|MHZC_ETHERNET_ENABLED)) != 0) return; - pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); pcmcia_function_disable(sc->sc_pf); + pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); } /***************************************************************************** diff --git a/sys/dev/pcmcia/pcmcia.c b/sys/dev/pcmcia/pcmcia.c index 2d6a49f712d1..4d04231181a0 100644 --- a/sys/dev/pcmcia/pcmcia.c +++ b/sys/dev/pcmcia/pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcmcia.c,v 1.47 2004/08/09 16:59:10 mycroft Exp $ */ +/* $NetBSD: pcmcia.c,v 1.48 2004/08/09 18:30:51 mycroft Exp $ */ /* * Copyright (c) 2004 Charles M. Hannum. All rights reserved. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcmcia.c,v 1.47 2004/08/09 16:59:10 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcmcia.c,v 1.48 2004/08/09 18:30:51 mycroft Exp $"); #include "opt_pcmciaverbose.h" @@ -584,6 +584,7 @@ pcmcia_function_disable(pf) struct pcmcia_function *pf; { struct pcmcia_function *tmp; + int reg; if (pf->cfe == NULL) panic("pcmcia_function_enable: function not initialized"); @@ -595,6 +596,14 @@ pcmcia_function_disable(pf) goto out; } + if (pcmcia_mfc(pf->sc)) { + reg = pcmcia_ccr_read(pf, PCMCIA_CCR_OPTION); + reg &= ~(PCMCIA_CCR_OPTION_FUNC_ENABLE| + PCMCIA_CCR_OPTION_ADDR_DECODE| + PCMCIA_CCR_OPTION_IREQ_ENABLE); + pcmcia_ccr_write(pf, PCMCIA_CCR_OPTION, reg); + } + /* * it's possible for different functions' CCRs to be in the same * underlying page. Check for that. Note we mark us as disabled @@ -864,9 +873,11 @@ pcmcia_intr_disestablish(pf, ih) pcmcia_chip_intr_disestablish(pf->sc->pct, pf->sc->pch, pf->sc->ih); - reg = pcmcia_ccr_read(pf, PCMCIA_CCR_OPTION); - reg &= ~PCMCIA_CCR_OPTION_IREQ_ENABLE; - pcmcia_ccr_write(pf, PCMCIA_CCR_OPTION, reg); + if (pf->pf_flags & PFF_ENABLED) { + reg = pcmcia_ccr_read(pf, PCMCIA_CCR_OPTION); + reg &= ~PCMCIA_CCR_OPTION_IREQ_ENABLE; + pcmcia_ccr_write(pf, PCMCIA_CCR_OPTION, reg); + } pf->ih_fct = NULL; pf->ih_arg = NULL; diff --git a/sys/dev/pcmcia/xirc.c b/sys/dev/pcmcia/xirc.c index 55bfc0f657f5..ced8e3dc9fbd 100644 --- a/sys/dev/pcmcia/xirc.c +++ b/sys/dev/pcmcia/xirc.c @@ -1,4 +1,4 @@ -/* $NetBSD: xirc.c,v 1.5 2004/08/09 18:11:01 mycroft Exp $ */ +/* $NetBSD: xirc.c,v 1.6 2004/08/09 18:30:51 mycroft Exp $ */ /*- * Copyright (c) 1999, 2000, 2004 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xirc.c,v 1.5 2004/08/09 18:11:01 mycroft Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xirc.c,v 1.6 2004/08/09 18:30:51 mycroft Exp $"); #include "opt_inet.h" #include "opt_ns.h" @@ -553,8 +553,8 @@ xirc_disable(sc, flag, media) if ((sc->sc_flags & (XIRC_MODEM_ENABLED|XIRC_ETHERNET_ENABLED)) != 0) return; - pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); pcmcia_function_disable(sc->sc_pf); + pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih); } /****** Here begins the com attachment code. ******/