summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2003-06-07 20:46:39 +0000
committerimp <imp@FreeBSD.org>2003-06-07 20:46:39 +0000
commit6fe75065edf585a7dfae6ebe9db1538a1fac6636 (patch)
treebd7ef989472fa8db7411b3f82b9f76217d2f0676 /sys/dev
parentc57f179395b739d56236ae29b0eb7cb37c046046 (diff)
downloadFreeBSD-src-6fe75065edf585a7dfae6ebe9db1538a1fac6636.zip
FreeBSD-src-6fe75065edf585a7dfae6ebe9db1538a1fac6636.tar.gz
MFP4:
Merge some common code from cbb into exca.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/exca/exca.c72
-rw-r--r--sys/dev/exca/excavar.h16
2 files changed, 88 insertions, 0 deletions
diff --git a/sys/dev/exca/exca.c b/sys/dev/exca/exca.c
index 5245b2b..09627fb 100644
--- a/sys/dev/exca/exca.c
+++ b/sys/dev/exca/exca.c
@@ -56,11 +56,14 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/condvar.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/queue.h>
#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/conf.h>
#include <sys/bus.h>
@@ -636,6 +639,9 @@ exca_valid_slot(struct exca_softc *exca)
{
uint8_t c;
+ /* Assume the worst */
+ exca->chipset = EXCA_BOGUS;
+
/*
* see if there's a PCMCIA controller here
* Intel PCMCIA controllers use 0x82 and 0x83
@@ -759,6 +765,72 @@ exca_probe_slots(device_t dev, struct exca_softc *exca, bus_space_tag_t iot,
return (err);
}
+void
+exca_insert(struct exca_softc *exca)
+{
+ if (exca->pccarddev != NULL) {
+ if (CARD_ATTACH_CARD(exca->pccarddev) != 0)
+ device_printf(exca->dev,
+ "PC Card card activation failed\n");
+ } else {
+ device_printf(exca->dev,
+ "PC Card inserted, but no pccard bus.\n");
+ }
+}
+
+
+void
+exca_removal(struct exca_softc *exca)
+{
+ if (exca->pccarddev != NULL)
+ CARD_DETACH_CARD(exca->pccarddev);
+}
+
+int
+exca_activate_resource(struct exca_softc *exca, device_t child, int type,
+ int rid, struct resource *res)
+{
+ int err;
+ if (!(rman_get_flags(res) & RF_ACTIVE)) { /* not already activated */
+ switch (type) {
+ case SYS_RES_IOPORT:
+ err = exca_io_map(exca, 0, res);
+ break;
+ case SYS_RES_MEMORY:
+ err = exca_mem_map(exca, 0, res);
+ break;
+ default:
+ err = 0;
+ break;
+ }
+ if (err)
+ return (err);
+
+ }
+ return (BUS_ACTIVATE_RESOURCE(device_get_parent(exca->dev), child,
+ type, rid, res));
+}
+
+int
+exca_deactivate_resource(struct exca_softc *exca, device_t child, int type,
+ int rid, struct resource *res)
+{
+ if (rman_get_flags(res) & RF_ACTIVE) { /* if activated */
+ switch (type) {
+ case SYS_RES_IOPORT:
+ if (exca_io_unmap_res(exca, res))
+ return (ENOENT);
+ break;
+ case SYS_RES_MEMORY:
+ if (exca_mem_unmap_res(exca, res))
+ return (ENOENT);
+ break;
+ }
+ }
+ return (BUS_DEACTIVATE_RESOURCE(device_get_parent(exca->dev), child,
+ type, rid, res));
+}
+
static int
exca_modevent(module_t mod, int cmd, void *arg)
{
diff --git a/sys/dev/exca/excavar.h b/sys/dev/exca/excavar.h
index 2f6aca5..e79bd6a 100644
--- a/sys/dev/exca/excavar.h
+++ b/sys/dev/exca/excavar.h
@@ -76,6 +76,9 @@ struct exca_softc
uint32_t flags;
#define EXCA_SOCKET_PRESENT 0x00000001
#define EXCA_HAS_MEMREG_WIN 0x00000002
+#define EXCA_CARD_OK 0x00000004
+#define EXCA_KTHREAD_RUNNING 0x00000008
+#define EXCA_KTHREAD_DONE 0x00000010
uint32_t offset;
int chipset;
#define EXCA_CARDBUS 0
@@ -93,12 +96,18 @@ struct exca_softc
#define EXCA_RF5C396 12 /* Ricoh RF5C396 */
#define EXCA_IBM 13 /* IBM clone */
#define EXCA_IBM_KING 14 /* IBM KING PCMCIA Controller */
+#define EXCA_BOGUS -1 /* Invalid/not present/etc */
exca_getb_fn *getb;
exca_putb_fn *putb;
+ struct proc *event_thread;
+ struct mtx mtx;
+ struct cv cv;
+ device_t pccarddev;
};
void exca_init(struct exca_softc *sc, device_t dev,
bus_space_tag_t, bus_space_handle_t, uint32_t);
+void exca_insert(struct exca_softc *sc);
int exca_io_map(struct exca_softc *sc, int width, struct resource *r);
int exca_io_unmap_res(struct exca_softc *sc, struct resource *res);
int exca_is_pcic(struct exca_softc *sc);
@@ -110,8 +119,15 @@ int exca_mem_set_offset(struct exca_softc *sc, struct resource *res,
int exca_mem_unmap_res(struct exca_softc *sc, struct resource *res);
int exca_probe_slots(device_t dev, struct exca_softc *exca,
bus_space_tag_t iot, bus_space_handle_t ioh);
+void exca_removal(struct exca_softc *);
void exca_reset(struct exca_softc *, device_t child);
+/* bus/device interfaces */
+int exca_activate_resource(struct exca_softc *exca, device_t child, int type,
+ int rid, struct resource *res);
+int exca_deactivate_resource(struct exca_softc *exca, device_t child, int type,
+ int rid, struct resource *res);
+
static __inline uint8_t
exca_getb(struct exca_softc *sc, int reg)
{
OpenPOWER on IntegriCloud