Date: Mon, 19 Nov 2001 17:11:29 +0900 (JST) From: YAMAMOTO Shigeru <shigeru@iij.ad.jp> To: freebsd-mobile@freebsd.org Cc: freebsd-current@freebsd.org Subject: 2 patches for NEWCARD Message-ID: <20011119.171129.72757009.shigeru@iij.ad.jp>
next in thread | raw e-mail | index | archive | help
----Next_Part(Mon_Nov_19_17:11:29_2001_257)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi all,
I make 2 patches for NEWCARD.
one is to supoort to suspend/resume PC Card devices on NEWCARD.
other is to ignore ghost interrupt at ed driver when removing PC Card.
It is a quick hack and I only tested on my NotePC, Sony VAIO 818.
So I don't know my patches work fine on other NotePC.
Please try if you have interest to my patches.
Thanks,
-------
YAMAMOTO Shigeru <shigeru@iij.ad.jp>
----Next_Part(Mon_Nov_19_17:11:29_2001_257)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="cb.diff"
Index: sys/dev/pccbb/pccbb.c
===================================================================
RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/pccbb/pccbb.c,v
retrieving revision 1.27
diff -u -r1.27 pccbb.c
--- sys/dev/pccbb/pccbb.c 3 Nov 2001 16:45:31 -0000 1.27
+++ sys/dev/pccbb/pccbb.c 18 Nov 2001 19:37:52 -0000
@@ -2096,14 +2096,112 @@
b, s, f, reg, val, width);
}
+static
+int
+pccbb_suspend(device_t dev) {
+ int error = 0;
+ struct pccbb_softc* sc = device_get_softc(dev);
+ int numdevs;
+ device_t* devlist;
+ int tmp;
+
+ bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intrhand);
+
+ device_get_children(dev, &devlist, &numdevs);
+
+ error = 0;
+ for (tmp = 0; tmp < numdevs; tmp++) {
+ if (device_detach(devlist[tmp]) == 0) {
+ device_delete_child(dev, devlist[tmp]);
+ }
+ else {
+ error++;
+ }
+ }
+ free(devlist, M_TEMP);
+ if (error > 0) {
+ return ENXIO;
+ }
+
+ sc->sc_cbdev = NULL;
+ sc->sc_pccarddev = NULL;
+
+ return(error);
+}
+
+static
+int
+pccbb_resume(device_t self)
+{
+ int error = 0;
+ struct pccbb_softc *sc = (struct pccbb_softc *)device_get_softc(self);
+
+ pci_write_config(self, PCCBBR_SOCKBASE,
+ rman_get_start(sc->sc_base_res), 4);
+ DEVPRINTF((self, "PCI Memory allocated: %08lx\n",
+ rman_get_start(sc->sc_base_res)));
+
+ pccbb_chipinit(sc);
+
+ /* CSC Interrupt: Card detect interrupt on */
+ sc->sc_socketreg->socket_mask |= PCCBB_SOCKET_MASK_CD;
+
+ /* reset interrupt */
+ {
+ u_int32_t tmp;
+
+ tmp = sc->sc_socketreg->socket_event;
+ sc->sc_socketreg->socket_event = tmp;
+ }
+
+ /* establish the interrupt. */
+ if (bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO, pccbb_intr, sc,
+ &(sc->sc_intrhand))) {
+ device_printf(self, "couldn't establish interrupt");
+ bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
+ bus_release_resource(self, SYS_RES_MEMORY, PCCBBR_SOCKBASE,
+ sc->sc_base_res);
+ mtx_destroy(&sc->sc_mtx);
+ error = ENOMEM;
+ }
+
+ /* attach children */
+ if (!error) {
+ sc->sc_cbdev = device_add_child(self, "cardbus", -1);
+ if (sc->sc_cbdev == NULL)
+ DEVPRINTF((self, "WARNING: cannot add cardbus bus.\n"));
+ else if (device_probe_and_attach(sc->sc_cbdev) != 0) {
+ DEVPRINTF((self, "WARNING: cannot attach cardbus bus!\n"));
+ sc->sc_cbdev = NULL;
+ }
+
+ sc->sc_pccarddev = device_add_child(self, "pccard", -1);
+ if (sc->sc_pccarddev == NULL)
+ DEVPRINTF((self, "WARNING: cannot add pccard bus.\n"));
+ else if (device_probe_and_attach(sc->sc_pccarddev) != 0) {
+ DEVPRINTF((self, "WARNING: cannot attach pccard bus.\n"));
+ sc->sc_pccarddev = NULL;
+ }
+ }
+
+ /* wakeup thread */
+ if (!error) {
+ mtx_lock(&sc->sc_mtx);
+ wakeup(sc);
+ mtx_unlock(&sc->sc_mtx);
+ }
+
+ return(error);
+}
+
static device_method_t pccbb_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pccbb_probe),
DEVMETHOD(device_attach, pccbb_attach),
DEVMETHOD(device_detach, pccbb_detach),
DEVMETHOD(device_shutdown, pccbb_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
+ DEVMETHOD(device_suspend, pccbb_suspend),
+ DEVMETHOD(device_resume, pccbb_resume),
/* bus methods */
DEVMETHOD(bus_print_child, bus_generic_print_child),
----Next_Part(Mon_Nov_19_17:11:29_2001_257)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="ed.diff"
Index: sys/dev/ed/if_ed.c
===================================================================
RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/ed/if_ed.c,v
retrieving revision 1.206
diff -u -r1.206 if_ed.c
--- sys/dev/ed/if_ed.c 4 Nov 2001 22:56:20 -0000 1.206
+++ sys/dev/ed/if_ed.c 11 Nov 2001 15:25:52 -0000
@@ -2296,7 +2296,7 @@
/*
* loop until there are no more new interrupts
*/
- while ((isr = ed_nic_inb(sc, ED_P0_ISR)) != 0) {
+ while ((isr = ed_nic_inb(sc, ED_P0_ISR)) != 0 && isr != 0xff) {
/*
* reset all the bits that we are 'acknowledging' by writing a
----Next_Part(Mon_Nov_19_17:11:29_2001_257)----
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011119.171129.72757009.shigeru>
