diff options
-rw-r--r-- | sys/dev/pccard/pccard.c | 1 | ||||
-rw-r--r-- | sys/dev/pccard/pccard_cis.c | 3 | ||||
-rw-r--r-- | sys/dev/pccard/pccard_cis_quirks.c | 1 | ||||
-rw-r--r-- | sys/dev/pccard/pccardchip.h | 148 | ||||
-rw-r--r-- | sys/dev/pccard/pccardvar.h | 11 | ||||
-rw-r--r-- | sys/dev/pcic/i82365.c | 83 | ||||
-rw-r--r-- | sys/dev/pcic/i82365_isa.c | 1 | ||||
-rw-r--r-- | sys/dev/pcic/i82365var.h | 3 |
8 files changed, 34 insertions, 217 deletions
diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index 00cd1e6..c2e62ba 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -44,7 +44,6 @@ #include <machine/resource.h> #include <dev/pccard/pccardreg.h> -#include <dev/pccard/pccardchip.h> #include <dev/pccard/pccardvar.h> #include "power_if.h" diff --git a/sys/dev/pccard/pccard_cis.c b/sys/dev/pccard/pccard_cis.c index 0628f07..e922024 100644 --- a/sys/dev/pccard/pccard_cis.c +++ b/sys/dev/pccard/pccard_cis.c @@ -44,7 +44,6 @@ #include <machine/resource.h> #include <dev/pccard/pccardreg.h> -#include <dev/pccard/pccardchip.h> #include <dev/pccard/pccardvar.h> #include "card_if.h" @@ -135,6 +134,7 @@ pccard_scan_cis(device_t dev, int (*fct)(struct pccard_tuple *, void *), rid, PCCARD_A_MEM_ATTR); tuple.memt = rman_get_bustag(res); tuple.memh = rman_get_bushandle(res); + tuple.ptr = 0; DPRINTF(("cis mem map %x\n", (unsigned int) tuple.memh)); @@ -169,6 +169,7 @@ pccard_scan_cis(device_t dev, int (*fct)(struct pccard_tuple *, void *), ret = 1; goto done; } + ret = 1; goto done; /* XXX IMP XXX */ tuple.ptr++; break; } diff --git a/sys/dev/pccard/pccard_cis_quirks.c b/sys/dev/pccard/pccard_cis_quirks.c index 5cd0aa1..0219383 100644 --- a/sys/dev/pccard/pccard_cis_quirks.c +++ b/sys/dev/pccard/pccard_cis_quirks.c @@ -47,7 +47,6 @@ #include <dev/pccard/pccarddevs.h> #include <dev/pccard/pccardreg.h> -#include <dev/pccard/pccardchip.h> #include <dev/pccard/pccardvar.h> /* There are cards out there whose CIS flat-out lies. This file diff --git a/sys/dev/pccard/pccardchip.h b/sys/dev/pccard/pccardchip.h deleted file mode 100644 index fe8b936..0000000 --- a/sys/dev/pccard/pccardchip.h +++ /dev/null @@ -1,148 +0,0 @@ -/* $NetBSD: pcmciachip.h,v 1.4 1999/10/15 06:07:32 haya Exp $ */ -/* $FreeBSD$ */ - -/* - * Copyright (c) 1997 Marc Horowitz. 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Marc Horowitz. - * 4. The name of the author 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 ``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. - */ - -#ifndef _PCCARD_PCCARDCHIP_H_ -#define _PCCARD_PCCARDCHIP_H_ - -#if 0 -#include <machine/bus.h> - -struct pccard_function; -struct pccard_mem_handle; -struct pccard_io_handle; - -/* interfaces for pccard to call the chipset */ - -typedef struct pccard_chip_functions *pccard_chipset_tag_t; -typedef void *pccard_chipset_handle_t; -#endif -typedef int pccard_mem_handle_t; - -#define PCCARD_MEM_ATTR 1 -#define PCCARD_MEM_COMMON 2 - -#define PCCARD_WIDTH_AUTO 0 -#define PCCARD_WIDTH_IO8 1 -#define PCCARD_WIDTH_IO16 2 - -#if 0 -struct pccard_chip_functions { - /* memory space allocation */ - int (*mem_alloc)(pccard_chipset_handle_t, bus_size_t, - struct pccard_mem_handle *); - void (*mem_free)(pccard_chipset_handle_t, - struct pccard_mem_handle *); - - /* memory space window mapping */ - int (*mem_map)(pccard_chipset_handle_t, int, bus_addr_t, - bus_size_t, struct pccard_mem_handle *, - bus_addr_t *, int *); - void (*mem_unmap)(pccard_chipset_handle_t, int); - - /* I/O space allocation */ - int (*io_alloc) (pccard_chipset_handle_t, bus_addr_t, - bus_size_t, bus_size_t, struct pccard_io_handle *); - void (*io_free) (pccard_chipset_handle_t, - struct pccard_io_handle *); - - /* I/O space window mapping */ - int (*io_map) (pccard_chipset_handle_t, int, bus_addr_t, - bus_size_t, struct pccard_io_handle *, int *); - void (*io_unmap) (pccard_chipset_handle_t, int); - - /* interrupt glue */ - void *(*intr_establish) (pccard_chipset_handle_t, - struct pccard_function *, int, int (*)(void *), void *); - void (*intr_disestablish) (pccard_chipset_handle_t, void *); - - /* card enable/disable */ - void (*socket_enable) (pccard_chipset_handle_t); - void (*socket_disable) (pccard_chipset_handle_t); - - /* card detection */ - int (*card_detect)(pccard_chipset_handle_t); -}; - -/* Memory space functions. */ -#define pccard_chip_mem_alloc(tag, handle, size, pcmhp) \ - ((*(tag)->mem_alloc)((handle), (size), (pcmhp))) - -#define pccard_chip_mem_free(tag, handle, pcmhp) \ - ((*(tag)->mem_free)((handle), (pcmhp))) - -#define pccard_chip_mem_map(tag, handle, kind, card_addr, size, pcmhp, \ - offsetp, windowp) \ - ((*(tag)->mem_map)((handle), (kind), (card_addr), (size), (pcmhp), \ - (offsetp), (windowp))) - -#define pccard_chip_mem_unmap(tag, handle, window) \ - ((*(tag)->mem_unmap)((handle), (window))) - -/* I/O space functions. */ -#define pccard_chip_io_alloc(tag, handle, start, size, align, pcihp) \ - ((*(tag)->io_alloc)((handle), (start), (size), (align), (pcihp))) - -#define pccard_chip_io_free(tag, handle, pcihp) \ - ((*(tag)->io_free)((handle), (pcihp))) - -#define pccard_chip_io_map(tag, handle, width, card_addr, size, pcihp, \ - windowp) \ - ((*(tag)->io_map)((handle), (width), (card_addr), (size), (pcihp), \ - (windowp))) - -#define pccard_chip_io_unmap(tag, handle, window) \ - ((*(tag)->io_unmap)((handle), (window))) - -/* Interrupt functions. */ -#define pccard_chip_intr_establish(tag, handle, pf, ipl, fct, arg) \ - ((*(tag)->intr_establish)((handle), (pf), (ipl), (fct), (arg))) - -#define pccard_chip_intr_disestablish(tag, handle, ih) \ - ((*(tag)->intr_disestablish)((handle), (ih))) - -/* Socket functions. */ -#define pccard_chip_socket_enable(tag, handle) \ - ((*(tag)->socket_enable)((handle))) -#define pccard_chip_socket_disable(tag, handle) \ - ((*(tag)->socket_disable)((handle))) - -struct pccardbus_attach_args { - char *paa_busname; /* Bus name */ - pccard_chipset_tag_t pct; - pccard_chipset_handle_t pch; - bus_addr_t iobase; /* start i/o space allocation here */ - bus_size_t iosize; /* size of the i/o space range */ -}; - -#endif /* 0 */ - -#endif /* _PCCARD_PCCARDCHIP_H_ */ diff --git a/sys/dev/pccard/pccardvar.h b/sys/dev/pccard/pccardvar.h index 281c5dd..19e9434 100644 --- a/sys/dev/pccard/pccardvar.h +++ b/sys/dev/pccard/pccardvar.h @@ -35,8 +35,6 @@ #include <machine/bus.h> -#include <dev/pccard/pccardchip.h> - extern int pccard_verbose; /* @@ -61,7 +59,6 @@ struct pccard_mem_handle { bus_space_handle_t memh; /* mapped space handle */ bus_addr_t addr; /* resulting address in bus space */ bus_size_t size; /* size of mem space */ - pccard_mem_handle_t mhandle; /* opaque memory handle */ bus_size_t realsize; /* how much we really allocated */ long offset; int kind; @@ -126,7 +123,6 @@ struct pccard_function { struct pccard_mem_handle pf_pcmh; #define pf_ccrt pf_pcmh.memt #define pf_ccrh pf_pcmh.memh -#define pf_ccr_mhandle pf_pcmh.mhandle #define pf_ccr_realsize pf_pcmh.realsize bus_addr_t pf_ccr_offset; int pf_ccr_window; @@ -161,6 +157,13 @@ struct pccard_card { STAILQ_HEAD(, pccard_function) pf_head; }; +#define PCCARD_MEM_ATTR 1 +#define PCCARD_MEM_COMMON 2 + +#define PCCARD_WIDTH_AUTO 0 +#define PCCARD_WIDTH_IO8 1 +#define PCCARD_WIDTH_IO16 2 + /* More later? */ struct pccard_ivar { struct resource_list resources; diff --git a/sys/dev/pcic/i82365.c b/sys/dev/pcic/i82365.c index 5e02bd6..f99e9f3 100644 --- a/sys/dev/pcic/i82365.c +++ b/sys/dev/pcic/i82365.c @@ -96,9 +96,6 @@ static void pcic_intr(void *arg); static void pcic_attach_card(struct pcic_handle *); static void pcic_detach_card(struct pcic_handle *, int); -#if 0 -void pcic_deactivate_card(struct pcic_handle *); -#endif static void pcic_chip_do_mem_map(struct pcic_handle *, int); static void pcic_chip_do_io_map(struct pcic_handle *, int); @@ -129,7 +126,6 @@ pcic_get_handle(device_t dev, device_t child) return ((struct pcic_handle *) device_get_ivars(child)); } - int pcic_ident_ok(int ident) { @@ -233,6 +229,8 @@ pcic_activate(device_t dev) return err; } + /* XXX This might not be needed in future, get it directly from + * XXX parent */ sc->mem_rid = 0; sc->mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->mem_rid, 0, ~0, 1 << 13, RF_ACTIVE); @@ -243,9 +241,6 @@ pcic_activate(device_t dev) pcic_deactivate(dev); return ENOMEM; } - sc->subregionmask = (1 << - ((rman_get_end(sc->mem_res) - rman_get_start(sc->mem_res) + 1) / - PCIC_MEM_PAGESIZE)) - 1; sc->iot = rman_get_bustag(sc->port_res); sc->ioh = rman_get_bushandle(sc->port_res);; @@ -621,7 +616,8 @@ pcic_init_socket(struct pcic_handle *h) #if 0 /* XXX */ -/* SHould do this later */ +/* Should do this later */ +/* maybe as part of interrupt routing verification */ if ((reg & PCIC_IF_STATUS_CARDDETECT_MASK) == PCIC_IF_STATUS_CARDDETECT_PRESENT) { pcic_attach_card(h); @@ -745,30 +741,14 @@ pcic_detach_card(struct pcic_handle *h, int flags) } } -#if 0 -void -pcic_deactivate_card(struct pcic_handle *h) -{ - - /* call the MI deactivate function */ - pccard_card_deactivate(h->dev); - - /* power down the socket */ - pcic_write(h, PCIC_PWRCTL, 0); - - /* reset the socket */ - pcic_write(h, PCIC_INTR, 0); -} -#endif - static int -pcic_chip_mem_alloc(struct pcic_handle *h, bus_size_t size, +pcic_chip_mem_alloc(struct pcic_handle *h, struct resource *r, bus_size_t size, struct pccard_mem_handle *pcmhp) { bus_space_handle_t memh; bus_addr_t addr; bus_size_t sizepg; - int i, mask, mhandle; + int mask; struct pcic_softc *sc = h->sc; /* out of sc->memh, allocate as many pages as necessary */ @@ -780,34 +760,19 @@ pcic_chip_mem_alloc(struct pcic_handle *h, bus_size_t size, mask = (1 << sizepg) - 1; - addr = 0; /* XXX gcc -Wuninitialized */ - mhandle = 0; /* XXX gcc -Wuninitialized */ - - for (i = 0; i <= PCIC_MAX_MEM_PAGES - sizepg; i++) { - if ((sc->subregionmask & (mask << i)) == (mask << i)) { - mhandle = mask << i; - addr = sc->membase + (i * PCIC_MEM_PAGESIZE); - memh = addr; - sc->subregionmask &= ~(mhandle); - pcmhp->memt = sc->memt; - pcmhp->memh = memh; - pcmhp->addr = addr; - pcmhp->size = size; - pcmhp->mhandle = mhandle; - pcmhp->realsize = sizepg * PCIC_MEM_PAGESIZE; - return (0); - } - } - - return (1); + addr = rman_get_start(r); + memh = addr; + pcmhp->memt = sc->memt; + pcmhp->memh = memh; + pcmhp->addr = addr; + pcmhp->size = size; + pcmhp->realsize = sizepg * PCIC_MEM_PAGESIZE; + return (0); } static void pcic_chip_mem_free(struct pcic_handle *h, struct pccard_mem_handle *pcmhp) { - struct pcic_softc *sc = h->sc; - - sc->subregionmask |= pcmhp->mhandle; } static struct mem_map_index_st { @@ -930,7 +895,6 @@ pcic_chip_mem_map(struct pcic_handle *h, int kind, bus_addr_t card_addr, bus_addr_t busaddr; long card_offset; int i, win; - struct pcic_softc *sc = h->sc; win = -1; for (i = 0; i < (sizeof(mem_map_index) / sizeof(mem_map_index[0])); @@ -946,11 +910,6 @@ pcic_chip_mem_map(struct pcic_handle *h, int kind, bus_addr_t card_addr, return (1); *windowp = win; -#if 0 - /* XXX this is pretty gross */ - if (sc->memt != pcmhp->memt) - panic("pcic_chip_mem_map memt is bogus"); -#endif busaddr = pcmhp->addr; /* @@ -1123,7 +1082,9 @@ pcic_chip_io_map(struct pcic_handle *h, int width, bus_addr_t offset, #ifdef PCICDEBUG static char *width_names[] = { "auto", "io8", "io16" }; #endif +#if 0 struct pcic_softc *sc = h->sc; +#endif /* XXX Sanity check offset/size. */ @@ -1451,9 +1412,15 @@ pcic_alloc_resource(device_t dev, device_t child, int type, int *rid, struct resource *r; struct pcic_handle *h = pcic_get_handle(dev, child); + /* Nearly default */ + if (type == SYS_RES_MEMORY && start == 0 && end == ~0 && count != 1) { + start = 0xd0000; /* XXX */ + end = 0xdffff; + } + r = bus_generic_alloc_resource(dev, child, type, rid, start, end, count, flags); - if (!r) + if (r == NULL) return r; sz = rman_get_end(r) - rman_get_start(r) + 1; switch (type) { @@ -1467,7 +1434,7 @@ pcic_alloc_resource(device_t dev, device_t child, int type, int *rid, } break; case SYS_RES_MEMORY: - err = pcic_chip_mem_alloc(h, sz, &h->mem[*rid]); + err = pcic_chip_mem_alloc(h, r, sz, &h->mem[*rid]); if (err) { bus_generic_release_resource(dev, child, type, *rid, r); @@ -1524,8 +1491,8 @@ pcic_set_res_flags(device_t dev, device_t child, int type, int rid, u_int32_t flags) { struct pcic_handle *h = pcic_get_handle(dev, child); -printf("%p %p %d %d %#x\n", dev, child, type, rid, flags); + DPRINTF(("%p %p %d %d %#x\n", dev, child, type, rid, flags)); if (type != SYS_RES_MEMORY) return (EINVAL); h->mem[rid].kind = PCCARD_MEM_ATTR; diff --git a/sys/dev/pcic/i82365_isa.c b/sys/dev/pcic/i82365_isa.c index 22d8ae0..e4a98c3 100644 --- a/sys/dev/pcic/i82365_isa.c +++ b/sys/dev/pcic/i82365_isa.c @@ -49,7 +49,6 @@ #include <dev/pccard/pccardreg.h> #include <dev/pccard/pccardvar.h> -#include <dev/pccard/pccardchip.h> #include <dev/pcic/i82365reg.h> #include <dev/pcic/i82365var.h> diff --git a/sys/dev/pcic/i82365var.h b/sys/dev/pcic/i82365var.h index 0a3b9e5..5a0c723 100644 --- a/sys/dev/pcic/i82365var.h +++ b/sys/dev/pcic/i82365var.h @@ -31,7 +31,6 @@ */ #include <dev/pccard/pccardreg.h> -#include <dev/pccard/pccardchip.h> #include <dev/pcic/i82365reg.h> @@ -107,8 +106,6 @@ struct pcic_softc { struct resource *port_res; int port_rid; - /* this needs to be large enough to hold PCIC_MEM_PAGES bits */ - int subregionmask; #define PCIC_MAX_MEM_PAGES (8 * sizeof(int)) /* used by memory window mapping functions */ |