summaryrefslogtreecommitdiffstats
path: root/sys/dev/pcic
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2000-04-19 08:31:21 +0000
committerimp <imp@FreeBSD.org>2000-04-19 08:31:21 +0000
commit45487d7f0a809050d1dc86acd6d4a2ae82b85581 (patch)
tree107084e97198d2a36b00244f6a2880d10b6ee36c /sys/dev/pcic
parent5b36470f2033fd9b5d9ae54ce79ef9909a5dba1b (diff)
downloadFreeBSD-src-45487d7f0a809050d1dc86acd6d4a2ae82b85581.zip
FreeBSD-src-45487d7f0a809050d1dc86acd6d4a2ae82b85581.tar.gz
OK. Next step: we read in CIS.
I've done this by having requests to allocate memory propigate up the tree. We'll see how well this works and reevaluate if it isn't working well. Also initialize ptr in the tuple. As well as minor reorg of memory allocation. Likely need to do similar things for I/O when the time comes. I've move all defines from pccardchip.h into pccardvar.h and eliminated pccardchip.h.
Diffstat (limited to 'sys/dev/pcic')
-rw-r--r--sys/dev/pcic/i82365.c83
-rw-r--r--sys/dev/pcic/i82365_isa.c1
-rw-r--r--sys/dev/pcic/i82365var.h3
3 files changed, 25 insertions, 62 deletions
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 */
OpenPOWER on IntegriCloud