diff options
author | Warner Losh <imp@FreeBSD.org> | 1999-11-28 21:11:13 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 1999-11-28 21:11:13 +0000 |
commit | f27f6c00760337dbbf7ee8b69f7694aa57a90626 (patch) | |
tree | 52d743179f69be997ac98b30269f250e0b1e3a0b | |
parent | 4fe1353de0b0435d0d82a5feb224ce742373bff9 (diff) | |
download | src-f27f6c00760337dbbf7ee8b69f7694aa57a90626.tar.gz src-f27f6c00760337dbbf7ee8b69f7694aa57a90626.zip |
Add resource activation routines to pcic driver. Minor cleanup of
socket attach code. We now have at least a chance for pccard devices
appearing in the future.
This is a snapshot of ongoing work. Proceed at your own risk.
Notes
Notes:
svn path=/head/; revision=53855
-rw-r--r-- | sys/dev/pccard/card_if.m | 56 | ||||
-rw-r--r-- | sys/dev/pccard/power_if.m | 53 | ||||
-rw-r--r-- | sys/dev/pcic/i82365.c | 53 | ||||
-rw-r--r-- | sys/dev/pcic/i82365_isa.c | 24 | ||||
-rw-r--r-- | sys/dev/pcic/i82365var.h | 12 | ||||
-rw-r--r-- | sys/modules/pccard/Makefile | 2 | ||||
-rw-r--r-- | sys/modules/pcic/Makefile | 2 |
7 files changed, 169 insertions, 33 deletions
diff --git a/sys/dev/pccard/card_if.m b/sys/dev/pccard/card_if.m new file mode 100644 index 000000000000..256ec7e3ee64 --- /dev/null +++ b/sys/dev/pccard/card_if.m @@ -0,0 +1,56 @@ +# +# Copyright (c) 1999 M. Warner Losh. +# All rights reserved. +# +# 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. 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. +# +# 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. +# +# $FreeBSD$ +# + +INTERFACE card; + +# +# Companion interface for pccard. We need to set attributes for memory +# and i/o port mappings (as well as other types of attributes) that have +# a well defined meaning inside the pccard/cardbus system. The bus +# methods are inadequate for this because this must be done at the time the +# resources are set for the device, which predates their activation. Also, +# the driver activating the resources doesn't necessarily know or need to know +# these attributes. +# +# XXX A nagging doubt in the back of my mind suggests that these sorts of +# XXX things might be able to be done with ivars. This nagging doubt doesn't +# XXX offer a good way to actually do this, but remains nonetheless. +# +METHOD int set_resource_attribute { + device_t dev; + device_t child; + int *rid; + u_int flags; +}; + +METHOD int get_resource_attribute { + device_t dev; + device_t child; + int rid; + u_int *flags; +}; diff --git a/sys/dev/pccard/power_if.m b/sys/dev/pccard/power_if.m new file mode 100644 index 000000000000..b77b82706876 --- /dev/null +++ b/sys/dev/pccard/power_if.m @@ -0,0 +1,53 @@ +# +# Copyright (c) 1999 M. Warner Losh. +# All rights reserved. +# +# 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. 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. +# +# 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. +# +# $FreeBSD$ +# + +INTERFACE power; + +# +# Interface for powering cards on/off. It is hoped that this will be +# generic enough to be used for other systems in addition to the pccard +# <-> pcic interface that it was originally written for. +# +METHOD int set_slot { + device_t dev; + device_t child; + int slot; + int vpp; + int vcc; +}; + +# +# Gets the current power requirements of the card. +# +METHOD int get_slot { + device_t dev; + device_t child; + int slot; + int *vpp; + int *vcc; +}; diff --git a/sys/dev/pcic/i82365.c b/sys/dev/pcic/i82365.c index caa13302234d..ccfa673b72ba 100644 --- a/sys/dev/pcic/i82365.c +++ b/sys/dev/pcic/i82365.c @@ -83,8 +83,8 @@ int pcic_debug = 0; #define PCIC_MEM_ALIGN PCIC_MEM_PAGESIZE -void pcic_attach_socket __P((struct pcic_handle *)); -void pcic_init_socket __P((struct pcic_handle *)); +static void pcic_attach_socket(device_t, struct pcic_handle *); +static void pcic_init_socket(struct pcic_handle *); #if XXX int pcic_submatch __P((struct device *, struct cfdata *, void *)); @@ -343,23 +343,19 @@ pcic_attach(device_t dev) } void -pcic_attach_sockets(sc) - struct pcic_softc *sc; +pcic_attach_sockets(device_t dev) { + struct pcic_softc *sc = (struct pcic_softc *) device_get_softc(dev); int i; for (i = 0; i < PCIC_NSLOTS; i++) if (sc->handle[i].flags & PCIC_FLAG_SOCKETP) - pcic_attach_socket(&sc->handle[i]); + pcic_attach_socket(dev, &sc->handle[i]); } void -pcic_attach_socket(h) - struct pcic_handle *h; +pcic_attach_socket(device_t dev, struct pcic_handle *h) { - struct pccardbus_attach_args paa; - struct pcic_softc *sc = (struct pcic_softc *)(h->ph_parent); - /* initialize the rest of the handle */ h->shutdown = 0; @@ -367,20 +363,19 @@ pcic_attach_socket(h) h->ioalloc = 0; h->ih_irq = 0; - /* now, config one pccard device per socket */ - - paa.paa_busname = "pccard"; - paa.pct = (pccard_chipset_tag_t) sc->pct; - paa.pch = (pccard_chipset_handle_t) h; - paa.iobase = sc->iobase; - paa.iosize = sc->iosize; - -#if XXX - h->pccard = config_found_sm(&sc->dev, &paa, pcic_print, - pcic_submatch); -#endif + /* + * now, config one pccard device per socket + * + * XXX This should add all devices that can attach to pcic, which + * is what we want in the general case. + * + * XXX Notice we don't use h AT ALL. This should be considered to + * XXX be BAD. + */ + device_add_child(dev, NULL, -1, NULL); /* if there's actually a pccard device attached, initialize the slot */ + /* XXX WE SHOULD MOVE THIS TO CHILD ATTACHED */ if (h->pccard) pcic_init_socket(h); @@ -518,7 +513,7 @@ pcic_init_socket(h) */ #ifdef DIAGNOSTIC if (h->event_thread != NULL) - panic("pcic_attach_socket: event thread"); + panic("pcic_init_socket: event thread"); #endif pcic_create_event_thread(h); @@ -1440,3 +1435,15 @@ st_pcic_write(h, idx, data) bus_space_write_1(h->ph_bus_t, h->ph_bus_h, PCIC_REG_DATA, data); } + +int pcic_activate_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + return bus_generic_activate_resource(dev, child, type, rid, r); +} + +int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + return bus_generic_deactivate_resource(dev, child, type, rid, r); +} diff --git a/sys/dev/pcic/i82365_isa.c b/sys/dev/pcic/i82365_isa.c index 85cfe949435a..ec2f7fcd9642 100644 --- a/sys/dev/pcic/i82365_isa.c +++ b/sys/dev/pcic/i82365_isa.c @@ -170,8 +170,6 @@ pcic_isa_attach(device_t dev) ((rman_get_end(sc->mem_res) - rman_get_start(sc->mem_res) + 1) / PCIC_MEM_PAGESIZE)) - 1; - sc->pct = (pccard_chipset_tag_t) & pcic_isa_functions; - sc->irq_rid = 0; sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid, 0, ~0, 1, RF_ACTIVE); @@ -210,7 +208,7 @@ pcic_isa_attach(device_t dev) rman_get_start(sc->port_res), rman_get_end(sc->port_res) - rman_get_end(sc->port_res) + 1); - pcic_attach_sockets(sc); + pcic_attach_sockets(dev); #endif return 0; error: @@ -232,14 +230,30 @@ pcic_isa_detach(device_t dev) return 0; } - - static device_method_t pcic_isa_methods[] = { /* Device interface */ DEVMETHOD(device_probe, pcic_isa_probe), DEVMETHOD(device_attach, pcic_isa_attach), DEVMETHOD(device_detach, pcic_isa_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + + /* Bus Interface */ + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_activate_resource, pcic_activate_resource), + DEVMETHOD(bus_deactivate_resource, pcic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), +#if 0 + /* pccard/cardbus interface */ + DEVMETHOD(card_set_resource_attribute, pcic_set_resource_attribute), + DEVMETHOD(card_get_resource_attribute, pcic_get_resource_attribute), + + /* Power Interface */ + /* Not yet */ +#endif { 0, 0 } }; diff --git a/sys/dev/pcic/i82365var.h b/sys/dev/pcic/i82365var.h index cb3bc76f7446..6ff967197aab 100644 --- a/sys/dev/pcic/i82365var.h +++ b/sys/dev/pcic/i82365var.h @@ -120,8 +120,6 @@ struct pcic_softc { /* XXX isa_chipset_tag_t, pci_chipset_tag_t, etc. */ void *intr_est; - pccard_chipset_tag_t pct; - /* this needs to be large enough to hold PCIC_MEM_PAGES bits */ int subregionmask; #define PCIC_MAX_MEM_PAGES (8 * sizeof(int)) @@ -151,7 +149,7 @@ int pcic_vendor __P((struct pcic_handle *)); char *pcic_vendor_to_string __P((int)); void pcic_attach(device_t dev); -void pcic_attach_sockets __P((struct pcic_softc *)); +void pcic_attach_sockets(device_t dev); int pcic_intr __P((void *arg)); int pcic_chip_mem_alloc __P((pccard_chipset_handle_t, bus_size_t, @@ -207,3 +205,11 @@ pcic_write(h, idx, data) (*(h)->ph_write)((h), (idx), (data)) #endif + +/* + * bus/device/etc routines + */ +int pcic_activate_resource(device_t dev, device_t child, int type, int rid, + struct resource *r); +int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid, + struct resource *r); diff --git a/sys/modules/pccard/Makefile b/sys/modules/pccard/Makefile index a55651991ca7..c1511fddf058 100644 --- a/sys/modules/pccard/Makefile +++ b/sys/modules/pccard/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../dev/pccard KMOD= pccard SRCS= pccard.c pccard_cis.c pccard_cis_quirks.c \ - device_if.h bus_if.h isa_if.h + device_if.h bus_if.h card_if.h card_if.c power_if.h power_if.c NOMAN= .include <bsd.kmod.mk> diff --git a/sys/modules/pcic/Makefile b/sys/modules/pcic/Makefile index e4d22ef1e580..b5b6b59da43d 100644 --- a/sys/modules/pcic/Makefile +++ b/sys/modules/pcic/Makefile @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../dev/pcic KMOD= pcic SRCS= i82365.c i82365_isa.c i82365_isasubr.c \ - device_if.h bus_if.h isa_if.h + device_if.h bus_if.h isa_if.h power_if.h card_if.h NOMAN= .include <bsd.kmod.mk> |