summaryrefslogtreecommitdiffstats
path: root/sys/dev/pccard
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2000-04-13 06:42:58 +0000
committerimp <imp@FreeBSD.org>2000-04-13 06:42:58 +0000
commit254febffb998a2a1fd6e6be57dcb73d57335fa14 (patch)
treea2d4e1bb5e6d57a7d14b19556f10300a403ba1f4 /sys/dev/pccard
parent40ba664ca8fe45d0d014929f0da130b67ac78345 (diff)
downloadFreeBSD-src-254febffb998a2a1fd6e6be57dcb73d57335fa14.zip
FreeBSD-src-254febffb998a2a1fd6e6be57dcb73d57335fa14.tar.gz
checkpoint latest pccard/pcic hacking:
o Eliminate cross calls between the devices. Instead move to using the newbus messaging system. Added three new card calls: attach_card, detach_card, get_type. o Eliminate interrupt routine in pccard we never use. o Move from deactivate to detach for removing cards. o Start mapping CIS memory, but it is broken and causes panics. At least it is closer to working than before. o Eliminate struct device everywhere. It was bogus. o Initialize softc for pccard device so we have valid pointers to ourselves. o Implement routine to find the pcic ivar for a child device of the pccard so we can use it to talk to the pcic hardware. o Lots of minor tiding up. This version now panics when we try to read the CIS. The next batch of work to make this work is what was outlined in my posting to mobile about resource allocation and such.
Diffstat (limited to 'sys/dev/pccard')
-rw-r--r--sys/dev/pccard/card_if.m33
-rw-r--r--sys/dev/pccard/pccard.c172
-rw-r--r--sys/dev/pccard/pccard_cis.c13
-rw-r--r--sys/dev/pccard/pccardvar.h13
4 files changed, 89 insertions, 142 deletions
diff --git a/sys/dev/pccard/card_if.m b/sys/dev/pccard/card_if.m
index 51b3bcb..6223789 100644
--- a/sys/dev/pccard/card_if.m
+++ b/sys/dev/pccard/card_if.m
@@ -37,16 +37,41 @@ INTERFACE card;
# the driver activating the resources doesn't necessarily know or need to know
# these attributes.
#
-METHOD int set_resource_attribute {
+METHOD int set_res_flags {
device_t dev;
device_t child;
+ int restype;
int rid;
- u_int flags;
+ u_long value;
};
-METHOD int get_resource_attribute {
+METHOD int get_res_flags {
device_t dev;
device_t child;
+ int restype;
int rid;
- u_int *flags;
+ u_long *value;
};
+
+METHOD int set_memory_offset {
+ device_t dev;
+ device_t child;
+ int rid;
+ u_int32_t offset;
+}
+
+# These might be better static
+
+METHOD int attach_card {
+ device_t dev;
+}
+
+METHOD int detach_card {
+ device_t dev;
+ int flags;
+}
+
+METHOD int get_type {
+ device_t dev;
+ int *type;
+}
diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c
index ee95cd0..00cd1e6 100644
--- a/sys/dev/pccard/pccard.c
+++ b/sys/dev/pccard/pccard.c
@@ -48,6 +48,7 @@
#include <dev/pccard/pccardvar.h>
#include "power_if.h"
+#include "card_if.h"
#define PCCARDDEBUG
@@ -55,14 +56,9 @@
int pccard_debug = 1;
#define DPRINTF(arg) if (pccard_debug) printf arg
#define DEVPRINTF(arg) if (pccard_debug) device_printf arg
-int pccardintr_debug = 0;
-/* this is done this way to avoid doing lots of conditionals
- at interrupt level. */
-#define PCCARD_CARD_INTR (pccardintr_debug?pccard_card_intrdebug:pccard_card_intr)
#else
#define DPRINTF(arg)
#define DEVPRINTF(arg)
-#define PCCARD_CARD_INTR (pccard_card_intr)
#endif
#ifdef PCCARDVERBOSE
@@ -73,11 +69,6 @@ int pccard_verbose = 0;
int pccard_print(void *, const char *);
-int pccard_card_intr(void *);
-#ifdef PCCARDDEBUG
-int pccard_card_intrdebug(void *);
-#endif
-
int
pccard_ccr_read(pf, ccr)
struct pccard_function *pf;
@@ -100,8 +91,8 @@ pccard_ccr_write(pf, ccr, val)
}
}
-int
-pccard_card_attach(device_t dev)
+static int
+pccard_attach_card(device_t dev)
{
struct pccard_softc *sc = (struct pccard_softc *)
device_get_softc(dev);
@@ -146,16 +137,7 @@ pccard_card_attach(device_t dev)
if (STAILQ_EMPTY(&pf->cfe_head))
continue;
-#ifdef DIAGNOSTIC
- if (pf->child != NULL) {
- device_printf(sc->dev,
- "%s still attached to function %d!\n",
- device_get_name(pf->child), pf->number);
- panic("pccard_card_attach");
- }
-#endif
pf->sc = sc;
- pf->child = NULL;
pf->cfe = NULL;
pf->ih_fct = NULL;
pf->ih_arg = NULL;
@@ -184,8 +166,8 @@ pccard_card_attach(device_t dev)
return (attached ? 0 : 1);
}
-void
-pccard_card_detach(device_t dev, int flags)
+static int
+pccard_detach_card(device_t dev, int flags)
{
struct pccard_softc *sc = (struct pccard_softc *)
device_get_softc(dev);
@@ -201,11 +183,9 @@ pccard_card_detach(device_t dev, int flags)
STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) {
if (STAILQ_FIRST(&pf->cfe_head) == NULL)
continue;
- if (pf->child == NULL)
- continue;
+#if XXX
DEVPRINTF((sc->dev, "detaching %s (function %d)\n",
device_get_name(pf->child), pf->number));
-#if XXX
if ((error = config_detach(pf->child, flags)) != 0) {
device_printf(sc->dev,
"error %d detaching %s (function %d)\n",
@@ -214,35 +194,11 @@ pccard_card_detach(device_t dev, int flags)
pf->child = NULL;
#endif
}
+ return 0;
}
-void
-pccard_card_deactivate(device_t dev)
-{
- struct pccard_softc *sc = (struct pccard_softc *)
- device_get_softc(dev);
- struct pccard_function *pf;
-
- /*
- * We're in the chip's card removal interrupt handler.
- * Deactivate the child driver. The PCCARD socket's
- * event thread will run later to finish the detach.
- */
- STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) {
- if (STAILQ_FIRST(&pf->cfe_head) == NULL)
- continue;
- if (pf->child == NULL)
- continue;
- DEVPRINTF((sc->dev, "deactivating %s (function %d)\n",
- device_get_name(pf->child), pf->number));
-#if XXX
- config_deactivate(pf->child);
-#endif
- }
-}
-
-int
-pccard_card_gettype(device_t dev)
+static int
+pccard_card_gettype(device_t dev, int *type)
{
struct pccard_softc *sc = (struct pccard_softc *)
device_get_softc(dev);
@@ -257,9 +213,10 @@ pccard_card_gettype(device_t dev)
if (pf == NULL ||
(STAILQ_NEXT(pf, pf_list) == NULL &&
(pf->cfe == NULL || pf->cfe->iftype == PCCARD_IFTYPE_MEMORY)))
- return (PCCARD_IFTYPE_MEMORY);
+ *type = PCCARD_IFTYPE_MEMORY;
else
- return (PCCARD_IFTYPE_IO);
+ *type = PCCARD_IFTYPE_IO;
+ return 0;
}
/*
@@ -531,74 +488,6 @@ pccard_io_unmap(struct pccard_function *pf, int window)
}
#endif
-/* I don't think FreeBSD needs the next two functions at all */
-/* XXX */
-int
-pccard_card_intr(void *arg)
-{
- struct pccard_softc *sc = arg;
- struct pccard_function *pf;
- int reg, ret, ret2;
-
- ret = 0;
-
- STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) {
- if (pf->ih_fct != NULL &&
- (pf->ccr_mask & (1 << (PCCARD_CCR_STATUS / 2)))) {
- reg = pccard_ccr_read(pf, PCCARD_CCR_STATUS);
- if (reg & PCCARD_CCR_STATUS_INTR) {
- ret2 = (*pf->ih_fct)(pf->ih_arg);
- if (ret2 != 0 && ret == 0)
- ret = ret2;
- reg = pccard_ccr_read(pf, PCCARD_CCR_STATUS);
- pccard_ccr_write(pf, PCCARD_CCR_STATUS,
- reg & ~PCCARD_CCR_STATUS_INTR);
- }
- }
- }
-
- return (ret);
-}
-
-#ifdef PCCARDDEBUG
-int
-pccard_card_intrdebug(arg)
- void *arg;
-{
- struct pccard_softc *sc = arg;
- struct pccard_function *pf;
- int reg, ret, ret2;
-
- ret = 0;
-
- STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) {
- device_printf(sc->dev,
- "intr flags=%x fct=%d cor=%02x csr=%02x pin=%02x",
- pf->pf_flags, pf->number,
- pccard_ccr_read(pf, PCCARD_CCR_OPTION),
- pccard_ccr_read(pf, PCCARD_CCR_STATUS),
- pccard_ccr_read(pf, PCCARD_CCR_PIN));
- if (pf->ih_fct != NULL &&
- (pf->ccr_mask & (1 << (PCCARD_CCR_STATUS / 2)))) {
- reg = pccard_ccr_read(pf, PCCARD_CCR_STATUS);
- if (reg & PCCARD_CCR_STATUS_INTR) {
- ret2 = (*pf->ih_fct)(pf->ih_arg);
- if (ret2 != 0 && ret == 0)
- ret = ret2;
- reg = pccard_ccr_read(pf, PCCARD_CCR_STATUS);
- printf("; csr %02x->%02x",
- reg, reg & ~PCCARD_CCR_STATUS_INTR);
- pccard_ccr_write(pf, PCCARD_CCR_STATUS,
- reg & ~PCCARD_CCR_STATUS_INTR);
- }
- }
- printf("\n");
- }
-
- return (ret);
-}
-#endif
-
#define PCCARD_NPORT 2
#define PCCARD_NMEM 5
#define PCCARD_NIRQ 1
@@ -607,6 +496,7 @@ pccard_card_intrdebug(arg)
static int
pccard_add_children(device_t dev, int busno)
{
+ /* Call parent to scan for any current children */
return 0;
}
@@ -617,6 +507,17 @@ pccard_probe(device_t dev)
return pccard_add_children(dev, device_get_unit(dev));
}
+static int
+pccard_attach(device_t dev)
+{
+ struct pccard_softc *sc;
+
+ sc = (struct pccard_softc *) device_get_softc(dev);
+ sc->dev = dev;
+
+ return bus_generic_attach(dev);
+}
+
static void
pccard_print_resources(struct resource_list *rl, const char *name, int type,
int count, const char *format)
@@ -727,10 +628,26 @@ pccard_delete_resource(device_t dev, device_t child, int type, int rid)
resource_list_delete(rl, type, rid);
}
+static int
+pccard_set_res_flags(device_t dev, device_t child, int type, int rid,
+ u_int32_t flags)
+{
+ return CARD_SET_RES_FLAGS(device_get_parent(dev), child, type,
+ rid, flags);
+}
+
+static int
+pccard_set_memory_offset(device_t dev, device_t child, int rid,
+ u_int32_t offset)
+{
+ return CARD_SET_MEMORY_OFFSET(device_get_parent(dev), child, rid,
+ offset);
+}
+
static device_method_t pccard_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pccard_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
+ DEVMETHOD(device_attach, pccard_attach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
@@ -748,6 +665,13 @@ static device_method_t pccard_methods[] = {
DEVMETHOD(bus_get_resource, pccard_get_resource),
DEVMETHOD(bus_delete_resource, pccard_delete_resource),
+ /* Card Interface */
+ DEVMETHOD(card_set_res_flags, pccard_set_res_flags),
+ DEVMETHOD(card_set_memory_offset, pccard_set_memory_offset),
+ DEVMETHOD(card_get_type, pccard_card_gettype),
+ DEVMETHOD(card_attach_card, pccard_attach_card),
+ DEVMETHOD(card_detach_card, pccard_detach_card),
+
{ 0, 0 }
};
diff --git a/sys/dev/pccard/pccard_cis.c b/sys/dev/pccard/pccard_cis.c
index 344d26b..0628f07 100644
--- a/sys/dev/pccard/pccard_cis.c
+++ b/sys/dev/pccard/pccard_cis.c
@@ -47,8 +47,11 @@
#include <dev/pccard/pccardchip.h>
#include <dev/pccard/pccardvar.h>
+#include "card_if.h"
+
+#define PCCARDCISDEBUG
#ifdef PCCARDCISDEBUG
-int pccardcis_debug = 0;
+int pccardcis_debug = 1;
#define DPRINTF(arg) if (pccardcis_debug) printf arg
#define DEVPRINTF(arg) if (pccardcis_debug) device_printf arg
#else
@@ -92,6 +95,8 @@ pccard_read_cis(struct pccard_softc *sc)
state.pf = NULL;
+printf("Calling scan_cis\n");
+
if (pccard_scan_cis(sc->dev, pccard_parse_cis_tuple,
&state) == -1)
state.card->error++;
@@ -121,13 +126,13 @@ pccard_scan_cis(device_t dev, int (*fct)(struct pccard_tuple *, void *),
rid = 0;
res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0,
- PCCARD_CIS_SIZE, RF_ACTIVE /* | RF_PCCARD_ATTR */);
+ PCCARD_CIS_SIZE, RF_ACTIVE);
if (res == NULL) {
-#ifdef DIAGNOSTIC
device_printf(dev, "can't alloc memory to read attributes\n");
-#endif
return -1;
}
+ CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY,
+ rid, PCCARD_A_MEM_ATTR);
tuple.memt = rman_get_bustag(res);
tuple.memh = rman_get_bushandle(res);
diff --git a/sys/dev/pccard/pccardvar.h b/sys/dev/pccard/pccardvar.h
index dbf2825..281c5dd 100644
--- a/sys/dev/pccard/pccardvar.h
+++ b/sys/dev/pccard/pccardvar.h
@@ -122,7 +122,6 @@ struct pccard_function {
STAILQ_ENTRY(pccard_function) pf_list;
/* run-time state */
struct pccard_softc *sc;
- struct device *child;
struct pccard_config_entry *cfe;
struct pccard_mem_handle pf_pcmh;
#define pf_ccrt pf_pcmh.memt
@@ -202,8 +201,8 @@ struct pccard_tuple {
void pccard_read_cis(struct pccard_softc *);
void pccard_check_cis_quirks(device_t);
void pccard_print_cis(device_t);
-int pccard_scan_cis(struct device * dev,
- int (*) (struct pccard_tuple *, void *), void *);
+int pccard_scan_cis(device_t,
+ int (*) (struct pccard_tuple *, void *), void *);
#define pccard_cis_read_1(tuple, idx0) \
(bus_space_read_1((tuple)->memt, (tuple)->memh, (tuple)->mult*(idx0)))
@@ -284,12 +283,6 @@ pccard_get_ether(device_t dev, u_char *enaddr)
}
enum {
- PCCARD_A_MEM_ATTR
+ PCCARD_A_MEM_ATTR = 0x1
};
-/* Set the */
-
-static __inline__ void
-pccard_set_attribute(device_t dev, struct resource *r, int rid, int flags)
-{
-}
OpenPOWER on IntegriCloud