From 666d2603cff7cea42d4218308aacf32d9ef0699b Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Tue, 10 Feb 2004 07:55:47 +0000 Subject: [PATCH] Initial backport of NEWCARD from FreeBSD 5. The included version is from end of November 2002 with the exception of bus/pccard/pccarddevs which is from November 2003. Thanks to Warner Losh and the other folks for NEWCARD. --- sys/bus/pccard/Makefile.pccarddevs | 9 + sys/bus/pccard/card_if.m | 252 +++ sys/{dev/misc => bus}/pccard/devlist2h.awk | 72 +- sys/bus/pccard/i82365.h | 332 --- sys/bus/pccard/mecia.c | 767 ------- sys/bus/pccard/meciareg.h | 61 - sys/bus/pccard/pccard.c | 1729 +++++++++----- sys/{dev/misc => bus}/pccard/pccard_cis.c | 207 +- .../misc => bus}/pccard/pccard_cis_quirks.c | 68 +- sys/bus/pccard/pccard_nbk.c | 439 ---- sys/bus/pccard/pccard_nbk.h | 37 - sys/bus/pccard/pccarddevs | 611 +++++ sys/bus/pccard/pccarddevs.h | 1148 ++++++++++ sys/bus/pccard/pccardreg.h | 2 +- sys/bus/pccard/pccardvar.h | 150 +- sys/bus/pccard/pccbb/Makefile | 11 - sys/bus/pccard/pcic.c | 1330 ----------- sys/bus/pccard/pcic_isa.c | 398 ---- sys/bus/pccard/pcic_pci.c | 1578 ------------- sys/bus/pccard/pcic_pci.h | 271 --- sys/bus/pccard/pcicvar.h | 123 - sys/{dev/misc => bus}/pccard/power_if.m | 4 +- sys/conf/files | 59 +- sys/conf/kmod.mk | 5 +- sys/config/GENERIC | 8 +- sys/config/LINT | 14 +- sys/dev/Makefile | 4 +- sys/dev/disk/fd/fd.c | 4 +- sys/dev/misc/Makefile | 4 +- sys/dev/misc/pccard/Makefile | 10 - sys/dev/misc/pccard/Makefile.pccarddevs | 9 - sys/dev/misc/pccard/card_if.m | 86 - sys/dev/misc/pccard/files.pccard | 72 - sys/dev/misc/pccard/pccard.c | 689 ------ sys/dev/misc/pccard/pccardchip.h | 149 -- sys/dev/misc/pccard/pccarddevs | 284 --- sys/dev/misc/pccard/pccarddevs.h | 497 ----- sys/dev/misc/pccard/pccarddevs_data.h | 1135 ---------- sys/dev/misc/pcic/Makefile | 10 - sys/dev/pccard/Makefile | 6 + sys/dev/pccard/cardbus/Makefile | 9 + sys/dev/pccard/cardbus/cardbus.c | 1266 +++++++++++ sys/dev/pccard/cardbus/cardbus_cis.c | 1113 ++++++++++ sys/dev/pccard/cardbus/cardbus_cis.h | 115 + sys/dev/pccard/cardbus/cardbusreg.h | 92 + sys/dev/pccard/cardbus/cardbusvar.h | 57 + sys/dev/pccard/exca/Makefile | 8 + sys/dev/pccard/exca/exca.c | 628 ++++++ sys/dev/pccard/exca/excareg.h | 427 ++++ sys/dev/pccard/exca/excavar.h | 119 + sys/dev/pccard/pccbb/Makefile | 8 + sys/dev/pccard/pccbb/pccbb.c | 1977 +++++++++++++++++ sys/{bus => dev}/pccard/pccbb/pccbbdevid.h | 15 +- sys/dev/pccard/pccbb/pccbbreg.h | 233 ++ sys/dev/pccard/pccbb/pccbbvar.h | 111 + sys/dev/pccard/pcic/Makefile | 8 + sys/dev/{misc => pccard}/pcic/i82365.c | 187 +- sys/dev/{misc => pccard}/pcic/i82365_isa.c | 118 +- sys/dev/{misc => pccard}/pcic/i82365reg.h | 4 +- sys/dev/{misc => pccard}/pcic/i82365var.h | 59 +- sys/i386/conf/GENERIC | 8 +- sys/i386/conf/LINT | 14 +- 62 files changed, 9920 insertions(+), 9300 deletions(-) create mode 100644 sys/bus/pccard/Makefile.pccarddevs create mode 100644 sys/bus/pccard/card_if.m rename sys/{dev/misc => bus}/pccard/devlist2h.awk (72%) delete mode 100644 sys/bus/pccard/i82365.h delete mode 100644 sys/bus/pccard/mecia.c delete mode 100644 sys/bus/pccard/meciareg.h rename sys/{dev/misc => bus}/pccard/pccard_cis.c (87%) rename sys/{dev/misc => bus}/pccard/pccard_cis_quirks.c (80%) delete mode 100644 sys/bus/pccard/pccard_nbk.c delete mode 100644 sys/bus/pccard/pccard_nbk.h create mode 100644 sys/bus/pccard/pccarddevs create mode 100644 sys/bus/pccard/pccarddevs.h delete mode 100644 sys/bus/pccard/pccbb/Makefile delete mode 100644 sys/bus/pccard/pcic.c delete mode 100644 sys/bus/pccard/pcic_isa.c delete mode 100644 sys/bus/pccard/pcic_pci.c delete mode 100644 sys/bus/pccard/pcic_pci.h delete mode 100644 sys/bus/pccard/pcicvar.h rename sys/{dev/misc => bus}/pccard/power_if.m (90%) delete mode 100644 sys/dev/misc/pccard/Makefile delete mode 100644 sys/dev/misc/pccard/Makefile.pccarddevs delete mode 100644 sys/dev/misc/pccard/card_if.m delete mode 100644 sys/dev/misc/pccard/files.pccard delete mode 100644 sys/dev/misc/pccard/pccard.c delete mode 100644 sys/dev/misc/pccard/pccardchip.h delete mode 100644 sys/dev/misc/pccard/pccarddevs delete mode 100644 sys/dev/misc/pccard/pccarddevs.h delete mode 100644 sys/dev/misc/pccard/pccarddevs_data.h delete mode 100644 sys/dev/misc/pcic/Makefile create mode 100644 sys/dev/pccard/Makefile create mode 100644 sys/dev/pccard/cardbus/Makefile create mode 100644 sys/dev/pccard/cardbus/cardbus.c create mode 100644 sys/dev/pccard/cardbus/cardbus_cis.c create mode 100644 sys/dev/pccard/cardbus/cardbus_cis.h create mode 100644 sys/dev/pccard/cardbus/cardbusreg.h create mode 100644 sys/dev/pccard/cardbus/cardbusvar.h create mode 100644 sys/dev/pccard/exca/Makefile create mode 100644 sys/dev/pccard/exca/exca.c create mode 100644 sys/dev/pccard/exca/excareg.h create mode 100644 sys/dev/pccard/exca/excavar.h create mode 100644 sys/dev/pccard/pccbb/Makefile create mode 100644 sys/dev/pccard/pccbb/pccbb.c rename sys/{bus => dev}/pccard/pccbb/pccbbdevid.h (87%) create mode 100644 sys/dev/pccard/pccbb/pccbbreg.h create mode 100644 sys/dev/pccard/pccbb/pccbbvar.h create mode 100644 sys/dev/pccard/pcic/Makefile rename sys/dev/{misc => pccard}/pcic/i82365.c (92%) rename sys/dev/{misc => pccard}/pcic/i82365_isa.c (81%) rename sys/dev/{misc => pccard}/pcic/i82365reg.h (98%) rename sys/dev/{misc => pccard}/pcic/i82365var.h (80%) diff --git a/sys/bus/pccard/Makefile.pccarddevs b/sys/bus/pccard/Makefile.pccarddevs new file mode 100644 index 0000000000..dd0709a943 --- /dev/null +++ b/sys/bus/pccard/Makefile.pccarddevs @@ -0,0 +1,9 @@ +# $NetBSD: Makefile.pcmciadevs,v 1.1 1998/07/19 17:28:15 christos Exp $ +# $FreeBSD: src/sys/dev/pccard/Makefile.pccarddevs,v 1.3 2003/03/28 06:44:57 imp Exp $ +# $DragonFly: src/sys/bus/pccard/Makefile.pccarddevs,v 1.1 2004/02/10 07:55:45 joerg Exp $ + +AWK= awk + +pccarddevs.h: pccarddevs devlist2h.awk + /bin/rm -f pccarddevs.h + ${AWK} -f devlist2h.awk pccarddevs diff --git a/sys/bus/pccard/card_if.m b/sys/bus/pccard/card_if.m new file mode 100644 index 0000000000..c63b40522d --- /dev/null +++ b/sys/bus/pccard/card_if.m @@ -0,0 +1,252 @@ +# +# 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: src/sys/dev/pccard/card_if.m,v 1.21 2002/11/02 23:00:28 imp Exp $ +# $DragonFly: src/sys/bus/pccard/card_if.m,v 1.1 2004/02/10 07:55:45 joerg Exp $ +# + +#include +#include + +INTERFACE card; + +# WARNING: THIS FILE IS USED BY BOTH OLDCARD AND NEWCARD. MAKE SURE +# YOU TEST BOTH KERNELS IF CHANGING THIS FILE. + +# +# 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. +# +METHOD int set_res_flags { + device_t dev; + device_t child; + int restype; + int rid; + u_long value; +}; + +METHOD int get_res_flags { + device_t dev; + device_t child; + int restype; + int rid; + u_long *value; +}; + +# +# Sets the memory offset of the pccard bridge's window into attribute +# or common memory space. +# +METHOD int set_memory_offset { + device_t dev; + device_t child; + int rid; + u_int32_t cardaddr; + u_int32_t *deltap; +} + +METHOD int get_memory_offset { + device_t dev; + device_t child; + int rid; + u_int32_t *offset; +} + +# +# pccard bridges call this method to initate the attachment of a card +# +METHOD int attach_card { + device_t dev; +} + +# +# pccard bridges call this to detach a card. +# +METHOD int detach_card { + device_t dev; +} + +# +# Returns the type of card this is. Maybe we don't need this. +# +METHOD int get_type { + device_t dev; + int *type; +} + +# +# Returns the function number for this device. +# +METHOD int get_function { + device_t dev; + device_t child; + int *func; +} + +# +# Activates (and powers up if necessary) the card's nth function +# since each function gets its own device, there is no need to +# to specify a function number +# +METHOD int activate_function { + device_t dev; + device_t child; +} + +METHOD int deactivate_function { + device_t dev; + device_t child; +} + +# +# Compatibility methods for OLDCARD drivers. We use these routines to make +# it possible to call the OLDCARD driver's probe routine in the context that +# it expects. For OLDCARD these are implemented as pass throughs to the +# device_{probe,attach} routines. For NEWCARD they are implemented such +# such that probe becomes strictly a matching routine and attach does both +# the old probe and old attach. +# +# compat devices should use the following: +# +# /* Device interface */ +# DEVMETHOD(device_probe), pccard_compat_probe), +# DEVMETHOD(device_attach), pccard_compat_attach), +# /* Card interface */ +# DEVMETHOD(card_compat_match, foo_match), /* newly written */ +# DEVMETHOD(card_compat_probe, foo_probe), /* old probe */ +# DEVMETHOD(card_compat_attach, foo_attach), /* old attach */ +# +# This will allow a single driver binary image to be used for both +# OLDCARD and NEWCARD. +# +# Drivers wishing to not retain OLDCARD compatibility needn't do this. +# +# The compat_do_* versions are so that we can make the pccard_compat_probe +# and _attach static lines and have the bus system pick the right version +# to use so we don't enshrine pccard_* symbols in the driver's module. +# +METHOD int compat_probe { + device_t dev; +} + +METHOD int compat_attach { + device_t dev; +} + +CODE { + static int null_do_probe(device_t bus, device_t dev) + { + return (CARD_COMPAT_DO_PROBE(device_get_parent(bus), dev)); + } + + static int null_do_attach(device_t bus, device_t dev) + { + return (CARD_COMPAT_DO_ATTACH(device_get_parent(bus), dev)); + } +} + +METHOD int compat_do_probe { + device_t bus; + device_t dev; +} DEFAULT null_do_probe; + +METHOD int compat_do_attach { + device_t bus; + device_t dev; +} DEFAULT null_do_attach; + +# +# Find "dev" in the passed table of devices. Return it or NULL. +# +METHOD struct pccard_product * do_product_lookup { + device_t bus; + device_t dev; + const struct pccard_product *tab; + size_t ent_size; + pccard_product_match_fn matchfn; +} + +# +# Helper method for the above. When a compatibility driver is converted, +# one must write a match routine. This routine is unused on OLDCARD but +# is used as a discriminator for NEWCARD. +# +METHOD int compat_match { + device_t dev; +} + +# +# Method for devices to ask its CIS-enabled parent bus for CIS info. +# Device driver requests all tuples if type 'id', the routine places +# 'nret' number of tuples in 'buff'. Returns 0 if all tuples processed, +# or an error code if processing was aborted. +# Users of this method will be responsible for freeing the memory allocated +# by calling the cis_free method. +# + +HEADER { + struct cis_tupleinfo { + u_int8_t id; + int len; + char *data; + }; +}; + +CODE { + static int + null_cis_read(device_t dev, device_t child, u_int8_t id, + struct cis_tupleinfo **buff, int *nret) + { + *nret = 0; + *buff = NULL; + return ENXIO; + } + + static void + null_cis_free(device_t dev, struct cis_tupleinfo *buff, int *nret) + { + return; + } +}; + +METHOD int cis_read { + device_t dev; + device_t child; + u_int8_t id; + struct cis_tupleinfo **buff; + int *nret; +} DEFAULT null_cis_read; + +METHOD int cis_free { + device_t dev; + struct cis_tupleinfo *buff; + int nret; +} DEFAULT null_cis_free; + diff --git a/sys/dev/misc/pccard/devlist2h.awk b/sys/bus/pccard/devlist2h.awk similarity index 72% rename from sys/dev/misc/pccard/devlist2h.awk rename to sys/bus/pccard/devlist2h.awk index a62ab5c2d1..caf1a7ac31 100644 --- a/sys/dev/misc/pccard/devlist2h.awk +++ b/sys/bus/pccard/devlist2h.awk @@ -1,7 +1,7 @@ #! /usr/bin/awk -f # $NetBSD: devlist2h.awk,v 1.3 1998/09/05 14:42:06 christos Exp $ -# $FreeBSD: src/sys/dev/pccard/devlist2h.awk,v 1.1 1999/10/26 06:52:28 imp Exp $ -# $DragonFly: src/sys/dev/misc/pccard/Attic/devlist2h.awk,v 1.2 2003/06/17 04:28:29 dillon Exp $ +# $FreeBSD: src/sys/dev/pccard/devlist2h.awk,v 1.3 2003/03/28 06:43:50 imp Exp $ +# $DragonFly: src/sys/bus/pccard/devlist2h.awk,v 1.1 2004/02/10 07:55:45 joerg Exp $ # # Copyright (c) 1998 The NetBSD Foundation, Inc. # All rights reserved. @@ -94,23 +94,13 @@ function collectline(f, line) { } BEGIN { nproducts = nvendors = 0 - dfile="pccarddevs_data.h" hfile="pccarddevs.h" } NR == 1 { VERSION = $0 gsub("\\$", "", VERSION) - printf("/*\t\$FreeBSD\$\t*/\n\n") > dfile - printf("/*\n") > dfile - printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ - > dfile - printf(" *\n") > dfile - printf(" * generated from:\n") > dfile - printf(" *\t%s\n", VERSION) > dfile - printf(" */\n") > dfile - - printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile + printf("/*\t\$DragonFly\$\t*/\n\n") > hfile printf("/*\n") > hfile printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ > hfile @@ -126,8 +116,10 @@ $1 == "vendor" { vendorindex[$2] = nvendors; # record index for this name, for later. vendors[nvendors, 1] = $2; # name + if ($3 == "-1") + $3 = "0xffffffff"; vendors[nvendors, 2] = $3; # id - printf("#define\tPCCARD_VENDOR_%s\t%s\t", vendors[nvendors, 1], + printf("#define\tPCMCIA_VENDOR_%s\t%s\t", vendors[nvendors, 1], vendors[nvendors, 2]) > hfile vendors[nvendors, 3] = collectline(4, line) printf("/* %s */\n", vendors[nvendors, 3]) > hfile @@ -137,13 +129,15 @@ $1 == "product" { nproducts++ products[nproducts, 1] = $2; # vendor name + if ($3 == "-1") + $3 = "0xffffffff"; products[nproducts, 2] = $3; # product id products[nproducts, 3] = $4; # id f = 5; if ($4 == "{") { - products[nproducts, 3] = -1 + products[nproducts, 3] = "0xffffffff"; z = "{ " for (i = 0; i < 4; i++) { if (f <= NF) { @@ -166,62 +160,20 @@ $1 == "product" { else { products[nproducts, 4] = "{ NULL, NULL, NULL, NULL }" } - printf("#define\tPCCARD_CIS_%s_%s\t%s\n", + printf("#define\tPCMCIA_CIS_%s_%s\t%s\n", products[nproducts, 1], products[nproducts, 2], products[nproducts, 4]) > hfile - printf("#define\tPCCARD_PRODUCT_%s_%s\t%s\n", products[nproducts, 1], + printf("#define\tPCMCIA_PRODUCT_%s_%s\t%s\n", products[nproducts, 1], products[nproducts, 2], products[nproducts, 3]) > hfile products[nproducts, 5] = collectline(f, line) - printf("#define\tPCCARD_STR_%s_%s\t\"%s\"\n", + printf("#define\tPCMCIA_STR_%s_%s\t\"%s\"\n", products[nproducts, 1], products[nproducts, 2], products[nproducts, 5]) > hfile next } { - if ($0 == "") - blanklines++ print $0 > hfile - if (blanklines < 2) - print $0 > dfile -} -END { - # print out the match tables - - printf("\n") > dfile - - printf("struct pccard_knowndev pccard_knowndevs[] = {\n") > dfile - for (i = 1; i <= nproducts; i++) { - printf("\t{\n") > dfile - if (products[i, 3] == -1) { - printf("\t PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_%s_%s,\n", - products[i, 1], products[i, 2]) > dfile - } else { - printf("\t PCCARD_VENDOR_%s, PCCARD_PRODUCT_%s_%s,\n", - products[i, 1], products[i, 1], products[i, 2]) > dfile - } - printf("\t PCCARD_CIS_%s_%s,\n", - products[i, 1], products[i, 2]) > dfile - printf("\t ") > dfile - printf("0") > dfile - printf(",\n") > dfile - - vendi = vendorindex[products[i, 1]]; - printf("\t \"%s\",\n", vendors[vendi, 3]) > dfile - printf("\t \"%s\"\t},\n", products[i, 5]) > dfile - printf("\t},\n") > dfile - } - for (i = 1; i <= nvendors; i++) { - printf("\t{\n") > dfile - printf("\t PCCARD_VENDOR_%s, 0,\n", vendors[i, 1]) > dfile - printf("\t PCCARD_KNOWNDEV_NOPROD,\n") > dfile - printf("\t PCCARD_CIS_INVALID,\n") > dfile - printf("\t \"%s\",\n", vendors[i, 3]) > dfile - printf("\t NULL,\n") > dfile - printf("\t},\n") > dfile - } - printf("\t{ 0, 0, { NULL, NULL, NULL, NULL }, 0, NULL, NULL, }\n") > dfile - printf("};\n") > dfile } diff --git a/sys/bus/pccard/i82365.h b/sys/bus/pccard/i82365.h deleted file mode 100644 index cac33fd655..0000000000 --- a/sys/bus/pccard/i82365.h +++ /dev/null @@ -1,332 +0,0 @@ -/* - * i82365.h - Definitions for Intel 82365 PCIC - * PCMCIA Card Interface Controller - * - * originally by Barry Jaspan; hacked over by Keith Moore - * hacked to unrecognisability by Andrew McRae (andrew@mega.com.au) - * - * Updated 3/3/95 to include Cirrus Logic stuff. - *------------------------------------------------------------------------- - * - * Copyright (c) 2001 M. Warner Losh. All rights reserved. - * Copyright (c) 1995 Andrew McRae. 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. 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. - * - * $FreeBSD: src/sys/pccard/i82365.h,v 1.10.2.9 2002/09/22 20:26:58 imp Exp $ - * $DragonFly: src/sys/bus/pccard/Attic/i82365.h,v 1.2 2003/06/17 04:28:55 dillon Exp $ - */ - -#define PCIC_I82365 0 /* Intel i82365SL-A/B or clone */ -#define PCIC_IBM 1 /* IBM clone */ -#define PCIC_VLSI 2 /* VLSI chip */ -#define PCIC_PD6722 3 /* Cirrus logic PD6722 */ -#define PCIC_PD6710 4 /* Cirrus logic PD6710 */ -#define PCIC_VG365 5 /* Vadem 365 */ -#define PCIC_VG465 6 /* Vadem 465 */ -#define PCIC_VG468 7 /* Vadem 468 */ -#define PCIC_VG469 8 /* Vadem 469 */ -#define PCIC_RF5C296 9 /* Ricoh RF5C296 */ -#define PCIC_RF5C396 10 /* Ricoh RF5C396 */ -#define PCIC_IBM_KING 11 /* IBM KING PCMCIA Controller */ -#define PCIC_I82365SL_DF 12 /* Intel i82365sl-DF step */ -#define PCIC_PD6729 13 /* Cirrus Logic PD6729 */ -#define PCIC_PD673X 14 /* Cirrus Logic PD673x */ - -/* - * Address of the controllers. Each controller can manage - * two PCMCIA slots. Up to 8 slots are supported in total. - * The PCIC controller is accessed via an index port and a - * data port. The index port has the 8 bit address of the - * register accessed via the data port. How I long for - * real memory mapped I/O! - * The top two bits of the index address are used to - * identify the port number, and the lower 6 bits - * select one of the 64 possible data registers. - */ -#define PCIC_INDEX 0 /* Index register */ -#define PCIC_DATA 1 /* Data register */ -#define PCIC_NPORT 2 /* Number of ports */ -#define PCIC_PORT_0 0x3e0 /* index reg, chips 0 and 1 */ - -/* - * Register index addresses. - */ -#define PCIC_ID_REV 0x00 /* Identification and Revision */ -#define PCIC_STATUS 0x01 /* Interface Status */ -#define PCIC_POWER 0x02 /* Power and RESETDRV control */ -#define PCIC_INT_GEN 0x03 /* Interrupt and General Control */ -#define PCIC_STAT_CHG 0x04 /* Card Status Change */ -#define PCIC_STAT_INT 0x05 /* Card Status Change Interrupt Config */ -#define PCIC_ADDRWINE 0x06 /* Address Window Enable */ -#define PCIC_IOCTL 0x07 /* I/O Control */ -#define PCIC_IO0 0x08 /* I/O Address 0 */ -#define PCIC_IO1 0x0c /* I/O Address 1 */ -#define PCIC_MEMBASE 0x10 /* Base of memory window registers */ -#define PCIC_CDGC 0x16 /* Card Detect and General Control */ -#define PCIC_MISC1 0x16 /* PD67xx: Misc control register 1 per slot */ -#define PCIC_GLO_CTRL 0x1e /* Global Control Register */ -#define PCIC_MISC2 0x1e /* PD67xx: Misc control register 2 per chip */ -#define PCIC_CLCHIP 0x1f /* PD67xx: Chip I/D */ -#define PCIC_EXT_IND 0x2e /* PD67xx: Extended Index */ -#define PCIC_EXTENDED 0x2f /* PD67xx: Extended register */ -#define PCIC_CVSR 0x2f /* Vadem: Voltage select register */ -#define PCIC_RICOH_MCR2 0x2f /* Ricoh: Mode Control Register 2 */ - -#define PCIC_VMISC 0x3a /* Vadem: Misc control register */ -#define PCIC_RICOH_ID 0x3a /* Ricoh: ID register */ - -#define PCIC_TOPIC_FCR 0x3e /* Toshiba ToPIC: Function Control Register */ - -#define PCIC_TIME_SETUP0 0x3a -#define PCIC_TIME_CMD0 0x3b -#define PCIC_TIME_RECOV0 0x3c -#define PCIC_TIME_SETUP1 0x3d -#define PCIC_TIME_CMD1 0x3e -#define PCIC_TIME_RECOV1 0x3f - -/* Yenta only registers */ -#define PCIC_MEMORY_HIGH0 0x40 /* A31..A25 of mapping addres for */ -#define PCIC_MEMORY_HIGH1 0x41 /* the memory windows. */ -#define PCIC_MEMORY_HIGH2 0x42 -#define PCIC_MEMORY_HIGH3 0x43 - - -#define PCIC_SLOT_SIZE 0x40 /* Size of register set for one slot */ - -/* Now register bits, ordered by reg # */ - -/* For Identification and Revision (PCIC_ID_REV) */ -#define PCIC_INTEL0 0x82 /* Intel 82365SL Rev. 0; Both Memory and I/O */ -#define PCIC_INTEL1 0x83 /* Intel 82365SL Rev. 1; Both Memory and I/O */ -#define PCIC_INTEL2 0x84 /* Intel 82365SL step D */ -#define PCIC_VLSI82C146 0x84 /* VLSI 82C146 */ -#define PCIC_IBM1 0x88 /* IBM PCIC clone; Both Memory and I/O */ -#define PCIC_IBM2 0x89 /* IBM PCIC clone; Both Memory and I/O */ -#define PCIC_IBM3 0x8a /* IBM KING PCIC clone; Both Memory and I/O */ - -/* For Interface Status register (PCIC_STATUS) */ -#define PCIC_VPPV 0x80 /* Vpp_valid or reserved*/ -#define PCIC_RICOH_5VCARD 0x80 /* 5V card detected */ -#define PCIC_POW 0x40 /* PC Card power active */ -#define PCIC_READY 0x20 /* Ready/~Busy */ -#define PCIC_MWP 0x10 /* Memory Write Protect */ -#define PCIC_CD 0x0C /* Both card detect bits */ -#define PCIC_BVD 0x03 /* Both Battery Voltage Detect bits */ - -/* For the Power and RESETDRV register (PCIC_POWER) */ -#define PCIC_OUTENA 0x80 /* Output Enable */ -#define PCIC_DISRST 0x40 /* Disable RESETDRV */ -#define PCIC_APSENA 0x20 /* Auto Pwer Switch Enable */ -#define PCIC_PCPWRE 0x10 /* PC Card Power Enable */ -#define PCIC_VCC 0x18 /* Vcc control bits */ -#define PCIC_VCC_5V 0x10 /* 5 volts */ -#define PCIC_VCC_ON 0x10 /* Turn on VCC on some chips. */ -#define PCIC_VCC_3V 0x18 /* 3 volts */ -#define PCIC_VCC_5V_KING 0x14 /* 5 volts for KING PCIC */ -#define PCIC_VPP 0x03 /* Vpp control bits */ -#define PCIC_VPP_5V 0x01 /* 5 volts */ -#define PCIC_VPP_12V 0x02 /* 12 volts */ - -/* For the Interrupt and General Control register (PCIC_INT_GEN) */ -#define PCIC_CARDRESET 0x40 /* Card reset 0 = Reset, 1 = Normal */ -#define PCIC_CARDTYPE 0x20 /* Card Type 0 = memory, 1 = I/O */ -#define PCIC_IOCARD 0x20 -#define PCIC_MEMCARD 0x00 -#define PCIC_INTR_ENA 0x10 /* PCI CSC Interrupt enable */ - -/* For the Card Status Change register (PCIC_STAT_CHG) */ -#define PCIC_CDTCH 0x08 /* Card Detect Change */ -#define PCIC_RDYCH 0x04 /* Ready Change */ -#define PCIC_BATWRN 0x02 /* Battery Warning */ -#define PCIC_BATDED 0x01 /* Battery Dead */ - -/* For the Card status change interrupt PCIC_STAT_INT */ -#define PCIC_CSCSELECT 0xf0 /* CSCSELECT */ -#define PCIC_SI_IRQ_SHIFT 4 -#define PCIC_CDEN 0x8 -#define PCIC_READYEN 0x4 -#define PCIC_BATWARNEN 0x2 -#define PCIC_BATDEADEN 0x1 - -/* - * For the Address Window Enable Register (PCIC_ADDRWINE) - * The lower 6 bits contain enable bits for the memory - * windows (LSB = memory window 0). - */ -#define PCIC_MEMCS16 0x20 /* ~MEMCS16 Decode A23-A12 */ -#define PCIC_IO0_EN 0x40 /* I/O Window 0 Enable */ -#define PCIC_IO1_EN 0x80 /* I/O Window 1 Enable */ - -/* - * For the I/O Control Register (PCIC_IOCTL) - * The lower nybble is the flags for I/O window 0 - * The upper nybble is the flags for I/O window 1 - */ -#define PCIC_IO_16BIT 0x01 /* I/O to this segment is 16 bit */ -#define PCIC_IO_CS16 0x02 /* I/O cs16 source is the card */ -#define PCIC_IO_0WS 0x04 /* zero wait states added on 8 bit cycles */ -#define PCIC_IO_WS 0x08 /* Wait states added for 16 bit cycles */ - -/* - * The memory window registers contain the start and end - * physical host address that the PCIC maps to the card, - * and an offset calculated from the card memory address. - * All values are shifted down 12 bits, so allocation is - * done in 4Kb blocks. Only 12 bits of each value is - * stored, limiting the range to the ISA address size of - * 24 bits. The upper 4 bits of the most significant byte - * within the values are used for various flags. - * - * The layout is: - * - * base+0 : lower 8 bits of system memory start address - * base+1 : upper 4 bits of system memory start address + flags - * base+2 : lower 8 bits of system memory end address - * base+3 : upper 4 bits of system memory end address + flags - * base+4 : lower 8 bits of offset to card address - * base+5 : upper 4 bits of offset to card address + flags - * - * The following two bytes are reserved for other use. - */ -#define PCIC_MEMSIZE 8 -/* - * Flags for system memory start address upper byte - */ -#define PCIC_ZEROWS 0x40 /* Zero wait states */ -#define PCIC_DATA16 0x80 /* Data width is 16 bits */ - -/* - * Flags for system memory end address upper byte - */ -#define PCIC_MW0 0x40 /* Wait state bit 0 */ -#define PCIC_MW1 0x80 /* Wait state bit 1 */ - -/* - * Flags for card offset upper byte - */ -#define PCIC_REG 0x40 /* Attribute/Common select (why called Reg?) */ -#define PCIC_WP 0x80 /* Write-protect this window */ - -/* For Card Detect and General Control register (PCIC_CDGC) */ -#define PCIC_16_DL_INH 0x01 /* 16-bit memory delay inhibit */ -#define PCIC_CNFG_RST_EN 0x02 /* configuration reset enable */ -#define PCIC_GPI_EN 0x04 /* GPI Enable */ -#define PCIC_GPI_TRANS 0x08 /* GPI Transition Control */ -#define PCIC_CDRES_EN 0x10 /* card detect resume enable */ -#define PCIC_SW_CD_INT 0x20 /* s/w card detect interrupt */ -#define PCIC_VS1STAT 0x40 /* 0 VS1# low, 1 VS1# high */ -#define PCIC_VS2STAT 0x80 /* 0 VS2# low, 1 VS2# high */ - -/* CL-PD67[12]x: For 3.3V cards, etc. (PCIC_MISC1) */ -#define PCIC_MISC1_5V_DETECT 0x01 /* PD6710 only */ -#define PCIC_MISC1_VCC_33 0x02 /* Set Vcc is 3.3V, else 5.0V */ -#define PCIC_MISC1_PMINT 0x04 /* Pulse management intr */ -#define PCIC_MISC1_PCINT 0x08 /* Pulse card interrupt */ -#define PCIC_MISC1_SPEAKER 0x10 /* Enable speaker */ -#define PCIC_MISC1_INPACK 0x80 /* INPACK throttles data */ - -/* i82365B and newer (!PD67xx) Global Control register (PCIC_GLO_CTRL) */ -#define PCIC_PWR_DOWN 0x01 /* power down */ -#define PCIC_LVL_MODE 0x02 /* level mode interrupt enable */ -#define PCIC_WB_CSCINT 0x04 /* explicit write-back csc intr */ -/* Rev B only */ -#define PCIC_IRQ0_LEVEL 0x08 /* irq 14 pulse mode enable */ -#define PCIC_IRQ1_LEVEL 0x10 - -/* CL-PD67[12]x: For Misc. Control Register 2 (PCIC_MISC2) */ -#define PCIC_LPDM_EN 0x02 /* Cirrus PD672x: low power dynamic mode */ - -/* CL-PD67[12]x: Chip info (PCIC_CLCHIP) */ -#define PCIC_CLC_TOGGLE 0xc0 /* These bits toggle 1 -> 0 */ -#define PCIC_CLC_DUAL 0x20 /* Single/dual socket version */ - -/* Cirrus Logic: Extended Registers (PCIC_EXT_IND) */ -#define PCIC_EXT_DATA 0x0a /* External Data */ - -/* EXT_DATA */ -#define PCIC_VS1A 0x01 -#define PCIC_VS2A 0x02 -#define PCIC_VS1B 0x04 -#define PCIC_VS2B 0x08 - -/* Cirrus Logic: Extended register Extension Control 1 */ -#define PCIC_EXTCTRL1 0x03 -#define PCIC_EC1_VCC_LOCK 0x1 /* Vcc Power locked to s/w change */ -#define PCIC_EC1_AUTO_POWER_CLEAR 0x2 /* Vcc power cleared on eject? */ -#define PCIC_EC1_LED_ENABLE 0x4 /* LED activity enable */ -#define PCIC_EC1_CARD_IRQ_INV 0x8 /* Card IRQ level inverted for pci? */ -#define PCIC_EC1_CSC_IRQ_INV 0x10 /* CSC IRQ level inverted for pci? */ -#define PCIC_EC1_PULLUP 0x20 /* Dis pullup when 1. */ - -/* Vadem: Card Voltage Select register (PCIC_CVSR) */ -#define PCIC_CVSR_VS 0x03 /* Voltage select */ -#define PCIC_CVSR_VS_5 0x00 /* 5.0 V */ -#define PCIC_CVSR_VS_33a 0x01 /* alt 3.3V */ -#define PCIC_CVSR_VS_XX 0x02 /* X.XV when available */ -#define PCIC_CVSR_VS_33 0x03 /* 3.3V */ - -/* Ricoh: Misc Control Register 2 (PCIC_RICOH_MCR2) */ -#define PCIC_MCR2_VCC_33 0x01 /* 3.3V */ - -/* Vadem: misc register (PCIC_VMISC) */ -#define PCIC_VADEMREV 0x40 - -/* Ricoh: ID register values (PCIC_RICOH_ID) */ -#define PCIC_RID_296 0x32 -#define PCIC_RID_396 0xb2 - -/* Toshiba ToPIC: Function Control Register */ -#define PCIC_FCR_3V_EN 0x01 /* Enable 3V cards */ -#define PCIC_FCR_VS_EN 0x02 /* Voltage Sense enable */ - -/* - * Mask of allowable interrupts. - * - * For IBM-AT machines, irqs 3, 4, 5, 7, 9, 10, 11, 12, 14, 15 are - * allowed. Nearly all IBM-AT machines with pcic cards or bridges - * wire these interrupts (or a subset thereof) to the corresponding - * pins on the ISA bus. Some older laptops are reported to not route - * all the interrupt pins to the bus because the designers knew that - * some would conflict with builtin devices. - * - * For NEC PC98 machines, irq 3, 5, 6, 9, 10, 11, 12, 13 are allowed. - * These correspond to the C-BUS signals INT 0, 1, 2, 3, 41, 42, 5, 6 - * respectively. This is with the desktop C-BUS addin card. - * - * Hiroshi TSUKADA-san writes in FreeBSD98-testers that cbus IRQ - * 6 is routed to the IRQ 7 pin of the pcic in pc98 cbus based - * cards. I do not know how pc98 laptop models are wired. - */ -#ifdef PC98 -#define PCIC_INT_MASK_ALLOWED 0x3E68 /* PC98 */ -#else -#define PCIC_INT_MASK_ALLOWED 0xDEB8 /* AT */ -#endif - -#define PCIC_IO_WIN 2 -#define PCIC_MEM_WIN 5 - -#define PCIC_CARD_SLOTS 4 -#define PCIC_MAX_CARDS 2 -#define PCIC_MAX_SLOTS (PCIC_MAX_CARDS * PCIC_CARD_SLOTS) diff --git a/sys/bus/pccard/mecia.c b/sys/bus/pccard/mecia.c deleted file mode 100644 index 765a854295..0000000000 --- a/sys/bus/pccard/mecia.c +++ /dev/null @@ -1,767 +0,0 @@ -/* - * NEC MECIA controller. - *------------------------------------------------------------------------- - * - * Copyright (c) 2001 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 ``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. - * - * $FreeBSD: src/sys/pccard/mecia.c,v 1.2.2.4 2001/08/14 23:36:18 imp Exp $ - * $DragonFly: src/sys/bus/pccard/Attic/mecia.c,v 1.3 2003/08/07 21:16:46 dillon Exp $ - * - * Based heavily on the FreeBSD pcic driver's pcic98 support, derived - * from PAO3 tree. This copyright notice likely needs modification for - * such a linage. The only authorship I could find was: - * - * PC9801 original PCMCIA controller code for NS/A,Ne,NX/C,NR/L. - * by Noriyuki Hosobuchi - */ - -#include -#include -#include -#include -#include - -#include "meciareg.h" -#include "cardinfo.h" -#include "slot.h" -#ifndef MECIA_IOBASE -#define MECIA_IOBASE 0x80d0 -#endif - -/* Get pnp IDs */ -#include - -#include -#include "card_if.h" - -#define MECIA_DEVICE2SOFTC(dev) ((struct mecia_slot *) device_get_softc(dev)) - -/* - * Prototypes for interrupt handler. - */ -static driver_intr_t meciaintr; -static int mecia_ioctl(struct slot *, int, caddr_t); -static int mecia_power(struct slot *); -static void mecia_mapirq(struct slot *, int); -static timeout_t mecia_reset; -static void mecia_resume(struct slot *); -static void mecia_disable(struct slot *); -static timeout_t meciatimeout; -static struct callout_handle meciatimeout_ch - = CALLOUT_HANDLE_INITIALIZER(&meciatimeout_ch); -static int mecia_memory(struct slot *, int); -static int mecia_io(struct slot *, int); - -/* - * Per-slot data table. - */ -struct mecia_slot { - int unit; /* Unit number */ - int slotnum; /* My slot number */ - struct slot *slt; /* Back ptr to slot */ - device_t dev; /* My device */ - u_char last_reg1; /* Last value of change reg */ -}; - -static struct slot_ctrl mecia_cinfo = { - mecia_mapirq, - mecia_memory, - mecia_io, - mecia_reset, - mecia_disable, - mecia_power, - mecia_ioctl, - mecia_resume, - 1, -#if 0 - 1 -#else - 2 /* Fake for UE2212 LAN card */ -#endif -}; - -static int validunits = 0; - -/* - * Look for an NEC MECIA. - * For each available slot, allocate a PC-CARD slot. - */ - -static int -mecia_probe(device_t dev) -{ - int validslots = 0; - - /* Check isapnp ids */ - if (isa_get_logicalid(dev)) /* skip PnP probes */ - return (ENXIO); - - if (inb(MECIA_REG0) != 0xff) { - validslots++; - /* XXX need to allocated the port resources */ - device_set_desc(dev, "MECIA PC98 Original PCMCIA Controller"); - } - return (validslots ? 0 : ENXIO); -} - -static int -mecia_attach(device_t dev) -{ - int error; - int irq; - void *ih; - device_t kid; - struct resource *r; - int rid; - struct slot *slt; - struct mecia_slot *sp; - - sp = MECIA_DEVICE2SOFTC(dev); - sp->unit = validunits++; - kid = device_add_child(dev, NULL, -1); - if (kid == NULL) { - device_printf(dev, "Can't add pccard bus slot 0\n"); - return (ENXIO); - } - device_probe_and_attach(kid); - slt = pccard_init_slot(kid, &mecia_cinfo); - if (slt == 0) { - device_printf(dev, "Can't get pccard info slot 0\n"); - return (ENXIO); - } - slt->cdata = sp; - sp->slt = slt; - validunits++; - - rid = 0; - r = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE); - if (!r) - return (ENXIO); - - irq = bus_get_resource_start(dev, SYS_RES_IRQ, 0); - if (irq == 0) { - /* See if the user has requested a specific IRQ */ - if (!getenv_int("machdep.pccard.mecia_irq", &irq)) - irq = 0; - } - rid = 0; - r = 0; - if (irq > 0) { - r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, irq, - irq, 1, RF_ACTIVE); - } - if (r && ((1 << (rman_get_start(r))) & MECIA_INT_MASK_ALLOWED) == 0) { - device_printf(dev, - "Hardware does not support irq %d, trying polling.\n", - irq); - bus_release_resource(dev, SYS_RES_IRQ, rid, r); - r = 0; - irq = 0; - } - if (r) { - error = bus_setup_intr(dev, r, INTR_TYPE_MISC, - meciaintr, (void *) sp, &ih); - if (error) { - bus_release_resource(dev, SYS_RES_IRQ, rid, r); - return (error); - } - irq = rman_get_start(r); - device_printf(dev, "management irq %d\n", irq); - } else { - irq = 0; - } - if (irq == 0) { - meciatimeout_ch = timeout(meciatimeout, (void *) sp, hz/2); - device_printf(dev, "Polling mode\n"); - } - - sp->last_reg1 = inb(MECIA_REG1); - if (sp->last_reg1 & MECIA_CARDEXIST) { - /* PCMCIA card exist */ - sp->slt->laststate = sp->slt->state = filled; - pccard_event(sp->slt, card_inserted); - } else { - sp->slt->laststate = sp->slt->state = empty; - } - sp->slt->irq = irq; - - return (bus_generic_attach(dev)); -} - -static int -mecia_sresource(struct slot *slt, caddr_t data) -{ - struct pccard_resource *pr; - struct resource *r; - int flags; - int rid = 0; - device_t pccarddev = slt->dev; - - pr = (struct pccard_resource *)data; - pr->resource_addr = ~0ul; - switch(pr->type) { - default: - return (EINVAL); - case SYS_RES_MEMORY: - case SYS_RES_IRQ: - case SYS_RES_IOPORT: - break; - } - flags = rman_make_alignment_flags(pr->size); - r = bus_alloc_resource(pccarddev, pr->type, &rid, pr->min, pr->max, - pr->size, flags); - if (r != NULL) { - pr->resource_addr = (u_long)rman_get_start(r); - bus_release_resource(bridgedev, pr->type, rid, r); - } - return (0); -} - -/* - * ioctl calls - Controller specific ioctls - */ -static int -mecia_ioctl(struct slot *slt, int cmd, caddr_t data) -{ - switch(cmd) { - default: - return (ENOTTY); - case PIOCSRESOURCE: /* Can I use this resource? */ - mecia_sresource(slt, data); - break; - } - return (0); -} - -/* - * MECIA timer. If the controller doesn't have a free IRQ to use - * or if interrupt steering doesn't work, poll the controller for - * insertion/removal events. - */ -static void -meciatimeout(void *chan) -{ - meciaintr(chan); - meciatimeout_ch = timeout(meciatimeout, chan, hz/2); -} - -/* - * MECIA Interrupt handler. - * Check the slot and report any changes. - */ -static void -meciaintr(void *arg) -{ - u_char reg1; - int s; - struct mecia_slot *sp = (struct mecia_slot *) arg; - - s = splhigh(); - /* Check for a card in this slot */ - reg1 = inb(MECIA_REG1); - if ((sp->last_reg1 ^ reg1) & MECIA_CARDEXIST) { - sp->last_reg1 = reg1; - if (reg1 & MECIA_CARDEXIST) - pccard_event(sp->slt, card_inserted); - else - pccard_event(sp->slt, card_removed); - } - splx(s); -} - -/* - * local functions for PC-98 Original PC-Card controller - */ -#define MECIA_ALWAYS_128MAPPING 1 /* trick for using UE2212 */ - -int mecia_mode = 0; /* almost the same as the value in MECIA_REG2 */ - -static unsigned char reg_winsel = MECIA_UNMAPWIN; -static unsigned short reg_pagofs = 0; - -static int -mecia_memory(struct slot *slt, int win) -{ - struct mem_desc *mp = &slt->mem[win]; - unsigned char x; - - if (mp->flags & MDF_ACTIVE) { - /* slot = 0, window = 0, sys_addr = 0xda000, length = 8KB */ - if ((unsigned long)mp->start != 0xda000) { - printf( - "sys_addr must be 0xda000. requested address = %p\n", - mp->start); - return (EINVAL); - } - - /* omajinai ??? */ - outb(MECIA_REG0, 0); - x = inb(MECIA_REG1); - x &= 0xfc; - x |= 0x02; - outb(MECIA_REG1, x); - reg_winsel = inb(MECIA_REG_WINSEL); - reg_pagofs = inw(MECIA_REG_PAGOFS); - outb(MECIA_REG_WINSEL, MECIA_MAPWIN); - outw(MECIA_REG_PAGOFS, (mp->card >> 13)); /* 8KB */ - - if (mp->flags & MDF_ATTR) - outb(MECIA_REG7, inb(MECIA_REG7) | MECIA_ATTRMEM); - else - outb(MECIA_REG7, inb(MECIA_REG7) & (~MECIA_ATTRMEM)); - - outb(MECIA_REG_WINSEL, MECIA_MAPWIN); -#if 0 - if ((mp->flags & MDF_16BITS) == 1) /* 16bit */ - outb(MECIA_REG2, inb(MECIA_REG2) & (~MECIA_8BIT)); - else /* 8bit */ - outb(MECIA_REG2, inb(MECIA_REG2) | MECIA_8BIT); -#endif - } else { /* !(mp->flags & MDF_ACTIVE) */ - outb(MECIA_REG0, 0); - x = inb(MECIA_REG1); - x &= 0xfc; - x |= 0x02; - outb(MECIA_REG1, x); -#if 0 - outb(MECIA_REG_WINSEL, MECIA_UNMAPWIN); - outw(MECIA_REG_PAGOFS, 0); -#else - outb(MECIA_REG_WINSEL, reg_winsel); - outw(MECIA_REG_PAGOFS, reg_pagofs); -#endif - } - return (0); -} - -static int -mecia_io(struct slot *slt, int win) -{ - struct io_desc *ip = &slt->io[win]; - unsigned char x; - unsigned short cardbase; - u_short ofst; - - if (win != 0) { - /* ignore for UE2212 */ - printf( - "mecia:Illegal MECIA I/O window(%d) request! Ignored.\n", win); -/* return (EINVAL);*/ - return (0); - } - - if (ip->flags & IODF_ACTIVE) { - x = inb(MECIA_REG2) & 0x0f; -#if 0 - if (! (ip->flags & IODF_CS16)) - x |= MECIA_8BIT; -#else - if (! (ip->flags & IODF_16BIT)) { - x |= MECIA_8BIT; - mecia_mode |= MECIA_8BIT; - } -#endif - - ofst = ip->start & 0xf; - cardbase = ip->start & ~0xf; -#ifndef MECIA_ALWAYS_128MAPPING - if (ip->size + ofst > 16) -#endif - { /* 128bytes mapping */ - x |= MECIA_MAP128; - mecia_mode |= MECIA_MAP128; - ofst |= ((cardbase & 0x70) << 4); - cardbase &= ~0x70; - } - - x |= MECIA_MAPIO; - outb(MECIA_REG2, x); - - outw(MECIA_REG4, MECIA_IOBASE); /* 98side I/O base */ - outw(MECIA_REG5, cardbase); /* card side I/O base */ - - if (bootverbose) { - printf("mecia: I/O mapped 0x%04x(98) -> " - "0x%04x(Card) and width %d bytes\n", - MECIA_IOBASE+ofst, ip->start, ip->size); - printf("mecia: reg2=0x%02x reg3=0x%02x reg7=0x%02x\n", - inb(MECIA_REG2), inb(MECIA_REG3), - inb(MECIA_REG7)); - printf("mecia: mode=%d\n", mecia_mode); - } - - ip->start = MECIA_IOBASE + ofst; - } else { - outb(MECIA_REG2, inb(MECIA_REG2) & (~MECIA_MAPIO)); - mecia_mode = 0; - } - return (0); -} - -static int -mecia_power(struct slot *slt) -{ - unsigned char reg; - - reg = inb(MECIA_REG7) & (~MECIA_VPP12V); - switch(slt->pwr.vpp) { - default: - return (EINVAL); - case 50: - break; - case 120: - reg |= MECIA_VPP12V; - break; - } - outb(MECIA_REG7, reg); - DELAY(100*1000); - - reg = inb(MECIA_REG2) & (~MECIA_VCC3P3V); - switch(slt->pwr.vcc) { - default: - return (EINVAL); - case 33: - reg |= MECIA_VCC3P3V; - break; - case 50: - break; - } - outb(MECIA_REG2, reg); - DELAY(100*1000); - return (0); -} - -static void -mecia_mapirq(struct slot *slt, int irq) -{ - u_char x; - - switch (irq) { - case 3: - x = MECIA_INT0; - break; - case 5: - x = MECIA_INT1; - break; - case 6: - x = MECIA_INT2; - break; - case 10: - x = MECIA_INT4; - break; - case 12: - x = MECIA_INT5; - break; - case 0: /* disable */ - x = MECIA_INTDISABLE; - break; - default: - printf("mecia: illegal irq %d\n", irq); - return; - } -#ifdef MECIA_DEBUG - printf("mecia: irq=%d mapped.\n", irq); -#endif - outb(MECIA_REG3, x); -} - -static void -mecia_reset(void *chan) -{ - struct slot *slt = chan; - - outb(MECIA_REG0, 0); - outb(MECIA_REG2, inb(MECIA_REG2) & (~MECIA_MAPIO)); - outb(MECIA_REG3, MECIA_INTDISABLE); -#if 0 -/* mecia_reset() is called after mecia_power() */ - outb(MECIA_REG2, inb(MECIA_REG2) & (~MECIA_VCC3P3V)); - outb(MECIA_REG7, inb(MECIA_REG7) & (~MECIA_VPP12V)); -#endif - outb(MECIA_REG1, 0); - - selwakeup(&slt->selp); -} - -static void -mecia_disable(struct slot *slt) -{ - /* null function */ -} - -static void -mecia_resume(struct slot *slt) -{ - /* XXX MECIA How ? */ -} - -static int -mecia_activate_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - int err; - - if (dev != device_get_parent(device_get_parent(child)) || devi == NULL) - return (bus_generic_activate_resource(dev, child, type, - rid, r)); - - switch (type) { - case SYS_RES_IOPORT: { - struct io_desc *ip; - ip = &devi->slt->io[rid]; - if (ip->flags == 0) { - if (rid == 0) - ip->flags = IODF_WS | IODF_16BIT | IODF_CS16; - else - ip->flags = devi->slt->io[0].flags; - } - ip->flags |= IODF_ACTIVE; - ip->start = rman_get_start(r); - ip->size = rman_get_end(r) - rman_get_start(r) + 1; - err = mecia_cinfo.mapio(devi->slt, rid); - if (err) - return (err); - break; - } - case SYS_RES_IRQ: - /* - * We actually defer the activation of the IRQ resource - * until the interrupt is registered to avoid stray - * interrupt messages. - */ - break; - case SYS_RES_MEMORY: { - struct mem_desc *mp; - if (rid >= NUM_MEM_WINDOWS) - return (EINVAL); - mp = &devi->slt->mem[rid]; - mp->flags |= MDF_ACTIVE; - mp->start = (caddr_t) rman_get_start(r); - mp->size = rman_get_end(r) - rman_get_start(r) + 1; - err = mecia_cinfo.mapmem(devi->slt, rid); - if (err) - return (err); - break; - } - default: - break; - } - err = bus_generic_activate_resource(dev, child, type, rid, r); - return (err); -} - -static int -mecia_deactivate_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - int err; - - if (dev != device_get_parent(device_get_parent(child)) || devi == NULL) - return (bus_generic_deactivate_resource(dev, child, type, - rid, r)); - - switch (type) { - case SYS_RES_IOPORT: { - struct io_desc *ip = &devi->slt->io[rid]; - ip->flags &= ~IODF_ACTIVE; - err = mecia_cinfo.mapio(devi->slt, rid); - if (err) - return (err); - break; - } - case SYS_RES_IRQ: - break; - case SYS_RES_MEMORY: { - struct mem_desc *mp = &devi->slt->mem[rid]; - mp->flags &= ~(MDF_ACTIVE | MDF_ATTR); - err = mecia_cinfo.mapmem(devi->slt, rid); - if (err) - return (err); - break; - } - default: - break; - } - err = bus_generic_deactivate_resource(dev, child, type, rid, r); - return (err); -} - -static int -mecia_setup_intr(device_t dev, device_t child, struct resource *irq, - int flags, driver_intr_t *intr, void *arg, void **cookiep) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - int err; - - if (((1 << rman_get_start(irq)) & MECIA_INT_MASK_ALLOWED) == 0) { - device_printf(dev, "Hardware does not support irq %ld.\n", - rman_get_start(irq)); - return (EINVAL); - } - - err = bus_generic_setup_intr(dev, child, irq, flags, intr, arg, - cookiep); - if (err == 0) - mecia_cinfo.mapirq(devi->slt, rman_get_start(irq)); - else - device_printf(dev, "Error %d irq %ld\n", err, - rman_get_start(irq)); - return (err); -} - -static int -mecia_teardown_intr(device_t dev, device_t child, struct resource *irq, - void *cookie) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - - mecia_cinfo.mapirq(devi->slt, 0); - return (bus_generic_teardown_intr(dev, child, irq, cookie)); -} - -static int -mecia_set_res_flags(device_t bus, device_t child, int restype, int rid, - u_long value) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - int err = 0; - - switch (restype) { - case SYS_RES_MEMORY: { - struct mem_desc *mp = &devi->slt->mem[rid]; - switch (value) { - case PCCARD_A_MEM_COM: - mp->flags &= ~MDF_ATTR; - break; - case PCCARD_A_MEM_ATTR: - mp->flags |= MDF_ATTR; - break; - case PCCARD_A_MEM_8BIT: - mp->flags &= ~MDF_16BITS; - break; - case PCCARD_A_MEM_16BIT: - mp->flags |= MDF_16BITS; - break; - } - err = mecia_cinfo.mapmem(devi->slt, rid); - break; - } - default: - err = EOPNOTSUPP; - } - return (err); -} - -static int -mecia_get_res_flags(device_t bus, device_t child, int restype, int rid, - u_long *value) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - int err = 0; - - if (value == 0) - return (ENOMEM); - - switch (restype) { - case SYS_RES_IOPORT: { - struct io_desc *ip = &devi->slt->io[rid]; - *value = ip->flags; - break; - } - case SYS_RES_MEMORY: { - struct mem_desc *mp = &devi->slt->mem[rid]; - *value = mp->flags; - break; - } - default: - err = EOPNOTSUPP; - } - return (err); -} - -static int -mecia_set_memory_offset(device_t bus, device_t child, int rid, - u_int32_t offset, u_int32_t *deltap) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - struct mem_desc *mp = &devi->slt->mem[rid]; - - mp->card = offset; - if (deltap) - *deltap = 0; /* XXX BAD XXX */ - return (mecia_cinfo.mapmem(devi->slt, rid)); -} - -static int -mecia_get_memory_offset(device_t bus, device_t child, int rid, - u_int32_t *offset) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - struct mem_desc *mp = &devi->slt->mem[rid]; - - if (offset == 0) - return (ENOMEM); - - *offset = mp->card; - - return (0); -} - -static device_method_t mecia_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, mecia_probe), - DEVMETHOD(device_attach, mecia_attach), - DEVMETHOD(device_detach, bus_generic_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - DEVMETHOD(bus_activate_resource, mecia_activate_resource), - DEVMETHOD(bus_deactivate_resource, mecia_deactivate_resource), - DEVMETHOD(bus_setup_intr, mecia_setup_intr), - DEVMETHOD(bus_teardown_intr, mecia_teardown_intr), - - /* Card interface */ - DEVMETHOD(card_set_res_flags, mecia_set_res_flags), - DEVMETHOD(card_get_res_flags, mecia_get_res_flags), - DEVMETHOD(card_set_memory_offset, mecia_set_memory_offset), - DEVMETHOD(card_get_memory_offset, mecia_get_memory_offset), - - { 0, 0 } -}; - -devclass_t mecia_devclass; - -static driver_t mecia_driver = { - "mecia", - mecia_methods, - sizeof(struct mecia_slot) -}; - -DRIVER_MODULE(mecia, isa, mecia_driver, mecia_devclass, 0, 0); diff --git a/sys/bus/pccard/meciareg.h b/sys/bus/pccard/meciareg.h deleted file mode 100644 index 403761ecfe..0000000000 --- a/sys/bus/pccard/meciareg.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * meciareg.h - * - * PC9801 original PCMCIA controller code for NS/A,Ne,NX/C,NR/L. - * by Noriyuki Hosobuchi - * - * $FreeBSD: src/sys/pccard/meciareg.h,v 1.2.2.1 2001/07/06 22:58:49 imp Exp $ - * $DragonFly: src/sys/bus/pccard/Attic/meciareg.h,v 1.2 2003/06/17 04:28:55 dillon Exp $ - */ - -/*--- I/O port definition */ -#define MECIA_REG0 0x0a8e /* byte */ -#define MECIA_REG1 0x1a8e /* byte */ -#define MECIA_REG2 0x2a8e /* byte */ -#define MECIA_REG3 0x3a8e /* byte : Interrupt */ -#define MECIA_REG4 0x4a8e /* word : PC98 side I/O base */ -#define MECIA_REG5 0x5a8e /* word : Card side I/O base */ -#define MECIA_REG7 0x7a8e /* byte */ - -#define MECIA_REG_WINSEL 0x1e8e /* byte : win bank select register */ -#define MECIA_REG_PAGOFS 0x0e8e /* word */ - -/* PC98_REG_WINSEL */ -#define MECIA_MAPWIN 0x84 /* map Card on 0xda0000 - 0xdbffff */ -#define MECIA_UNMAPWIN 0x00 - -/* MECIA_REG1 */ -#define MECIA_CARDEXIST 0x08 /* 1:exist 0:not exist */ - -/* MECIA_REG2 */ -#define MECIA_MAPIO 0x80 /* 1:I/O 0:Memory */ -#define MECIA_IOTHROUGH 0x40 /* 0:I/O map 1:I/O addr-through */ -#define MECIA_8BIT 0x20 /* bit width 1:8bit 0:16bit */ -#define MECIA_MAP128 0x10 /* I/O map size 1:128byte 0:16byte */ -#define MECIA_VCC3P3V 0x02 /* Vcc 1:3.3V 0:5.0V */ - -/* MECIA_REG3 */ -#define MECIA_INT0 (0xf8 + 0x0) /* INT0(IRQ3) */ -#define MECIA_INT1 (0xf8 + 0x1) /* INT1(IRQ5) */ -#define MECIA_INT2 (0xf8 + 0x2) /* INT2(IRQ6) */ -#define MECIA_INT4 (0xf8 + 0x4) /* INT4(IRQ10) */ -#define MECIA_INT5 (0xf8 + 0x5) /* INT5(IRQ12) */ -#define MECIA_INTDISABLE (0xf8 + 0x7) /* disable interrupt */ - -/* MECIA_REG7 */ -#define MECIA_ATTRMEM 0x20 /* 1:attr mem 0:common mem */ -#define MECIA_VPP12V 0x10 /* Vpp 0:5V 1:12V */ - - -#ifdef KERNEL -extern int mecia_mode; /* in 'pccard/pcic.c' */ -#define mecia_8bit_on() \ - if (mecia_mode & MECIA_8BIT) \ - outb(MECIA_REG2, inb(MECIA_REG2) | MECIA_8BIT) -#define mecia_8bit_off() \ - if (mecia_mode & MECIA_8BIT) \ - outb(MECIA_REG2, inb(MECIA_REG2) & ~MECIA_8BIT) -#define mecia_map128() (mecia_mode & MECIA_MAP128) -#endif - -#define MECIA_INT_MASK_ALLOWED 0x3E68 /* PC98 */ diff --git a/sys/bus/pccard/pccard.c b/sys/bus/pccard/pccard.c index 889ab4d435..5c8bd2618f 100644 --- a/sys/bus/pccard/pccard.c +++ b/sys/bus/pccard/pccard.c @@ -1,11 +1,9 @@ +/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */ +/* $FreeBSD: src/sys/dev/pccard/pccard.c,v 1.70 2002/11/14 14:02:32 mux Exp $ */ +/* $DragonFly: src/sys/bus/pccard/pccard.c,v 1.8 2004/02/10 07:55:45 joerg Exp $ + /* - * pccard.c - Interface code for PC-CARD controllers. - * - * June 1995, Andrew McRae (andrew@mega.com.au) - *------------------------------------------------------------------------- - * - * Copyright (c) 2001 M. Warner Losh. All rights reserved. - * Copyright (c) 1995 Andrew McRae. All rights reserved. + * 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 @@ -15,7 +13,10 @@ * 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. The name of the author may not be used to endorse or promote products + * 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 @@ -28,679 +29,1275 @@ * 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: src/sys/pccard/pccard.c,v 1.106.2.15 2003/02/26 18:42:00 imp Exp $ - * $DragonFly: src/sys/bus/pccard/pccard.c,v 1.7 2003/08/07 21:16:46 dillon Exp $ */ #include -#include #include -#include #include +#include +#include +#include #include -#include -#include -#include +#include + #include -#include #include +#include +#include -#include "cardinfo.h" -#include "driver.h" -#include "slot.h" -#include "pccard_nbk.h" +#include -#include +#include +#include -static int allocate_driver(struct slot *, struct dev_desc *); -static void inserted(void *); -static void disable_slot(struct slot *); -static void disable_slot_to(struct slot *); -static void power_off_slot(void *); +#include "power_if.h" +#include "card_if.h" -/* - * The driver interface for read/write uses a block - * of memory in the ISA I/O memory space allocated via - * an ioctl setting. - * - * Now that we have different bus attachments, we should really - * use a better algorythm to allocate memory. - */ -static unsigned long pccard_mem; /* Physical memory */ -static unsigned char *pccard_kmem; /* Kernel virtual address */ -static struct resource *pccard_mem_res; -static int pccard_mem_rid; - -static d_open_t crdopen; -static d_close_t crdclose; -static d_read_t crdread; -static d_write_t crdwrite; -static d_ioctl_t crdioctl; -static d_poll_t crdpoll; - -#define CDEV_MAJOR 50 -static struct cdevsw crd_cdevsw = { - /* name */ "crd", - /* maj */ CDEV_MAJOR, - /* flags */ 0, - /* port */ NULL, - /* autoq */ 0, - - /* open */ crdopen, - /* close */ crdclose, - /* read */ crdread, - /* write */ crdwrite, - /* ioctl */ crdioctl, - /* poll */ crdpoll, - /* mmap */ nommap, - /* strategy */ nostrategy, - /* dump */ nodump, - /* psize */ nopsize -}; +#define PCCARDDEBUG + +/* sysctl vars */ +SYSCTL_NODE(_hw, OID_AUTO, pccard, CTLFLAG_RD, 0, "PCCARD parameters"); + +int pccard_debug = 0; +TUNABLE_INT("hw.pccard.debug", &pccard_debug); +SYSCTL_INT(_hw_pccard, OID_AUTO, debug, CTLFLAG_RW, + &pccard_debug, 0, + "pccard debug"); + +int pccard_cis_debug = 0; +TUNABLE_INT("hw.pccard.cis_debug", &pccard_cis_debug); +SYSCTL_INT(_hw_pccard, OID_AUTO, cis_debug, CTLFLAG_RW, + &pccard_cis_debug, 0, "pccard CIS debug"); + +#ifdef PCCARDDEBUG +#define DPRINTF(arg) if (pccard_debug) printf arg +#define DEVPRINTF(arg) if (pccard_debug) device_printf arg +#define PRVERBOSE(arg) printf arg +#define DEVPRVERBOSE(arg) device_printf arg +#else +#define DPRINTF(arg) +#define DEVPRINTF(arg) +#define PRVERBOSE(arg) if (bootverbose) printf arg +#define DEVPRVERBOSE(arg) if (bootverbose) device_printf arg +#endif + +static int pccard_ccr_read(struct pccard_function *pf, int ccr); +static void pccard_ccr_write(struct pccard_function *pf, int ccr, int val); +static int pccard_attach_card(device_t dev); +static int pccard_detach_card(device_t dev); +static int pccard_card_gettype(device_t dev, int *type); +static void pccard_function_init(struct pccard_function *pf); +static void pccard_function_free(struct pccard_function *pf); +static int pccard_function_enable(struct pccard_function *pf); +static void pccard_function_disable(struct pccard_function *pf); +static int pccard_compat_do_probe(device_t bus, device_t dev); +static int pccard_compat_do_attach(device_t bus, device_t dev); +static int pccard_add_children(device_t dev, int busno); +static int pccard_probe(device_t dev); +static int pccard_attach(device_t dev); +static int pccard_detach(device_t dev); +static void pccard_print_resources(struct resource_list *rl, + const char *name, int type, int count, const char *format); +static int pccard_print_child(device_t dev, device_t child); +static int pccard_set_resource(device_t dev, device_t child, int type, + int rid, u_long start, u_long count); +static int pccard_get_resource(device_t dev, device_t child, int type, + int rid, u_long *startp, u_long *countp); +static void pccard_delete_resource(device_t dev, device_t child, int type, + int rid); +static int pccard_set_res_flags(device_t dev, device_t child, int type, + int rid, u_int32_t flags); +static int pccard_set_memory_offset(device_t dev, device_t child, int rid, + u_int32_t offset, u_int32_t *deltap); +static void pccard_probe_nomatch(device_t cbdev, device_t child); +static int pccard_read_ivar(device_t bus, device_t child, int which, + u_char *result); +static void pccard_driver_added(device_t dev, driver_t *driver); +static struct resource *pccard_alloc_resource(device_t dev, + device_t child, int type, int *rid, u_long start, + u_long end, u_long count, u_int flags); +static int pccard_release_resource(device_t dev, device_t child, int type, + int rid, struct resource *r); +static void pccard_child_detached(device_t parent, device_t dev); +static void pccard_intr(void *arg); +static int pccard_setup_intr(device_t dev, device_t child, + struct resource *irq, int flags, driver_intr_t *intr, + void *arg, void **cookiep); +static int pccard_teardown_intr(device_t dev, device_t child, + struct resource *r, void *cookie); + +static const struct pccard_product * +pccard_do_product_lookup(device_t bus, device_t dev, + const struct pccard_product *tab, size_t ent_size, + pccard_product_match_fn matchfn); + + +static int +pccard_ccr_read(struct pccard_function *pf, int ccr) +{ + return (bus_space_read_1(pf->pf_ccrt, pf->pf_ccrh, + pf->pf_ccr_offset + ccr)); +} -/* - * Power off the slot. - * (doing it immediately makes the removal of some cards unstable) - */ static void -power_off_slot(void *arg) +pccard_ccr_write(struct pccard_function *pf, int ccr, int val) +{ + if ((pf->ccr_mask) & (1 << (ccr / 2))) { + bus_space_write_1(pf->pf_ccrt, pf->pf_ccrh, + pf->pf_ccr_offset + ccr, val); + } +} + +static int +pccard_attach_card(device_t dev) { - struct slot *slt = (struct slot *)arg; - int s; + struct pccard_softc *sc = PCCARD_SOFTC(dev); + struct pccard_function *pf; + struct pccard_ivar *ivar; + device_t child; + int i; /* - * The following will generate an interrupt. So, to hold off - * the interrupt unitl after disable runs so that we can get rid - * rid of the interrupt before it becomes unsafe to touch the - * device. - * - * XXX In current, the spl stuff is a nop. + * this is here so that when socket_enable calls gettype, trt happens */ - s = splhigh(); - /* Power off the slot. */ - slt->pwr_off_pending = 0; - slt->ctrl->disable(slt); - splx(s); + STAILQ_INIT(&sc->card.pf_head); + + DEVPRINTF((dev, "chip_socket_enable\n")); + POWER_ENABLE_SOCKET(device_get_parent(dev), dev); + + DEVPRINTF((dev, "read_cis\n")); + pccard_read_cis(sc); + + DEVPRINTF((dev, "check_cis_quirks\n")); + pccard_check_cis_quirks(dev); + + /* + * bail now if the card has no functions, or if there was an error in + * the cis. + */ + + if (sc->card.error) { + device_printf(dev, "CARD ERROR!\n"); + return (1); + } + if (STAILQ_EMPTY(&sc->card.pf_head)) { + device_printf(dev, "Card has no functions!\n"); + return (1); + } + + if (bootverbose || pccard_debug) + pccard_print_cis(dev); + + DEVPRINTF((dev, "functions scanning\n")); + i = -1; + STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { + i++; + if (STAILQ_EMPTY(&pf->cfe_head)) { + device_printf(dev, + "Function %d has no config entries.!\n", i); + continue; + } + pf->sc = sc; + pf->cfe = NULL; + pf->dev = NULL; + } + DEVPRINTF((dev, "Card has %d functions. pccard_mfc is %d\n", i + 1, + pccard_mfc(sc))); + + STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { + if (STAILQ_EMPTY(&pf->cfe_head)) + continue; + /* + * In NetBSD, the drivers are responsible for activating + * each function of a card. I think that in FreeBSD we + * want to activate them enough for the usual bus_*_resource + * routines will do the right thing. This many mean a + * departure from the current NetBSD model. + * + * This seems to work well in practice for most cards. + * However, there are two cases that are problematic. + * If a driver wishes to pick and chose which config + * entry to use, then this method falls down. These + * are usually older cards. In addition, there are + * some cards that have multiple hardware units on the + * cards, but presents only one CIS chain. These cards + * are combination cards, but only one of these units + * can be on at a time. + */ + ivar = malloc(sizeof(struct pccard_ivar), M_DEVBUF, + M_WAITOK | M_ZERO); + child = device_add_child(dev, NULL, -1); + device_set_ivars(child, ivar); + ivar->fcn = pf; + pf->dev = child; + /* + * XXX We might want to move the next two lines into + * XXX the pccard interface layer. For the moment, this + * XXX is OK, but some drivers want to pick the config + * XXX entry to use as well as some address tweaks (mostly + * XXX due to bugs in decode logic that makes some + * XXX addresses illegal or broken). + */ + pccard_function_init(pf); + if (sc->sc_enabled_count == 0) + POWER_ENABLE_SOCKET(device_get_parent(dev), dev); + if (pccard_function_enable(pf) == 0 && + device_probe_and_attach(child) == 0) { + DEVPRINTF((sc->dev, "function %d CCR at %d " + "offset %x: %x %x %x %x, %x %x %x %x, %x\n", + pf->number, pf->pf_ccr_window, pf->pf_ccr_offset, + pccard_ccr_read(pf, 0x00), + pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04), + pccard_ccr_read(pf, 0x06), pccard_ccr_read(pf, 0x0A), + pccard_ccr_read(pf, 0x0C), pccard_ccr_read(pf, 0x0E), + pccard_ccr_read(pf, 0x10), pccard_ccr_read(pf, 0x12))); + } else { + if (pf->cfe != NULL) + pccard_function_disable(pf); + } + } + return (0); } -/* - * disable_slot - Disables the slot by removing - * the power and unmapping the I/O - */ -static void -disable_slot(struct slot *slt) +static int +pccard_detach_card(device_t dev) { - device_t pccarddev; - device_t *kids; - int nkids; - int i; - int ret; + struct pccard_softc *sc = PCCARD_SOFTC(dev); + struct pccard_function *pf; + struct pccard_config_entry *cfe; /* - * Note that a race condition is possible here; if a - * driver is accessing the device and it is removed, then - * all bets are off... + * We are running on either the PCCARD socket's event thread + * or in user context detaching a device by user request. */ - pccarddev = slt->dev; - device_get_children(pccarddev, &kids, &nkids); - for (i = 0; i < nkids; i++) { - if ((ret = device_delete_child(pccarddev, kids[i])) != 0) - printf("pccard: delete of %s failed: %d\n", - device_get_nameunit(kids[i]), ret); - } - free(kids, M_TEMP); + STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { + int state = device_get_state(pf->dev); + + if (state == DS_ATTACHED || state == DS_BUSY) + device_detach(pf->dev); + if (pf->cfe != NULL) + pccard_function_disable(pf); + pccard_function_free(pf); + device_delete_child(dev, pf->dev); + } + if (sc->sc_enabled_count == 0) + POWER_DISABLE_SOCKET(device_get_parent(dev), dev); - /* Power off the slot 1/2 second after removal of the card */ - slt->poff_ch = timeout(power_off_slot, (caddr_t)slt, hz / 2); - slt->pwr_off_pending = 1; + while (NULL != (pf = STAILQ_FIRST(&sc->card.pf_head))) { + while (NULL != (cfe = STAILQ_FIRST(&pf->cfe_head))) { + STAILQ_REMOVE_HEAD(&pf->cfe_head, cfe_list); + free(cfe, M_DEVBUF); + } + STAILQ_REMOVE_HEAD(&sc->card.pf_head, pf_list); + free(pf, M_DEVBUF); + } + return (0); } -static void -disable_slot_to(struct slot *slt) +static const struct pccard_product * +pccard_do_product_lookup(device_t bus, device_t dev, + const struct pccard_product *tab, size_t ent_size, + pccard_product_match_fn matchfn) { - disable_slot(slt); - if (slt->state == empty) - printf("pccard: card removed, slot %d\n", slt->slotnum); + const struct pccard_product *ent; + int matches; + u_int32_t fcn; + u_int32_t vendor; + u_int32_t prod; + char *vendorstr; + char *prodstr; + +#ifdef DIAGNOSTIC + if (sizeof *ent > ent_size) + panic("pccard_product_lookup: bogus ent_size %ld", + (long) ent_size); +#endif + if (pccard_get_vendor(dev, &vendor)) + return (NULL); + if (pccard_get_product(dev, &prod)) + return (NULL); + if (pccard_get_function_number(dev, &fcn)) + return (NULL); + if (pccard_get_vendor_str(dev, &vendorstr)) + return (NULL); + if (pccard_get_product_str(dev, &prodstr)) + return (NULL); + for (ent = tab; ent->pp_name != NULL; ent = + (const struct pccard_product *) ((const char *) ent + ent_size)) { + matches = 1; + if (ent->pp_vendor == PCCARD_VENDOR_ANY && + ent->pp_product == PCCARD_VENDOR_ANY && + ent->pp_cis[0] == NULL && + ent->pp_cis[1] == NULL) { + device_printf(dev, + "Total wildcard entry ignored for %s\n", + ent->pp_name); + continue; + } + if (matches && ent->pp_vendor != PCCARD_VENDOR_ANY && + vendor != ent->pp_vendor) + matches = 0; + if (matches && ent->pp_product != PCCARD_PRODUCT_ANY && + prod != ent->pp_product) + matches = 0; + if (matches && fcn != ent->pp_expfunc) + matches = 0; + if (matches && ent->pp_cis[0] && + strcmp(ent->pp_cis[0], vendorstr) != 0) + matches = 0; + if (matches && ent->pp_cis[1] && + strcmp(ent->pp_cis[1], prodstr) != 0) + matches = 0; + /* XXX need to match cis[2] and cis[3] also XXX */ + if (matchfn != NULL) + matches = (*matchfn)(dev, ent, matches); + if (matches) + return (ent); + } + return (NULL); +} + +static int +pccard_card_gettype(device_t dev, int *type) +{ + struct pccard_softc *sc = PCCARD_SOFTC(dev); + struct pccard_function *pf; + + /* + * set the iftype to memory if this card has no functions (not yet + * probed), or only one function, and that is not initialized yet or + * that is memory. + */ + pf = STAILQ_FIRST(&sc->card.pf_head); + if (pf == NULL || + (STAILQ_NEXT(pf, pf_list) == NULL && + (pf->cfe == NULL || pf->cfe->iftype == PCCARD_IFTYPE_MEMORY))) + *type = PCCARD_IFTYPE_MEMORY; else - printf("pccard: card deactivated, slot %d\n", slt->slotnum); - pccard_remove_beep(); - selwakeup(&slt->selp); + *type = PCCARD_IFTYPE_IO; + return (0); } /* - * pccard_init_slot - Initialize the slot controller and attach various - * things to it. We also make the device for it. We create the device that - * will be exported to devfs. + * Initialize a PCCARD function. May be called as long as the function is + * disabled. + * + * Note: pccard_function_init should not keep resources allocated. It should + * only set them up ala isa pnp, set the values in the rl lists, and return. + * Any resource held after pccard_function_init is called is a bug. However, + * the bus routines to get the resources also assume that pccard_function_init + * does this, so they need to be fixed too. */ -struct slot * -pccard_init_slot(device_t dev, struct slot_ctrl *ctrl) +static void +pccard_function_init(struct pccard_function *pf) { - int slotno; - struct slot *slt; - - slt = PCCARD_DEVICE2SOFTC(dev); - slotno = device_get_unit(dev); - slt->dev = dev; - slt->d = make_dev(&crd_cdevsw, slotno, 0, 0, 0600, "card%d", slotno); - slt->d->si_drv1 = slt; - slt->ctrl = ctrl; - slt->slotnum = slotno; - callout_handle_init(&slt->insert_ch); - callout_handle_init(&slt->poff_ch); + struct pccard_config_entry *cfe; + int i; + struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); + struct resource_list *rl = &devi->resources; + struct resource_list_entry *rle; + struct resource *r = 0; + device_t bus; + int start; + int end; + int spaces; - return (slt); + if (pf->pf_flags & PFF_ENABLED) { + printf("pccard_function_init: function is enabled"); + return; + } + bus = device_get_parent(pf->dev); + /* Remember which configuration entry we are using. */ + STAILQ_FOREACH(cfe, &pf->cfe_head, cfe_list) { + for (i = 0; i < cfe->num_iospace; i++) + cfe->iores[i] = NULL; + cfe->irqres = NULL; + spaces = 0; + for (i = 0; i < cfe->num_iospace; i++) { + start = cfe->iospace[i].start; + if (start) + end = start + cfe->iospace[i].length - 1; + else + end = ~0; + cfe->iorid[i] = i; + DEVPRINTF((bus, "I/O rid %d start %x end %x\n", + i, start, end)); + r = cfe->iores[i] = bus_alloc_resource(bus, + SYS_RES_IOPORT, &cfe->iorid[i], start, end, + cfe->iospace[i].length, + rman_make_alignment_flags(cfe->iospace[i].length)); + if (cfe->iores[i] == NULL) + goto not_this_one; + resource_list_add(rl, SYS_RES_IOPORT, cfe->iorid[i], + rman_get_start(r), rman_get_end(r), + cfe->iospace[i].length); + rle = resource_list_find(rl, SYS_RES_IOPORT, + cfe->iorid[i]); + rle->res = r; + spaces++; + } + if (cfe->num_memspace > 0) { + /* + * Not implement yet, Fix me. + */ + DEVPRINTF((bus, "Memory space not yet implemented.\n")); + } + if (spaces == 0) { + DEVPRINTF((bus, "Neither memory nor I/O mampped\n")); + goto not_this_one; + } + if (cfe->irqmask) { + cfe->irqrid = 0; + r = cfe->irqres = bus_alloc_resource(bus, SYS_RES_IRQ, + &cfe->irqrid, 0, ~0, 1, 0); + if (cfe->irqres == NULL) + goto not_this_one; + resource_list_add(rl, SYS_RES_IRQ, cfe->irqrid, + rman_get_start(r), rman_get_end(r), 1); + rle = resource_list_find(rl, SYS_RES_IRQ, + cfe->irqrid); + rle->res = r; + } + /* If we get to here, we've allocated all we need */ + pf->cfe = cfe; + break; + not_this_one:; + DEVPRVERBOSE((bus, "Allocation failed for cfe %d\n", + cfe->number)); + /* + * Release resources that we partially allocated + * from this config entry. + */ + for (i = 0; i < cfe->num_iospace; i++) { + if (cfe->iores[i] != NULL) { + bus_release_resource(bus, SYS_RES_IOPORT, + cfe->iorid[i], cfe->iores[i]); + rle = resource_list_find(rl, SYS_RES_IOPORT, + cfe->iorid[i]); + rle->res = NULL; + resource_list_delete(rl, SYS_RES_IOPORT, + cfe->iorid[i]); + } + cfe->iores[i] = NULL; + } + if (cfe->irqmask && cfe->irqres != NULL) { + bus_release_resource(bus, SYS_RES_IRQ, + cfe->irqrid, cfe->irqres); + rle = resource_list_find(rl, SYS_RES_IRQ, + cfe->irqrid); + rle->res = NULL; + resource_list_delete(rl, SYS_RES_IRQ, cfe->irqrid); + cfe->irqres = NULL; + } + } } /* - * allocate_driver - Create a new device entry for this - * slot, and attach a driver to it. + * Free resources allocated by pccard_function_init(), May be called as long + * as the function is disabled. + * + * NOTE: This function should be unnecessary. pccard_function_init should + * never keep resources initialized. */ +static void +pccard_function_free(struct pccard_function *pf) +{ + struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); + struct resource_list_entry *rle; + + if (pf->pf_flags & PFF_ENABLED) { + printf("pccard_function_init: function is enabled"); + return; + } + + SLIST_FOREACH(rle, &devi->resources, link) { + if (rle->res) { + if (rle->res->r_dev != pf->sc->dev) + device_printf(pf->sc->dev, + "function_free: Resource still owned by " + "child, oops. " + "(type=%d, rid=%d, addr=%lx)\n", + rle->type, rle->rid, + rman_get_start(rle->res)); + BUS_RELEASE_RESOURCE(device_get_parent(pf->sc->dev), + rle->res->r_dev, rle->type, rle->rid, rle->res); + rle->res = NULL; + } + } + resource_list_free(&devi->resources); +} + +/* Enable a PCCARD function */ static int -allocate_driver(struct slot *slt, struct dev_desc *desc) +pccard_function_enable(struct pccard_function *pf) { - struct pccard_devinfo *devi; - device_t pccarddev; - int err, irq = 0; - device_t child; - device_t *devs; - int count; + struct pccard_function *tmp; + int reg; + device_t dev = pf->sc->dev; + + if (pf->cfe == NULL) { + DEVPRVERBOSE((dev, "No config entry could be allocated.\n")); + return (ENOMEM); + } - pccarddev = slt->dev; - err = device_get_children(pccarddev, &devs, &count); - if (err != 0) - return (err); - free(devs, M_TEMP); - if (count) { - device_printf(pccarddev, - "Can not attach more than one child.\n"); - return (EIO); - } - irq = ffs(desc->irqmask) - 1; - MALLOC(devi, struct pccard_devinfo *, sizeof(*devi), M_DEVBUF, - M_WAITOK | M_ZERO); - strcpy(devi->name, desc->name); /* - * Create an entry for the device under this slot. + * Increase the reference count on the socket, enabling power, if + * necessary. */ - devi->running = 1; - devi->slt = slt; - bcopy(desc->misc, devi->misc, sizeof(desc->misc)); - strcpy(devi->manufstr, desc->manufstr); - strcpy(devi->versstr, desc->versstr); - devi->manufacturer = desc->manufacturer; - devi->product = desc->product; - devi->prodext = desc->prodext; - resource_list_init(&devi->resources); - child = device_add_child(pccarddev, devi->name, desc->unit); - if (child == NULL) { - if (desc->unit != -1) - device_printf(pccarddev, - "Unit %d failed for %s, try a different unit\n", - desc->unit, devi->name); - else - device_printf(pccarddev, - "No units available for %s. Impossible?\n", - devi->name); - return (EIO); - } - device_set_flags(child, desc->flags); - device_set_ivars(child, devi); - if (bootverbose) { - device_printf(pccarddev, "Assigning %s:", - device_get_nameunit(child)); - if (desc->iobase) - printf(" io 0x%x-0x%x", - desc->iobase, desc->iobase + desc->iosize - 1); - if (irq) - printf(" irq %d", irq); - if (desc->mem) - printf(" mem 0x%lx-0x%lx", desc->mem, - desc->mem + desc->memsize - 1); - printf(" flags 0x%x\n", desc->flags); - } - err = bus_set_resource(child, SYS_RES_IOPORT, 0, desc->iobase, - desc->iosize); - if (err) - goto err; - if (irq) - err = bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1); - if (err) - goto err; - if (desc->memsize) { - err = bus_set_resource(child, SYS_RES_MEMORY, 0, desc->mem, - desc->memsize); - if (err) - goto err; - } - err = device_probe_and_attach(child); + pf->sc->sc_enabled_count++; + + if (pf->pf_flags & PFF_ENABLED) { + /* + * Don't do anything if we're already enabled. + */ + return (0); + } + /* - * XXX We unwisely assume that the detach code won't run while the - * XXX the attach code is attaching. Someone should put some - * XXX interlock code. This can happen if probe/attach takes a while - * XXX and the user ejects the card, which causes the detach - * XXX function to be called. + * it's possible for different functions' CCRs to be in the same + * underlying page. Check for that. */ - strncpy(desc->name, device_get_nameunit(child), sizeof(desc->name)); - desc->name[sizeof(desc->name) - 1] = '\0'; -err: - if (err) - device_delete_child(pccarddev, child); - return (err); + STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { + if ((tmp->pf_flags & PFF_ENABLED) && + (pf->ccr_base >= (tmp->ccr_base - tmp->pf_ccr_offset)) && + ((pf->ccr_base + PCCARD_CCR_SIZE) <= + (tmp->ccr_base - tmp->pf_ccr_offset + + tmp->pf_ccr_realsize))) { + pf->pf_ccrt = tmp->pf_ccrt; + pf->pf_ccrh = tmp->pf_ccrh; + pf->pf_ccr_realsize = tmp->pf_ccr_realsize; + + /* + * pf->pf_ccr_offset = (tmp->pf_ccr_offset - + * tmp->ccr_base) + pf->ccr_base; + */ + /* pf->pf_ccr_offset = + (tmp->pf_ccr_offset + pf->ccr_base) - + tmp->ccr_base; */ + pf->pf_ccr_window = tmp->pf_ccr_window; + break; + } + } + if (tmp == NULL) { + pf->ccr_rid = 0; + pf->ccr_res = bus_alloc_resource(dev, SYS_RES_MEMORY, + &pf->ccr_rid, 0, ~0, 1 << 10, RF_ACTIVE); + if (!pf->ccr_res) + goto bad; + DEVPRINTF((dev, "ccr_res == %lx-%lx, base=%x\n", + rman_get_start(pf->ccr_res), rman_get_end(pf->ccr_res), + pf->ccr_base)); + CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, + pf->ccr_rid, PCCARD_A_MEM_ATTR); + CARD_SET_MEMORY_OFFSET(device_get_parent(dev), dev, + pf->ccr_rid, pf->ccr_base, &pf->pf_ccr_offset); + pf->pf_ccrt = rman_get_bustag(pf->ccr_res); + pf->pf_ccrh = rman_get_bushandle(pf->ccr_res); + pf->pf_ccr_realsize = 1; + } + + reg = (pf->cfe->number & PCCARD_CCR_OPTION_CFINDEX); + reg |= PCCARD_CCR_OPTION_LEVIREQ; + if (pccard_mfc(pf->sc)) { + reg |= (PCCARD_CCR_OPTION_FUNC_ENABLE | + PCCARD_CCR_OPTION_ADDR_DECODE); + /* PCCARD_CCR_OPTION_IRQ_ENABLE set elsewhere as needed */ + } + pccard_ccr_write(pf, PCCARD_CCR_OPTION, reg); + + reg = 0; + if ((pf->cfe->flags & PCCARD_CFE_IO16) == 0) + reg |= PCCARD_CCR_STATUS_IOIS8; + if (pf->cfe->flags & PCCARD_CFE_AUDIO) + reg |= PCCARD_CCR_STATUS_AUDIO; + pccard_ccr_write(pf, PCCARD_CCR_STATUS, reg); + + pccard_ccr_write(pf, PCCARD_CCR_SOCKETCOPY, 0); + + if (pccard_mfc(pf->sc)) { + long tmp, iosize; + + tmp = pf->pf_mfc_iomax - pf->pf_mfc_iobase; + /* round up to nearest (2^n)-1 */ + for (iosize = 1; iosize < tmp; iosize <<= 1) + ; + iosize--; + + pccard_ccr_write(pf, PCCARD_CCR_IOBASE0, + pf->pf_mfc_iobase & 0xff); + pccard_ccr_write(pf, PCCARD_CCR_IOBASE1, + (pf->pf_mfc_iobase >> 8) & 0xff); + pccard_ccr_write(pf, PCCARD_CCR_IOBASE2, 0); + pccard_ccr_write(pf, PCCARD_CCR_IOBASE3, 0); + + pccard_ccr_write(pf, PCCARD_CCR_IOSIZE, iosize); + } + +#ifdef PCCARDDEBUG + if (pccard_debug) { + STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { + device_printf(tmp->sc->dev, + "function %d CCR at %d offset %x: " + "%x %x %x %x, %x %x %x %x, %x\n", + tmp->number, tmp->pf_ccr_window, + tmp->pf_ccr_offset, + pccard_ccr_read(tmp, 0x00), + pccard_ccr_read(tmp, 0x02), + pccard_ccr_read(tmp, 0x04), + pccard_ccr_read(tmp, 0x06), + pccard_ccr_read(tmp, 0x0A), + pccard_ccr_read(tmp, 0x0C), + pccard_ccr_read(tmp, 0x0E), + pccard_ccr_read(tmp, 0x10), + pccard_ccr_read(tmp, 0x12)); + } + } +#endif + pf->pf_flags |= PFF_ENABLED; + return (0); + + bad: + /* + * Decrement the reference count, and power down the socket, if + * necessary. + */ + pf->sc->sc_enabled_count--; + DEVPRINTF((dev, "bad --enabled_count = %d\n", pf->sc->sc_enabled_count)); + + return (1); } -/* - * card insert routine - Called from a timeout to debounce - * insertion events. - */ +/* Disable PCCARD function. */ static void -inserted(void *arg) +pccard_function_disable(struct pccard_function *pf) { - struct slot *slt = arg; + struct pccard_function *tmp; + device_t dev = pf->sc->dev; + + if (pf->cfe == NULL) + panic("pccard_function_disable: function not initialized"); + + if ((pf->pf_flags & PFF_ENABLED) == 0) { + /* + * Don't do anything if we're already disabled. + */ + return; + } + + if (pf->intr_handler != NULL) { + struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); + struct resource_list_entry *rle = + resource_list_find(&devi->resources, SYS_RES_IRQ, 0); + BUS_TEARDOWN_INTR(dev, pf->dev, rle->res, + pf->intr_handler_cookie); + } - slt->state = filled; /* - * Disable any pending timeouts for this slot, and explicitly - * power it off right now. Then, re-enable the power using - * the (possibly new) power settings. + * it's possible for different functions' CCRs to be in the same + * underlying page. Check for that. Note we mark us as disabled + * first to avoid matching ourself. */ - untimeout(power_off_slot, (caddr_t)slt, slt->poff_ch); - power_off_slot(slt); + + pf->pf_flags &= ~PFF_ENABLED; + STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { + if ((tmp->pf_flags & PFF_ENABLED) && + (pf->ccr_base >= (tmp->ccr_base - tmp->pf_ccr_offset)) && + ((pf->ccr_base + PCCARD_CCR_SIZE) <= + (tmp->ccr_base - tmp->pf_ccr_offset + + tmp->pf_ccr_realsize))) + break; + } + + /* Not used by anyone else; unmap the CCR. */ + if (tmp == NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, pf->ccr_rid, + pf->ccr_res); + pf->ccr_res = NULL; + } /* - * Enable 5V to the card so that the CIS can be read. Well, - * enable the most natural voltage so that the CIS can be read. + * Decrement the reference count, and power down the socket, if + * necessary. */ - slt->pwr.vcc = -1; - slt->pwr.vpp = -1; - slt->ctrl->power(slt); - - printf("pccard: card inserted, slot %d\n", slt->slotnum); - pccard_insert_beep(); - slt->ctrl->reset(slt); + pf->sc->sc_enabled_count--; } /* - * Card event callback. Called at splhigh to prevent - * device interrupts from interceding. + * simulate the old "probe" routine. In the new world order, the driver + * needs to grab devices while in the old they were assigned to the device by + * the pccardd process. These symbols are exported to the upper layers. */ -void -pccard_event(struct slot *slt, enum card_event event) +static int +pccard_compat_do_probe(device_t bus, device_t dev) { - if (slt->insert_seq) { - slt->insert_seq = 0; - untimeout(inserted, (void *)slt, slt->insert_ch); - } + return (CARD_COMPAT_MATCH(dev)); +} - switch(event) { - case card_removed: - case card_deactivated: - if (slt->state == filled || slt->state == inactive) { - if (event == card_removed) - slt->state = empty; - else - slt->state = inactive; - disable_slot_to(slt); - } - break; - case card_inserted: - slt->insert_seq = 1; - slt->insert_ch = timeout(inserted, (void *)slt, hz/4); - break; - } +static int +pccard_compat_do_attach(device_t bus, device_t dev) +{ + int err; + + err = CARD_COMPAT_PROBE(dev); + if (err == 0) + err = CARD_COMPAT_ATTACH(dev); + return (err); } -/* - * Device driver interface. - */ -static int -crdopen(dev_t dev, int oflags, int devtype, d_thread_t *td) +#define PCCARD_NPORT 2 +#define PCCARD_NMEM 5 +#define PCCARD_NIRQ 1 +#define PCCARD_NDRQ 0 + +static int +pccard_add_children(device_t dev, int busno) { - struct slot *slt = PCCARD_DEV2SOFTC(dev); + /* Call parent to scan for any current children */ + return (0); +} - if (slt == NULL) - return (ENXIO); - if (slt->rwmem == 0) - slt->rwmem = MDF_ATTR; +static int +pccard_probe(device_t dev) +{ + device_set_desc(dev, "16-bit PCCard bus"); + return (pccard_add_children(dev, device_get_unit(dev))); +} + +static int +pccard_attach(device_t dev) +{ + struct pccard_softc *sc = PCCARD_SOFTC(dev); + + sc->dev = dev; + sc->sc_enabled_count = 0; + return (bus_generic_attach(dev)); +} + +static int +pccard_detach(device_t dev) +{ + pccard_detach_card(dev); + return 0; +} + +static int +pccard_suspend(device_t self) +{ + pccard_detach_card(self); return (0); } -/* - * Close doesn't de-allocate any resources, since - * slots may be assigned to drivers already. - */ -static int -crdclose(dev_t dev, int fflag, int devtype, d_thread_t *td) +static int +pccard_resume(device_t self) { return (0); } -/* - * read interface. Map memory at lseek offset, - * then transfer to user space. - */ -static int -crdread(dev_t dev, struct uio *uio, int ioflag) -{ - struct slot *slt = PCCARD_DEV2SOFTC(dev); - struct mem_desc *mp, oldmap; - unsigned char *p; - unsigned int offs; - int error = 0, win, count; - - if (slt == 0 || slt->state != filled) - return (ENXIO); - if (pccard_mem == 0) - return (ENOMEM); - for (win = slt->ctrl->maxmem - 1; win >= 0; win--) - if ((slt->mem[win].flags & MDF_ACTIVE) == 0) - break; - if (win < 0) - return (EBUSY); - mp = &slt->mem[win]; - oldmap = *mp; - mp->flags = slt->rwmem | MDF_ACTIVE; - while (uio->uio_resid && error == 0) { - mp->card = uio->uio_offset; - mp->size = PCCARD_MEMSIZE; - mp->start = (caddr_t)(void *)(uintptr_t)pccard_mem; - if ((error = slt->ctrl->mapmem(slt, win)) != 0) +static void +pccard_print_resources(struct resource_list *rl, const char *name, int type, + int count, const char *format) +{ + struct resource_list_entry *rle; + int printed; + int i; + + printed = 0; + for (i = 0; i < count; i++) { + rle = resource_list_find(rl, type, i); + if (rle != NULL) { + if (printed == 0) + printf(" %s ", name); + else if (printed > 0) + printf(","); + printed++; + printf(format, rle->start); + if (rle->count > 1) { + printf("-"); + printf(format, rle->start + rle->count - 1); + } + } else if (i > 3) { + /* check the first few regardless */ break; - offs = (unsigned int)uio->uio_offset & (PCCARD_MEMSIZE - 1); - p = pccard_kmem + offs; - count = MIN(PCCARD_MEMSIZE - offs, uio->uio_resid); - error = uiomove(p, count, uio); + } } - /* - * Restore original map. - */ - *mp = oldmap; - slt->ctrl->mapmem(slt, win); - - return (error); } -/* - * crdwrite - Write data to card memory. - * Handles wrap around so that only one memory - * window is used. - */ -static int -crdwrite(dev_t dev, struct uio *uio, int ioflag) -{ - struct slot *slt = PCCARD_DEV2SOFTC(dev); - struct mem_desc *mp, oldmap; - unsigned char *p; - unsigned int offs; - int error = 0, win, count; - - if (slt == 0 || slt->state != filled) - return (ENXIO); - if (pccard_mem == 0) - return (ENOMEM); - for (win = slt->ctrl->maxmem - 1; win >= 0; win--) - if ((slt->mem[win].flags & MDF_ACTIVE) == 0) - break; - if (win < 0) - return (EBUSY); - mp = &slt->mem[win]; - oldmap = *mp; - mp->flags = slt->rwmem | MDF_ACTIVE; - while (uio->uio_resid && error == 0) { - mp->card = uio->uio_offset; - mp->size = PCCARD_MEMSIZE; - mp->start = (caddr_t)(void *)(uintptr_t)pccard_mem; - if ((error = slt->ctrl->mapmem(slt, win)) != 0) - break; - offs = (unsigned int)uio->uio_offset & (PCCARD_MEMSIZE - 1); - p = pccard_kmem + offs; - count = MIN(PCCARD_MEMSIZE - offs, uio->uio_resid); - error = uiomove(p, count, uio); +static int +pccard_print_child(device_t dev, device_t child) +{ + struct pccard_ivar *devi = PCCARD_IVAR(child); + struct resource_list *rl = &devi->resources; + int retval = 0; + + retval += bus_print_child_header(dev, child); + retval += printf(" at"); + + if (devi != NULL) { + pccard_print_resources(rl, "port", SYS_RES_IOPORT, + PCCARD_NPORT, "%#lx"); + pccard_print_resources(rl, "iomem", SYS_RES_MEMORY, + PCCARD_NMEM, "%#lx"); + pccard_print_resources(rl, "irq", SYS_RES_IRQ, PCCARD_NIRQ, + "%ld"); + pccard_print_resources(rl, "drq", SYS_RES_DRQ, PCCARD_NDRQ, + "%ld"); + retval += printf(" function %d config %d", devi->fcn->number, + devi->fcn->cfe->number); } - /* - * Restore original map. - */ - *mp = oldmap; - slt->ctrl->mapmem(slt, win); - return (error); + retval += bus_print_child_footer(dev, child); + + return (retval); } -/* - * ioctl calls - allows setting/getting of memory and I/O - * descriptors, and assignment of drivers. - */ -static int -crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, d_thread_t *td) +static int +pccard_set_resource(device_t dev, device_t child, int type, int rid, + u_long start, u_long count) { - u_int32_t addr; - int err; - struct io_desc *ip; - struct mem_desc *mp; - device_t pccarddev; - int pwval; - int s; - struct slot *slt = PCCARD_DEV2SOFTC(dev); + struct pccard_ivar *devi = PCCARD_IVAR(child); + struct resource_list *rl = &devi->resources; - if (slt == 0 && cmd != PIOCRWMEM) - return (ENXIO); + if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY + && type != SYS_RES_IRQ && type != SYS_RES_DRQ) + return (EINVAL); + if (rid < 0) + return (EINVAL); + if (type == SYS_RES_IOPORT && rid >= PCCARD_NPORT) + return (EINVAL); + if (type == SYS_RES_MEMORY && rid >= PCCARD_NMEM) + return (EINVAL); + if (type == SYS_RES_IRQ && rid >= PCCARD_NIRQ) + return (EINVAL); + if (type == SYS_RES_DRQ && rid >= PCCARD_NDRQ) + return (EINVAL); - KKASSERT(td->td_proc != NULL); + resource_list_add(rl, type, rid, start, start + count - 1, count); + if (NULL != resource_list_alloc(rl, device_get_parent(dev), dev, + type, &rid, start, start + count - 1, count, 0)) + return 0; + else + return ENOMEM; +} - switch(cmd) { +static int +pccard_get_resource(device_t dev, device_t child, int type, int rid, + u_long *startp, u_long *countp) +{ + struct pccard_ivar *devi = PCCARD_IVAR(child); + struct resource_list *rl = &devi->resources; + struct resource_list_entry *rle; + + rle = resource_list_find(rl, type, rid); + if (rle == NULL) + return (ENOENT); + + if (startp != NULL) + *startp = rle->start; + if (countp != NULL) + *countp = rle->count; + + return (0); +} + +static void +pccard_delete_resource(device_t dev, device_t child, int type, int rid) +{ + struct pccard_ivar *devi = PCCARD_IVAR(child); + struct resource_list *rl = &devi->resources; + 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, u_int32_t *deltap) + +{ + return (CARD_SET_MEMORY_OFFSET(device_get_parent(dev), child, rid, + offset, deltap)); +} + +static void +pccard_probe_nomatch(device_t bus, device_t child) +{ + struct pccard_ivar *devi = PCCARD_IVAR(child); + struct pccard_function *func = devi->fcn; + struct pccard_softc *sc = PCCARD_SOFTC(bus); + + device_printf(bus, ""); + printf(" (manufacturer=0x%04x, product=0x%04x) at function %d\n", + sc->card.manufacturer, sc->card.product, func->number); + device_printf(bus, " CIS info: %s, %s, %s\n", sc->card.cis1_info[0], + sc->card.cis1_info[1], sc->card.cis1_info[2]); + return; +} + +static int +pccard_child_location_str(device_t bus, device_t child, char *buf, + size_t buflen) +{ + struct pccard_ivar *devi = PCCARD_IVAR(child); + struct pccard_function *func = devi->fcn; + + snprintf(buf, buflen, "function=%d", func->number); + return (0); +} + +static int +pccard_child_pnpinfo_str(device_t bus, device_t child, char *buf, + size_t buflen) +{ + struct pccard_ivar *devi = PCCARD_IVAR(child); + struct pccard_function *func = devi->fcn; + struct pccard_softc *sc = PCCARD_SOFTC(bus); + + snprintf(buf, buflen, "manufacturer=0x%04x product=0x%04x " + "cisvendor=\"%s\" cisproduct=\"%s\" function_type=%d", + sc->card.manufacturer, sc->card.product, sc->card.cis1_info[0], + sc->card.cis1_info[1], func->function); + return (0); +} + +static int +pccard_read_ivar(device_t bus, device_t child, int which, u_char *result) +{ + struct pccard_ivar *devi = PCCARD_IVAR(child); + struct pccard_function *func = devi->fcn; + struct pccard_softc *sc = PCCARD_SOFTC(bus); + + switch (which) { default: - if (slt->ctrl->ioctl) - return (slt->ctrl->ioctl(slt, cmd, data)); - return (ENOTTY); - /* - * Get slot state. - */ - case PIOCGSTATE: - s = splhigh(); - ((struct slotstate *)data)->state = slt->state; - ((struct slotstate *)data)->laststate = slt->laststate; - slt->laststate = slt->state; - splx(s); - ((struct slotstate *)data)->maxmem = slt->ctrl->maxmem; - ((struct slotstate *)data)->maxio = slt->ctrl->maxio; - ((struct slotstate *)data)->irqs = 0; + case PCCARD_IVAR_ETHADDR: + bcopy(func->pf_funce_lan_nid, result, ETHER_ADDR_LEN); break; - /* - * Get memory context. - */ - case PIOCGMEM: - s = ((struct mem_desc *)data)->window; - if (s < 0 || s >= slt->ctrl->maxmem) - return (EINVAL); - mp = &slt->mem[s]; - ((struct mem_desc *)data)->flags = mp->flags; - ((struct mem_desc *)data)->start = mp->start; - ((struct mem_desc *)data)->size = mp->size; - ((struct mem_desc *)data)->card = mp->card; + case PCCARD_IVAR_VENDOR: + *(u_int32_t *) result = sc->card.manufacturer; break; - /* - * Set memory context. If context already active, then unmap it. - * It is hard to see how the parameters can be checked. - * At the very least, we only allow root to set the context. - */ - case PIOCSMEM: - if (suser(td)) - return (EPERM); - if (slt->state != filled) - return (ENXIO); - s = ((struct mem_desc *)data)->window; - if (s < 0 || s >= slt->ctrl->maxmem) - return (EINVAL); - slt->mem[s] = *((struct mem_desc *)data); - return (slt->ctrl->mapmem(slt, s)); - /* - * Get I/O port context. - */ - case PIOCGIO: - s = ((struct io_desc *)data)->window; - if (s < 0 || s >= slt->ctrl->maxio) - return (EINVAL); - ip = &slt->io[s]; - ((struct io_desc *)data)->flags = ip->flags; - ((struct io_desc *)data)->start = ip->start; - ((struct io_desc *)data)->size = ip->size; + case PCCARD_IVAR_PRODUCT: + *(u_int32_t *) result = sc->card.product; break; - /* - * Set I/O port context. - */ - case PIOCSIO: - if (suser(td)) - return (EPERM); - if (slt->state != filled) - return (ENXIO); - s = ((struct io_desc *)data)->window; - if (s < 0 || s >= slt->ctrl->maxio) - return (EINVAL); - slt->io[s] = *((struct io_desc *)data); - /* XXX Don't actually map */ - return (0); + case PCCARD_IVAR_PRODEXT: + *(u_int16_t *) result = sc->card.prodext; break; - /* - * Set memory window flags for read/write interface. - */ - case PIOCRWFLAG: - slt->rwmem = *(int *)data; + case PCCARD_IVAR_FUNCTION: + *(u_int32_t *) result = func->function; break; - /* - * Set the memory window to be used for the read/write interface. - */ - case PIOCRWMEM: - if (*(unsigned long *)data == 0) { - *(unsigned long *)data = pccard_mem; - break; + case PCCARD_IVAR_FUNCTION_NUMBER: + if (!func) { + device_printf(bus, "No function number, bug!\n"); + return (ENOENT); } - if (suser(td)) - return (EPERM); - /* - * Validate the memory by checking it against the I/O - * memory range. It must also start on an aligned block size. - */ - if (*(unsigned long *)data & (PCCARD_MEMSIZE-1)) - return (EINVAL); - pccarddev = PCCARD_DEV2SOFTC(dev)->dev; - pccard_mem_rid = 0; - addr = *(unsigned long *)data; - if (pccard_mem_res) - bus_release_resource(pccarddev, SYS_RES_MEMORY, - pccard_mem_rid, pccard_mem_res); - pccard_mem_res = bus_alloc_resource(pccarddev, SYS_RES_MEMORY, - &pccard_mem_rid, addr, addr, PCCARD_MEMSIZE, - RF_ACTIVE | rman_make_alignment_flags(PCCARD_MEMSIZE)); - if (pccard_mem_res == NULL) - return (EINVAL); - pccard_mem = rman_get_start(pccard_mem_res); - pccard_kmem = rman_get_virtual(pccard_mem_res); + *(u_int32_t *) result = func->number; break; - /* - * Set power values. - */ - case PIOCSPOW: - slt->pwr = *(struct power *)data; - return (slt->ctrl->power(slt)); - /* - * Allocate a driver to this slot. - */ - case PIOCSDRV: - if (suser(td)) - return (EPERM); - err = allocate_driver(slt, (struct dev_desc *)data); - if (!err) - pccard_success_beep(); - else - pccard_failure_beep(); - return (err); - /* - * Virtual removal/insertion - */ - case PIOCSVIR: - pwval = *(int *)data; - if (!pwval) { - if (slt->state != filled) - return (EINVAL); - pccard_event(slt, card_deactivated); - } else { - if (slt->state != empty && slt->state != inactive) - return (EINVAL); - pccard_event(slt, card_inserted); - } + case PCCARD_IVAR_VENDOR_STR: + *(char **) result = sc->card.cis1_info[0]; break; - case PIOCSBEEP: - if (pccard_beep_select(*(int *)data)) { - return (EINVAL); - } + case PCCARD_IVAR_PRODUCT_STR: + *(char **) result = sc->card.cis1_info[1]; + break; + case PCCARD_IVAR_CIS3_STR: + *(char **) result = sc->card.cis1_info[2]; + break; + case PCCARD_IVAR_CIS4_STR: + *(char **) result = sc->card.cis1_info[3]; break; } return (0); } -/* - * poll - Poll on exceptions will return true - * when a change in card status occurs. - */ -static int -crdpoll(dev_t dev, int events, d_thread_t *td) +static void +pccard_driver_added(device_t dev, driver_t *driver) { - int revents = 0; - int s; - struct slot *slt = PCCARD_DEV2SOFTC(dev); + struct pccard_softc *sc = PCCARD_SOFTC(dev); + struct pccard_function *pf; + device_t child; - if (events & (POLLIN | POLLRDNORM)) - revents |= events & (POLLIN | POLLRDNORM); + STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { + if (STAILQ_EMPTY(&pf->cfe_head)) + continue; + child = pf->dev; + if (device_get_state(child) != DS_NOTPRESENT) + continue; + if (pccard_function_enable(pf) == 0 && + device_probe_and_attach(child) == 0) { + DEVPRINTF((sc->dev, "function %d CCR at %d " + "offset %x: %x %x %x %x, %x %x %x %x, %x\n", + pf->number, pf->pf_ccr_window, pf->pf_ccr_offset, + pccard_ccr_read(pf, 0x00), + pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04), + pccard_ccr_read(pf, 0x06), pccard_ccr_read(pf, 0x0A), + pccard_ccr_read(pf, 0x0C), pccard_ccr_read(pf, 0x0E), + pccard_ccr_read(pf, 0x10), pccard_ccr_read(pf, 0x12))); + } else { + if (pf->cfe != NULL) + pccard_function_disable(pf); + } + } + return; +} - if (events & (POLLOUT | POLLWRNORM)) - revents |= events & (POLLIN | POLLRDNORM); +static struct resource * +pccard_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + struct pccard_ivar *dinfo; + struct resource_list_entry *rle = 0; + int passthrough = (device_get_parent(child) != dev); + struct resource *r = NULL; - s = splhigh(); - /* - * select for exception - card event. - */ - if (events & POLLRDBAND) - if (slt == 0 || slt->laststate != slt->state) - revents |= POLLRDBAND; + if (passthrough) { + return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, + type, rid, start, end, count, flags)); + } - if (revents == 0) - selrecord(td, &slt->selp); + dinfo = device_get_ivars(child); + rle = resource_list_find(&dinfo->resources, type, *rid); - splx(s); - return (revents); + if (rle == NULL) + return (NULL); /* no resource of that type/rid */ + + if (rle->res == NULL) { + switch(type) { + case SYS_RES_IOPORT: + r = bus_alloc_resource(dev, type, rid, start, end, + count, rman_make_alignment_flags(count)); + if (r == NULL) + goto bad; + resource_list_add(&dinfo->resources, type, *rid, + rman_get_start(r), rman_get_end(r), count); + rle = resource_list_find(&dinfo->resources, type, *rid); + if (!rle) + goto bad; + rle->res = r; + break; + case SYS_RES_MEMORY: + break; + case SYS_RES_IRQ: + break; + } + return (rle->res); + } + if (rle->res->r_dev != dev) + return (NULL); + bus_release_resource(dev, type, *rid, rle->res); + rle->res = NULL; + switch(type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + if (!(flags & RF_ALIGNMENT_MASK)) + flags |= rman_make_alignment_flags(rle->count); + break; + case SYS_RES_IRQ: + flags |= RF_SHAREABLE; + break; + } + rle->res = resource_list_alloc(&dinfo->resources, dev, child, + type, rid, rle->start, rle->end, rle->count, flags); + return (rle->res); +bad:; + device_printf(dev, "WARNING: Resource not reserved by pccard\n"); + return (NULL); } -/* - * APM hooks for suspending and resuming. - */ -int -pccard_suspend(device_t dev) +static int +pccard_release_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) { - struct slot *slt = PCCARD_DEVICE2SOFTC(dev); + struct pccard_ivar *dinfo; + int passthrough = (device_get_parent(child) != dev); + struct resource_list_entry *rle = 0; + int ret; + int flags; - /* This code stolen from pccard_event:card_removed */ - if (slt->state == filled) { - int s = splhigh(); /* nop on current */ - disable_slot(slt); - slt->laststate = suspend; /* for pccardd */ - slt->state = empty; - splx(s); - printf("pccard: card disabled, slot %d\n", slt->slotnum); + if (passthrough) + return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, + type, rid, r); + + dinfo = device_get_ivars(child); + + rle = resource_list_find(&dinfo->resources, type, rid); + + if (!rle) { + device_printf(dev, "Allocated resource not found, " + "%d %x %lx %lx\n", + type, rid, rman_get_start(r), rman_get_size(r)); + return ENOENT; + } + if (!rle->res) { + device_printf(dev, "Allocated resource not recorded\n"); + return ENOENT; + } + + ret = BUS_RELEASE_RESOURCE(device_get_parent(dev), child, + type, rid, r); + switch(type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + flags = rman_make_alignment_flags(rle->count); + break; + case SYS_RES_IRQ: + flags = RF_SHAREABLE; + break; + default: + flags = 0; } + rle->res = bus_alloc_resource(dev, type, &rid, + rle->start, rle->end, rle->count, flags); + if (rle->res == NULL) + device_printf(dev, "release_resource: " + "unable to reaquire resource\n"); + return ret; +} + +static void +pccard_child_detached(device_t parent, device_t dev) +{ + struct pccard_ivar *ivar = PCCARD_IVAR(dev); + struct pccard_function *pf = ivar->fcn; + + pccard_function_disable(pf); +} + +static void +pccard_intr(void *arg) +{ + struct pccard_function *pf = (struct pccard_function*) arg; + int reg; + int doisr = 1; + /* - * Disable any pending timeouts for this slot since we're - * powering it down/disabling now. + * MFC cards know if they interrupted, so we have to ack the + * interrupt and call the ISR. Non-MFC cards don't have these + * bits, so they always get called. Many non-MFC cards have + * this bit set always upon read, but some do not. + * + * We always ack the interrupt, even if there's no ISR + * for the card. This is done on the theory that acking + * the interrupt will pacify the card enough to keep an + * interrupt storm from happening. Of course this won't + * help in the non-MFC case. */ - untimeout(power_off_slot, (caddr_t)slt, slt->poff_ch); - slt->ctrl->disable(slt); - return (0); + if (pccard_mfc(pf->sc)) { + reg = pccard_ccr_read(pf, PCCARD_CCR_STATUS); + if (reg & PCCARD_CCR_STATUS_INTR) + pccard_ccr_write(pf, PCCARD_CCR_STATUS, + reg & ~PCCARD_CCR_STATUS_INTR); + else + doisr = 0; + } + if (pf->intr_handler != NULL && doisr) + pf->intr_handler(pf->intr_handler_arg); } -int -pccard_resume(device_t dev) +static int +pccard_setup_intr(device_t dev, device_t child, struct resource *irq, + int flags, driver_intr_t *intr, void *arg, void **cookiep) { - struct slot *slt = PCCARD_DEVICE2SOFTC(dev); + struct pccard_softc *sc = PCCARD_SOFTC(dev); + struct pccard_ivar *ivar = PCCARD_IVAR(child); + struct pccard_function *func = ivar->fcn; + int err; - slt->ctrl->resume(slt); + if (func->intr_handler != NULL) + panic("Only one interrupt handler per function allowed"); + err = bus_generic_setup_intr(dev, child, irq, flags, pccard_intr, + func, cookiep); + if (err != 0) + return (err); + func->intr_handler = intr; + func->intr_handler_arg = arg; + func->intr_handler_cookie = *cookiep; + if (pccard_mfc(sc)) { + pccard_ccr_write(func, PCCARD_CCR_OPTION, + pccard_ccr_read(func, PCCARD_CCR_OPTION) | + PCCARD_CCR_OPTION_IREQ_ENABLE); + } return (0); } + +static int +pccard_teardown_intr(device_t dev, device_t child, struct resource *r, + void *cookie) +{ + struct pccard_softc *sc = PCCARD_SOFTC(dev); + struct pccard_ivar *ivar = PCCARD_IVAR(child); + struct pccard_function *func = ivar->fcn; + int ret; + + if (pccard_mfc(sc)) { + pccard_ccr_write(func, PCCARD_CCR_OPTION, + pccard_ccr_read(func, PCCARD_CCR_OPTION) & + ~PCCARD_CCR_OPTION_IREQ_ENABLE); + } + ret = bus_generic_teardown_intr(dev, child, r, cookie); + if (ret == 0) { + func->intr_handler = NULL; + func->intr_handler_arg = NULL; + func->intr_handler_cookie = NULL; + } + + return (ret); +} + +static device_method_t pccard_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pccard_probe), + DEVMETHOD(device_attach, pccard_attach), + DEVMETHOD(device_detach, pccard_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, pccard_suspend), + DEVMETHOD(device_resume, pccard_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, pccard_print_child), + DEVMETHOD(bus_driver_added, pccard_driver_added), + DEVMETHOD(bus_child_detached, pccard_child_detached), + DEVMETHOD(bus_alloc_resource, pccard_alloc_resource), + DEVMETHOD(bus_release_resource, pccard_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, pccard_setup_intr), + DEVMETHOD(bus_teardown_intr, pccard_teardown_intr), + DEVMETHOD(bus_set_resource, pccard_set_resource), + DEVMETHOD(bus_get_resource, pccard_get_resource), + DEVMETHOD(bus_delete_resource, pccard_delete_resource), + DEVMETHOD(bus_probe_nomatch, pccard_probe_nomatch), + DEVMETHOD(bus_read_ivar, pccard_read_ivar), + DEVMETHOD(bus_child_pnpinfo_str, pccard_child_pnpinfo_str), + DEVMETHOD(bus_child_location_str, pccard_child_location_str), + + /* 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), + DEVMETHOD(card_compat_do_probe, pccard_compat_do_probe), + DEVMETHOD(card_compat_do_attach, pccard_compat_do_attach), + DEVMETHOD(card_do_product_lookup, pccard_do_product_lookup), + + { 0, 0 } +}; + +static driver_t pccard_driver = { + "pccard", + pccard_methods, + sizeof(struct pccard_softc) +}; + +devclass_t pccard_devclass; + +/* Maybe we need to have a slot device? */ +DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0); +DRIVER_MODULE(pccard, pc98pcic, pccard_driver, pccard_devclass, 0, 0); +DRIVER_MODULE(pccard, cbb, pccard_driver, pccard_devclass, 0, 0); +DRIVER_MODULE(pccard, tcic, pccard_driver, pccard_devclass, 0, 0); +MODULE_VERSION(pccard, 1); +/*MODULE_DEPEND(pccard, pcic, 1, 1, 1);*/ diff --git a/sys/dev/misc/pccard/pccard_cis.c b/sys/bus/pccard/pccard_cis.c similarity index 87% rename from sys/dev/misc/pccard/pccard_cis.c rename to sys/bus/pccard/pccard_cis.c index 089bc22302..e4773dbb51 100644 --- a/sys/dev/misc/pccard/pccard_cis.c +++ b/sys/bus/pccard/pccard_cis.c @@ -1,3 +1,7 @@ +/* $NetBSD: pcmcia_cis.c,v 1.17 2000/02/10 09:01:52 chopps Exp $ */ +/* $FreeBSD: src/sys/dev/pccard/pccard_cis.c,v 1.23 2002/11/14 14:02:32 mux Exp $ */ +/* $DragonFly: src/sys/bus/pccard/pccard_cis.c,v 1.1 2004/02/10 07:55:45 joerg Exp $ */ + /* * Copyright (c) 1997 Marc Horowitz. All rights reserved. * @@ -25,10 +29,6 @@ * 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. - * - * $NetBSD: pcmcia_cis.c,v 1.10 1998/12/29 09:03:15 marc Exp $ - * $FreeBSD: src/sys/dev/pccard/pccard_cis.c,v 1.5.2.1 2000/05/23 03:56:59 imp Exp $ - * $DragonFly: src/sys/dev/misc/pccard/Attic/pccard_cis.c,v 1.3 2003/08/15 08:32:29 dillon Exp $ */ #include @@ -49,11 +49,12 @@ #include "card_if.h" +extern int pccard_cis_debug; + #define PCCARDCISDEBUG #ifdef PCCARDCISDEBUG -int pccardcis_debug = 1; -#define DPRINTF(arg) if (pccardcis_debug) printf arg -#define DEVPRINTF(arg) if (pccardcis_debug) device_printf arg +#define DPRINTF(arg) if (pccard_cis_debug) printf arg +#define DEVPRINTF(arg) if (pccard_cis_debug) device_printf arg #else #define DPRINTF(arg) #define DEVPRINTF(arg) @@ -71,14 +72,14 @@ struct cis_state { }; int pccard_parse_cis_tuple(struct pccard_tuple *, void *); +static int decode_funce(struct pccard_tuple *, struct pccard_function *); void pccard_read_cis(struct pccard_softc *sc) { struct cis_state state; - state.count = 0; - state.gotmfc = 0; + bzero(&state, sizeof state); state.card = &sc->card; @@ -89,14 +90,12 @@ pccard_read_cis(struct pccard_softc *sc) state.card->cis1_info[1] = NULL; state.card->cis1_info[2] = NULL; state.card->cis1_info[3] = NULL; - state.card->manufacturer = PCCARD_VENDOR_INVALID; - state.card->product = PCCARD_PRODUCT_INVALID; + state.card->manufacturer = PCMCIA_VENDOR_INVALID; + state.card->product = PCMCIA_PRODUCT_INVALID; STAILQ_INIT(&state.card->pf_head); state.pf = NULL; -printf("Calling scan_cis\n"); - if (pccard_scan_cis(sc->dev, pccard_parse_cis_tuple, &state) == -1) state.card->error++; @@ -170,7 +169,6 @@ 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; } @@ -210,7 +208,7 @@ pccard_scan_cis(device_t dev, int (*fct)(struct pccard_tuple *, void *), u_int cksum, sum; int i; - *((u_int16_t *) & offset) = + offset = (uint16_t) pccard_tuple_read_2(&tuple, 0); length = pccard_tuple_read_2(&tuple, 2); cksum = pccard_tuple_read_1(&tuple, 4); @@ -226,9 +224,8 @@ pccard_scan_cis(device_t dev, int (*fct)(struct pccard_tuple *, void *), * distant regions */ if ((addr >= PCCARD_CIS_SIZE) || - ((addr + length) < 0) || ((addr + length) >= - PCCARD_CIS_SIZE)) { + PCCARD_CIS_SIZE)) { DPRINTF((" skipped, " "too distant\n")); break; @@ -262,17 +259,50 @@ pccard_scan_cis(device_t dev, int (*fct)(struct pccard_tuple *, void *), "short %d\n", tuple.length)); break; } + if (((tuple.length - 1) % 5) != 0) { + DPRINTF(("CISTPL_LONGLINK_MFC bogus " + "length %d\n", tuple.length)); + break; + } /* * this is kind of ad hoc, as I don't have * any real documentation */ { - int i; + int i, tmp_count; - mfc_count = + /* + * put count into tmp var so that + * if we have to bail (because it's + * a bogus count) it won't be + * remembered for later use. + */ + tmp_count = pccard_tuple_read_1(&tuple, 0); + DPRINTF(("CISTPL_LONGLINK_MFC %d", - mfc_count)); + tmp_count)); + + /* + * make _sure_ it's the right size; + * if too short, it may be a weird + * (unknown/undefined) format + */ + if (tuple.length != (tmp_count*5 + 1)) { + DPRINTF((" bogus length %d\n", + tuple.length)); + break; + } + /* + * sanity check for a programming + * error which is difficult to find + * when debugging. + */ + if (tmp_count > + howmany(sizeof mfc, sizeof mfc[0])) + panic("CISTPL_LONGLINK_MFC mfc " + "count would blow stack"); + mfc_count = tmp_count; for (i = 0; i < mfc_count; i++) { mfc[i].common = (pccard_tuple_read_1(&tuple, @@ -316,6 +346,7 @@ pccard_scan_cis(device_t dev, int (*fct)(struct pccard_tuple *, void *), if ((i % 16) == 13) DPRINTF(("\n")); } + if ((i % 16) != 14) DPRINTF(("\n")); } @@ -324,10 +355,6 @@ pccard_scan_cis(device_t dev, int (*fct)(struct pccard_tuple *, void *), tuple.ptr += 2 + tuple.length; } -#ifdef XXX /* I'm not up to this tonight, need to implement new API */ - /* to deal with moving windows and such. At least that's */ - /* what it appears at this instant */ - /* * the chain is done. Clean up and move onto the next one, * if any. The loop is here in the case that there is an MFC @@ -337,53 +364,26 @@ pccard_scan_cis(device_t dev, int (*fct)(struct pccard_tuple *, void *), */ while (1) { - pccard_chip_mem_unmap(pct, pch, window); - if (longlink_present) { - /* - * if the longlink is to attribute memory, - * then it is unindexed. That is, if the - * link value is 0x100, then the actual - * memory address is 0x200. This means that - * we need to multiply by 2 before calling - * mem_map, and then divide the resulting ptr - * by 2 after. - */ - - if (!longlink_common) - longlink_addr *= 2; - - pccard_chip_mem_map(pct, pch, longlink_common ? - PCCARD_MEM_COMMON : PCCARD_MEM_ATTR, - longlink_addr, PCCARD_CIS_SIZE, - &pcmh, &tuple.ptr, &window); - - if (!longlink_common) - tuple.ptr /= 2; + CARD_SET_RES_FLAGS(device_get_parent(dev), dev, + SYS_RES_MEMORY, rid, longlink_common ? + PCCARD_A_MEM_COM : PCCARD_A_MEM_ATTR); DPRINTF(("cis mem map %x\n", (unsigned int) tuple.memh)); tuple.mult = longlink_common ? 1 : 2; + tuple.ptr = longlink_addr; longlink_present = 0; longlink_common = 1; longlink_addr = 0; } else if (mfc_count && (mfc_index < mfc_count)) { - if (!mfc[mfc_index].common) - mfc[mfc_index].addr *= 2; - - pccard_chip_mem_map(pct, pch, - mfc[mfc_index].common ? - PCCARD_MEM_COMMON : PCCARD_MEM_ATTR, - mfc[mfc_index].addr, PCCARD_CIS_SIZE, - &pcmh, &tuple.ptr, &window); - - if (!mfc[mfc_index].common) - tuple.ptr /= 2; + CARD_SET_RES_FLAGS(device_get_parent(dev), dev, + SYS_RES_MEMORY, rid, mfc[mfc_index].common + ? PCCARD_A_MEM_COM : PCCARD_A_MEM_ATTR); DPRINTF(("cis mem map %x\n", (unsigned int) tuple.memh)); /* set parse state, and point at the next one */ - tuple.mult = mfc[mfc_index].common ? 1 : 2; - + tuple.ptr = mfc[mfc_index].addr; mfc_index++; } else { goto done; @@ -413,10 +413,8 @@ pccard_scan_cis(device_t dev, int (*fct)(struct pccard_tuple *, void *), continue; } tuple.ptr += 2 + tuple.length; - break; } -#endif /* XXX */ } done: @@ -430,7 +428,7 @@ done: void pccard_print_cis(device_t dev) { - struct pccard_softc *sc = (struct pccard_softc *) device_get_softc(dev); + struct pccard_softc *sc = PCCARD_SOFTC(dev); struct pccard_card *card = &sc->card; struct pccard_function *pf; struct pccard_config_entry *cfe; @@ -506,7 +504,7 @@ pccard_print_cis(device_t dev) break; } - printf(", ccr addr %lx mask %lx\n", pf->ccr_base, pf->ccr_mask); + printf(", ccr addr %x mask %x\n", pf->ccr_base, pf->ccr_mask); STAILQ_FOREACH(cfe, &pf->cfe_head, cfe_list) { device_printf(dev, "function %d, config table entry " @@ -749,6 +747,18 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) } state->card->manufacturer = pccard_tuple_read_2(tuple, 0); state->card->product = pccard_tuple_read_2(tuple, 2); + /* + * This is for xe driver. But not limited to that driver. + * In PC Card Standard, + * Manufacturer ID: 2byte. + * Product ID: typically 2bytes, but there's no limit on its + * size. prodext is a two byte field, so maybe we should + * also handle the '6' case. So far no cards have surfaced + * with a length of '6'. + */ + if (tuple->length == 5 ) { + state->card->prodext = pccard_tuple_read_1(tuple, 4); + } DPRINTF(("CISTPL_MANFID\n")); break; case PCCARD_CISTPL_FUNCID: @@ -759,8 +769,7 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) } if ((state->pf == NULL) || (state->gotmfc == 2)) { state->pf = malloc(sizeof(*state->pf), M_DEVBUF, - M_NOWAIT); - bzero(state->pf, sizeof(*state->pf)); + M_NOWAIT | M_ZERO); state->pf->number = state->count++; state->pf->last_config_index = -1; STAILQ_INIT(&state->pf->cfe_head); @@ -772,6 +781,17 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) DPRINTF(("CISTPL_FUNCID\n")); break; + case PCCARD_CISTPL_FUNCE: + if (state->pf == NULL || state->pf->function <= 0) { + DPRINTF(("CISTPL_FUNCE is not followed by " + "valid CISTPL_FUNCID\n")); + break; + } + if (tuple->length >= 2) { + decode_funce(tuple, state->pf); + } + DPRINTF(("CISTPL_FUNCE\n")); + break; case PCCARD_CISTPL_CONFIG: if (tuple->length < 3) { DPRINTF(("CISTPL_CONFIG too short %d\n", @@ -797,8 +817,7 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) } if (state->pf == NULL) { state->pf = malloc(sizeof(*state->pf), - M_DEVBUF, M_NOWAIT); - bzero(state->pf, sizeof(*state->pf)); + M_DEVBUF, M_NOWAIT | M_ZERO); state->pf->number = state->count++; state->pf->last_config_index = -1; STAILQ_INIT(&state->pf->cfe_head); @@ -917,6 +936,10 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) if (intface) { reg = pccard_tuple_read_1(tuple, idx); idx++; + cfe->flags &= ~(PCCARD_CFE_MWAIT_REQUIRED + | PCCARD_CFE_RDYBSY_ACTIVE + | PCCARD_CFE_WP_ACTIVE + | PCCARD_CFE_BVD_ACTIVE); if (reg & PCCARD_TPCE_IF_MWAIT) cfe->flags |= PCCARD_CFE_MWAIT_REQUIRED; if (reg & PCCARD_TPCE_IF_RDYBSY) @@ -984,7 +1007,8 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) reg = pccard_tuple_read_1(tuple, idx); idx++; - + cfe->flags &= + ~(PCCARD_CFE_IO8 | PCCARD_CFE_IO16); if (reg & PCCARD_TPCE_IO_BUSWIDTH_8BIT) cfe->flags |= PCCARD_CFE_IO8; if (reg & PCCARD_TPCE_IO_BUSWIDTH_16BIT) @@ -1061,7 +1085,9 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) reg = pccard_tuple_read_1(tuple, idx); idx++; - + cfe->flags &= ~(PCCARD_CFE_IRQSHARE + | PCCARD_CFE_IRQPULSE + | PCCARD_CFE_IRQLEVEL); if (reg & PCCARD_TPCE_IR_SHARE) cfe->flags |= PCCARD_CFE_IRQSHARE; if (reg & PCCARD_TPCE_IR_PULSE) @@ -1183,13 +1209,15 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) reg = pccard_tuple_read_1(tuple, idx); idx++; - + cfe->flags &= ~(PCCARD_CFE_POWERDOWN + | PCCARD_CFE_READONLY + | PCCARD_CFE_AUDIO); if (reg & PCCARD_TPCE_MI_PWRDOWN) - cfe->flags = PCCARD_CFE_POWERDOWN; + cfe->flags |= PCCARD_CFE_POWERDOWN; if (reg & PCCARD_TPCE_MI_READONLY) - cfe->flags = PCCARD_CFE_READONLY; + cfe->flags |= PCCARD_CFE_READONLY; if (reg & PCCARD_TPCE_MI_AUDIO) - cfe->flags = PCCARD_CFE_AUDIO; + cfe->flags |= PCCARD_CFE_AUDIO; cfe->maxtwins = reg & PCCARD_TPCE_MI_MAXTWINS; while (reg & PCCARD_TPCE_MI_EXT) { @@ -1210,3 +1238,36 @@ pccard_parse_cis_tuple(struct pccard_tuple *tuple, void *arg) return (0); } + +static int +decode_funce(struct pccard_tuple *tuple, struct pccard_function *pf) +{ + int type = pccard_tuple_read_1(tuple, 0); + + switch (pf->function) { + case PCCARD_FUNCTION_DISK: + if (type == PCCARD_TPLFE_TYPE_DISK_DEVICE_INTERFACE) { + pf->pf_funce_disk_interface + = pccard_tuple_read_1(tuple, 1); + } + break; + case PCCARD_FUNCTION_NETWORK: + if (type == PCCARD_TPLFE_TYPE_LAN_NID) { + int i; + int len = pccard_tuple_read_1(tuple, 1); + if (tuple->length < 2 + len || len > 8) { + /* tuple length not enough or nid too long */ + break; + } + for (i = 0; i < len; i++) { + pf->pf_funce_lan_nid[i] + = pccard_tuple_read_1(tuple, i + 2); + } + pf->pf_funce_lan_nidlen = len; + } + break; + default: + break; + } + return 0; +} diff --git a/sys/dev/misc/pccard/pccard_cis_quirks.c b/sys/bus/pccard/pccard_cis_quirks.c similarity index 80% rename from sys/dev/misc/pccard/pccard_cis_quirks.c rename to sys/bus/pccard/pccard_cis_quirks.c index d56203c156..d21e71ef02 100644 --- a/sys/dev/misc/pccard/pccard_cis_quirks.c +++ b/sys/bus/pccard/pccard_cis_quirks.c @@ -1,3 +1,9 @@ +/* $NetBSD: pcmcia_cis_quirks.c,v 1.6 2000/04/12 21:07:55 scw Exp $ */ +/* $FreeBSD: src/sys/dev/pccard/pccard_cis_quirks.c,v 1.7 2002/02/09 21:34:06 imp Exp $ */ +/* $DragonFly: src/sys/bus/pccard/pccard_cis_quirks.c,v 1.1 2004/02/10 07:55:45 joerg Exp $ */ + +#define PCCARDDEBUG + /* * Copyright (c) 1998 Marc Horowitz. All rights reserved. * @@ -25,14 +31,8 @@ * 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. - * - * $NetBSD: pcmcia_cis_quirks.c,v 1.5 1999/10/11 17:50:21 thorpej Exp $ - * $FreeBSD: src/sys/dev/pccard/pccard_cis_quirks.c,v 1.2.2.1 2000/05/23 03:57:00 imp Exp $ - * $DragonFly: src/sys/dev/misc/pccard/Attic/pccard_cis_quirks.c,v 1.3 2003/08/15 08:32:29 dillon Exp $ */ -#define PCCARDDEBUG - #include #include #include @@ -46,7 +46,7 @@ #include #include -#include "pccarddevs.h" +#include #include #include @@ -162,23 +162,46 @@ static struct pccard_config_entry pccard_sveclancard_func0_cfe0 = { 0, /* maxtwins */ }; +static struct pccard_function pccard_ndc_nd5100_func0 = { + 0, /* function number */ + PCCARD_FUNCTION_NETWORK, + 0x23, /* last cfe number */ + 0x3f8, /* ccr_base */ + 0x3, /* ccr_mask */ +}; + +static struct pccard_config_entry pccard_ndc_nd5100_func0_cfe0 = { + 0x20, /* cfe number */ + PCCARD_CFE_MWAIT_REQUIRED | PCCARD_CFE_IO16 | PCCARD_CFE_IRQLEVEL, + PCCARD_IFTYPE_IO, + 1, /* num_iospace */ + 5, /* iomask */ + { { 0x20, 0x300 } }, /* iospace */ + 0xdeb8, /* irqmask */ + 0, /* num_memspace */ + { }, /* memspace */ + 0, /* maxtwins */ +}; + static struct pccard_cis_quirk pccard_cis_quirks[] = { - { PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3CXEM556, PCCARD_CIS_INVALID, + { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CXEM556, PCMCIA_CIS_INVALID, &pccard_3cxem556_func0, &pccard_3cxem556_func0_cfe0 }, - { PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3CXEM556, PCCARD_CIS_INVALID, + { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CXEM556, PCMCIA_CIS_INVALID, &pccard_3cxem556_func1, &pccard_3cxem556_func1_cfe0 }, - { PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3CXEM556INT, PCCARD_CIS_INVALID, + { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CXEM556INT, PCMCIA_CIS_INVALID, &pccard_3cxem556_func0, &pccard_3cxem556_func0_cfe0 }, - { PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3CXEM556INT, PCCARD_CIS_INVALID, + { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CXEM556INT, PCMCIA_CIS_INVALID, &pccard_3cxem556_func1, &pccard_3cxem556_func1_cfe0 }, - { PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3CCFEM556BI, - PCCARD_CIS_INVALID, + { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CCFEM556BI, + PCMCIA_CIS_INVALID, &pccard_3ccfem556bi_func0, &pccard_3ccfem556bi_func0_cfe0 }, - { PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3CCFEM556BI, - PCCARD_CIS_INVALID, + { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CCFEM556BI, + PCMCIA_CIS_INVALID, &pccard_3ccfem556bi_func1, &pccard_3ccfem556bi_func1_cfe0 }, - { PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, PCCARD_CIS_SVEC_LANCARD, + { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, PCMCIA_CIS_SVEC_LANCARD, &pccard_sveclancard_func0, &pccard_sveclancard_func0_cfe0 }, + { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, PCMCIA_CIS_NDC_ND5100_E, + &pccard_ndc_nd5100_func0, &pccard_ndc_nd5100_func0_cfe0 }, }; static int n_pccard_cis_quirks = @@ -186,8 +209,7 @@ static int n_pccard_cis_quirks = void pccard_check_cis_quirks(device_t dev) { - struct pccard_softc *sc = (struct pccard_softc *) - device_get_softc(dev); + struct pccard_softc *sc = PCCARD_SOFTC(dev); int wiped = 0; int i, j; struct pccard_function *pf, *pf_next, *pf_last; @@ -199,10 +221,10 @@ void pccard_check_cis_quirks(device_t dev) for (i=0; icard.manufacturer == pccard_cis_quirks[i].manufacturer) && (sc->card.product == pccard_cis_quirks[i].product) && - (((sc->card.manufacturer != PCCARD_VENDOR_INVALID) && - (sc->card.product != PCCARD_PRODUCT_INVALID)) || - ((sc->card.manufacturer == PCCARD_VENDOR_INVALID) && - (sc->card.product == PCCARD_PRODUCT_INVALID) && + (((sc->card.manufacturer != PCMCIA_VENDOR_INVALID) && + (sc->card.product != PCMCIA_PRODUCT_INVALID)) || + ((sc->card.manufacturer == PCMCIA_VENDOR_INVALID) && + (sc->card.product == PCMCIA_PRODUCT_INVALID) && sc->card.cis1_info[0] && (strcmp(sc->card.cis1_info[0], pccard_cis_quirks[i].cis1_info[0]) == 0) && @@ -210,7 +232,7 @@ void pccard_check_cis_quirks(device_t dev) (strcmp(sc->card.cis1_info[1], pccard_cis_quirks[i].cis1_info[1]) == 0)))) { if (!wiped) { - if (pccard_verbose) { + if (bootverbose) { device_printf(dev, "using CIS quirks for "); for (j = 0; j < 4; j++) { if (sc->card.cis1_info[j] == NULL) diff --git a/sys/bus/pccard/pccard_nbk.c b/sys/bus/pccard/pccard_nbk.c deleted file mode 100644 index 71aeab438b..0000000000 --- a/sys/bus/pccard/pccard_nbk.c +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright (c) 1999, 2001 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: src/sys/pccard/pccard_nbk.c,v 1.15.2.11 2002/09/22 20:26:58 imp Exp $ - * $DragonFly: src/sys/bus/pccard/Attic/pccard_nbk.c,v 1.4 2004/01/08 10:06:29 joerg Exp $ - */ - -/* - * This file contains various kludges to allow the legacy pccard system to - * work in the newbus system until the pccard system can be converted - * wholesale to newbus. As that is a while off, I'm providing this glue to - * allow newbus drivers to have pccard attachments. - * - * We do *NOT* implement ISA ivars at all. We are not an isa bus, and drivers - * that abuse isa_{set,get}_* must be fixed in order to work with pccard. - * We use ivars for something else anyway, so it becomes fairly awkward - * to do so. - * - * Here's a summary of the glue that we do to make things work. - * - * First, we have pccard node in the device and driver trees. The pccard - * device lives in the instance tree attached to the nexus. The pccard - * attachments will be attached to that node. This allows one to pass things - * up the tree that terminates at the nexus, like other buses. The pccard - * code will create a device instance for each of the drivers that are to - * be attached. - * - * These compatibility nodes are called pccnbk. PCCard New Bus Kludge. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/* XXX Shouldn't reach into the MD code here */ -#ifdef PC98 -#include -#else -#include -#endif - -#include "cardinfo.h" -#include "slot.h" - -#include -#include - -#include "card_if.h" - -devclass_t pccard_devclass; - -#define PCCARD_NPORT 2 -#define PCCARD_NMEM 5 -#define PCCARD_NIRQ 1 -#define PCCARD_NDRQ 0 - -#define PCCARD_DEVINFO(d) (struct pccard_devinfo *) device_get_ivars(d) - -SYSCTL_NODE(_machdep, OID_AUTO, pccard, CTLFLAG_RW, 0, "pccard"); - -#ifdef UNSAFE -static u_long mem_start = IOM_BEGIN; -static u_long mem_end = IOM_END; -#else -static u_long mem_start = 0xd0000; -static u_long mem_end = 0xeffff; -#endif - -SYSCTL_ULONG(_machdep_pccard, OID_AUTO, mem_start, CTLFLAG_RW, - &mem_start, 0, ""); -SYSCTL_ULONG(_machdep_pccard, OID_AUTO, mem_end, CTLFLAG_RW, - &mem_end, 0, ""); - -#if __FreeBSD_version >= 500000 -/* - * glue for NEWCARD/OLDCARD compat layer - */ -static int -pccard_compat_do_probe(device_t bus, device_t dev) -{ - return (CARD_COMPAT_PROBE(dev)); -} - -static int -pccard_compat_do_attach(device_t bus, device_t dev) -{ - return (CARD_COMPAT_ATTACH(dev)); -} -#endif - -static int -pccard_probe(device_t dev) -{ - device_set_desc(dev, "PC Card 16-bit bus (classic)"); - return (0); -} - -static int -pccard_attach(device_t dev) -{ - return (0); -} - -static void -pccard_print_resources(struct resource_list *rl, const char *name, int type, - int count, const char *format) -{ - struct resource_list_entry *rle; - int printed; - int i; - - printed = 0; - for (i = 0; i < count; i++) { - rle = resource_list_find(rl, type, i); - if (rle) { - if (printed == 0) - printf(" %s ", name); - else if (printed > 0) - printf(","); - printed++; - printf(format, rle->start); - if (rle->count > 1) { - printf("-"); - printf(format, rle->start + rle->count - 1); - } - } else if (i > 3) { - /* check the first few regardless */ - break; - } - } -} - -static int -pccard_print_child(device_t dev, device_t child) -{ - struct pccard_devinfo *devi = PCCARD_DEVINFO(child); - struct resource_list *rl = &devi->resources; - int retval = 0; - int flags = device_get_flags(child); - - retval += bus_print_child_header(dev, child); - retval += printf(" at"); - - if (devi) { - pccard_print_resources(rl, "port", SYS_RES_IOPORT, - PCCARD_NPORT, "%#lx"); - pccard_print_resources(rl, "iomem", SYS_RES_MEMORY, - PCCARD_NMEM, "%#lx"); - pccard_print_resources(rl, "irq", SYS_RES_IRQ, PCCARD_NIRQ, - "%ld"); - pccard_print_resources(rl, "drq", SYS_RES_DRQ, PCCARD_NDRQ, - "%ld"); - if (flags != 0) - retval += printf(" flags 0x%x", flags); - retval += printf(" slot %d", devi->slt->slotnum); - } - - retval += bus_print_child_footer(dev, child); - - return (retval); -} - -static int -pccard_set_resource(device_t dev, device_t child, int type, int rid, - u_long start, u_long count) -{ - struct pccard_devinfo *devi = PCCARD_DEVINFO(child); - struct resource_list *rl = &devi->resources; - - if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY - && type != SYS_RES_IRQ && type != SYS_RES_DRQ) - return (EINVAL); - if (rid < 0) - return (EINVAL); - if (type == SYS_RES_IOPORT && rid >= PCCARD_NPORT) - return (EINVAL); - if (type == SYS_RES_MEMORY && rid >= PCCARD_NMEM) - return (EINVAL); - if (type == SYS_RES_IRQ && rid >= PCCARD_NIRQ) - return (EINVAL); - if (type == SYS_RES_DRQ && rid >= PCCARD_NDRQ) - return (EINVAL); - - resource_list_add(rl, type, rid, start, start + count - 1, count); - - return (0); -} - -static int -pccard_get_resource(device_t dev, device_t child, int type, int rid, - u_long *startp, u_long *countp) -{ - struct pccard_devinfo *devi = PCCARD_DEVINFO(child); - struct resource_list *rl = &devi->resources; - struct resource_list_entry *rle; - - rle = resource_list_find(rl, type, rid); - if (!rle) - return (ENOENT); - - if (startp) - *startp = rle->start; - if (countp) - *countp = rle->count; - - return (0); -} - -static void -pccard_delete_resource(device_t dev, device_t child, int type, int rid) -{ - struct pccard_devinfo *devi = PCCARD_DEVINFO(child); - struct resource_list *rl = &devi->resources; - resource_list_delete(rl, type, rid); -} - -static struct resource * -pccard_alloc_resource(device_t bus, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) -{ - /* - * Consider adding a resource definition. We allow rid 0 for - * irq, 0-4 for memory and 0-1 for ports - */ - int passthrough = (device_get_parent(child) != bus); - int isdefault; - struct pccard_devinfo *devi = device_get_ivars(child); - struct resource_list *rl = &devi->resources; - struct resource_list_entry *rle; - struct resource *res; - - if (start == 0 && end == ~0 && type == SYS_RES_MEMORY && count != 1) { - start = mem_start; - end = mem_end; - } - isdefault = (start == 0UL && end == ~0UL); - if (!passthrough && !isdefault) { - rle = resource_list_find(rl, type, *rid); - if (!rle) { - if (*rid < 0) - return (NULL); - switch (type) { - case SYS_RES_IRQ: - if (*rid >= PCCARD_NIRQ) - return (NULL); - break; - case SYS_RES_DRQ: - if (*rid >= PCCARD_NDRQ) - return (NULL); - break; - case SYS_RES_MEMORY: - if (*rid >= PCCARD_NMEM) - return (NULL); - break; - case SYS_RES_IOPORT: - if (*rid >= PCCARD_NPORT) - return (NULL); - break; - default: - return (NULL); - } - resource_list_add(rl, type, *rid, start, end, count); - } - } - res = resource_list_alloc(rl, bus, child, type, rid, start, end, - count, flags); - return (res); -} - -static int -pccard_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - struct pccard_devinfo *devi = PCCARD_DEVINFO(child); - struct resource_list *rl = &devi->resources; - return (resource_list_release(rl, bus, child, type, rid, r)); -} - -static int -pccard_read_ivar(device_t bus, device_t child, int which, uintptr_t *result) -{ - struct pccard_devinfo *devi = PCCARD_DEVINFO(child); - - switch (which) { - case PCCARD_IVAR_ETHADDR: - bcopy(devi->misc, result, ETHER_ADDR_LEN); - return (0); - case PCCARD_IVAR_VENDOR: - *(u_int32_t *) result = devi->manufacturer; - return (0); - case PCCARD_IVAR_PRODUCT: - *(u_int32_t *) result = devi->product; - return (0); - case PCCARD_IVAR_PRODEXT: - *(u_int16_t *) result = devi->prodext; - return (0); - } - return (ENOENT); -} - -static int -pccard_set_res_flags(device_t bus, device_t child, int restype, int rid, - u_long value) -{ - return (CARD_SET_RES_FLAGS(device_get_parent(bus), child, restype, - rid, value)); -} - -static int -pccard_get_res_flags(device_t bus, device_t child, int restype, int rid, - u_long *value) -{ - return (CARD_GET_RES_FLAGS(device_get_parent(bus), child, restype, - rid, value)); -} - -static int -pccard_set_memory_offset(device_t bus, device_t child, int rid, - u_int32_t offset, u_int32_t *deltap) -{ - return (CARD_SET_MEMORY_OFFSET(device_get_parent(bus), child, rid, - offset, deltap)); -} - -static int -pccard_get_memory_offset(device_t bus, device_t child, int rid, - u_int32_t *offset) -{ - return (CARD_GET_MEMORY_OFFSET(device_get_parent(bus), child, rid, - offset)); -} - -#if __FreeBSD_version >= 500000 -static int -pccard_get_function_num(device_t bus, device_t child, int *function) -{ - *function = 0; - return (0); -} - -static int -pccard_activate_function(device_t bus, device_t child) -{ - /* pccardd has alrady activated the function */ - return (0); -} - -static int -pccard_deactivate_function(device_t bus, device_t child) -{ - /* pccardd will deactivate the function */ - return (0); -} - -static const struct pccard_product * -pccard_do_product_lookup(device_t bus, device_t dev, - const struct pccard_product *tab, - size_t ent_size, pccard_product_match_fn matchfn) -{ - return (NULL); -} -#endif - -static device_method_t pccard_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, pccard_probe), - DEVMETHOD(device_attach, pccard_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, pccard_suspend), - DEVMETHOD(device_resume, pccard_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, pccard_print_child), - DEVMETHOD(bus_driver_added, bus_generic_driver_added), - DEVMETHOD(bus_alloc_resource, pccard_alloc_resource), - DEVMETHOD(bus_release_resource, pccard_release_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_set_resource, pccard_set_resource), - DEVMETHOD(bus_get_resource, pccard_get_resource), - DEVMETHOD(bus_delete_resource, pccard_delete_resource), - DEVMETHOD(bus_read_ivar, pccard_read_ivar), - - /* Card interface */ - DEVMETHOD(card_set_res_flags, pccard_set_res_flags), - DEVMETHOD(card_get_res_flags, pccard_get_res_flags), - DEVMETHOD(card_set_memory_offset, pccard_set_memory_offset), - DEVMETHOD(card_get_memory_offset, pccard_get_memory_offset), -#if __FreeBSD_version >= 500000 - DEVMETHOD(card_get_function, pccard_get_function_num), - DEVMETHOD(card_activate_function, pccard_activate_function), - DEVMETHOD(card_deactivate_function, pccard_deactivate_function), - DEVMETHOD(card_compat_do_probe, pccard_compat_do_probe), - DEVMETHOD(card_compat_do_attach, pccard_compat_do_attach), - DEVMETHOD(card_do_product_lookup, pccard_do_product_lookup), -#endif - { 0, 0 } -}; - -static driver_t pccard_driver = { - "pccard", - pccard_methods, - sizeof(struct slot) -}; - -DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0); -DRIVER_MODULE(pccard, mecia, pccard_driver, pccard_devclass, 0, 0); -MODULE_VERSION(pccard, 1); diff --git a/sys/bus/pccard/pccard_nbk.h b/sys/bus/pccard/pccard_nbk.h deleted file mode 100644 index 7efdcff94f..0000000000 --- a/sys/bus/pccard/pccard_nbk.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 1999, 2001 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: src/sys/pccard/pccard_nbk.h,v 1.4.2.2 2002/09/22 20:26:58 imp Exp $ - * $DragonFly: src/sys/bus/pccard/Attic/pccard_nbk.h,v 1.2 2003/06/17 04:28:55 dillon Exp $ - */ - -#ifndef PCCARD_PCCARD_NBK_H -#define PCCARD_PCCARD_NBK_H - -SYSCTL_DECL(_machdep_pccard); - -struct pccard_device; -extern devclass_t pccard_devclass; - -#endif /* ! PCCARD_PCCARD_NBK_H */ diff --git a/sys/bus/pccard/pccarddevs b/sys/bus/pccard/pccarddevs new file mode 100644 index 0000000000..ba8afa7cde --- /dev/null +++ b/sys/bus/pccard/pccarddevs @@ -0,0 +1,611 @@ +$DragonFly: src/sys/bus/pccard/pccarddevs,v 1.1 2004/02/10 07:55:45 joerg Exp $ +/* $NetBSD: pcmciadevs,v 1.186 2003/09/16 08:26:37 onoe Exp $ */ +/* $OpenBSD: pcmciadevs,v 1.93 2002/06/21 08:31:10 henning Exp $ */ +/* $FreeBSD: src/sys/dev/pccard/pccarddevs,v 1.79 2003/11/03 16:09:17 imp Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +/* + * List of known PCMCIA vendors, sorted by numeric ID. + */ + +vendor FUJITSU 0x0004 Fujitsu Corporation +vendor INTERSIL 0x000b Intersil +vendor PANASONIC 0x0032 Matsushita Electric Industrial Co. +vendor SANDISK 0x0045 Sandisk Corporation +vendor NEWMEDIA 0x0057 New Media Corporation +vendor INTEL 0x0089 Intel +vendor IBM 0x00a4 IBM Corporation +vendor SHARP 0x00b0 Sharp Corporation +vendor 3COM 0x0101 3Com Corporation +vendor MEGAHERTZ 0x0102 Megahertz Corporation +vendor SOCKET 0x0104 Socket Communications +vendor TDK 0x0105 TDK Corporation +vendor XIRCOM 0x0105 Xircom +vendor SMC 0x0108 Standard Microsystems Corporation +vendor MOTOROLA 0x0109 Motorola Corporation +vendor NI 0x010b National Instruments +vendor QLOGIC 0x0114 QLogic +vendor USROBOTICS 0x0115 US Robotics Corporation +vendor OLICOM 0x0121 Olicom +vendor PROXIM 0x0126 Proxim +vendor DSPSI 0x0128 DSP Solutions, Inc +vendor ADAPTEC 0x012f Adaptec Corporation +vendor QUATECH 0x0137 Quatech +vendor COMPAQ 0x0138 Compaq +vendor OSITECH 0x0140 Ositech +vendor DLINK_2 0x0143 D-Link +vendor DLINK_3 0x0149 D-Link +vendor LINKSYS 0x0149 Linksys Corporation +vendor NETGEAR 0x0149 Netgear +vendor SIMPLETECH 0x014d Simple Technology +vendor SYMBOL2 0x014d Symbol +vendor LUCENT 0x0156 Lucent Technologies +vendor GEMPLUS 0x0157 Gemplus +vendor AIRONET 0x015f Aironet Wireless Communications +vendor ERICSSON 0x016b Ericsson +vendor PSION 0x016c Psion +vendor COMPAQ2 0x0183 Compaq +vendor PARALON 0x0183 Paralon Technologies Inc +vendor KINGSTON 0x0186 Kingston +vendor MELCO 0x018a Melco Corporation +vendor DAYNA 0x0194 Dayna Corporation +vendor RAYTHEON 0x01a6 Raytheon +vendor IODATA 0x01bf I-O DATA +vendor BAY 0x01eb Bay Networks +vendor FARALLON 0x0200 Farallon Communications +vendor TELECOMDEVICE 0x021b Telecom Device +vendor NOKIA 0x023d Nokia Communications +vendor SAMSUNG 0x0250 Samsung +vendor HWN 0x0261 Home Wireless Networks +vendor ARTEM 0x0268 ARtem +vendor SYMBOL 0x026c Symbol +vendor BUFFALO 0x026f BUFFALO (Melco Corporation) +vendor BROMAX 0x0274 Bromax communications, Inc +vendor IODATA2 0x028a I-O DATA +vendor ASUS 0x02aa ASUS +vendor SIEMENS 0x02ac Siemens +vendor MICROSOFT 0x02d2 Microsoft Corporation + +/* + * The following vendor IDs are byte-swapped from what the company is assigned. + */ +vendor NWN 0x0602 No Wires Needed +vendor BREEZECOM 0x0a02 BreezeCOM +vendor LASAT 0x3401 Lasat Communications A/S +vendor BONDWELL 0x3b01 Bondwell +vendor LEXARMEDIA 0x4e01 Lexar Media +vendor COMPEX 0x8a01 Compex Corporation +vendor ZONET 0x8a01 Zonet Technology Inc. +vendor ELSA 0xd601 Elsa + +/* + * The following vendor IDs are not, as far as I can tell, actually + * assigned to these people. However, all the ones starting with '0xc' + * look coherent enough that maybe somebody other than PCMCIA is + * assigning numbers in that range. + */ +vendor NEWMEDIA2 0x10cd NewMedia +vendor PLANEX_2 0x14ea PLANEX +vendor ACTIONTEC 0x1668 ACTIONTEC +vendor AIRVAST 0x50c2 AirVast Technology +vendor ARCHOS 0x5241 Archos +vendor DUAL 0x890f Dual +vendor EDIMAX 0x890f Edimax Technology Inc. +vendor CONTEC 0xc001 Contec +vendor MACNICA 0xc00b MACNICA +vendor ROLAND 0xc00c Roland +vendor COREGA2 0xc00f Corega K.K. +vendor ALLIEDTELESIS 0xc00f Allied Telesis K.K. +vendor HAGIWARASYSCOM 0xc012 Hagiwara SYS-COM +vendor RATOC 0xc015 RATOC System Inc. +vendor WORKBIT 0xc024 WORKBIT +vendor EMTAC 0xc250 EMTAC Technology Corporation + +/* + * List of known products. Grouped by vendor, sorted by number within the + * group. + */ + +/* 3COM Products */ +product 3COM 3CRWE737A 0x0001 3Com AirConnect Wireless LAN +product 3COM 3CXM056BNW 0x002f 3Com/NoteWorthy 3CXM056-BNW 56K Modem +product 3COM 3CXEM556 0x0035 3Com/Megahertz 3CXEM556 Ethernet/Modem +product 3COM 3CXEM556INT 0x003d 3Com/Megahertz 3CXEM556-INT Ethernet/Modem +product 3COM 3CCFEM556BI 0x0556 3Com/Megahertz 3CCFEM556BI Ethernet/Modem +product 3COM 3C562 0x0562 3Com 3c562 33.6 Modem/10Mbps Ethernet +product 3COM 3C589 0x0589 3Com 3c589 10Mbps Ethernet +product 3COM 3C574 0x0574 3Com 3c574-TX 10/100Mbps Ethernet +product 3COM 3CRWE777A 0x0777 3Com 3CRWE777A Airconnect +product 3COM 3C1 0x0cf1 3Com Megahertz 3C1 10Mbps LAN CF+ Card +product 3COM 3CRWE62092A 0x2092 3Com 3CRWE62092A Wireless LAN + +/* ACTIONTEC Products */ +product ACTIONTEC PRISM 0x0101 PRISM Wireless LAN PC Card + +/* Adaptec Products */ +product ADAPTEC APA1460 0x0001 Adaptec APA-1460 SlimSCSI +product ADAPTEC APA1460A 0x0002 Adaptec APA-1460A SlimSCSI + +/* Aironet */ +product AIRONET PC4500 0x0005 Aironet PC4500 Wireless LAN Adapter +product AIRONET PC4800 0x0007 Aironet PC4800 Wireless LAN Adapter +product AIRONET 350 0x000a Aironet 350 Wireless LAN Adapter + +/* AirVast */ +product AIRVAST WN_100 0x7300 AirVast WN-100 + +/* Allied Telesis K.K. */ +product ALLIEDTELESIS LA_PCM 0x0002 Allied Telesis LA-PCM + +/* Archos */ +product ARCHOS ARC_ATAPI 0x0043 MiniCD + +/* ARtem */ +product ARTEM ONAIR 0x0001 ARtem OnAir + +/* ASUS WL-100 */ +product ASUS WL100 0x0002 ASUS SpaceLink WL-100 Wireless LAN + +/* Bay Networks */ +product BAY STACK_650 0x0804 BayStack 650 Wireless LAN +product BAY SURFER_PRO 0x0806 AirSurfer Pro Wireless LAN +product BAY STACK_660 0x0807 BayStack 660 Wireless LAN +product BAY EMOBILITY_11B 0x080a e-Mobility 11Mb Wireless LAN + +/* Bondwell */ +product BONDWELL B236 0x0000 Game Card Joystick + +/* BreezeCOM */ +product BREEZECOM BREEZENET 0x0102 BreezeCOM BreezeNET + +/* Bromax Communications, Inc (Linksys OEM) */ +product BROMAX IWN 0x1612 Instant Wireless Network PC Card +product BROMAX IWN3 0x1613 Instant Wireless Network PC Card, Versin 3 +product BROMAX WCF11 0x3301 Instant Wireless Network CF Card + +/* BUFFALO */ +product BUFFALO LPC3_CLX 0x0301 BUFFALO LPC3-CLX Ethernet Adapter +product BUFFALO WLI_PCM_S11 0x0305 BUFFALO AirStation 11Mbps WLAN +product BUFFALO LPC_CF_CLT 0x0307 BUFFALO LPC-CF-CLT +product BUFFALO LPC3_CLT 0x030a BUFFALO LPC3-CLT Ethernet Adapter +product BUFFALO WLI_CF_S11G 0x030b BUFFALO AirStation 11Mbps CF WLAN + +/* Compaq Products */ +product COMPAQ NC5004 0x0002 Compaq Agency NC5004 Wireless Card +product COMPAQ2 CPQ_10_100 0x010a Compaq Netelligent 10/100 Ethernet + +/* Compex Products */ +product COMPEX AMP_WIRELESS 0x0066 AMP +product COMPEX LINKPORT_ENET_B 0x0100 Compex Linkport ENET-B Ethernet + +/* Contec C-NET(PC) */ +product CONTEC CNETPC 0x0000 Contec C-NET(PC)C +product CONTEC FX_DS110_PCC 0x0008 Contec FLEXLAN/FX-DS110-PCC + +/* Dayna Products */ +product DAYNA COMMUNICARD_E_1 0x002d Dayna CommuniCard E +product DAYNA COMMUNICARD_E_2 0x002f Dayna CommuniCard E + +/* DIGITAL Products */ +product DIGITAL MOBILE_MEDIA_CDROM 0x0d00 Digital Mobile Media CD-ROM + +/* D-Link Products */ +product DLINK_2 DMF560TX 0xc0ab D-Link DMF-650TX + +/* DSP Solutions, Inc. (Megahertz OEM) */ +product DSPSI XJEM1144 0x0101 Megahertz X-JACK +product DSPSI XJACK 0x0103 Megahertz X-JACK Ethernet + +/* Dual */ +product DUAL NE2000 0x0100 Dual NE2000 + +/* Edimax Products */ +product EDIMAX EP4000A 0x0100 Edimax EP4000A + +/* ELSA Products */ +product ELSA MC2_IEEE 0x0001 AirLancer MC-2 IEEE +product ELSA XI300_IEEE 0x0002 XI300 Wireless LAN +product ELSA XI800_IEEE 0x0004 XI800 CF Wireless LAN +product ELSA XI325_IEEE 0x0005 XI325 Wireless LAN + +/* EMTAC */ +product EMTAC WLAN 0x0002 EMTAC A2424i 11Mbps WLAN Card + +/* Ericsson */ +product ERICSSON WIRELESSLAN 0x0001 DSSS Wireless LAN PC Card + +/* Farallon */ +product FARALLON SKYLINE 0x0a01 SkyLINE Wireless + +/* Fujutsu Products */ +product FUJITSU SCSI600 0x0401 Fujitsu SCSI 600 Interface +product FUJITSU LA10S 0x1003 Fujitsu Compact Flash Ethernet +product FUJITSU LA501 0x2000 Fujitsu Towa LA501 Ethernet +product FUJITSU WL110 0x2003 PEGA-WL110 Wireless LAN + +/* Gemplus */ +product GEMPLUS GPR400 0x3004 GPR400 Smartcard Reader + +/* Home Wireless Networks */ +product HWN AIRWAY80211 0x0002 HWN Airway Wireless PCMCIA Card + +/* IBM Products */ +product IBM MICRODRIVE 0x0000 IBM Microdrive +product IBM 3270 0x0001 IBM 3270 Emulation +product IBM INFOMOVER 0x0002 IBM InfoMover +product IBM 5250 0x000b IBM 5250 Emulation +product IBM TROPIC 0x001e IBM Token Ring 4/16 +product IBM SCSI 0x0026 IBM SCSI PCMCIA +product IBM PORTABLE_CDROM 0x002d IBM PCMCIA Portable CD-ROM Drive +product IBM HOME_AND_AWAY 0x002e IBM Home and Away Modem +product IBM WIRELESS_LAN_ENTRY 0x0032 IBM Wireless LAN Entry +product IBM SMART_CAPTURE_II 0x003c IBM Smart Capture Card II +product IBM ETHERJET 0x003f IBM EtherJet Ethernet + +/* Intel Products */ +product INTEL PRO_WLAN_2011 0x0001 Intel PRO/Wireless 2011 LAN PC Card +product INTEL EEPRO100 0x010a Intel EtherExpress PRO/100 +product INTEL ETHEREXPPRO 0x0301 Intel EtherExpress Pro PCMCIA Card + +/* Intersil */ +/* Note: The following likely is an OEM card under a different Intersil name */ +product INTERSIL MA401RA 0x7300 Netgear MA401RA + +/* I-O DATA */ +product IODATA PCLATE 0x2216 I-O DATA PCLA/TE +product IODATA2 WNB11PCM 0x0002 I-O DATA WN-B11/PCM +product IODATA2 WCF12 0x0673 Wireless CF Card + +/* Kingston Products */ +product KINGSTON KNE2 0x0100 Kingston KNE-PC2 Ethernet + +/* Lasat Products */ +product LASAT CREDIT_288 0x2811 Lasat Credit 288 Modem + +/* Lexar Media */ +product LEXARMEDIA COMPACTFLASH 0x0100 Lexar Media CompactFlash + +/* Linksys corporation */ +product LINKSYS TRUST_COMBO_ECARD 0x021b Trust (Linksys) Combo EthernetCard +product LINKSYS ETHERFAST 0x0230 Linksys Etherfast 10/100 Ethernet +product LINKSYS ECARD_1 0x0265 Linksys EthernetCard or D-Link DE-650 +product LINKSYS COMBO_ECARD 0xc1ab Linksys Combo EthernetCard + +/* Lucent WaveLAN/IEEE */ +product LUCENT WAVELAN_IEEE 0x0002 WaveLAN/IEEE + +/* MACNICA */ +product MACNICA ME1_JEIDA 0x3300 MACNICA ME1 for JEIDA +product MACNICA MPS110 0xa041 MACNICA Miracle SCSI-II mPS110 + +/* Megahertz Products */ +product MEGAHERTZ XJEM3336 0x0006 Megahertz X-JACK Ethernet Modem +product MEGAHERTZ XJ4288 0x0023 Megahertz XJ4288 Modem +product MEGAHERTZ XJ4336 0x0027 Megahertz XJ4336 Modem +product MEGAHERTZ XJ5560 0x0034 Megahertz X-JACK 56kbps Modem + +/* Melco Products */ +product MELCO LPC3_TX 0xc1ab Melco LPC3-TX +product MELCO LPC3_CLX 0x0301 Melco LPC3-CLX Ethernet Adapter + +/* Microsoft Products */ +product MICROSOFT MN_520 0x0001 Microsoft MN-520 WLAN Card + +/* Motorola Products */ +product MOTOROLA POWER144 0x0105 Motorola Power 14.4 Modem +product MOTOROLA PM100C 0x0302 Motorola Personal Messenger 100C CDPD Modem +product MOTOROLA MONTANA_336 0x0505 Motorola Montana 33.6 + +/* New Media Products */ +product NEWMEDIA BASICS 0x0019 New Media BASICS Ethernet +product NEWMEDIA LANSURFER 0x0021 NewMedia LANSurfer +product NEWMEDIA LIVEWIRE 0x1004 NewMedia LiveWire Ethernet LAN Adapter +product NEWMEDIA MULTIMEDIA 0x100b NewMedia Multimedia +product NEWMEDIA BUSTOASTER2 0xa002 New Media SCSI Bus Toaster +product NEWMEDIA BUSTOASTER 0xc102 New Media SCSI Bus Toaster +product NEWMEDIA BUSTOASTER3 0xd302 New Media SCSI Bus Toaster +product NEWMEDIA WAVJAMMER 0xe005 NewMedia .WAVjammer +product NEWMEDIA2 BUSTOASTER 0x0001 NewMedia BusToaster + +/* Netgear */ +product NETGEAR FA410TX 0x0230 Netgear FA410TX +product NETGEAR FA410TXC 0x4530 Netgear FA410TXC +product NETGEAR FA411 0x0411 Netgear FA411 + +/* National Instruments */ +product NI PCMCIA_GPIB 0x4882 National Instruments PCMCIA-GPIB + +/* Nokia Products */ +product NOKIA C110_WLAN 0x1110 Nokia C110/C111 +product NOKIA C020_WLAN 0x20c0 Nokia C020 WLAN Card + +/* No Wires Needed */ +product NWN WLAN_550 0x0002 NWN 550 WLAN +product NWN WLAN_1148 0x0003 NWN 1148 WLAN + +/* Olicom Products */ +product OLICOM TR 0x2132 GoCard Token Ring 16/4 +product OLICOM OC2220 0x2022 GoCard Ethernet +product OLICOM OC2231 0x3122 GoCard Combo Eth/Modem 288 +product OLICOM OC2232 0x3222 GoCard Combo Eth/Modem 336 + +/* Ositech Products */ +product OSITECH TRUMPCARD_SOD 0x0008 Ositech Seven of Diamonds Ethernet Card + +/* Panasonic Products */ +product PANASONIC KXLC002 0x0304 Panasonic 4X CD-ROM Interface Card +product PANASONIC KXLC003 0x0504 Panasonic 8X CD-ROM Interface Card +product PANASONIC KXLC004 0x0604 Panasonic KXL-810AN Interface Card +product PANASONIC KXLC005 0x2704 Panasonic 16X CD-ROM Interface Card +product PANASONIC KME 0x2604 Panasonic CD-R/RW Interface + +/* Planex */ +product PLANEX_2 GWNS11H 0xb001 Planex GW-NS11H + +/* Proxim */ +product PROXIM HARMONY 0x0002 Proxim HARMONY 80211B +product PROXIM ROAMABOUT_2400FH 0x1058 Digital RoamAbout 2400FH +product PROXIM RANGELAN2_7401 0x1158 Proxim RangeLAN2 7401 +product PROXIM RANGELANDS_8430 0x8000 Proxim RangeLAN-DS 8430 + +/* Psion */ +product PSION GOLDCARD 0x0020 Psion Gold Card + +/* QLogic */ +product QLOGIC PC05 0x0104 Qlogic Fast SCSI + +/* Quatech */ +product QUATECH SPP_100 0x0003 Quatech Enhanced Parallel Port +product QUATECH DSP_225 0x0008 Quatech Dual Serial Port + +/* RATOC System Inc. Products */ +/* Don't use because both cards have same product id */ +product RATOC REX_R280_9530 0x0001 RATOC REX-R280/REX-9530 + +/* Raylink/WebGear */ +product RAYTHEON WLAN 0x0000 WLAN Adapter + +/* Roland */ +product ROLAND SCP55 0x0001 Roland SCP-55 + +/* Samsung */ +product SAMSUNG SWL_2000N 0x0002 Samsung MagicLAN SWL-2000N + +/* Sandisk Products */ +product SANDISK SDCFB 0x0401 Sandisk CompactFlash Card + +/* Sharp Products */ +product SHARP PALDIO611S 0x0000 PALDIO 611S PC CARD + +/* Siemens */ +product SIEMENS SS1021 0x0002 Siemens SpeedStream 1021 + +/* Simple Technology Products */ +product SIMPLETECH COMMUNICATOR288 0x0100 Simple Technology 28.8 Communicator +/* Simpletech ID also used by Symbol */ +product SIMPLETECH SPECTRUM24 0x801 Symbol Spectrum24 WLAN Adapter + +/* Standard Microsystems Corporation Products */ +product SMC 8016 0x0105 SMC 8016 EtherCard +product SMC EZCARD 0x8022 SMC EZCard 10 PCMCIA + +/* Socket Communications Products */ +product SOCKET EA_ETHER 0x0000 Socket Communications EA +product SOCKET LP_WLAN_CF 0x0001 Socket Communications Low Power WLAN Card +product SOCKET PAGECARD 0x0003 Socket Communications PageCard +product SOCKET DUAL_RS232 0x0006 Socket Communications Dual RS232 +product SOCKET LP_ETHER 0x000d Socket Communications LP-E +product SOCKET LP_ETHER_CF 0x0075 Socket Communications LP-E CF +product SOCKET LP_ETH_10_100_CF 0x0145 Socket Communications 10/100 Ethernet + +/* Symbol */ +product SYMBOL LA4100 0x0001 Symbol Spectrum24 LA4100 Series WLAN + +/* TDK Products */ +product TDK LAK_CD011WL 0x0000 TDK LAK-CD011WL +product TDK LAK_CD021BX 0x0200 TDK LAK-CD021BX Ethernet +product TDK LAK_CF010 0x0900 TDK LAC-CF010 +product TDK DFL9610 0x0d0a TDK DFL9610 Ethernet & Digital Cellular +product TDK C6500012 0x410a TDK ELSA MicroLink MC all + +/* Telecom Device */ +product TELECOMDEVICE TCD_HPC100 0x0202 Telecom Device TCD-HPC100 + +/* US Robotics Products */ +product USROBOTICS WORLDPORT144 0x3330 US Robotics WorldPort 14.4 Modem + +/* WORKBIT Products */ +product WORKBIT ULTRA_NINJA_16 0x8006 WORKBIT Ultra Ninja-16 (16bit mode) + +/* Xircom Products */ +product XIRCOM CWE1130 0x0007 Xircom Wireless Ethernet Adapter +product XIRCOM CE 0x0108 Xircom CreditCard Ethernet +product XIRCOM CE3 0x010a Xircom CreditCard 10/100 Ethernet +product XIRCOM CE2 0x010b Xircom CreditCard Ethernet II +product XIRCOM XE2000 0x0153 Xircom XE2000 10/100 Ethernet +product XIRCOM CNW_801 0x0801 Xircom CreditCard Netwave (Canada) +product XIRCOM CNW_802 0x0802 Xircom CreditCard Netwave (US) +product XIRCOM CT2 0x1101 Xircom CreditCard Token Ring II +product XIRCOM CEM 0x110a Xircom CreditCard Ethernet + Modem +product XIRCOM REM56 0x110a Xircom RealPort Ethernet 10/100 + Modem 56 +product XIRCOM CEM28 0x110b Xircom CreditCard Ethernet + Modem 28 +product XIRCOM CEM56 0x110b Xircom CreditCard Ethernet + Modem 56 +product XIRCOM CEM33 0x110d Xircom CreditCard Ethernet + Modem 33 + +/* ZONET */ +product ZONET ZEN 0x0100 Zonet Zen 10/10 + +/* + * Cards we know only by their cis, sorted by name. + */ +vendor AMBICOM -1 AmbiCom Inc +vendor ACCTON -1 ACCTON +vendor ADDTRON -1 Addtron +vendor ARGOSY -1 ARGOSY +vendor AMD -1 AMD +vendor BILLIONTON -1 Billionton Systems Inc. +vendor CNET -1 CNet +vendor COREGA -1 Corega K.K. +vendor DIGITAL -1 Digital Equipment Corporation +vendor DLINK -1 D-Link +vendor DYNALINK -1 DynaLink +vendor EIGERLABS -1 Eiger labs,Inc. +vendor EPSON -1 Seiko Epson Corporation +vendor EXP -1 EXP Computer Inc +vendor FUJITSU2 -1 Fujitsu +vendor FUTUREDOMAIN -1 FutureDomain +vendor FREECOM -1 Freecom +vendor GEMTEK -1 Gem Tek +vendor ICOM -1 ICOM Inc +vendor INTERSIL2 -1 Intersil +vendor IODATA3 -1 I-O DATA +vendor LANTECH -1 Lantech Computer Company +vendor MELCO2 -1 Melco Corporation +vendor NAKAGAWAMETAL -1 NAKAGAWA METAL +vendor NDC -1 NDC +vendor NEC -1 NEC +vendor OEM2 -1 Generic OEM +vendor PLANET -1 Planet +vendor PLANEX -1 Planex Communications Inc +vendor PREMAX -1 Premax +vendor RPTI -1 RPTI +vendor SVEC -1 SVEC/Hawking Technology +vendor SYNERGY21 -1 Synergy 21 +vendor TEAC -1 TEAC +vendor TOSHIBA -1 TOSHIBA +vendor WORKBIT2 -1 WORKBIT +vendor YEDATA -1 Y-E DATA +vendor YIS -1 YIS Corporation +vendor ZOOM -1 ZOOM + +product ACCTON EN2212 { "ACCTON", "EN2212", NULL, NULL } Accton EN2212 +product ACCTON EN2216 { "ACCTON", "EN2216-PCMCIA-ETHERNET", "EN2216R01", NULL } Accton EN2216 +product ACCTON EN2226 { "Accton", "Fast&spEtherCard-16", "EN2226", "1.00" } Accton EN2226 +product ADDTRON AWP100 { "Addtron", "AWP-100&spWireless&spPCMCIA", "Version&sp01.02", NULL } +product ALLIEDTELESIS WR211PCM { "Allied&spTelesis&spK.K.", "WR211PCM", NULL, NULL } Allied Telesis WR211PCM +product AMBICOM AMB8002T { "AmbiCom&spInc", "AMB8002T", NULL, NULL } AmbiCom AMB8002T +product AMD AM79C930 { "AMD", "Am79C930", NULL, NULL } AMD Am79C930 +product ARGOSY SP320 { "PCMCIA", "RS-COM 2P", NULL, NULL } ARGOSY SP320 Dual port serial PCMCIA +product BILLIONTON CFLT10N { "CF", "10Base-Ethernet", "1.0", NULL } Billionton Systems Inc. CFLT10N Ethernet +product BILLIONTON LNT10TN { "PCMCIA", "LNT-10TN", NULL, NULL } Billionton Systems Inc. LNT-10TN NE2000 Compatible Card +product CNET NE2000 { "CNet", "CN40BC&spEthernet", "D", "NE2000" } CNet CN40BC NE2000 Compatible +product COREGA ETHER_PCC_T { "corega&spK.K.", "corega&spEther&spPCC-T", NULL, NULL } Corega Ether PCC-T +product COREGA ETHER_PCC_TD { "corega&spK.K.", "corega&spEther&spPCC-TD", NULL, NULL } Corega Ether PCC-TD +product COREGA ETHER_II_PCC_T { "corega&spK.K.", "corega&spEtherII&spPCC-T", NULL, NULL } Corega EtherII PCC-T +product COREGA ETHER_II_PCC_TD { "corega&spK.K.", "corega&spEtherII&spPCC-TD", NULL, NULL } Corega EtherII PCC-TD +product COREGA FAST_ETHER_PCC_TX { "corega&spK.K.", "corega&spFastEther&spPCC-TX", NULL, NULL } Corega FastEther PCC-TX +product COREGA FETHER_PCC_TXD { "corega&spK.K.", "corega&spFEther&spPCC-TXD", NULL, NULL } Corega FEther PCC-TXD +product COREGA FETHER_PCC_TXF { "corega", "FEther&spPCC-TXF", NULL, NULL } Corega FEther PCC-TXF +product COREGA WIRELESS_LAN_PCC_11 { "corega&spK.K.", "Wireless&spLAN&spPCC-11", NULL, NULL } Corega Wireless LAN PCC-11 +product COREGA WIRELESS_LAN_PCCA_11 { "corega&spK.K.", "Wireless&spLAN&spPCCA-11", NULL, NULL } Corega Wireless LAN PCCA-11 +product COREGA WIRELESS_LAN_PCCB_11 { "corega_K.K.", "Wireless_LAN_PCCB-11", NULL, NULL } Corega Wireless LAN PCCB-11 +product COREGA WIRELESS_LAN_PCCL_11 { "corega", "WL&spPCCL-11", NULL, NULL } Corega Wireless LAN PCCL-11 + +product DIGITAL DEPCMXX { "DIGITAL", "DEPCM-XX", NULL, NULL } DEC DEPCM-BA +product DLINK DE650 { "D-Link", "DE-650", NULL, NULL } D-Link DE-650 +product DLINK DE660 { "D-Link", "DE-660", NULL, NULL } D-Link DE-660 +product DLINK DE660PLUS { "D-Link", "DE-660+", NULL, NULL } D-Link DE-660+ +product DLINK DFE670TXD { "D-Link", "DFE-670TXD", NULL, NULL } D-Link DFE-670TXD +product DLINK DWL650H { "D-Link&spCorporation", "D-Link&spDWL-650H&sp11Mbps&spWLAN&spAdapter", NULL, NULL } D-Link DWL-650H +product DYNALINK L10C { "DYNALINK", "L10C", NULL, NULL } Dynalink L10C +/* + * vendor ID of EPX_AA2000 is Fujitsu (0x0004) and product ID is 0x2000, but + * it conflicts with Fujitsu Towa LA501 Ethernet. + */ +product EIGERLABS EPX_AA2000 { "Eiger&splabs,Inc.", "EPX-AA2000&spPC&spSound&spCard", NULL, NULL } EPX-AA2000 PC Sound Card +product EPSON EEN10B { "Seiko&spEpson&spCorp.", "Ethernet", "P/N:&spEEN10B&spRev.&sp00", NULL } Epson EEN10B +product EPSON SC200 { "EPSON", "SCSI-2&spPC&spCard&spSC200", NULL, NULL } Media Intelligent SCSI-2 PC Card MSC-200 +product EXP EXPMULTIMEDIA { "EXP&sp&sp&sp", "PnPIDE", "F1", NULL } EXP IDE/ATAPI DVD Card +product EXP THINLANCOMBO { "PCMCIA&spLAN", "Ethernet", NULL, NULL } EXP ThinLan Combo +product FREECOM PCCARDIDE { "FREECOM", "PCCARD-IDE", NULL, NULL } FREECOM PCCARD-IDE +product FUJITSU2 FMV_J181 { "PCMCIA&spMBH10302", "01", NULL, NULL } FUJITSU FMV-J181 PCMCIA Card +product FUJITSU2 FMV_J182 { "FUJITSU", "LAN&spCard(FMV-J182)", "Ver.01", NULL } FUJITSU FMV-J182 PCMCIA Card +product FUJITSU2 FMV_J182A { "FUJITSU", "LAN&spCard(FMV-J182)", "Ver.02", NULL } FUJITSU FMV-J182A PCMCIA Card +product FUJITSU2 ITCFJ182A { "FUJITSU", "LAN&spCard(ITCFJ182)", "Ver.01", NULL } FUJITSU ITCFJ182A CompactCard +product FUTUREDOMAIN SCSI2GO { "Future&spDomain&spCorporation" "SCSI&spPCMCIA&spCredit&spCard&spController", NULL, NULL } Future Domain SCSI2GO +product GEMTEK WLAN { "Intersil", "PRISM&sp2_5&spPCMCIA&spADAPTER", "ISL37300P", "Eval-RevA" } GEMTEK Prism2_5 WaveLAN Card +product IBM SCSICARD { "IBM&spCorp.", "SCSI&spPCMCIA&spCard", NULL, NULL } IBM SCSI PCMCIA Card +product ICOM SL200 { "Icom", "SL-200", NULL, NULL } Icom SL-200 +product INTERSIL2 PRISM2 { "INTERSIL", "HFA384x/IEEE", "Version&sp01.02", NULL } Intersil Prism II +product IODATA CBIDE2 { "IO&spDATA", "CBIDE2&sp&sp&sp&sp&sp&sp", NULL, NULL } IO-DATA CBIDE2/16-bit mode +product IODATA3 CBSC16 { "IO&spDATA", "CBSC16&sp&sp&sp&sp&sp&sp&sp", NULL, NULL } IO-DATA CBSC16 +product IODATA PCLAT { "I-O&spDATA", "PCLA", "ETHERNET", NULL } IO-DATA PCLA/T +product LANTECH FASTNETTX { "ASIX", "AX88190", NULL, NULL } Lantech Fastnet/TX +product LINKSYS ECARD_2 { "LINKSYS", "E-CARD", NULL, NULL } Linksys E-Card +product LINKSYS PCM100 { "Linksys", "EtherFast&sp10/100&spIntegrated&spPC&spCard&sp(PCM100)", "Ver&sp1.0", NULL } +product MACNICA MPS100 { "MACNICA", "MIRACLE&spSCSI", "mPS100", "D.0" } Macnica Miracle SCSI mPS100 +product MEGAHERTZ XJ2288 { "MEGAHERTZ", "MODEM&spXJ2288", NULL, NULL } Megahertz XJ2288 Modem +product MELCO2 LPC2_TX { "MELCO", "LPC2-TX", NULL, NULL } Melco LPC2-TX +product NAKAGAWAMETAL LNT10TN { "PCMCIA", "LNT-10TN", NULL, NULL } NAKAGAWA METAL LNT-10TN NE2000 Compatible Card +product NANOSPEED PRISM2 { "NANOSPEED", "HFA384x/IEEE", "Version&sp01.02", NULL } NANOSPEED ROOT-RZ2000 WLAN Card +product NDC ND5100_E { "NDC", "Ethernet", "A", NULL } Sohoware ND5100E NE2000 Compatible Card +product NEC CMZ_RT_WP { "NEC", "Wireless&spCard&spCMZ-RT-WP", "Version&sp01.01", NULL } NEC Wireless Card CMZ-RT-WP +product NEC PC9801N_J03R { "NEC", "PC-9801N-J03R", NULL, NULL } NEC PC-9801N-J03R +product NEWMEDIA BASICS_SCSI { "BASICS&spby&spNew&spMedia&spCorporation" "SCSI&spSym53C500", NULL, NULL } New Media Corporation BASICS SCSI +product NTT_ME WLAN { "NTT-ME", "11Mbps&spWireless&spLAN&spPC&spCard", NULL, NULL } NTT-ME 11Mbps Wireless LAN PC Card +product OEM2 CDROM1 { "PCMCIA", "CD-ROM", NULL, NULL } Generic PCMCIA CD-ROM +product OEM2 IDE { "PCMCIA", "IDE&spCARD", NULL, NULL } Generic PCMCIA IDE CARD +product PLANET SMARTCOM2000 { "PCMCIA", "UE2212", NULL, NULL } Planet SmartCOM 2000 +/* + * vendor ID of both FNW-3600-T and FNW-3700-T is LINKSYS (0x0149) and + * product ID is 0xc1ab, but it conflicts with LINKSYS Combo EthernetCard. + */ +product PLANEX FNW3600T -1 Planex FNW-3600-T +product PLANEX FNW3700T -1 Planex FNW-3700-T +product RPTI EP400 { "RPTI&spLTD.", "EP400", "CISV100", NULL } RPTI EP400 +product RPTI EP401 { "RPTI", "EP401&spEthernet&spNE2000&spCompatible", NULL, NULL } RPTI EP401 +product PREMAX PE200 { "PMX&sp&sp&sp", "PE-200", NULL, NULL } PreMax PE-200 +product RATOC REX_R280 { "RATOC&spSystem&spInc.", "10BASE_T&spCARD&spR280", NULL, NULL } RATOC REX-R280 +product RATOC REX5536 { "1195&spRATOC&spSystem&spInc.", "REX5536&spSCSI2&spCARD", NULL, NULL } RATOC REX-5536 +product RATOC REX5536AM { "PCMCIA&spSCSI&spMBH10404", "01", NULL, NULL } RATOC REX-5536AM +product RATOC REX5536M { "PCMCIA&spSCSI2&spCARD", "01", NULL, NULL } RATOC REX-5536M +product RATOC REX5572 { "RATOC&spSystem&spInc.", "SOUND/SCSI2&spCARD", NULL, NULL } RATOC REX-5572 +product RATOC REX9530 { "RATOC&spSystem&spInc.", "SCSI2&spCARD&sp37", NULL, NULL } RATOC REX-9530 +product SIMPLETECH SPECTRUM24_ALT { "Symbol&spTechnologies", "LA4111&spSpectrum24&spWireless&spLAN&spPC&spCard", NULL, NULL } LA4111 Spectrum24 Wireless LAN PC Card +product SMC 2632W { "SMC", "SMC2632W", "Version&sp01.02", NULL } SMC 2632 EZ Connect Wireless PC Card +product SMC 8041 { "SMC", "8041TX-10/100-PC-Card-V2", NULL, NULL } SMC 8041TX 10/100 PC Card +product SVEC COMBOCARD { "Ethernet", "Adapter", NULL, NULL } SVEC/Hawking Tech. Combo Card +product SVEC LANCARD { "SVEC", "FD605&spPCMCIA&spEtherNet&spCard", "V1-1", NULL } SVEC PCMCIA Lan Card +product SYNERGY21 S21810 { "PCMCIA", "Ethernet", "A", "004743118001" } Synergy 21 S21810+ NE2000 Compatible Card +product TEAC IDECARDII { NULL, "NinjaATA-", NULL, NULL } TEAC IDE Card/II +product TOSHIBA CBIDE2 { "LOOKMEET", "CBIDE2&sp&sp&sp&sp&sp&sp", NULL, NULL } TOSHIBA PA2673U CBIDE2/16-bit mode (IO-DATA OEM) +product WORKBIT2 NINJA_SCSI3 { "WBT", "NinjaSCSI-3", NULL, NULL } WORKBIT Ninja SCSI series +product XIRCOM CFE_10 { "Xircom", "CompactCard&spEthernet", "CFE-10", "1.00" } Xircom CompactCard CFE-10 +product YEDATA EXTERNAL_FDD { "Y-E&spDATA", "External&spFDD", NULL, NULL } Y-E DATA External FDD +product YIS YWL11B { "YIS&spCorp.", "YWL-11b", NULL, NULL } YIS Corp. YWL-11b +product ZOOM AIR_4000 { "Zoom", "Air-4000", NULL, NULL } Zoom Air-4000 diff --git a/sys/bus/pccard/pccarddevs.h b/sys/bus/pccard/pccarddevs.h new file mode 100644 index 0000000000..5fd34e2f57 --- /dev/null +++ b/sys/bus/pccard/pccarddevs.h @@ -0,0 +1,1148 @@ +/* $DragonFly: src/sys/bus/pccard/pccarddevs.h,v 1.1 2004/02/10 07:55:45 joerg Exp $ */ + +/* + * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. + * + * generated from: + * FreeBSD: src/sys/dev/pccard/pccarddevs,v 1.79 2003/11/03 16:09:17 imp Exp + */ +/* $NetBSD: pcmciadevs,v 1.186 2003/09/16 08:26:37 onoe Exp $ */ +/* $OpenBSD: pcmciadevs,v 1.93 2002/06/21 08:31:10 henning Exp $ */ +/* $DragonFly: src/sys/bus/pccard/pccarddevs.h,v 1.1 2004/02/10 07:55:45 joerg Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +/* + * List of known PCMCIA vendors, sorted by numeric ID. + */ + +#define PCMCIA_VENDOR_FUJITSU 0x0004 /* Fujitsu Corporation */ +#define PCMCIA_VENDOR_INTERSIL 0x000b /* Intersil */ +#define PCMCIA_VENDOR_PANASONIC 0x0032 /* Matsushita Electric Industrial Co. */ +#define PCMCIA_VENDOR_SANDISK 0x0045 /* Sandisk Corporation */ +#define PCMCIA_VENDOR_NEWMEDIA 0x0057 /* New Media Corporation */ +#define PCMCIA_VENDOR_INTEL 0x0089 /* Intel */ +#define PCMCIA_VENDOR_IBM 0x00a4 /* IBM Corporation */ +#define PCMCIA_VENDOR_SHARP 0x00b0 /* Sharp Corporation */ +#define PCMCIA_VENDOR_3COM 0x0101 /* 3Com Corporation */ +#define PCMCIA_VENDOR_MEGAHERTZ 0x0102 /* Megahertz Corporation */ +#define PCMCIA_VENDOR_SOCKET 0x0104 /* Socket Communications */ +#define PCMCIA_VENDOR_TDK 0x0105 /* TDK Corporation */ +#define PCMCIA_VENDOR_XIRCOM 0x0105 /* Xircom */ +#define PCMCIA_VENDOR_SMC 0x0108 /* Standard Microsystems Corporation */ +#define PCMCIA_VENDOR_MOTOROLA 0x0109 /* Motorola Corporation */ +#define PCMCIA_VENDOR_NI 0x010b /* National Instruments */ +#define PCMCIA_VENDOR_QLOGIC 0x0114 /* QLogic */ +#define PCMCIA_VENDOR_USROBOTICS 0x0115 /* US Robotics Corporation */ +#define PCMCIA_VENDOR_OLICOM 0x0121 /* Olicom */ +#define PCMCIA_VENDOR_PROXIM 0x0126 /* Proxim */ +#define PCMCIA_VENDOR_DSPSI 0x0128 /* DSP Solutions, Inc */ +#define PCMCIA_VENDOR_ADAPTEC 0x012f /* Adaptec Corporation */ +#define PCMCIA_VENDOR_QUATECH 0x0137 /* Quatech */ +#define PCMCIA_VENDOR_COMPAQ 0x0138 /* Compaq */ +#define PCMCIA_VENDOR_OSITECH 0x0140 /* Ositech */ +#define PCMCIA_VENDOR_DLINK_2 0x0143 /* D-Link */ +#define PCMCIA_VENDOR_DLINK_3 0x0149 /* D-Link */ +#define PCMCIA_VENDOR_LINKSYS 0x0149 /* Linksys Corporation */ +#define PCMCIA_VENDOR_NETGEAR 0x0149 /* Netgear */ +#define PCMCIA_VENDOR_SIMPLETECH 0x014d /* Simple Technology */ +#define PCMCIA_VENDOR_SYMBOL2 0x014d /* Symbol */ +#define PCMCIA_VENDOR_LUCENT 0x0156 /* Lucent Technologies */ +#define PCMCIA_VENDOR_GEMPLUS 0x0157 /* Gemplus */ +#define PCMCIA_VENDOR_AIRONET 0x015f /* Aironet Wireless Communications */ +#define PCMCIA_VENDOR_ERICSSON 0x016b /* Ericsson */ +#define PCMCIA_VENDOR_PSION 0x016c /* Psion */ +#define PCMCIA_VENDOR_COMPAQ2 0x0183 /* Compaq */ +#define PCMCIA_VENDOR_PARALON 0x0183 /* Paralon Technologies Inc */ +#define PCMCIA_VENDOR_KINGSTON 0x0186 /* Kingston */ +#define PCMCIA_VENDOR_MELCO 0x018a /* Melco Corporation */ +#define PCMCIA_VENDOR_DAYNA 0x0194 /* Dayna Corporation */ +#define PCMCIA_VENDOR_RAYTHEON 0x01a6 /* Raytheon */ +#define PCMCIA_VENDOR_IODATA 0x01bf /* I-O DATA */ +#define PCMCIA_VENDOR_BAY 0x01eb /* Bay Networks */ +#define PCMCIA_VENDOR_FARALLON 0x0200 /* Farallon Communications */ +#define PCMCIA_VENDOR_TELECOMDEVICE 0x021b /* Telecom Device */ +#define PCMCIA_VENDOR_NOKIA 0x023d /* Nokia Communications */ +#define PCMCIA_VENDOR_SAMSUNG 0x0250 /* Samsung */ +#define PCMCIA_VENDOR_HWN 0x0261 /* Home Wireless Networks */ +#define PCMCIA_VENDOR_ARTEM 0x0268 /* ARtem */ +#define PCMCIA_VENDOR_SYMBOL 0x026c /* Symbol */ +#define PCMCIA_VENDOR_BUFFALO 0x026f /* BUFFALO (Melco Corporation) */ +#define PCMCIA_VENDOR_BROMAX 0x0274 /* Bromax communications, Inc */ +#define PCMCIA_VENDOR_IODATA2 0x028a /* I-O DATA */ +#define PCMCIA_VENDOR_ASUS 0x02aa /* ASUS */ +#define PCMCIA_VENDOR_SIEMENS 0x02ac /* Siemens */ +#define PCMCIA_VENDOR_MICROSOFT 0x02d2 /* Microsoft Corporation */ + +/* + * The following vendor IDs are byte-swapped from what the company is assigned. + */ +#define PCMCIA_VENDOR_NWN 0x0602 /* No Wires Needed */ +#define PCMCIA_VENDOR_BREEZECOM 0x0a02 /* BreezeCOM */ +#define PCMCIA_VENDOR_LASAT 0x3401 /* Lasat Communications A/S */ +#define PCMCIA_VENDOR_BONDWELL 0x3b01 /* Bondwell */ +#define PCMCIA_VENDOR_LEXARMEDIA 0x4e01 /* Lexar Media */ +#define PCMCIA_VENDOR_COMPEX 0x8a01 /* Compex Corporation */ +#define PCMCIA_VENDOR_ZONET 0x8a01 /* Zonet Technology Inc. */ +#define PCMCIA_VENDOR_ELSA 0xd601 /* Elsa */ + +/* + * The following vendor IDs are not, as far as I can tell, actually + * assigned to these people. However, all the ones starting with '0xc' + * look coherent enough that maybe somebody other than PCMCIA is + * assigning numbers in that range. + */ +#define PCMCIA_VENDOR_NEWMEDIA2 0x10cd /* NewMedia */ +#define PCMCIA_VENDOR_PLANEX_2 0x14ea /* PLANEX */ +#define PCMCIA_VENDOR_ACTIONTEC 0x1668 /* ACTIONTEC */ +#define PCMCIA_VENDOR_AIRVAST 0x50c2 /* AirVast Technology */ +#define PCMCIA_VENDOR_ARCHOS 0x5241 /* Archos */ +#define PCMCIA_VENDOR_DUAL 0x890f /* Dual */ +#define PCMCIA_VENDOR_EDIMAX 0x890f /* Edimax Technology Inc. */ +#define PCMCIA_VENDOR_CONTEC 0xc001 /* Contec */ +#define PCMCIA_VENDOR_MACNICA 0xc00b /* MACNICA */ +#define PCMCIA_VENDOR_ROLAND 0xc00c /* Roland */ +#define PCMCIA_VENDOR_COREGA2 0xc00f /* Corega K.K. */ +#define PCMCIA_VENDOR_ALLIEDTELESIS 0xc00f /* Allied Telesis K.K. */ +#define PCMCIA_VENDOR_HAGIWARASYSCOM 0xc012 /* Hagiwara SYS-COM */ +#define PCMCIA_VENDOR_RATOC 0xc015 /* RATOC System Inc. */ +#define PCMCIA_VENDOR_WORKBIT 0xc024 /* WORKBIT */ +#define PCMCIA_VENDOR_EMTAC 0xc250 /* EMTAC Technology Corporation */ + +/* + * List of known products. Grouped by vendor, sorted by number within the + * group. + */ + +/* 3COM Products */ +#define PCMCIA_CIS_3COM_3CRWE737A { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3CRWE737A 0x0001 +#define PCMCIA_STR_3COM_3CRWE737A "3Com AirConnect Wireless LAN" +#define PCMCIA_CIS_3COM_3CXM056BNW { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3CXM056BNW 0x002f +#define PCMCIA_STR_3COM_3CXM056BNW "3Com/NoteWorthy 3CXM056-BNW 56K Modem" +#define PCMCIA_CIS_3COM_3CXEM556 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3CXEM556 0x0035 +#define PCMCIA_STR_3COM_3CXEM556 "3Com/Megahertz 3CXEM556 Ethernet/Modem" +#define PCMCIA_CIS_3COM_3CXEM556INT { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3CXEM556INT 0x003d +#define PCMCIA_STR_3COM_3CXEM556INT "3Com/Megahertz 3CXEM556-INT Ethernet/Modem" +#define PCMCIA_CIS_3COM_3CCFEM556BI { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3CCFEM556BI 0x0556 +#define PCMCIA_STR_3COM_3CCFEM556BI "3Com/Megahertz 3CCFEM556BI Ethernet/Modem" +#define PCMCIA_CIS_3COM_3C562 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3C562 0x0562 +#define PCMCIA_STR_3COM_3C562 "3Com 3c562 33.6 Modem/10Mbps Ethernet" +#define PCMCIA_CIS_3COM_3C589 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3C589 0x0589 +#define PCMCIA_STR_3COM_3C589 "3Com 3c589 10Mbps Ethernet" +#define PCMCIA_CIS_3COM_3C574 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3C574 0x0574 +#define PCMCIA_STR_3COM_3C574 "3Com 3c574-TX 10/100Mbps Ethernet" +#define PCMCIA_CIS_3COM_3CRWE777A { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3CRWE777A 0x0777 +#define PCMCIA_STR_3COM_3CRWE777A "3Com 3CRWE777A Airconnect" +#define PCMCIA_CIS_3COM_3C1 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3C1 0x0cf1 +#define PCMCIA_STR_3COM_3C1 "3Com Megahertz 3C1 10Mbps LAN CF+ Card" +#define PCMCIA_CIS_3COM_3CRWE62092A { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_3COM_3CRWE62092A 0x2092 +#define PCMCIA_STR_3COM_3CRWE62092A "3Com 3CRWE62092A Wireless LAN" + +/* ACTIONTEC Products */ +#define PCMCIA_CIS_ACTIONTEC_PRISM { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ACTIONTEC_PRISM 0x0101 +#define PCMCIA_STR_ACTIONTEC_PRISM "PRISM Wireless LAN PC Card" + +/* Adaptec Products */ +#define PCMCIA_CIS_ADAPTEC_APA1460 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ADAPTEC_APA1460 0x0001 +#define PCMCIA_STR_ADAPTEC_APA1460 "Adaptec APA-1460 SlimSCSI" +#define PCMCIA_CIS_ADAPTEC_APA1460A { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ADAPTEC_APA1460A 0x0002 +#define PCMCIA_STR_ADAPTEC_APA1460A "Adaptec APA-1460A SlimSCSI" + +/* Aironet */ +#define PCMCIA_CIS_AIRONET_PC4500 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_AIRONET_PC4500 0x0005 +#define PCMCIA_STR_AIRONET_PC4500 "Aironet PC4500 Wireless LAN Adapter" +#define PCMCIA_CIS_AIRONET_PC4800 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_AIRONET_PC4800 0x0007 +#define PCMCIA_STR_AIRONET_PC4800 "Aironet PC4800 Wireless LAN Adapter" +#define PCMCIA_CIS_AIRONET_350 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_AIRONET_350 0x000a +#define PCMCIA_STR_AIRONET_350 "Aironet 350 Wireless LAN Adapter" + +/* AirVast */ +#define PCMCIA_CIS_AIRVAST_WN_100 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_AIRVAST_WN_100 0x7300 +#define PCMCIA_STR_AIRVAST_WN_100 "AirVast WN-100" + +/* Allied Telesis K.K. */ +#define PCMCIA_CIS_ALLIEDTELESIS_LA_PCM { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ALLIEDTELESIS_LA_PCM 0x0002 +#define PCMCIA_STR_ALLIEDTELESIS_LA_PCM "Allied Telesis LA-PCM" + +/* Archos */ +#define PCMCIA_CIS_ARCHOS_ARC_ATAPI { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ARCHOS_ARC_ATAPI 0x0043 +#define PCMCIA_STR_ARCHOS_ARC_ATAPI "MiniCD" + +/* ARtem */ +#define PCMCIA_CIS_ARTEM_ONAIR { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ARTEM_ONAIR 0x0001 +#define PCMCIA_STR_ARTEM_ONAIR "ARtem OnAir" + +/* ASUS WL-100 */ +#define PCMCIA_CIS_ASUS_WL100 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ASUS_WL100 0x0002 +#define PCMCIA_STR_ASUS_WL100 "ASUS SpaceLink WL-100 Wireless LAN" + +/* Bay Networks */ +#define PCMCIA_CIS_BAY_STACK_650 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BAY_STACK_650 0x0804 +#define PCMCIA_STR_BAY_STACK_650 "BayStack 650 Wireless LAN" +#define PCMCIA_CIS_BAY_SURFER_PRO { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BAY_SURFER_PRO 0x0806 +#define PCMCIA_STR_BAY_SURFER_PRO "AirSurfer Pro Wireless LAN" +#define PCMCIA_CIS_BAY_STACK_660 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BAY_STACK_660 0x0807 +#define PCMCIA_STR_BAY_STACK_660 "BayStack 660 Wireless LAN" +#define PCMCIA_CIS_BAY_EMOBILITY_11B { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BAY_EMOBILITY_11B 0x080a +#define PCMCIA_STR_BAY_EMOBILITY_11B "e-Mobility 11Mb Wireless LAN" + +/* Bondwell */ +#define PCMCIA_CIS_BONDWELL_B236 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BONDWELL_B236 0x0000 +#define PCMCIA_STR_BONDWELL_B236 "Game Card Joystick" + +/* BreezeCOM */ +#define PCMCIA_CIS_BREEZECOM_BREEZENET { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BREEZECOM_BREEZENET 0x0102 +#define PCMCIA_STR_BREEZECOM_BREEZENET "BreezeCOM BreezeNET" + +/* Bromax Communications, Inc (Linksys OEM) */ +#define PCMCIA_CIS_BROMAX_IWN { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BROMAX_IWN 0x1612 +#define PCMCIA_STR_BROMAX_IWN "Instant Wireless Network PC Card" +#define PCMCIA_CIS_BROMAX_IWN3 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BROMAX_IWN3 0x1613 +#define PCMCIA_STR_BROMAX_IWN3 "Instant Wireless Network PC Card, Versin 3" +#define PCMCIA_CIS_BROMAX_WCF11 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BROMAX_WCF11 0x3301 +#define PCMCIA_STR_BROMAX_WCF11 "Instant Wireless Network CF Card" + +/* BUFFALO */ +#define PCMCIA_CIS_BUFFALO_LPC3_CLX { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BUFFALO_LPC3_CLX 0x0301 +#define PCMCIA_STR_BUFFALO_LPC3_CLX "BUFFALO LPC3-CLX Ethernet Adapter" +#define PCMCIA_CIS_BUFFALO_WLI_PCM_S11 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BUFFALO_WLI_PCM_S11 0x0305 +#define PCMCIA_STR_BUFFALO_WLI_PCM_S11 "BUFFALO AirStation 11Mbps WLAN" +#define PCMCIA_CIS_BUFFALO_LPC_CF_CLT { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BUFFALO_LPC_CF_CLT 0x0307 +#define PCMCIA_STR_BUFFALO_LPC_CF_CLT "BUFFALO LPC-CF-CLT" +#define PCMCIA_CIS_BUFFALO_LPC3_CLT { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BUFFALO_LPC3_CLT 0x030a +#define PCMCIA_STR_BUFFALO_LPC3_CLT "BUFFALO LPC3-CLT Ethernet Adapter" +#define PCMCIA_CIS_BUFFALO_WLI_CF_S11G { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_BUFFALO_WLI_CF_S11G 0x030b +#define PCMCIA_STR_BUFFALO_WLI_CF_S11G "BUFFALO AirStation 11Mbps CF WLAN" + +/* Compaq Products */ +#define PCMCIA_CIS_COMPAQ_NC5004 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_COMPAQ_NC5004 0x0002 +#define PCMCIA_STR_COMPAQ_NC5004 "Compaq Agency NC5004 Wireless Card" +#define PCMCIA_CIS_COMPAQ2_CPQ_10_100 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_COMPAQ2_CPQ_10_100 0x010a +#define PCMCIA_STR_COMPAQ2_CPQ_10_100 "Compaq Netelligent 10/100 Ethernet" + +/* Compex Products */ +#define PCMCIA_CIS_COMPEX_AMP_WIRELESS { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_COMPEX_AMP_WIRELESS 0x0066 +#define PCMCIA_STR_COMPEX_AMP_WIRELESS "AMP" +#define PCMCIA_CIS_COMPEX_LINKPORT_ENET_B { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_COMPEX_LINKPORT_ENET_B 0x0100 +#define PCMCIA_STR_COMPEX_LINKPORT_ENET_B "Compex Linkport ENET-B Ethernet" + +/* Contec C-NET(PC) */ +#define PCMCIA_CIS_CONTEC_CNETPC { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_CONTEC_CNETPC 0x0000 +#define PCMCIA_STR_CONTEC_CNETPC "Contec C-NET(PC)C" +#define PCMCIA_CIS_CONTEC_FX_DS110_PCC { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_CONTEC_FX_DS110_PCC 0x0008 +#define PCMCIA_STR_CONTEC_FX_DS110_PCC "Contec FLEXLAN/FX-DS110-PCC" + +/* Dayna Products */ +#define PCMCIA_CIS_DAYNA_COMMUNICARD_E_1 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_1 0x002d +#define PCMCIA_STR_DAYNA_COMMUNICARD_E_1 "Dayna CommuniCard E" +#define PCMCIA_CIS_DAYNA_COMMUNICARD_E_2 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_2 0x002f +#define PCMCIA_STR_DAYNA_COMMUNICARD_E_2 "Dayna CommuniCard E" + +/* DIGITAL Products */ +#define PCMCIA_CIS_DIGITAL_MOBILE_MEDIA_CDROM { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_DIGITAL_MOBILE_MEDIA_CDROM 0x0d00 +#define PCMCIA_STR_DIGITAL_MOBILE_MEDIA_CDROM "Digital Mobile Media CD-ROM" + +/* D-Link Products */ +#define PCMCIA_CIS_DLINK_2_DMF560TX { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_DLINK_2_DMF560TX 0xc0ab +#define PCMCIA_STR_DLINK_2_DMF560TX "D-Link DMF-650TX" + +/* DSP Solutions, Inc. (Megahertz OEM) */ +#define PCMCIA_CIS_DSPSI_XJEM1144 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_DSPSI_XJEM1144 0x0101 +#define PCMCIA_STR_DSPSI_XJEM1144 "Megahertz X-JACK" +#define PCMCIA_CIS_DSPSI_XJACK { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_DSPSI_XJACK 0x0103 +#define PCMCIA_STR_DSPSI_XJACK "Megahertz X-JACK Ethernet" + +/* Dual */ +#define PCMCIA_CIS_DUAL_NE2000 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_DUAL_NE2000 0x0100 +#define PCMCIA_STR_DUAL_NE2000 "Dual NE2000" + +/* Edimax Products */ +#define PCMCIA_CIS_EDIMAX_EP4000A { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_EDIMAX_EP4000A 0x0100 +#define PCMCIA_STR_EDIMAX_EP4000A "Edimax EP4000A" + +/* ELSA Products */ +#define PCMCIA_CIS_ELSA_MC2_IEEE { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ELSA_MC2_IEEE 0x0001 +#define PCMCIA_STR_ELSA_MC2_IEEE "AirLancer MC-2 IEEE" +#define PCMCIA_CIS_ELSA_XI300_IEEE { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ELSA_XI300_IEEE 0x0002 +#define PCMCIA_STR_ELSA_XI300_IEEE "XI300 Wireless LAN" +#define PCMCIA_CIS_ELSA_XI800_IEEE { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ELSA_XI800_IEEE 0x0004 +#define PCMCIA_STR_ELSA_XI800_IEEE "XI800 CF Wireless LAN" +#define PCMCIA_CIS_ELSA_XI325_IEEE { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ELSA_XI325_IEEE 0x0005 +#define PCMCIA_STR_ELSA_XI325_IEEE "XI325 Wireless LAN" + +/* EMTAC */ +#define PCMCIA_CIS_EMTAC_WLAN { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_EMTAC_WLAN 0x0002 +#define PCMCIA_STR_EMTAC_WLAN "EMTAC A2424i 11Mbps WLAN Card" + +/* Ericsson */ +#define PCMCIA_CIS_ERICSSON_WIRELESSLAN { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ERICSSON_WIRELESSLAN 0x0001 +#define PCMCIA_STR_ERICSSON_WIRELESSLAN "DSSS Wireless LAN PC Card" + +/* Farallon */ +#define PCMCIA_CIS_FARALLON_SKYLINE { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_FARALLON_SKYLINE 0x0a01 +#define PCMCIA_STR_FARALLON_SKYLINE "SkyLINE Wireless" + +/* Fujutsu Products */ +#define PCMCIA_CIS_FUJITSU_SCSI600 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_FUJITSU_SCSI600 0x0401 +#define PCMCIA_STR_FUJITSU_SCSI600 "Fujitsu SCSI 600 Interface" +#define PCMCIA_CIS_FUJITSU_LA10S { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_FUJITSU_LA10S 0x1003 +#define PCMCIA_STR_FUJITSU_LA10S "Fujitsu Compact Flash Ethernet" +#define PCMCIA_CIS_FUJITSU_LA501 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_FUJITSU_LA501 0x2000 +#define PCMCIA_STR_FUJITSU_LA501 "Fujitsu Towa LA501 Ethernet" +#define PCMCIA_CIS_FUJITSU_WL110 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_FUJITSU_WL110 0x2003 +#define PCMCIA_STR_FUJITSU_WL110 "PEGA-WL110 Wireless LAN" + +/* Gemplus */ +#define PCMCIA_CIS_GEMPLUS_GPR400 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_GEMPLUS_GPR400 0x3004 +#define PCMCIA_STR_GEMPLUS_GPR400 "GPR400 Smartcard Reader" + +/* Home Wireless Networks */ +#define PCMCIA_CIS_HWN_AIRWAY80211 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_HWN_AIRWAY80211 0x0002 +#define PCMCIA_STR_HWN_AIRWAY80211 "HWN Airway Wireless PCMCIA Card" + +/* IBM Products */ +#define PCMCIA_CIS_IBM_MICRODRIVE { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_MICRODRIVE 0x0000 +#define PCMCIA_STR_IBM_MICRODRIVE "IBM Microdrive" +#define PCMCIA_CIS_IBM_3270 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_3270 0x0001 +#define PCMCIA_STR_IBM_3270 "IBM 3270 Emulation" +#define PCMCIA_CIS_IBM_INFOMOVER { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_INFOMOVER 0x0002 +#define PCMCIA_STR_IBM_INFOMOVER "IBM InfoMover" +#define PCMCIA_CIS_IBM_5250 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_5250 0x000b +#define PCMCIA_STR_IBM_5250 "IBM 5250 Emulation" +#define PCMCIA_CIS_IBM_TROPIC { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_TROPIC 0x001e +#define PCMCIA_STR_IBM_TROPIC "IBM Token Ring 4/16" +#define PCMCIA_CIS_IBM_SCSI { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_SCSI 0x0026 +#define PCMCIA_STR_IBM_SCSI "IBM SCSI PCMCIA" +#define PCMCIA_CIS_IBM_PORTABLE_CDROM { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_PORTABLE_CDROM 0x002d +#define PCMCIA_STR_IBM_PORTABLE_CDROM "IBM PCMCIA Portable CD-ROM Drive" +#define PCMCIA_CIS_IBM_HOME_AND_AWAY { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_HOME_AND_AWAY 0x002e +#define PCMCIA_STR_IBM_HOME_AND_AWAY "IBM Home and Away Modem" +#define PCMCIA_CIS_IBM_WIRELESS_LAN_ENTRY { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_WIRELESS_LAN_ENTRY 0x0032 +#define PCMCIA_STR_IBM_WIRELESS_LAN_ENTRY "IBM Wireless LAN Entry" +#define PCMCIA_CIS_IBM_SMART_CAPTURE_II { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_SMART_CAPTURE_II 0x003c +#define PCMCIA_STR_IBM_SMART_CAPTURE_II "IBM Smart Capture Card II" +#define PCMCIA_CIS_IBM_ETHERJET { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IBM_ETHERJET 0x003f +#define PCMCIA_STR_IBM_ETHERJET "IBM EtherJet Ethernet" + +/* Intel Products */ +#define PCMCIA_CIS_INTEL_PRO_WLAN_2011 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_INTEL_PRO_WLAN_2011 0x0001 +#define PCMCIA_STR_INTEL_PRO_WLAN_2011 "Intel PRO/Wireless 2011 LAN PC Card" +#define PCMCIA_CIS_INTEL_EEPRO100 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_INTEL_EEPRO100 0x010a +#define PCMCIA_STR_INTEL_EEPRO100 "Intel EtherExpress PRO/100" +#define PCMCIA_CIS_INTEL_ETHEREXPPRO { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_INTEL_ETHEREXPPRO 0x0301 +#define PCMCIA_STR_INTEL_ETHEREXPPRO "Intel EtherExpress Pro PCMCIA Card" + +/* Intersil */ +/* Note: The following likely is an OEM card under a different Intersil name */ +#define PCMCIA_CIS_INTERSIL_MA401RA { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_INTERSIL_MA401RA 0x7300 +#define PCMCIA_STR_INTERSIL_MA401RA "Netgear MA401RA" + +/* I-O DATA */ +#define PCMCIA_CIS_IODATA_PCLATE { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IODATA_PCLATE 0x2216 +#define PCMCIA_STR_IODATA_PCLATE "I-O DATA PCLA/TE" +#define PCMCIA_CIS_IODATA2_WNB11PCM { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IODATA2_WNB11PCM 0x0002 +#define PCMCIA_STR_IODATA2_WNB11PCM "I-O DATA WN-B11/PCM" +#define PCMCIA_CIS_IODATA2_WCF12 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_IODATA2_WCF12 0x0673 +#define PCMCIA_STR_IODATA2_WCF12 "Wireless CF Card" + +/* Kingston Products */ +#define PCMCIA_CIS_KINGSTON_KNE2 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_KINGSTON_KNE2 0x0100 +#define PCMCIA_STR_KINGSTON_KNE2 "Kingston KNE-PC2 Ethernet" + +/* Lasat Products */ +#define PCMCIA_CIS_LASAT_CREDIT_288 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_LASAT_CREDIT_288 0x2811 +#define PCMCIA_STR_LASAT_CREDIT_288 "Lasat Credit 288 Modem" + +/* Lexar Media */ +#define PCMCIA_CIS_LEXARMEDIA_COMPACTFLASH { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_LEXARMEDIA_COMPACTFLASH 0x0100 +#define PCMCIA_STR_LEXARMEDIA_COMPACTFLASH "Lexar Media CompactFlash" + +/* Linksys corporation */ +#define PCMCIA_CIS_LINKSYS_TRUST_COMBO_ECARD { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_LINKSYS_TRUST_COMBO_ECARD 0x021b +#define PCMCIA_STR_LINKSYS_TRUST_COMBO_ECARD "Trust (Linksys) Combo EthernetCard" +#define PCMCIA_CIS_LINKSYS_ETHERFAST { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_LINKSYS_ETHERFAST 0x0230 +#define PCMCIA_STR_LINKSYS_ETHERFAST "Linksys Etherfast 10/100 Ethernet" +#define PCMCIA_CIS_LINKSYS_ECARD_1 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_LINKSYS_ECARD_1 0x0265 +#define PCMCIA_STR_LINKSYS_ECARD_1 "Linksys EthernetCard or D-Link DE-650" +#define PCMCIA_CIS_LINKSYS_COMBO_ECARD { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD 0xc1ab +#define PCMCIA_STR_LINKSYS_COMBO_ECARD "Linksys Combo EthernetCard" + +/* Lucent WaveLAN/IEEE */ +#define PCMCIA_CIS_LUCENT_WAVELAN_IEEE { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_LUCENT_WAVELAN_IEEE 0x0002 +#define PCMCIA_STR_LUCENT_WAVELAN_IEEE "WaveLAN/IEEE" + +/* MACNICA */ +#define PCMCIA_CIS_MACNICA_ME1_JEIDA { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MACNICA_ME1_JEIDA 0x3300 +#define PCMCIA_STR_MACNICA_ME1_JEIDA "MACNICA ME1 for JEIDA" +#define PCMCIA_CIS_MACNICA_MPS110 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MACNICA_MPS110 0xa041 +#define PCMCIA_STR_MACNICA_MPS110 "MACNICA Miracle SCSI-II mPS110" + +/* Megahertz Products */ +#define PCMCIA_CIS_MEGAHERTZ_XJEM3336 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MEGAHERTZ_XJEM3336 0x0006 +#define PCMCIA_STR_MEGAHERTZ_XJEM3336 "Megahertz X-JACK Ethernet Modem" +#define PCMCIA_CIS_MEGAHERTZ_XJ4288 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MEGAHERTZ_XJ4288 0x0023 +#define PCMCIA_STR_MEGAHERTZ_XJ4288 "Megahertz XJ4288 Modem" +#define PCMCIA_CIS_MEGAHERTZ_XJ4336 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MEGAHERTZ_XJ4336 0x0027 +#define PCMCIA_STR_MEGAHERTZ_XJ4336 "Megahertz XJ4336 Modem" +#define PCMCIA_CIS_MEGAHERTZ_XJ5560 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MEGAHERTZ_XJ5560 0x0034 +#define PCMCIA_STR_MEGAHERTZ_XJ5560 "Megahertz X-JACK 56kbps Modem" + +/* Melco Products */ +#define PCMCIA_CIS_MELCO_LPC3_TX { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MELCO_LPC3_TX 0xc1ab +#define PCMCIA_STR_MELCO_LPC3_TX "Melco LPC3-TX" +#define PCMCIA_CIS_MELCO_LPC3_CLX { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MELCO_LPC3_CLX 0x0301 +#define PCMCIA_STR_MELCO_LPC3_CLX "Melco LPC3-CLX Ethernet Adapter" + +/* Microsoft Products */ +#define PCMCIA_CIS_MICROSOFT_MN_520 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MICROSOFT_MN_520 0x0001 +#define PCMCIA_STR_MICROSOFT_MN_520 "Microsoft MN-520 WLAN Card" + +/* Motorola Products */ +#define PCMCIA_CIS_MOTOROLA_POWER144 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MOTOROLA_POWER144 0x0105 +#define PCMCIA_STR_MOTOROLA_POWER144 "Motorola Power 14.4 Modem" +#define PCMCIA_CIS_MOTOROLA_PM100C { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MOTOROLA_PM100C 0x0302 +#define PCMCIA_STR_MOTOROLA_PM100C "Motorola Personal Messenger 100C CDPD Modem" +#define PCMCIA_CIS_MOTOROLA_MONTANA_336 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_MOTOROLA_MONTANA_336 0x0505 +#define PCMCIA_STR_MOTOROLA_MONTANA_336 "Motorola Montana 33.6" + +/* New Media Products */ +#define PCMCIA_CIS_NEWMEDIA_BASICS { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NEWMEDIA_BASICS 0x0019 +#define PCMCIA_STR_NEWMEDIA_BASICS "New Media BASICS Ethernet" +#define PCMCIA_CIS_NEWMEDIA_LANSURFER { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NEWMEDIA_LANSURFER 0x0021 +#define PCMCIA_STR_NEWMEDIA_LANSURFER "NewMedia LANSurfer" +#define PCMCIA_CIS_NEWMEDIA_LIVEWIRE { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NEWMEDIA_LIVEWIRE 0x1004 +#define PCMCIA_STR_NEWMEDIA_LIVEWIRE "NewMedia LiveWire Ethernet LAN Adapter" +#define PCMCIA_CIS_NEWMEDIA_MULTIMEDIA { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NEWMEDIA_MULTIMEDIA 0x100b +#define PCMCIA_STR_NEWMEDIA_MULTIMEDIA "NewMedia Multimedia" +#define PCMCIA_CIS_NEWMEDIA_BUSTOASTER2 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NEWMEDIA_BUSTOASTER2 0xa002 +#define PCMCIA_STR_NEWMEDIA_BUSTOASTER2 "New Media SCSI Bus Toaster" +#define PCMCIA_CIS_NEWMEDIA_BUSTOASTER { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NEWMEDIA_BUSTOASTER 0xc102 +#define PCMCIA_STR_NEWMEDIA_BUSTOASTER "New Media SCSI Bus Toaster" +#define PCMCIA_CIS_NEWMEDIA_BUSTOASTER3 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NEWMEDIA_BUSTOASTER3 0xd302 +#define PCMCIA_STR_NEWMEDIA_BUSTOASTER3 "New Media SCSI Bus Toaster" +#define PCMCIA_CIS_NEWMEDIA_WAVJAMMER { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NEWMEDIA_WAVJAMMER 0xe005 +#define PCMCIA_STR_NEWMEDIA_WAVJAMMER "NewMedia .WAVjammer" +#define PCMCIA_CIS_NEWMEDIA2_BUSTOASTER { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NEWMEDIA2_BUSTOASTER 0x0001 +#define PCMCIA_STR_NEWMEDIA2_BUSTOASTER "NewMedia BusToaster" + +/* Netgear */ +#define PCMCIA_CIS_NETGEAR_FA410TX { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NETGEAR_FA410TX 0x0230 +#define PCMCIA_STR_NETGEAR_FA410TX "Netgear FA410TX" +#define PCMCIA_CIS_NETGEAR_FA410TXC { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NETGEAR_FA410TXC 0x4530 +#define PCMCIA_STR_NETGEAR_FA410TXC "Netgear FA410TXC" +#define PCMCIA_CIS_NETGEAR_FA411 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NETGEAR_FA411 0x0411 +#define PCMCIA_STR_NETGEAR_FA411 "Netgear FA411" + +/* National Instruments */ +#define PCMCIA_CIS_NI_PCMCIA_GPIB { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NI_PCMCIA_GPIB 0x4882 +#define PCMCIA_STR_NI_PCMCIA_GPIB "National Instruments PCMCIA-GPIB" + +/* Nokia Products */ +#define PCMCIA_CIS_NOKIA_C110_WLAN { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NOKIA_C110_WLAN 0x1110 +#define PCMCIA_STR_NOKIA_C110_WLAN "Nokia C110/C111" +#define PCMCIA_CIS_NOKIA_C020_WLAN { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NOKIA_C020_WLAN 0x20c0 +#define PCMCIA_STR_NOKIA_C020_WLAN "Nokia C020 WLAN Card" + +/* No Wires Needed */ +#define PCMCIA_CIS_NWN_WLAN_550 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NWN_WLAN_550 0x0002 +#define PCMCIA_STR_NWN_WLAN_550 "NWN 550 WLAN" +#define PCMCIA_CIS_NWN_WLAN_1148 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_NWN_WLAN_1148 0x0003 +#define PCMCIA_STR_NWN_WLAN_1148 "NWN 1148 WLAN" + +/* Olicom Products */ +#define PCMCIA_CIS_OLICOM_TR { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_OLICOM_TR 0x2132 +#define PCMCIA_STR_OLICOM_TR "GoCard Token Ring 16/4" +#define PCMCIA_CIS_OLICOM_OC2220 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_OLICOM_OC2220 0x2022 +#define PCMCIA_STR_OLICOM_OC2220 "GoCard Ethernet" +#define PCMCIA_CIS_OLICOM_OC2231 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_OLICOM_OC2231 0x3122 +#define PCMCIA_STR_OLICOM_OC2231 "GoCard Combo Eth/Modem 288" +#define PCMCIA_CIS_OLICOM_OC2232 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_OLICOM_OC2232 0x3222 +#define PCMCIA_STR_OLICOM_OC2232 "GoCard Combo Eth/Modem 336" + +/* Ositech Products */ +#define PCMCIA_CIS_OSITECH_TRUMPCARD_SOD { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_OSITECH_TRUMPCARD_SOD 0x0008 +#define PCMCIA_STR_OSITECH_TRUMPCARD_SOD "Ositech Seven of Diamonds Ethernet Card" + +/* Panasonic Products */ +#define PCMCIA_CIS_PANASONIC_KXLC002 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PANASONIC_KXLC002 0x0304 +#define PCMCIA_STR_PANASONIC_KXLC002 "Panasonic 4X CD-ROM Interface Card" +#define PCMCIA_CIS_PANASONIC_KXLC003 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PANASONIC_KXLC003 0x0504 +#define PCMCIA_STR_PANASONIC_KXLC003 "Panasonic 8X CD-ROM Interface Card" +#define PCMCIA_CIS_PANASONIC_KXLC004 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PANASONIC_KXLC004 0x0604 +#define PCMCIA_STR_PANASONIC_KXLC004 "Panasonic KXL-810AN Interface Card" +#define PCMCIA_CIS_PANASONIC_KXLC005 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PANASONIC_KXLC005 0x2704 +#define PCMCIA_STR_PANASONIC_KXLC005 "Panasonic 16X CD-ROM Interface Card" +#define PCMCIA_CIS_PANASONIC_KME { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PANASONIC_KME 0x2604 +#define PCMCIA_STR_PANASONIC_KME "Panasonic CD-R/RW Interface" + +/* Planex */ +#define PCMCIA_CIS_PLANEX_2_GWNS11H { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PLANEX_2_GWNS11H 0xb001 +#define PCMCIA_STR_PLANEX_2_GWNS11H "Planex GW-NS11H" + +/* Proxim */ +#define PCMCIA_CIS_PROXIM_HARMONY { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PROXIM_HARMONY 0x0002 +#define PCMCIA_STR_PROXIM_HARMONY "Proxim HARMONY 80211B" +#define PCMCIA_CIS_PROXIM_ROAMABOUT_2400FH { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PROXIM_ROAMABOUT_2400FH 0x1058 +#define PCMCIA_STR_PROXIM_ROAMABOUT_2400FH "Digital RoamAbout 2400FH" +#define PCMCIA_CIS_PROXIM_RANGELAN2_7401 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PROXIM_RANGELAN2_7401 0x1158 +#define PCMCIA_STR_PROXIM_RANGELAN2_7401 "Proxim RangeLAN2 7401" +#define PCMCIA_CIS_PROXIM_RANGELANDS_8430 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PROXIM_RANGELANDS_8430 0x8000 +#define PCMCIA_STR_PROXIM_RANGELANDS_8430 "Proxim RangeLAN-DS 8430" + +/* Psion */ +#define PCMCIA_CIS_PSION_GOLDCARD { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PSION_GOLDCARD 0x0020 +#define PCMCIA_STR_PSION_GOLDCARD "Psion Gold Card" + +/* QLogic */ +#define PCMCIA_CIS_QLOGIC_PC05 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_QLOGIC_PC05 0x0104 +#define PCMCIA_STR_QLOGIC_PC05 "Qlogic Fast SCSI" + +/* Quatech */ +#define PCMCIA_CIS_QUATECH_SPP_100 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_QUATECH_SPP_100 0x0003 +#define PCMCIA_STR_QUATECH_SPP_100 "Quatech Enhanced Parallel Port" +#define PCMCIA_CIS_QUATECH_DSP_225 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_QUATECH_DSP_225 0x0008 +#define PCMCIA_STR_QUATECH_DSP_225 "Quatech Dual Serial Port" + +/* RATOC System Inc. Products */ +/* Don't use because both cards have same product id */ +#define PCMCIA_CIS_RATOC_REX_R280_9530 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_RATOC_REX_R280_9530 0x0001 +#define PCMCIA_STR_RATOC_REX_R280_9530 "RATOC REX-R280/REX-9530" + +/* Raylink/WebGear */ +#define PCMCIA_CIS_RAYTHEON_WLAN { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_RAYTHEON_WLAN 0x0000 +#define PCMCIA_STR_RAYTHEON_WLAN "WLAN Adapter" + +/* Roland */ +#define PCMCIA_CIS_ROLAND_SCP55 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ROLAND_SCP55 0x0001 +#define PCMCIA_STR_ROLAND_SCP55 "Roland SCP-55" + +/* Samsung */ +#define PCMCIA_CIS_SAMSUNG_SWL_2000N { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SAMSUNG_SWL_2000N 0x0002 +#define PCMCIA_STR_SAMSUNG_SWL_2000N "Samsung MagicLAN SWL-2000N" + +/* Sandisk Products */ +#define PCMCIA_CIS_SANDISK_SDCFB { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SANDISK_SDCFB 0x0401 +#define PCMCIA_STR_SANDISK_SDCFB "Sandisk CompactFlash Card" + +/* Sharp Products */ +#define PCMCIA_CIS_SHARP_PALDIO611S { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SHARP_PALDIO611S 0x0000 +#define PCMCIA_STR_SHARP_PALDIO611S "PALDIO 611S PC CARD" + +/* Siemens */ +#define PCMCIA_CIS_SIEMENS_SS1021 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SIEMENS_SS1021 0x0002 +#define PCMCIA_STR_SIEMENS_SS1021 "Siemens SpeedStream 1021" + +/* Simple Technology Products */ +#define PCMCIA_CIS_SIMPLETECH_COMMUNICATOR288 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SIMPLETECH_COMMUNICATOR288 0x0100 +#define PCMCIA_STR_SIMPLETECH_COMMUNICATOR288 "Simple Technology 28.8 Communicator" +/* Simpletech ID also used by Symbol */ +#define PCMCIA_CIS_SIMPLETECH_SPECTRUM24 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SIMPLETECH_SPECTRUM24 0x801 +#define PCMCIA_STR_SIMPLETECH_SPECTRUM24 "Symbol Spectrum24 WLAN Adapter" + +/* Standard Microsystems Corporation Products */ +#define PCMCIA_CIS_SMC_8016 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SMC_8016 0x0105 +#define PCMCIA_STR_SMC_8016 "SMC 8016 EtherCard" +#define PCMCIA_CIS_SMC_EZCARD { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SMC_EZCARD 0x8022 +#define PCMCIA_STR_SMC_EZCARD "SMC EZCard 10 PCMCIA" + +/* Socket Communications Products */ +#define PCMCIA_CIS_SOCKET_EA_ETHER { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SOCKET_EA_ETHER 0x0000 +#define PCMCIA_STR_SOCKET_EA_ETHER "Socket Communications EA" +#define PCMCIA_CIS_SOCKET_LP_WLAN_CF { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SOCKET_LP_WLAN_CF 0x0001 +#define PCMCIA_STR_SOCKET_LP_WLAN_CF "Socket Communications Low Power WLAN Card" +#define PCMCIA_CIS_SOCKET_PAGECARD { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SOCKET_PAGECARD 0x0003 +#define PCMCIA_STR_SOCKET_PAGECARD "Socket Communications PageCard" +#define PCMCIA_CIS_SOCKET_DUAL_RS232 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SOCKET_DUAL_RS232 0x0006 +#define PCMCIA_STR_SOCKET_DUAL_RS232 "Socket Communications Dual RS232" +#define PCMCIA_CIS_SOCKET_LP_ETHER { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SOCKET_LP_ETHER 0x000d +#define PCMCIA_STR_SOCKET_LP_ETHER "Socket Communications LP-E" +#define PCMCIA_CIS_SOCKET_LP_ETHER_CF { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SOCKET_LP_ETHER_CF 0x0075 +#define PCMCIA_STR_SOCKET_LP_ETHER_CF "Socket Communications LP-E CF" +#define PCMCIA_CIS_SOCKET_LP_ETH_10_100_CF { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SOCKET_LP_ETH_10_100_CF 0x0145 +#define PCMCIA_STR_SOCKET_LP_ETH_10_100_CF "Socket Communications 10/100 Ethernet" + +/* Symbol */ +#define PCMCIA_CIS_SYMBOL_LA4100 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_SYMBOL_LA4100 0x0001 +#define PCMCIA_STR_SYMBOL_LA4100 "Symbol Spectrum24 LA4100 Series WLAN" + +/* TDK Products */ +#define PCMCIA_CIS_TDK_LAK_CD011WL { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_TDK_LAK_CD011WL 0x0000 +#define PCMCIA_STR_TDK_LAK_CD011WL "TDK LAK-CD011WL" +#define PCMCIA_CIS_TDK_LAK_CD021BX { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_TDK_LAK_CD021BX 0x0200 +#define PCMCIA_STR_TDK_LAK_CD021BX "TDK LAK-CD021BX Ethernet" +#define PCMCIA_CIS_TDK_LAK_CF010 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_TDK_LAK_CF010 0x0900 +#define PCMCIA_STR_TDK_LAK_CF010 "TDK LAC-CF010" +#define PCMCIA_CIS_TDK_DFL9610 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_TDK_DFL9610 0x0d0a +#define PCMCIA_STR_TDK_DFL9610 "TDK DFL9610 Ethernet & Digital Cellular" +#define PCMCIA_CIS_TDK_C6500012 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_TDK_C6500012 0x410a +#define PCMCIA_STR_TDK_C6500012 "TDK ELSA MicroLink MC all" + +/* Telecom Device */ +#define PCMCIA_CIS_TELECOMDEVICE_TCD_HPC100 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_TELECOMDEVICE_TCD_HPC100 0x0202 +#define PCMCIA_STR_TELECOMDEVICE_TCD_HPC100 "Telecom Device TCD-HPC100" + +/* US Robotics Products */ +#define PCMCIA_CIS_USROBOTICS_WORLDPORT144 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_USROBOTICS_WORLDPORT144 0x3330 +#define PCMCIA_STR_USROBOTICS_WORLDPORT144 "US Robotics WorldPort 14.4 Modem" + +/* WORKBIT Products */ +#define PCMCIA_CIS_WORKBIT_ULTRA_NINJA_16 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_WORKBIT_ULTRA_NINJA_16 0x8006 +#define PCMCIA_STR_WORKBIT_ULTRA_NINJA_16 "WORKBIT Ultra Ninja-16 (16bit mode)" + +/* Xircom Products */ +#define PCMCIA_CIS_XIRCOM_CWE1130 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CWE1130 0x0007 +#define PCMCIA_STR_XIRCOM_CWE1130 "Xircom Wireless Ethernet Adapter" +#define PCMCIA_CIS_XIRCOM_CE { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CE 0x0108 +#define PCMCIA_STR_XIRCOM_CE "Xircom CreditCard Ethernet" +#define PCMCIA_CIS_XIRCOM_CE3 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CE3 0x010a +#define PCMCIA_STR_XIRCOM_CE3 "Xircom CreditCard 10/100 Ethernet" +#define PCMCIA_CIS_XIRCOM_CE2 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CE2 0x010b +#define PCMCIA_STR_XIRCOM_CE2 "Xircom CreditCard Ethernet II" +#define PCMCIA_CIS_XIRCOM_XE2000 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_XE2000 0x0153 +#define PCMCIA_STR_XIRCOM_XE2000 "Xircom XE2000 10/100 Ethernet" +#define PCMCIA_CIS_XIRCOM_CNW_801 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CNW_801 0x0801 +#define PCMCIA_STR_XIRCOM_CNW_801 "Xircom CreditCard Netwave (Canada)" +#define PCMCIA_CIS_XIRCOM_CNW_802 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CNW_802 0x0802 +#define PCMCIA_STR_XIRCOM_CNW_802 "Xircom CreditCard Netwave (US)" +#define PCMCIA_CIS_XIRCOM_CT2 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CT2 0x1101 +#define PCMCIA_STR_XIRCOM_CT2 "Xircom CreditCard Token Ring II" +#define PCMCIA_CIS_XIRCOM_CEM { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CEM 0x110a +#define PCMCIA_STR_XIRCOM_CEM "Xircom CreditCard Ethernet + Modem" +#define PCMCIA_CIS_XIRCOM_REM56 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_REM56 0x110a +#define PCMCIA_STR_XIRCOM_REM56 "Xircom RealPort Ethernet 10/100 + Modem 56" +#define PCMCIA_CIS_XIRCOM_CEM28 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CEM28 0x110b +#define PCMCIA_STR_XIRCOM_CEM28 "Xircom CreditCard Ethernet + Modem 28" +#define PCMCIA_CIS_XIRCOM_CEM56 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CEM56 0x110b +#define PCMCIA_STR_XIRCOM_CEM56 "Xircom CreditCard Ethernet + Modem 56" +#define PCMCIA_CIS_XIRCOM_CEM33 { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_XIRCOM_CEM33 0x110d +#define PCMCIA_STR_XIRCOM_CEM33 "Xircom CreditCard Ethernet + Modem 33" + +/* ZONET */ +#define PCMCIA_CIS_ZONET_ZEN { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_ZONET_ZEN 0x0100 +#define PCMCIA_STR_ZONET_ZEN "Zonet Zen 10/10" + +/* + * Cards we know only by their cis, sorted by name. + */ +#define PCMCIA_VENDOR_AMBICOM 0xffffffff /* AmbiCom Inc */ +#define PCMCIA_VENDOR_ACCTON 0xffffffff /* ACCTON */ +#define PCMCIA_VENDOR_ADDTRON 0xffffffff /* Addtron */ +#define PCMCIA_VENDOR_ARGOSY 0xffffffff /* ARGOSY */ +#define PCMCIA_VENDOR_AMD 0xffffffff /* AMD */ +#define PCMCIA_VENDOR_BILLIONTON 0xffffffff /* Billionton Systems Inc. */ +#define PCMCIA_VENDOR_CNET 0xffffffff /* CNet */ +#define PCMCIA_VENDOR_COREGA 0xffffffff /* Corega K.K. */ +#define PCMCIA_VENDOR_DIGITAL 0xffffffff /* Digital Equipment Corporation */ +#define PCMCIA_VENDOR_DLINK 0xffffffff /* D-Link */ +#define PCMCIA_VENDOR_DYNALINK 0xffffffff /* DynaLink */ +#define PCMCIA_VENDOR_EIGERLABS 0xffffffff /* Eiger labs,Inc. */ +#define PCMCIA_VENDOR_EPSON 0xffffffff /* Seiko Epson Corporation */ +#define PCMCIA_VENDOR_EXP 0xffffffff /* EXP Computer Inc */ +#define PCMCIA_VENDOR_FUJITSU2 0xffffffff /* Fujitsu */ +#define PCMCIA_VENDOR_FUTUREDOMAIN 0xffffffff /* FutureDomain */ +#define PCMCIA_VENDOR_FREECOM 0xffffffff /* Freecom */ +#define PCMCIA_VENDOR_GEMTEK 0xffffffff /* Gem Tek */ +#define PCMCIA_VENDOR_ICOM 0xffffffff /* ICOM Inc */ +#define PCMCIA_VENDOR_INTERSIL2 0xffffffff /* Intersil */ +#define PCMCIA_VENDOR_IODATA3 0xffffffff /* I-O DATA */ +#define PCMCIA_VENDOR_LANTECH 0xffffffff /* Lantech Computer Company */ +#define PCMCIA_VENDOR_MELCO2 0xffffffff /* Melco Corporation */ +#define PCMCIA_VENDOR_NAKAGAWAMETAL 0xffffffff /* NAKAGAWA METAL */ +#define PCMCIA_VENDOR_NDC 0xffffffff /* NDC */ +#define PCMCIA_VENDOR_NEC 0xffffffff /* NEC */ +#define PCMCIA_VENDOR_OEM2 0xffffffff /* Generic OEM */ +#define PCMCIA_VENDOR_PLANET 0xffffffff /* Planet */ +#define PCMCIA_VENDOR_PLANEX 0xffffffff /* Planex Communications Inc */ +#define PCMCIA_VENDOR_PREMAX 0xffffffff /* Premax */ +#define PCMCIA_VENDOR_RPTI 0xffffffff /* RPTI */ +#define PCMCIA_VENDOR_SVEC 0xffffffff /* SVEC/Hawking Technology */ +#define PCMCIA_VENDOR_SYNERGY21 0xffffffff /* Synergy 21 */ +#define PCMCIA_VENDOR_TEAC 0xffffffff /* TEAC */ +#define PCMCIA_VENDOR_TOSHIBA 0xffffffff /* TOSHIBA */ +#define PCMCIA_VENDOR_WORKBIT2 0xffffffff /* WORKBIT */ +#define PCMCIA_VENDOR_YEDATA 0xffffffff /* Y-E DATA */ +#define PCMCIA_VENDOR_YIS 0xffffffff /* YIS Corporation */ +#define PCMCIA_VENDOR_ZOOM 0xffffffff /* ZOOM */ + +#define PCMCIA_CIS_ACCTON_EN2212 { "ACCTON", "EN2212", NULL, NULL } +#define PCMCIA_PRODUCT_ACCTON_EN2212 0xffffffff +#define PCMCIA_STR_ACCTON_EN2212 "Accton EN2212" +#define PCMCIA_CIS_ACCTON_EN2216 { "ACCTON", "EN2216-PCMCIA-ETHERNET", "EN2216R01", NULL } +#define PCMCIA_PRODUCT_ACCTON_EN2216 0xffffffff +#define PCMCIA_STR_ACCTON_EN2216 "Accton EN2216" +#define PCMCIA_CIS_ACCTON_EN2226 { "Accton", "Fast EtherCard-16", "EN2226", "1.00" } +#define PCMCIA_PRODUCT_ACCTON_EN2226 0xffffffff +#define PCMCIA_STR_ACCTON_EN2226 "Accton EN2226" +#define PCMCIA_CIS_ADDTRON_AWP100 { "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02", NULL } +#define PCMCIA_PRODUCT_ADDTRON_AWP100 0xffffffff +#define PCMCIA_STR_ADDTRON_AWP100 "" +#define PCMCIA_CIS_ALLIEDTELESIS_WR211PCM { "Allied Telesis K.K.", "WR211PCM", NULL, NULL } +#define PCMCIA_PRODUCT_ALLIEDTELESIS_WR211PCM 0xffffffff +#define PCMCIA_STR_ALLIEDTELESIS_WR211PCM "Allied Telesis WR211PCM" +#define PCMCIA_CIS_AMBICOM_AMB8002T { "AmbiCom Inc", "AMB8002T", NULL, NULL } +#define PCMCIA_PRODUCT_AMBICOM_AMB8002T 0xffffffff +#define PCMCIA_STR_AMBICOM_AMB8002T "AmbiCom AMB8002T" +#define PCMCIA_CIS_AMD_AM79C930 { "AMD", "Am79C930", NULL, NULL } +#define PCMCIA_PRODUCT_AMD_AM79C930 0xffffffff +#define PCMCIA_STR_AMD_AM79C930 "AMD Am79C930" +#define PCMCIA_CIS_ARGOSY_SP320 { "PCMCIA", "RS-COM 2P", NULL, NULL +#define PCMCIA_PRODUCT_ARGOSY_SP320 0xffffffff +#define PCMCIA_STR_ARGOSY_SP320 "} ARGOSY SP320 Dual port serial PCMCIA" +#define PCMCIA_CIS_BILLIONTON_CFLT10N { "CF", "10Base-Ethernet", "1.0", NULL } +#define PCMCIA_PRODUCT_BILLIONTON_CFLT10N 0xffffffff +#define PCMCIA_STR_BILLIONTON_CFLT10N "Billionton Systems Inc. CFLT10N Ethernet" +#define PCMCIA_CIS_BILLIONTON_LNT10TN { "PCMCIA", "LNT-10TN", NULL, NULL } +#define PCMCIA_PRODUCT_BILLIONTON_LNT10TN 0xffffffff +#define PCMCIA_STR_BILLIONTON_LNT10TN "Billionton Systems Inc. LNT-10TN NE2000 Compatible Card" +#define PCMCIA_CIS_CNET_NE2000 { "CNet", "CN40BC Ethernet", "D", "NE2000" } +#define PCMCIA_PRODUCT_CNET_NE2000 0xffffffff +#define PCMCIA_STR_CNET_NE2000 "CNet CN40BC NE2000 Compatible" +#define PCMCIA_CIS_COREGA_ETHER_PCC_T { "corega K.K.", "corega Ether PCC-T", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_ETHER_PCC_T 0xffffffff +#define PCMCIA_STR_COREGA_ETHER_PCC_T "Corega Ether PCC-T" +#define PCMCIA_CIS_COREGA_ETHER_PCC_TD { "corega K.K.", "corega Ether PCC-TD", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_ETHER_PCC_TD 0xffffffff +#define PCMCIA_STR_COREGA_ETHER_PCC_TD "Corega Ether PCC-TD" +#define PCMCIA_CIS_COREGA_ETHER_II_PCC_T { "corega K.K.", "corega EtherII PCC-T", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_ETHER_II_PCC_T 0xffffffff +#define PCMCIA_STR_COREGA_ETHER_II_PCC_T "Corega EtherII PCC-T" +#define PCMCIA_CIS_COREGA_ETHER_II_PCC_TD { "corega K.K.", "corega EtherII PCC-TD", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_ETHER_II_PCC_TD 0xffffffff +#define PCMCIA_STR_COREGA_ETHER_II_PCC_TD "Corega EtherII PCC-TD" +#define PCMCIA_CIS_COREGA_FAST_ETHER_PCC_TX { "corega K.K.", "corega FastEther PCC-TX", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_FAST_ETHER_PCC_TX 0xffffffff +#define PCMCIA_STR_COREGA_FAST_ETHER_PCC_TX "Corega FastEther PCC-TX" +#define PCMCIA_CIS_COREGA_FETHER_PCC_TXD { "corega K.K.", "corega FEther PCC-TXD", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_FETHER_PCC_TXD 0xffffffff +#define PCMCIA_STR_COREGA_FETHER_PCC_TXD "Corega FEther PCC-TXD" +#define PCMCIA_CIS_COREGA_FETHER_PCC_TXF { "corega", "FEther PCC-TXF", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_FETHER_PCC_TXF 0xffffffff +#define PCMCIA_STR_COREGA_FETHER_PCC_TXF "Corega FEther PCC-TXF" +#define PCMCIA_CIS_COREGA_WIRELESS_LAN_PCC_11 { "corega K.K.", "Wireless LAN PCC-11", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCC_11 0xffffffff +#define PCMCIA_STR_COREGA_WIRELESS_LAN_PCC_11 "Corega Wireless LAN PCC-11" +#define PCMCIA_CIS_COREGA_WIRELESS_LAN_PCCA_11 { "corega K.K.", "Wireless LAN PCCA-11", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCCA_11 0xffffffff +#define PCMCIA_STR_COREGA_WIRELESS_LAN_PCCA_11 "Corega Wireless LAN PCCA-11" +#define PCMCIA_CIS_COREGA_WIRELESS_LAN_PCCB_11 { "corega_K.K.", "Wireless_LAN_PCCB-11", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCCB_11 0xffffffff +#define PCMCIA_STR_COREGA_WIRELESS_LAN_PCCB_11 "Corega Wireless LAN PCCB-11" +#define PCMCIA_CIS_COREGA_WIRELESS_LAN_PCCL_11 { "corega", "WL PCCL-11", NULL, NULL } +#define PCMCIA_PRODUCT_COREGA_WIRELESS_LAN_PCCL_11 0xffffffff +#define PCMCIA_STR_COREGA_WIRELESS_LAN_PCCL_11 "Corega Wireless LAN PCCL-11" + +#define PCMCIA_CIS_DIGITAL_DEPCMXX { "DIGITAL", "DEPCM-XX", NULL, NULL } +#define PCMCIA_PRODUCT_DIGITAL_DEPCMXX 0xffffffff +#define PCMCIA_STR_DIGITAL_DEPCMXX "DEC DEPCM-BA" +#define PCMCIA_CIS_DLINK_DE650 { "D-Link", "DE-650", NULL, NULL } +#define PCMCIA_PRODUCT_DLINK_DE650 0xffffffff +#define PCMCIA_STR_DLINK_DE650 "D-Link DE-650" +#define PCMCIA_CIS_DLINK_DE660 { "D-Link", "DE-660", NULL, NULL } +#define PCMCIA_PRODUCT_DLINK_DE660 0xffffffff +#define PCMCIA_STR_DLINK_DE660 "D-Link DE-660" +#define PCMCIA_CIS_DLINK_DE660PLUS { "D-Link", "DE-660+", NULL, NULL } +#define PCMCIA_PRODUCT_DLINK_DE660PLUS 0xffffffff +#define PCMCIA_STR_DLINK_DE660PLUS "D-Link DE-660+" +#define PCMCIA_CIS_DLINK_DFE670TXD { "D-Link", "DFE-670TXD", NULL, NULL } +#define PCMCIA_PRODUCT_DLINK_DFE670TXD 0xffffffff +#define PCMCIA_STR_DLINK_DFE670TXD "D-Link DFE-670TXD" +#define PCMCIA_CIS_DLINK_DWL650H { "D-Link Corporation", "D-Link DWL-650H 11Mbps WLAN Adapter", NULL, NULL } +#define PCMCIA_PRODUCT_DLINK_DWL650H 0xffffffff +#define PCMCIA_STR_DLINK_DWL650H "D-Link DWL-650H" +#define PCMCIA_CIS_DYNALINK_L10C { "DYNALINK", "L10C", NULL, NULL } +#define PCMCIA_PRODUCT_DYNALINK_L10C 0xffffffff +#define PCMCIA_STR_DYNALINK_L10C "Dynalink L10C" +/* + * vendor ID of EPX_AA2000 is Fujitsu (0x0004) and product ID is 0x2000, but + * it conflicts with Fujitsu Towa LA501 Ethernet. + */ +#define PCMCIA_CIS_EIGERLABS_EPX_AA2000 { "Eiger labs,Inc.", "EPX-AA2000 PC Sound Card", NULL, NULL } +#define PCMCIA_PRODUCT_EIGERLABS_EPX_AA2000 0xffffffff +#define PCMCIA_STR_EIGERLABS_EPX_AA2000 "EPX-AA2000 PC Sound Card" +#define PCMCIA_CIS_EPSON_EEN10B { "Seiko Epson Corp.", "Ethernet", "P/N: EEN10B Rev. 00", NULL } +#define PCMCIA_PRODUCT_EPSON_EEN10B 0xffffffff +#define PCMCIA_STR_EPSON_EEN10B "Epson EEN10B" +#define PCMCIA_CIS_EPSON_SC200 { "EPSON", "SCSI-2 PC Card SC200", NULL, NULL } +#define PCMCIA_PRODUCT_EPSON_SC200 0xffffffff +#define PCMCIA_STR_EPSON_SC200 "Media Intelligent SCSI-2 PC Card MSC-200" +#define PCMCIA_CIS_EXP_EXPMULTIMEDIA { "EXP ", "PnPIDE", "F1", NULL } +#define PCMCIA_PRODUCT_EXP_EXPMULTIMEDIA 0xffffffff +#define PCMCIA_STR_EXP_EXPMULTIMEDIA "EXP IDE/ATAPI DVD Card" +#define PCMCIA_CIS_EXP_THINLANCOMBO { "PCMCIA LAN", "Ethernet", NULL, NULL } +#define PCMCIA_PRODUCT_EXP_THINLANCOMBO 0xffffffff +#define PCMCIA_STR_EXP_THINLANCOMBO "EXP ThinLan Combo" +#define PCMCIA_CIS_FREECOM_PCCARDIDE { "FREECOM", "PCCARD-IDE", NULL, NULL } +#define PCMCIA_PRODUCT_FREECOM_PCCARDIDE 0xffffffff +#define PCMCIA_STR_FREECOM_PCCARDIDE "FREECOM PCCARD-IDE" +#define PCMCIA_CIS_FUJITSU2_FMV_J181 { "PCMCIA MBH10302", "01", NULL, NULL } +#define PCMCIA_PRODUCT_FUJITSU2_FMV_J181 0xffffffff +#define PCMCIA_STR_FUJITSU2_FMV_J181 "FUJITSU FMV-J181 PCMCIA Card" +#define PCMCIA_CIS_FUJITSU2_FMV_J182 { "FUJITSU", "LAN Card(FMV-J182)", "Ver.01", NULL } +#define PCMCIA_PRODUCT_FUJITSU2_FMV_J182 0xffffffff +#define PCMCIA_STR_FUJITSU2_FMV_J182 "FUJITSU FMV-J182 PCMCIA Card" +#define PCMCIA_CIS_FUJITSU2_FMV_J182A { "FUJITSU", "LAN Card(FMV-J182)", "Ver.02", NULL } +#define PCMCIA_PRODUCT_FUJITSU2_FMV_J182A 0xffffffff +#define PCMCIA_STR_FUJITSU2_FMV_J182A "FUJITSU FMV-J182A PCMCIA Card" +#define PCMCIA_CIS_FUJITSU2_ITCFJ182A { "FUJITSU", "LAN Card(ITCFJ182)", "Ver.01", NULL } +#define PCMCIA_PRODUCT_FUJITSU2_ITCFJ182A 0xffffffff +#define PCMCIA_STR_FUJITSU2_ITCFJ182A "FUJITSU ITCFJ182A CompactCard" +#define PCMCIA_CIS_FUTUREDOMAIN_SCSI2GO { "Future Domain Corporation" "SCSI PCMCIA Credit Card Controller", NULL, NULL } +#define PCMCIA_PRODUCT_FUTUREDOMAIN_SCSI2GO 0xffffffff +#define PCMCIA_STR_FUTUREDOMAIN_SCSI2GO "Future Domain SCSI2GO" +#define PCMCIA_CIS_GEMTEK_WLAN { "Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P", "Eval-RevA" } +#define PCMCIA_PRODUCT_GEMTEK_WLAN 0xffffffff +#define PCMCIA_STR_GEMTEK_WLAN "GEMTEK Prism2_5 WaveLAN Card" +#define PCMCIA_CIS_IBM_SCSICARD { "IBM Corp.", "SCSI PCMCIA Card", NULL, NULL } +#define PCMCIA_PRODUCT_IBM_SCSICARD 0xffffffff +#define PCMCIA_STR_IBM_SCSICARD "IBM SCSI PCMCIA Card" +#define PCMCIA_CIS_ICOM_SL200 { "Icom", "SL-200", NULL, NULL } +#define PCMCIA_PRODUCT_ICOM_SL200 0xffffffff +#define PCMCIA_STR_ICOM_SL200 "Icom SL-200" +#define PCMCIA_CIS_INTERSIL2_PRISM2 { "INTERSIL", "HFA384x/IEEE", "Version 01.02", NULL } +#define PCMCIA_PRODUCT_INTERSIL2_PRISM2 0xffffffff +#define PCMCIA_STR_INTERSIL2_PRISM2 "Intersil Prism II" +#define PCMCIA_CIS_IODATA_CBIDE2 { "IO DATA", "CBIDE2 ", NULL, NULL } +#define PCMCIA_PRODUCT_IODATA_CBIDE2 0xffffffff +#define PCMCIA_STR_IODATA_CBIDE2 "IO-DATA CBIDE2/16-bit mode" +#define PCMCIA_CIS_IODATA3_CBSC16 { "IO DATA", "CBSC16 ", NULL, NULL } +#define PCMCIA_PRODUCT_IODATA3_CBSC16 0xffffffff +#define PCMCIA_STR_IODATA3_CBSC16 "IO-DATA CBSC16" +#define PCMCIA_CIS_IODATA_PCLAT { "I-O DATA", "PCLA", "ETHERNET", NULL } +#define PCMCIA_PRODUCT_IODATA_PCLAT 0xffffffff +#define PCMCIA_STR_IODATA_PCLAT "IO-DATA PCLA/T" +#define PCMCIA_CIS_LANTECH_FASTNETTX { "ASIX", "AX88190", NULL, NULL } +#define PCMCIA_PRODUCT_LANTECH_FASTNETTX 0xffffffff +#define PCMCIA_STR_LANTECH_FASTNETTX "Lantech Fastnet/TX" +#define PCMCIA_CIS_LINKSYS_ECARD_2 { "LINKSYS", "E-CARD", NULL, NULL } +#define PCMCIA_PRODUCT_LINKSYS_ECARD_2 0xffffffff +#define PCMCIA_STR_LINKSYS_ECARD_2 "Linksys E-Card" +#define PCMCIA_CIS_LINKSYS_PCM100 { "Linksys", "EtherFast 10/100 Integrated PC Card (PCM100)", "Ver 1.0", NULL } +#define PCMCIA_PRODUCT_LINKSYS_PCM100 0xffffffff +#define PCMCIA_STR_LINKSYS_PCM100 "" +#define PCMCIA_CIS_MACNICA_MPS100 { "MACNICA", "MIRACLE SCSI", "mPS100", "D.0" } +#define PCMCIA_PRODUCT_MACNICA_MPS100 0xffffffff +#define PCMCIA_STR_MACNICA_MPS100 "Macnica Miracle SCSI mPS100" +#define PCMCIA_CIS_MEGAHERTZ_XJ2288 { "MEGAHERTZ", "MODEM XJ2288", NULL, NULL } +#define PCMCIA_PRODUCT_MEGAHERTZ_XJ2288 0xffffffff +#define PCMCIA_STR_MEGAHERTZ_XJ2288 "Megahertz XJ2288 Modem" +#define PCMCIA_CIS_MELCO2_LPC2_TX { "MELCO", "LPC2-TX", NULL, NULL } +#define PCMCIA_PRODUCT_MELCO2_LPC2_TX 0xffffffff +#define PCMCIA_STR_MELCO2_LPC2_TX "Melco LPC2-TX" +#define PCMCIA_CIS_NAKAGAWAMETAL_LNT10TN { "PCMCIA", "LNT-10TN", NULL, NULL } +#define PCMCIA_PRODUCT_NAKAGAWAMETAL_LNT10TN 0xffffffff +#define PCMCIA_STR_NAKAGAWAMETAL_LNT10TN "NAKAGAWA METAL LNT-10TN NE2000 Compatible Card" +#define PCMCIA_CIS_NANOSPEED_PRISM2 { "NANOSPEED", "HFA384x/IEEE", "Version 01.02", NULL } +#define PCMCIA_PRODUCT_NANOSPEED_PRISM2 0xffffffff +#define PCMCIA_STR_NANOSPEED_PRISM2 "NANOSPEED ROOT-RZ2000 WLAN Card" +#define PCMCIA_CIS_NDC_ND5100_E { "NDC", "Ethernet", "A", NULL } +#define PCMCIA_PRODUCT_NDC_ND5100_E 0xffffffff +#define PCMCIA_STR_NDC_ND5100_E "Sohoware ND5100E NE2000 Compatible Card" +#define PCMCIA_CIS_NEC_CMZ_RT_WP { "NEC", "Wireless Card CMZ-RT-WP", "Version 01.01", NULL } +#define PCMCIA_PRODUCT_NEC_CMZ_RT_WP 0xffffffff +#define PCMCIA_STR_NEC_CMZ_RT_WP "NEC Wireless Card CMZ-RT-WP" +#define PCMCIA_CIS_NEC_PC9801N_J03R { "NEC", "PC-9801N-J03R", NULL, NULL } +#define PCMCIA_PRODUCT_NEC_PC9801N_J03R 0xffffffff +#define PCMCIA_STR_NEC_PC9801N_J03R "NEC PC-9801N-J03R" +#define PCMCIA_CIS_NEWMEDIA_BASICS_SCSI { "BASICS by New Media Corporation" "SCSI Sym53C500", NULL, NULL } +#define PCMCIA_PRODUCT_NEWMEDIA_BASICS_SCSI 0xffffffff +#define PCMCIA_STR_NEWMEDIA_BASICS_SCSI "New Media Corporation BASICS SCSI" +#define PCMCIA_CIS_NTT_ME_WLAN { "NTT-ME", "11Mbps Wireless LAN PC Card", NULL, NULL } +#define PCMCIA_PRODUCT_NTT_ME_WLAN 0xffffffff +#define PCMCIA_STR_NTT_ME_WLAN "NTT-ME 11Mbps Wireless LAN PC Card" +#define PCMCIA_CIS_OEM2_CDROM1 { "PCMCIA", "CD-ROM", NULL, NULL } +#define PCMCIA_PRODUCT_OEM2_CDROM1 0xffffffff +#define PCMCIA_STR_OEM2_CDROM1 "Generic PCMCIA CD-ROM" +#define PCMCIA_CIS_OEM2_IDE { "PCMCIA", "IDE CARD", NULL, NULL } +#define PCMCIA_PRODUCT_OEM2_IDE 0xffffffff +#define PCMCIA_STR_OEM2_IDE "Generic PCMCIA IDE CARD" +#define PCMCIA_CIS_PLANET_SMARTCOM2000 { "PCMCIA", "UE2212", NULL, NULL } +#define PCMCIA_PRODUCT_PLANET_SMARTCOM2000 0xffffffff +#define PCMCIA_STR_PLANET_SMARTCOM2000 "Planet SmartCOM 2000" +/* + * vendor ID of both FNW-3600-T and FNW-3700-T is LINKSYS (0x0149) and + * product ID is 0xc1ab, but it conflicts with LINKSYS Combo EthernetCard. + */ +#define PCMCIA_CIS_PLANEX_FNW3600T { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PLANEX_FNW3600T -1 +#define PCMCIA_STR_PLANEX_FNW3600T "Planex FNW-3600-T" +#define PCMCIA_CIS_PLANEX_FNW3700T { NULL, NULL, NULL, NULL } +#define PCMCIA_PRODUCT_PLANEX_FNW3700T -1 +#define PCMCIA_STR_PLANEX_FNW3700T "Planex FNW-3700-T" +#define PCMCIA_CIS_RPTI_EP400 { "RPTI LTD.", "EP400", "CISV100", NULL } +#define PCMCIA_PRODUCT_RPTI_EP400 0xffffffff +#define PCMCIA_STR_RPTI_EP400 "RPTI EP400" +#define PCMCIA_CIS_RPTI_EP401 { "RPTI", "EP401 Ethernet NE2000 Compatible", NULL, NULL } +#define PCMCIA_PRODUCT_RPTI_EP401 0xffffffff +#define PCMCIA_STR_RPTI_EP401 "RPTI EP401" +#define PCMCIA_CIS_PREMAX_PE200 { "PMX ", "PE-200", NULL, NULL } +#define PCMCIA_PRODUCT_PREMAX_PE200 0xffffffff +#define PCMCIA_STR_PREMAX_PE200 "PreMax PE-200" +#define PCMCIA_CIS_RATOC_REX_R280 { "RATOC System Inc.", "10BASE_T CARD R280", NULL, NULL } +#define PCMCIA_PRODUCT_RATOC_REX_R280 0xffffffff +#define PCMCIA_STR_RATOC_REX_R280 "RATOC REX-R280" +#define PCMCIA_CIS_RATOC_REX5536 { "1195 RATOC System Inc.", "REX5536 SCSI2 CARD", NULL, NULL } +#define PCMCIA_PRODUCT_RATOC_REX5536 0xffffffff +#define PCMCIA_STR_RATOC_REX5536 "RATOC REX-5536" +#define PCMCIA_CIS_RATOC_REX5536AM { "PCMCIA SCSI MBH10404", "01", NULL, NULL } +#define PCMCIA_PRODUCT_RATOC_REX5536AM 0xffffffff +#define PCMCIA_STR_RATOC_REX5536AM "RATOC REX-5536AM" +#define PCMCIA_CIS_RATOC_REX5536M { "PCMCIA SCSI2 CARD", "01", NULL, NULL } +#define PCMCIA_PRODUCT_RATOC_REX5536M 0xffffffff +#define PCMCIA_STR_RATOC_REX5536M "RATOC REX-5536M" +#define PCMCIA_CIS_RATOC_REX5572 { "RATOC System Inc.", "SOUND/SCSI2 CARD", NULL, NULL } +#define PCMCIA_PRODUCT_RATOC_REX5572 0xffffffff +#define PCMCIA_STR_RATOC_REX5572 "RATOC REX-5572" +#define PCMCIA_CIS_RATOC_REX9530 { "RATOC System Inc.", "SCSI2 CARD 37", NULL, NULL } +#define PCMCIA_PRODUCT_RATOC_REX9530 0xffffffff +#define PCMCIA_STR_RATOC_REX9530 "RATOC REX-9530" +#define PCMCIA_CIS_SIMPLETECH_SPECTRUM24_ALT { "Symbol Technologies", "LA4111 Spectrum24 Wireless LAN PC Card", NULL, NULL } +#define PCMCIA_PRODUCT_SIMPLETECH_SPECTRUM24_ALT 0xffffffff +#define PCMCIA_STR_SIMPLETECH_SPECTRUM24_ALT "LA4111 Spectrum24 Wireless LAN PC Card" +#define PCMCIA_CIS_SMC_2632W { "SMC", "SMC2632W", "Version 01.02", NULL } +#define PCMCIA_PRODUCT_SMC_2632W 0xffffffff +#define PCMCIA_STR_SMC_2632W "SMC 2632 EZ Connect Wireless PC Card" +#define PCMCIA_CIS_SMC_8041 { "SMC", "8041TX-10/100-PC-Card-V2", NULL, NULL } +#define PCMCIA_PRODUCT_SMC_8041 0xffffffff +#define PCMCIA_STR_SMC_8041 "SMC 8041TX 10/100 PC Card" +#define PCMCIA_CIS_SVEC_COMBOCARD { "Ethernet", "Adapter", NULL, NULL } +#define PCMCIA_PRODUCT_SVEC_COMBOCARD 0xffffffff +#define PCMCIA_STR_SVEC_COMBOCARD "SVEC/Hawking Tech. Combo Card" +#define PCMCIA_CIS_SVEC_LANCARD { "SVEC", "FD605 PCMCIA EtherNet Card", "V1-1", NULL } +#define PCMCIA_PRODUCT_SVEC_LANCARD 0xffffffff +#define PCMCIA_STR_SVEC_LANCARD "SVEC PCMCIA Lan Card" +#define PCMCIA_CIS_SYNERGY21_S21810 { "PCMCIA", "Ethernet", "A", "004743118001" } +#define PCMCIA_PRODUCT_SYNERGY21_S21810 0xffffffff +#define PCMCIA_STR_SYNERGY21_S21810 "Synergy 21 S21810+ NE2000 Compatible Card" +#define PCMCIA_CIS_TEAC_IDECARDII { NULL, "NinjaATA-", NULL, NULL } +#define PCMCIA_PRODUCT_TEAC_IDECARDII 0xffffffff +#define PCMCIA_STR_TEAC_IDECARDII "TEAC IDE Card/II" +#define PCMCIA_CIS_TOSHIBA_CBIDE2 { "LOOKMEET", "CBIDE2 ", NULL, NULL } +#define PCMCIA_PRODUCT_TOSHIBA_CBIDE2 0xffffffff +#define PCMCIA_STR_TOSHIBA_CBIDE2 "TOSHIBA PA2673U CBIDE2/16-bit mode (IO-DATA OEM)" +#define PCMCIA_CIS_WORKBIT2_NINJA_SCSI3 { "WBT", "NinjaSCSI-3", NULL, NULL } +#define PCMCIA_PRODUCT_WORKBIT2_NINJA_SCSI3 0xffffffff +#define PCMCIA_STR_WORKBIT2_NINJA_SCSI3 "WORKBIT Ninja SCSI series" +#define PCMCIA_CIS_XIRCOM_CFE_10 { "Xircom", "CompactCard Ethernet", "CFE-10", "1.00" } +#define PCMCIA_PRODUCT_XIRCOM_CFE_10 0xffffffff +#define PCMCIA_STR_XIRCOM_CFE_10 "Xircom CompactCard CFE-10" +#define PCMCIA_CIS_YEDATA_EXTERNAL_FDD { "Y-E DATA", "External FDD", NULL, NULL } +#define PCMCIA_PRODUCT_YEDATA_EXTERNAL_FDD 0xffffffff +#define PCMCIA_STR_YEDATA_EXTERNAL_FDD "Y-E DATA External FDD" +#define PCMCIA_CIS_YIS_YWL11B { "YIS Corp.", "YWL-11b", NULL, NULL } +#define PCMCIA_PRODUCT_YIS_YWL11B 0xffffffff +#define PCMCIA_STR_YIS_YWL11B "YIS Corp. YWL-11b" +#define PCMCIA_CIS_ZOOM_AIR_4000 { "Zoom", "Air-4000", NULL, NULL } +#define PCMCIA_PRODUCT_ZOOM_AIR_4000 0xffffffff +#define PCMCIA_STR_ZOOM_AIR_4000 "Zoom Air-4000" diff --git a/sys/bus/pccard/pccardreg.h b/sys/bus/pccard/pccardreg.h index a767699cf5..f50352e002 100644 --- a/sys/bus/pccard/pccardreg.h +++ b/sys/bus/pccard/pccardreg.h @@ -1,6 +1,6 @@ /* $NetBSD: pcmciareg.h,v 1.7 1998/10/29 09:45:52 enami Exp $ */ /* $FreeBSD: src/sys/dev/pccard/pccardreg.h,v 1.1 1999/10/26 06:52:31 imp Exp $ */ -/* $DragonFly: src/sys/bus/pccard/pccardreg.h,v 1.2 2003/06/17 04:28:29 dillon Exp $ */ +/* $DragonFly: src/sys/bus/pccard/pccardreg.h,v 1.3 2004/02/10 07:55:45 joerg Exp $ */ /* * Copyright (c) 1997 Marc Horowitz. All rights reserved. diff --git a/sys/bus/pccard/pccardvar.h b/sys/bus/pccard/pccardvar.h index 849467e60b..bc997212e1 100644 --- a/sys/bus/pccard/pccardvar.h +++ b/sys/bus/pccard/pccardvar.h @@ -1,6 +1,6 @@ -/* $NetBSD: pcmciavar.h,v 1.9 1998/12/29 09:00:28 marc Exp $ */ -/* $FreeBSD: src/sys/dev/pccard/pccardvar.h,v 1.6.2.3 2002/09/01 05:45:51 imp Exp $ */ -/* $DragonFly: src/sys/bus/pccard/pccardvar.h,v 1.2 2003/06/17 04:28:29 dillon Exp $ */ +/* $NetBSD: pcmciavar.h,v 1.12 2000/02/08 12:51:31 enami Exp $ */ +/* $FreeBSD: src/sys/dev/pccard/pccardvar.h,v 1.34 2002/11/14 05:15:50 imp Exp $ */ +/* $DragonFly: src/sys/bus/pccard/pccardvar.h,v 1.3 2004/02/10 07:55:45 joerg Exp $ */ /* * Copyright (c) 1997 Marc Horowitz. All rights reserved. @@ -61,7 +61,8 @@ struct pccard_mem_handle { bus_addr_t addr; /* resulting address in bus space */ bus_size_t size; /* size of mem space */ bus_size_t realsize; /* how much we really allocated */ - long offset; + long offset; /* mapped Offset on card */ + bus_addr_t cardaddr; /* Absolute address on card */ int kind; }; @@ -104,16 +105,36 @@ struct pccard_config_entry { u_long hostaddr; } memspace[2]; /* XXX this could be as high as 8 */ int maxtwins; + struct resource *iores[4]; + int iorid[4]; + struct resource *irqres; + int irqrid; + struct resource *memres[2]; + int memrid[2]; STAILQ_ENTRY(pccard_config_entry) cfe_list; }; +struct pccard_funce_disk { + int pfd_interface; +}; + +struct pccard_funce_lan { + int pfl_nidlen; + u_int8_t pfl_nid[8]; +}; + +union pccard_funce { + struct pccard_funce_disk pfv_disk; + struct pccard_funce_lan pfv_lan; +}; + struct pccard_function { /* read off the card */ int number; int function; int last_config_index; - u_long ccr_base; - u_long ccr_mask; + uint32_t ccr_base; /* Offset with card's memory */ + uint32_t ccr_mask; struct resource *ccr_res; int ccr_rid; STAILQ_HEAD(, pccard_config_entry) cfe_head; @@ -122,17 +143,23 @@ struct pccard_function { struct pccard_softc *sc; struct pccard_config_entry *cfe; struct pccard_mem_handle pf_pcmh; + device_t dev; #define pf_ccrt pf_pcmh.memt #define pf_ccrh pf_pcmh.memh #define pf_ccr_realsize pf_pcmh.realsize - bus_addr_t pf_ccr_offset; + uint32_t pf_ccr_offset; /* Offset from ccr_base of CIS */ int pf_ccr_window; - long pf_mfc_iobase; + long pf_mfc_iobase; /* Right type? */ long pf_mfc_iomax; - int (*ih_fct)(void *); - void *ih_arg; - int ih_ipl; int pf_flags; + driver_intr_t *intr_handler; + void *intr_handler_arg; + void *intr_handler_cookie; + + union pccard_funce pf_funce; /* CISTPL_FUNCE */ +#define pf_funce_disk_interface pf_funce.pfv_disk.pfd_interface +#define pf_funce_lan_nid pf_funce.pfv_lan.pfl_nid +#define pf_funce_lan_nidlen pf_funce.pfv_lan.pfl_nidlen }; /* pf_flags */ @@ -150,11 +177,12 @@ struct pccard_card { * indicates no id was found. */ int32_t manufacturer; -#define PCCARD_VENDOR_INVALID -1 +#define PCMCIA_VENDOR_INVALID -1 int32_t product; -#define PCCARD_PRODUCT_INVALID -1 +#define PCMCIA_PRODUCT_INVALID -1 + int16_t prodext; u_int16_t error; -#define PCCARD_CIS_INVALID { NULL, NULL, NULL, NULL } +#define PCMCIA_CIS_INVALID { NULL, NULL, NULL, NULL } STAILQ_HEAD(, pccard_function) pf_head; }; @@ -168,7 +196,7 @@ struct pccard_card { /* More later? */ struct pccard_ivar { struct resource_list resources; - int slotnum; + struct pccard_function *fcn; }; struct pccard_softc { @@ -177,9 +205,7 @@ struct pccard_softc { /* this stuff is for the card */ struct pccard_card card; - void *ih; int sc_enabled_count; /* num functions enabled */ - }; void @@ -202,6 +228,33 @@ struct pccard_tuple { bus_space_handle_t memh; }; +struct pccard_product { + const char *pp_name; /* NULL if end of table */ +#define PCCARD_VENDOR_ANY ((u_int32_t) -1) + u_int32_t pp_vendor; +#define PCCARD_PRODUCT_ANY ((u_int32_t) -1) + u_int32_t pp_product; + int pp_expfunc; + const char *pp_cis[4]; +}; + +typedef int (*pccard_product_match_fn) (device_t dev, + const struct pccard_product *ent, int vpfmatch); + +#include "card_if.h" + +/* + * make this inline so that we don't have to worry about dangling references + * to it in the modules or the code. + */ +static __inline const struct pccard_product * +pccard_product_lookup(device_t dev, const struct pccard_product *tab, + size_t ent_size, pccard_product_match_fn matchfn) +{ + return CARD_DO_PRODUCT_LOOKUP(device_get_parent(dev), dev, + tab, ent_size, matchfn); +} + void pccard_read_cis(struct pccard_softc *); void pccard_check_cis_quirks(device_t); void pccard_print_cis(device_t); @@ -215,7 +268,7 @@ int pccard_scan_cis(device_t, (pccard_cis_read_1((tuple), ((tuple)->ptr+(2+(idx1))))) #define pccard_tuple_read_2(tuple, idx2) \ - (pccard_tuple_read_1((tuple), (idx2)) | \ + (pccard_tuple_read_1((tuple), (idx2)) | \ (pccard_tuple_read_1((tuple), (idx2)+1)<<8)) #define pccard_tuple_read_3(tuple, idx3) \ @@ -238,17 +291,9 @@ int pccard_scan_cis(device_t, #define PCCARD_SPACE_MEMORY 1 #define PCCARD_SPACE_IO 2 -int pccard_ccr_read(struct pccard_function *, int); -void pccard_ccr_write(struct pccard_function *, int, int); - #define pccard_mfc(sc) (STAILQ_FIRST(&(sc)->card.pf_head) && \ STAILQ_NEXT(STAILQ_FIRST(&(sc)->card.pf_head),pf_list)) -void pccard_function_init(struct pccard_function *, - struct pccard_config_entry *); -int pccard_function_enable(struct pccard_function *); -void pccard_function_disable(struct pccard_function *); - #define pccard_io_alloc(pf, start, size, align, pciop) \ (pccard_chip_io_alloc((pf)->sc->pct, pf->sc->pch, (start), \ (size), (align), (pciop))) @@ -262,17 +307,27 @@ void pccard_io_unmap(struct pccard_function *, int); #define pccard_mem_alloc(pf, size, pcmhp) \ (pccard_chip_mem_alloc((pf)->sc->pct, (pf)->sc->pch, (size), (pcmhp))) - #define pccard_mem_free(pf, pcmhp) \ (pccard_chip_mem_free((pf)->sc->pct, (pf)->sc->pch, (pcmhp))) - #define pccard_mem_map(pf, kind, card_addr, size, pcmhp, offsetp, windowp) \ (pccard_chip_mem_map((pf)->sc->pct, (pf)->sc->pch, (kind), \ (card_addr), (size), (pcmhp), (offsetp), (windowp))) - #define pccard_mem_unmap(pf, window) \ (pccard_chip_mem_unmap((pf)->sc->pct, (pf)->sc->pch, (window))) +/* compat layer */ +static __inline int +pccard_compat_probe(device_t dev) +{ + return (CARD_COMPAT_DO_PROBE(device_get_parent(dev), dev)); +} + +static __inline int +pccard_compat_attach(device_t dev) +{ + return (CARD_COMPAT_DO_ATTACH(device_get_parent(dev), dev)); +} + /* ivar interface */ enum { PCCARD_IVAR_ETHADDR, /* read ethernet address from CIS tupple */ @@ -287,18 +342,41 @@ enum { PCCARD_IVAR_FUNCTION }; -/* read ethernet address from CIS tupple */ -__inline static int -pccard_get_ether(device_t dev, u_char *enaddr) -{ - return BUS_READ_IVAR(device_get_parent(dev), dev, - PCCARD_IVAR_ETHADDR, (uintptr_t *)enaddr); +#define PCCARD_ACCESSOR(A, B, T) \ +__inline static int \ +pccard_get_ ## A(device_t dev, T *t) \ +{ \ + return BUS_READ_IVAR(device_get_parent(dev), dev, \ + PCCARD_IVAR_ ## B, (uintptr_t *) t); \ } +PCCARD_ACCESSOR(ether, ETHADDR, u_int8_t) +PCCARD_ACCESSOR(vendor, VENDOR, u_int32_t) +PCCARD_ACCESSOR(product, PRODUCT, u_int32_t) +PCCARD_ACCESSOR(prodext, PRODEXT, u_int16_t) +PCCARD_ACCESSOR(function_number,FUNCTION_NUMBER, u_int32_t) +PCCARD_ACCESSOR(function, FUNCTION, u_int32_t) +PCCARD_ACCESSOR(vendor_str, VENDOR_STR, char *) +PCCARD_ACCESSOR(product_str, PRODUCT_STR, char *) +PCCARD_ACCESSOR(cis3_str, CIS3_STR, char *) + /* shared memory flags */ enum { - PCCARD_A_MEM_ATTR=1, /* attribute */ PCCARD_A_MEM_COM, /* common */ + PCCARD_A_MEM_ATTR, /* attribute */ PCCARD_A_MEM_8BIT, /* 8 bit */ PCCARD_A_MEM_16BIT /* 16 bit */ }; + +#define PCCARD_SOFTC(d) (struct pccard_softc *) device_get_softc(d) +#define PCCARD_IVAR(d) (struct pccard_ivar *) device_get_ivars(d) + +#define PCCARD_S(a, b) PCMCIA_STR_ ## a ## _ ## b +#define PCCARD_P(a, b) PCMCIA_PRODUCT_ ## a ## _ ## b +#define PCCARD_C(a, b) PCMCIA_CIS_ ## a ## _ ## b +#define PCMCIA_CARD(v, p, f) { PCCARD_S(v, p), PCMCIA_VENDOR_ ## v, \ + PCCARD_P(v, p), f, PCCARD_C(v, p) } +#define PCMCIA_CARD2(v1, p1, p2, f) \ + { PCMCIA_STR_ ## p2, PCMCIA_VENDOR_ ## v1, PCCARD_P(v1, p1), \ + f, PCMCIA_CIS_ ## p2} + diff --git a/sys/bus/pccard/pccbb/Makefile b/sys/bus/pccard/pccbb/Makefile deleted file mode 100644 index 58a2d09625..0000000000 --- a/sys/bus/pccard/pccbb/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# $FreeBSD: src/sys/modules/cbb/Makefile,v 1.2 1999/11/28 18:52:41 bde Exp $ -# $DragonFly: src/sys/bus/pccard/pccbb/Attic/Makefile,v 1.3 2003/08/15 01:19:54 dillon Exp $ -# -# XXX disabled, no pccbb.c to be found. - -KMOD= cbb -SRCS= pccbb.c \ - device_if.h bus_if.h -NOMAN= - -.include diff --git a/sys/bus/pccard/pcic.c b/sys/bus/pccard/pcic.c deleted file mode 100644 index 4c1f4c70e2..0000000000 --- a/sys/bus/pccard/pcic.c +++ /dev/null @@ -1,1330 +0,0 @@ -/* - * Intel PCIC or compatible Controller driver - *------------------------------------------------------------------------- - * - * Copyright (c) 2001 M. Warner Losh. All rights reserved. - * Copyright (c) 1995 Andrew McRae. 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. 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. - * - * $FreeBSD: src/sys/pccard/pcic.c,v 1.89.2.28 2003/02/26 18:42:00 imp Exp $ - * $DragonFly: src/sys/bus/pccard/Attic/pcic.c,v 1.4 2004/01/08 10:06:29 joerg Exp $ - */ - -#include -#include -#include -#include -#include -#include - -#include -#include "i82365.h" -#include "pcic_pci.h" -#include "cardinfo.h" -#include "slot.h" -#include "pcicvar.h" - -/* Get pnp IDs */ -#include -#include -#include "pccardvar.h" -#include "card_if.h" - -/* - * Prototypes for interrupt handler. - */ -static int pcic_ioctl(struct slot *, int, caddr_t); -static int pcic_power(struct slot *); -static void pcic_mapirq(struct slot *, int); -static timeout_t pcic_reset; -static void pcic_resume(struct slot *); -static void pcic_disable(struct slot *); -static int pcic_memory(struct slot *, int); -static int pcic_io(struct slot *, int); - -devclass_t pcic_devclass; - -static struct slot_ctrl pcic_cinfo = { - pcic_mapirq, - pcic_memory, - pcic_io, - pcic_reset, - pcic_disable, - pcic_power, - pcic_ioctl, - pcic_resume, - PCIC_MEM_WIN, - PCIC_IO_WIN -}; - -/* sysctl vars */ -SYSCTL_NODE(_hw, OID_AUTO, pcic, CTLFLAG_RD, 0, "PCIC parameters"); - -int pcic_override_irq = 0; -TUNABLE_INT("machdep.pccard.pcic_irq", &pcic_override_irq); -TUNABLE_INT("hw.pcic.irq", &pcic_override_irq); -SYSCTL_INT(_hw_pcic, OID_AUTO, irq, CTLFLAG_RD, - &pcic_override_irq, 0, - "Override the IRQ configured by the config system for all pcic devices"); - -int pcic_boot_deactivated = 0; -TUNABLE_INT("hw.pcic.boot_deactivated", &pcic_boot_deactivated); -SYSCTL_INT(_hw_pcic, OID_AUTO, boot_deactivated, CTLFLAG_RD, - &pcic_boot_deactivated, 0, - "Override the automatic powering up of pccards at boot. This works\n\ -around what turns out to be an old bug in the code that has since been\n\ -corrected. It is now deprecated and will be removed completely before\n\ -FreeBSD 4.8."); - -/* - * CL-PD6722's VSENSE method - * 0: NO VSENSE (assume a 5.0V card) - * 1: 6710's method (default) - * 2: 6729's method - */ -int pcic_pd6722_vsense = 1; -TUNABLE_INT("hw.pcic.pd6722_vsense", &pcic_pd6722_vsense); -SYSCTL_INT(_hw_pcic, OID_AUTO, pd6722_vsense, CTLFLAG_RD, - &pcic_pd6722_vsense, 1, - "Select CL-PD6722's VSENSE method. VSENSE is used to determine the\n\ -volatage of inserted cards. The CL-PD6722 has two methods to determine the\n\ -voltage of the card. 0 means assume a 5.0V card and do not check. 1 means\n\ -use the same method that the CL-PD6710 uses (default). 2 means use the\n\ -same method as the CL-PD6729. 2 is documented in the datasheet as being\n\ -the correct way, but 1 seems to give better results on more laptops."); - -/* - * Read a register from the PCIC. - */ -unsigned char -pcic_getb_io(struct pcic_slot *sp, int reg) -{ - bus_space_write_1(sp->bst, sp->bsh, PCIC_INDEX, sp->offset + reg); - return (bus_space_read_1(sp->bst, sp->bsh, PCIC_DATA)); -} - -/* - * Write a register on the PCIC - */ -void -pcic_putb_io(struct pcic_slot *sp, int reg, unsigned char val) -{ - /* - * Many datasheets recommend using outw rather than outb to save - * a microsecond. Maybe we should do this, but we'd likely only - * save 20-30us on card activation. - */ - bus_space_write_1(sp->bst, sp->bsh, PCIC_INDEX, sp->offset + reg); - bus_space_write_1(sp->bst, sp->bsh, PCIC_DATA, val); -} - -/* - * Clear bit(s) of a register. - */ -__inline void -pcic_clrb(struct pcic_slot *sp, int reg, unsigned char mask) -{ - sp->putb(sp, reg, sp->getb(sp, reg) & ~mask); -} - -/* - * Set bit(s) of a register - */ -__inline void -pcic_setb(struct pcic_slot *sp, int reg, unsigned char mask) -{ - sp->putb(sp, reg, sp->getb(sp, reg) | mask); -} - -/* - * Write a 16 bit value to 2 adjacent PCIC registers - */ -static __inline void -pcic_putw(struct pcic_slot *sp, int reg, unsigned short word) -{ - sp->putb(sp, reg, word & 0xFF); - sp->putb(sp, reg + 1, (word >> 8) & 0xff); -} - -/* - * pc98 cbus cards introduce a slight wrinkle here. They route the irq7 pin - * from the pcic chip to INT 2 on the cbus. INT 2 is normally mapped to - * irq 6 on the pc98 architecture, so if we get a request for irq 6 - * lie to the hardware and say it is 7. All the other usual mappings for - * cbus INT into irq space are the same as the rest of the system. - */ -static __inline int -host_irq_to_pcic(int irq) -{ -#ifdef PC98 - if (irq == 6) - irq = 7; -#endif - return (irq); -} - -/* - * Free up resources allocated so far. - */ -void -pcic_dealloc(device_t dev) -{ - struct pcic_softc *sc; - - sc = (struct pcic_softc *) device_get_softc(dev); - if (sc->slot_poll) - untimeout(sc->slot_poll, sc, sc->timeout_ch); - if (sc->iores) - bus_release_resource(dev, SYS_RES_IOPORT, sc->iorid, - sc->iores); - if (sc->memres) - bus_release_resource(dev, SYS_RES_MEMORY, sc->memrid, - sc->memres); - if (sc->ih) - bus_teardown_intr(dev, sc->irqres, sc->ih); - if (sc->irqres) - bus_release_resource(dev, SYS_RES_IRQ, sc->irqrid, sc->irqres); -} - -/* - * entry point from main code to map/unmap memory context. - */ -static int -pcic_memory(struct slot *slt, int win) -{ - struct pcic_slot *sp = slt->cdata; - struct mem_desc *mp = &slt->mem[win]; - int reg = win * PCIC_MEMSIZE + PCIC_MEMBASE; - - if (win < 0 || win >= slt->ctrl->maxmem) { - printf("Illegal PCIC MEMORY window request %d\n", win); - return (ENXIO); - } - if (mp->flags & MDF_ACTIVE) { - unsigned long sys_addr = (uintptr_t)(void *)mp->start >> 12; - if ((sys_addr >> 12) != 0 && - (sp->sc->flags & PCIC_YENTA_HIGH_MEMORY) == 0) { - printf("This pcic does not support mapping > 24M\n"); - return (ENXIO); - } - /* - * Write the addresses, card offsets and length. - * The values are all stored as the upper 12 bits of the - * 24 bit address i.e everything is allocated as 4 Kb chunks. - * Memory mapped cardbus bridges extend this slightly to allow - * one to set the upper 8 bits of the 32bit address as well. - * If the chip supports it, then go ahead and write those - * upper 8 bits. - */ - pcic_putw(sp, reg, sys_addr & 0xFFF); - pcic_putw(sp, reg+2, (sys_addr + (mp->size >> 12) - 1) & 0xFFF); - pcic_putw(sp, reg+4, ((mp->card >> 12) - sys_addr) & 0x3FFF); - if (sp->sc->flags & PCIC_YENTA_HIGH_MEMORY) - sp->putb(sp, PCIC_MEMORY_HIGH0 + win, sys_addr >> 12); - /* - * Each 16 bit register has some flags in the upper bits. - */ - if (mp->flags & MDF_16BITS) - pcic_setb(sp, reg+1, PCIC_DATA16); - if (mp->flags & MDF_ZEROWS) - pcic_setb(sp, reg+1, PCIC_ZEROWS); - if (mp->flags & MDF_WS0) - pcic_setb(sp, reg+3, PCIC_MW0); - if (mp->flags & MDF_WS1) - pcic_setb(sp, reg+3, PCIC_MW1); - if (mp->flags & MDF_ATTR) - pcic_setb(sp, reg+5, PCIC_REG); - if (mp->flags & MDF_WP) - pcic_setb(sp, reg+5, PCIC_WP); - /* - * Enable the memory window. By experiment, we need a delay. - */ - pcic_setb(sp, PCIC_ADDRWINE, (1<cdata; - struct io_desc *ip = &slt->io[win]; - if (bootverbose) { - printf("pcic: I/O win %d flags %x %x-%x\n", win, ip->flags, - ip->start, ip->start + ip->size - 1); - } - - switch (win) { - case 0: - mask = PCIC_IO0_EN; - reg = PCIC_IO0; - break; - case 1: - mask = PCIC_IO1_EN; - reg = PCIC_IO1; - break; - default: - printf("Illegal PCIC I/O window request %d\n", win); - return (ENXIO); - } - if (ip->flags & IODF_ACTIVE) { - unsigned char x, ioctlv; - - pcic_putw(sp, reg, ip->start); - pcic_putw(sp, reg+2, ip->start + ip->size - 1); - x = 0; - if (ip->flags & IODF_ZEROWS) - x |= PCIC_IO_0WS; - if (ip->flags & IODF_WS) - x |= PCIC_IO_WS; - if (ip->flags & IODF_CS16) - x |= PCIC_IO_CS16; - if (ip->flags & IODF_16BIT) - x |= PCIC_IO_16BIT; - /* - * Extract the current flags and merge with new flags. - * Flags for window 0 in lower nybble, and in upper nybble - * for window 1. - */ - ioctlv = sp->getb(sp, PCIC_IOCTL); - DELAY(100); - switch (win) { - case 0: - sp->putb(sp, PCIC_IOCTL, x | (ioctlv & 0xf0)); - break; - case 1: - sp->putb(sp, PCIC_IOCTL, (x << 4) | (ioctlv & 0xf)); - break; - } - DELAY(100); - pcic_setb(sp, PCIC_ADDRWINE, mask); - DELAY(100); - } else { - pcic_clrb(sp, PCIC_ADDRWINE, mask); - DELAY(100); - pcic_putw(sp, reg, 0); - pcic_putw(sp, reg + 2, 0); - } - return (0); -} - -static void -pcic_do_mgt_irq(struct pcic_slot *sp, int irq) -{ - u_int32_t reg; - - if (sp->sc->csc_route == pcic_iw_pci) { - /* Do the PCI side of things: Enable the Card Change int */ - reg = CB_SM_CD; - bus_space_write_4(sp->bst, sp->bsh, CB_SOCKET_MASK, reg); - /* - * TI Chips need us to set the following. We tell the - * controller to route things via PCI interrupts. Also - * we clear the interrupt number in the STAT_INT register - * as well. The TI-12xx and newer chips require one or the - * other of these to happen, depending on what is set in the - * diagnostic register. I do both on the theory that other - * chips might need one or the other and that no harm will - * come from it. If there is harm, then I'll make it a bit - * in the tables. - */ - pcic_setb(sp, PCIC_INT_GEN, PCIC_INTR_ENA); - pcic_clrb(sp, PCIC_STAT_INT, PCIC_CSCSELECT); - } else { - /* Management IRQ changes */ - /* - * The PCIC_INTR_ENA bit means either "tie the function - * and csc interrupts together" or "Route csc interrupts - * via PCI" or "Reserved". In any case, we want to clear - * it since we're using ISA interrupts. - */ - pcic_clrb(sp, PCIC_INT_GEN, PCIC_INTR_ENA); - irq = host_irq_to_pcic(irq); - sp->putb(sp, PCIC_STAT_INT, (irq << PCIC_SI_IRQ_SHIFT) | - PCIC_CDEN); - } -} - -int -pcic_attach(device_t dev) -{ - int i; - device_t kid; - struct pcic_softc *sc; - struct slot *slt; - struct pcic_slot *sp; - - sc = (struct pcic_softc *) device_get_softc(dev); - callout_handle_init(&sc->timeout_ch); - sp = &sc->slots[0]; - for (i = 0; i < PCIC_CARD_SLOTS; i++, sp++) { - if (!sp->slt) - continue; - sp->slt = 0; - kid = device_add_child(dev, NULL, -1); - if (kid == NULL) { - device_printf(dev, "Can't add pccard bus slot %d", i); - return (ENXIO); - } - device_probe_and_attach(kid); - slt = pccard_init_slot(kid, &pcic_cinfo); - if (slt == 0) { - device_printf(dev, "Can't get pccard info slot %d", i); - return (ENXIO); - } - sc->slotmask |= (1 << i); - slt->cdata = sp; - sp->slt = slt; - sp->sc = sc; - } - - sp = &sc->slots[0]; - for (i = 0; i < PCIC_CARD_SLOTS; i++, sp++) { - if (sp->slt == NULL) - continue; - - pcic_do_mgt_irq(sp, sc->irq); - sp->slt->irq = sc->irq; - - /* Check for changes */ - sp->slt->laststate = sp->slt->state = empty; - if (pcic_boot_deactivated) { - sp->putb(sp, PCIC_POWER, 0); - if ((sp->getb(sp, PCIC_STATUS) & PCIC_CD) == PCIC_CD) { - sp->slt->state = inactive; - pccard_event(sp->slt, card_deactivated); - } - } else { - pcic_do_stat_delta(sp); - } - } - - return (bus_generic_attach(dev)); -} - - -static int -pcic_sresource(struct slot *slt, caddr_t data) -{ - struct pccard_resource *pr; - struct resource *r; - int flags; - int rid = 0; - device_t bridgedev = slt->dev; - struct pcic_slot *sp = slt->cdata; - - pr = (struct pccard_resource *)data; - pr->resource_addr = ~0ul; - - /* - * If we're using PCI interrupt routing, then force the IRQ to - * use and to heck with what the user requested. If they want - * to be able to request IRQs, they must use ISA interrupt - * routing. If we don't give them an irq, and it is the - * pccardd 0,0 case, then just return (giving the "bad resource" - * return in pr->resource_addr). - */ - if (pr->type == SYS_RES_IRQ) { - if (sp->sc->func_route >= pcic_iw_pci) { - pr->resource_addr = sp->sc->irq; - return (0); - } - if (pr->min == 0 && pr->max == 0) - return (0); - } - - /* - * Make sure we grok this type. - */ - switch(pr->type) { - default: - return (EINVAL); - case SYS_RES_MEMORY: - case SYS_RES_IRQ: - case SYS_RES_IOPORT: - break; - } - - /* - * Allocate the resource, and align it to the most natural - * size. If we get it, then tell userland what we actually got - * in the range they requested. - */ - flags = rman_make_alignment_flags(pr->size); - r = bus_alloc_resource(bridgedev, pr->type, &rid, pr->min, pr->max, - pr->size, flags); - if (r != NULL) { - pr->resource_addr = (u_long)rman_get_start(r); - bus_release_resource(bridgedev, pr->type, rid, r); - } - return (0); -} - -/* - * ioctl calls - Controller specific ioctls - */ -static int -pcic_ioctl(struct slot *slt, int cmd, caddr_t data) -{ - struct pcic_slot *sp = slt->cdata; - struct pcic_reg *preg = (struct pcic_reg *) data; - - switch(cmd) { - default: - return (ENOTTY); - case PIOCGREG: /* Get pcic register */ - preg->value = sp->getb(sp, preg->reg); - break; /* Set pcic register */ - case PIOCSREG: - sp->putb(sp, preg->reg, preg->value); - break; - case PIOCSRESOURCE: /* Can I use this resource? */ - pcic_sresource(slt, data); - break; - } - return (0); -} - -/* - * pcic_cardbus_power - * - * Power the card up, as specified, using the cardbus power - * registers to control power. Microsoft recommends that cardbus - * vendors support powering the card via cardbus registers because - * there is no standard for 3.3V cards. Since at least a few of the - * cardbus bridges have minor issues with power via the ExCA registers, - * go ahead and do it all via cardbus registers. - * - * An expamination of the code will show the relative ease that we do - * Vpp in comparison to the ExCA case (which may be partially broken). - */ -static int -pcic_cardbus_power(struct pcic_slot *sp, struct slot *slt) -{ - uint32_t power; - uint32_t state; - - /* - * If we're doing an auto-detect, and we're in a badvcc state, then - * we need to force the socket to rescan the card. We don't do this - * all the time because the socket can take up to 200ms to do the deed, - * and that's too long to busy wait. Since this is a relatively rare - * event (some BIOSes, and earlier versions of OLDCARD caused it), we - * test for it special. - */ - state = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE); - if (slt->pwr.vcc == -1 && (state & CB_SS_BADVCC)) { - /* - * Force the bridge to scan the card for the proper voltages - * that it supports. - */ - bus_space_write_4(sp->bst, sp->bsh, CB_SOCKET_FORCE, - CB_SF_INTCVS); - state = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE); - /* This while loop can take 100-150ms */ - while ((state & CB_SS_CARD_MASK) == 0) { - DELAY(10 * 1000); - state = bus_space_read_4(sp->bst, sp->bsh, - CB_SOCKET_STATE); - } - } - - - /* - * Preserve the clock stop bit of the socket power register. Not - * sure that we want to do that, but maybe we should set it based - * on the power state. - */ - power = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_POWER); - power = 0; - - /* - * vcc == -1 means automatically detect the voltage of the card. - * Do so and apply the right amount of power. - */ - if (slt->pwr.vcc == -1) { - if (state & CB_SS_5VCARD) - slt->pwr.vcc = 50; - else if (state & CB_SS_3VCARD) - slt->pwr.vcc = 33; - else if (state & CB_SS_XVCARD) - slt->pwr.vcc = 22; - else if (state & CB_SS_YVCARD) - slt->pwr.vcc = 11; - if (bootverbose && slt->pwr.vcc != -1) - device_printf(sp->sc->dev, - "Autodetected %d.%dV card\n", - slt->pwr.vcc / 10, slt->pwr.vcc % 10); - } - - switch(slt->pwr.vcc) { - default: - return (EINVAL); - case 0: - power |= CB_SP_VCC_0V; - break; - case 11: - power |= CB_SP_VCC_YV; - break; - case 22: - power |= CB_SP_VCC_XV; - break; - case 33: - power |= CB_SP_VCC_3V; - break; - case 50: - power |= CB_SP_VCC_5V; - break; - } - - /* - * vpp == -1 means use vcc voltage. - */ - if (slt->pwr.vpp == -1) - slt->pwr.vpp = slt->pwr.vcc; - switch(slt->pwr.vpp) { - default: - return (EINVAL); - case 0: - power |= CB_SP_VPP_0V; - break; - case 11: - power |= CB_SP_VPP_YV; - break; - case 22: - power |= CB_SP_VPP_XV; - break; - case 33: - power |= CB_SP_VPP_3V; - break; - case 50: - power |= CB_SP_VPP_5V; - break; - case 120: - power |= CB_SP_VPP_12V; - break; - } - bus_space_write_4(sp->bst, sp->bsh, CB_SOCKET_POWER, power); - - /* - * OK. We need to bring the card out of reset. Let the power - * stabilize for 300ms (why 300?) and then enable the outputs - * and then wait 100ms (why 100?) for it to stabilize. These numbers - * were stolen from the dim, dark past of OLDCARD and I have no clue - * how they were derived. I also use the bit setting routines here - * as a measure of conservatism. - */ - if (power) { - pcic_setb(sp, PCIC_POWER, PCIC_DISRST); - DELAY(300*1000); - pcic_setb(sp, PCIC_POWER, PCIC_DISRST | PCIC_OUTENA); - DELAY(100*1000); - } else { - pcic_clrb(sp, PCIC_POWER, PCIC_DISRST | PCIC_OUTENA); - } - - return (0); -} - -/* - * pcic_power - Enable the power of the slot according to - * the parameters in the power structure(s). - */ -static int -pcic_power(struct slot *slt) -{ - unsigned char c, c2; - unsigned char reg = PCIC_DISRST | PCIC_PCPWRE; - struct pcic_slot *sp = slt->cdata; - struct pcic_slot *sp2; - struct pcic_softc *sc = sp->sc; - int dodefault = 0; - char controller; - - /* - * Cardbus power registers are completely different. - */ - if (sc->flags & PCIC_CARDBUS_POWER) - return (pcic_cardbus_power(sp, slt)); - - if (bootverbose) - device_printf(sc->dev, "Power: Vcc=%d Vpp=%d\n", slt->pwr.vcc, - slt->pwr.vpp); - /* - * If we're automatically detecting what voltage to use, then we need - * to ask the bridge what type (voltage-wise) the card is. - */ - if (slt->pwr.vcc == -1) { - if (sc->flags & PCIC_DF_POWER) { - /* - * Look at the VS[12]# bits on the card. If VS1 is - * clear then the card needs 3.3V instead of 5.0V. - */ - c = sp->getb(sp, PCIC_CDGC); - if ((c & PCIC_VS1STAT) == 0) - slt->pwr.vcc = 33; - else - slt->pwr.vcc = 50; - } - if (sc->flags & PCIC_PD_POWER) { - /* - * The 6710 does it one way, and the '22 and '29 do it - * another. The '22 can also do it the same way as a - * '10 does it, despite what the datasheets say. Some - * laptops with '22 don't seem to have the signals - * wired right for the '29 method to work. The - * laptops that don't work hang solid when the pccard - * memory is accessed. - * - * To allow for both types of laptops, - * hw.pcic.pd6722_vsense will select which one to use. - * 0 - none, 1 - the '10 way and 2 - the '29 way. - */ - controller = sp->controller; - if (controller == PCIC_PD6722) { - switch (pcic_pd6722_vsense) { - case 1: - controller = PCIC_PD6710; - break; - case 2: - controller = PCIC_PD6729; - break; - } - } - - switch (controller) { - case PCIC_PD6710: - c = sp->getb(sp, PCIC_MISC1); - if ((c & PCIC_MISC1_5V_DETECT) == 0) - slt->pwr.vcc = 33; - else - slt->pwr.vcc = 50; - break; - case PCIC_PD6722: /* see above for why we do */ - break; /* none here */ - case PCIC_PD6729: - /* - * VS[12] signals are in slot1's - * extended reg 0xa for both slots. - */ - sp2 = &sc->slots[1]; - sp2->putb(sp2, PCIC_EXT_IND, PCIC_EXT_DATA); - c = sp2->getb(sp2, PCIC_EXTENDED); - if (sp == sp2) /* slot 1 */ - c >>= 2; - if ((c & PCIC_VS1A) == 0) - slt->pwr.vcc = 33; - else - slt->pwr.vcc = 50; - break; - default: - /* I have no idea how to do this for others */ - break; - } - - /* - * Regardless of the above, setting the Auto Power - * Switch Enable appears to help. - */ - reg |= PCIC_APSENA; - } - if (sc->flags & PCIC_RICOH_POWER) { - /* - * The ISA bridge have the 5V/3.3V in register - * 1, bit 7. However, 3.3V cards can only be - * detected if GPI_EN is disabled. - */ - c = sp->getb(sp, PCIC_STATUS); - c2 = sp->getb(sp, PCIC_CDGC); - if ((c & PCIC_RICOH_5VCARD) && (c2 & PCIC_GPI_EN) == 0) - slt->pwr.vcc = 33; - else - slt->pwr.vcc = 50; - } - /* Other power schemes here */ - - if (bootverbose && slt->pwr.vcc != -1) - device_printf(sc->dev, "Autodetected %d.%dV card\n", - slt->pwr.vcc / 10, slt->pwr.vcc %10); - } - if (slt->pwr.vcc == -1) { - if (bootverbose) - device_printf(sc->dev, - "Couldn't autodetect voltage, assuming 5.0V\n"); - dodefault = 1; - slt->pwr.vcc = 50; - } - - /* - * XXX Note: The Vpp controls varies quit a bit between bridge chips - * and the following might not be right in all cases. The Linux - * code and wildboar code bases are more complex. However, most - * applications want vpp == vcc and the following code does appear - * to do that for all bridge sets. - */ - if (slt->pwr.vpp == -1) - slt->pwr.vpp = slt->pwr.vcc; - switch(slt->pwr.vpp) { - default: - return (EINVAL); - case 0: - break; - case 50: - case 33: - reg |= PCIC_VPP_5V; - break; - case 120: - reg |= PCIC_VPP_12V; - break; - } - - if (slt->pwr.vcc) - reg |= PCIC_VCC_ON; /* Turn on Vcc */ - switch(slt->pwr.vcc) { - default: - return (EINVAL); - case 0: - break; - case 33: - /* - * The wildboar code has comments that state that - * the IBM KING controller doesn't support 3.3V - * on the "IBM Smart PC card drive". The code - * intemates that's the only place they have seen - * it used and that there's a boatload of issues - * with it. I'm not even sure this is right because - * the only docs I've been able to find say this is for - * 5V power. Of course, this "doc" is just code comments - * so who knows for sure. - */ - if (sc->flags & PCIC_KING_POWER) { - reg |= PCIC_VCC_5V_KING; - break; - } - if (sc->flags & PCIC_VG_POWER) { - pcic_setb(sp, PCIC_CVSR, PCIC_CVSR_VS); - break; - } - if (sc->flags & PCIC_PD_POWER) { - pcic_setb(sp, PCIC_MISC1, PCIC_MISC1_VCC_33); - break; - } - if (sc->flags & PCIC_RICOH_POWER) { - pcic_setb(sp, PCIC_RICOH_MCR2, PCIC_MCR2_VCC_33); - break; - } - if (sc->flags & PCIC_DF_POWER) - reg |= PCIC_VCC_3V; - break; - case 50: - if (sc->flags & PCIC_KING_POWER) - reg |= PCIC_VCC_5V_KING; - /* - * For all of the variant power schemes for 3.3V go - * ahead and turn off the 3.3V enable bit. For all - * bridges, the setting the Vcc on bit does the rest. - * Note that we don't have to turn off the 3.3V bit - * for the '365 step D since with the reg assigments - * to this point it doesn't get turned on. - */ - if (sc->flags & PCIC_VG_POWER) - pcic_clrb(sp, PCIC_CVSR, PCIC_CVSR_VS); - if (sc->flags & PCIC_PD_POWER) - pcic_clrb(sp, PCIC_MISC1, PCIC_MISC1_VCC_33); - if (sc->flags & PCIC_RICOH_POWER) - pcic_clrb(sp, PCIC_RICOH_MCR2, PCIC_MCR2_VCC_33); - break; - } - sp->putb(sp, PCIC_POWER, reg); - if (bootverbose) - device_printf(sc->dev, "Power applied\n"); - DELAY(300*1000); - if (slt->pwr.vcc) { - reg |= PCIC_OUTENA; - sp->putb(sp, PCIC_POWER, reg); - if (bootverbose) - device_printf(sc->dev, "Output enabled\n"); - DELAY(100*1000); - if (bootverbose) - device_printf(sc->dev, "Settling complete\n"); - } - - /* - * Some chipsets will attempt to preclude us from supplying - * 5.0V to cards that only handle 3.3V. We seem to need to - * try 3.3V to paper over some power handling issues in other - * parts of the system. Maybe the proper detection of 3.3V cards - * now obviates the need for this hack, so put a printf in to - * warn the world about it. - */ - if (!(sp->getb(sp, PCIC_STATUS) & PCIC_POW) && dodefault) { - slt->pwr.vcc = 33; - slt->pwr.vpp = 0; - device_printf(sc->dev, - "Failed at 5.0V. Trying 3.3V. Please report message to mobile@freebsd.org\n"); - return (pcic_power(slt)); - } - if (bootverbose) - printf("Power complete.\n"); - return (0); -} - -/* - * tell the PCIC which irq we want to use. only the following are legal: - * 3, 4, 5, 7, 9, 10, 11, 12, 14, 15. We require the callers of this - * routine to do the check for legality. - */ -static void -pcic_mapirq(struct slot *slt, int irq) -{ - struct pcic_slot *sp = slt->cdata; - - sp->sc->chip->map_irq(sp, irq); -} - -/* - * pcic_reset - Reset the card and enable initial power. This may - * need to be interrupt driven in the future. We should likely turn - * the reset on, DELAY for a period of time < 250ms, turn it off and - * tsleep for a while and check it when we're woken up. I think that - * we're running afoul of the card status interrupt glitching, causing - * an interrupt storm because the card doesn't seem to be able to - * clear this pin while in reset. - */ -static void -pcic_reset(void *chan) -{ - struct slot *slt = chan; - struct pcic_slot *sp = slt->cdata; - - if (bootverbose) - device_printf(sp->sc->dev, "reset %d ", slt->insert_seq); - switch (slt->insert_seq) { - case 0: /* Something funny happended on the way to the pub... */ - if (bootverbose) - printf("\n"); - return; - case 1: /* Assert reset */ - pcic_clrb(sp, PCIC_INT_GEN, PCIC_CARDRESET); - if (bootverbose) - printf("int is %x stat is %x\n", - sp->getb(sp, PCIC_INT_GEN), - sp->getb(sp, PCIC_STATUS)); - slt->insert_seq = 2; - timeout(pcic_reset, (void *)slt, hz/4); - return; - case 2: /* Deassert it again */ - pcic_setb(sp, PCIC_INT_GEN, PCIC_CARDRESET | PCIC_IOCARD); - if (bootverbose) - printf("int is %x stat is %x\n", - sp->getb(sp, PCIC_INT_GEN), - sp->getb(sp, PCIC_STATUS)); - slt->insert_seq = 3; - timeout(pcic_reset, (void *)slt, hz/4); - return; - case 3: /* Wait if card needs more time */ - if (bootverbose) - printf("int is %x stat is %x\n", - sp->getb(sp, PCIC_INT_GEN), - sp->getb(sp, PCIC_STATUS)); - if ((sp->getb(sp, PCIC_STATUS) & PCIC_READY) == 0) { - timeout(pcic_reset, (void *)slt, hz/10); - return; - } - } - slt->insert_seq = 0; - if (sp->controller == PCIC_PD6722 || sp->controller == PCIC_PD6710) { - sp->putb(sp, PCIC_TIME_SETUP0, 0x1); - sp->putb(sp, PCIC_TIME_CMD0, 0x6); - sp->putb(sp, PCIC_TIME_RECOV0, 0x0); - sp->putb(sp, PCIC_TIME_SETUP1, 1); - sp->putb(sp, PCIC_TIME_CMD1, 0xf); - sp->putb(sp, PCIC_TIME_RECOV1, 0); - } - selwakeup(&slt->selp); -} - -/* - * pcic_disable - Disable the slot. I wonder if these operations can - * cause an interrupt we need to acknowledge? XXX - */ -static void -pcic_disable(struct slot *slt) -{ - struct pcic_slot *sp = slt->cdata; - - pcic_clrb(sp, PCIC_INT_GEN, PCIC_CARDTYPE | PCIC_CARDRESET); - pcic_mapirq(slt, 0); - slt->pwr.vcc = slt->pwr.vpp = 0; - pcic_power(slt); -} - -/* - * pcic_resume - Suspend/resume support for PCIC - */ -static void -pcic_resume(struct slot *slt) -{ - struct pcic_slot *sp = slt->cdata; - - pcic_do_mgt_irq(sp, slt->irq); - if (sp->controller == PCIC_PD6722) { - pcic_setb(sp, PCIC_MISC1, PCIC_MISC1_SPEAKER); - pcic_setb(sp, PCIC_MISC2, PCIC_LPDM_EN); - } - if (sp->slt->state != inactive) - pcic_do_stat_delta(sp); -} - -int -pcic_activate_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - int err; - - if (dev != device_get_parent(device_get_parent(child)) || devi == NULL) - return (bus_generic_activate_resource(dev, child, type, - rid, r)); - - switch (type) { - case SYS_RES_IOPORT: { - struct io_desc *ip; - ip = &devi->slt->io[rid]; - if (ip->flags == 0) { - if (rid == 0) - ip->flags = IODF_WS | IODF_16BIT | IODF_CS16; - else - ip->flags = devi->slt->io[0].flags; - } - ip->flags |= IODF_ACTIVE; - ip->start = rman_get_start(r); - ip->size = rman_get_end(r) - rman_get_start(r) + 1; - err = pcic_io(devi->slt, rid); - if (err) - return (err); - break; - } - case SYS_RES_IRQ: - /* - * We actually defer the activation of the IRQ resource - * until the interrupt is registered to avoid stray - * interrupt messages. - */ - break; - case SYS_RES_MEMORY: { - struct mem_desc *mp; - if (rid >= NUM_MEM_WINDOWS) - return (EINVAL); - mp = &devi->slt->mem[rid]; - mp->flags |= MDF_ACTIVE; - mp->start = (caddr_t) rman_get_start(r); - mp->size = rman_get_end(r) - rman_get_start(r) + 1; - err = pcic_memory(devi->slt, rid); - if (err) - return (err); - break; - } - default: - break; - } - err = bus_generic_activate_resource(dev, child, type, rid, r); - return (err); -} - -int -pcic_deactivate_resource(device_t dev, device_t child, int type, int rid, - struct resource *r) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - int err; - - if (dev != device_get_parent(device_get_parent(child)) || devi == NULL) - return (bus_generic_deactivate_resource(dev, child, type, - rid, r)); - - switch (type) { - case SYS_RES_IOPORT: { - struct io_desc *ip = &devi->slt->io[rid]; - ip->flags &= ~IODF_ACTIVE; - err = pcic_io(devi->slt, rid); - if (err) - return (err); - break; - } - case SYS_RES_IRQ: - break; - case SYS_RES_MEMORY: { - struct mem_desc *mp = &devi->slt->mem[rid]; - mp->flags &= ~(MDF_ACTIVE | MDF_ATTR); - err = pcic_memory(devi->slt, rid); - if (err) - return (err); - break; - } - default: - break; - } - err = bus_generic_deactivate_resource(dev, child, type, rid, r); - return (err); -} - -int -pcic_setup_intr(device_t dev, device_t child, struct resource *irq, - int flags, driver_intr_t *intr, void *arg, void **cookiep) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - int err; - - if (((1 << rman_get_start(irq)) & PCIC_INT_MASK_ALLOWED) == 0) { - device_printf(dev, "Hardware does not support irq %ld.\n", - rman_get_start(irq)); - return (EINVAL); - } - - err = bus_generic_setup_intr(dev, child, irq, flags, intr, arg, - cookiep); - if (err == 0) - pcic_mapirq(devi->slt, rman_get_start(irq)); - else - device_printf(dev, "Error %d irq %ld\n", err, - rman_get_start(irq)); - return (err); -} - -int -pcic_teardown_intr(device_t dev, device_t child, struct resource *irq, - void *cookie) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - - pcic_mapirq(devi->slt, 0); - return (bus_generic_teardown_intr(dev, child, irq, cookie)); -} - -int -pcic_set_res_flags(device_t bus, device_t child, int restype, int rid, - u_long value) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - int err = 0; - - switch (restype) { - case SYS_RES_MEMORY: { - struct mem_desc *mp = &devi->slt->mem[rid]; - switch (value) { - case PCCARD_A_MEM_COM: - mp->flags &= ~MDF_ATTR; - break; - case PCCARD_A_MEM_ATTR: - mp->flags |= MDF_ATTR; - break; - case PCCARD_A_MEM_8BIT: - mp->flags &= ~MDF_16BITS; - break; - case PCCARD_A_MEM_16BIT: - mp->flags |= MDF_16BITS; - break; - } - err = pcic_memory(devi->slt, rid); - break; - } - default: - err = EOPNOTSUPP; - } - return (err); -} - -int -pcic_get_res_flags(device_t bus, device_t child, int restype, int rid, - u_long *value) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - int err = 0; - - if (value == 0) - return (ENOMEM); - - switch (restype) { - case SYS_RES_IOPORT: { - struct io_desc *ip = &devi->slt->io[rid]; - *value = ip->flags; - break; - } - case SYS_RES_MEMORY: { - struct mem_desc *mp = &devi->slt->mem[rid]; - *value = mp->flags; - break; - } - default: - err = EOPNOTSUPP; - } - return (err); -} - -int -pcic_set_memory_offset(device_t bus, device_t child, int rid, - u_int32_t offset, u_int32_t *deltap) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - struct mem_desc *mp = &devi->slt->mem[rid]; - - mp->card = offset; - if (deltap) - *deltap = 0; /* XXX BAD XXX */ - return (pcic_memory(devi->slt, rid)); -} - -int -pcic_get_memory_offset(device_t bus, device_t child, int rid, u_int32_t *offset) -{ - struct pccard_devinfo *devi = device_get_ivars(child); - struct mem_desc *mp = &devi->slt->mem[rid]; - - if (offset == 0) - return (ENOMEM); - - *offset = mp->card; - - return (0); -} - -struct resource * -pcic_alloc_resource(device_t dev, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) -{ - struct pcic_softc *sc = device_get_softc(dev); - - /* - * If we're routing via pci, we can share. - */ - if (sc->func_route == pcic_iw_pci && type == SYS_RES_IRQ) { - if (bootverbose) - device_printf(child, "Forcing IRQ to %d\n", sc->irq); - start = end = sc->irq; - flags |= RF_SHAREABLE; - } - - return (bus_generic_alloc_resource(dev, child, type, rid, start, end, - count, flags)); -} - -void -pcic_do_stat_delta(struct pcic_slot *sp) -{ - if ((sp->getb(sp, PCIC_STATUS) & PCIC_CD) != PCIC_CD) - pccard_event(sp->slt, card_removed); - else - pccard_event(sp->slt, card_inserted); -} -/* - * Wrapper function for pcicintr so that signatures match. - */ -void -pcic_isa_intr(void *arg) -{ - pcic_isa_intr1(arg); -} - -/* - * PCIC timer. If the controller doesn't have a free IRQ to use - * or if interrupt steering doesn't work, poll the controller for - * insertion/removal events. - */ -void -pcic_timeout(void *chan) -{ - struct pcic_softc *sc = (struct pcic_softc *) chan; - - if (pcic_isa_intr1(chan) != 0) { - device_printf(sc->dev, - "Static bug detected, ignoring hardware."); - sc->slot_poll = 0; - return; - } - sc->timeout_ch = timeout(sc->slot_poll, chan, hz/2); -} - -/* - * PCIC Interrupt handler. - * Check each slot in turn, and read the card status change - * register. If this is non-zero, then a change has occurred - * on this card, so send an event to the main code. - */ -int -pcic_isa_intr1(void *arg) -{ - int slot, s; - u_int8_t chg; - struct pcic_softc *sc = (struct pcic_softc *) arg; - struct pcic_slot *sp = &sc->slots[0]; - - s = splhigh(); - for (slot = 0; slot < PCIC_CARD_SLOTS; slot++, sp++) { - if (sp->slt == NULL) - continue; - if ((chg = sp->getb(sp, PCIC_STAT_CHG)) != 0) { - /* - * if chg is 0xff, then we know that we've hit - * the famous "static bug" for some desktop - * pcmcia cards. This is caused by static - * discharge frying the poor card's mind and - * it starts return 0xff forever. We return - * an error and stop polling the card. When - * we're interrupt based, we never see this. - * The card just goes away silently. - */ - if (chg == 0xff) { - splx(s); - return (EIO); - } - if (chg & PCIC_CDTCH) - pcic_do_stat_delta(sp); - } - } - splx(s); - return (0); -} - -int -pcic_isa_mapirq(struct pcic_slot *sp, int irq) -{ - irq = host_irq_to_pcic(irq); - if (irq == 0) - pcic_clrb(sp, PCIC_INT_GEN, 0xF); - else - sp->putb(sp, PCIC_INT_GEN, - (sp->getb(sp, PCIC_INT_GEN) & 0xF0) | irq); - return (0); -} diff --git a/sys/bus/pccard/pcic_isa.c b/sys/bus/pccard/pcic_isa.c deleted file mode 100644 index 95a6eb62c2..0000000000 --- a/sys/bus/pccard/pcic_isa.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - * Copyright (c) 2001 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 ``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. - * - * $FreeBSD: src/sys/pccard/pcic_isa.c,v 1.13.2.8 2003/02/26 18:42:00 imp Exp $ - * $DragonFly: src/sys/bus/pccard/Attic/pcic_isa.c,v 1.3 2003/08/07 21:16:46 dillon Exp $ - */ - -#include -#include -#include -#include -#include -#include - -#include "i82365.h" -#include "cardinfo.h" -#include "slot.h" -#include "pcicvar.h" - -/* Get pnp IDs */ -#include -#include -#include "pccardvar.h" -#include "card_if.h" - -static struct isa_pnp_id pcic_ids[] = { - {PCIC_PNP_ACTIONTEC, NULL}, /* AEI0218 */ - {PCIC_PNP_IBM3765, NULL}, /* IBM3765 */ - {PCIC_PNP_82365, NULL}, /* PNP0E00 */ - {PCIC_PNP_CL_PD6720, NULL}, /* PNP0E01 */ - {PCIC_PNP_VLSI_82C146, NULL}, /* PNP0E02 */ - {PCIC_PNP_82365_CARDBUS, NULL}, /* PNP0E03 */ - {PCIC_PNP_SCM_SWAPBOX, NULL}, /* SCM0469 */ - {PCIC_NEC_PC9801_102, NULL}, /* NEC8091 */ - {PCIC_NEC_PC9821RA_E01, NULL}, /* NEC8121 */ - {0} -}; - -static struct { - const char *name; - u_int32_t flags; -} bridges[] = { - { "Intel i82365SL-A/B", PCIC_AB_POWER}, - { "IBM PCIC", PCIC_AB_POWER}, - { "VLSI 82C146", PCIC_AB_POWER}, - { "Cirrus logic 6722", PCIC_PD_POWER}, - { "Cirrus logic 6710", PCIC_PD_POWER}, - { "Vadem 365", PCIC_VG_POWER}, - { "Vadem 465", PCIC_VG_POWER}, - { "Vadem 468", PCIC_VG_POWER}, - { "Vadem 469", PCIC_VG_POWER}, - { "Ricoh RF5C296", PCIC_RICOH_POWER}, - { "Ricoh RF5C396", PCIC_RICOH_POWER}, - { "IBM KING", PCIC_KING_POWER}, - { "Intel i82365SL-DF", PCIC_DF_POWER} -}; - -static pcic_intr_way_t pcic_isa_intr_way; -static pcic_init_t pcic_isa_init; - -struct pcic_chip pcic_isa_chip = { - pcic_isa_intr_way, - pcic_isa_intr_way, - pcic_isa_mapirq, - pcic_isa_init -}; - -/* - * Look for an Intel PCIC (or compatible). - * For each available slot, allocate a PC-CARD slot. - */ -static int -pcic_isa_probe(device_t dev) -{ - int slotnum, validslots = 0; - struct pcic_slot *sp; - struct pcic_slot *sp0; - struct pcic_slot *sp1; - struct pcic_slot spsave; - unsigned char c; - struct resource *r; - int rid; - struct pcic_softc *sc; - int error; - - /* Check isapnp ids */ - error = ISA_PNP_PROBE(device_get_parent(dev), dev, pcic_ids); - if (error == ENXIO) - return (ENXIO); - - if (bus_get_resource_start(dev, SYS_RES_IOPORT, 0) == 0) - bus_set_resource(dev, SYS_RES_IOPORT, 0, PCIC_PORT_0, - PCIC_NPORT); - rid = 0; - r = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE); - if (!r) { - if (bootverbose) - device_printf(dev, "Cannot get I/O range\n"); - return (ENOMEM); - } - - sc = (struct pcic_softc *) device_get_softc(dev); - sc->dev = dev; - sp = &sc->slots[0]; - for (slotnum = 0; slotnum < PCIC_CARD_SLOTS; slotnum++, sp++) { - /* - * Initialise the PCIC slot table. - */ - sp->getb = pcic_getb_io; - sp->putb = pcic_putb_io; - sp->bst = rman_get_bustag(r); - sp->bsh = rman_get_bushandle(r); - sp->offset = slotnum * PCIC_SLOT_SIZE; - sp->controller = -1; - } - - /* - * Prescan for the broken VLSI chips. - * - * According to the Linux PCMCIA code from David Hinds, - * working chipsets return 0x84 from their (correct) ID ports, - * while the broken ones would need to be probed at the new - * offset we set after we assume it's broken. - * - * Note: because of this, we may incorrectly detect a single - * slot vlsi chip as an i82365sl step D. I cannot find a - * datasheet for the affected chip, so that's the best we can - * do for now. - */ - sp0 = &sc->slots[0]; - sp1 = &sc->slots[1]; - if (sp0->getb(sp0, PCIC_ID_REV) == PCIC_VLSI82C146 && - sp1->getb(sp1, PCIC_ID_REV) != PCIC_VLSI82C146) { - spsave = *sp1; - sp1->bsh += 4; - sp1->offset = PCIC_SLOT_SIZE << 1; - if (sp1->getb(sp1, PCIC_ID_REV) != PCIC_VLSI82C146) { - *sp1 = spsave; - } else { - sp0->controller = PCIC_VLSI; - sp1->controller = PCIC_VLSI; - } - } - - /* - * Look for normal chipsets here. - */ - sp = &sc->slots[0]; - for (slotnum = 0; slotnum < PCIC_CARD_SLOTS; slotnum++, sp++) { - /* - * see if there's a PCMCIA controller here - * Intel PCMCIA controllers use 0x82 and 0x83 - * IBM clone chips use 0x88 and 0x89, apparently - */ - c = sp->getb(sp, PCIC_ID_REV); - sp->revision = -1; - switch(c) { - /* - * 82365 or clones. - */ - case PCIC_INTEL0: - case PCIC_INTEL1: - sp->controller = PCIC_I82365; - sp->revision = c & 1; - /* - * Check for Vadem chips by unlocking their extra - * registers and looking for valid ID. Bit 3 in - * the ID register is normally 0, except when - * PCIC_VADEMREV is set. Other bridges appear - * to ignore this frobbing. - */ - bus_space_write_1(sp->bst, sp->bsh, PCIC_INDEX, 0x0E); - bus_space_write_1(sp->bst, sp->bsh, PCIC_INDEX, 0x37); - pcic_setb(sp, PCIC_VMISC, PCIC_VADEMREV); - c = sp->getb(sp, PCIC_ID_REV); - if (c & 0x08) { - switch (sp->revision = c & 7) { - case 1: - sp->controller = PCIC_VG365; - break; - case 2: - sp->controller = PCIC_VG465; - break; - case 3: - sp->controller = PCIC_VG468; - break; - default: - sp->controller = PCIC_VG469; - break; - } - pcic_clrb(sp, PCIC_VMISC, PCIC_VADEMREV); - } - - /* - * Check for RICOH RF5C[23]96 PCMCIA Controller - */ - c = sp->getb(sp, PCIC_RICOH_ID); - if (c == PCIC_RID_396) - sp->controller = PCIC_RF5C396; - else if (c == PCIC_RID_296) - sp->controller = PCIC_RF5C296; - - break; - /* - * Intel i82365sl-DF step or maybe a vlsi 82c146 - * we detected the vlsi case earlier, so if the controller - * isn't set, we know it is an i82365sl step D. - */ - case PCIC_INTEL2: - if (sp->controller == -1) - sp->controller = PCIC_I82365SL_DF; - break; - case PCIC_IBM1: - case PCIC_IBM2: - sp->controller = PCIC_IBM; - sp->revision = c & 1; - break; - case PCIC_IBM3: - sp->controller = PCIC_IBM_KING; - sp->revision = c & 1; - break; - default: - continue; - } - /* - * Check for Cirrus logic chips. - */ - sp->putb(sp, PCIC_CLCHIP, 0); - c = sp->getb(sp, PCIC_CLCHIP); - if ((c & PCIC_CLC_TOGGLE) == PCIC_CLC_TOGGLE) { - c = sp->getb(sp, PCIC_CLCHIP); - if ((c & PCIC_CLC_TOGGLE) == 0) { - if (c & PCIC_CLC_DUAL) - sp->controller = PCIC_PD6722; - else - sp->controller = PCIC_PD6710; - sp->revision = 8 - ((c & 0x1F) >> 2); - } - } - device_set_desc(dev, bridges[(int) sp->controller].name); - sc->flags = bridges[(int) sp->controller].flags; - /* - * OK it seems we have a PCIC or lookalike. - * Allocate a slot and initialise the data structures. - */ - validslots++; - sp->slt = (struct slot *) 1; - /* - * Modem cards send the speaker audio (dialing noises) - * to the host's speaker. Cirrus Logic PCIC chips must - * enable this. There is also a Low Power Dynamic Mode bit - * that claims to reduce power consumption by 30%, so - * enable it and hope for the best. - */ - if (sp->controller == PCIC_PD6722) { - pcic_setb(sp, PCIC_MISC1, PCIC_MISC1_SPEAKER); - pcic_setb(sp, PCIC_MISC2, PCIC_LPDM_EN); - } - } - bus_release_resource(dev, SYS_RES_IOPORT, rid, r); - return (validslots ? 0 : ENXIO); -} - -static int -pcic_isa_attach(device_t dev) -{ - struct pcic_softc *sc; - int rid; - struct resource *r; - int irq = 0; - int error; - - sc = device_get_softc(dev); - rid = 0; - r = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE); - if (!r) { - pcic_dealloc(dev); - return (ENXIO); - } - sc->iorid = rid; - sc->iores = r; - sc->csc_route = pcic_iw_isa; - sc->func_route = pcic_iw_isa; - sc->chip = &pcic_isa_chip; - - rid = 0; - r = NULL; - r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, RF_ACTIVE); - if (r == NULL && pcic_override_irq != 0) { - irq = pcic_override_irq; - r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, irq, irq, 1, - RF_ACTIVE); - } - if (r && ((1 << (rman_get_start(r))) & PCIC_INT_MASK_ALLOWED) == 0) { - device_printf(dev, - "Hardware does not support irq %d, trying polling.\n", - irq); - bus_release_resource(dev, SYS_RES_IRQ, rid, r); - irq = 0; - r = NULL; - } - sc->irqrid = rid; - sc->irqres = r; - irq = 0; - if (r != NULL) { - error = bus_setup_intr(dev, r, INTR_TYPE_MISC, - pcic_isa_intr, (void *) sc, &sc->ih); - if (error) { - pcic_dealloc(dev); - return (error); - } - irq = rman_get_start(r); - device_printf(dev, "management irq %d\n", irq); - } - sc->irq = irq; - if (irq == 0) { - sc->slot_poll = pcic_timeout; - sc->timeout_ch = timeout(sc->slot_poll, (void *) sc, hz/2); - device_printf(dev, "Polling mode\n"); - } - - return (pcic_attach(dev)); -} - -/* - * ISA cards can only do ISA interrupts. There's no need to do - * anything but check args for sanity. - */ -static int -pcic_isa_intr_way(struct pcic_slot *sp, enum pcic_intr_way iw) -{ - if (iw != pcic_iw_isa) - return (EINVAL); - return (0); -} - -/* - * No speicial initialization is necesary for ISA cards. - */ -static void -pcic_isa_init(device_t dev) -{ -} - -static device_method_t pcic_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, pcic_isa_probe), - DEVMETHOD(device_attach, pcic_isa_attach), - DEVMETHOD(device_detach, bus_generic_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_alloc_resource, pcic_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - DEVMETHOD(bus_activate_resource, pcic_activate_resource), - DEVMETHOD(bus_deactivate_resource, pcic_deactivate_resource), - DEVMETHOD(bus_setup_intr, pcic_setup_intr), - DEVMETHOD(bus_teardown_intr, pcic_teardown_intr), - - /* Card interface */ - DEVMETHOD(card_set_res_flags, pcic_set_res_flags), - DEVMETHOD(card_get_res_flags, pcic_get_res_flags), - DEVMETHOD(card_set_memory_offset, pcic_set_memory_offset), - DEVMETHOD(card_get_memory_offset, pcic_get_memory_offset), - - { 0, 0 } -}; - -static driver_t pcic_driver = { - "pcic", - pcic_methods, - sizeof(struct pcic_softc) -}; - -DRIVER_MODULE(pcic, isa, pcic_driver, pcic_devclass, 0, 0); diff --git a/sys/bus/pccard/pcic_pci.c b/sys/bus/pccard/pcic_pci.c deleted file mode 100644 index c94552a1a7..0000000000 --- a/sys/bus/pccard/pcic_pci.c +++ /dev/null @@ -1,1578 +0,0 @@ -/* - * Copyright (c) 2000, 2002 M. Warner Losh. All Rights Reserved. - * Copyright (c) 1997 Ted Faber 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 immediately at the beginning of the file, without modification, - * 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. Absolutely no warranty of function or purpose is made by the author - * Ted Faber. - * - * 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. - * - * $FreeBSD: src/sys/pccard/pcic_pci.c,v 1.54.2.22 2003/02/26 18:42:00 imp Exp $ - * $DragonFly: src/sys/bus/pccard/Attic/pcic_pci.c,v 1.3 2003/08/07 21:16:46 dillon Exp $ - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "pcic_pci.h" -#include "i82365.h" -#include "cardinfo.h" -#include "slot.h" -#include "pcicvar.h" - -#include -#include "card_if.h" - -#define PRVERB(x) do { \ - if (bootverbose) { device_printf x; } \ - } while (0) - -static int pcic_pci_get_memory(device_t dev); - -SYSCTL_DECL(_hw_pcic); - -static int pcic_ignore_function_1 = 0; -TUNABLE_INT("hw.pcic.ignore_function_1", &pcic_ignore_function_1); -SYSCTL_INT(_hw_pcic, OID_AUTO, ignore_function_1, CTLFLAG_RD, - &pcic_ignore_function_1, 0, - "When set, driver ignores pci function 1 of the bridge. This option\n\ -is obsolete and will be deleted before FreeBSD 4.8."); - -/* - * The following should be a hint, so we can do it on a per device - * instance, but this is convenient. Do not set this unless pci - * routing doesn't work. It is purposely vague and undocumented - * at the moment. Sadly, this seems to be needed way too often. - */ -static int pcic_intr_path = (int)pcic_iw_pci; -TUNABLE_INT("hw.pcic.intr_path", &pcic_intr_path); -SYSCTL_INT(_hw_pcic, OID_AUTO, intr_path, CTLFLAG_RD, &pcic_intr_path, 0, - "Which path to send the interrupts over. Normally interrupts for\n\ -cardbus bridges are routed over the PCI bus (2). However, some laptops\n\ -will hang when using PCI interrupts due to bugs in this code. Those\n\ -bugs can be worked around by forcings ISA interrupts (1)."); - -static int pcic_init_routing = 0; -TUNABLE_INT("hw.pcic.init_routing", &pcic_init_routing); -SYSCTL_INT(_hw_pcic, OID_AUTO, init_routing, CTLFLAG_RD, - &pcic_init_routing, 0, - "Force the interrupt routing to be initialized on those bridges where\n\ -doing so will cause probelms. This is very rare and generally is not\n\ -needed. The default of 0 is almost always appropriate. Only set to 1 if\n\ -instructed to do so for debugging. Only TI bridges are affected by this\n\ -option, and what the code does is of dubious value. This option is obsolete\n\ -and will be deleted before FreeBSD 4.8."); - -static int pcic_ignore_pci = 0; -TUNABLE_INT("hw.pcic.ignore_pci", &pcic_ignore_pci); -SYSCTL_INT(_hw_pcic, OID_AUTO, ignore_pci, CTLFLAG_RD, - &pcic_ignore_pci, 0, - "When set, driver ignores pci cardbus bridges it would otherwise claim.\n\ -Generally speaking, this option is not needed for anything other than as an\n\ -aid in debugging."); - -static int pcic_pd6729_intr_path = (int)pcic_iw_isa; -TUNABLE_INT("hw.pcic.pd6729_intr_path", &pcic_pd6729_intr_path); -SYSCTL_INT(_hw_pcic, OID_AUTO, pd6729_intr_path, CTLFLAG_RD, - &pcic_pd6729_intr_path, 0, - "Determine the interrupt path or method for Cirrus Logic PD6729 and\n\ -similar I/O space based pcmcia bridge. Chips on a PCI expansion card need\n\ -a value of 2, while chips installed in a laptop need a value of 1 (which is\n\ -also the default). This is similar to hw.pcic.intr_path, but separate so\n\ -that it can default to ISA when intr_path defaults to PCI."); - -static int pcic_ti12xx_enable_pci_clock = 0; -TUNABLE_INT("hw.pcic.ti12xx_enable_pci_clock", &pcic_ti12xx_enable_pci_clock); -SYSCTL_INT(_hw_pcic, OID_AUTO, ti12xx_enable_pci_clock, CTLFLAG_RD, - &pcic_ti12xx_enable_pci_clock, 0, - "Some TI-12xx parts need to have the PCI clock enabled. These designs do\n\ -not provide a clock themselves. Most of the reference boards have the\n\ -required oscillator parts, so the number of machines that needs this to be\n\ -set is vanishingly small."); - -static void pcic_pci_cardbus_init(device_t); -static pcic_intr_way_t pcic_pci_gen_func; -static pcic_intr_way_t pcic_pci_gen_csc; -static pcic_intr_mapirq_t pcic_pci_gen_mapirq; - -static pcic_intr_way_t pcic_pci_oz67xx_func; -static pcic_intr_way_t pcic_pci_oz67xx_csc; -static pcic_init_t pcic_pci_oz67xx_init; - -static pcic_intr_way_t pcic_pci_oz68xx_func; -static pcic_intr_way_t pcic_pci_oz68xx_csc; -static pcic_init_t pcic_pci_oz68xx_init; - -static pcic_intr_way_t pcic_pci_pd6729_func; -static pcic_intr_way_t pcic_pci_pd6729_csc; -static pcic_init_t pcic_pci_pd6729_init; - -static pcic_intr_way_t pcic_pci_pd68xx_func; -static pcic_intr_way_t pcic_pci_pd68xx_csc; -static pcic_init_t pcic_pci_pd68xx_init; - -static pcic_intr_way_t pcic_pci_ricoh_func; -static pcic_intr_way_t pcic_pci_ricoh_csc; -static pcic_init_t pcic_pci_ricoh_init; - -static pcic_intr_way_t pcic_pci_ti113x_func; -static pcic_intr_way_t pcic_pci_ti113x_csc; -static pcic_init_t pcic_pci_ti_init; - -static pcic_intr_way_t pcic_pci_ti12xx_func; -static pcic_intr_way_t pcic_pci_ti12xx_csc; - -static pcic_intr_way_t pcic_pci_topic_func; -static pcic_intr_way_t pcic_pci_topic_csc; -static pcic_init_t pcic_pci_topic_init; - -static struct pcic_chip pcic_pci_oz67xx_chip = { - pcic_pci_oz67xx_func, - pcic_pci_oz67xx_csc, - pcic_pci_gen_mapirq, - pcic_pci_oz67xx_init -}; - -static struct pcic_chip pcic_pci_oz68xx_chip = { - pcic_pci_oz68xx_func, - pcic_pci_oz68xx_csc, - pcic_pci_gen_mapirq, - pcic_pci_oz68xx_init -}; - -static struct pcic_chip pcic_pci_pd6729_chip = { - pcic_pci_pd6729_func, - pcic_pci_pd6729_csc, - pcic_pci_gen_mapirq, - pcic_pci_pd6729_init -}; - -static struct pcic_chip pcic_pci_pd68xx_chip = { - pcic_pci_pd68xx_func, - pcic_pci_pd68xx_csc, - pcic_pci_gen_mapirq, - pcic_pci_pd68xx_init -}; - -static struct pcic_chip pcic_pci_ricoh_chip = { - pcic_pci_ricoh_func, - pcic_pci_ricoh_csc, - pcic_pci_gen_mapirq, - pcic_pci_ricoh_init -}; - -static struct pcic_chip pcic_pci_ti113x_chip = { - pcic_pci_ti113x_func, - pcic_pci_ti113x_csc, - pcic_pci_gen_mapirq, - pcic_pci_ti_init -}; - -static struct pcic_chip pcic_pci_ti12xx_chip = { - pcic_pci_ti12xx_func, - pcic_pci_ti12xx_csc, - pcic_pci_gen_mapirq, - pcic_pci_ti_init -}; - -static struct pcic_chip pcic_pci_topic_chip = { - pcic_pci_topic_func, - pcic_pci_topic_csc, - pcic_pci_gen_mapirq, - pcic_pci_topic_init -}; - -static struct pcic_chip pcic_pci_generic_chip = { - pcic_pci_gen_func, - pcic_pci_gen_csc, - pcic_pci_gen_mapirq, - pcic_pci_cardbus_init -}; - -/* Chipset specific flags */ -#define TI_NO_MFUNC 0x10000 - -struct pcic_pci_table -{ - u_int32_t devid; - const char *descr; - int type; - u_int32_t flags; - struct pcic_chip *chip; -} pcic_pci_devs[] = { - { PCIC_ID_OMEGA_82C094, "Omega 82C094G", - PCIC_I82365, PCIC_DF_POWER, &pcic_pci_pd6729_chip }, - { PCIC_ID_CLPD6729, "Cirrus Logic PD6729/6730 PCI-PCMCIA Bridge", - PCIC_PD6729, PCIC_PD_POWER, &pcic_pci_pd6729_chip }, - { PCIC_ID_CLPD6832, "Cirrus Logic PD6832 PCI-CardBus Bridge", - PCIC_PD673X, PCIC_CARDBUS_POWER, &pcic_pci_pd68xx_chip }, - { PCIC_ID_CLPD6833, "Cirrus Logic PD6833 PCI-CardBus Bridge", - PCIC_PD673X, PCIC_CARDBUS_POWER, &pcic_pci_pd68xx_chip }, - { PCIC_ID_CLPD6834, "Cirrus Logic PD6834 PCI-CardBus Bridge", - PCIC_PD673X, PCIC_CARDBUS_POWER, &pcic_pci_pd68xx_chip }, - { PCIC_ID_OZ6729, "O2micro OZ6729 PC-Card Bridge", - PCIC_I82365, PCIC_AB_POWER, &pcic_pci_oz67xx_chip }, - { PCIC_ID_OZ6730, "O2micro OZ6730 PC-Card Bridge", - PCIC_I82365, PCIC_AB_POWER, &pcic_pci_oz67xx_chip }, - { PCIC_ID_OZ6832, "O2micro 6832/6833 PCI-Cardbus Bridge", - PCIC_I82365, PCIC_CARDBUS_POWER, &pcic_pci_oz68xx_chip }, - { PCIC_ID_OZ6860, "O2micro 6836/6860 PCI-Cardbus Bridge", - PCIC_I82365, PCIC_CARDBUS_POWER, &pcic_pci_oz68xx_chip }, - { PCIC_ID_OZ6872, "O2micro 6812/6872 PCI-Cardbus Bridge", - PCIC_I82365, PCIC_CARDBUS_POWER, &pcic_pci_oz68xx_chip }, - { PCIC_ID_OZ6912, "O2micro 6912 PCI-Cardbus Bridge", - PCIC_I82365, PCIC_CARDBUS_POWER, &pcic_pci_oz68xx_chip }, - { PCIC_ID_OZ6922, "O2micro 6922 PCI-Cardbus Bridge", - PCIC_I82365, PCIC_AB_POWER, &pcic_pci_oz68xx_chip }, - { PCIC_ID_OZ6933, "O2micro 6933 PCI-Cardbus Bridge", - PCIC_I82365, PCIC_AB_POWER, &pcic_pci_oz68xx_chip }, - { PCIC_ID_RICOH_RL5C465, "Ricoh RL5C465 PCI-CardBus Bridge", - PCIC_RF5C296, PCIC_CARDBUS_POWER, &pcic_pci_ricoh_chip }, - { PCIC_ID_RICOH_RL5C475, "Ricoh RL5C475 PCI-CardBus Bridge", - PCIC_RF5C296, PCIC_CARDBUS_POWER, &pcic_pci_ricoh_chip }, - { PCIC_ID_RICOH_RL5C476, "Ricoh RL5C476 PCI-CardBus Bridge", - PCIC_RF5C296, PCIC_CARDBUS_POWER, &pcic_pci_ricoh_chip }, - { PCIC_ID_RICOH_RL5C477, "Ricoh RL5C477 PCI-CardBus Bridge", - PCIC_RF5C296, PCIC_CARDBUS_POWER, &pcic_pci_ricoh_chip }, - { PCIC_ID_RICOH_RL5C478, "Ricoh RL5C478 PCI-CardBus Bridge", - PCIC_RF5C296, PCIC_CARDBUS_POWER, &pcic_pci_ricoh_chip }, - { PCIC_ID_SMC_34C90, "SMC 34C90 PCI-CardBus Bridge", - PCIC_RF5C296, PCIC_CARDBUS_POWER, &pcic_pci_generic_chip }, - { PCIC_ID_TI1031, "TI PCI-1031 PCI-PCMCIA Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti113x_chip }, - { PCIC_ID_TI1130, "TI PCI-1130 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti113x_chip }, - { PCIC_ID_TI1131, "TI PCI-1131 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti113x_chip }, - { PCIC_ID_TI1210, "TI PCI-1210 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1211, "TI PCI-1211 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1220, "TI PCI-1220 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1221, "TI PCI-1221 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1225, "TI PCI-1225 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1250, "TI PCI-1250 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER | TI_NO_MFUNC, - &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1251, "TI PCI-1251 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER | TI_NO_MFUNC, - &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1251B, "TI PCI-1251B PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER | TI_NO_MFUNC, - &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1260, "TI PCI-1260 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1260B, "TI PCI-1260B PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1410, "TI PCI-1410 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1420, "TI PCI-1420 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1421, "TI PCI-1421 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1450, "TI PCI-1450 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER | TI_NO_MFUNC, - &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1451, "TI PCI-1451 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1510, "TI PCI-1510 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI1520, "TI PCI-1520 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI4410, "TI PCI-4410 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI4450, "TI PCI-4450 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI4451, "TI PCI-4451 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TI4510, "TI PCI-4510 PCI-CardBus Bridge", - PCIC_I82365SL_DF, PCIC_CARDBUS_POWER, &pcic_pci_ti12xx_chip }, - { PCIC_ID_TOPIC95, "Toshiba ToPIC95 PCI-CardBus Bridge", - PCIC_I82365, PCIC_CARDBUS_POWER, &pcic_pci_topic_chip }, - { PCIC_ID_TOPIC95B, "Toshiba ToPIC95B PCI-CardBus Bridge", - PCIC_I82365, PCIC_CARDBUS_POWER, &pcic_pci_topic_chip }, - { PCIC_ID_TOPIC97, "Toshiba ToPIC97 PCI-CardBus Bridge", - PCIC_I82365, PCIC_CARDBUS_POWER, &pcic_pci_topic_chip }, - { PCIC_ID_TOPIC100, "Toshiba ToPIC100 PCI-CardBus Bridge", - PCIC_I82365, PCIC_CARDBUS_POWER, &pcic_pci_topic_chip }, - { 0, NULL, 0, 0, NULL } -}; - -/* - * Read a register from the PCIC. - */ -static unsigned char -pcic_pci_getb2(struct pcic_slot *sp, int reg) -{ - return (bus_space_read_1(sp->bst, sp->bsh, sp->offset + reg)); -} - -/* - * Write a register on the PCIC - */ -static void -pcic_pci_putb2(struct pcic_slot *sp, int reg, unsigned char val) -{ - bus_space_write_1(sp->bst, sp->bsh, sp->offset + reg, val); -} - -/* - * lookup inside the table - */ -static struct pcic_pci_table * -pcic_pci_lookup(u_int32_t devid, struct pcic_pci_table *tbl) -{ - while (tbl->devid) { - if (tbl->devid == devid) - return (tbl); - tbl++; - } - return (NULL); -} - -/* - * The standard way to control fuction interrupts is via bit 7 in the BCR - * register. Some data sheets indicate that this is just for "intterupts" - * while others are clear that it is for function interrupts. When this - * bit is set, function interrupts are routed via the ExCA register. When - * this bit is clear, they are routed via the PCI bus, usually via the int - * in the INTPIN register. - */ -static int -pcic_pci_gen_func(struct pcic_slot *sp, enum pcic_intr_way way) -{ - u_int16_t bcr; - - bcr = pci_read_config(sp->sc->dev, CB_PCI_BRIDGE_CTRL, 2); - if (way == pcic_iw_pci) - bcr &= ~CB_BCR_INT_EXCA; - else - bcr |= CB_BCR_INT_EXCA; - pci_write_config(sp->sc->dev, CB_PCI_BRIDGE_CTRL, bcr, 2); - return (0); -} - -static int -pcic_pci_gen_csc(struct pcic_slot *sp, enum pcic_intr_way way) -{ - return (0); -} - -/* - * The O2micro OZ67xx chips functions. - */ -static int -pcic_pci_oz67xx_func(struct pcic_slot *sp, enum pcic_intr_way way) -{ - return (pcic_pci_gen_func(sp, way)); -} - -static int -pcic_pci_oz67xx_csc(struct pcic_slot *sp, enum pcic_intr_way way) -{ - /* - * Need datasheet to find out what's going on. However, the - * 68xx datasheets are so vague that it is hard to know what - * the right thing to do is. - */ - /* XXX */ - return (0); -} - - -static void -pcic_pci_oz67xx_init(device_t dev) -{ - device_printf(dev, "Warning: O2micro OZ67xx chips may not work\n"); - pcic_pci_cardbus_init(dev); -} - -/* - * The O2micro OZ68xx chips functions. - */ -static int -pcic_pci_oz68xx_func(struct pcic_slot *sp, enum pcic_intr_way way) -{ - return (pcic_pci_gen_func(sp, way)); -} - -static int -pcic_pci_oz68xx_csc(struct pcic_slot *sp, enum pcic_intr_way way) -{ - /* - * The 68xx datasheets make it hard to know what the right thing - * to do here is. We do what we know, which is nothing, and - * hope for the best. - */ - /* XXX */ - return (0); -} - -static void -pcic_pci_oz68xx_init(device_t dev) -{ - /* - * This is almost certainly incomplete. - */ - device_printf(dev, "Warning: O2micro OZ68xx chips may not work\n"); - pcic_pci_cardbus_init(dev); -} - -/* - * The Cirrus Logic PD6729/30. These are weird beasts, so be careful. - * They are ISA parts glued to the PCI bus and do not follow the yenta - * specification for cardbus bridges. They seem to be similar to the - * intel parts that were also cloned by o2micro and maybe others, but - * they are so much more common that the author doesn't have experience - * with them to know for sure. - */ -static int -pcic_pci_pd6729_func(struct pcic_slot *sp, enum pcic_intr_way way) -{ - /* - * For pci interrupts, we need to set bit 3 of extension register - * 3 to 1. For ISA interrupts, we need to clear it. - */ - sp->putb(sp, PCIC_EXT_IND, PCIC_EXTCTRL1); - if (way == pcic_iw_pci) - pcic_setb(sp, PCIC_EXTENDED, PCIC_EC1_CARD_IRQ_INV); - else - pcic_clrb(sp, PCIC_EXTENDED, PCIC_EC1_CARD_IRQ_INV); - - return (0); -} - -static int -pcic_pci_pd6729_csc(struct pcic_slot *sp, enum pcic_intr_way way) -{ - /* - * For pci interrupts, we need to set bit 4 of extension register - * 3 to 1. For ISA interrupts, we need to clear it. - */ - sp->putb(sp, PCIC_EXT_IND, PCIC_EXTCTRL1); - if (way == pcic_iw_pci) - pcic_setb(sp, PCIC_EXTENDED, PCIC_EC1_CSC_IRQ_INV); - else - pcic_clrb(sp, PCIC_EXTENDED, PCIC_EC1_CSC_IRQ_INV); - - return (0); -} - - -static void -pcic_pci_pd6729_init(device_t dev) -{ - struct pcic_softc *sc = device_get_softc(dev); - - /* - * Tell the chip to do its routing thing. - */ - pcic_pci_pd6729_func(&sc->slots[0], sc->func_route); - pcic_pci_pd6729_csc(&sc->slots[0], sc->csc_route); -} - -/* - * Set up the CL-PD6832, 6833 and 6834. - */ -static int -pcic_pci_pd68xx_func(struct pcic_slot *sp, enum pcic_intr_way way) -{ - return (pcic_pci_gen_func(sp, way)); -} - -static int -pcic_pci_pd68xx_csc(struct pcic_slot *sp, enum pcic_intr_way way) -{ - struct pcic_softc *sc = sp->sc; - device_t dev = sc->dev; - u_int32_t device_id = pci_get_devid(dev); - u_long bcr; - u_long cm1; - - /* - * CLPD6832 management interrupt enable bit is bit 11 - * (MGMT_IRQ_ENA) in bridge control register(offset 0x3d). - * When on, card status interrupts are ISA controlled by - * the ExCA register 0x05. - * - * The CLPD6833 does things differently. It doesn't have bit - * 11 in the bridge control register. Instead, this - * functionality appears to be in the "Configuration - * Miscellaneous 1" register bit 1. - * - * I'm assuming that the CLPD6834 does things like the '33 - */ - if (device_id == PCIC_ID_CLPD6832) { - bcr = pci_read_config(dev, CB_PCI_BRIDGE_CTRL, 2); - if (way == pcic_iw_pci) - bcr &= ~CLPD6832_BCR_MGMT_IRQ_ENA; - else - bcr |= CLPD6832_BCR_MGMT_IRQ_ENA; - pci_write_config(dev, CB_PCI_BRIDGE_CTRL, bcr, 2); - } - if (device_id != PCIC_ID_CLPD6832) { - cm1 = pci_read_config(dev, CLPD6833_CFG_MISC_1, 4); - if (way == pcic_iw_pci) - cm1 &= ~CLPD6833_CM1_MGMT_EXCA_ENA; - else - cm1 |= CLPD6833_CM1_MGMT_EXCA_ENA; - pci_write_config(dev, CLPD6833_CFG_MISC_1, cm1, 4); - } - return (0); -} - -static void -pcic_pci_pd68xx_init(device_t dev) -{ - pcic_pci_cardbus_init(dev); -} - -static int -pcic_pci_ricoh_func(struct pcic_slot *sp, enum pcic_intr_way way) -{ - return (pcic_pci_gen_func(sp, way)); -} - -static int -pcic_pci_ricoh_csc(struct pcic_slot *sp, enum pcic_intr_way way) -{ - struct pcic_softc *sc = sp->sc; - device_t dev = sc->dev; - u_int16_t mcr2; - - /* - * For CSC interrupts via ISA, we can't do that exactly. - * However, we can disable INT# routing, which is usually what - * we want. This is bit 7 in the field. Note, bit 6 looks - * interesting, but appears to be unnecessary. - */ - mcr2 = pci_read_config(dev, R5C47X_MISC_CONTROL_REGISTER_2, 2); - if (way == pcic_iw_pci) - mcr2 &= ~R5C47X_MCR2_CSC_TO_INTX_DISABLE; - else - mcr2 |= R5C47X_MCR2_CSC_TO_INTX_DISABLE; - pci_write_config(dev, R5C47X_MISC_CONTROL_REGISTER_2, mcr2, 2); - - return (0); -} - -static void -pcic_pci_ricoh_init(device_t dev) -{ - u_int16_t brgcntl; - u_int32_t device_id = pci_get_devid(dev); - - switch (device_id) { - case PCIC_ID_RICOH_RL5C465: - case PCIC_ID_RICOH_RL5C466: - /* - * Ricoh chips have a legacy bridge enable different than most - * Code cribbed from NEWBUS's bridge code since I can't find a - * datasheet for them that has register definitions. - */ - brgcntl = pci_read_config(dev, CB_PCI_BRIDGE_CTRL, 2); - brgcntl &= ~(CB_BCR_RL_3E2_EN | CB_BCR_RL_3E0_EN); - pci_write_config(dev, CB_PCI_BRIDGE_CTRL, brgcntl, 2); - break; - } - pcic_pci_cardbus_init(dev); -} - -/* - * TI 1030, 1130, and 1131. - */ -static int -pcic_pci_ti113x_func(struct pcic_slot *sp, enum pcic_intr_way way) -{ - u_int32_t cardcntl; - device_t dev = sp->sc->dev; - - /* - * The TI-1130 (and 1030 and 1131) have a different interrupt - * routing control than the newer chips. assume we're not - * routing either csc or func interrupts via PCI, but enable - * as necessary when we find someone uses PCI interrupts. In - * order to get any pci interrupts, PCI_IRQ_ENA (bit 5) must - * be set. If either PCI_IREQ (bit 4) or PCI_CSC (bit 3) are - * set, then set bit 5 at the same time, since setting them - * enables the PCI interrupt routing. - * - * It also appears necessary to set the function routing bit - * in the bridge control register, but cardbus_init does that - * for us. - */ - cardcntl = pci_read_config(dev, TI113X_PCI_CARD_CONTROL, 1); - if (way == pcic_iw_pci) - cardcntl |= TI113X_CARDCNTL_PCI_IREQ; - else - cardcntl &= ~TI113X_CARDCNTL_PCI_IREQ; - if (cardcntl & (TI113X_CARDCNTL_PCI_IREQ | TI113X_CARDCNTL_PCI_CSC)) - cardcntl |= TI113X_CARDCNTL_PCI_IRQ_ENA; - else - cardcntl &= ~TI113X_CARDCNTL_PCI_IRQ_ENA; - pci_write_config(dev, TI113X_PCI_CARD_CONTROL, cardcntl, 1); - - return (pcic_pci_gen_func(sp, way)); -} - -static int -pcic_pci_ti113x_csc(struct pcic_slot *sp, enum pcic_intr_way way) -{ - u_int32_t cardcntl; - device_t dev = sp->sc->dev; - - /* - * The TI-1130 (and 1030 and 1131) have a different interrupt - * routing control than the newer cards. assume we're not - * routing PCI, but enable as necessary when we find someone - * uses PCI interrupts. In order to get any pci interrupts, - * PCI_IRQ_ENA (bit 5) must be set. If either PCI_IREQ (bit - * 4) or PCI_CSC (bit 3) are set, then set bit 5 at the same - * time, since setting them enables the PCI interrupt routing. - * - * It also appears necessary to set the function routing bit - * in the bridge control register, but cardbus_init does that - * for us. - */ - cardcntl = pci_read_config(dev, TI113X_PCI_CARD_CONTROL, 1); - if (way == pcic_iw_pci) - cardcntl |= TI113X_CARDCNTL_PCI_CSC; - else - cardcntl &= ~TI113X_CARDCNTL_PCI_CSC; - if (cardcntl & (TI113X_CARDCNTL_PCI_IREQ | TI113X_CARDCNTL_PCI_CSC)) - cardcntl |= TI113X_CARDCNTL_PCI_IRQ_ENA; - else - cardcntl &= ~TI113X_CARDCNTL_PCI_IRQ_ENA; - pci_write_config(dev, TI113X_PCI_CARD_CONTROL, cardcntl, 1); - - return (0); -} - -static int -pcic_pci_ti12xx_func(struct pcic_slot *sp, enum pcic_intr_way way) -{ - u_int32_t syscntl, devcntl, cardcntl, mfunc; - device_t dev = sp->sc->dev; - - syscntl = pci_read_config(dev, TI113X_PCI_SYSTEM_CONTROL, 4); - devcntl = pci_read_config(dev, TI113X_PCI_DEVICE_CONTROL, 1); - cardcntl = pci_read_config(dev, TI113X_PCI_CARD_CONTROL, 1); - - /* - * Special code for the Orinoco cards (and a few others). They - * seem to need this special code to make them work only over pci - * interrupts. Sadly, doing this code also causes problems for - * many laptops, so we have to make it controlled by a tunable. - * Actually, experience has shown that this rarely, if ever, - * helps. - */ - if (way == pcic_iw_pci) { - /* - * pcic_init_routing seems to do nothing useful towards - * fixing the hang problems. I plan on removing it in - * 4.8 or so. - */ - if (pcic_init_routing) { - devcntl &= ~TI113X_DEVCNTL_INTR_MASK; - pci_write_config(dev, TI113X_PCI_DEVICE_CONTROL, - devcntl, 1); - syscntl |= TI113X_SYSCNTL_INTRTIE; - } - - /* - * I've had reports that we need the pci clock enabled, - * provide a hook to do so. The number of cards that - * require this is quite small. - */ - if (pcic_ti12xx_enable_pci_clock) { - syscntl |= TI12XX_SYSCNTL_PCI_CLOCK; - pci_write_config(dev, TI113X_PCI_SYSTEM_CONTROL, - syscntl, 4); - } - - /* - * Some PCI add-in cards don't have good EEPROMs on them, - * so they get this MUX register wrong. The MUX register - * defaults to 0, which is usually wrong for this register, - * so we initialize it to make sense. - * - * We don't bother to turn it off in the ISA case since it - * is an initialization issue. - * - * A few weird TI bridges don't have MFUNC, so filter - * those out too. - */ - if ((sp->sc->flags & TI_NO_MFUNC) == 0) { - mfunc = pci_read_config(dev, TI12XX_PCI_MFUNC, 4); - if (mfunc == 0) { - mfunc = (mfunc & ~TI12XX_MFUNC_PIN0) | - TI12XX_MFUNC_PIN0_INTA; - if ((syscntl & TI113X_SYSCNTL_INTRTIE) == 0) - mfunc = (mfunc & ~TI12XX_MFUNC_PIN1) | - TI12XX_MFUNC_PIN1_INTB; - pci_write_config(dev, TI12XX_PCI_MFUNC, mfunc, - 4); - } - } - - } - return (pcic_pci_gen_func(sp, way)); -} - -static int -pcic_pci_ti12xx_csc(struct pcic_slot *sp, enum pcic_intr_way way) -{ - /* - * Nothing happens here. The TI12xx parts will route the - * CSC interrupt via PCI if ExCA register tells it to use - * interrupt 0. And via IRQ otherwise (except for reserved - * values which may or may not do anything). - * - * We just hope for the best here that doing nothing is the - * right thing to do. - */ - return (0); -} - -/* - * TI PCI-CardBus Host Adapter specific function code. - * This function is separated from pcic_pci_attach(). - * Takeshi Shibagaki(shiba@jp.freebsd.org). - */ -static void -pcic_pci_ti_init(device_t dev) -{ - u_int32_t syscntl, diagctl, devcntl, cardcntl; - u_int32_t device_id = pci_get_devid(dev); - int ti113x = (device_id == PCIC_ID_TI1031) || - (device_id == PCIC_ID_TI1130) || - (device_id == PCIC_ID_TI1131); - - syscntl = pci_read_config(dev, TI113X_PCI_SYSTEM_CONTROL, 4); - devcntl = pci_read_config(dev, TI113X_PCI_DEVICE_CONTROL, 1); - cardcntl = pci_read_config(dev, TI113X_PCI_CARD_CONTROL, 1); - - if (ti113x) { - device_printf(dev, "TI113X PCI Config Reg: "); - if (syscntl & TI113X_SYSCNTL_CLKRUN_ENA) { - if (syscntl & TI113X_SYSCNTL_CLKRUN_SEL) - printf("[clkrun irq 12]"); - else - printf("[clkrun irq 10]"); - } - } else { - device_printf(dev, "TI12XX PCI Config Reg: "); - - /* - * Turn on async CSC interrupts. This appears to - * be the default, but the old, pre pci-aware, code - * did this and it appears PAO does as well. - */ - diagctl = pci_read_config(dev, TI12XX_PCI_DIAGNOSTIC, 1); - diagctl |= TI12XX_DIAG_CSC_INTR; - pci_write_config(dev, TI12XX_PCI_DIAGNOSTIC, diagctl, 1); - - /* - * Turn off Zoom Video. Some cards have this enabled, - * some do not but it causes problems when enabled. This - * register doesn't exist on the 1130 (and likely the 1131, - * but without a datasheet it is impossible to know). - * Some 12xx chips may not have it, but setting it is - * believed to be harmless on those models. - */ - pci_write_config(dev, TI12XX_PCI_MULTIMEDIA_CONTROL, 0, 4); - } - if (cardcntl & TI113X_CARDCNTL_RING_ENA) - printf("[ring enable]"); - if (cardcntl & TI113X_CARDCNTL_SPKR_ENA) - printf("[speaker enable]"); - if (syscntl & TI113X_SYSCNTL_PWRSAVINGS) - printf("[pwr save]"); - switch(devcntl & TI113X_DEVCNTL_INTR_MASK){ - case TI113X_DEVCNTL_INTR_ISA : - printf("[CSC parallel isa irq]"); - break; - case TI113X_DEVCNTL_INTR_SERIAL : - printf("[CSC serial isa irq]"); - break; - case TI113X_DEVCNTL_INTR_NONE : - printf("[pci only]"); - break; - case TI12XX_DEVCNTL_INTR_ALLSERIAL : - printf("[FUNC pci int + CSC serial isa irq]"); - break; - } - printf("\n"); - pcic_pci_cardbus_init(dev); -} - -/* - * Code for TOPIC chips - */ -static int -pcic_pci_topic_func(struct pcic_slot *sp, enum pcic_intr_way way) -{ -#ifdef THIS_BRAEKS_THINGS - device_t dev = sp->sc->dev; - u_int32_t scr; - - scr = pci_read_config(dev, TOPIC_SOCKET_CTRL, 4); - if (way == pcic_iw_pci) - scr |= TOPIC_SOCKET_CTRL_SCR_IRQSEL; - else - scr &= ~TOPIC_SOCKET_CTRL_SCR_IRQSEL; - pci_write_config(dev, TOPIC_SLOT_CTRL, scr, 4); -#endif - return (pcic_pci_gen_func(sp, way)); -} - -static int -pcic_pci_topic_csc(struct pcic_slot *sp, enum pcic_intr_way way) -{ - device_t dev = sp->sc->dev; - u_int32_t scr; - u_int32_t device_id; - - device_id = pci_get_devid(dev); - if (device_id == PCIC_ID_TOPIC100 || device_id == PCIC_ID_TOPIC97) { - scr = pci_read_config(dev, TOPIC_SLOT_CTRL, 4); - if (way == pcic_iw_pci) - scr |= TOPIC97_SLOT_CTRL_PCIINT; - else - scr &= ~TOPIC97_SLOT_CTRL_PCIINT; - pci_write_config(dev, TOPIC_SLOT_CTRL, scr, 4); - } - - return (0); -} - -static void -pcic_pci_topic_init(device_t dev) -{ - struct pcic_softc *sc = device_get_softc(dev); - u_int32_t reg; - u_int32_t device_id; - - device_id = pci_get_devid(dev); - reg = pci_read_config(dev, TOPIC_SLOT_CTRL, 4); - reg |= (TOPIC_SLOT_CTRL_SLOTON | TOPIC_SLOT_CTRL_SLOTEN | - TOPIC_SLOT_CTRL_ID_LOCK | TOPIC_SLOT_CTRL_CARDBUS); - reg &= ~TOPIC_SLOT_CTRL_SWDETECT; - if (device_id == PCIC_ID_TOPIC100 || device_id == PCIC_ID_TOPIC97) { - reg |= TOPIC97_SLOT_CTRL_PCIINT; - reg &= ~(TOPIC97_SLOT_CTRL_STSIRQP | TOPIC97_SLOT_CTRL_IRQP); - } - pci_write_config(dev, TOPIC_SLOT_CTRL, reg, 4); - pcic_pci_cardbus_init(dev); - - if (device_id == PCIC_ID_TOPIC100 || device_id == PCIC_ID_TOPIC97) { - /* - * We need to enable voltage sense and 3V cards explicitly - * in the bridge. The datasheets I have for both the - * ToPIC 97 and 100 both lists these ports. Without - * datasheets for the ToPIC95s, I can't tell if we need - * to do it there or not. - */ - pcic_setb(&sc->slots[0], PCIC_TOPIC_FCR, - PCIC_FCR_3V_EN | PCIC_FCR_VS_EN); - } -} - -static void -pcic_pci_cardbus_init(device_t dev) -{ - struct pcic_softc *sc = device_get_softc(dev); - u_int16_t brgcntl; - int unit; - - unit = device_get_unit(dev); - - brgcntl = pci_read_config(dev, CB_PCI_BRIDGE_CTRL, 2); - brgcntl |= CB_BCR_WRITE_POST_EN | CB_BCR_MASTER_ABORT; - pci_write_config(dev, CB_PCI_BRIDGE_CTRL, brgcntl, 2); - - /* Turn off legacy address */ - pci_write_config(dev, CB_PCI_LEGACY16_IOADDR, 0, 2); - - /* - * Write zeros into the remaining memory I/O windows. This - * seems to turn off the pci configuration of these things and - * make the cardbus bridge use the values for memory - * programmed into the pcic registers. - */ - pci_write_config(dev, CB_PCI_MEMBASE0, 0, 4); - pci_write_config(dev, CB_PCI_MEMLIMIT0, 0, 4); - pci_write_config(dev, CB_PCI_MEMBASE1, 0, 4); - pci_write_config(dev, CB_PCI_MEMLIMIT1, 0, 4); - pci_write_config(dev, CB_PCI_IOBASE0, 0, 4); - pci_write_config(dev, CB_PCI_IOLIMIT0, 0, 4); - pci_write_config(dev, CB_PCI_IOBASE1, 0, 4); - pci_write_config(dev, CB_PCI_IOLIMIT1, 0, 4); - - /* - * Tell the chip to do its routing thing. - */ - sc->chip->func_intr_way(&sc->slots[0], sc->func_route); - sc->chip->csc_intr_way(&sc->slots[0], sc->csc_route); - - return; -} - -static const char * -pcic_pci_cardtype(u_int32_t stat) -{ - if (stat & CB_SS_NOTCARD) - return ("unrecognized by bridge"); - if ((stat & (CB_SS_16BIT | CB_SS_CB)) == (CB_SS_16BIT | CB_SS_CB)) - return ("16-bit and 32-bit (can't happen)"); - if (stat & CB_SS_16BIT) - return ("16-bit pccard"); - if (stat & CB_SS_CB) - return ("32-bit cardbus"); - return ("none (can't happen)"); -} - -/* - * Card insertion and removal code. The insertion events need to be - * debounced so that the noisy insertion/removal events don't result - * in the hardware being initialized many times, only to be torn down - * as well. This may also cause races with pccardd. Instead, we wait - * for the insertion signal to be stable for 0.5 seconds before we declare - * it to be a real insertion event. Removal is also debounced. We turn - * off interrupt servicing during the settling time to prevent infinite - * loops in the driver. - * - * Note: We only handle the card detect change events. We don't handle - * power events and status change events. - */ -static void -pcic_cd_change(void *arg) -{ - struct pcic_softc *sc = (struct pcic_softc *) arg; - struct pcic_slot *sp = &sc->slots[0]; - u_int32_t stat; - - sc->cd_pending = 0; - stat = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE); - - /* Status changed while present; remove the card from the system. */ - if (sc->cd_present) { - sc->cd_present = 0; - pccard_event(sp->slt, card_removed); - } - /* Nothing to do if the debounced state is 'not present'. */ - if ((stat & CB_SS_CD) != 0) - return; - - sc->cd_present = 1; - if (bootverbose && (stat & CB_SS_BADVCC) != 0) - device_printf(sc->dev, "BAD Vcc request: 0x%x\n", stat); - if ((stat & CB_SS_16BIT) == 0) - device_printf(sp->sc->dev, "Card type %s is unsupported\n", - pcic_pci_cardtype(stat)); - else - pccard_event(sp->slt, card_inserted); -} - -static void -pcic_pci_intr(void *arg) -{ - struct pcic_softc *sc = (struct pcic_softc *) arg; - struct pcic_slot *sp = &sc->slots[0]; - u_int32_t event; - - event = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_EVENT); - if (event != 0) { - if (bootverbose) - device_printf(sc->dev, "Event mask 0x%x\n", event); - - /* - * Treat all card-detect signal transitions the same way - * since we can't reliably tell if this is an insert or a - * remove event. Stop the card from getting interrupts and - * defer the insert/remove event until the CB_SOCKET_STATE - * signals have had time to settle. - */ - if ((event & CB_SE_CD) != 0) { - if (sc->cd_pending) { - untimeout(pcic_cd_change, arg, sc->cd_ch); - sc->cd_pending = 0; - } - sc->cd_pending = 1; - sc->cd_ch = timeout(pcic_cd_change, arg, hz/2); - sc->func_intr = NULL; - } - - /* Ack the interrupt */ - bus_space_write_4(sp->bst, sp->bsh, 0, event); - } - - /* - * Some TI chips also require us to read the old ExCA register for - * card status change when we route CSC via PCI! So, we go ahead - * and read it to clear the bits. Maybe we should check the status - * ala the ISA interrupt handler, but those changes should be caught - * in the CD change. - * - * We have to check it every interrupt because these bits can sometimes - * show up indepentently of the CB_SOCKET_EVENT register above. - */ - sp->getb(sp, PCIC_STAT_CHG); -} - -/* - * Return the ID string for the controller if the vendor/product id - * matches, NULL otherwise. - */ -static int -pcic_pci_probe(device_t dev) -{ - u_int8_t subclass; - u_int8_t progif; - const char *desc; - u_int32_t device_id; - struct pcic_pci_table *itm; - struct resource *res; - int rid; - - if (pcic_ignore_pci) - return (ENXIO); - device_id = pci_get_devid(dev); - desc = NULL; - itm = pcic_pci_lookup(device_id, &pcic_pci_devs[0]); - if (pcic_ignore_function_1 && pci_get_function(dev) == 1) { - if (itm != NULL) - PRVERB((dev, "Ignoring function 1\n")); - return (ENXIO); - } - if (itm != NULL) - desc = itm->descr; - if (desc == NULL && pci_get_class(dev) == PCIC_BRIDGE) { - subclass = pci_get_subclass(dev); - progif = pci_get_progif(dev); - if (subclass == PCIS_BRIDGE_PCMCIA && progif == 0) - desc = "Generic PCI-PCMCIA Bridge"; - if (subclass == PCIS_BRIDGE_CARDBUS && progif == 0) - desc = "YENTA PCI-CardBus Bridge"; - if (bootverbose && desc) - printf("Found unknown %s devid 0x%x\n", desc, device_id); - } - if (desc == NULL) - return (ENXIO); - device_set_desc(dev, desc); - - /* - * Take us out of power down mode, if necessary. It also - * appears that even reading the power register is enough on - * some systems to cause correct behavior. - */ - if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { - /* Reset the power state. */ - device_printf(dev, "chip is in D%d power mode " - "-- setting to D0\n", pci_get_powerstate(dev)); - pci_set_powerstate(dev, PCI_POWERSTATE_D0); - } - - /* - * Allocated/deallocate interrupt. This forces the PCI BIOS or - * other MD method to route the interrupts to this card. - * This so we get the interrupt number in the probe message. - * We only need to route interrupts when we're doing pci - * parallel interrupt routing. - * - * We use two different variables for the memory based and I/O - * based cards, so the check here is a little more complex than - * one would otherwise hope. - * - * XXX The bus code for PCI really should do this for us. - */ - if ((pcic_intr_path == pcic_iw_pci && - device_id != PCIC_ID_CLPD6729) || - (pcic_pd6729_intr_path == pcic_iw_pci && - device_id == PCIC_ID_CLPD6729)) { - rid = 0; -#ifdef __i386__ - /* - * IRQ 0 is invalid on x86, but not other platforms. - * If we have irq 0, then write 255 to force a new, non- - * bogus one to be assigned. I think that in -current - * the code in this ifdef may be obsolete with the new - * invalid mapping that we're doing in the pci layer -- imp - */ - if (pci_get_irq(dev) == 0) { - pci_set_irq(dev, 255); - pci_write_config(dev, PCIR_INTLINE, 255, 1); - } -#endif - res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, - RF_ACTIVE); - if (res) - bus_release_resource(dev, SYS_RES_IRQ, rid, res); - } - - return (0); -} - -static void -pcic_pci_shutdown(device_t dev) -{ -/* - * More reports of things working w/o this code than with it. - */ -#if 0 - struct pcic_softc *sc; - struct pcic_slot *sp; - - sc = (struct pcic_softc *) device_get_softc(dev); - sp = &sc->slots[0]; - - /* - * Turn off the power to the slot in an attempt to - * keep the system from hanging on reboot. We also turn off - * card interrupts in an attempt to control interrupt storms. - * on some (all?) this has the effect of also turning off - * card status change interrupts. A side effect of writing 0 - * to INT_GEN is that the card is placed into "reset" mode - * where nothing happens until it is taken out of "reset" - * mode. - * - * Also, turn off the generation of status interrupts too. - */ - sp->putb(sp, PCIC_INT_GEN, 0); - sp->putb(sp, PCIC_STAT_INT, 0); - sp->putb(sp, PCIC_POWER, 0); - DELAY(4000); - - /* - * Writing to INT_GEN can cause an interrupt, so we blindly - * ack all possible interrupts here. Reading the stat change - * shouldn't be necessary, but some TI chipsets need it in the - * normal course of operations, so we do it here too. We can't - * lose any interrupts after this point, so go ahead and ack - * everything. The bits in INT_GEN clear upon reading them. - * We also set the interrupt mask to 0, in an effort to avoid - * getting further interrupts. - */ - bus_space_write_4(sp->bst, sp->bsh, CB_SOCKET_MASK, 0); - bus_space_write_4(sp->bst, sp->bsh, CB_SOCKET_EVENT, 0xffffffff); - sp->getb(sp, PCIC_STAT_CHG); -#endif -} - -/* - * Print out the config space - */ -static void -pcic_pci_print_config(device_t dev) -{ - int i; - - device_printf(dev, "PCI Configuration space:"); - for (i = 0; i < 256; i += 4) { - if (i % 16 == 0) - printf("\n 0x%02x: ", i); - printf("0x%08x ", pci_read_config(dev, i, 4)); - } - printf("\n"); -} - -/* - * Generic pci interrupt attach routine. It tries to understand all parts, - * and do sane things for those parts it does not understand. - */ -static int -pcic_pci_attach(device_t dev) -{ - u_int32_t device_id = pci_get_devid(dev); - u_long command; - struct pcic_slot *sp; - struct pcic_softc *sc; - u_int32_t sockbase; - u_int32_t stat; - struct pcic_pci_table *itm; - int rid; - int i; - struct resource *r = NULL; - int error; - u_long irq = 0; - driver_intr_t *intr = NULL; - - /* - * In sys/pci/pcireg.h, PCIR_COMMAND must be separated - * PCI_COMMAND_REG(0x04) and PCI_STATUS_REG(0x06). - * Takeshi Shibagaki(shiba@jp.freebsd.org). - */ - command = pci_read_config(dev, PCIR_COMMAND, 4); - command |= PCIM_CMD_PORTEN | PCIM_CMD_MEMEN; - pci_write_config(dev, PCIR_COMMAND, command, 4); - - sc = (struct pcic_softc *) device_get_softc(dev); - sp = &sc->slots[0]; - sp->sc = sc; - sockbase = pci_read_config(dev, 0x10, 4); - if (sockbase & 0x1) { - sc->iorid = CB_PCI_SOCKET_BASE; - sc->iores = bus_alloc_resource(dev, SYS_RES_IOPORT, - &sc->iorid, 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE); - if (sc->iores == NULL) - return (ENOMEM); - - sc->flags = PCIC_PD_POWER; - itm = pcic_pci_lookup(device_id, &pcic_pci_devs[0]); - for (i = 0; i < 2; i++) { - sp[i].bst = rman_get_bustag(sc->iores); - sp[i].bsh = rman_get_bushandle(sc->iores); - sp[i].sc = sc; - sp[i].revision = 0; - sp[i].getb = pcic_getb_io; - sp[i].putb = pcic_putb_io; - sp[i].offset = i * PCIC_SLOT_SIZE; - sp[i].controller = itm ? itm->type : PCIC_PD6729; - if ((sp[i].getb(&sp[i], PCIC_ID_REV) & 0xc0) == 0x80) - sp[i].slt = (struct slot *) 1; - } - sc->csc_route = sc->func_route = pcic_pd6729_intr_path; - if (itm) - sc->flags = itm->flags; - /* - * We have to use the ISA interrupt routine for status - * changes since we don't have any "yenta" pci registers. - * We have to do this even when we're using pci type - * interrupts because on these cards the interrupts are - * cleared in the same way that the ISA cards clear them. - */ - intr = pcic_isa_intr; - } else { - sc->memrid = CB_PCI_SOCKET_BASE; - sc->memres = bus_alloc_resource(dev, SYS_RES_MEMORY, - &sc->memrid, 0, ~0, 1, RF_ACTIVE); - if (sc->memres == NULL && pcic_pci_get_memory(dev) != 0) - return (ENOMEM); - sp->getb = pcic_pci_getb2; - sp->putb = pcic_pci_putb2; - sp->offset = CB_EXCA_OFFSET; - sp->bst = rman_get_bustag(sc->memres); - sp->bsh = rman_get_bushandle(sc->memres); - itm = pcic_pci_lookup(device_id, &pcic_pci_devs[0]); - if (itm != NULL) { - sp->controller = itm->type; - sp->revision = 0; - sc->flags = itm->flags; - } else { - /* By default, assume we're a D step compatible */ - sp->controller = PCIC_I82365SL_DF; - sp->revision = 0; - sc->flags = PCIC_CARDBUS_POWER; - } - /* All memory mapped cardbus bridges have these registers */ - sc->flags |= PCIC_YENTA_HIGH_MEMORY; - sp->slt = (struct slot *) 1; - sc->csc_route = pcic_intr_path; - sc->func_route = pcic_intr_path; - stat = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE); - sc->cd_present = (stat & CB_SS_CD) == 0; - } - sc->dev = dev; - if (itm) - sc->chip = itm->chip; - else - sc->chip = &pcic_pci_generic_chip; - - if (sc->csc_route == pcic_iw_pci) { - rid = 0; - r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, - RF_ACTIVE | RF_SHAREABLE); - if (r == NULL) { - sc->csc_route = pcic_iw_isa; - sc->func_route = pcic_iw_isa; - device_printf(dev, - "No PCI interrupt routed, trying ISA.\n"); - } else { - if (intr == NULL) - intr = pcic_pci_intr; - irq = rman_get_start(r); - } - } - if (sc->csc_route == pcic_iw_isa) { - rid = 0; - irq = pcic_override_irq; - if (irq != 0) { - r = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, irq, - irq, 1, RF_ACTIVE); - if (r == NULL) { - device_printf(dev, - "Can't route ISA CSC interrupt.\n"); - pcic_dealloc(dev); - return (ENXIO); - } - device_printf(dev, - "Management interrupt on ISA IRQ %ld\n", irq); - if (intr == NULL) - intr = pcic_isa_intr; - } else { - sc->slot_poll = pcic_timeout; - sc->timeout_ch = timeout(sc->slot_poll, sc, hz/2); - device_printf(dev, "Polling mode\n"); - intr = NULL; - } - } - - /* - * Initialize AFTER we figure out what kind of interrupt we're - * going to be using, if any. - */ - if (!sc->chip) - panic("Bug: sc->chip not set!\n"); - sc->chip->init(dev); - - /* - * Now install the interrupt handler, if necessary. - */ - sc->irqrid = rid; - sc->irqres = r; - sc->irq = irq; - if (intr) { - error = bus_setup_intr(dev, r, INTR_TYPE_AV, intr, sc, &sc->ih); - if (error) { - pcic_dealloc(dev); - return (error); - } - } - if (bootverbose) - pcic_pci_print_config(dev); - return (pcic_attach(dev)); -} - -static int -pcic_pci_detach(device_t dev) -{ - return (EBUSY); /* Can't detach this device */ -} - -/* - * The PCI bus should do this for us. However, it doesn't quite yet, so - * we cope by doing it ourselves. If it ever does, this code can go quietly - * into that good night. - */ -static int -pcic_pci_get_memory(device_t dev) -{ - struct pcic_softc *sc; - u_int32_t sockbase; - - sc = (struct pcic_softc *) device_get_softc(dev); - sockbase = pci_read_config(dev, sc->memrid, 4); - if (sockbase >= 0x100000 && sockbase < 0xfffffff0) { - device_printf(dev, "Could not map register memory 0x%x\n", - sockbase); - return (ENOMEM); - } - pci_write_config(dev, sc->memrid, 0xffffffff, 4); - sockbase = pci_read_config(dev, sc->memrid, 4); - sockbase = (sockbase & 0xfffffff0) & -(sockbase & 0xfffffff0); -#define CARDBUS_SYS_RES_MEMORY_START 0x88000000 -#define CARDBUS_SYS_RES_MEMORY_END 0xFFFFFFFF - sc->memres = bus_generic_alloc_resource(device_get_parent(dev), - dev, SYS_RES_MEMORY, &sc->memrid, - CARDBUS_SYS_RES_MEMORY_START, CARDBUS_SYS_RES_MEMORY_END, - sockbase, RF_ACTIVE | rman_make_alignment_flags(sockbase)); - if (sc->memres == NULL) { - device_printf(dev, "Could not grab register memory\n"); - return (ENOMEM); - } - sockbase = rman_get_start(sc->memres); - pci_write_config(dev, sc->memrid, sockbase, 4); - device_printf(dev, "PCI Memory allocated: 0x%08x\n", sockbase); - return (0); -} - -static int -pcic_pci_gen_mapirq(struct pcic_slot *sp, int irq) -{ - /* - * If we're doing ISA interrupt routing, then just go to the - * generic ISA routine. Also, irq 0 means turn off the interrupts - * at the bridge. - */ - if (sp->sc->func_route == pcic_iw_isa || irq == 0) - return (pcic_isa_mapirq(sp, irq)); - - /* - * Ohterwise we're doing PCI interrupts. For those cardbus bridges - * that follow yenta (and the one pcmcia bridge that does), we don't - * do a thing to get the IRQ mapped into the system. However, - * for other controllers that are PCI, but not yetna compliant, we - * need to do some special mapping. - * - * XXX Maybe we shouldn't assume INTA#, but rather as the function - * XXX what Intline to use. - */ - if (sp->controller == PCIC_PD6729) { - /* - * INTA - 3 - * INTB - 4 - * INTC - 5 - * INTD - 7 - */ - sp->putb(sp, PCIC_INT_GEN, /* Assume INTA# */ - (sp->getb(sp, PCIC_INT_GEN) & 0xF0) | 3); - return (0); - } - return (0); -} - -static void -pcic_pci_func_intr(void *arg) -{ - struct pcic_softc *sc = (struct pcic_softc *) arg; - struct pcic_slot *sp = &sc->slots[0]; - u_int32_t stat; - int doit = 0; - - /* - * The 6729 controller is a weird one, and we have to use - * the ISA registers to check to see if the card is there. - * Otherwise we look at the PCI state register to find out - * if the card is there. - */ - if (sp->controller == PCIC_PD6729) { - if ((sp->getb(sp, PCIC_STATUS) & PCIC_CD) == PCIC_CD) - doit = 1; - } - else { - stat = bus_space_read_4(sp->bst, sp->bsh, CB_SOCKET_STATE); - if ((stat & CB_SS_CD) == 0 && sc->func_intr != 0) - doit = 1; - } - if (doit && sc->func_intr != NULL) - sc->func_intr(sc->func_arg); -} - -static int -pcic_pci_setup_intr(device_t dev, device_t child, struct resource *irq, - int flags, driver_intr_t *intr, void *arg, void **cookiep) -{ - struct pcic_softc *sc = device_get_softc(dev); - struct pcic_slot *sp = &sc->slots[0]; - int err; - - if (sc->func_route == pcic_iw_isa) - return(pcic_setup_intr(dev, child, irq, flags, intr, arg, - cookiep)); - -#if __FreeBSD_version >= 500000 - if ((flags & INTR_FAST) != 0) -#else - if ((flags & INTR_TYPE_FAST) != 0) -#endif - return (EINVAL); - if (sc->func_intr != NULL) { - device_printf(child, "Can't establish another ISR\n"); - return (EINVAL); - } - - err = bus_generic_setup_intr(dev, child, irq, flags, - pcic_pci_func_intr, sc, cookiep); - if (err != 0) - return (err); - sc->chip->map_irq(sp, rman_get_start(irq)); - sc->func_intr = intr; - sc->func_arg = arg; - return (0); -} - -static int -pcic_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, - void *cookie) -{ - struct pcic_softc *sc = device_get_softc(dev); - - if (sc->func_route == pcic_iw_isa) - return (pcic_teardown_intr(dev, child, irq, cookie)); - sc->func_intr = NULL; - return (bus_generic_teardown_intr(dev, child, irq, cookie)); -} - -static int -pcic_pci_resume(device_t dev) -{ - struct pcic_softc *sc = device_get_softc(dev); - - /* - * Some BIOSes will not save the BARs for the pci chips, so we - * must do it ourselves. If the BAR is reset to 0 for an I/O - * device, it will read back as 0x1, so no explicit test for - * memory devices are needed. - * - * Note: The PCI bus code should do this automatically for us on - * suspend/resume, but until it does, we have to cope. - */ - if (pci_read_config(dev, CB_PCI_SOCKET_BASE, 4) == 0) - pci_write_config(dev, CB_PCI_SOCKET_BASE, - rman_get_start(sc->memres), 4); - return (bus_generic_resume(dev)); -} - -static device_method_t pcic_pci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, pcic_pci_probe), - DEVMETHOD(device_attach, pcic_pci_attach), - DEVMETHOD(device_detach, pcic_pci_detach), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, pcic_pci_resume), - DEVMETHOD(device_shutdown, pcic_pci_shutdown), - - /* Bus interface */ - DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_alloc_resource, pcic_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - DEVMETHOD(bus_activate_resource, pcic_activate_resource), - DEVMETHOD(bus_deactivate_resource, pcic_deactivate_resource), - DEVMETHOD(bus_setup_intr, pcic_pci_setup_intr), - DEVMETHOD(bus_teardown_intr, pcic_pci_teardown_intr), - - /* Card interface */ - DEVMETHOD(card_set_res_flags, pcic_set_res_flags), - DEVMETHOD(card_get_res_flags, pcic_get_res_flags), - DEVMETHOD(card_set_memory_offset, pcic_set_memory_offset), - DEVMETHOD(card_get_memory_offset, pcic_get_memory_offset), - - {0, 0} -}; - -static driver_t pcic_pci_driver = { - "pcic", - pcic_pci_methods, - sizeof(struct pcic_softc) -}; - -DRIVER_MODULE(pcic, pci, pcic_pci_driver, pcic_devclass, 0, 0); diff --git a/sys/bus/pccard/pcic_pci.h b/sys/bus/pccard/pcic_pci.h deleted file mode 100644 index 36b55368b5..0000000000 --- a/sys/bus/pccard/pcic_pci.h +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 2001 M. Warner Losh. All rights reserved. - * Copyright (c) 1997 Ted Faber. 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 immediately at the beginning of the file, without modification, - * 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. Absolutely no warranty of function or purpose is made by the author - * Ted Faber. - * - * 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. - * - * $FreeBSD: src/sys/pccard/pcic_pci.h,v 1.23.2.12 2003/02/26 18:42:00 imp Exp $ - * $DragonFly: src/sys/bus/pccard/Attic/pcic_pci.h,v 1.3 2003/08/07 21:16:46 dillon Exp $ - */ - -/* Share the devid database with NEWCARD */ -#include - -/* CL-PD683x CardBus defines */ -#define CLPD6833_CFG_MISC_1 0x98 - -/* Configuration constants */ -#define CLPD6832_BCR_MGMT_IRQ_ENA 0x0800 -#define CLPD6833_CM1_MGMT_EXCA_ENA 0x0001 /* Set ExCA, Clr PCI */ - -/* End of CL-PD6832 defines */ -/* Texas Instruments PCI-1130/1131 CardBus Controller */ -#define TI113X_PCI_SYSTEM_CONTROL 0x80 /* System Control */ -#define TI12XX_PCI_MULTIMEDIA_CONTROL 0x84 /* Zoom Video */ -#define TI12XX_PCI_MFUNC 0x8c /* multifunction pins */ -#define TI113X_PCI_RETRY_STATUS 0x90 /* Retry Status */ -#define TI113X_PCI_CARD_CONTROL 0x91 /* Card Control */ -#define TI113X_PCI_DEVICE_CONTROL 0x92 /* Device Control */ -#define TI113X_PCI_BUFFER_CONTROL 0x93 /* Buffer Control */ -#define TI12XX_PCI_DIAGNOSTIC 0x93 /* Diagnostic register */ -#define TI113X_PCI_SOCKET_DMA0 0x94 /* Socket DMA Register 0 */ -#define TI113X_PCI_SOCKET_DMA1 0x98 /* Socket DMA Register 1 */ - -/* Card control register (TI113X_SYSTEM_CONTROL == 0x80) */ -#define TI113X_SYSCNTL_INTRTIE 0x20000000u -#define TI12XX_SYSCNTL_PCI_CLOCK 0x08000000u -#define TI113X_SYSCNTL_SMIENB 0x00800000u -#define TI113X_SYSCNTL_VCC_PROTECT 0x00200000u -#define TI113X_SYSCNTL_CLKRUN_SEL 0x00000080u -#define TI113X_SYSCNTL_PWRSAVINGS 0x00000040u -#define TI113X_SYSCNTL_KEEP_CLK 0x00000002u -#define TI113X_SYSCNTL_CLKRUN_ENA 0x00000001u - -/* MFUNC register (TI12XX_MFUNC == 0x8c) */ -#define TI12XX_MFUNC_PIN0 0x0000000fu -#define TI12XX_MFUNC_PIN0_INTA 0x2 -#define TI12XX_MFUNC_PIN1 0x000000f0u -#define TI12XX_MFUNC_PIN1_INTB 0x20 -#define TI12XX_MFUNC_PIN2 0x00000f00u -#define TI12XX_MFUNC_PIN3 0x0000f000u -#define TI12XX_MFUNC_PIN4 0x000f0000u -#define TI12XX_MFUNC_PIN5 0x00f00000u -#define TI12XX_MFUNC_PIN6 0x0f000000u - -/* Card control register (TI113X_CARD_CONTROL == 0x91) */ -#define TI113X_CARDCNTL_RING_ENA 0x80u -#define TI113X_CARDCNTL_ZOOM_VIDEO 0x40u -#define TI113X_CARDCNTL_PCI_IRQ_ENA 0x20u -#define TI113X_CARDCNTL_PCI_IREQ 0x10u -#define TI113X_CARDCNTL_PCI_CSC 0x08u -#define TI113X_CARDCNTL_MASK (TI113X_CARDCNTL_PCI_IRQ_ENA | TI113X_CARDCNTL_PCI_IREQ | TI113X_CARDCNTL_PCI_CSC) -#define TI113X_FUNC0_VALID TI113X_CARDCNTL_MASK -#define TI113X_FUNC1_VALID (TI113X_CARDCNTL_PCI_IREQ | TI113X_CARDCNTL_PCI_CSC) -/* Reserved bit 0x04u */ -#define TI113X_CARDCNTL_SPKR_ENA 0x02u -#define TI113X_CARDCNTL_INT 0x01u - -/* Device control register (TI113X_DEVICE_CONTROL == 0x92) */ -#define TI113X_DEVCNTL_5V_SOCKET 0x40u -#define TI113X_DEVCNTL_3V_SOCKET 0x20u -#define TI113X_DEVCNTL_INTR_MASK 0x06u -#define TI113X_DEVCNTL_INTR_NONE 0x00u -#define TI113X_DEVCNTL_INTR_ISA 0x02u -#define TI113X_DEVCNTL_INTR_SERIAL 0x04u -/* TI12XX specific code */ -#define TI12XX_DEVCNTL_INTR_ALLSERIAL 0x06u - -/* Diagnostic register (misnamed) TI12XX_PCI_DIAGNOSTIC == 0x93 */ -#define TI12XX_DIAG_CSC_INTR 0x20 /* see datasheet */ - -/* Texas Instruments PCI-1130/1131 CardBus Controller */ -#define TI113X_ExCA_IO_OFFSET0 0x36 /* Offset of I/O window */ -#define TI113X_ExCA_IO_OFFSET1 0x38 /* Offset of I/O window */ -#define TI113X_ExCA_MEM_WINDOW_PAGE 0x3C /* Memory Window Page */ - -/* - * Ricoh R5C47[5678] parts have these registers. Maybe the 46x also use - * them, but I can't find out for sure without datasheets... - */ -#define R5C47X_MISC_CONTROL_REGISTER_2 0xa0 -#define R5C47X_MCR2_CSC_TO_INTX_DISABLE 0x0010 /* Bit 7 */ - -/* - * Special resister definition for Toshiba ToPIC95/97 - * These values are borrowed from pcmcia-cs/Linux. - */ -#define TOPIC_SOCKET_CTRL 0x90 -# define TOPIC_SOCKET_CTRL_SCR_IRQSEL 0x00000001 /* PCI intr */ - -#define TOPIC_SLOT_CTRL 0xa0 -# define TOPIC_SLOT_CTRL_SLOTON 0x00000080 -# define TOPIC_SLOT_CTRL_SLOTEN 0x00000040 -# define TOPIC_SLOT_CTRL_ID_LOCK 0x00000020 -# define TOPIC_SLOT_CTRL_ID_WP 0x00000010 -# define TOPIC_SLOT_CTRL_PORT_MASK 0x0000000c -# define TOPIC_SLOT_CTRL_PORT_SHIFT 2 -# define TOPIC_SLOT_CTRL_OSF_MASK 0x00000003 -# define TOPIC_SLOT_CTRL_OSF_SHIFT 0 - -# define TOPIC_SLOT_CTRL_INTB 0x00002000 -# define TOPIC_SLOT_CTRL_INTA 0x00001000 -# define TOPIC_SLOT_CTRL_INT_MASK 0x00003000 -# define TOPIC_SLOT_CTRL_CLOCK_MASK 0x00000c00 -# define TOPIC_SLOT_CTRL_CLOCK_2 0x00000800 /* PCI Clock/2 */ -# define TOPIC_SLOT_CTRL_CLOCK_1 0x00000400 /* PCI Clock */ -# define TOPIC_SLOT_CTRL_CLOCK_0 0x00000000 /* no clock */ -# define TOPIC97_SLOT_CTRL_STSIRQP 0x00000400 /* status change intr pulse */ -# define TOPIC97_SLOT_CTRL_IRQP 0x00000200 /* function intr pulse */ -# define TOPIC97_SLOT_CTRL_PCIINT 0x00000100 /* intr routing to PCI INT */ - -# define TOPIC_SLOT_CTRL_CARDBUS 0x80000000 -# define TOPIC_SLOT_CTRL_VS1 0x04000000 -# define TOPIC_SLOT_CTRL_VS2 0x02000000 -# define TOPIC_SLOT_CTRL_SWDETECT 0x01000000 - -#define TOPIC_REG_CTRL 0x00a4 -# define TOPIC_REG_CTRL_RESUME_RESET 0x80000000 -# define TOPIC_REG_CTRL_REMOVE_RESET 0x40000000 -# define TOPIC97_REG_CTRL_CLKRUN_ENA 0x20000000 -# define TOPIC97_REG_CTRL_TESTMODE 0x10000000 -# define TOPIC97_REG_CTRL_IOPLUP 0x08000000 -# define TOPIC_REG_CTRL_BUFOFF_PWROFF 0x02000000 -# define TOPIC_REG_CTRL_BUFOFF_SIGOFF 0x01000000 -# define TOPIC97_REG_CTRL_CB_DEV_MASK 0x0000f800 -# define TOPIC97_REG_CTRL_CB_DEV_SHIFT 11 -# define TOPIC97_REG_CTRL_RI_DISABLE 0x00000004 -# define TOPIC97_REG_CTRL_CAUDIO_OFF 0x00000002 -# define TOPIC_REG_CTRL_CAUDIO_INVERT 0x00000001 - -/* For Bridge Control register (CB_PCI_BRIDGE_CTRL) */ -#define CB_BCR_MASTER_ABORT 0x0020 -#define CB_BCR_CB_RESET 0x0040 -#define CB_BCR_INT_EXCA 0x0080 -#define CB_BCR_WRITE_POST_EN 0x0400 - /* additional bits for Ricoh's cardbus products */ -#define CB_BCR_RL_3E0_EN 0x0800 -#define CB_BCR_RL_3E2_EN 0x1000 - -/* PCI Configuration Registers (common) */ -#define CB_PCI_VENDOR_ID 0x00 /* vendor ID */ -#define CB_PCI_DEVICE_ID 0x02 /* device ID */ -#define CB_PCI_COMMAND 0x04 /* PCI command */ -#define CB_PCI_STATUS 0x06 /* PCI status */ -#define CB_PCI_REVISION_ID 0x08 /* PCI revision ID */ -#define CB_PCI_CLASS 0x09 /* PCI class code */ -#define CB_PCI_CACHE_LINE_SIZE 0x0c /* Cache line size */ -#define CB_PCI_LATENCY 0x0d /* PCI latency timer */ -#define CB_PCI_HEADER_TYPE 0x0e /* PCI header type */ -#define CB_PCI_BIST 0x0f /* Built-in self test */ -#define CB_PCI_SOCKET_BASE 0x10 /* Socket/ExCA base address reg. */ -#define CB_PCI_CB_STATUS 0x16 /* CardBus Status */ -#define CB_PCI_PCI_BUS_NUM 0x18 /* PCI bus number */ -#define CB_PCI_CB_BUS_NUM 0x19 /* CardBus bus number */ -#define CB_PCI_CB_SUB_BUS_NUM 0x1A /* Subordinate CardBus bus number */ -#define CB_PCI_CB_LATENCY 0x1A /* CardBus latency timer */ -#define CB_PCI_MEMBASE0 0x1C /* Memory base register 0 */ -#define CB_PCI_MEMLIMIT0 0x20 /* Memory limit register 0 */ -#define CB_PCI_MEMBASE1 0x24 /* Memory base register 1 */ -#define CB_PCI_MEMLIMIT1 0x28 /* Memory limit register 1 */ -#define CB_PCI_IOBASE0 0x2C /* I/O base register 0 */ -#define CB_PCI_IOLIMIT0 0x30 /* I/O limit register 0 */ -#define CB_PCI_IOBASE1 0x34 /* I/O base register 1 */ -#define CB_PCI_IOLIMIT1 0x38 /* I/O limit register 1 */ -#define CB_PCI_INT_LINE 0x3C /* Interrupt Line */ -#define CB_PCI_INT_PIN 0x3D /* Interrupt Pin */ -#define CB_PCI_BRIDGE_CTRL 0x3E /* Bridge Control */ -#define CB_PCI_SUBSYS_VENDOR_ID 0x40 /* Subsystem Vendor ID */ -#define CB_PCI_SUBSYS_ID 0x42 /* Subsystem ID */ -#define CB_PCI_LEGACY16_IOADDR 0x44 /* Legacy 16bit I/O address */ -#define CB_PCI_LEGACY16_IOENABLE 0x01 /* Enable Legacy 16bit I/O address */ - -/* PCI Memory register offsets for YENTA devices */ -#define CB_SOCKET_EVENT 0x00 -#define CB_SOCKET_MASK 0x04 -#define CB_SOCKET_STATE 0x08 -#define CB_SOCKET_FORCE 0x0c -#define CB_SOCKET_POWER 0x10 -#define CB_EXCA_OFFSET 0x800 /* Offset for ExCA registers */ - -#define CB_SE_CD 0x6 /* Socket Event Card detect */ -#define CB_SE_POWER 0x8 - -#define CB_SM_CD 0x6 /* Socket MASK Card detect */ -#define CB_SM_POWER 0x8 - -/* Socket State Register */ -#define CB_SS_CARDSTS 0x00000001 /* Card Status Change */ -#define CB_SS_CD1 0x00000002 /* Card Detect 1 */ -#define CB_SS_CD2 0x00000004 /* Card Detect 2 */ -#define CB_SS_CD 0x00000006 /* Card Detect all */ -#define CB_SS_PWRCYCLE 0x00000008 /* Power Cycle */ -#define CB_SS_16BIT 0x00000010 /* 16-bit Card */ -#define CB_SS_CB 0x00000020 /* Cardbus Card */ -#define CB_SS_IREQ 0x00000040 /* Ready */ -#define CB_SS_NOTCARD 0x00000080 /* Unrecognized Card */ -#define CB_SS_DATALOST 0x00000100 /* Data Lost */ -#define CB_SS_BADVCC 0x00000200 /* Bad VccRequest */ -#define CB_SS_5VCARD 0x00000400 /* 5 V Card */ -#define CB_SS_3VCARD 0x00000800 /* 3.3 V Card */ -#define CB_SS_XVCARD 0x00001000 /* X.X V Card */ -#define CB_SS_YVCARD 0x00002000 /* Y.Y V Card */ -#define CB_SS_CARD_MASK 0x00003c00 /* *VCARD signal */ -#define CB_SS_5VSOCK 0x10000000 /* 5 V Socket */ -#define CB_SS_3VSOCK 0x20000000 /* 3.3 V Socket */ -#define CB_SS_XVSOCK 0x40000000 /* X.X V Socket */ -#define CB_SS_YVSOCK 0x80000000 /* Y.Y V Socket */ - -/* Socket power register */ -#define CB_SP_CLKSTOP 0x80 /* Cardbus clock stop protocol */ -#define CB_SP_VCC_MASK 0x70 -#define CB_SP_VCC_0V 0x00 - /* 0x10 is reserved 12V in VPP */ -#define CB_SP_VCC_5V 0x20 -#define CB_SP_VCC_3V 0x30 -#define CB_SP_VCC_XV 0x40 -#define CB_SP_VCC_YV 0x50 - /* 0x60 and 0x70 are reserved */ -#define CB_SP_VPP_MASK 0x07 -#define CB_SP_VPP_0V 0x00 -#define CB_SP_VPP_12V 0x01 -#define CB_SP_VPP_5V 0x02 -#define CB_SP_VPP_3V 0x03 -#define CB_SP_VPP_XV 0x04 -#define CB_SP_VPP_YV 0x05 - -/* Socket force register */ -#define CB_SF_INTCVS (1 << 14) /* Interregate CVS/CCD pins */ -#define CB_SF_5VCARD (1 << 11) -#define CB_SF_3VCARD (1 << 10) -#define CB_SF_BADVCC (1 << 9) -#define CB_SF_DATALOST (1 << 8) -#define CB_SF_NOTACARD (1 << 7) -#define CB_SF_CBCARD (1 << 5) -#define CB_SF_16CARD (1 << 4) -#define CB_SF_POWERCYCLE (1 << 3) -#define CB_SF_CCD2 (1 << 2) -#define CB_SF_CCD1 (1 << 1) -#define CB_SF_CSTCHG (1 << 0) - /* 0x6 and 0x7 are reserved */ diff --git a/sys/bus/pccard/pcicvar.h b/sys/bus/pccard/pcicvar.h deleted file mode 100644 index cccaf07829..0000000000 --- a/sys/bus/pccard/pcicvar.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2001 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 ``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. - * - * $FreeBSD: src/sys/pccard/pcicvar.h,v 1.15.2.11 2002/09/22 20:26:58 imp Exp $ - * $DragonFly: src/sys/bus/pccard/Attic/pcicvar.h,v 1.3 2004/01/08 10:06:29 joerg Exp $ - */ - -/* - * Per-slot data table. - */ -struct pcic_slot { - int offset; /* Offset value for index */ - char controller; /* Device type */ - char revision; /* Device Revision */ - struct slot *slt; /* Back ptr to slot */ - struct pcic_softc *sc; /* Back pointer to softc */ - u_int8_t (*getb)(struct pcic_slot *, int); - void (*putb)(struct pcic_slot *, int, u_int8_t); - bus_space_tag_t bst; - bus_space_handle_t bsh; -}; - -enum pcic_intr_way { pcic_iw_isa = 1, pcic_iw_pci = 2 }; - -struct pcic_softc -{ - u_int32_t slotmask;/* Mask of valid slots */ - u_int32_t flags; /* Interesting flags */ -#define PCIC_AB_POWER 0x00000001 /* Use old A/B step power */ -#define PCIC_DF_POWER 0x00000002 /* Uses DF step regs */ -#define PCIC_PD_POWER 0x00000004 /* Uses CL-PD regs */ -#define PCIC_VG_POWER 0x00000008 /* Uses VG power regs */ -#define PCIC_KING_POWER 0x00000010 /* Uses IBM KING regs */ -#define PCIC_RICOH_POWER 0x00000020 /* Uses the ricoh power regs */ -#define PCIC_CARDBUS_POWER 0x00000040 /* Cardbus power regs */ -#define PCIC_YENTA_HIGH_MEMORY 0x0080 /* Can do high memory mapping */ - - enum pcic_intr_way csc_route; /* How to route csc interrupts */ - enum pcic_intr_way func_route; /* How to route function ints */ - int iorid; /* Rid of I/O region */ - struct resource *iores; /* resource for I/O region */ - int memrid; /* Memory rid */ - struct resource *memres;/* Resource for memory mapped regs */ - int irqrid; /* Irq rid */ - struct resource *irqres;/* Irq resource */ - void *ih; /* Our interrupt handler. */ - int irq; - device_t dev; /* Our device */ - void (*slot_poll)(void *); - struct callout_handle timeout_ch; - struct pcic_slot slots[PCIC_MAX_SLOTS]; - int cd_pending; /* debounce timeout active */ - int cd_present; /* debounced card-present state */ - struct callout_handle cd_ch; /* handle for pcic_cd_insert */ - struct pcic_chip *chip; - driver_intr_t *func_intr; - void *func_arg; -}; - -typedef int (pcic_intr_way_t)(struct pcic_slot *, enum pcic_intr_way); -typedef int (pcic_intr_mapirq_t)(struct pcic_slot *, int irq); -typedef void (pcic_init_t)(device_t); - -struct pcic_chip -{ - pcic_intr_way_t *func_intr_way; - pcic_intr_way_t *csc_intr_way; - pcic_intr_mapirq_t *map_irq; - pcic_init_t *init; -}; - -extern devclass_t pcic_devclass; -extern int pcic_override_irq; - -int pcic_activate_resource(device_t dev, device_t child, int type, int rid, - struct resource *r); -struct resource *pcic_alloc_resource(device_t dev, device_t child, int type, - int *rid, u_long start, u_long end, u_long count, u_int flags); -int pcic_attach(device_t dev); -void pcic_clrb(struct pcic_slot *sp, int reg, unsigned char mask); -int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid, - struct resource *r); -void pcic_dealloc(device_t dev); -void pcic_do_stat_delta(struct pcic_slot *sp); -int pcic_get_memory_offset(device_t bus, device_t child, int rid, - u_int32_t *offset); -int pcic_get_res_flags(device_t bus, device_t child, int restype, int rid, - u_long *value); -unsigned char pcic_getb_io(struct pcic_slot *sp, int reg); -driver_intr_t pcic_isa_intr; -int pcic_isa_intr1(void *); -pcic_intr_mapirq_t pcic_isa_mapirq; -void pcic_putb_io(struct pcic_slot *sp, int reg, unsigned char val); -int pcic_set_memory_offset(device_t bus, device_t child, int rid, - u_int32_t offset, u_int32_t *deltap); -int pcic_set_res_flags(device_t bus, device_t child, int restype, int rid, - u_long value); -void pcic_setb(struct pcic_slot *sp, int reg, unsigned char mask); -int pcic_setup_intr(device_t dev, device_t child, struct resource *irq, - int flags, driver_intr_t *intr, void *arg, void **cookiep); -int pcic_teardown_intr(device_t dev, device_t child, struct resource *irq, - void *cookie); -timeout_t pcic_timeout; diff --git a/sys/dev/misc/pccard/power_if.m b/sys/bus/pccard/power_if.m similarity index 90% rename from sys/dev/misc/pccard/power_if.m rename to sys/bus/pccard/power_if.m index 63e51119dd..4eef372961 100644 --- a/sys/dev/misc/pccard/power_if.m +++ b/sys/bus/pccard/power_if.m @@ -23,8 +23,8 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: src/sys/dev/pccard/power_if.m,v 1.2.2.1 2000/05/23 03:57:00 imp Exp $ -# $DragonFly: src/sys/dev/misc/pccard/Attic/power_if.m,v 1.2 2003/06/17 04:28:29 dillon Exp $ +# $FreeBSD: src/sys/dev/pccard/power_if.m,v 1.3 2000/04/16 06:04:13 imp Exp $ +# $DragonFly: src/sys/bus/pccard/power_if.m,v 1.1 2004/02/10 07:55:45 joerg Exp $ # #include diff --git a/sys/conf/files b/sys/conf/files index 1fb5cc3279..2435ecefa5 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,5 +1,5 @@ # $FreeBSD: src/sys/conf/files,v 1.340.2.137 2003/06/04 17:10:30 sam Exp $ -# $DragonFly: src/sys/conf/files,v 1.45 2004/02/09 21:13:17 dillon Exp $ +# $DragonFly: src/sys/conf/files,v 1.46 2004/02/10 07:55:46 joerg Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -249,6 +249,12 @@ dev/acpica/Osd/OsdStream.c optional acpica dev/acpica/Osd/OsdSynch.c optional acpica dev/acpica/Osd/OsdTable.c optional acpica +dev/pccard/pccbb/pccbb.c optional cbb +dev/pccard/cardbus/cardbus.c optional cardbus +dev/pccard/cardbus/cardbus_cis.c optional cardbus +dev/pccard/exca/exca.c optional cbb +dev/pccard/pcic/i82365.c optional pcic pccard +dev/pccard/pcic/i82365_isa.c optional pcic pccard isa dev/disk/advansys/adv_eisa.c optional adv eisa dev/disk/advansys/adv_pci.c optional adv pci @@ -262,13 +268,13 @@ dev/disk/advansys/adwmcode.c optional adw dev/netif/an/if_an.c optional an dev/netif/an/if_an_isa.c optional an isa dev/netif/an/if_an_pci.c optional an pci -dev/netif/an/if_an_pccard.c optional an card +dev/netif/an/if_an_pccard.c optional an pccard dev/netif/ar/if_ar.c optional ar dev/netif/ar/if_ar_pci.c optional ar pci dev/raid/asr/asr.c optional asr pci dev/disk/ata/ata-all.c optional ata dev/disk/ata/ata-isa.c optional ata isa -dev/disk/ata/ata-card.c optional ata card +dev/disk/ata/ata-card.c optional ata pccard dev/disk/ata/ata-pci.c optional ata pci dev/disk/ata/ata-dma.c optional ata pci dev/disk/ata/ata-disk.c optional atadisk @@ -290,7 +296,7 @@ dev/disk/aha/aha_isa.c optional aha isa dev/disk/aha/aha_mca.c optional aha mca dev/disk/ahb/ahb.c optional ahb eisa dev/disk/aic/aic.c optional aic -dev/disk/aic/aic_pccard.c optional aic card +dev/disk/aic/aic_pccard.c optional aic pccard dev/disk/aic7xxx/aic7770.c optional ahc eisa dev/disk/aic7xxx/ahc_eisa.c optional ahc eisa #dev/disk/aic7xxx/ahc_isa.c optional ahc isa @@ -314,7 +320,7 @@ dev/raid/ciss/ciss.c optional ciss dev/netif/cm/smc90cx6.c optional cm dev/netif/cs/if_cs.c optional cs dev/netif/cs/if_cs_isa.c optional cs isa -dev/netif/cs/if_cs_pccard.c optional cs card +dev/netif/cs/if_cs_pccard.c optional cs pccard #dev/raid/dpt/dpt_control.c optional dpt dev/raid/dpt/dpt_scsi.c optional dpt dev/raid/dpt/dpt_eisa.c optional dpt eisa @@ -324,13 +330,13 @@ dev/netif/ep/if_ep.c optional ep dev/netif/ep/if_ep_isa.c optional ep isa dev/netif/ep/if_ep_eisa.c optional ep eisa dev/netif/ep/if_ep_mca.c optional ep mca -dev/netif/ep/if_ep_pccard.c optional ep card +dev/netif/ep/if_ep_pccard.c optional ep pccard dev/atm/en/midway.c optional en dev/netif/ex/if_ex.c optional ex dev/netif/ex/if_ex_isa.c optional ex isa -dev/netif/ex/if_ex_pccard.c optional ex card +dev/netif/ex/if_ex_pccard.c optional ex pccard dev/netif/fe/if_fe.c optional fe -dev/netif/fe/if_fe_pccard.c optional fe card +dev/netif/fe/if_fe_pccard.c optional fe pccard bus/firewire/firewire.c optional firewire bus/firewire/fwcrom.c optional firewire bus/firewire/fwdev.c optional firewire @@ -417,20 +423,11 @@ dev/disk/mpt/mpt_pci.c optional mpt dev/netif/my/if_my.c optional my dev/misc/musycc/musycc.c optional musycc dev/disk/ncv/ncr53c500.c optional ncv -dev/disk/ncv/ncr53c500_pccard.c optional ncv card +dev/disk/ncv/ncr53c500_pccard.c optional ncv pccard dev/netif/nge/if_nge.c optional nge dev/misc/nmdm/nmdm.c optional nmdm dev/disk/nsp/nsp.c optional nsp -dev/disk/nsp/nsp_pccard.c optional nsp card -dev/misc/pccard/pccard.c optional pccard -dev/misc/pccard/pccard_cis.c optional pccard -dev/misc/pccard/pccard_cis_quirks.c optional pccard -dev/misc/pccard/power_if.m optional pccard -dev/misc/pccard/power_if.m optional card -dev/misc/pccard/card_if.m optional pccard -dev/misc/pccard/card_if.m optional card -dev/misc/pcic/i82365.c optional pcic pccard -dev/misc/pcic/i82365_isa.c optional pcic pccard +dev/disk/nsp/nsp_pccard.c optional nsp pccard dev/netif/fea/if_fea.c optional fea eisa dev/netif/fpa/if_fpa.c optional fpa pci dev/netif/pdq_layer/pdq.c optional fea eisa @@ -451,7 +448,7 @@ dev/misc/ppi/ppi.c optional ppi dev/misc/pps/pps.c optional pps dev/disk/vpo/vpo.c optional vpo dev/disk/vpo/vpoio.c optional vpo -dev/netif/ray/if_ray.c optional ray card +dev/netif/ray/if_ray.c optional ray pccard dev/netif/ray/if_ray.c optional ray pccard dev/crypto/rndtest/rndtest.c optional rndtest dev/serial/rp/rp.c optional nrp @@ -471,13 +468,13 @@ dev/serial/si/si_isa.c optional si isa dev/serial/si/si_pci.c optional si pci dev/netif/sn/if_sn.c optional sn dev/netif/sn/if_sn_isa.c optional sn isa -dev/netif/sn/if_sn_pccard.c optional sn card +dev/netif/sn/if_sn_pccard.c optional sn pccard dev/misc/snp/snp.c optional snp dev/netif/sr/if_sr.c optional sr dev/netif/sr/if_sr_pci.c optional sr pci dev/disk/stg/tmc18c30.c optional stg dev/disk/stg/tmc18c30_isa.c optional stg isa -dev/disk/stg/tmc18c30_pccard.c optional stg card +dev/disk/stg/tmc18c30_pccard.c optional stg pccard bus/iicbus/iicbb.c optional iicbb bus/iicbus/iicbb_if.m optional iicbb bus/iicbus/iicsmb.c optional iicsmb @@ -515,10 +512,10 @@ dev/netif/vx/if_vx.c optional vx dev/netif/vx/if_vx_eisa.c optional vx eisa dev/netif/vx/if_vx_pci.c optional vx pci dev/netif/wi/if_wi.c optional wi -dev/netif/wi/if_wi_pccard.c optional wi card +dev/netif/wi/if_wi_pccard.c optional wi pccard dev/netif/wi/if_wi_pci.c optional wi pci dev/netif/wi/wi_hostap.c optional wi -dev/netif/xe/if_xe.c optional xe card +dev/netif/xe/if_xe.c optional xe pccard vfs/gnu/ext2fs/ext2_alloc.c optional ext2fs vfs/gnu/ext2fs/ext2_balloc.c optional ext2fs vfs/gnu/ext2fs/ext2_inode.c optional ext2fs @@ -1056,12 +1053,12 @@ vfs/nwfs/nwfs_node.c optional nwfs vfs/nwfs/nwfs_subr.c optional nwfs vfs/nwfs/nwfs_vfsops.c optional nwfs vfs/nwfs/nwfs_vnops.c optional nwfs -bus/pccard/pccard.c optional card -bus/pccard/pccard_beep.c optional card -bus/pccard/pccard_nbk.c optional card -bus/pccard/pcic.c optional pcic card -bus/pccard/pcic_isa.c optional pcic isa card -bus/pccard/pcic_pci.c optional pcic pci card +bus/pccard/card_if.m standard +bus/pccard/pccard.c optional pccard +bus/pccard/pccard_cis.c optional pccard +bus/pccard/pccard_cis_quirks.c optional pccard +bus/pccard/pccard_beep.c optional pccard +bus/pccard/power_if.m standard dev/agp/agp.c optional agp dev/agp/agp_intel.c optional agp dev/agp/agp_nvidia.c optional agp @@ -1076,7 +1073,7 @@ dev/netif/awi/am79c930.c optional awi dev/netif/awi/awi.c optional awi dev/netif/awi/awi_wep.c optional awi dev/netif/awi/awi_wicfg.c optional awi -dev/netif/awi/if_awi_pccard.c optional awi card +dev/netif/awi/if_awi_pccard.c optional awi pccard dev/video/bktr/bktr_core.c optional bktr pci dev/video/bktr/bktr_i2c.c optional bktr pci smbus dev/video/bktr/bktr_card.c optional bktr pci diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 6af4104ff9..75d1d74333 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -1,6 +1,6 @@ # From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 # $FreeBSD: src/sys/conf/kmod.mk,v 1.82.2.15 2003/02/10 13:11:50 nyan Exp $ -# $DragonFly: src/sys/conf/kmod.mk,v 1.8 2003/11/17 00:54:39 asmodai Exp $ +# $DragonFly: src/sys/conf/kmod.mk,v 1.9 2004/02/10 07:55:46 joerg Exp $ # # The include file handles installing Kernel Loadable Device # drivers (KLD's). @@ -218,7 +218,8 @@ ${_src}: MFILES?= kern/bus_if.m kern/device_if.m bus/iicbus/iicbb_if.m \ bus/iicbus/iicbus_if.m bus/isa/isa_if.m dev/netif/mii_layer/miibus_if.m \ - dev/misc/pccard/card_if.m dev/misc/pccard/power_if.m bus/pci/pci_if.m \ + bus/pccard/card_if.m bus/pccard/power_if.m bus/pci/pci_if.m \ + bus/pci/pcib_if.m \ bus/ppbus/ppbus_if.m bus/smbus/smbus_if.m bus/usb/usb_if.m \ dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \ dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m \ diff --git a/sys/config/GENERIC b/sys/config/GENERIC index 0edc5ad639..c8ad116652 100644 --- a/sys/config/GENERIC +++ b/sys/config/GENERIC @@ -16,7 +16,7 @@ # in doubt as to the purpose or necessity of a line, check first in LINT. # # $FreeBSD: src/sys/i386/conf/GENERIC,v 1.246.2.54 2003/04/28 03:41:46 simokawa Exp $ -# $DragonFly: src/sys/config/GENERIC,v 1.8 2004/01/27 18:26:43 dillon Exp $ +# $DragonFly: src/sys/config/GENERIC,v 1.9 2004/02/10 07:55:47 joerg Exp $ machine i386 cpu I386_CPU @@ -171,9 +171,9 @@ device npx0 at nexus? port IO_NPX irq 13 device apm0 at nexus? disable flags 0x20 # Advanced Power Management # PCCARD (PCMCIA) support -device card -device pcic0 at isa? irq 0 port 0x3e0 iomem 0xd0000 -device pcic1 at isa? irq 0 port 0x3e2 iomem 0xd4000 disable +device pccard +device cardbus +device cbb # Serial (COM) ports device sio0 at isa? port IO_COM1 flags 0x10 irq 4 diff --git a/sys/config/LINT b/sys/config/LINT index b051c1f944..315c0f0031 100644 --- a/sys/config/LINT +++ b/sys/config/LINT @@ -3,7 +3,7 @@ # as much of the source tree as it can. # # $FreeBSD: src/sys/i386/conf/LINT,v 1.749.2.144 2003/06/04 17:56:59 sam Exp $ -# $DragonFly: src/sys/config/LINT,v 1.20 2004/02/06 15:31:58 hmp Exp $ +# $DragonFly: src/sys/config/LINT,v 1.21 2004/02/10 07:55:47 joerg Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -2048,11 +2048,13 @@ device bktr # # PCCARD/PCMCIA # -# card: pccard slots -# pcic: isa/pccard bridge -device pcic0 at isa? -device pcic1 at isa? -device card +# pccard: pccard slots +# pcic: isa/pccard bridge (OLDCARD) +# cardbus/cbb: cardbus bridge (NEWCARD) +device pccard +device cardbus +device cbb +device pcic # You may need to reset all pccards after resuming options PCIC_RESUME_RESET # reset after resume diff --git a/sys/dev/Makefile b/sys/dev/Makefile index 2067b7b684..f670d09cee 100644 --- a/sys/dev/Makefile +++ b/sys/dev/Makefile @@ -1,7 +1,7 @@ -# $DragonFly: src/sys/dev/Makefile,v 1.1 2003/08/15 08:32:26 dillon Exp $ +# $DragonFly: src/sys/dev/Makefile,v 1.2 2004/02/10 07:55:46 joerg Exp $ # -SUBDIR=agp crypto disk drm misc netif powermng raid \ +SUBDIR=agp crypto disk drm misc netif pccard powermng raid \ serial sound usbmisc video .include diff --git a/sys/dev/disk/fd/fd.c b/sys/dev/disk/fd/fd.c index e35737254a..901cd5f245 100644 --- a/sys/dev/disk/fd/fd.c +++ b/sys/dev/disk/fd/fd.c @@ -51,12 +51,12 @@ * * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 * $FreeBSD: src/sys/isa/fd.c,v 1.176.2.8 2002/05/15 21:56:14 joerg Exp $ - * $DragonFly: src/sys/dev/disk/fd/fd.c,v 1.12 2004/01/11 16:45:16 joerg Exp $ + * $DragonFly: src/sys/dev/disk/fd/fd.c,v 1.13 2004/02/10 07:55:46 joerg Exp $ * */ #include "opt_fdc.h" -#include "use_card.h" +#include "use_pccard.h" #include #include diff --git a/sys/dev/misc/Makefile b/sys/dev/misc/Makefile index 34d085b0f5..86bc56e3fb 100644 --- a/sys/dev/misc/Makefile +++ b/sys/dev/misc/Makefile @@ -1,6 +1,6 @@ -# $DragonFly: src/sys/dev/misc/Makefile,v 1.1 2003/08/15 08:32:29 dillon Exp $ +# $DragonFly: src/sys/dev/misc/Makefile,v 1.2 2004/02/10 07:55:46 joerg Exp $ # -SUBDIR=joy pcfclock streams nmdm pcic syscons pccard snp +SUBDIR=joy pcfclock streams nmdm syscons snp .include diff --git a/sys/dev/misc/pccard/Makefile b/sys/dev/misc/pccard/Makefile deleted file mode 100644 index 25d5a60636..0000000000 --- a/sys/dev/misc/pccard/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD: src/sys/modules/pccard/Makefile,v 1.3 1999/11/28 21:11:09 imp Exp $ -# $DragonFly: src/sys/dev/misc/pccard/Attic/Makefile,v 1.2 2003/06/17 04:28:46 dillon Exp $ - -.PATH: ${.CURDIR}/../../dev/pccard -KMOD= pccard -SRCS= pccard.c pccard_cis.c pccard_cis_quirks.c \ - device_if.h bus_if.h card_if.h card_if.c power_if.h power_if.c -NOMAN= - -.include diff --git a/sys/dev/misc/pccard/Makefile.pccarddevs b/sys/dev/misc/pccard/Makefile.pccarddevs deleted file mode 100644 index 04d3614ec7..0000000000 --- a/sys/dev/misc/pccard/Makefile.pccarddevs +++ /dev/null @@ -1,9 +0,0 @@ -# $NetBSD: Makefile.pcmciadevs,v 1.1 1998/07/19 17:28:15 christos Exp $ -# $FreeBSD: src/sys/dev/pccard/Makefile.pccarddevs,v 1.1 1999/10/26 06:52:28 imp Exp $ -# $DragonFly: src/sys/dev/misc/pccard/Attic/Makefile.pccarddevs,v 1.2 2003/06/17 04:28:28 dillon Exp $ - -AWK= awk - -pccarddevs.h pccarddevs_data.h: pccarddevs devlist2h.awk - /bin/rm -f pccarddevs.h pccarddevs_data.h - ${AWK} -f devlist2h.awk pccarddevs diff --git a/sys/dev/misc/pccard/card_if.m b/sys/dev/misc/pccard/card_if.m deleted file mode 100644 index bf9161a4d4..0000000000 --- a/sys/dev/misc/pccard/card_if.m +++ /dev/null @@ -1,86 +0,0 @@ -# -# 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: src/sys/dev/pccard/card_if.m,v 1.1.2.2 2001/01/02 22:49:15 dmlb Exp $ -# $DragonFly: src/sys/dev/misc/pccard/Attic/card_if.m,v 1.3 2004/01/08 10:06:29 joerg Exp $ -# - -#include - -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. -# -METHOD int set_res_flags { - device_t dev; - device_t child; - int restype; - int rid; - u_long value; -}; - -METHOD int get_res_flags { - device_t dev; - device_t child; - int restype; - int rid; - u_long *value; -}; - -METHOD int set_memory_offset { - device_t dev; - device_t child; - int rid; - u_int32_t offset; - u_int32_t *deltap; -} - -METHOD int get_memory_offset { - device_t dev; - device_t child; - int rid; - u_int32_t *offset; -} - -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/misc/pccard/files.pccard b/sys/dev/misc/pccard/files.pccard deleted file mode 100644 index 35e2279ff0..0000000000 --- a/sys/dev/misc/pccard/files.pccard +++ /dev/null @@ -1,72 +0,0 @@ -# $NetBSD: files.pcmcia,v 1.14 1999/01/01 19:30:03 christos Exp $ -# $FreeBSD: src/sys/dev/pccard/files.pccard,v 1.1 1999/10/26 06:52:29 imp Exp $ -# $DragonFly: src/sys/dev/misc/pccard/Attic/files.pccard,v 1.2 2003/06/17 04:28:29 dillon Exp $ -# -# Config.new file and device description for machine-independent PCMCIA code. -# Included by ports that need it. - -defopt PCMCIAVERBOSE - -device pcmcia {[function = -1], [irq = -1]} -file dev/pcmcia/pcmcia.c pcmcia -file dev/pcmcia/pcmcia_cis.c pcmcia -file dev/pcmcia/pcmcia_cis_quirks.c pcmcia - -# device declaration in sys/conf/files -attach pcmcia at pcmciabus - -# 3Com 3c589 Ethernet, 3c562 multifunction Ethernet, and 3CXEM556 -# multifunction Ethernet controllers -# device declaration in sys/conf/files -attach ep at pcmcia with ep_pcmcia: elink -file dev/pcmcia/if_ep_pcmcia.c ep_pcmcia - -# National Semiconductor DS8390/WD83C690-based boards -# (NE[12]000, and clones) -attach ne at pcmcia with ne_pcmcia: rtl80x9 -file dev/pcmcia/if_ne_pcmcia.c ne_pcmcia - -# Adaptec APA-1460 SCSI Host Adapter -#attach aic at pcmcia with aic_pcmcia -#file dev/pcmcia/aic_pcmcia.c aic_pcmcia - -#attach com at pcmcia with com_pcmcia -#file dev/pcmcia/com_pcmcia.c com_pcmcia - -# Digital RoamAbout / Lucent WaveLAN PCMCIA card -#device wl: arp, ether, ifnet -#attach wl at pcmcia with wl_pcmcia -#file dev/pcmcia/if_wl_pcmcia.c wl_pcmcia -#defopt opt_wl_pcmcia.h WL_TIMER WLP_CC_DEBUG WL_DEBUG MMC_STATUS WL_IFCNTRS WL_TIMING - -# PCMCIA IDE controller -#attach wdc at pcmcia with wdc_pcmcia -#file dev/pcmcia/wdc_pcmcia.c wdc_pcmcia - -# SMC91Cxx Ethernet Controllers (i.e. Megahertz X-Jack) -attach sn at pcmcia with sm_pcmcia -file dev/pcmcia/if_sm_pcmcia.c sm_pcmcia - -# MB8696x Ethernet Controllers (i.e. TDK LAK CD021BX) -attach fe at pcmcia with mbe_pcmcia -file dev/pcmcia/if_mbe_pcmcia.c mbe_pcmcia - -# PCMCIA Floppy controller -#attach fdc at pcmcia with fdc_pcmcia -#file dev/pcmcia/fdc_pcmcia.c fdc_pcmcia - -# PCMCIA multi-port serial cards -#device pcmcom {[slave = -1]} -#attach pcmcom at pcmcia -#attach com at pcmcom with com_pcmcom -#file dev/pcmcia/pcmcom.c pcmcom | com_pcmcom needs-flag - -# Xircom Netwave -#device cnw: arp, ether, ifnet -#attach cnw at pcmcia -#file dev/pcmcia/if_cnw.c cnw - -# Xircom CreditCard -device xe: ether, ifnet -attach xe at pcmcia with xe_pcmcia -file dev/pcmcia/if_xe.c xe diff --git a/sys/dev/misc/pccard/pccard.c b/sys/dev/misc/pccard/pccard.c deleted file mode 100644 index 09fd48e4f6..0000000000 --- a/sys/dev/misc/pccard/pccard.c +++ /dev/null @@ -1,689 +0,0 @@ -/* - * 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. - * - * $NetBSD: pcmcia.c,v 1.13 1998/12/24 04:51:59 marc Exp $ - * $FreeBSD: src/sys/dev/pccard/pccard.c,v 1.8.2.1 2000/05/23 03:56:59 imp Exp $ - * $DragonFly: src/sys/dev/misc/pccard/Attic/pccard.c,v 1.4 2004/01/08 10:06:29 joerg Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include "power_if.h" -#include "card_if.h" - -#define PCCARDDEBUG - -#ifdef PCCARDDEBUG -int pccard_debug = 1; -#define DPRINTF(arg) if (pccard_debug) printf arg -#define DEVPRINTF(arg) if (pccard_debug) device_printf arg -#else -#define DPRINTF(arg) -#define DEVPRINTF(arg) -#endif - -#ifdef PCCARDVERBOSE -int pccard_verbose = 1; -#else -int pccard_verbose = 0; -#endif - -int pccard_print(void *, const char *); - -int -pccard_ccr_read(pf, ccr) - struct pccard_function *pf; - int ccr; -{ - return (bus_space_read_1(pf->pf_ccrt, pf->pf_ccrh, - pf->pf_ccr_offset + ccr)); -} - -void -pccard_ccr_write(pf, ccr, val) - struct pccard_function *pf; - int ccr; - int val; -{ - - if ((pf->ccr_mask) & (1 << (ccr / 2))) { - bus_space_write_1(pf->pf_ccrt, pf->pf_ccrh, - pf->pf_ccr_offset + ccr, val); - } -} - -static int -pccard_attach_card(device_t dev) -{ - struct pccard_softc *sc = (struct pccard_softc *) - device_get_softc(dev); - struct pccard_function *pf; - int attached; - - DEVPRINTF((dev, "pccard_card_attach\n")); - /* - * this is here so that when socket_enable calls gettype, trt happens - */ - STAILQ_INIT(&sc->card.pf_head); - - DEVPRINTF((dev, "chip_socket_enable\n")); - POWER_ENABLE_SOCKET(device_get_parent(dev), dev); - - DEVPRINTF((dev, "read_cis\n")); - pccard_read_cis(sc); - - DEVPRINTF((dev, "chip_socket_disable\n")); - POWER_DISABLE_SOCKET(device_get_parent(dev), dev); - - DEVPRINTF((dev, "check_cis_quirks\n")); - pccard_check_cis_quirks(dev); - - /* - * bail now if the card has no functions, or if there was an error in - * the cis. - */ - - if (sc->card.error) - return (1); - if (STAILQ_EMPTY(&sc->card.pf_head)) - return (1); - - if (pccard_verbose) - pccard_print_cis(dev); - - attached = 0; - - DEVPRINTF((dev, "functions scanning\n")); - STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { - if (STAILQ_EMPTY(&pf->cfe_head)) - continue; - - pf->sc = sc; - pf->cfe = NULL; - pf->ih_fct = NULL; - pf->ih_arg = NULL; - } - - STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { - if (STAILQ_EMPTY(&pf->cfe_head)) - continue; - -#if XXX - if (attach_child()) { - attached++; - - DEVPRINTF((sc->dev, "function %d CCR at %d " - "offset %lx: %x %x %x %x, %x %x %x %x, %x\n", - pf->number, pf->pf_ccr_window, pf->pf_ccr_offset, - pccard_ccr_read(pf, 0x00), - pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04), - pccard_ccr_read(pf, 0x06), pccard_ccr_read(pf, 0x0A), - pccard_ccr_read(pf, 0x0C), pccard_ccr_read(pf, 0x0E), - pccard_ccr_read(pf, 0x10), pccard_ccr_read(pf, 0x12))); - } -#endif - } - - return (attached ? 0 : 1); -} - -static int -pccard_detach_card(device_t dev, int flags) -{ - struct pccard_softc *sc = (struct pccard_softc *) - device_get_softc(dev); - struct pccard_function *pf; -#if XXX - int error; -#endif - - /* - * We are running on either the PCCARD socket's event thread - * or in user context detaching a device by user request. - */ - STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { - if (STAILQ_FIRST(&pf->cfe_head) == NULL) - continue; -#if XXX - DEVPRINTF((sc->dev, "detaching %s (function %d)\n", - device_get_name(pf->child), pf->number)); - if ((error = config_detach(pf->child, flags)) != 0) { - device_printf(sc->dev, - "error %d detaching %s (function %d)\n", - error, device_get_name(pf->child), pf->number); - } else - pf->child = NULL; -#endif - } - return 0; -} - -static int -pccard_card_gettype(device_t dev, int *type) -{ - struct pccard_softc *sc = (struct pccard_softc *) - device_get_softc(dev); - struct pccard_function *pf; - - /* - * set the iftype to memory if this card has no functions (not yet - * probed), or only one function, and that is not initialized yet or - * that is memory. - */ - pf = STAILQ_FIRST(&sc->card.pf_head); - if (pf == NULL || - (STAILQ_NEXT(pf, pf_list) == NULL && - (pf->cfe == NULL || pf->cfe->iftype == PCCARD_IFTYPE_MEMORY))) - *type = PCCARD_IFTYPE_MEMORY; - else - *type = PCCARD_IFTYPE_IO; - return 0; -} - -/* - * Initialize a PCCARD function. May be called as long as the function is - * disabled. - */ -void -pccard_function_init(struct pccard_function *pf, - struct pccard_config_entry *cfe) -{ - if (pf->pf_flags & PFF_ENABLED) - panic("pccard_function_init: function is enabled"); - - /* Remember which configuration entry we are using. */ - pf->cfe = cfe; -} - -/* Enable a PCCARD function */ -int -pccard_function_enable(struct pccard_function *pf) -{ - struct pccard_function *tmp; - int reg; - device_t dev = pf->sc->dev; - - if (pf->cfe == NULL) - panic("pccard_function_enable: function not initialized"); - - /* - * Increase the reference count on the socket, enabling power, if - * necessary. - */ - if (pf->sc->sc_enabled_count++ == 0) - POWER_ENABLE_SOCKET(device_get_parent(dev), dev); - DEVPRINTF((dev, "++enabled_count = %d\n", pf->sc->sc_enabled_count)); - - if (pf->pf_flags & PFF_ENABLED) { - /* - * Don't do anything if we're already enabled. - */ - return (0); - } - - /* - * it's possible for different functions' CCRs to be in the same - * underlying page. Check for that. - */ - - STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { - if ((tmp->pf_flags & PFF_ENABLED) && - (pf->ccr_base >= (tmp->ccr_base - tmp->pf_ccr_offset)) && - ((pf->ccr_base + PCCARD_CCR_SIZE) <= - (tmp->ccr_base - tmp->pf_ccr_offset + - tmp->pf_ccr_realsize))) { - pf->pf_ccrt = tmp->pf_ccrt; - pf->pf_ccrh = tmp->pf_ccrh; - pf->pf_ccr_realsize = tmp->pf_ccr_realsize; - - /* - * pf->pf_ccr_offset = (tmp->pf_ccr_offset - - * tmp->ccr_base) + pf->ccr_base; - */ - pf->pf_ccr_offset = - (tmp->pf_ccr_offset + pf->ccr_base) - - tmp->ccr_base; - pf->pf_ccr_window = tmp->pf_ccr_window; - break; - } - } - - if (tmp == NULL) { - pf->ccr_rid = 0; - pf->ccr_res = bus_alloc_resource(dev, SYS_RES_MEMORY, - &pf->ccr_rid, pf->ccr_base, pf->ccr_base + PCCARD_CCR_SIZE, - PCCARD_CCR_SIZE, RF_ACTIVE); - /* XXX SET MEM_ATTR */ - if (!pf->ccr_res) - goto bad; - pf->pf_ccrt = rman_get_bustag(pf->ccr_res); - pf->pf_ccrh = rman_get_bushandle(pf->ccr_res); - pf->pf_ccr_offset = rman_get_start(pf->ccr_res); - pf->pf_ccr_realsize = 1; - } - - reg = (pf->cfe->number & PCCARD_CCR_OPTION_CFINDEX); - reg |= PCCARD_CCR_OPTION_LEVIREQ; - if (pccard_mfc(pf->sc)) { - reg |= (PCCARD_CCR_OPTION_FUNC_ENABLE | - PCCARD_CCR_OPTION_ADDR_DECODE); - if (pf->ih_fct) - reg |= PCCARD_CCR_OPTION_IREQ_ENABLE; - - } - pccard_ccr_write(pf, PCCARD_CCR_OPTION, reg); - - reg = 0; - - if ((pf->cfe->flags & PCCARD_CFE_IO16) == 0) - reg |= PCCARD_CCR_STATUS_IOIS8; - if (pf->cfe->flags & PCCARD_CFE_AUDIO) - reg |= PCCARD_CCR_STATUS_AUDIO; - pccard_ccr_write(pf, PCCARD_CCR_STATUS, reg); - - pccard_ccr_write(pf, PCCARD_CCR_SOCKETCOPY, 0); - - if (pccard_mfc(pf->sc)) { - long tmp, iosize; - - tmp = pf->pf_mfc_iomax - pf->pf_mfc_iobase; - /* round up to nearest (2^n)-1 */ - for (iosize = 1; iosize < tmp; iosize <<= 1) - ; - iosize--; - - pccard_ccr_write(pf, PCCARD_CCR_IOBASE0, - pf->pf_mfc_iobase & 0xff); - pccard_ccr_write(pf, PCCARD_CCR_IOBASE1, - (pf->pf_mfc_iobase >> 8) & 0xff); - pccard_ccr_write(pf, PCCARD_CCR_IOBASE2, 0); - pccard_ccr_write(pf, PCCARD_CCR_IOBASE3, 0); - - pccard_ccr_write(pf, PCCARD_CCR_IOSIZE, iosize); - } - -#ifdef PCCARDDEBUG - if (pccard_debug) { - STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { - device_printf(tmp->sc->dev, - "function %d CCR at %d offset %x: " - "%x %x %x %x, %x %x %x %x, %x\n", - tmp->number, tmp->pf_ccr_window, - tmp->pf_ccr_offset, - pccard_ccr_read(tmp, 0x00), - pccard_ccr_read(tmp, 0x02), - pccard_ccr_read(tmp, 0x04), - pccard_ccr_read(tmp, 0x06), - pccard_ccr_read(tmp, 0x0A), - pccard_ccr_read(tmp, 0x0C), - pccard_ccr_read(tmp, 0x0E), - pccard_ccr_read(tmp, 0x10), - pccard_ccr_read(tmp, 0x12)); - } - } -#endif - pf->pf_flags |= PFF_ENABLED; - return (0); - - bad: - /* - * Decrement the reference count, and power down the socket, if - * necessary. - */ - if (--pf->sc->sc_enabled_count == 0) - POWER_DISABLE_SOCKET(device_get_parent(dev), dev); - DEVPRINTF((dev, "--enabled_count = %d\n", pf->sc->sc_enabled_count)); - - return (1); -} - -/* Disable PCCARD function. */ -void -pccard_function_disable(struct pccard_function *pf) -{ - struct pccard_function *tmp; - device_t dev = pf->sc->dev; - - if (pf->cfe == NULL) - panic("pccard_function_enable: function not initialized"); - - if ((pf->pf_flags & PFF_ENABLED) == 0) { - /* - * Don't do anything if we're already disabled. - */ - return; - } - - /* - * it's possible for different functions' CCRs to be in the same - * underlying page. Check for that. Note we mark us as disabled - * first to avoid matching ourself. - */ - - pf->pf_flags &= ~PFF_ENABLED; - STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { - if ((tmp->pf_flags & PFF_ENABLED) && - (pf->ccr_base >= (tmp->ccr_base - tmp->pf_ccr_offset)) && - ((pf->ccr_base + PCCARD_CCR_SIZE) <= - (tmp->ccr_base - tmp->pf_ccr_offset + tmp->pf_ccr_realsize))) - break; - } - - /* Not used by anyone else; unmap the CCR. */ - if (tmp == NULL) { - bus_release_resource(dev, SYS_RES_MEMORY, pf->ccr_rid, - pf->ccr_res); - pf->ccr_res = NULL; - } - - /* - * Decrement the reference count, and power down the socket, if - * necessary. - */ - if (--pf->sc->sc_enabled_count == 0) - POWER_DISABLE_SOCKET(device_get_parent(dev), dev); - DEVPRINTF((dev, "--enabled_count = %d\n", pf->sc->sc_enabled_count)); -} - -#if 0 -/* XXX These functions are needed, but not like this XXX */ -int -pccard_io_map(struct pccard_function *pf, int width, bus_addr_t offset, - bus_size_t size, struct pccard_io_handle *pcihp, int *windowp) -{ - int reg; - - if (pccard_chip_io_map(pf->sc->pct, pf->sc->pch, - width, offset, size, pcihp, windowp)) - return (1); - - /* - * XXX in the multifunction multi-iospace-per-function case, this - * needs to cooperate with io_alloc to make sure that the spaces - * don't overlap, and that the ccr's are set correctly - */ - - if (pccard_mfc(pf->sc)) { - long tmp, iosize; - - if (pf->pf_mfc_iomax == 0) { - pf->pf_mfc_iobase = pcihp->addr + offset; - pf->pf_mfc_iomax = pf->pf_mfc_iobase + size; - } else { - /* this makes the assumption that nothing overlaps */ - if (pf->pf_mfc_iobase > pcihp->addr + offset) - pf->pf_mfc_iobase = pcihp->addr + offset; - if (pf->pf_mfc_iomax < pcihp->addr + offset + size) - pf->pf_mfc_iomax = pcihp->addr + offset + size; - } - - tmp = pf->pf_mfc_iomax - pf->pf_mfc_iobase; - /* round up to nearest (2^n)-1 */ - for (iosize = 1; iosize >= tmp; iosize <<= 1) - ; - iosize--; - - pccard_ccr_write(pf, PCCARD_CCR_IOBASE0, - pf->pf_mfc_iobase & 0xff); - pccard_ccr_write(pf, PCCARD_CCR_IOBASE1, - (pf->pf_mfc_iobase >> 8) & 0xff); - pccard_ccr_write(pf, PCCARD_CCR_IOBASE2, 0); - pccard_ccr_write(pf, PCCARD_CCR_IOBASE3, 0); - - pccard_ccr_write(pf, PCCARD_CCR_IOSIZE, iosize); - - reg = pccard_ccr_read(pf, PCCARD_CCR_OPTION); - reg |= PCCARD_CCR_OPTION_ADDR_DECODE; - pccard_ccr_write(pf, PCCARD_CCR_OPTION, reg); - } - return (0); -} - -void -pccard_io_unmap(struct pccard_function *pf, int window) -{ - - pccard_chip_io_unmap(pf->sc->pct, pf->sc->pch, window); - - /* XXX Anything for multi-function cards? */ -} -#endif - -#define PCCARD_NPORT 2 -#define PCCARD_NMEM 5 -#define PCCARD_NIRQ 1 -#define PCCARD_NDRQ 0 - -static int -pccard_add_children(device_t dev, int busno) -{ - /* Call parent to scan for any current children */ - return 0; -} - -static int -pccard_probe(device_t dev) -{ - device_set_desc(dev, "PC Card bus -- newconfig version"); - 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) -{ - struct resource_list_entry *rle; - int printed; - int i; - - printed = 0; - for (i = 0; i < count; i++) { - rle = resource_list_find(rl, type, i); - if (rle) { - if (printed == 0) - printf(" %s ", name); - else if (printed > 0) - printf(","); - printed++; - printf(format, rle->start); - if (rle->count > 1) { - printf("-"); - printf(format, rle->start + rle->count - 1); - } - } else if (i > 3) { - /* check the first few regardless */ - break; - } - } -} - -static int -pccard_print_child(device_t dev, device_t child) -{ - struct pccard_ivar *devi = (struct pccard_ivar *) device_get_ivars(child); - struct resource_list *rl = &devi->resources; - int retval = 0; - - retval += bus_print_child_header(dev, child); - retval += printf(" at"); - - if (devi) { - pccard_print_resources(rl, "port", SYS_RES_IOPORT, - PCCARD_NPORT, "%#lx"); - pccard_print_resources(rl, "iomem", SYS_RES_MEMORY, - PCCARD_NMEM, "%#lx"); - pccard_print_resources(rl, "irq", SYS_RES_IRQ, PCCARD_NIRQ, - "%ld"); - pccard_print_resources(rl, "drq", SYS_RES_DRQ, PCCARD_NDRQ, - "%ld"); - retval += printf(" slot %d", devi->slotnum); - } - - retval += bus_print_child_footer(dev, child); - - return (retval); -} - -static int -pccard_set_resource(device_t dev, device_t child, int type, int rid, - u_long start, u_long count) -{ - struct pccard_ivar *devi = (struct pccard_ivar *) device_get_ivars(child); - struct resource_list *rl = &devi->resources; - - if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY - && type != SYS_RES_IRQ && type != SYS_RES_DRQ) - return EINVAL; - if (rid < 0) - return EINVAL; - if (type == SYS_RES_IOPORT && rid >= PCCARD_NPORT) - return EINVAL; - if (type == SYS_RES_MEMORY && rid >= PCCARD_NMEM) - return EINVAL; - if (type == SYS_RES_IRQ && rid >= PCCARD_NIRQ) - return EINVAL; - if (type == SYS_RES_DRQ && rid >= PCCARD_NDRQ) - return EINVAL; - - resource_list_add(rl, type, rid, start, start + count - 1, count); - - return 0; -} - -static int -pccard_get_resource(device_t dev, device_t child, int type, int rid, - u_long *startp, u_long *countp) -{ - struct pccard_ivar *devi = (struct pccard_ivar *) device_get_ivars(child); - struct resource_list *rl = &devi->resources; - struct resource_list_entry *rle; - - rle = resource_list_find(rl, type, rid); - if (!rle) - return ENOENT; - - if (startp) - *startp = rle->start; - if (countp) - *countp = rle->count; - - return 0; -} - -static void -pccard_delete_resource(device_t dev, device_t child, int type, int rid) -{ - struct pccard_ivar *devi = (struct pccard_ivar *) device_get_ivars(child); - struct resource_list *rl = &devi->resources; - 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, u_int32_t *deltap) -{ - return CARD_SET_MEMORY_OFFSET(device_get_parent(dev), child, rid, - offset, deltap); -} - -static device_method_t pccard_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, pccard_probe), - DEVMETHOD(device_attach, pccard_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, pccard_print_child), - DEVMETHOD(bus_driver_added, bus_generic_driver_added), - DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_set_resource, pccard_set_resource), - 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 } -}; - -static driver_t pccard_driver = { - "pccard", - pccard_methods, - 1, /* no softc */ -}; - -devclass_t pccard_devclass; - -DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0); -DRIVER_MODULE(pccard, pc98pcic, pccard_driver, pccard_devclass, 0, 0); -DRIVER_MODULE(pccard, pccbb, pccard_driver, pccard_devclass, 0, 0); -DRIVER_MODULE(pccard, tcic, pccard_driver, pccard_devclass, 0, 0); diff --git a/sys/dev/misc/pccard/pccardchip.h b/sys/dev/misc/pccard/pccardchip.h deleted file mode 100644 index 9d1a501a37..0000000000 --- a/sys/dev/misc/pccard/pccardchip.h +++ /dev/null @@ -1,149 +0,0 @@ -/* $NetBSD: pcmciachip.h,v 1.4 1999/10/15 06:07:32 haya Exp $ */ -/* $FreeBSD: src/sys/dev/pccard/pccardchip.h,v 1.6 2000/01/10 06:58:17 imp Exp $ */ -/* $DragonFly: src/sys/dev/misc/pccard/Attic/pccardchip.h,v 1.2 2003/06/17 04:28:29 dillon Exp $ */ - -/* - * 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 - -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/misc/pccard/pccarddevs b/sys/dev/misc/pccard/pccarddevs deleted file mode 100644 index 77e9ec61f3..0000000000 --- a/sys/dev/misc/pccard/pccarddevs +++ /dev/null @@ -1,284 +0,0 @@ -$FreeBSD: src/sys/dev/pccard/pccarddevs,v 1.3.2.1 2000/05/23 03:57:00 imp Exp $ -$DragonFly: src/sys/dev/misc/pccard/Attic/pccarddevs,v 1.2 2003/06/17 04:28:29 dillon Exp $ -/* $NetBSD: pcmciadevs,v 1.60 1999/11/29 02:28:19 jun Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * 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 the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -/* - * List of known PCMCIA vendors - */ - -vendor FUJITSU 0x0004 Fujitsu Corporation -vendor PANASONIC 0x0032 Matsushita Electric Industrial Co. -vendor SANDISK 0x0045 Sandisk Corporation -vendor NEWMEDIA 0x0057 NewMedia Corporation -vendor INTEL 0x0089 Intel Corporation -vendor IBM 0x00a4 IBM Corporation -vendor MOTOROLA 0x0109 Motorola Corporation -vendor 3COM 0x0101 3Com Corporation -vendor MEGAHERTZ 0x0102 Megahertz Corporation -vendor SOCKET 0x0104 Socket Communications -vendor TDK 0x0105 TDK Corporation -vendor XIRCOM 0x0105 Xircom -vendor SMC 0x0108 Standard Microsystems Corporation -vendor USROBOTICS 0x0115 US Robotics Corporation -vendor MEGAHERTZ2 0x0128 Megahertz Corporation -vendor ADAPTEC 0x012f Adaptec Corporation -vendor COMPAQ 0x0138 Compaq -vendor LINKSYS 0x0149 Linksys Corporation -vendor SIMPLETECH 0x014d Simple Technology -vendor LUCENT 0x0156 Lucent Technologies -vendor AIRONET 0x015f Aironet Wireless Communications -vendor COMPAQ2 0x0183 Compaq -vendor DAYNA 0x0194 Dayna Corporation -vendor RAYTHEON 0x01a6 Raytheon -vendor IODATA 0x01bf I-O DATA -vendor BAY 0x01eb Bay Networks -vendor NOKIA 0x023d Nokia Communications -vendor LASAT 0x3401 Lasat Communications A/S -vendor LEXARMEDIA 0x4e01 Lexar Media -vendor COMPEX 0x8a01 Compex Corporation -vendor MELCO 0x8a01 Melco Corporation -vendor CONTEC 0xc001 Contec -vendor COREGA 0xc00f Corega K.K. -vendor ALLIEDTELESIS 0xc00f Allied Telesis K.K. -vendor HAGIWARASYSCOM 0xc012 Hagiwara SYS-COM -vendor RATOC 0xc015 RATOC System Inc. - -/* - * List of known products. Grouped by vendor. - */ - -/* Adaptec Products */ -product ADAPTEC APA1460_1 0x0001 Adaptec APA-1460/A SCSI Host Adapter -product ADAPTEC APA1460_2 0x0002 Adaptec APA-1460/B SCSI Host Adapter - -/* 3COM Products */ -product 3COM 3C1 0x0cf1 3Com Megahertz 3C1 10Mbps LAN CF+ Card -product 3COM 3C562 0x0562 3Com 3c562 33.6 Modem/10Mbps Ethernet -product 3COM 3C589 0x0589 3Com 3c589 10Mbps Ethernet -product 3COM 3C574 0x0574 3Com 3c574-TX 10/100Mbps Ethernet -product 3COM 3CXM056BNW 0x002f 3Com/NoteWorthy 3CXM056-BNW 56K Modem -product 3COM 3CXEM556 0x0035 3Com/Megahertz 3CXEM556 Ethernet/Modem -product 3COM 3CXEM556INT 0x003d 3Com/Megahertz 3CXEM556-INT Ethernet/Modem -product 3COM 3CCFEM556BI 0x0556 3Com/Megahertz 3CCFEM556BI Ethernet/Modem - -/* Compex Products */ -product COMPEX LINKPORT_ENET_B 0x0100 Compex Linkport ENET-B Ethernet - -/* Lasat Products */ -product LASAT CREDIT_288 0x2811 Lasat Credit 288 Modem - -/* Dayna Products */ -product DAYNA COMMUNICARD_E_1 0x002d Dayna CommuniCard E -product DAYNA COMMUNICARD_E_2 0x002f Dayna CommuniCard E - -/* DIGITAL Products */ -product DIGITAL MOBILE_MEDIA_CDROM 0x0d00 Digital Mobile Media CD-ROM - -/* Fujutsu Products */ -product FUJITSU SCSI600 0x0401 Fujitsu SCSI 600 Interface - -/* Motorola Products */ -product MOTOROLA POWER144 0x0105 Motorola Power 14.4 Modem -product MOTOROLA PM100C 0x0302 Motorola Personal Messenger 100C CDPD Modem - -/* Fujitsu Products */ -product FUJITSU LA501 0x2000 Fujitsu Towa LA501 Ethernet -product FUJITSU LA10S 0x1003 Fujitsu Compact Flash Ethernet - -/* IBM Products */ -product IBM 3270 0x0001 3270 Emulation -product IBM INFOMOVER 0x0002 National Semiconductor InfoMover -product IBM 5250 0x000b 5250 Emulation -product IBM TROPIC 0x001e Token Ring 4/16 -product IBM HOME_AND_AWAY 0x002e IBM Home and Away Modem -product IBM WIRELESS_LAN_ENTRY 0x0032 Wireless LAN Entry -product IBM PORTABLE_CDROM 0x002d PCMCIA Portable CD-ROM Drive -product IBM ETHERJET 0x003f IBM EtherJet Ethernet - -/* I-O DATA */ -product IODATA PCLATE 0x2216 I-O DATA PCLA/TE - -/* Lexar Media */ -product LEXARMEDIA COMPATFLASH 0x0100 Lexar Media CompactFlash - -/* Linksys corporation */ -product LINKSYS ETHERFAST 0x0230 Linksys Etherfast 10/100 Ethernet -product LINKSYS ECARD_1 0x0265 Linksys EthernetCard or D-Link DE-650 -product LINKSYS COMBO_ECARD 0xc1ab Linksys Combo EthernetCard -product LINKSYS TRUST_COMBO_ECARD 0x021b Trust (Linksys) Combo EthernetCard - -/* Megahertz Products */ -product MEGAHERTZ XJ4288 0x0023 Megahertz XJ4288 Modem -product MEGAHERTZ XJ4336 0x0027 Megahertz XJ4336 Modem -product MEGAHERTZ XJ5560 0x0034 Megahertz X-JACK 56kbps Modem -product MEGAHERTZ2 XJACK 0x0103 Megahertz X-JACK Ethernet -product MEGAHERTZ XJEM3336 0x0006 Megahertz X-JACK Ethernet Modem - -/* Melco Products */ -product MELCO LPC3_TX 0xc1ab Melco LPC3-TX - -/* Nokia Products */ -product NOKIA C020_WLAN 0x20c0 Nokia C020 WLAN Card - -/* Panasonic Products */ -product PANASONIC KXLC002 0x0304 Panasonic 4X CD-ROM Interface Card - -/* US Robotics Products */ -product USROBOTICS WORLDPORT144 0x3330 US Robotics WorldPort 14.4 Modem - -/* Sandisk Products */ -product SANDISK SDCFB 0x0401 Sandisk CompactFlash Card - -/* Simple Technology Products */ -product SIMPLETECH COMMUNICATOR288 0x0100 Simple Technology 28.8 Communicator -/* Simpletech ID also used by Symbol */ -product SIMPLETECH SPECTRUM24 0x801 Symbol Spectrum24 WLAN Adapter - -/* Socket Communications Products */ -product SOCKET PAGECARD 0x0003 Socket Communications PageCard -product SOCKET DUAL_RS232 0x0006 Socket Communications Dual RS232 -product SOCEKT LP_ETHER_CF 0x0075 Socket Communications Low Power Ethernet CF - -/* TDK Products */ -product TDK LAK_CD021BX 0x0200 TDK LAK-CD021BX Ethernet -product TDK DFL9610 0x0d0a TDK DFL9610 Ethernet & Digital Cellular -product TDK LAK_CF010 0x0900 TDK LAC-CF010 - -/* TDK Vendor ID also used by Xircom! */ -product TDK XIR_CE_10 0x0108 Xircom CreditCard Ethernet -product TDK XIR_CEM_10 0x110a Xircom CreditCard Ethernet + Modem -product TDK XIR_CEM_28 0x110b Xircom CreditCard Ethernet + Modem 28.8 -product TDK XIR_PS_CE2_10 0x010b Xircom CreditCard CE2 Ethernet -product TDK XIR_CE3_10_100 0x010a Xircom CreditCard CE3 10/100 Ethernet -/* conflicts with above - * product TDK XIR_CFE_10 0x010a Xircom CompactCard CFE-10 - */ -product TDK XIR_CNW_801 0x0801 Xircom CreditCard Netwave (Canada) -product TDK XIR_CNW_802 0x0802 Xircom CreditCard Netwave (US) - -/* New Media Products */ -product NEWMEDIA BASICS 0x0019 New Media BASICS Ethernet -product NEWMEDIA BUSTOASTER 0xc102 New Media BusToaster SCSI Host Adapter - -/* Standard Microsystems Corporation Products */ -product SMC 8016 0x0105 SMC 8016 EtherCard -product SMC EZCARD 0x8022 SMC EZCard 10 PCMCIA - -/* Contec C-NET(PC) */ -product CONTEC CNETPC 0x0000 Contec C-NET(PC)C - -/* Allied Telesis K.K. */ -product ALLIEDTELESIS LA_PCM 0x0002 Allied Telesis LA-PCM - -/* RATOC System Inc. Products */ -product RATOC REX_R280 0x1 RATOC REX-R280 - -/* Lucent WaveLAN/IEEE */ -product LUCENT WAVELAN_IEEE 0x0002 WaveLAN/IEEE - -/* Aironet */ -product AIRONET PC4500 0x0005 Aironet PC4500 Wireless LAN Adapter -product AIRONET PC4800 0x0007 Aironet PC4800 Wireless LAN Adapter - -/* Bay Networks */ -product BAY STACK_650 0x0804 BayStack 650 Wireless LAN -product BAY SURFER_PRO 0x0806 AirSurfer Pro Wireless LAN -product BAY STACK_660 0x0807 BayStack 660 Wireless LAN - -/* Raylink/WebGear */ -product RAYTHEON WLAN 0x0000 WLAN Adapter - -/* Cards we know only by their cis */ -vendor PREMAX -1 Premax -vendor PLANET -1 Planet -vendor PLANEX -1 Planex Communications Inc -vendor DLINK -1 D-Link -vendor RPTI -1 RPTI -vendor ACCTON -1 ACCTON -vendor YEDATA -1 Y-E DATA -vendor DIGITAL -1 Digital Equipment Corporation -vendor TEAC -1 TEAC -vendor SVEC -1 SVEC/Hawking Technology -vendor NAKAGAWAMETAL -1 NAKAGAWA METAL -vendor AMBICOM -1 AmbiCom Inc -vendor EPSON -1 Seiko Epson Corporation -vendor EXP -1 EXP Computer Inc -vendor ICOM -1 ICOM Inc -vendor BILLIONTON -1 Billionton Systems Inc. -vendor AMD -1 AMD - -product MEGAHERTZ XJ2288 { "MEGAHERTZ", "MODEM&spXJ2288", NULL, NULL } Megahertz XJ2288 Modem -product PREMAX PE200 { "PMX&sp&sp&sp", "PE-200", NULL, NULL } PreMax PE-200 -product PLANET SMARTCOM2000 { "PCMCIA", "UE2212", NULL, NULL } Planet SmartCOM 2000 -/* - * vendor ID of both FNW-3600-T and FNW-3700-T is LINKSYS (0x0149) and - * product ID is 0xc1ab, but it conflicts with LINKSYS Combo EthernetCard. - */ -product PLANEX FNW3600T -1 Planex FNW-3600-T -product PLANEX FNW3700T -1 Planex FNW-3700-T -product DLINK DE650 { "D-Link", "DE-650", NULL, NULL } D-Link DE-650 -product DLINK DE660 { "D-Link", "DE-660", NULL, NULL } D-Link DE-660 -product RPTI EP400 { "RPTI&spLTD.", "EP400", "CISV100", NULL } RPTI EP400 -product RPTI EP401 { "RPTI", "EP401&spEthernet&spNE2000&spCompatible", NULL, NULL } RPTI EP401 -product ACCTON EN2212 { "ACCTON", "EN2212", NULL, NULL } Accton EN2212 -product YEDATA EXTERNAL_FDD { "Y-E&spDATA", "External&spFDD", NULL, NULL } Y-E DATA External FDD -product DIGITAL DEPCMXX { "DIGITAL", "DEPCM-XX", NULL, NULL } DEC DEPCM-BA -product TEAC IDECARDII { NULL, "NinjaATA-", NULL, NULL } TEAC IDE Card/II -product LINKSYS ECARD_2 { "LINKSYS", "E-CARD", NULL, NULL } Linksys E-Card -product COREGA ETHER_PCC_T { "corega&spK.K.", "corega&spEther&spPCC-T", NULL, NULL } Corega Ether PCC-T -product COREGA ETHER_II_PCC_T { "corega&spK.K.", "corega&spEtherII&spPCC-T", NULL, NULL } Corega EtherII PCC-T -product COREGA FAST_ETHER_PCC_TX { "corega&spK.K.", "corega&spFastEther&spPCC-TX", NULL, NULL } Corega FastEther PCC-TX -product SVEC COMBOCARD { "Ethernet", "Adapter", NULL, NULL } SVEC/Hawking Tech. Combo Card -product SVEC LANCARD { "SVEC", "FD605&spPCMCIA&spEtherNet&spCard", "V1-1", NULL } SVEC PCMCIA Lan Card -/* - * vendor ID of PN650TX is LINKSYS (0x0149) and product ID is 0xc1ab, but - * it conflicts with LINKSYS Combo EthernetCard. - */ -product SVEC PN650TX -1 SVEC PN650TX 10/100 Dual Speed Fast Ethernet PC Card - -product NAKAGAWAMETAL LNT10TN { "PCMCIA", "LNT-10TN", NULL, NULL } NAKAGAWA METAL LNT-10TN NE2000 Compatible Card -product EPSON EEN10B { "Seiko&spEpson&spCorp.", "Ethernet", "P/N:&spEEN10B&spRev.&sp00", NULL } Epson EEN10B -product EXP EXPMULTIMEDIA { "EXP&sp&sp&sp", "PnPIDE", "F1", NULL } EXP IDE/ATAPI DVD Card -product AMD AM79C930 { "AMD", "Am79C930", NULL, NULL } AMD Am79C930 -product ICOM SL200 { "Icom", "SL-200", NULL, NULL } Icom SL-200 -product XIRCOM CFE_10 { "Xircom", "CompactCard&spEthernet", "CFE-10", "1.00" } Xircom CompactCard CFE-10 -product BILLIONTON LNT10TN { "PCMCIA", "LNT-10TN", NULL, NULL } Billionton Systems Inc. LNT-10TN NE2000 Compatible Card - -product AMBICOM AMB8002T { "AmbiCom&spInc", "AMB8002T", NULL, NULL } AmbiCom AMB8002T -product IODATA PCLAT { "I-O&spDATA", "PCLA", "ETHERNET", NULL } IO-DATA PCLA/T diff --git a/sys/dev/misc/pccard/pccarddevs.h b/sys/dev/misc/pccard/pccarddevs.h deleted file mode 100644 index d2f3b49dd6..0000000000 --- a/sys/dev/misc/pccard/pccarddevs.h +++ /dev/null @@ -1,497 +0,0 @@ -/* - * $NetBSD: pcmciadevs,v 1.85 2000/03/22 21:39:57 mycroft Exp $ - * $FreeBSD: src/sys/dev/pccard/pccarddevs.h,v 1.3.2.1 2000/05/23 03:57:00 imp Exp $ - * $DragonFly: src/sys/dev/misc/pccard/Attic/pccarddevs.h,v 1.3 2003/11/15 21:05:41 dillon Exp $ - */ - -/* - * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. - * - * generated from: - * FreeBSD: src/sys/dev/pccard/pccarddevs,v 1.3 1999/11/29 20:53:36 imp Exp - */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * 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 the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -/* - * List of known PCMCIA vendors - */ - -#define PCCARD_VENDOR_FUJITSU 0x0004 /* Fujitsu Corporation */ -#define PCCARD_VENDOR_PANASONIC 0x0032 /* Matsushita Electric Industrial Co. */ -#define PCCARD_VENDOR_SANDISK 0x0045 /* Sandisk Corporation */ -#define PCCARD_VENDOR_NEWMEDIA 0x0057 /* NewMedia Corporation */ -#define PCCARD_VENDOR_INTEL 0x0089 /* Intel Corporation */ -#define PCCARD_VENDOR_IBM 0x00a4 /* IBM Corporation */ -#define PCCARD_VENDOR_MOTOROLA 0x0109 /* Motorola Corporation */ -#define PCCARD_VENDOR_3COM 0x0101 /* 3Com Corporation */ -#define PCCARD_VENDOR_MEGAHERTZ 0x0102 /* Megahertz Corporation */ -#define PCCARD_VENDOR_SOCKET 0x0104 /* Socket Communications */ -#define PCCARD_VENDOR_TDK 0x0105 /* TDK Corporation */ -#define PCCARD_VENDOR_XIRCOM 0x0105 /* Xircom */ -#define PCCARD_VENDOR_SMC 0x0108 /* Standard Microsystems Corporation */ -#define PCCARD_VENDOR_USROBOTICS 0x0115 /* US Robotics Corporation */ -#define PCCARD_VENDOR_MEGAHERTZ2 0x0128 /* Megahertz Corporation */ -#define PCCARD_VENDOR_ADAPTEC 0x012f /* Adaptec Corporation */ -#define PCCARD_VENDOR_COMPAQ 0x0138 /* Compaq */ -#define PCCARD_VENDOR_LINKSYS 0x0149 /* Linksys Corporation */ -#define PCCARD_VENDOR_SIMPLETECH 0x014d /* Simple Technology */ -#define PCCARD_VENDOR_LUCENT 0x0156 /* Lucent Technologies */ -#define PCCARD_VENDOR_AIRONET 0x015f /* Aironet Wireless Communications */ -#define PCCARD_VENDOR_COMPAQ2 0x0183 /* Compaq */ -#define PCCARD_VENDOR_DAYNA 0x0194 /* Dayna Corporation */ -#define PCCARD_VENDOR_RAYTHEON 0x01a6 /* Raytheon */ -#define PCCARD_VENDOR_IODATA 0x01bf /* I-O DATA */ -#define PCCARD_VENDOR_BAY 0x01eb /* Bay Networks */ -#define PCCARD_VENDOR_NOKIA 0x023d /* Nokia Communications */ -#define PCCARD_VENDOR_LASAT 0x3401 /* Lasat Communications A/S */ -#define PCCARD_VENDOR_LEXARMEDIA 0x4e01 /* Lexar Media */ -#define PCCARD_VENDOR_COMPEX 0x8a01 /* Compex Corporation */ -#define PCCARD_VENDOR_MELCO 0x8a01 /* Melco Corporation */ -#define PCCARD_VENDOR_CONTEC 0xc001 /* Contec */ -#define PCCARD_VENDOR_COREGA 0xc00f /* Corega K.K. */ -#define PCCARD_VENDOR_ALLIEDTELESIS 0xc00f /* Allied Telesis K.K. */ -#define PCCARD_VENDOR_HAGIWARASYSCOM 0xc012 /* Hagiwara SYS-COM */ -#define PCCARD_VENDOR_RATOC 0xc015 /* RATOC System Inc. */ - -/* - * List of known products. Grouped by vendor. - */ - -/* Adaptec Products */ -#define PCCARD_CIS_ADAPTEC_APA1460_1 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_ADAPTEC_APA1460_1 0x0001 -#define PCCARD_STR_ADAPTEC_APA1460_1 "Adaptec APA-1460/A SCSI Host Adapter" -#define PCCARD_CIS_ADAPTEC_APA1460_2 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_ADAPTEC_APA1460_2 0x0002 -#define PCCARD_STR_ADAPTEC_APA1460_2 "Adaptec APA-1460/B SCSI Host Adapter" - -/* 3COM Products */ -#define PCCARD_CIS_3COM_3C1 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_3COM_3C1 0x0cf1 -#define PCCARD_STR_3COM_3C1 "3Com Megahertz 3C1 10Mbps LAN CF+ Card" -#define PCCARD_CIS_3COM_3C562 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_3COM_3C562 0x0562 -#define PCCARD_STR_3COM_3C562 "3Com 3c562 33.6 Modem/10Mbps Ethernet" -#define PCCARD_CIS_3COM_3C589 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_3COM_3C589 0x0589 -#define PCCARD_STR_3COM_3C589 "3Com 3c589 10Mbps Ethernet" -#define PCCARD_CIS_3COM_3C574 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_3COM_3C574 0x0574 -#define PCCARD_STR_3COM_3C574 "3Com 3c574-TX 10/100Mbps Ethernet" -#define PCCARD_CIS_3COM_3CXM056BNW { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_3COM_3CXM056BNW 0x002f -#define PCCARD_STR_3COM_3CXM056BNW "3Com/NoteWorthy 3CXM056-BNW 56K Modem" -#define PCCARD_CIS_3COM_3CXEM556 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_3COM_3CXEM556 0x0035 -#define PCCARD_STR_3COM_3CXEM556 "3Com/Megahertz 3CXEM556 Ethernet/Modem" -#define PCCARD_CIS_3COM_3CXEM556INT { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_3COM_3CXEM556INT 0x003d -#define PCCARD_STR_3COM_3CXEM556INT "3Com/Megahertz 3CXEM556-INT Ethernet/Modem" -#define PCCARD_CIS_3COM_3CCFEM556BI { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_3COM_3CCFEM556BI 0x0556 -#define PCCARD_STR_3COM_3CCFEM556BI "3Com/Megahertz 3CCFEM556BI Ethernet/Modem" - -/* Compex Products */ -#define PCCARD_CIS_COMPEX_LINKPORT_ENET_B { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_COMPEX_LINKPORT_ENET_B 0x0100 -#define PCCARD_STR_COMPEX_LINKPORT_ENET_B "Compex Linkport ENET-B Ethernet" - -/* Lasat Products */ -#define PCCARD_CIS_LASAT_CREDIT_288 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_LASAT_CREDIT_288 0x2811 -#define PCCARD_STR_LASAT_CREDIT_288 "Lasat Credit 288 Modem" - -/* Dayna Products */ -#define PCCARD_CIS_DAYNA_COMMUNICARD_E_1 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_DAYNA_COMMUNICARD_E_1 0x002d -#define PCCARD_STR_DAYNA_COMMUNICARD_E_1 "Dayna CommuniCard E" -#define PCCARD_CIS_DAYNA_COMMUNICARD_E_2 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_DAYNA_COMMUNICARD_E_2 0x002f -#define PCCARD_STR_DAYNA_COMMUNICARD_E_2 "Dayna CommuniCard E" - -/* DIGITAL Products */ -#define PCCARD_CIS_DIGITAL_MOBILE_MEDIA_CDROM { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_DIGITAL_MOBILE_MEDIA_CDROM 0x0d00 -#define PCCARD_STR_DIGITAL_MOBILE_MEDIA_CDROM "Digital Mobile Media CD-ROM" - -/* Fujutsu Products */ -#define PCCARD_CIS_FUJITSU_SCSI600 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_FUJITSU_SCSI600 0x0401 -#define PCCARD_STR_FUJITSU_SCSI600 "Fujitsu SCSI 600 Interface" - -/* Motorola Products */ -#define PCCARD_CIS_MOTOROLA_POWER144 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_MOTOROLA_POWER144 0x0105 -#define PCCARD_STR_MOTOROLA_POWER144 "Motorola Power 14.4 Modem" -#define PCCARD_CIS_MOTOROLA_PM100C { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_MOTOROLA_PM100C 0x0302 -#define PCCARD_STR_MOTOROLA_PM100C "Motorola Personal Messenger 100C CDPD Modem" - -/* Fujitsu Products */ -#define PCCARD_CIS_FUJITSU_LA501 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_FUJITSU_LA501 0x2000 -#define PCCARD_STR_FUJITSU_LA501 "Fujitsu Towa LA501 Ethernet" -#define PCCARD_CIS_FUJITSU_LA10S { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_FUJITSU_LA10S 0x1003 -#define PCCARD_STR_FUJITSU_LA10S "Fujitsu Compact Flash Ethernet" - -/* IBM Products */ -#define PCCARD_CIS_IBM_3270 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_IBM_3270 0x0001 -#define PCCARD_STR_IBM_3270 "3270 Emulation" -#define PCCARD_CIS_IBM_INFOMOVER { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_IBM_INFOMOVER 0x0002 -#define PCCARD_STR_IBM_INFOMOVER "National Semiconductor InfoMover" -#define PCCARD_CIS_IBM_5250 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_IBM_5250 0x000b -#define PCCARD_STR_IBM_5250 "5250 Emulation" -#define PCCARD_CIS_IBM_TROPIC { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_IBM_TROPIC 0x001e -#define PCCARD_STR_IBM_TROPIC "Token Ring 4/16" -#define PCCARD_CIS_IBM_HOME_AND_AWAY { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_IBM_HOME_AND_AWAY 0x002e -#define PCCARD_STR_IBM_HOME_AND_AWAY "IBM Home and Away Modem" -#define PCCARD_CIS_IBM_WIRELESS_LAN_ENTRY { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_IBM_WIRELESS_LAN_ENTRY 0x0032 -#define PCCARD_STR_IBM_WIRELESS_LAN_ENTRY "Wireless LAN Entry" -#define PCCARD_CIS_IBM_PORTABLE_CDROM { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_IBM_PORTABLE_CDROM 0x002d -#define PCCARD_STR_IBM_PORTABLE_CDROM "PCMCIA Portable CD-ROM Drive" -#define PCCARD_CIS_IBM_ETHERJET { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_IBM_ETHERJET 0x003f -#define PCCARD_STR_IBM_ETHERJET "IBM EtherJet Ethernet" - -/* I-O DATA */ -#define PCCARD_CIS_IODATA_PCLATE { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_IODATA_PCLATE 0x2216 -#define PCCARD_STR_IODATA_PCLATE "I-O DATA PCLA/TE" - -/* Lexar Media */ -#define PCCARD_CIS_LEXARMEDIA_COMPATFLASH { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_LEXARMEDIA_COMPATFLASH 0x0100 -#define PCCARD_STR_LEXARMEDIA_COMPATFLASH "Lexar Media CompactFlash" - -/* Linksys corporation */ -#define PCCARD_CIS_LINKSYS_ETHERFAST { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_LINKSYS_ETHERFAST 0x0230 -#define PCCARD_STR_LINKSYS_ETHERFAST "Linksys Etherfast 10/100 Ethernet" -#define PCCARD_CIS_LINKSYS_ECARD_1 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_LINKSYS_ECARD_1 0x0265 -#define PCCARD_STR_LINKSYS_ECARD_1 "Linksys EthernetCard or D-Link DE-650" -#define PCCARD_CIS_LINKSYS_COMBO_ECARD { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_LINKSYS_COMBO_ECARD 0xc1ab -#define PCCARD_STR_LINKSYS_COMBO_ECARD "Linksys Combo EthernetCard" -#define PCCARD_CIS_LINKSYS_TRUST_COMBO_ECARD { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_LINKSYS_TRUST_COMBO_ECARD 0x021b -#define PCCARD_STR_LINKSYS_TRUST_COMBO_ECARD "Trust (Linksys) Combo EthernetCard" - -/* Megahertz Products */ -#define PCCARD_CIS_MEGAHERTZ_XJ4288 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_MEGAHERTZ_XJ4288 0x0023 -#define PCCARD_STR_MEGAHERTZ_XJ4288 "Megahertz XJ4288 Modem" -#define PCCARD_CIS_MEGAHERTZ_XJ4336 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_MEGAHERTZ_XJ4336 0x0027 -#define PCCARD_STR_MEGAHERTZ_XJ4336 "Megahertz XJ4336 Modem" -#define PCCARD_CIS_MEGAHERTZ_XJ5560 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_MEGAHERTZ_XJ5560 0x0034 -#define PCCARD_STR_MEGAHERTZ_XJ5560 "Megahertz X-JACK 56kbps Modem" -#define PCCARD_CIS_MEGAHERTZ2_XJACK { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_MEGAHERTZ2_XJACK 0x0103 -#define PCCARD_STR_MEGAHERTZ2_XJACK "Megahertz X-JACK Ethernet" -#define PCCARD_CIS_MEGAHERTZ_XJEM3336 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_MEGAHERTZ_XJEM3336 0x0006 -#define PCCARD_STR_MEGAHERTZ_XJEM3336 "Megahertz X-JACK Ethernet Modem" - -/* Melco Products */ -#define PCCARD_CIS_MELCO_LPC3_TX { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_MELCO_LPC3_TX 0xc1ab -#define PCCARD_STR_MELCO_LPC3_TX "Melco LPC3-TX" - -/* Nokia Products */ -#define PCCARD_CIS_NOKIA_C020_WLAN { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_NOKIA_C020_WLAN 0x20c0 -#define PCCARD_STR_NOKIA_C020_WLAN "Nokia C020 WLAN Card" - -/* Panasonic Products */ -#define PCCARD_CIS_PANASONIC_KXLC002 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_PANASONIC_KXLC002 0x0304 -#define PCCARD_STR_PANASONIC_KXLC002 "Panasonic 4X CD-ROM Interface Card" - -/* US Robotics Products */ -#define PCCARD_CIS_USROBOTICS_WORLDPORT144 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_USROBOTICS_WORLDPORT144 0x3330 -#define PCCARD_STR_USROBOTICS_WORLDPORT144 "US Robotics WorldPort 14.4 Modem" - -/* Sandisk Products */ -#define PCCARD_CIS_SANDISK_SDCFB { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_SANDISK_SDCFB 0x0401 -#define PCCARD_STR_SANDISK_SDCFB "Sandisk CompactFlash Card" - -/* Simple Technology Products */ -#define PCCARD_CIS_SIMPLETECH_COMMUNICATOR288 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_SIMPLETECH_COMMUNICATOR288 0x0100 -#define PCCARD_STR_SIMPLETECH_COMMUNICATOR288 "Simple Technology 28.8 Communicator" -/* Simpletech ID also used by Symbol */ -#define PCCARD_CIS_SIMPLETECH_SPECTRUM24 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_SIMPLETECH_SPECTRUM24 0x801 -#define PCCARD_STR_SIMPLETECH_SPECTRUM24 "Symbol Spectrum24 WLAN Adapter" - -/* Socket Communications Products */ -#define PCCARD_CIS_SOCKET_PAGECARD { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_SOCKET_PAGECARD 0x0003 -#define PCCARD_STR_SOCKET_PAGECARD "Socket Communications PageCard" -#define PCCARD_CIS_SOCKET_DUAL_RS232 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_SOCKET_DUAL_RS232 0x0006 -#define PCCARD_STR_SOCKET_DUAL_RS232 "Socket Communications Dual RS232" -#define PCCARD_CIS_SOCEKT_LP_ETHER_CF { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_SOCEKT_LP_ETHER_CF 0x0075 -#define PCCARD_STR_SOCEKT_LP_ETHER_CF "Socket Communications Low Power Ethernet CF" - -/* TDK Products */ -#define PCCARD_CIS_TDK_LAK_CD021BX { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_TDK_LAK_CD021BX 0x0200 -#define PCCARD_STR_TDK_LAK_CD021BX "TDK LAK-CD021BX Ethernet" -#define PCCARD_CIS_TDK_DFL9610 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_TDK_DFL9610 0x0d0a -#define PCCARD_STR_TDK_DFL9610 "TDK DFL9610 Ethernet & Digital Cellular" -#define PCCARD_CIS_TDK_LAK_CF010 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_TDK_LAK_CF010 0x0900 -#define PCCARD_STR_TDK_LAK_CF010 "TDK LAC-CF010" - -/* TDK Vendor ID also used by Xircom! */ -#define PCCARD_CIS_TDK_XIR_CE_10 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_TDK_XIR_CE_10 0x0108 -#define PCCARD_STR_TDK_XIR_CE_10 "Xircom CreditCard Ethernet" -#define PCCARD_CIS_TDK_XIR_CEM_10 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_TDK_XIR_CEM_10 0x110a -#define PCCARD_STR_TDK_XIR_CEM_10 "Xircom CreditCard Ethernet + Modem" -#define PCCARD_CIS_TDK_XIR_CEM_28 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_TDK_XIR_CEM_28 0x110b -#define PCCARD_STR_TDK_XIR_CEM_28 "Xircom CreditCard Ethernet + Modem 28.8" -#define PCCARD_CIS_TDK_XIR_PS_CE2_10 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_TDK_XIR_PS_CE2_10 0x010b -#define PCCARD_STR_TDK_XIR_PS_CE2_10 "Xircom CreditCard CE2 Ethernet" -#define PCCARD_CIS_TDK_XIR_CE3_10_100 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_TDK_XIR_CE3_10_100 0x010a -#define PCCARD_STR_TDK_XIR_CE3_10_100 "Xircom CreditCard CE3 10/100 Ethernet" -/* conflicts with above - * product TDK XIR_CFE_10 0x010a Xircom CompactCard CFE-10 - */ -#define PCCARD_CIS_TDK_XIR_CNW_801 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_TDK_XIR_CNW_801 0x0801 -#define PCCARD_STR_TDK_XIR_CNW_801 "Xircom CreditCard Netwave (Canada)" -#define PCCARD_CIS_TDK_XIR_CNW_802 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_TDK_XIR_CNW_802 0x0802 -#define PCCARD_STR_TDK_XIR_CNW_802 "Xircom CreditCard Netwave (US)" - -/* New Media Products */ -#define PCCARD_CIS_NEWMEDIA_BASICS { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_NEWMEDIA_BASICS 0x0019 -#define PCCARD_STR_NEWMEDIA_BASICS "New Media BASICS Ethernet" -#define PCCARD_CIS_NEWMEDIA_BUSTOASTER { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_NEWMEDIA_BUSTOASTER 0xc102 -#define PCCARD_STR_NEWMEDIA_BUSTOASTER "New Media BusToaster SCSI Host Adapter" - -/* Standard Microsystems Corporation Products */ -#define PCCARD_CIS_SMC_8016 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_SMC_8016 0x0105 -#define PCCARD_STR_SMC_8016 "SMC 8016 EtherCard" -#define PCCARD_CIS_SMC_EZCARD { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_SMC_EZCARD 0x8022 -#define PCCARD_STR_SMC_EZCARD "SMC EZCard 10 PCMCIA" - -/* Contec C-NET(PC) */ -#define PCCARD_CIS_CONTEC_CNETPC { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_CONTEC_CNETPC 0x0000 -#define PCCARD_STR_CONTEC_CNETPC "Contec C-NET(PC)C" - -/* Allied Telesis K.K. */ -#define PCCARD_CIS_ALLIEDTELESIS_LA_PCM { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_ALLIEDTELESIS_LA_PCM 0x0002 -#define PCCARD_STR_ALLIEDTELESIS_LA_PCM "Allied Telesis LA-PCM" - -/* RATOC System Inc. Products */ -#define PCCARD_CIS_RATOC_REX_R280 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_RATOC_REX_R280 0x1 -#define PCCARD_STR_RATOC_REX_R280 "RATOC REX-R280" - -/* Lucent WaveLAN/IEEE */ -#define PCCARD_CIS_LUCENT_WAVELAN_IEEE { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_LUCENT_WAVELAN_IEEE 0x0002 -#define PCCARD_STR_LUCENT_WAVELAN_IEEE "WaveLAN/IEEE" - -/* Aironet */ -#define PCCARD_CIS_AIRONET_PC4500 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_AIRONET_PC4500 0x0005 -#define PCCARD_STR_AIRONET_PC4500 "Aironet PC4500 Wireless LAN Adapter" -#define PCCARD_CIS_AIRONET_PC4800 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_AIRONET_PC4800 0x0007 -#define PCCARD_STR_AIRONET_PC4800 "Aironet PC4800 Wireless LAN Adapter" - -/* Bay Networks */ -#define PCCARD_CIS_BAY_STACK_650 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_BAY_STACK_650 0x0804 -#define PCCARD_STR_BAY_STACK_650 "BayStack 650 Wireless LAN" -#define PCCARD_CIS_BAY_SURFER_PRO { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_BAY_SURFER_PRO 0x0806 -#define PCCARD_STR_BAY_SURFER_PRO "AirSurfer Pro Wireless LAN" -#define PCCARD_CIS_BAY_STACK_660 { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_BAY_STACK_660 0x0807 -#define PCCARD_STR_BAY_STACK_660 "BayStack 660 Wireless LAN" - -/* Raylink/WebGear */ -#define PCCARD_CIS_RAYTHEON_WLAN { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_RAYTHEON_WLAN 0x0000 -#define PCCARD_STR_RAYTHEON_WLAN "WLAN Adapter" - -/* Cards we know only by their cis */ -#define PCCARD_VENDOR_PREMAX -1 /* Premax */ -#define PCCARD_VENDOR_PLANET -1 /* Planet */ -#define PCCARD_VENDOR_PLANEX -1 /* Planex Communications Inc */ -#define PCCARD_VENDOR_DLINK -1 /* D-Link */ -#define PCCARD_VENDOR_RPTI -1 /* RPTI */ -#define PCCARD_VENDOR_ACCTON -1 /* ACCTON */ -#define PCCARD_VENDOR_YEDATA -1 /* Y-E DATA */ -#define PCCARD_VENDOR_DIGITAL -1 /* Digital Equipment Corporation */ -#define PCCARD_VENDOR_TEAC -1 /* TEAC */ -#define PCCARD_VENDOR_SVEC -1 /* SVEC/Hawking Technology */ -#define PCCARD_VENDOR_NAKAGAWAMETAL -1 /* NAKAGAWA METAL */ -#define PCCARD_VENDOR_AMBICOM -1 /* AmbiCom Inc */ -#define PCCARD_VENDOR_EPSON -1 /* Seiko Epson Corporation */ -#define PCCARD_VENDOR_EXP -1 /* EXP Computer Inc */ -#define PCCARD_VENDOR_ICOM -1 /* ICOM Inc */ -#define PCCARD_VENDOR_BILLIONTON -1 /* Billionton Systems Inc. */ -#define PCCARD_VENDOR_AMD -1 /* AMD */ - -#define PCCARD_CIS_MEGAHERTZ_XJ2288 { "MEGAHERTZ", "MODEM XJ2288", NULL, NULL } -#define PCCARD_PRODUCT_MEGAHERTZ_XJ2288 -1 -#define PCCARD_STR_MEGAHERTZ_XJ2288 "Megahertz XJ2288 Modem" -#define PCCARD_CIS_PREMAX_PE200 { "PMX ", "PE-200", NULL, NULL } -#define PCCARD_PRODUCT_PREMAX_PE200 -1 -#define PCCARD_STR_PREMAX_PE200 "PreMax PE-200" -#define PCCARD_CIS_PLANET_SMARTCOM2000 { "PCMCIA", "UE2212", NULL, NULL } -#define PCCARD_PRODUCT_PLANET_SMARTCOM2000 -1 -#define PCCARD_STR_PLANET_SMARTCOM2000 "Planet SmartCOM 2000" -/* - * vendor ID of both FNW-3600-T and FNW-3700-T is LINKSYS (0x0149) and - * product ID is 0xc1ab, but it conflicts with LINKSYS Combo EthernetCard. - */ -#define PCCARD_CIS_PLANEX_FNW3600T { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_PLANEX_FNW3600T -1 -#define PCCARD_STR_PLANEX_FNW3600T "Planex FNW-3600-T" -#define PCCARD_CIS_PLANEX_FNW3700T { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_PLANEX_FNW3700T -1 -#define PCCARD_STR_PLANEX_FNW3700T "Planex FNW-3700-T" -#define PCCARD_CIS_DLINK_DE650 { "D-Link", "DE-650", NULL, NULL } -#define PCCARD_PRODUCT_DLINK_DE650 -1 -#define PCCARD_STR_DLINK_DE650 "D-Link DE-650" -#define PCCARD_CIS_DLINK_DE660 { "D-Link", "DE-660", NULL, NULL } -#define PCCARD_PRODUCT_DLINK_DE660 -1 -#define PCCARD_STR_DLINK_DE660 "D-Link DE-660" -#define PCCARD_CIS_RPTI_EP400 { "RPTI LTD.", "EP400", "CISV100", NULL } -#define PCCARD_PRODUCT_RPTI_EP400 -1 -#define PCCARD_STR_RPTI_EP400 "RPTI EP400" -#define PCCARD_CIS_RPTI_EP401 { "RPTI", "EP401 Ethernet NE2000 Compatible", NULL, NULL } -#define PCCARD_PRODUCT_RPTI_EP401 -1 -#define PCCARD_STR_RPTI_EP401 "RPTI EP401" -#define PCCARD_CIS_ACCTON_EN2212 { "ACCTON", "EN2212", NULL, NULL } -#define PCCARD_PRODUCT_ACCTON_EN2212 -1 -#define PCCARD_STR_ACCTON_EN2212 "Accton EN2212" -#define PCCARD_CIS_YEDATA_EXTERNAL_FDD { "Y-E DATA", "External FDD", NULL, NULL } -#define PCCARD_PRODUCT_YEDATA_EXTERNAL_FDD -1 -#define PCCARD_STR_YEDATA_EXTERNAL_FDD "Y-E DATA External FDD" -#define PCCARD_CIS_DIGITAL_DEPCMXX { "DIGITAL", "DEPCM-XX", NULL, NULL } -#define PCCARD_PRODUCT_DIGITAL_DEPCMXX -1 -#define PCCARD_STR_DIGITAL_DEPCMXX "DEC DEPCM-BA" -#define PCCARD_CIS_TEAC_IDECARDII { NULL, "NinjaATA-", NULL, NULL } -#define PCCARD_PRODUCT_TEAC_IDECARDII -1 -#define PCCARD_STR_TEAC_IDECARDII "TEAC IDE Card/II" -#define PCCARD_CIS_LINKSYS_ECARD_2 { "LINKSYS", "E-CARD", NULL, NULL } -#define PCCARD_PRODUCT_LINKSYS_ECARD_2 -1 -#define PCCARD_STR_LINKSYS_ECARD_2 "Linksys E-Card" -#define PCCARD_CIS_COREGA_ETHER_PCC_T { "corega K.K.", "corega Ether PCC-T", NULL, NULL } -#define PCCARD_PRODUCT_COREGA_ETHER_PCC_T -1 -#define PCCARD_STR_COREGA_ETHER_PCC_T "Corega Ether PCC-T" -#define PCCARD_CIS_COREGA_ETHER_II_PCC_T { "corega K.K.", "corega EtherII PCC-T", NULL, NULL } -#define PCCARD_PRODUCT_COREGA_ETHER_II_PCC_T -1 -#define PCCARD_STR_COREGA_ETHER_II_PCC_T "Corega EtherII PCC-T" -#define PCCARD_CIS_COREGA_FAST_ETHER_PCC_TX { "corega K.K.", "corega FastEther PCC-TX", NULL, NULL } -#define PCCARD_PRODUCT_COREGA_FAST_ETHER_PCC_TX -1 -#define PCCARD_STR_COREGA_FAST_ETHER_PCC_TX "Corega FastEther PCC-TX" -#define PCCARD_CIS_SVEC_COMBOCARD { "Ethernet", "Adapter", NULL, NULL } -#define PCCARD_PRODUCT_SVEC_COMBOCARD -1 -#define PCCARD_STR_SVEC_COMBOCARD "SVEC/Hawking Tech. Combo Card" -#define PCCARD_CIS_SVEC_LANCARD { "SVEC", "FD605 PCMCIA EtherNet Card", "V1-1", NULL } -#define PCCARD_PRODUCT_SVEC_LANCARD -1 -#define PCCARD_STR_SVEC_LANCARD "SVEC PCMCIA Lan Card" -/* - * vendor ID of PN650TX is LINKSYS (0x0149) and product ID is 0xc1ab, but - * it conflicts with LINKSYS Combo EthernetCard. - */ -#define PCCARD_CIS_SVEC_PN650TX { NULL, NULL, NULL, NULL } -#define PCCARD_PRODUCT_SVEC_PN650TX -1 -#define PCCARD_STR_SVEC_PN650TX "SVEC PN650TX 10/100 Dual Speed Fast Ethernet PC Card" - -#define PCCARD_CIS_NAKAGAWAMETAL_LNT10TN { "PCMCIA", "LNT-10TN", NULL, NULL } -#define PCCARD_PRODUCT_NAKAGAWAMETAL_LNT10TN -1 -#define PCCARD_STR_NAKAGAWAMETAL_LNT10TN "NAKAGAWA METAL LNT-10TN NE2000 Compatible Card" -#define PCCARD_CIS_EPSON_EEN10B { "Seiko Epson Corp.", "Ethernet", "P/N: EEN10B Rev. 00", NULL } -#define PCCARD_PRODUCT_EPSON_EEN10B -1 -#define PCCARD_STR_EPSON_EEN10B "Epson EEN10B" -#define PCCARD_CIS_EXP_EXPMULTIMEDIA { "EXP ", "PnPIDE", "F1", NULL } -#define PCCARD_PRODUCT_EXP_EXPMULTIMEDIA -1 -#define PCCARD_STR_EXP_EXPMULTIMEDIA "EXP IDE/ATAPI DVD Card" -#define PCCARD_CIS_AMD_AM79C930 { "AMD", "Am79C930", NULL, NULL } -#define PCCARD_PRODUCT_AMD_AM79C930 -1 -#define PCCARD_STR_AMD_AM79C930 "AMD Am79C930" -#define PCCARD_CIS_ICOM_SL200 { "Icom", "SL-200", NULL, NULL } -#define PCCARD_PRODUCT_ICOM_SL200 -1 -#define PCCARD_STR_ICOM_SL200 "Icom SL-200" -#define PCCARD_CIS_XIRCOM_CFE_10 { "Xircom", "CompactCard Ethernet", "CFE-10", "1.00" } -#define PCCARD_PRODUCT_XIRCOM_CFE_10 -1 -#define PCCARD_STR_XIRCOM_CFE_10 "Xircom CompactCard CFE-10" -#define PCCARD_CIS_BILLIONTON_LNT10TN { "PCMCIA", "LNT-10TN", NULL, NULL } -#define PCCARD_PRODUCT_BILLIONTON_LNT10TN -1 -#define PCCARD_STR_BILLIONTON_LNT10TN "Billionton Systems Inc. LNT-10TN NE2000 Compatible Card" - -#define PCCARD_CIS_AMBICOM_AMB8002T { "AmbiCom Inc", "AMB8002T", NULL, NULL } -#define PCCARD_PRODUCT_AMBICOM_AMB8002T -1 -#define PCCARD_STR_AMBICOM_AMB8002T "AmbiCom AMB8002T" -#define PCCARD_CIS_IODATA_PCLAT { "I-O DATA", "PCLA", "ETHERNET", NULL } -#define PCCARD_PRODUCT_IODATA_PCLAT -1 -#define PCCARD_STR_IODATA_PCLAT "IO-DATA PCLA/T" diff --git a/sys/dev/misc/pccard/pccarddevs_data.h b/sys/dev/misc/pccard/pccarddevs_data.h deleted file mode 100644 index 9d8dff8985..0000000000 --- a/sys/dev/misc/pccard/pccarddevs_data.h +++ /dev/null @@ -1,1135 +0,0 @@ -/* $FreeBSD: src/sys/dev/pccard/pccarddevs_data.h,v 1.3.2.1 2000/05/23 03:57:00 imp Exp $ */ -/* $DragonFly: src/sys/dev/misc/pccard/Attic/pccarddevs_data.h,v 1.2 2003/06/17 04:28:29 dillon Exp $ */ - -/* - * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. - * - * generated from: - * FreeBSD: src/sys/dev/pccard/pccarddevs,v 1.3 1999/11/29 20:53:36 imp Exp - */ -/* $NetBSD: pcmciadevs,v 1.85 2000/03/22 21:39:57 mycroft Exp $ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * 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 the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -struct pccard_knowndev pccard_knowndevs[] = { - { - PCCARD_VENDOR_ADAPTEC, PCCARD_PRODUCT_ADAPTEC_APA1460_1, - PCCARD_CIS_ADAPTEC_APA1460_1, - 0, - "Adaptec Corporation", - "Adaptec APA-1460/A SCSI Host Adapter" }, - }, - { - PCCARD_VENDOR_ADAPTEC, PCCARD_PRODUCT_ADAPTEC_APA1460_2, - PCCARD_CIS_ADAPTEC_APA1460_2, - 0, - "Adaptec Corporation", - "Adaptec APA-1460/B SCSI Host Adapter" }, - }, - { - PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3C1, - PCCARD_CIS_3COM_3C1, - 0, - "3Com Corporation", - "3Com Megahertz 3C1 10Mbps LAN CF+ Card" }, - }, - { - PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3C562, - PCCARD_CIS_3COM_3C562, - 0, - "3Com Corporation", - "3Com 3c562 33.6 Modem/10Mbps Ethernet" }, - }, - { - PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3C589, - PCCARD_CIS_3COM_3C589, - 0, - "3Com Corporation", - "3Com 3c589 10Mbps Ethernet" }, - }, - { - PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3C574, - PCCARD_CIS_3COM_3C574, - 0, - "3Com Corporation", - "3Com 3c574-TX 10/100Mbps Ethernet" }, - }, - { - PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3CXM056BNW, - PCCARD_CIS_3COM_3CXM056BNW, - 0, - "3Com Corporation", - "3Com/NoteWorthy 3CXM056-BNW 56K Modem" }, - }, - { - PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3CXEM556, - PCCARD_CIS_3COM_3CXEM556, - 0, - "3Com Corporation", - "3Com/Megahertz 3CXEM556 Ethernet/Modem" }, - }, - { - PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3CXEM556INT, - PCCARD_CIS_3COM_3CXEM556INT, - 0, - "3Com Corporation", - "3Com/Megahertz 3CXEM556-INT Ethernet/Modem" }, - }, - { - PCCARD_VENDOR_3COM, PCCARD_PRODUCT_3COM_3CCFEM556BI, - PCCARD_CIS_3COM_3CCFEM556BI, - 0, - "3Com Corporation", - "3Com/Megahertz 3CCFEM556BI Ethernet/Modem" }, - }, - { - PCCARD_VENDOR_COMPEX, PCCARD_PRODUCT_COMPEX_LINKPORT_ENET_B, - PCCARD_CIS_COMPEX_LINKPORT_ENET_B, - 0, - "Compex Corporation", - "Compex Linkport ENET-B Ethernet" }, - }, - { - PCCARD_VENDOR_LASAT, PCCARD_PRODUCT_LASAT_CREDIT_288, - PCCARD_CIS_LASAT_CREDIT_288, - 0, - "Lasat Communications A/S", - "Lasat Credit 288 Modem" }, - }, - { - PCCARD_VENDOR_DAYNA, PCCARD_PRODUCT_DAYNA_COMMUNICARD_E_1, - PCCARD_CIS_DAYNA_COMMUNICARD_E_1, - 0, - "Dayna Corporation", - "Dayna CommuniCard E" }, - }, - { - PCCARD_VENDOR_DAYNA, PCCARD_PRODUCT_DAYNA_COMMUNICARD_E_2, - PCCARD_CIS_DAYNA_COMMUNICARD_E_2, - 0, - "Dayna Corporation", - "Dayna CommuniCard E" }, - }, - { - PCCARD_VENDOR_DIGITAL, PCCARD_PRODUCT_DIGITAL_MOBILE_MEDIA_CDROM, - PCCARD_CIS_DIGITAL_MOBILE_MEDIA_CDROM, - 0, - "Digital Equipment Corporation", - "Digital Mobile Media CD-ROM" }, - }, - { - PCCARD_VENDOR_FUJITSU, PCCARD_PRODUCT_FUJITSU_SCSI600, - PCCARD_CIS_FUJITSU_SCSI600, - 0, - "Fujitsu Corporation", - "Fujitsu SCSI 600 Interface" }, - }, - { - PCCARD_VENDOR_MOTOROLA, PCCARD_PRODUCT_MOTOROLA_POWER144, - PCCARD_CIS_MOTOROLA_POWER144, - 0, - "Motorola Corporation", - "Motorola Power 14.4 Modem" }, - }, - { - PCCARD_VENDOR_MOTOROLA, PCCARD_PRODUCT_MOTOROLA_PM100C, - PCCARD_CIS_MOTOROLA_PM100C, - 0, - "Motorola Corporation", - "Motorola Personal Messenger 100C CDPD Modem" }, - }, - { - PCCARD_VENDOR_FUJITSU, PCCARD_PRODUCT_FUJITSU_LA501, - PCCARD_CIS_FUJITSU_LA501, - 0, - "Fujitsu Corporation", - "Fujitsu Towa LA501 Ethernet" }, - }, - { - PCCARD_VENDOR_FUJITSU, PCCARD_PRODUCT_FUJITSU_LA10S, - PCCARD_CIS_FUJITSU_LA10S, - 0, - "Fujitsu Corporation", - "Fujitsu Compact Flash Ethernet" }, - }, - { - PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_3270, - PCCARD_CIS_IBM_3270, - 0, - "IBM Corporation", - "3270 Emulation" }, - }, - { - PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_INFOMOVER, - PCCARD_CIS_IBM_INFOMOVER, - 0, - "IBM Corporation", - "National Semiconductor InfoMover" }, - }, - { - PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_5250, - PCCARD_CIS_IBM_5250, - 0, - "IBM Corporation", - "5250 Emulation" }, - }, - { - PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_TROPIC, - PCCARD_CIS_IBM_TROPIC, - 0, - "IBM Corporation", - "Token Ring 4/16" }, - }, - { - PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_HOME_AND_AWAY, - PCCARD_CIS_IBM_HOME_AND_AWAY, - 0, - "IBM Corporation", - "IBM Home and Away Modem" }, - }, - { - PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_WIRELESS_LAN_ENTRY, - PCCARD_CIS_IBM_WIRELESS_LAN_ENTRY, - 0, - "IBM Corporation", - "Wireless LAN Entry" }, - }, - { - PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_PORTABLE_CDROM, - PCCARD_CIS_IBM_PORTABLE_CDROM, - 0, - "IBM Corporation", - "PCMCIA Portable CD-ROM Drive" }, - }, - { - PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_ETHERJET, - PCCARD_CIS_IBM_ETHERJET, - 0, - "IBM Corporation", - "IBM EtherJet Ethernet" }, - }, - { - PCCARD_VENDOR_IODATA, PCCARD_PRODUCT_IODATA_PCLATE, - PCCARD_CIS_IODATA_PCLATE, - 0, - "I-O DATA", - "I-O DATA PCLA/TE" }, - }, - { - PCCARD_VENDOR_LEXARMEDIA, PCCARD_PRODUCT_LEXARMEDIA_COMPATFLASH, - PCCARD_CIS_LEXARMEDIA_COMPATFLASH, - 0, - "Lexar Media", - "Lexar Media CompactFlash" }, - }, - { - PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_ETHERFAST, - PCCARD_CIS_LINKSYS_ETHERFAST, - 0, - "Linksys Corporation", - "Linksys Etherfast 10/100 Ethernet" }, - }, - { - PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_ECARD_1, - PCCARD_CIS_LINKSYS_ECARD_1, - 0, - "Linksys Corporation", - "Linksys EthernetCard or D-Link DE-650" }, - }, - { - PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_COMBO_ECARD, - PCCARD_CIS_LINKSYS_COMBO_ECARD, - 0, - "Linksys Corporation", - "Linksys Combo EthernetCard" }, - }, - { - PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_TRUST_COMBO_ECARD, - PCCARD_CIS_LINKSYS_TRUST_COMBO_ECARD, - 0, - "Linksys Corporation", - "Trust (Linksys) Combo EthernetCard" }, - }, - { - PCCARD_VENDOR_MEGAHERTZ, PCCARD_PRODUCT_MEGAHERTZ_XJ4288, - PCCARD_CIS_MEGAHERTZ_XJ4288, - 0, - "Megahertz Corporation", - "Megahertz XJ4288 Modem" }, - }, - { - PCCARD_VENDOR_MEGAHERTZ, PCCARD_PRODUCT_MEGAHERTZ_XJ4336, - PCCARD_CIS_MEGAHERTZ_XJ4336, - 0, - "Megahertz Corporation", - "Megahertz XJ4336 Modem" }, - }, - { - PCCARD_VENDOR_MEGAHERTZ, PCCARD_PRODUCT_MEGAHERTZ_XJ5560, - PCCARD_CIS_MEGAHERTZ_XJ5560, - 0, - "Megahertz Corporation", - "Megahertz X-JACK 56kbps Modem" }, - }, - { - PCCARD_VENDOR_MEGAHERTZ2, PCCARD_PRODUCT_MEGAHERTZ2_XJACK, - PCCARD_CIS_MEGAHERTZ2_XJACK, - 0, - "Megahertz Corporation", - "Megahertz X-JACK Ethernet" }, - }, - { - PCCARD_VENDOR_MEGAHERTZ, PCCARD_PRODUCT_MEGAHERTZ_XJEM3336, - PCCARD_CIS_MEGAHERTZ_XJEM3336, - 0, - "Megahertz Corporation", - "Megahertz X-JACK Ethernet Modem" }, - }, - { - PCCARD_VENDOR_MELCO, PCCARD_PRODUCT_MELCO_LPC3_TX, - PCCARD_CIS_MELCO_LPC3_TX, - 0, - "Melco Corporation", - "Melco LPC3-TX" }, - }, - { - PCCARD_VENDOR_NOKIA, PCCARD_PRODUCT_NOKIA_C020_WLAN, - PCCARD_CIS_NOKIA_C020_WLAN, - 0, - "Nokia Communications", - "Nokia C020 WLAN Card" }, - }, - { - PCCARD_VENDOR_PANASONIC, PCCARD_PRODUCT_PANASONIC_KXLC002, - PCCARD_CIS_PANASONIC_KXLC002, - 0, - "Matsushita Electric Industrial Co.", - "Panasonic 4X CD-ROM Interface Card" }, - }, - { - PCCARD_VENDOR_USROBOTICS, PCCARD_PRODUCT_USROBOTICS_WORLDPORT144, - PCCARD_CIS_USROBOTICS_WORLDPORT144, - 0, - "US Robotics Corporation", - "US Robotics WorldPort 14.4 Modem" }, - }, - { - PCCARD_VENDOR_SANDISK, PCCARD_PRODUCT_SANDISK_SDCFB, - PCCARD_CIS_SANDISK_SDCFB, - 0, - "Sandisk Corporation", - "Sandisk CompactFlash Card" }, - }, - { - PCCARD_VENDOR_SIMPLETECH, PCCARD_PRODUCT_SIMPLETECH_COMMUNICATOR288, - PCCARD_CIS_SIMPLETECH_COMMUNICATOR288, - 0, - "Simple Technology", - "Simple Technology 28.8 Communicator" }, - }, - { - PCCARD_VENDOR_SIMPLETECH, PCCARD_PRODUCT_SIMPLETECH_SPECTRUM24, - PCCARD_CIS_SIMPLETECH_SPECTRUM24, - 0, - "Simple Technology", - "Symbol Spectrum24 WLAN Adapter" }, - }, - { - PCCARD_VENDOR_SOCKET, PCCARD_PRODUCT_SOCKET_PAGECARD, - PCCARD_CIS_SOCKET_PAGECARD, - 0, - "Socket Communications", - "Socket Communications PageCard" }, - }, - { - PCCARD_VENDOR_SOCKET, PCCARD_PRODUCT_SOCKET_DUAL_RS232, - PCCARD_CIS_SOCKET_DUAL_RS232, - 0, - "Socket Communications", - "Socket Communications Dual RS232" }, - }, - { - PCCARD_VENDOR_SOCEKT, PCCARD_PRODUCT_SOCEKT_LP_ETHER_CF, - PCCARD_CIS_SOCEKT_LP_ETHER_CF, - 0, - "", - "Socket Communications Low Power Ethernet CF" }, - }, - { - PCCARD_VENDOR_TDK, PCCARD_PRODUCT_TDK_LAK_CD021BX, - PCCARD_CIS_TDK_LAK_CD021BX, - 0, - "TDK Corporation", - "TDK LAK-CD021BX Ethernet" }, - }, - { - PCCARD_VENDOR_TDK, PCCARD_PRODUCT_TDK_DFL9610, - PCCARD_CIS_TDK_DFL9610, - 0, - "TDK Corporation", - "TDK DFL9610 Ethernet & Digital Cellular" }, - }, - { - PCCARD_VENDOR_TDK, PCCARD_PRODUCT_TDK_LAK_CF010, - PCCARD_CIS_TDK_LAK_CF010, - 0, - "TDK Corporation", - "TDK LAC-CF010" }, - }, - { - PCCARD_VENDOR_TDK, PCCARD_PRODUCT_TDK_XIR_CE_10, - PCCARD_CIS_TDK_XIR_CE_10, - 0, - "TDK Corporation", - "Xircom CreditCard Ethernet" }, - }, - { - PCCARD_VENDOR_TDK, PCCARD_PRODUCT_TDK_XIR_CEM_10, - PCCARD_CIS_TDK_XIR_CEM_10, - 0, - "TDK Corporation", - "Xircom CreditCard Ethernet + Modem" }, - }, - { - PCCARD_VENDOR_TDK, PCCARD_PRODUCT_TDK_XIR_CEM_28, - PCCARD_CIS_TDK_XIR_CEM_28, - 0, - "TDK Corporation", - "Xircom CreditCard Ethernet + Modem 28.8" }, - }, - { - PCCARD_VENDOR_TDK, PCCARD_PRODUCT_TDK_XIR_PS_CE2_10, - PCCARD_CIS_TDK_XIR_PS_CE2_10, - 0, - "TDK Corporation", - "Xircom CreditCard CE2 Ethernet" }, - }, - { - PCCARD_VENDOR_TDK, PCCARD_PRODUCT_TDK_XIR_CE3_10_100, - PCCARD_CIS_TDK_XIR_CE3_10_100, - 0, - "TDK Corporation", - "Xircom CreditCard CE3 10/100 Ethernet" }, - }, - { - PCCARD_VENDOR_TDK, PCCARD_PRODUCT_TDK_XIR_CNW_801, - PCCARD_CIS_TDK_XIR_CNW_801, - 0, - "TDK Corporation", - "Xircom CreditCard Netwave (Canada)" }, - }, - { - PCCARD_VENDOR_TDK, PCCARD_PRODUCT_TDK_XIR_CNW_802, - PCCARD_CIS_TDK_XIR_CNW_802, - 0, - "TDK Corporation", - "Xircom CreditCard Netwave (US)" }, - }, - { - PCCARD_VENDOR_NEWMEDIA, PCCARD_PRODUCT_NEWMEDIA_BASICS, - PCCARD_CIS_NEWMEDIA_BASICS, - 0, - "NewMedia Corporation", - "New Media BASICS Ethernet" }, - }, - { - PCCARD_VENDOR_NEWMEDIA, PCCARD_PRODUCT_NEWMEDIA_BUSTOASTER, - PCCARD_CIS_NEWMEDIA_BUSTOASTER, - 0, - "NewMedia Corporation", - "New Media BusToaster SCSI Host Adapter" }, - }, - { - PCCARD_VENDOR_SMC, PCCARD_PRODUCT_SMC_8016, - PCCARD_CIS_SMC_8016, - 0, - "Standard Microsystems Corporation", - "SMC 8016 EtherCard" }, - }, - { - PCCARD_VENDOR_SMC, PCCARD_PRODUCT_SMC_EZCARD, - PCCARD_CIS_SMC_EZCARD, - 0, - "Standard Microsystems Corporation", - "SMC EZCard 10 PCMCIA" }, - }, - { - PCCARD_VENDOR_CONTEC, PCCARD_PRODUCT_CONTEC_CNETPC, - PCCARD_CIS_CONTEC_CNETPC, - 0, - "Contec", - "Contec C-NET(PC)C" }, - }, - { - PCCARD_VENDOR_ALLIEDTELESIS, PCCARD_PRODUCT_ALLIEDTELESIS_LA_PCM, - PCCARD_CIS_ALLIEDTELESIS_LA_PCM, - 0, - "Allied Telesis K.K.", - "Allied Telesis LA-PCM" }, - }, - { - PCCARD_VENDOR_RATOC, PCCARD_PRODUCT_RATOC_REX_R280, - PCCARD_CIS_RATOC_REX_R280, - 0, - "RATOC System Inc.", - "RATOC REX-R280" }, - }, - { - PCCARD_VENDOR_LUCENT, PCCARD_PRODUCT_LUCENT_WAVELAN_IEEE, - PCCARD_CIS_LUCENT_WAVELAN_IEEE, - 0, - "Lucent Technologies", - "WaveLAN/IEEE" }, - }, - { - PCCARD_VENDOR_AIRONET, PCCARD_PRODUCT_AIRONET_PC4500, - PCCARD_CIS_AIRONET_PC4500, - 0, - "Aironet Wireless Communications", - "Aironet PC4500 Wireless LAN Adapter" }, - }, - { - PCCARD_VENDOR_AIRONET, PCCARD_PRODUCT_AIRONET_PC4800, - PCCARD_CIS_AIRONET_PC4800, - 0, - "Aironet Wireless Communications", - "Aironet PC4800 Wireless LAN Adapter" }, - }, - { - PCCARD_VENDOR_BAY, PCCARD_PRODUCT_BAY_STACK_650, - PCCARD_CIS_BAY_STACK_650, - 0, - "Bay Networks", - "BayStack 650 Wireless LAN" }, - }, - { - PCCARD_VENDOR_BAY, PCCARD_PRODUCT_BAY_SURFER_PRO, - PCCARD_CIS_BAY_SURFER_PRO, - 0, - "Bay Networks", - "AirSurfer Pro Wireless LAN" }, - }, - { - PCCARD_VENDOR_BAY, PCCARD_PRODUCT_BAY_STACK_660, - PCCARD_CIS_BAY_STACK_660, - 0, - "Bay Networks", - "BayStack 660 Wireless LAN" }, - }, - { - PCCARD_VENDOR_RAYTHEON, PCCARD_PRODUCT_RAYTHEON_WLAN, - PCCARD_CIS_RAYTHEON_WLAN, - 0, - "Raytheon", - "WLAN Adapter" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_MEGAHERTZ_XJ2288, - PCCARD_CIS_MEGAHERTZ_XJ2288, - 0, - "Megahertz Corporation", - "Megahertz XJ2288 Modem" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_PREMAX_PE200, - PCCARD_CIS_PREMAX_PE200, - 0, - "Premax", - "PreMax PE-200" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_PLANET_SMARTCOM2000, - PCCARD_CIS_PLANET_SMARTCOM2000, - 0, - "Planet", - "Planet SmartCOM 2000" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_PLANEX_FNW3600T, - PCCARD_CIS_PLANEX_FNW3600T, - 0, - "Planex Communications Inc", - "Planex FNW-3600-T" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_PLANEX_FNW3700T, - PCCARD_CIS_PLANEX_FNW3700T, - 0, - "Planex Communications Inc", - "Planex FNW-3700-T" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_DLINK_DE650, - PCCARD_CIS_DLINK_DE650, - 0, - "D-Link", - "D-Link DE-650" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_DLINK_DE660, - PCCARD_CIS_DLINK_DE660, - 0, - "D-Link", - "D-Link DE-660" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_RPTI_EP400, - PCCARD_CIS_RPTI_EP400, - 0, - "RPTI", - "RPTI EP400" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_RPTI_EP401, - PCCARD_CIS_RPTI_EP401, - 0, - "RPTI", - "RPTI EP401" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_ACCTON_EN2212, - PCCARD_CIS_ACCTON_EN2212, - 0, - "ACCTON", - "Accton EN2212" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_YEDATA_EXTERNAL_FDD, - PCCARD_CIS_YEDATA_EXTERNAL_FDD, - 0, - "Y-E DATA", - "Y-E DATA External FDD" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_DIGITAL_DEPCMXX, - PCCARD_CIS_DIGITAL_DEPCMXX, - 0, - "Digital Equipment Corporation", - "DEC DEPCM-BA" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_TEAC_IDECARDII, - PCCARD_CIS_TEAC_IDECARDII, - 0, - "TEAC", - "TEAC IDE Card/II" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_LINKSYS_ECARD_2, - PCCARD_CIS_LINKSYS_ECARD_2, - 0, - "Linksys Corporation", - "Linksys E-Card" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_COREGA_ETHER_PCC_T, - PCCARD_CIS_COREGA_ETHER_PCC_T, - 0, - "Corega K.K.", - "Corega Ether PCC-T" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_COREGA_ETHER_II_PCC_T, - PCCARD_CIS_COREGA_ETHER_II_PCC_T, - 0, - "Corega K.K.", - "Corega EtherII PCC-T" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_COREGA_FAST_ETHER_PCC_TX, - PCCARD_CIS_COREGA_FAST_ETHER_PCC_TX, - 0, - "Corega K.K.", - "Corega FastEther PCC-TX" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_SVEC_COMBOCARD, - PCCARD_CIS_SVEC_COMBOCARD, - 0, - "SVEC/Hawking Technology", - "SVEC/Hawking Tech. Combo Card" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_SVEC_LANCARD, - PCCARD_CIS_SVEC_LANCARD, - 0, - "SVEC/Hawking Technology", - "SVEC PCMCIA Lan Card" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_SVEC_PN650TX, - PCCARD_CIS_SVEC_PN650TX, - 0, - "SVEC/Hawking Technology", - "SVEC PN650TX 10/100 Dual Speed Fast Ethernet PC Card" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_NAKAGAWAMETAL_LNT10TN, - PCCARD_CIS_NAKAGAWAMETAL_LNT10TN, - 0, - "NAKAGAWA METAL", - "NAKAGAWA METAL LNT-10TN NE2000 Compatible Card" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_EPSON_EEN10B, - PCCARD_CIS_EPSON_EEN10B, - 0, - "Seiko Epson Corporation", - "Epson EEN10B" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_EXP_EXPMULTIMEDIA, - PCCARD_CIS_EXP_EXPMULTIMEDIA, - 0, - "EXP Computer Inc", - "EXP IDE/ATAPI DVD Card" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_AMD_AM79C930, - PCCARD_CIS_AMD_AM79C930, - 0, - "AMD", - "AMD Am79C930" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_ICOM_SL200, - PCCARD_CIS_ICOM_SL200, - 0, - "ICOM Inc", - "Icom SL-200" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_XIRCOM_CFE_10, - PCCARD_CIS_XIRCOM_CFE_10, - 0, - "Xircom", - "Xircom CompactCard CFE-10" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_BILLIONTON_LNT10TN, - PCCARD_CIS_BILLIONTON_LNT10TN, - 0, - "Billionton Systems Inc.", - "Billionton Systems Inc. LNT-10TN NE2000 Compatible Card" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_AMBICOM_AMB8002T, - PCCARD_CIS_AMBICOM_AMB8002T, - 0, - "AmbiCom Inc", - "AmbiCom AMB8002T" }, - }, - { - PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_IODATA_PCLAT, - PCCARD_CIS_IODATA_PCLAT, - 0, - "I-O DATA", - "IO-DATA PCLA/T" }, - }, - { - PCCARD_VENDOR_FUJITSU, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Fujitsu Corporation", - NULL, - }, - { - PCCARD_VENDOR_PANASONIC, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Matsushita Electric Industrial Co.", - NULL, - }, - { - PCCARD_VENDOR_SANDISK, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Sandisk Corporation", - NULL, - }, - { - PCCARD_VENDOR_NEWMEDIA, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "NewMedia Corporation", - NULL, - }, - { - PCCARD_VENDOR_INTEL, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Intel Corporation", - NULL, - }, - { - PCCARD_VENDOR_IBM, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "IBM Corporation", - NULL, - }, - { - PCCARD_VENDOR_MOTOROLA, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Motorola Corporation", - NULL, - }, - { - PCCARD_VENDOR_3COM, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "3Com Corporation", - NULL, - }, - { - PCCARD_VENDOR_MEGAHERTZ, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Megahertz Corporation", - NULL, - }, - { - PCCARD_VENDOR_SOCKET, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Socket Communications", - NULL, - }, - { - PCCARD_VENDOR_TDK, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "TDK Corporation", - NULL, - }, - { - PCCARD_VENDOR_XIRCOM, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Xircom", - NULL, - }, - { - PCCARD_VENDOR_SMC, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Standard Microsystems Corporation", - NULL, - }, - { - PCCARD_VENDOR_USROBOTICS, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "US Robotics Corporation", - NULL, - }, - { - PCCARD_VENDOR_MEGAHERTZ2, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Megahertz Corporation", - NULL, - }, - { - PCCARD_VENDOR_ADAPTEC, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Adaptec Corporation", - NULL, - }, - { - PCCARD_VENDOR_COMPAQ, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Compaq", - NULL, - }, - { - PCCARD_VENDOR_LINKSYS, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Linksys Corporation", - NULL, - }, - { - PCCARD_VENDOR_SIMPLETECH, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Simple Technology", - NULL, - }, - { - PCCARD_VENDOR_LUCENT, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Lucent Technologies", - NULL, - }, - { - PCCARD_VENDOR_AIRONET, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Aironet Wireless Communications", - NULL, - }, - { - PCCARD_VENDOR_COMPAQ2, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Compaq", - NULL, - }, - { - PCCARD_VENDOR_DAYNA, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Dayna Corporation", - NULL, - }, - { - PCCARD_VENDOR_RAYTHEON, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Raytheon", - NULL, - }, - { - PCCARD_VENDOR_IODATA, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "I-O DATA", - NULL, - }, - { - PCCARD_VENDOR_BAY, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Bay Networks", - NULL, - }, - { - PCCARD_VENDOR_NOKIA, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Nokia Communications", - NULL, - }, - { - PCCARD_VENDOR_LASAT, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Lasat Communications A/S", - NULL, - }, - { - PCCARD_VENDOR_LEXARMEDIA, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Lexar Media", - NULL, - }, - { - PCCARD_VENDOR_COMPEX, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Compex Corporation", - NULL, - }, - { - PCCARD_VENDOR_MELCO, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Melco Corporation", - NULL, - }, - { - PCCARD_VENDOR_CONTEC, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Contec", - NULL, - }, - { - PCCARD_VENDOR_COREGA, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Corega K.K.", - NULL, - }, - { - PCCARD_VENDOR_ALLIEDTELESIS, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Allied Telesis K.K.", - NULL, - }, - { - PCCARD_VENDOR_HAGIWARASYSCOM, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Hagiwara SYS-COM", - NULL, - }, - { - PCCARD_VENDOR_RATOC, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "RATOC System Inc.", - NULL, - }, - { - PCCARD_VENDOR_PREMAX, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Premax", - NULL, - }, - { - PCCARD_VENDOR_PLANET, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Planet", - NULL, - }, - { - PCCARD_VENDOR_PLANEX, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Planex Communications Inc", - NULL, - }, - { - PCCARD_VENDOR_DLINK, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "D-Link", - NULL, - }, - { - PCCARD_VENDOR_RPTI, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "RPTI", - NULL, - }, - { - PCCARD_VENDOR_ACCTON, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "ACCTON", - NULL, - }, - { - PCCARD_VENDOR_YEDATA, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Y-E DATA", - NULL, - }, - { - PCCARD_VENDOR_DIGITAL, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Digital Equipment Corporation", - NULL, - }, - { - PCCARD_VENDOR_TEAC, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "TEAC", - NULL, - }, - { - PCCARD_VENDOR_SVEC, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "SVEC/Hawking Technology", - NULL, - }, - { - PCCARD_VENDOR_NAKAGAWAMETAL, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "NAKAGAWA METAL", - NULL, - }, - { - PCCARD_VENDOR_AMBICOM, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "AmbiCom Inc", - NULL, - }, - { - PCCARD_VENDOR_EPSON, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Seiko Epson Corporation", - NULL, - }, - { - PCCARD_VENDOR_EXP, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "EXP Computer Inc", - NULL, - }, - { - PCCARD_VENDOR_ICOM, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "ICOM Inc", - NULL, - }, - { - PCCARD_VENDOR_BILLIONTON, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "Billionton Systems Inc.", - NULL, - }, - { - PCCARD_VENDOR_AMD, 0, - PCCARD_KNOWNDEV_NOPROD, - PCCARD_CIS_INVALID, - "AMD", - NULL, - }, - { 0, 0, { NULL, NULL, NULL, NULL }, 0, NULL, NULL, } -}; diff --git a/sys/dev/misc/pcic/Makefile b/sys/dev/misc/pcic/Makefile deleted file mode 100644 index 3cc76e43a0..0000000000 --- a/sys/dev/misc/pcic/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD: src/sys/modules/pcic/Makefile,v 1.13 1999/12/19 05:49:56 imp Exp $ -# $DragonFly: src/sys/dev/misc/pcic/Attic/Makefile,v 1.3 2003/08/15 08:32:29 dillon Exp $ - -.PATH: ${.CURDIR}/../../../bus/pccard -KMOD= pcic -SRCS= i82365.c i82365_isa.c \ - device_if.h bus_if.h isa_if.h power_if.h card_if.h -NOMAN= - -.include diff --git a/sys/dev/pccard/Makefile b/sys/dev/pccard/Makefile new file mode 100644 index 0000000000..d19c32994f --- /dev/null +++ b/sys/dev/pccard/Makefile @@ -0,0 +1,6 @@ +# $DragonFly: src/sys/dev/pccard/Makefile,v 1.1 2004/02/10 07:55:46 joerg Exp $ +# + +SUBDIR=cardbus exca pccbb pcic + +.include diff --git a/sys/dev/pccard/cardbus/Makefile b/sys/dev/pccard/cardbus/Makefile new file mode 100644 index 0000000000..57013dbac8 --- /dev/null +++ b/sys/dev/pccard/cardbus/Makefile @@ -0,0 +1,9 @@ +# $DragonFly: src/sys/dev/pccard/cardbus/Makefile,v 1.1 2004/02/10 07:55:47 joerg Exp $ + +KMOD= cardbus +SRCS= cardbus.c cardbus_cis.c \ + device_if.h bus_if.h pci_if.h pcib_if.h power_if.h card_if.h +KMODDEPS = exca +NOMAN= + +.include diff --git a/sys/dev/pccard/cardbus/cardbus.c b/sys/dev/pccard/cardbus/cardbus.c new file mode 100644 index 0000000000..2a19fe5480 --- /dev/null +++ b/sys/dev/pccard/cardbus/cardbus.c @@ -0,0 +1,1266 @@ +/* + * Copyright (c) 2000,2001 Jonathan Chen. + * 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, + * without modification, immediately at the beginning of the file. + * 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: src/sys/dev/cardbus/cardbus.c,v 1.28 2002/11/27 17:30:41 imp Exp $ + * $DragonFly: src/sys/dev/pccard/cardbus/cardbus.c,v 1.1 2004/02/10 07:55:47 joerg Exp $ + */ + +/* + * Cardbus Bus Driver + * + * much of the bus code was stolen directly from sys/pci/pci.c + * (Copyright (c) 1997, Stefan Esser ) + * + * Written by Jonathan Chen + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "power_if.h" +#include "pcib_if.h" + +/* sysctl vars */ +SYSCTL_NODE(_hw, OID_AUTO, cardbus, CTLFLAG_RD, 0, "CardBus parameters"); + +int cardbus_debug = 0; +TUNABLE_INT("hw.cardbus.debug", &cardbus_debug); +SYSCTL_INT(_hw_cardbus, OID_AUTO, debug, CTLFLAG_RW, + &cardbus_debug, 0, + "CardBus debug"); + +int cardbus_cis_debug = 0; +TUNABLE_INT("hw.cardbus.cis_debug", &cardbus_cis_debug); +SYSCTL_INT(_hw_cardbus, OID_AUTO, cis_debug, CTLFLAG_RW, + &cardbus_cis_debug, 0, + "CardBus CIS debug"); + +#define DPRINTF(a) if (cardbus_debug) printf a +#define DEVPRINTF(x) if (cardbus_debug) device_printf x + + +static struct resource *cardbus_alloc_resource(device_t cbdev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, + u_int flags); +static int cardbus_attach(device_t cbdev); +static int cardbus_attach_card(device_t cbdev); +static int cardbus_child_location_str(device_t cbdev, device_t child, + char *, size_t len); +static int cardbus_child_pnpinfo_str(device_t cbdev, device_t child, + char *, size_t len); +static __inline void cardbus_clear_command_bit(device_t cbdev, device_t child, + u_int16_t bit); +static void cardbus_delete_resource(device_t cbdev, device_t child, + int type, int rid); +static void cardbus_delete_resource_method(device_t cbdev, device_t child, + int type, int rid); +static int cardbus_detach(device_t cbdev); +static int cardbus_detach_card(device_t cbdev); +static void cardbus_device_setup_regs(device_t brdev, int b, int s, int f, + pcicfgregs *cfg); +static void cardbus_disable_busmaster_method(device_t cbdev, device_t child); +static void cardbus_disable_io_method(device_t cbdev, device_t child, + int space); +static void cardbus_driver_added(device_t cbdev, driver_t *driver); +static void cardbus_enable_busmaster_method(device_t cbdev, device_t child); +static void cardbus_enable_io_method(device_t cbdev, device_t child, + int space); +static int cardbus_freecfg(struct cardbus_devinfo *dinfo); +static int cardbus_get_powerstate_method(device_t cbdev, device_t child); +static int cardbus_get_resource(device_t cbdev, device_t child, int type, + int rid, u_long *startp, u_long *countp); +static int cardbus_get_resource_method(device_t cbdev, device_t child, + int type, int rid, u_long *startp, u_long *countp); +static void cardbus_hdrtypedata(device_t brdev, int b, int s, int f, + pcicfgregs *cfg); +static int cardbus_print_child(device_t cbdev, device_t child); +static int cardbus_print_resources(struct resource_list *rl, + const char *name, int type, const char *format); +static void cardbus_print_verbose(struct cardbus_devinfo *dinfo); +static int cardbus_probe(device_t cbdev); +static void cardbus_probe_nomatch(device_t cbdev, device_t child); +static struct cardbus_devinfo *cardbus_read_device(device_t brdev, int b, + int s, int f); +static void cardbus_read_extcap(device_t cbdev, pcicfgregs *cfg); +static u_int32_t cardbus_read_config_method(device_t cbdev, + device_t child, int reg, int width); +static int cardbus_read_ivar(device_t cbdev, device_t child, int which, + u_long *result); +static void cardbus_release_all_resources(device_t cbdev, + struct cardbus_devinfo *dinfo); +static int cardbus_release_resource(device_t cbdev, device_t child, + int type, int rid, struct resource *r); +static __inline void cardbus_set_command_bit(device_t cbdev, device_t child, + u_int16_t bit); +static int cardbus_set_powerstate_method(device_t cbdev, device_t child, + int state); +static int cardbus_set_resource(device_t cbdev, device_t child, int type, + int rid, u_long start, u_long count, struct resource *res); +static int cardbus_set_resource_method(device_t cbdev, device_t child, + int type, int rid, u_long start, u_long count); +static int cardbus_setup_intr(device_t cbdev, device_t child, + struct resource *irq, int flags, driver_intr_t *intr, + void *arg, void **cookiep); +static int cardbus_teardown_intr(device_t cbdev, device_t child, + struct resource *irq, void *cookie); +static void cardbus_write_config_method(device_t cbdev, device_t child, + int reg, u_int32_t val, int width); +static int cardbus_write_ivar(device_t cbdev, device_t child, int which, + uintptr_t value); + +/************************************************************************/ +/* Probe/Attach */ +/************************************************************************/ + +static int +cardbus_probe(device_t cbdev) +{ + device_set_desc(cbdev, "CardBus bus"); + return 0; +} + +static int +cardbus_attach(device_t cbdev) +{ + return 0; +} + +static int +cardbus_detach(device_t cbdev) +{ + cardbus_detach_card(cbdev); + return 0; +} + +static int +cardbus_suspend(device_t self) +{ + cardbus_detach_card(self); + return (0); +} + +static int +cardbus_resume(device_t self) +{ + return (0); +} + +/************************************************************************/ +/* Attach/Detach card */ +/************************************************************************/ + +static void +cardbus_device_setup_regs(device_t brdev, int b, int s, int f, pcicfgregs *cfg) +{ + PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_INTLINE, + pci_get_irq(device_get_parent(brdev)), 1); + cfg->intline = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_INTLINE, 1); + + PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_CACHELNSZ, 0x08, 1); + cfg->cachelnsz = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_CACHELNSZ, 1); + + PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_LATTIMER, 0xa8, 1); + cfg->lattimer = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_LATTIMER, 1); + + PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_MINGNT, 0x14, 1); + cfg->mingnt = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_MINGNT, 1); + + PCIB_WRITE_CONFIG(brdev, b, s, f, PCIR_MAXLAT, 0x14, 1); + cfg->maxlat = PCIB_READ_CONFIG(brdev, b, s, f, PCIR_MAXLAT, 1); +} + +static int +cardbus_attach_card(device_t cbdev) +{ + device_t brdev = device_get_parent(cbdev); + int cardattached = 0; + static int curr_bus_number = 2; /* XXX EVILE BAD (see below) */ + int bus, slot, func; + + cardbus_detach_card(cbdev); /* detach existing cards */ + + POWER_ENABLE_SOCKET(brdev, cbdev); + bus = pcib_get_bus(cbdev); + if (bus == 0) { + /* + * XXX EVILE BAD XXX + * Not all BIOSes initialize the secondary bus number properly, + * so if the default is bad, we just put one in and hope it + * works. + */ + bus = curr_bus_number; + pci_write_config(brdev, PCIR_SECBUS_2, curr_bus_number, 1); + pci_write_config(brdev, PCIR_SUBBUS_2, curr_bus_number + 2, 1); + curr_bus_number += 3; + } + /* For each function, set it up and try to attach a driver to it */ + for (slot = 0; slot <= CARDBUS_SLOTMAX; slot++) { + int cardbusfunchigh = 0; + for (func = 0; func <= cardbusfunchigh; func++) { + struct cardbus_devinfo *dinfo = + cardbus_read_device(brdev, bus, slot, func); + + if (dinfo == NULL) + continue; + if (dinfo->pci.cfg.mfdev) + cardbusfunchigh = CARDBUS_FUNCMAX; + + cardbus_device_setup_regs(brdev, bus, slot, func, + &dinfo->pci.cfg); + cardbus_print_verbose(dinfo); + dinfo->pci.cfg.dev = device_add_child(cbdev, NULL, -1); + if (!dinfo->pci.cfg.dev) { + DEVPRINTF((cbdev, "Cannot add child!\n")); + cardbus_freecfg(dinfo); + continue; + } + resource_list_init(&dinfo->pci.resources); + device_set_ivars(dinfo->pci.cfg.dev, dinfo); + cardbus_do_cis(cbdev, dinfo->pci.cfg.dev); + if (device_probe_and_attach(dinfo->pci.cfg.dev) != 0) + cardbus_release_all_resources(cbdev, dinfo); + else + cardattached++; + } + } + + if (cardattached > 0) + return (0); + POWER_DISABLE_SOCKET(brdev, cbdev); + return (ENOENT); +} + +static int +cardbus_detach_card(device_t cbdev) +{ + int numdevs; + device_t *devlist; + int tmp; + int err = 0; + + device_get_children(cbdev, &devlist, &numdevs); + + if (numdevs == 0) { + free(devlist, M_TEMP); + return (ENOENT); + } + + for (tmp = 0; tmp < numdevs; tmp++) { + struct cardbus_devinfo *dinfo = device_get_ivars(devlist[tmp]); + int status = device_get_state(devlist[tmp]); + + if (dinfo->pci.cfg.dev != devlist[tmp]) + device_printf(cbdev, "devinfo dev mismatch\n"); + if (status == DS_ATTACHED || status == DS_BUSY) + device_detach(devlist[tmp]); + cardbus_release_all_resources(cbdev, dinfo); + device_delete_child(cbdev, devlist[tmp]); + cardbus_freecfg(dinfo); + } + POWER_DISABLE_SOCKET(device_get_parent(cbdev), cbdev); + free(devlist, M_TEMP); + return (err); +} + +static void +cardbus_driver_added(device_t cbdev, driver_t *driver) +{ + int numdevs; + device_t *devlist; + int tmp; + struct cardbus_devinfo *dinfo; + + device_get_children(cbdev, &devlist, &numdevs); + + DEVICE_IDENTIFY(driver, cbdev); + POWER_ENABLE_SOCKET(device_get_parent(cbdev), cbdev); + for (tmp = 0; tmp < numdevs; tmp++) { + if (device_get_state(devlist[tmp]) == DS_NOTPRESENT) { + dinfo = device_get_ivars(devlist[tmp]); +#ifdef notyet + cardbus_device_setup_regs(brdev, bus, slot, func, + &dinfo->pci.cfg); +#endif + cardbus_print_verbose(dinfo); + resource_list_init(&dinfo->pci.resources); + cardbus_do_cis(cbdev, dinfo->pci.cfg.dev); + if (device_probe_and_attach(dinfo->pci.cfg.dev) != 0) { + cardbus_release_all_resources(cbdev, dinfo); + } + } + } + + free(devlist, M_TEMP); +} + +/************************************************************************/ +/* PCI-Like config reading (copied from pci.c */ +/************************************************************************/ + +/* read configuration header into pcicfgrect structure */ + +static void +cardbus_read_extcap(device_t cbdev, pcicfgregs *cfg) +{ +#define REG(n, w) PCIB_READ_CONFIG(cbdev, cfg->bus, cfg->slot, cfg->func, n, w) + int ptr, nextptr, ptrptr; + + switch (cfg->hdrtype) { + case 0: + ptrptr = 0x34; + break; + case 2: + ptrptr = 0x14; + break; + default: + return; /* no extended capabilities support */ + } + nextptr = REG(ptrptr, 1); /* sanity check? */ + + /* + * Read capability entries. + */ + while (nextptr != 0) { + /* Sanity check */ + if (nextptr > 255) { + printf("illegal PCI extended capability offset %d\n", + nextptr); + return; + } + /* Find the next entry */ + ptr = nextptr; + nextptr = REG(ptr + 1, 1); + + /* Process this entry */ + switch (REG(ptr, 1)) { + case 0x01: /* PCI power management */ + if (cfg->pp_cap == 0) { + cfg->pp_cap = REG(ptr + PCIR_POWER_CAP, 2); + cfg->pp_status = ptr + PCIR_POWER_STATUS; + cfg->pp_pmcsr = ptr + PCIR_POWER_PMCSR; + if ((nextptr - ptr) > PCIR_POWER_DATA) + cfg->pp_data = ptr + PCIR_POWER_DATA; + } + break; + default: + break; + } + } +#undef REG +} + +/* extract header type specific config data */ + +static void +cardbus_hdrtypedata(device_t brdev, int b, int s, int f, pcicfgregs *cfg) +{ +#define REG(n, w) PCIB_READ_CONFIG(brdev, b, s, f, n, w) + switch (cfg->hdrtype) { + case 0: + cfg->subvendor = REG(PCIR_SUBVEND_0, 2); + cfg->subdevice = REG(PCIR_SUBDEV_0, 2); + cfg->nummaps = PCI_MAXMAPS_0; + break; + case 1: + cfg->subvendor = REG(PCIR_SUBVEND_1, 2); + cfg->subdevice = REG(PCIR_SUBDEV_1, 2); + cfg->nummaps = PCI_MAXMAPS_1; + break; + case 2: + cfg->subvendor = REG(PCIR_SUBVEND_2, 2); + cfg->subdevice = REG(PCIR_SUBDEV_2, 2); + cfg->nummaps = PCI_MAXMAPS_2; + break; + } +#undef REG +} + +static struct cardbus_devinfo * +cardbus_read_device(device_t brdev, int b, int s, int f) +{ +#define REG(n, w) PCIB_READ_CONFIG(brdev, b, s, f, n, w) + pcicfgregs *cfg = NULL; + struct cardbus_devinfo *devlist_entry = NULL; + + if (REG(PCIR_DEVVENDOR, 4) != 0xffffffff) { + devlist_entry = malloc(sizeof(struct cardbus_devinfo), + M_DEVBUF, M_WAITOK | M_ZERO); + if (devlist_entry == NULL) + return (NULL); + + cfg = &devlist_entry->pci.cfg; + + cfg->bus = b; + cfg->slot = s; + cfg->func = f; + cfg->vendor = REG(PCIR_VENDOR, 2); + cfg->device = REG(PCIR_DEVICE, 2); + cfg->cmdreg = REG(PCIR_COMMAND, 2); + cfg->statreg = REG(PCIR_STATUS, 2); + cfg->baseclass = REG(PCIR_CLASS, 1); + cfg->subclass = REG(PCIR_SUBCLASS, 1); + cfg->progif = REG(PCIR_PROGIF, 1); + cfg->revid = REG(PCIR_REVID, 1); + cfg->hdrtype = REG(PCIR_HEADERTYPE, 1); + cfg->cachelnsz = REG(PCIR_CACHELNSZ, 1); + cfg->lattimer = REG(PCIR_LATTIMER, 1); + cfg->intpin = REG(PCIR_INTPIN, 1); + cfg->intline = REG(PCIR_INTLINE, 1); + + cfg->mingnt = REG(PCIR_MINGNT, 1); + cfg->maxlat = REG(PCIR_MAXLAT, 1); + + cfg->mfdev = (cfg->hdrtype & PCIM_MFDEV) != 0; + cfg->hdrtype &= ~PCIM_MFDEV; + + cardbus_hdrtypedata(brdev, b, s, f, cfg); + + if (REG(PCIR_STATUS, 2) & PCIM_STATUS_CAPPRESENT) + cardbus_read_extcap(brdev, cfg); + + devlist_entry->pci.conf.pc_sel.pc_bus = cfg->bus; + devlist_entry->pci.conf.pc_sel.pc_dev = cfg->slot; + devlist_entry->pci.conf.pc_sel.pc_func = cfg->func; + devlist_entry->pci.conf.pc_hdr = cfg->hdrtype; + + devlist_entry->pci.conf.pc_subvendor = cfg->subvendor; + devlist_entry->pci.conf.pc_subdevice = cfg->subdevice; + devlist_entry->pci.conf.pc_vendor = cfg->vendor; + devlist_entry->pci.conf.pc_device = cfg->device; + + devlist_entry->pci.conf.pc_class = cfg->baseclass; + devlist_entry->pci.conf.pc_subclass = cfg->subclass; + devlist_entry->pci.conf.pc_progif = cfg->progif; + devlist_entry->pci.conf.pc_revid = cfg->revid; + } + return (devlist_entry); +#undef REG +} + +/* free pcicfgregs structure and all depending data structures */ + +static int +cardbus_freecfg(struct cardbus_devinfo *dinfo) +{ + free(dinfo, M_DEVBUF); + + return (0); +} + +static void +cardbus_print_verbose(struct cardbus_devinfo *dinfo) +{ + if (bootverbose || cardbus_debug > 0) + { + pcicfgregs *cfg = &dinfo->pci.cfg; + + printf("found->\tvendor=0x%04x, dev=0x%04x, revid=0x%02x\n", + cfg->vendor, cfg->device, cfg->revid); + printf("\tclass=%02x-%02x-%02x, hdrtype=0x%02x, mfdev=%d\n", + cfg->baseclass, cfg->subclass, cfg->progif, + cfg->hdrtype, cfg->mfdev); + printf("\tcmdreg=0x%04x, statreg=0x%04x, " + "cachelnsz=%d (dwords)\n", + cfg->cmdreg, cfg->statreg, cfg->cachelnsz); + printf("\tlattimer=0x%02x (%d ns), mingnt=0x%02x (%d ns), " + "maxlat=0x%02x (%d ns)\n", + cfg->lattimer, cfg->lattimer * 30, + cfg->mingnt, cfg->mingnt * 250, cfg->maxlat, + cfg->maxlat * 250); + if (cfg->intpin > 0) + printf("\tintpin=%c, irq=%d\n", + cfg->intpin + 'a' - 1, cfg->intline); + } +} + +/************************************************************************/ +/* Resources */ +/************************************************************************/ + +static int +cardbus_set_resource(device_t cbdev, device_t child, int type, int rid, + u_long start, u_long count, struct resource *res) +{ + struct cardbus_devinfo *dinfo; + struct resource_list *rl; + struct resource_list_entry *rle; + + if (device_get_parent(child) != cbdev) + return ENOENT; + + dinfo = device_get_ivars(child); + rl = &dinfo->pci.resources; + rle = resource_list_find(rl, type, rid); + if (rle == NULL) { + resource_list_add(rl, type, rid, start, start + count - 1, + count); + if (res != NULL) { + rle = resource_list_find(rl, type, rid); + rle->res = res; + } + } else { + if (rle->res == NULL) { + } else if (rle->res->r_dev == cbdev && + (!(rman_get_flags(rle->res) & RF_ACTIVE))) { + int f; + f = rman_get_flags(rle->res); + bus_release_resource(cbdev, type, rid, res); + rle->res = bus_alloc_resource(cbdev, type, &rid, + start, start + count - 1, + count, f); + } else { + device_printf(cbdev, "set_resource: resource busy\n"); + return EBUSY; + } + rle->start = start; + rle->end = start + count - 1; + rle->count = count; + if (res != NULL) + rle->res = res; + } + if (device_get_parent(child) == cbdev) + pci_write_config(child, rid, start, 4); + return 0; +} + +static int +cardbus_get_resource(device_t cbdev, device_t child, int type, int rid, + u_long *startp, u_long *countp) +{ + struct cardbus_devinfo *dinfo; + struct resource_list *rl; + struct resource_list_entry *rle; + + if (device_get_parent(child) != cbdev) + return ENOENT; + + dinfo = device_get_ivars(child); + rl = &dinfo->pci.resources; + rle = resource_list_find(rl, type, rid); + if (!rle) + return ENOENT; + if (startp) + *startp = rle->start; + if (countp) + *countp = rle->count; + return 0; +} + +static void +cardbus_delete_resource(device_t cbdev, device_t child, int type, int rid) +{ + struct cardbus_devinfo *dinfo; + struct resource_list *rl; + struct resource_list_entry *rle; + + if (device_get_parent(child) != cbdev) + return; + + dinfo = device_get_ivars(child); + rl = &dinfo->pci.resources; + rle = resource_list_find(rl, type, rid); + if (rle) { + if (rle->res) { + if (rle->res->r_dev != cbdev || + rman_get_flags(rle->res) & RF_ACTIVE) { + device_printf(cbdev, "delete_resource: " + "Resource still owned by child, oops. " + "(type=%d, rid=%d, addr=%lx)\n", + rle->type, rle->rid, + rman_get_start(rle->res)); + return; + } + bus_release_resource(cbdev, type, rid, rle->res); + } + resource_list_delete(rl, type, rid); + } + if (device_get_parent(child) == cbdev) + pci_write_config(child, rid, 0, 4); +} + +static int +cardbus_set_resource_method(device_t cbdev, device_t child, int type, int rid, + u_long start, u_long count) +{ + int ret; + ret = cardbus_set_resource(cbdev, child, type, rid, start, count, NULL); + if (ret != 0) + return ret; + return BUS_SET_RESOURCE(device_get_parent(cbdev), child, type, rid, + start, count); +} + +static int +cardbus_get_resource_method(device_t cbdev, device_t child, int type, int rid, + u_long *startp, u_long *countp) +{ + int ret; + ret = cardbus_get_resource(cbdev, child, type, rid, startp, countp); + if (ret != 0) + return ret; + return BUS_GET_RESOURCE(device_get_parent(cbdev), child, type, rid, + startp, countp); +} + +static void +cardbus_delete_resource_method(device_t cbdev, device_t child, + int type, int rid) +{ + cardbus_delete_resource(cbdev, child, type, rid); + BUS_DELETE_RESOURCE(device_get_parent(cbdev), child, type, rid); +} + +static void +cardbus_release_all_resources(device_t cbdev, struct cardbus_devinfo *dinfo) +{ + struct resource_list_entry *rle; + + /* Free all allocated resources */ + SLIST_FOREACH(rle, &dinfo->pci.resources, link) { + if (rle->res) { + if (rle->res->r_dev != cbdev) + device_printf(cbdev, "release_all_resource: " + "Resource still owned by child, oops. " + "(type=%d, rid=%d, addr=%lx)\n", + rle->type, rle->rid, + rman_get_start(rle->res)); + BUS_RELEASE_RESOURCE(device_get_parent(cbdev), + rle->res->r_dev, + rle->type, rle->rid, + rle->res); + rle->res = NULL; + /* + * zero out config so the card won't acknowledge + * access to the space anymore + */ + pci_write_config(dinfo->pci.cfg.dev, rle->rid, 0, 4); + } + } + resource_list_free(&dinfo->pci.resources); +} + +static struct resource * +cardbus_alloc_resource(device_t cbdev, device_t child, int type, + int *rid, u_long start, u_long end, u_long count, u_int flags) +{ + struct cardbus_devinfo *dinfo; + struct resource_list_entry *rle = 0; + int passthrough = (device_get_parent(child) != cbdev); + + if (passthrough) { + return (BUS_ALLOC_RESOURCE(device_get_parent(cbdev), child, + type, rid, start, end, count, flags)); + } + + dinfo = device_get_ivars(child); + rle = resource_list_find(&dinfo->pci.resources, type, *rid); + + if (!rle) + return NULL; /* no resource of that type/rid */ + + if (!rle->res) { + device_printf(cbdev, "WARNING: Resource not reserved by bus\n"); + return NULL; + } else { + /* Release the cardbus hold on the resource */ + if (rle->res->r_dev != cbdev) + return NULL; + bus_release_resource(cbdev, type, *rid, rle->res); + rle->res = NULL; + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + if (!(flags & RF_ALIGNMENT_MASK)) + flags |= rman_make_alignment_flags(rle->count); + break; + case SYS_RES_IRQ: + flags |= RF_SHAREABLE; + break; + } + /* Allocate the resource to the child */ + return resource_list_alloc(&dinfo->pci.resources, cbdev, child, + type, rid, rle->start, rle->end, rle->count, flags); + } +} + +static int +cardbus_release_resource(device_t cbdev, device_t child, int type, int rid, + struct resource *r) +{ + struct cardbus_devinfo *dinfo; + int passthrough = (device_get_parent(child) != cbdev); + struct resource_list_entry *rle = 0; + int flags; + int ret; + + if (passthrough) { + return BUS_RELEASE_RESOURCE(device_get_parent(cbdev), child, + type, rid, r); + } + + dinfo = device_get_ivars(child); + /* + * According to the PCI 2.2 spec, devices may share an address + * decoder between memory mapped ROM access and memory + * mapped register access. To be safe, disable ROM access + * whenever it is released. + */ + if (rid == CARDBUS_ROM_REG) { + uint32_t rom_reg; + + rom_reg = pci_read_config(child, rid, 4); + rom_reg &= ~CARDBUS_ROM_ENABLE; + pci_write_config(child, rid, rom_reg, 4); + } + + rle = resource_list_find(&dinfo->pci.resources, type, rid); + + if (!rle) { + device_printf(cbdev, "Allocated resource not found\n"); + return ENOENT; + } + if (!rle->res) { + device_printf(cbdev, "Allocated resource not recorded\n"); + return ENOENT; + } + + ret = BUS_RELEASE_RESOURCE(device_get_parent(cbdev), child, + type, rid, r); + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + flags = rman_make_alignment_flags(rle->count); + break; + case SYS_RES_IRQ: + flags = RF_SHAREABLE; + break; + default: + flags = 0; + } + /* Restore cardbus hold on the resource */ + rle->res = bus_alloc_resource(cbdev, type, &rid, + rle->start, rle->end, rle->count, flags); + if (rle->res == NULL) + device_printf(cbdev, "release_resource: " + "unable to reacquire resource\n"); + return ret; +} + +static int +cardbus_setup_intr(device_t cbdev, device_t child, struct resource *irq, + int flags, driver_intr_t *intr, void *arg, void **cookiep) +{ + int ret; + device_t cdev; + struct cardbus_devinfo *dinfo; + + ret = bus_generic_setup_intr(cbdev, child, irq, flags, intr, arg, + cookiep); + if (ret != 0) + return ret; + + for (cdev = child; cbdev != device_get_parent(cdev); + cdev = device_get_parent(cdev)) + /* NOTHING */; + dinfo = device_get_ivars(cdev); + + return 0; +} + +static int +cardbus_teardown_intr(device_t cbdev, device_t child, struct resource *irq, + void *cookie) +{ + int ret; + device_t cdev; + struct cardbus_devinfo *dinfo; + + ret = bus_generic_teardown_intr(cbdev, child, irq, cookie); + if (ret != 0) + return ret; + + for (cdev = child; cbdev != device_get_parent(cdev); + cdev = device_get_parent(cdev)) + /* NOTHING */; + dinfo = device_get_ivars(cdev); + + return (0); +} + + +/************************************************************************/ +/* Other Bus Methods */ +/************************************************************************/ + +static int +cardbus_print_resources(struct resource_list *rl, const char *name, + int type, const char *format) +{ + struct resource_list_entry *rle; + int printed, retval; + + printed = 0; + retval = 0; + /* Yes, this is kinda cheating */ + SLIST_FOREACH(rle, rl, link) { + if (rle->type == type) { + if (printed == 0) + retval += printf(" %s ", name); + else if (printed > 0) + retval += printf(","); + printed++; + retval += printf(format, rle->start); + if (rle->count > 1) { + retval += printf("-"); + retval += printf(format, rle->start + + rle->count - 1); + } + } + } + return retval; +} + +static int +cardbus_print_child(device_t cbdev, device_t child) +{ + struct cardbus_devinfo *dinfo; + struct resource_list *rl; + pcicfgregs *cfg; + int retval = 0; + + dinfo = device_get_ivars(child); + cfg = &dinfo->pci.cfg; + rl = &dinfo->pci.resources; + + retval += bus_print_child_header(cbdev, child); + + retval += cardbus_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx"); + retval += cardbus_print_resources(rl, "mem", SYS_RES_MEMORY, "%#lx"); + retval += cardbus_print_resources(rl, "irq", SYS_RES_IRQ, "%ld"); + if (device_get_flags(cbdev)) + retval += printf(" flags %#x", device_get_flags(cbdev)); + + retval += printf(" at device %d.%d", pci_get_slot(child), + pci_get_function(child)); + + retval += bus_print_child_footer(cbdev, child); + + return (retval); +} + +static void +cardbus_probe_nomatch(device_t cbdev, device_t child) +{ + struct cardbus_devinfo *dinfo; + pcicfgregs *cfg; + + dinfo = device_get_ivars(child); + cfg = &dinfo->pci.cfg; + device_printf(cbdev, ""); + printf(" (vendor=0x%04x, dev=0x%04x)", cfg->vendor, cfg->device); + printf(" at %d.%d", pci_get_slot(child), pci_get_function(child)); + if (cfg->intpin > 0 && cfg->intline != 255) { + printf(" irq %d", cfg->intline); + } + printf("\n"); + + return; +} + +static int +cardbus_child_location_str(device_t cbdev, device_t child, char *buf, + size_t buflen) +{ + struct cardbus_devinfo *dinfo; + pcicfgregs *cfg; + + dinfo = device_get_ivars(child); + cfg = &dinfo->pci.cfg; + snprintf(buf, buflen, "slot=%d function=%d", pci_get_slot(child), + pci_get_function(child)); + return (0); +} + +static int +cardbus_child_pnpinfo_str(device_t cbdev, device_t child, char *buf, + size_t buflen) +{ + struct cardbus_devinfo *dinfo; + pcicfgregs *cfg; + + dinfo = device_get_ivars(child); + cfg = &dinfo->pci.cfg; + snprintf(buf, buflen, "vendor=0x%04x device=0x%04x subvendor=0x%04x " + "subdevice=0x%04x", cfg->vendor, cfg->device, cfg->subvendor, + cfg->subdevice); + return (0); +} + +static int +cardbus_read_ivar(device_t cbdev, device_t child, int which, u_long *result) +{ + struct cardbus_devinfo *dinfo; + pcicfgregs *cfg; + + dinfo = device_get_ivars(child); + cfg = &dinfo->pci.cfg; + + switch (which) { + case PCI_IVAR_ETHADDR: + /* + * The generic accessor doesn't deal with failure, so + * we set the return value, then return an error. + */ + if ((dinfo->fepresent & (1 << TPL_FUNCE_LAN_NID)) == 0) { + *((u_int8_t **) result) = NULL; + return (EINVAL); + } + *((u_int8_t **) result) = dinfo->funce.lan.nid; + break; + case PCI_IVAR_SUBVENDOR: + *result = cfg->subvendor; + break; + case PCI_IVAR_SUBDEVICE: + *result = cfg->subdevice; + break; + case PCI_IVAR_VENDOR: + *result = cfg->vendor; + break; + case PCI_IVAR_DEVICE: + *result = cfg->device; + break; + case PCI_IVAR_DEVID: + *result = (cfg->device << 16) | cfg->vendor; + break; + case PCI_IVAR_CLASS: + *result = cfg->baseclass; + break; + case PCI_IVAR_SUBCLASS: + *result = cfg->subclass; + break; + case PCI_IVAR_PROGIF: + *result = cfg->progif; + break; + case PCI_IVAR_REVID: + *result = cfg->revid; + break; + case PCI_IVAR_INTPIN: + *result = cfg->intpin; + break; + case PCI_IVAR_IRQ: + *result = cfg->intline; + break; + case PCI_IVAR_BUS: + *result = cfg->bus; + break; + case PCI_IVAR_SLOT: + *result = cfg->slot; + break; + case PCI_IVAR_FUNCTION: + *result = cfg->func; + break; + default: + return ENOENT; + } + return 0; +} + +static int +cardbus_write_ivar(device_t cbdev, device_t child, int which, uintptr_t value) +{ + struct cardbus_devinfo *dinfo; + pcicfgregs *cfg; + + dinfo = device_get_ivars(child); + cfg = &dinfo->pci.cfg; + + switch (which) { + case PCI_IVAR_ETHADDR: + case PCI_IVAR_SUBVENDOR: + case PCI_IVAR_SUBDEVICE: + case PCI_IVAR_VENDOR: + case PCI_IVAR_DEVICE: + case PCI_IVAR_DEVID: + case PCI_IVAR_CLASS: + case PCI_IVAR_SUBCLASS: + case PCI_IVAR_PROGIF: + case PCI_IVAR_REVID: + case PCI_IVAR_INTPIN: + case PCI_IVAR_IRQ: + case PCI_IVAR_BUS: + case PCI_IVAR_SLOT: + case PCI_IVAR_FUNCTION: + return EINVAL; /* disallow for now */ + default: + return ENOENT; + } + return 0; +} + +/************************************************************************/ +/* Compatibility with PCI bus (XXX: Do we need this?) */ +/************************************************************************/ + +/* + * PCI power manangement + */ +static int +cardbus_set_powerstate_method(device_t cbdev, device_t child, int state) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + pcicfgregs *cfg = &dinfo->pci.cfg; + u_int16_t status; + int result; + + if (cfg->pp_cap != 0) { + status = PCI_READ_CONFIG(cbdev, child, cfg->pp_status, 2) + & ~PCIM_PSTAT_DMASK; + result = 0; + switch (state) { + case PCI_POWERSTATE_D0: + status |= PCIM_PSTAT_D0; + break; + case PCI_POWERSTATE_D1: + if (cfg->pp_cap & PCIM_PCAP_D1SUPP) { + status |= PCIM_PSTAT_D1; + } else { + result = EOPNOTSUPP; + } + break; + case PCI_POWERSTATE_D2: + if (cfg->pp_cap & PCIM_PCAP_D2SUPP) { + status |= PCIM_PSTAT_D2; + } else { + result = EOPNOTSUPP; + } + break; + case PCI_POWERSTATE_D3: + status |= PCIM_PSTAT_D3; + break; + default: + result = EINVAL; + } + if (result == 0) + PCI_WRITE_CONFIG(cbdev, child, cfg->pp_status, + status, 2); + } else { + result = ENXIO; + } + return (result); +} + +static int +cardbus_get_powerstate_method(device_t cbdev, device_t child) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + pcicfgregs *cfg = &dinfo->pci.cfg; + u_int16_t status; + int result; + + if (cfg->pp_cap != 0) { + status = PCI_READ_CONFIG(cbdev, child, cfg->pp_status, 2); + switch (status & PCIM_PSTAT_DMASK) { + case PCIM_PSTAT_D0: + result = PCI_POWERSTATE_D0; + break; + case PCIM_PSTAT_D1: + result = PCI_POWERSTATE_D1; + break; + case PCIM_PSTAT_D2: + result = PCI_POWERSTATE_D2; + break; + case PCIM_PSTAT_D3: + result = PCI_POWERSTATE_D3; + break; + default: + result = PCI_POWERSTATE_UNKNOWN; + break; + } + } else { + /* No support, device is always at D0 */ + result = PCI_POWERSTATE_D0; + } + return (result); +} + +static u_int32_t +cardbus_read_config_method(device_t cbdev, device_t child, int reg, int width) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + pcicfgregs *cfg = &dinfo->pci.cfg; + + return PCIB_READ_CONFIG(device_get_parent(cbdev), + cfg->bus, cfg->slot, cfg->func, reg, width); +} + +static void +cardbus_write_config_method(device_t cbdev, device_t child, int reg, + u_int32_t val, int width) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + pcicfgregs *cfg = &dinfo->pci.cfg; + + PCIB_WRITE_CONFIG(device_get_parent(cbdev), + cfg->bus, cfg->slot, cfg->func, reg, val, width); +} + +static __inline void +cardbus_set_command_bit(device_t cbdev, device_t child, u_int16_t bit) +{ + u_int16_t command; + + command = PCI_READ_CONFIG(cbdev, child, PCIR_COMMAND, 2); + command |= bit; + PCI_WRITE_CONFIG(cbdev, child, PCIR_COMMAND, command, 2); +} + +static __inline void +cardbus_clear_command_bit(device_t cbdev, device_t child, u_int16_t bit) +{ + u_int16_t command; + + command = PCI_READ_CONFIG(cbdev, child, PCIR_COMMAND, 2); + command &= ~bit; + PCI_WRITE_CONFIG(cbdev, child, PCIR_COMMAND, command, 2); +} + +static void +cardbus_enable_busmaster_method(device_t cbdev, device_t child) +{ + cardbus_set_command_bit(cbdev, child, PCIM_CMD_BUSMASTEREN); +} + +static void +cardbus_disable_busmaster_method(device_t cbdev, device_t child) +{ + cardbus_clear_command_bit(cbdev, child, PCIM_CMD_BUSMASTEREN); +} + +static void +cardbus_enable_io_method(device_t cbdev, device_t child, int space) +{ + switch (space) { + case SYS_RES_IOPORT: + cardbus_set_command_bit(cbdev, child, PCIM_CMD_PORTEN); + break; + case SYS_RES_MEMORY: + cardbus_set_command_bit(cbdev, child, PCIM_CMD_MEMEN); + break; + } +} + +static void +cardbus_disable_io_method(device_t cbdev, device_t child, int space) +{ + switch (space) { + case SYS_RES_IOPORT: + cardbus_clear_command_bit(cbdev, child, PCIM_CMD_PORTEN); + break; + case SYS_RES_MEMORY: + cardbus_clear_command_bit(cbdev, child, PCIM_CMD_MEMEN); + break; + } +} + +static device_method_t cardbus_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, cardbus_probe), + DEVMETHOD(device_attach, cardbus_attach), + DEVMETHOD(device_detach, cardbus_detach), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(device_suspend, cardbus_suspend), + DEVMETHOD(device_resume, cardbus_resume), + + /* Bus interface */ + DEVMETHOD(bus_print_child, cardbus_print_child), + DEVMETHOD(bus_probe_nomatch, cardbus_probe_nomatch), + DEVMETHOD(bus_read_ivar, cardbus_read_ivar), + DEVMETHOD(bus_write_ivar, cardbus_write_ivar), + DEVMETHOD(bus_driver_added, cardbus_driver_added), + DEVMETHOD(bus_alloc_resource, cardbus_alloc_resource), + DEVMETHOD(bus_release_resource, cardbus_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, cardbus_setup_intr), + DEVMETHOD(bus_teardown_intr, cardbus_teardown_intr), + + DEVMETHOD(bus_set_resource, cardbus_set_resource_method), + DEVMETHOD(bus_get_resource, cardbus_get_resource_method), + DEVMETHOD(bus_delete_resource, cardbus_delete_resource_method), + DEVMETHOD(bus_child_pnpinfo_str, cardbus_child_pnpinfo_str), + DEVMETHOD(bus_child_location_str, cardbus_child_location_str), + + /* Card Interface */ + DEVMETHOD(card_attach_card, cardbus_attach_card), + DEVMETHOD(card_detach_card, cardbus_detach_card), + DEVMETHOD(card_cis_read, cardbus_cis_read), + DEVMETHOD(card_cis_free, cardbus_cis_free), + + /* Cardbus/PCI interface */ + DEVMETHOD(pci_read_config, cardbus_read_config_method), + DEVMETHOD(pci_write_config, cardbus_write_config_method), + DEVMETHOD(pci_enable_busmaster, cardbus_enable_busmaster_method), + DEVMETHOD(pci_disable_busmaster, cardbus_disable_busmaster_method), + DEVMETHOD(pci_enable_io, cardbus_enable_io_method), + DEVMETHOD(pci_disable_io, cardbus_disable_io_method), + DEVMETHOD(pci_get_powerstate, cardbus_get_powerstate_method), + DEVMETHOD(pci_set_powerstate, cardbus_set_powerstate_method), + + {0,0} +}; + +static driver_t cardbus_driver = { + "cardbus", + cardbus_methods, + 0 /* no softc */ +}; + +static devclass_t cardbus_devclass; + +DRIVER_MODULE(cardbus, cbb, cardbus_driver, cardbus_devclass, 0, 0); +MODULE_VERSION(cardbus, 1); +MODULE_DEPEND(cardbus, exca, 1, 1, 1); +/* +MODULE_DEPEND(cardbus, pccbb, 1, 1, 1); +*/ diff --git a/sys/dev/pccard/cardbus/cardbus_cis.c b/sys/dev/pccard/cardbus/cardbus_cis.c new file mode 100644 index 0000000000..40a94798f1 --- /dev/null +++ b/sys/dev/pccard/cardbus/cardbus_cis.c @@ -0,0 +1,1113 @@ +/* + * Copyright (c) 2000,2001 Jonathan Chen. + * 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, + * without modification, immediately at the beginning of the file. + * 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: src/sys/dev/cardbus/cardbus_cis.c,v 1.27 2002/11/27 06:56:29 imp Exp $ + * $DragonFly: src/sys/dev/pccard/cardbus/cardbus_cis.c,v 1.1 2004/02/10 07:55:47 joerg Exp $ + */ + +/* + * CIS Handling for the Cardbus Bus + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +extern int cardbus_cis_debug; + +#define DPRINTF(a) if (cardbus_cis_debug) printf a +#define DEVPRINTF(x) if (cardbus_cis_debug) device_printf x + +#define DECODE_PARAMS \ + (device_t cbdev, device_t child, int id, int len, \ + u_int8_t *tupledata, u_int32_t start, u_int32_t *off, \ + struct tuple_callbacks *info) + +struct tuple_callbacks { + int id; + char *name; + int (*func) DECODE_PARAMS; +}; + +#define DECODE_PROTOTYPE(NAME) static int decode_tuple_ ## NAME DECODE_PARAMS +DECODE_PROTOTYPE(generic); +DECODE_PROTOTYPE(nothing); +DECODE_PROTOTYPE(copy); +DECODE_PROTOTYPE(linktarget); +DECODE_PROTOTYPE(vers_1); +DECODE_PROTOTYPE(funcid); +DECODE_PROTOTYPE(manfid); +DECODE_PROTOTYPE(funce); +DECODE_PROTOTYPE(bar); +DECODE_PROTOTYPE(unhandled); +DECODE_PROTOTYPE(end); +static int cardbus_read_tuple_conf(device_t cbdev, device_t child, + u_int32_t start, u_int32_t *off, int *tupleid, int *len, + u_int8_t *tupledata); +static int cardbus_read_tuple_mem(device_t cbdev, struct resource *res, + u_int32_t start, u_int32_t *off, int *tupleid, int *len, + u_int8_t *tupledata); +static int cardbus_read_tuple(device_t cbdev, device_t child, + struct resource *res, u_int32_t start, u_int32_t *off, + int *tupleid, int *len, u_int8_t *tupledata); +static void cardbus_read_tuple_finish(device_t cbdev, device_t child, + int rid, struct resource *res); +static struct resource *cardbus_read_tuple_init(device_t cbdev, device_t child, + u_int32_t *start, int *rid); +static int decode_tuple(device_t cbdev, device_t child, int tupleid, + int len, u_int8_t *tupledata, u_int32_t start, + u_int32_t *off, struct tuple_callbacks *callbacks); +static int cardbus_parse_cis(device_t cbdev, device_t child, + struct tuple_callbacks *callbacks); +static int barsort(const void *a, const void *b); +static int cardbus_alloc_resources(device_t cbdev, device_t child); +static void cardbus_add_map(device_t cbdev, device_t child, int reg); +static void cardbus_pickup_maps(device_t cbdev, device_t child); + + +#define MAKETUPLE(NAME,FUNC) { CISTPL_ ## NAME, #NAME, decode_tuple_ ## FUNC } + +static char *funcnames[] = { + "Multi-Functioned", + "Memory", + "Serial Port", + "Parallel Port", + "Fixed Disk", + "Video Adaptor", + "Network Adaptor", + "AIMS", + "SCSI", + "Security" +}; + +struct cardbus_quirk { + u_int32_t devid; /* Vendor/device of the card */ + int type; +#define CARDBUS_QUIRK_MAP_REG 1 /* PCI map register in weird place */ + int arg1; + int arg2; +}; + +struct cardbus_quirk cardbus_quirks[] = { + { 0 } +}; + +static struct cis_tupleinfo *cisread_buf; +static int ncisread_buf; + +/* + * Handler functions for various CIS tuples + */ + +DECODE_PROTOTYPE(generic) +{ +#ifdef CARDBUS_DEBUG + int i; + + if (info) + printf("TUPLE: %s [%d]:", info->name, len); + else + printf("TUPLE: Unknown(0x%02x) [%d]:", id, len); + + for (i = 0; i < len; i++) { + if (i % 0x10 == 0 && len > 0x10) + printf("\n 0x%02x:", i); + printf(" %02x", tupledata[i]); + } + printf("\n"); +#endif + return (0); +} + +DECODE_PROTOTYPE(nothing) +{ + return (0); +} + +DECODE_PROTOTYPE(copy) +{ + struct cis_tupleinfo *tmpbuf; + + tmpbuf = malloc(sizeof(struct cis_tupleinfo) * (ncisread_buf+1), + M_DEVBUF, M_WAITOK); + if (ncisread_buf > 0) { + memcpy(tmpbuf, cisread_buf, + sizeof(struct cis_tupleinfo) * ncisread_buf); + free(cisread_buf, M_DEVBUF); + } + cisread_buf = tmpbuf; + + cisread_buf[ncisread_buf].id = id; + cisread_buf[ncisread_buf].len = len; + cisread_buf[ncisread_buf].data = malloc(len, M_DEVBUF, M_WAITOK); + memcpy(cisread_buf[ncisread_buf].data, tupledata, len); + ncisread_buf++; + return (0); +} + +DECODE_PROTOTYPE(linktarget) +{ +#ifdef CARDBUS_DEBUG + int i; + + printf("TUPLE: %s [%d]:", info->name, len); + + for (i = 0; i < len; i++) { + if (i % 0x10 == 0 && len > 0x10) + printf("\n 0x%02x:", i); + printf(" %02x", tupledata[i]); + } + printf("\n"); +#endif + if (len != 3 || tupledata[0] != 'C' || tupledata[1] != 'I' || + tupledata[2] != 'S') { + printf("Invalid data for CIS Link Target!\n"); + decode_tuple_generic(cbdev, child, id, len, tupledata, + start, off, info); + return (EINVAL); + } + return (0); +} + +DECODE_PROTOTYPE(vers_1) +{ + int i; + + printf("Product version: %d.%d\n", tupledata[0], tupledata[1]); + printf("Product name: "); + for (i = 2; i < len; i++) { + if (tupledata[i] == '\0') + printf(" | "); + else if (tupledata[i] == 0xff) + break; + else + printf("%c", tupledata[i]); + } + printf("\n"); + return (0); +} + +DECODE_PROTOTYPE(funcid) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + int numnames = sizeof(funcnames) / sizeof(funcnames[0]); + int i; + + printf("Functions: "); + for (i = 0; i < len; i++) { + if (tupledata[i] < numnames) + printf("%s", funcnames[tupledata[i]]); + else + printf("Unknown(%d)", tupledata[i]); + if (i < len-1) + printf(", "); + } + + if (len > 0) + dinfo->funcid = tupledata[0]; /* use first in list */ + printf("\n"); + return (0); +} + +DECODE_PROTOTYPE(manfid) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + int i; + + printf("Manufacturer ID: "); + for (i = 0; i < len; i++) + printf("%02x", tupledata[i]); + printf("\n"); + + if (len == 5) { + dinfo->mfrid = tupledata[1] | (tupledata[2]<<8); + dinfo->prodid = tupledata[3] | (tupledata[4]<<8); + } + return (0); +} + +DECODE_PROTOTYPE(funce) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + int type, i; + + printf("Function Extension: "); + for (i = 0; i < len; i++) + printf("%02x", tupledata[i]); + printf("\n"); + if (len < 2) /* too short */ + return (0); + type = tupledata[0]; /* XXX <32 always? */ + switch (dinfo->funcid) { + case TPL_FUNC_SERIAL: + if (type == TPL_FUNCE_SER_UART) { /* NB: len known > 1 */ + dinfo->funce.sio.type = tupledata[1] & 0x1f; + } + dinfo->fepresent |= 1<funce.lan.tech = tupledata[1]; /* XXX mask? */ + break; +#if 0 + case TPL_FUNCE_LAN_SPEED: + for (i = 0; i < 3; i++) { + if (dinfo->funce.lan.speed[i] == 0) { + if (len > 4) { + dinfo->funce.lan.speed[i] = + ...; + } + break; + } + } + break; +#endif + case TPL_FUNCE_LAN_MEDIA: + for (i = 0; i < 4 && dinfo->funce.lan.media[i]; i++) { + if (dinfo->funce.lan.media[i] == 0) { + /* NB: len known > 1 */ + dinfo->funce.lan.media[i] = + tupledata[1]; /*XXX? mask */ + break; + } + } + break; + case TPL_FUNCE_LAN_NID: + if (len > 6) + bcopy(&tupledata[1], dinfo->funce.lan.nid, 6); + break; + case TPL_FUNCE_LAN_CONN: + dinfo->funce.lan.contype = tupledata[1];/*XXX mask? */ + break; + } + dinfo->fepresent |= 1< 5 || + (type == SYS_RES_IOPORT && bar == 5)) { + device_printf(cbdev, "Invalid BAR number: %02x(%02x)\n", + reg, bar); + return (0); + } + bar = CARDBUS_BASE0_REG + bar * 4; + if (type == SYS_RES_MEMORY) { + if (bar & TPL_BAR_REG_PREFETCHABLE) + dinfo->mprefetchable |= BARBIT(bar); + if (bar & TPL_BAR_REG_BELOW1MB) + dinfo->mbelow1mb |= BARBIT(bar); + } else if (type == SYS_RES_IOPORT) { + if (bar & TPL_BAR_REG_BELOW1MB) + dinfo->ibelow1mb |= BARBIT(bar); + } + DEVPRINTF((cbdev, "Opening BAR: type=%s, bar=%02x, len=%04x%s%s\n", + (type == SYS_RES_MEMORY) ? "MEM" : "IO", bar, len, + (type == SYS_RES_MEMORY && dinfo->mprefetchable & BARBIT(bar)) ? + " (Prefetchable)" : "", type == SYS_RES_MEMORY ? + ((dinfo->mbelow1mb & BARBIT(bar)) ? " (Below 1Mb)" : "") : + (dinfo->ibelow1mb & BARBIT(bar)) ? " (Below 1Mb)" : "" )); + + resource_list_add(&dinfo->pci.resources, type, bar, 0UL, ~0UL, len); + + /* + * Mark the appropriate bit in the PCI command register so that + * device drivers will know which type of BARs can be used. + */ + pci_enable_io(child, type); + return (0); +} + +DECODE_PROTOTYPE(unhandled) +{ + printf("TUPLE: %s [%d] is unhandled! Bailing...", info->name, len); + return (-1); +} + +DECODE_PROTOTYPE(end) +{ + printf("CIS reading done\n"); + return (0); +} + +/* + * Functions to read the a tuple from the card + */ + +static int +cardbus_read_tuple_conf(device_t cbdev, device_t child, u_int32_t start, + u_int32_t *off, int *tupleid, int *len, u_int8_t *tupledata) +{ + int i, j; + u_int32_t e; + u_int32_t loc; + + loc = start + *off; + + e = pci_read_config(child, loc - loc % 4, 4); + for (j = loc % 4; j > 0; j--) + e >>= 8; + *len = 0; + for (i = loc, j = -2; j < *len; j++, i++) { + if (i % 4 == 0) + e = pci_read_config(child, i, 4); + if (j == -2) + *tupleid = 0xff & e; + else if (j == -1) + *len = 0xff & e; + else + tupledata[j] = 0xff & e; + e >>= 8; + } + *off += *len + 2; + return (0); +} + +static int +cardbus_read_tuple_mem(device_t cbdev, struct resource *res, u_int32_t start, + u_int32_t *off, int *tupleid, int *len, u_int8_t *tupledata) +{ + bus_space_tag_t bt; + bus_space_handle_t bh; + int ret; + + bt = rman_get_bustag(res); + bh = rman_get_bushandle(res); + + *tupleid = bus_space_read_1(bt, bh, start + *off); + *len = bus_space_read_1(bt, bh, start + *off + 1); + bus_space_read_region_1(bt, bh, *off + start + 2, tupledata, *len); + ret = 0; + *off += *len + 2; + return (ret); +} + +static int +cardbus_read_tuple(device_t cbdev, device_t child, struct resource *res, + u_int32_t start, u_int32_t *off, int *tupleid, int *len, + u_int8_t *tupledata) +{ + if (res == (struct resource*)~0UL) { + return (cardbus_read_tuple_conf(cbdev, child, start, off, + tupleid, len, tupledata)); + } else { + return (cardbus_read_tuple_mem(cbdev, res, start, off, + tupleid, len, tupledata)); + } +} + +static void +cardbus_read_tuple_finish(device_t cbdev, device_t child, int rid, + struct resource *res) +{ + if (res != (struct resource*)~0UL) { + bus_release_resource(cbdev, SYS_RES_MEMORY, rid, res); + pci_write_config(child, rid, 0, 4); + PCI_DISABLE_IO(cbdev, child, SYS_RES_MEMORY); + } +} + +static struct resource * +cardbus_read_tuple_init(device_t cbdev, device_t child, u_int32_t *start, + int *rid) +{ + u_int32_t testval; + u_int32_t size; + struct resource *res; + + switch (CARDBUS_CIS_SPACE(*start)) { + case CARDBUS_CIS_ASI_TUPLE: + /* CIS in PCI config space need no initialization */ + return ((struct resource*)~0UL); + case CARDBUS_CIS_ASI_BAR0: + case CARDBUS_CIS_ASI_BAR1: + case CARDBUS_CIS_ASI_BAR2: + case CARDBUS_CIS_ASI_BAR3: + case CARDBUS_CIS_ASI_BAR4: + case CARDBUS_CIS_ASI_BAR5: + *rid = CARDBUS_BASE0_REG + (CARDBUS_CIS_SPACE(*start) - 1) * 4; + break; + case CARDBUS_CIS_ASI_ROM: + *rid = CARDBUS_ROM_REG; +#if 0 + /* + * This mask doesn't contain the bit that actually enables + * the Option ROM. + */ + pci_write_config(child, *rid, CARDBUS_ROM_ADDRMASK, 4); +#endif + break; + default: + device_printf(cbdev, "Unable to read CIS: Unknown space: %d\n", + CARDBUS_CIS_SPACE(*start)); + return (NULL); + } + + /* figure out how much space we need */ + pci_write_config(child, *rid, 0xffffffff, 4); + testval = pci_read_config(child, *rid, 4); + + /* + * This bit has a different meaning depending if we are dealing + * with a normal BAR or an Option ROM BAR. + */ + if (((testval & 0x1) == 0x1) && (*rid != CARDBUS_ROM_REG)) { + device_printf(cbdev, "CIS Space is IO, expecting memory.\n"); + return (NULL); + } + + size = CARDBUS_MAPREG_MEM_SIZE(testval); + /* XXX Is this some kind of hack? */ + if (size < 4096) + size = 4096; + /* allocate the memory space to read CIS */ + res = bus_alloc_resource(cbdev, SYS_RES_MEMORY, rid, 0, ~0, size, + rman_make_alignment_flags(size) | RF_ACTIVE); + if (res == NULL) { + device_printf(cbdev, "Unable to allocate resource " + "to read CIS.\n"); + return (NULL); + } + pci_write_config(child, *rid, + rman_get_start(res) | ((*rid == CARDBUS_ROM_REG)? + CARDBUS_ROM_ENABLE : 0), + 4); + PCI_ENABLE_IO(cbdev, child, SYS_RES_MEMORY); + + /* Flip to the right ROM image if CIS is in ROM */ + if (CARDBUS_CIS_SPACE(*start) == CARDBUS_CIS_ASI_ROM) { + bus_space_tag_t bt; + bus_space_handle_t bh; + u_int32_t imagesize; + u_int32_t imagebase = 0; + u_int32_t pcidata; + u_int16_t romsig; + int romnum = 0; + int imagenum; + + bt = rman_get_bustag(res); + bh = rman_get_bushandle(res); + + imagenum = CARDBUS_CIS_ASI_ROM_IMAGE(*start); + for (romnum = 0;; romnum++) { + romsig = bus_space_read_2(bt, bh, + imagebase + CARDBUS_EXROM_SIGNATURE); + if (romsig != 0xaa55) { + device_printf(cbdev, "Bad header in rom %d: " + "[%x] %04x\n", romnum, imagebase + + CARDBUS_EXROM_SIGNATURE, romsig); + bus_release_resource(cbdev, SYS_RES_MEMORY, + *rid, res); + *rid = 0; + return (NULL); + } + + /* + * If this was the Option ROM image that we were + * looking for, then we are done. + */ + if (romnum == imagenum) + break; + + /* Find out where the next Option ROM image is */ + pcidata = imagebase + bus_space_read_2(bt, bh, + imagebase + CARDBUS_EXROM_DATA_PTR); + imagesize = bus_space_read_2(bt, bh, + pcidata + CARDBUS_EXROM_DATA_IMAGE_LENGTH); + + if (imagesize == 0) { + /* + * XXX some ROMs seem to have this as zero, + * can we assume this means 1 block? + */ + device_printf(cbdev, "Warning, size of Option " + "ROM image %d is 0 bytes, assuming 512 " + "bytes.\n", romnum); + imagesize = 1; + } + + /* Image size is in 512 byte units */ + imagesize <<= 9; + + if ((bus_space_read_1(bt, bh, pcidata + + CARDBUS_EXROM_DATA_INDICATOR) & 0x80) != 0) { + device_printf(cbdev, "Cannot find CIS in " + "Option ROM\n"); + bus_release_resource(cbdev, SYS_RES_MEMORY, + *rid, res); + *rid = 0; + return (NULL); + } + imagebase += imagesize; + } + *start = imagebase + CARDBUS_CIS_ADDR(*start); + } else { + *start = CARDBUS_CIS_ADDR(*start); + } + + return (res); +} + +/* + * Dispatch the right handler function per tuple + */ + +static int +decode_tuple(device_t cbdev, device_t child, int tupleid, int len, + u_int8_t *tupledata, u_int32_t start, u_int32_t *off, + struct tuple_callbacks *callbacks) +{ + int i; + for (i = 0; callbacks[i].id != CISTPL_GENERIC; i++) { + if (tupleid == callbacks[i].id) + return (callbacks[i].func(cbdev, child, tupleid, len, + tupledata, start, off, &callbacks[i])); + } + + if (tupleid < CISTPL_CUSTOMSTART) { + device_printf(cbdev, "Undefined tuple encountered, " + "CIS parsing terminated\n"); + return (EINVAL); + } + return (callbacks[i].func(cbdev, child, tupleid, len, + tupledata, start, off, NULL)); +} + +static int +cardbus_parse_cis(device_t cbdev, device_t child, + struct tuple_callbacks *callbacks) +{ + u_int8_t tupledata[MAXTUPLESIZE]; + int tupleid; + int len; + int expect_linktarget; + u_int32_t start, off; + struct resource *res; + int rid; + + bzero(tupledata, MAXTUPLESIZE); + expect_linktarget = TRUE; + if ((start = pci_read_config(child, CARDBUS_CIS_REG, 4)) == 0) + return (ENXIO); + off = 0; + res = cardbus_read_tuple_init(cbdev, child, &start, &rid); + if (res == NULL) + return (ENXIO); + do { + if (0 != cardbus_read_tuple(cbdev, child, res, start, &off, + &tupleid, &len, tupledata)) { + device_printf(cbdev, "Failed to read CIS.\n"); + cardbus_read_tuple_finish(cbdev, child, rid, res); + return (ENXIO); + } + + if (expect_linktarget && tupleid != CISTPL_LINKTARGET) { + device_printf(cbdev, "Expecting link target, got 0x%x\n", + tupleid); + cardbus_read_tuple_finish(cbdev, child, rid, res); + return (EINVAL); + } + expect_linktarget = decode_tuple(cbdev, child, tupleid, len, + tupledata, start, &off, callbacks); + if (expect_linktarget != 0) { + cardbus_read_tuple_finish(cbdev, child, rid, res); + return (expect_linktarget); + } + } while (tupleid != CISTPL_END); + cardbus_read_tuple_finish(cbdev, child, rid, res); + return (0); +} + +static int +barsort(const void *a, const void *b) +{ + return ((*(const struct resource_list_entry * const *)b)->count - + (*(const struct resource_list_entry * const *)a)->count); +} + +static int +cardbus_alloc_resources(device_t cbdev, device_t child) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + int count; + struct resource_list_entry *rle; + struct resource_list_entry **barlist; + int tmp; + u_int32_t mem_psize = 0, mem_nsize = 0, io_size = 0; + struct resource *res; + u_int32_t start,end; + int rid, flags; + + count = 0; + SLIST_FOREACH(rle, &dinfo->pci.resources, link) { + count++; + } + if (count == 0) + return (0); + barlist = malloc(sizeof(struct resource_list_entry*) * count, M_DEVBUF, + M_WAITOK); + count = 0; + SLIST_FOREACH(rle, &dinfo->pci.resources, link) { + barlist[count] = rle; + if (rle->type == SYS_RES_IOPORT) { + io_size += rle->count; + } else if (rle->type == SYS_RES_MEMORY) { + if (dinfo->mprefetchable & BARBIT(rle->rid)) + mem_psize += rle->count; + else + mem_nsize += rle->count; + } + count++; + } + + /* + * We want to allocate the largest resource first, so that our + * allocated memory is packed. + */ + qsort(barlist, count, sizeof(struct resource_list_entry*), barsort); + + /* Allocate prefetchable memory */ + flags = 0; + for (tmp = 0; tmp < count; tmp++) { + if (barlist[tmp]->res == NULL && + barlist[tmp]->type == SYS_RES_MEMORY && + dinfo->mprefetchable & BARBIT(barlist[tmp]->rid)) { + flags = rman_make_alignment_flags(barlist[tmp]->count); + break; + } + } + if (flags > 0) { /* If any prefetchable memory is requested... */ + /* + * First we allocate one big space for all resources of this + * type. We do this because our parent, pccbb, needs to open + * a window to forward all addresses within the window, and + * it would be best if nobody else has resources allocated + * within the window. + * (XXX: Perhaps there might be a better way to do this?) + */ + rid = 0; + res = bus_alloc_resource(cbdev, SYS_RES_MEMORY, &rid, 0, + (dinfo->mprefetchable & dinfo->mbelow1mb)?0xFFFFF:~0UL, + mem_psize, flags); + start = rman_get_start(res); + end = rman_get_end(res); + DEVPRINTF((cbdev, "Prefetchable memory at %x-%x\n", start, end)); + /* + * Now that we know the region is free, release it and hand it + * out piece by piece. + */ + bus_release_resource(cbdev, SYS_RES_MEMORY, rid, res); + for (tmp = 0; tmp < count; tmp++) { + if (barlist[tmp]->res == NULL && + barlist[tmp]->type == SYS_RES_MEMORY && + dinfo->mprefetchable & BARBIT(barlist[tmp]->rid)) { + barlist[tmp]->res = bus_alloc_resource(cbdev, + barlist[tmp]->type, + &barlist[tmp]->rid, start, end, + barlist[tmp]->count, + rman_make_alignment_flags( + barlist[tmp]->count)); + if (barlist[tmp]->res == NULL) { + mem_nsize += barlist[tmp]->count; + dinfo->mprefetchable &= + ~BARBIT(barlist[tmp]->rid); + DEVPRINTF((cbdev, "Cannot pre-allocate " + "prefetchable memory, will try as " + "non-prefetchable.\n")); + } else { + barlist[tmp]->start = + rman_get_start(barlist[tmp]->res); + barlist[tmp]->end = + rman_get_end(barlist[tmp]->res); + pci_write_config(child, + barlist[tmp]->rid, + barlist[tmp]->start, 4); + DEVPRINTF((cbdev, "Prefetchable memory " + "rid=%x at %lx-%lx\n", + barlist[tmp]->rid, + barlist[tmp]->start, + barlist[tmp]->end)); + } + } + } + } + + /* Allocate non-prefetchable memory */ + flags = 0; + for (tmp = 0; tmp < count; tmp++) { + if (barlist[tmp]->res == NULL && + barlist[tmp]->type == SYS_RES_MEMORY) { + flags = rman_make_alignment_flags(barlist[tmp]->count); + break; + } + } + if (flags > 0) { /* If any non-prefetchable memory is requested... */ + /* + * First we allocate one big space for all resources of this + * type. We do this because our parent, pccbb, needs to open + * a window to forward all addresses within the window, and + * it would be best if nobody else has resources allocated + * within the window. + * (XXX: Perhaps there might be a better way to do this?) + */ + rid = 0; + res = bus_alloc_resource(cbdev, SYS_RES_MEMORY, &rid, 0, + ((~dinfo->mprefetchable) & dinfo->mbelow1mb)?0xFFFFF:~0UL, + mem_nsize, flags); + start = rman_get_start(res); + end = rman_get_end(res); + DEVPRINTF((cbdev, "Non-prefetchable memory at %x-%x\n", + start, end)); + /* + * Now that we know the region is free, release it and hand it + * out piece by piece. + */ + bus_release_resource(cbdev, SYS_RES_MEMORY, rid, res); + for (tmp = 0; tmp < count; tmp++) { + if (barlist[tmp]->res == NULL && + barlist[tmp]->type == SYS_RES_MEMORY) { + barlist[tmp]->res = bus_alloc_resource(cbdev, + barlist[tmp]->type, &barlist[tmp]->rid, + start, end, barlist[tmp]->count, + rman_make_alignment_flags( + barlist[tmp]->count)); + if (barlist[tmp]->res == NULL) { + DEVPRINTF((cbdev, "Cannot pre-allocate " + "memory for cardbus device\n")); + free(barlist, M_DEVBUF); + return (ENOMEM); + } + barlist[tmp]->start = + rman_get_start(barlist[tmp]->res); + barlist[tmp]->end = rman_get_end( + barlist[tmp]->res); + pci_write_config(child, barlist[tmp]->rid, + barlist[tmp]->start, 4); + DEVPRINTF((cbdev, "Non-prefetchable memory " + "rid=%x at %lx-%lx (%lx)\n", + barlist[tmp]->rid, barlist[tmp]->start, + barlist[tmp]->end, barlist[tmp]->count)); + } + } + } + + /* Allocate IO ports */ + flags = 0; + for (tmp = 0; tmp < count; tmp++) { + if (barlist[tmp]->res == NULL && + barlist[tmp]->type == SYS_RES_IOPORT) { + flags = rman_make_alignment_flags(barlist[tmp]->count); + break; + } + } + if (flags > 0) { /* If any IO port is requested... */ + /* + * First we allocate one big space for all resources of this + * type. We do this because our parent, pccbb, needs to open + * a window to forward all addresses within the window, and + * it would be best if nobody else has resources allocated + * within the window. + * (XXX: Perhaps there might be a better way to do this?) + */ + rid = 0; + res = bus_alloc_resource(cbdev, SYS_RES_IOPORT, &rid, 0, + (dinfo->ibelow1mb)?0xFFFFF:~0UL, io_size, flags); + start = rman_get_start(res); + end = rman_get_end(res); + DEVPRINTF((cbdev, "IO port at %x-%x\n", start, end)); + /* + * Now that we know the region is free, release it and hand it + * out piece by piece. + */ + bus_release_resource(cbdev, SYS_RES_IOPORT, rid, res); + for (tmp = 0; tmp < count; tmp++) { + if (barlist[tmp]->res == NULL && + barlist[tmp]->type == SYS_RES_IOPORT) { + barlist[tmp]->res = bus_alloc_resource(cbdev, + barlist[tmp]->type, &barlist[tmp]->rid, + start, end, barlist[tmp]->count, + rman_make_alignment_flags( + barlist[tmp]->count)); + if (barlist[tmp]->res == NULL) { + DEVPRINTF((cbdev, "Cannot pre-allocate " + "IO port for cardbus device\n")); + free(barlist, M_DEVBUF); + return (ENOMEM); + } + barlist[tmp]->start = + rman_get_start(barlist[tmp]->res); + barlist[tmp]->end = + rman_get_end(barlist[tmp]->res); + pci_write_config(child, barlist[tmp]->rid, + barlist[tmp]->start, 4); + DEVPRINTF((cbdev, "IO port rid=%x at %lx-%lx\n", + barlist[tmp]->rid, barlist[tmp]->start, + barlist[tmp]->end)); + } + } + } + + /* Allocate IRQ */ + rid = 0; + res = bus_alloc_resource(cbdev, SYS_RES_IRQ, &rid, 0, ~0UL, 1, + RF_SHAREABLE); + resource_list_add(&dinfo->pci.resources, SYS_RES_IRQ, rid, + rman_get_start(res), rman_get_end(res), 1); + rle = resource_list_find(&dinfo->pci.resources, SYS_RES_IRQ, rid); + rle->res = res; + dinfo->pci.cfg.intline = rman_get_start(res); + pci_write_config(child, PCIR_INTLINE, rman_get_start(res), 1); + + free(barlist, M_DEVBUF); + return (0); +} + +/* + * Adding a memory/io resource (sans CIS) + */ + +static void +cardbus_add_map(device_t cbdev, device_t child, int reg) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + struct resource_list_entry *rle; + u_int32_t size; + u_int32_t testval; + int type; + + SLIST_FOREACH(rle, &dinfo->pci.resources, link) { + if (rle->rid == reg) + return; + } + + if (reg == CARDBUS_ROM_REG) + testval = CARDBUS_ROM_ADDRMASK; + else + testval = ~0; + + pci_write_config(child, reg, testval, 4); + testval = pci_read_config(child, reg, 4); + + if (testval == ~0 || testval == 0) + return; + + if ((testval & 1) == 0) + type = SYS_RES_MEMORY; + else + type = SYS_RES_IOPORT; + + size = CARDBUS_MAPREG_MEM_SIZE(testval); + device_printf(cbdev, "Resource not specified in CIS: id=%x, size=%x\n", + reg, size); + resource_list_add(&dinfo->pci.resources, type, reg, 0UL, ~0UL, size); +} + +static void +cardbus_pickup_maps(device_t cbdev, device_t child) +{ + struct cardbus_devinfo *dinfo = device_get_ivars(child); + struct cardbus_quirk *q; + int reg; + + /* + * Try to pick up any resources that was not specified in CIS. + * Some devices (eg, 3c656) does not list all resources required by + * the driver in its CIS. + * XXX: should we do this or use quirks? + */ + for (reg = 0; reg < dinfo->pci.cfg.nummaps; reg++) { + cardbus_add_map(cbdev, child, PCIR_MAPS + reg * 4); + } + + for (q = &cardbus_quirks[0]; q->devid; q++) { + if (q->devid == ((dinfo->pci.cfg.device << 16) | dinfo->pci.cfg.vendor) + && q->type == CARDBUS_QUIRK_MAP_REG) { + cardbus_add_map(cbdev, child, q->arg1); + } + } +} + +int +cardbus_cis_read(device_t cbdev, device_t child, u_int8_t id, + struct cis_tupleinfo **buff, int *nret) +{ + struct tuple_callbacks cisread_callbacks[] = { + MAKETUPLE(NULL, nothing), + /* first entry will be overwritten */ + MAKETUPLE(NULL, nothing), + MAKETUPLE(DEVICE, nothing), + MAKETUPLE(LONG_LINK_CB, unhandled), + MAKETUPLE(INDIRECT, unhandled), + MAKETUPLE(CONFIG_CB, nothing), + MAKETUPLE(CFTABLE_ENTRY_CB, nothing), + MAKETUPLE(LONGLINK_MFC, unhandled), + MAKETUPLE(BAR, nothing), + MAKETUPLE(PWR_MGMNT, nothing), + MAKETUPLE(EXTDEVICE, nothing), + MAKETUPLE(CHECKSUM, nothing), + MAKETUPLE(LONGLINK_A, unhandled), + MAKETUPLE(LONGLINK_C, unhandled), + MAKETUPLE(LINKTARGET, nothing), + MAKETUPLE(NO_LINK, nothing), + MAKETUPLE(VERS_1, nothing), + MAKETUPLE(ALTSTR, nothing), + MAKETUPLE(DEVICE_A, nothing), + MAKETUPLE(JEDEC_C, nothing), + MAKETUPLE(JEDEC_A, nothing), + MAKETUPLE(CONFIG, nothing), + MAKETUPLE(CFTABLE_ENTRY, nothing), + MAKETUPLE(DEVICE_OC, nothing), + MAKETUPLE(DEVICE_OA, nothing), + MAKETUPLE(DEVICE_GEO, nothing), + MAKETUPLE(DEVICE_GEO_A, nothing), + MAKETUPLE(MANFID, nothing), + MAKETUPLE(FUNCID, nothing), + MAKETUPLE(FUNCE, nothing), + MAKETUPLE(SWIL, nothing), + MAKETUPLE(VERS_2, nothing), + MAKETUPLE(FORMAT, nothing), + MAKETUPLE(GEOMETRY, nothing), + MAKETUPLE(BYTEORDER, nothing), + MAKETUPLE(DATE, nothing), + MAKETUPLE(BATTERY, nothing), + MAKETUPLE(ORG, nothing), + MAKETUPLE(END, end), + MAKETUPLE(GENERIC, nothing), + }; + int ret; + + cisread_callbacks[0].id = id; + cisread_callbacks[0].name = "COPY"; + cisread_callbacks[0].func = decode_tuple_copy; + ncisread_buf = 0; + cisread_buf = NULL; + ret = cardbus_parse_cis(cbdev, child, cisread_callbacks); + + *buff = cisread_buf; + *nret = ncisread_buf; + return (ret); +} + +void +cardbus_cis_free(device_t cbdev, struct cis_tupleinfo *buff, int *nret) +{ + int i; + for (i = 0; i < *nret; i++) + free(buff[i].data, M_DEVBUF); + if (*nret > 0) + free(buff, M_DEVBUF); +} + +int +cardbus_do_cis(device_t cbdev, device_t child) +{ + int ret; + struct tuple_callbacks init_callbacks[] = { + MAKETUPLE(NULL, generic), + MAKETUPLE(DEVICE, generic), + MAKETUPLE(LONG_LINK_CB, unhandled), + MAKETUPLE(INDIRECT, unhandled), + MAKETUPLE(CONFIG_CB, generic), + MAKETUPLE(CFTABLE_ENTRY_CB, generic), + MAKETUPLE(LONGLINK_MFC, unhandled), + MAKETUPLE(BAR, bar), + MAKETUPLE(PWR_MGMNT, generic), + MAKETUPLE(EXTDEVICE, generic), + MAKETUPLE(CHECKSUM, generic), + MAKETUPLE(LONGLINK_A, unhandled), + MAKETUPLE(LONGLINK_C, unhandled), + MAKETUPLE(LINKTARGET, linktarget), + MAKETUPLE(NO_LINK, generic), + MAKETUPLE(VERS_1, vers_1), + MAKETUPLE(ALTSTR, generic), + MAKETUPLE(DEVICE_A, generic), + MAKETUPLE(JEDEC_C, generic), + MAKETUPLE(JEDEC_A, generic), + MAKETUPLE(CONFIG, generic), + MAKETUPLE(CFTABLE_ENTRY, generic), + MAKETUPLE(DEVICE_OC, generic), + MAKETUPLE(DEVICE_OA, generic), + MAKETUPLE(DEVICE_GEO, generic), + MAKETUPLE(DEVICE_GEO_A, generic), + MAKETUPLE(MANFID, manfid), + MAKETUPLE(FUNCID, funcid), + MAKETUPLE(FUNCE, funce), + MAKETUPLE(SWIL, generic), + MAKETUPLE(VERS_2, generic), + MAKETUPLE(FORMAT, generic), + MAKETUPLE(GEOMETRY, generic), + MAKETUPLE(BYTEORDER, generic), + MAKETUPLE(DATE, generic), + MAKETUPLE(BATTERY, generic), + MAKETUPLE(ORG, generic), + MAKETUPLE(END, end), + MAKETUPLE(GENERIC, generic), + }; + + ret = cardbus_parse_cis(cbdev, child, init_callbacks); + if (ret < 0) + return (ret); + cardbus_pickup_maps(cbdev, child); + return (cardbus_alloc_resources(cbdev, child)); +} diff --git a/sys/dev/pccard/cardbus/cardbus_cis.h b/sys/dev/pccard/cardbus/cardbus_cis.h new file mode 100644 index 0000000000..479fb7168c --- /dev/null +++ b/sys/dev/pccard/cardbus/cardbus_cis.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2000,2001 Jonathan Chen. + * 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, + * without modification, immediately at the beginning of the file. + * 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: src/sys/dev/cardbus/cardbus_cis.h,v 1.7 2002/11/27 06:56:29 imp Exp $ + * $DragonFly: src/sys/dev/pccard/cardbus/cardbus_cis.h,v 1.1 2004/02/10 07:55:47 joerg Exp $ + */ + +/* + * Cardbus CIS definitions + */ + +struct cis_tupleinfo; + +int cardbus_do_cis(device_t, device_t); +int cardbus_cis_read(device_t, device_t, u_int8_t, struct cis_tupleinfo**, + int*); +void cardbus_cis_free(device_t, struct cis_tupleinfo*, int*); + +#define MAXTUPLESIZE 0x400 + +/* CIS TUPLES */ + +#define CISTPL_NULL 0x00 +#define CISTPL_DEVICE 0x01 +#define CISTPL_LONG_LINK_CB 0x02 +#define CISTPL_INDIRECT 0x03 +#define CISTPL_CONFIG_CB 0x04 +#define CISTPL_CFTABLE_ENTRY_CB 0x05 +#define CISTPL_LONGLINK_MFC 0x06 +#define CISTPL_BAR 0x07 +#define CISTPL_PWR_MGMNT 0x08 +#define CISTPL_EXTDEVICE 0x09 +#define CISTPL_CHECKSUM 0x10 +#define CISTPL_LONGLINK_A 0x11 +#define CISTPL_LONGLINK_C 0x12 +#define CISTPL_LINKTARGET 0x13 +#define CISTPL_NO_LINK 0x14 +#define CISTPL_VERS_1 0x15 +#define CISTPL_ALTSTR 0x16 +#define CISTPL_DEVICE_A 0x17 +#define CISTPL_JEDEC_C 0x18 +#define CISTPL_JEDEC_A 0x19 +#define CISTPL_CONFIG 0x1A +#define CISTPL_CFTABLE_ENTRY 0x1B +#define CISTPL_DEVICE_OC 0x1C +#define CISTPL_DEVICE_OA 0x1D +#define CISTPL_DEVICE_GEO 0x1E +#define CISTPL_DEVICE_GEO_A 0x1F +#define CISTPL_MANFID 0x20 +#define CISTPL_FUNCID 0x21 +#define CISTPL_FUNCE 0x22 +#define CISTPL_SWIL 0x23 +#define CISTPL_VERS_2 0x40 +#define CISTPL_FORMAT 0x41 +#define CISTPL_GEOMETRY 0x42 +#define CISTPL_BYTEORDER 0x43 +#define CISTPL_DATE 0x44 +#define CISTPL_BATTERY 0x45 +#define CISTPL_ORG 0x46 +#define CISTPL_CUSTOMSTART 0x80 +#define CISTPL_END 0xFF + +#define CISTPL_GENERIC -1 /* catchall */ + +/* BAR */ +#define TPL_BAR_REG_ASI_MASK 0x07 +#define TPL_BAR_REG_AS 0x10 +#define TPL_BAR_REG_PREFETCHABLE_ONLY 0x20 +#define TPL_BAR_REG_PREFETCHABLE_CACHEABLE 0x40 +#define TPL_BAR_REG_PREFETCHABLE 0x60 +#define TPL_BAR_REG_BELOW1MB 0x80 + +/* CISTPL_FUNC */ +#define TPL_FUNC_MF 0 /* multi function tuple */ +#define TPL_FUNC_MEM 1 /* memory */ +#define TPL_FUNC_SERIAL 2 /* serial, including modem and fax */ +#define TPL_FUNC_PARALLEL 3 /* parallel, including printer and SCSI */ +#define TPL_FUNC_DISK 4 /* Disk */ +#define TPL_FUNC_VIDEO 5 /* Video Adaptor */ +#define TPL_FUNC_LAN 6 /* LAN Adaptor */ +#define TPL_FUNC_AIMS 7 /* Auto Inclement Mass Strages */ + +/* TPL_FUNC_LAN */ +#define TPL_FUNCE_LAN_TECH 1 /* technology */ +#define TPL_FUNCE_LAN_SPEED 2 /* speed */ +#define TPL_FUNCE_LAN_MEDIA 3 /* which media do you use? */ +#define TPL_FUNCE_LAN_NID 4 /* node id (address) */ +#define TPL_FUNCE_LAN_CONN 5 /* connector type (shape) */ + +/* TPL_FUNC_SERIAL */ +#define TPL_FUNCE_SER_UART 0 /* UART type */ diff --git a/sys/dev/pccard/cardbus/cardbusreg.h b/sys/dev/pccard/cardbus/cardbusreg.h new file mode 100644 index 0000000000..755a5d3066 --- /dev/null +++ b/sys/dev/pccard/cardbus/cardbusreg.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2000,2001 Jonathan Chen. + * 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, + * without modification, immediately at the beginning of the file. + * 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: src/sys/dev/cardbus/cardbusreg.h,v 1.6 2002/10/07 22:58:24 imp Exp $ + * $DragonFly: src/sys/dev/pccard/cardbus/cardbusreg.h,v 1.1 2004/02/10 07:55:47 joerg Exp $ + */ + +/* + * Register definitions for the Cardbus Bus + */ + + +/* Cardbus bus constants */ +#define CARDBUS_SLOTMAX 0 +#define CARDBUS_FUNCMAX 7 + +/* Cardbus configuration header registers */ +#define CARDBUS_BASE0_REG 0x10 +#define CARDBUS_BASE1_REG 0x14 +#define CARDBUS_BASE2_REG 0x18 +#define CARDBUS_BASE3_REG 0x1C +#define CARDBUS_BASE4_REG 0x20 +#define CARDBUS_BASE5_REG 0x24 +#define CARDBUS_CIS_REG 0x28 +# define CARDBUS_CIS_ASIMASK 0x07 +# define CARDBUS_CIS_ADDRMASK 0x0ffffff8 +# define CARDBUS_CIS_ASI_TUPLE 0x00 +# define CARDBUS_CIS_ASI_BAR0 0x01 +# define CARDBUS_CIS_ASI_BAR1 0x02 +# define CARDBUS_CIS_ASI_BAR2 0x03 +# define CARDBUS_CIS_ASI_BAR3 0x04 +# define CARDBUS_CIS_ASI_BAR4 0x05 +# define CARDBUS_CIS_ASI_BAR5 0x06 +# define CARDBUS_CIS_ASI_ROM 0x07 +#define CARDBUS_ROM_REG 0x30 +# define CARDBUS_ROM_ENABLE 0x00000001 +# define CARDBUS_ROM_ADDRMASK 0xfffff800 + +/* EXROM offsets for reading CIS */ +#define CARDBUS_EXROM_SIGNATURE 0x00 +#define CARDBUS_EXROM_DATA_PTR 0x18 + +#define CARDBUS_EXROM_DATA_SIGNATURE 0x00 /* Signature ("PCIR") */ +#define CARDBUS_EXROM_DATA_VENDOR_ID 0x04 /* Vendor Identification */ +#define CARDBUS_EXROM_DATA_DEVICE_ID 0x06 /* Device Identification */ +#define CARDBUS_EXROM_DATA_LENGTH 0x0a /* PCI Data Structure Length */ +#define CARDBUS_EXROM_DATA_REV 0x0c /* PCI Data Structure Revision */ +#define CARDBUS_EXROM_DATA_CLASS_CODE 0x0d /* Class Code */ +#define CARDBUS_EXROM_DATA_IMAGE_LENGTH 0x10 /* Image Length */ +#define CARDBUS_EXROM_DATA_DATA_REV 0x12 /* Revision Level of Code/Data */ +#define CARDBUS_EXROM_DATA_CODE_TYPE 0x14 /* Code Type */ +#define CARDBUS_EXROM_DATA_INDICATOR 0x15 /* Indicator */ + +/* useful macros */ +#define CARDBUS_CIS_ADDR(x) \ + (CARDBUS_CIS_ADDRMASK & (x)) +#define CARDBUS_CIS_SPACE(x) \ + (CARDBUS_CIS_ASIMASK & (x)) +#define CARDBUS_CIS_ASI_BAR(x) \ + (((CARDBUS_CIS_ASIMASK & (x))-1)*4+0x10) +#define CARDBUS_CIS_ASI_ROM_IMAGE(x) \ + (((x) >> 28) & 0xf) + +#define CARDBUS_MAPREG_MEM_ADDR_MASK 0x0ffffff0 +#define CARDBUS_MAPREG_MEM_ADDR(mr) \ + ((mr) & CARDBUS_MAPREG_MEM_ADDR_MASK) +#define CARDBUS_MAPREG_MEM_SIZE(mr) \ + (CARDBUS_MAPREG_MEM_ADDR(mr) & (~CARDBUS_MAPREG_MEM_ADDR(mr) + 1)) diff --git a/sys/dev/pccard/cardbus/cardbusvar.h b/sys/dev/pccard/cardbus/cardbusvar.h new file mode 100644 index 0000000000..e36910de2b --- /dev/null +++ b/sys/dev/pccard/cardbus/cardbusvar.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2000,2001 Jonathan Chen. + * 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, + * without modification, immediately at the beginning of the file. + * 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: src/sys/dev/cardbus/cardbusvar.h,v 1.7 2002/11/27 06:56:29 imp Exp $ + * $DragonFly: src/sys/dev/pccard/cardbus/cardbusvar.h,v 1.1 2004/02/10 07:55:47 joerg Exp $ + */ + +/* + * Structure definitions for the Cardbus Bus driver + */ +struct cardbus_devinfo { + struct pci_devinfo pci; + u_int8_t mprefetchable; /* bit mask of prefetchable BARs */ + u_int8_t mbelow1mb; /* bit mask of BARs which require below 1Mb */ + u_int8_t ibelow1mb; /* bit mask of BARs which require below 1Mb */ +#define BARBIT(RID) (1<<(((RID)-CARDBUS_BASE0_REG)/4)) + u_int16_t mfrid; /* manufacturer id */ + u_int16_t prodid; /* product id */ + u_int funcid; /* function id */ + union { + struct { + u_int type; /* UART type */ + } sio; + struct { + u_int8_t nid[6]; /* MAC address */ + u_int8_t tech; /* technology */ + u_int8_t contype; /* connector type */ + u_int32_t speed[3]; /* available speeds */ + u_int8_t media[4]; /* media types */ + } lan; + } funce; + u_int32_t fepresent; /* bit mask of funce values present */ +}; diff --git a/sys/dev/pccard/exca/Makefile b/sys/dev/pccard/exca/Makefile new file mode 100644 index 0000000000..51ec141168 --- /dev/null +++ b/sys/dev/pccard/exca/Makefile @@ -0,0 +1,8 @@ +# $DragonFly: src/sys/dev/pccard/exca/Makefile,v 1.1 2004/02/10 07:55:47 joerg Exp $ + +KMOD= exca +SRCS= exca.c \ + device_if.h bus_if.h card_if.h +NOMAN= + +.include diff --git a/sys/dev/pccard/exca/exca.c b/sys/dev/pccard/exca/exca.c new file mode 100644 index 0000000000..49fd8e1b86 --- /dev/null +++ b/sys/dev/pccard/exca/exca.c @@ -0,0 +1,628 @@ +/* $FreeBSD: src/sys/dev/exca/exca.c,v 1.6 2002/10/07 06:18:50 imp Exp $ */ +/* $DragonFly: src/sys/dev/pccard/exca/exca.c,v 1.1 2004/02/10 07:55:47 joerg Exp $ */ + +/* + * Copyright (c) 2002 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 ``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. + * + * This software may be derived from NetBSD i82365.c and other files with + * the following copyright: + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#ifdef EXCA_DEBUG +#define DEVPRINTF(dev, fmt, args...) device_printf((dev), (fmt), ## args) +#define DPRINTF(fmt, args...) printf(fmt, ## args) +#else +#define DEVPRINTF(dev, fmt, args...) +#define DPRINTF(fmt, args...) +#endif + +/* memory */ + +#define EXCA_MEMINFO(NUM) { \ + EXCA_SYSMEM_ADDR ## NUM ## _START_LSB, \ + EXCA_SYSMEM_ADDR ## NUM ## _START_MSB, \ + EXCA_SYSMEM_ADDR ## NUM ## _STOP_LSB, \ + EXCA_SYSMEM_ADDR ## NUM ## _STOP_MSB, \ + EXCA_SYSMEM_ADDR ## NUM ## _WIN, \ + EXCA_CARDMEM_ADDR ## NUM ## _LSB, \ + EXCA_CARDMEM_ADDR ## NUM ## _MSB, \ + EXCA_ADDRWIN_ENABLE_MEM ## NUM, \ +} + +static struct mem_map_index_st { + int sysmem_start_lsb; + int sysmem_start_msb; + int sysmem_stop_lsb; + int sysmem_stop_msb; + int sysmem_win; + int cardmem_lsb; + int cardmem_msb; + int memenable; +} mem_map_index[] = { + EXCA_MEMINFO(0), + EXCA_MEMINFO(1), + EXCA_MEMINFO(2), + EXCA_MEMINFO(3), + EXCA_MEMINFO(4) +}; +#undef EXCA_MEMINFO + +/* + * Helper function. This will map the requested memory slot. We setup the + * map before we call this function. This is used to initially force the + * mapping, as well as later restore the mapping after it has been destroyed + * in some fashion (due to a power event typically). + */ +static void +exca_do_mem_map(struct exca_softc *sc, int win) +{ + struct mem_map_index_st *map; + struct pccard_mem_handle *mem; + + map = &mem_map_index[win]; + mem = &sc->mem[win]; + exca_write(sc, map->sysmem_start_lsb, + (mem->addr >> EXCA_SYSMEM_ADDRX_SHIFT) & 0xff); + exca_write(sc, map->sysmem_start_msb, + ((mem->addr >> (EXCA_SYSMEM_ADDRX_SHIFT + 8)) & + EXCA_SYSMEM_ADDRX_START_MSB_ADDR_MASK) | 0x80); + + exca_write(sc, map->sysmem_stop_lsb, + ((mem->addr + mem->realsize - 1) >> + EXCA_SYSMEM_ADDRX_SHIFT) & 0xff); + exca_write(sc, map->sysmem_stop_msb, + (((mem->addr + mem->realsize - 1) >> + (EXCA_SYSMEM_ADDRX_SHIFT + 8)) & + EXCA_SYSMEM_ADDRX_STOP_MSB_ADDR_MASK) | + EXCA_SYSMEM_ADDRX_STOP_MSB_WAIT2); + + exca_write(sc, map->sysmem_win, + (mem->addr >> EXCA_MEMREG_WIN_SHIFT) & 0xff); + + exca_write(sc, map->cardmem_lsb, + (mem->offset >> EXCA_CARDMEM_ADDRX_SHIFT) & 0xff); + exca_write(sc, map->cardmem_msb, + ((mem->offset >> (EXCA_CARDMEM_ADDRX_SHIFT + 8)) & + EXCA_CARDMEM_ADDRX_MSB_ADDR_MASK) | + ((mem->kind == PCCARD_MEM_ATTR) ? + EXCA_CARDMEM_ADDRX_MSB_REGACTIVE_ATTR : 0)); + + exca_setb(sc, EXCA_ADDRWIN_ENABLE, EXCA_ADDRWIN_ENABLE_MEMCS16 | + map->memenable); + + DELAY(100); +#ifdef EXCA_DEBUG + { + int r1, r2, r3, r4, r5, r6, r7; + r1 = exca_read(sc, map->sysmem_start_msb); + r2 = exca_read(sc, map->sysmem_start_lsb); + r3 = exca_read(sc, map->sysmem_stop_msb); + r4 = exca_read(sc, map->sysmem_stop_lsb); + r5 = exca_read(sc, map->cardmem_msb); + r6 = exca_read(sc, map->cardmem_lsb); + r7 = exca_read(sc, map->sysmem_win); + printf("exca_do_mem_map window %d: %02x%02x %02x%02x " + "%02x%02x %02x (%08x+%08x.%08x*%08lx)\n", + win, r1, r2, r3, r4, r5, r6, r7, + mem->addr, mem->size, mem->realsize, + mem->offset); + } +#endif +} + +/* + * public interface to map a resource. kind is the type of memory to + * map (either common or attribute). Memory created via this interface + * starts out at card address 0. Since the only way to set this is + * to set it on a struct resource after it has been mapped, we're safe + * in maping this assumption. Note that resources can be remapped using + * exca_do_mem_map so that's how the card address can be set later. + */ +int +exca_mem_map(struct exca_softc *sc, int kind, struct resource *res) +{ + int win; + + for (win = 0; win < EXCA_MEM_WINS; win++) { + if ((sc->memalloc & (1 << win)) == 0) { + sc->memalloc |= (1 << win); + break; + } + } + if (win >= EXCA_MEM_WINS) + return (1); + if (((rman_get_start(res) >> EXCA_CARDMEM_ADDRX_SHIFT) & 0xff) != 0 && + (sc->flags & EXCA_HAS_MEMREG_WIN) == 0) { + device_printf(sc->dev, "Does not support mapping above 24M."); + return (1); + } + + sc->mem[win].cardaddr = 0; + sc->mem[win].memt = rman_get_bustag(res); + sc->mem[win].memh = rman_get_bushandle(res); + sc->mem[win].addr = rman_get_start(res); + sc->mem[win].size = rman_get_end(res) - sc->mem[win].addr + 1; + sc->mem[win].realsize = sc->mem[win].size + EXCA_MEM_PAGESIZE - 1; + sc->mem[win].realsize = sc->mem[win].realsize - + (sc->mem[win].realsize % EXCA_MEM_PAGESIZE); + sc->mem[win].offset = (long)(sc->mem[win].addr); + sc->mem[win].kind = kind; + DPRINTF("exca_mem_map window %d bus %x+%x+%lx card addr %x\n", + win, sc->mem[win].addr, sc->mem[win].size, + sc->mem[win].offset, sc->mem[win].cardaddr); + exca_do_mem_map(sc, win); + + return (0); +} + +/* + * Private helper function. This turns off a given memory map that is in + * use. We do this by just clearing the enable bit in the pcic. If we needed + * to make memory unmapping/mapping pairs faster, we would have to store + * more state information about the pcic and then use that to intelligently + * to the map/unmap. However, since we don't do that sort of thing often + * (generally just at configure time), it isn't a case worth optimizing. + */ +static void +exca_mem_unmap(struct exca_softc *sc, int window) +{ + if (window < 0 || window >= EXCA_MEM_WINS) + panic("exca_mem_unmap: window out of range"); + + exca_clrb(sc, EXCA_ADDRWIN_ENABLE, mem_map_index[window].memenable); + sc->memalloc &= ~(1 << window); +} + +/* + * Find the map that we're using to hold the resoruce. This works well + * so long as the client drivers don't do silly things like map the same + * area mutliple times, or map both common and attribute memory at the + * same time. This latter restriction is a bug. We likely should just + * store a pointer to the res in the mem[x] data structure. + */ +static int +exca_mem_findmap(struct exca_softc *sc, struct resource *res) +{ + int win; + + for (win = 0; win < EXCA_MEM_WINS; win++) { + if (sc->mem[win].memt == rman_get_bustag(res) && + sc->mem[win].addr == rman_get_start(res) && + sc->mem[win].size == rman_get_size(res)) + return (win); + } + return (-1); +} + +/* + * Set the memory flag. This means that we are setting if the memory + * is coming from attribute memory or from common memory on the card. + * CIS entries are generally in attribute memory (although they can + * reside in common memory). Generally, this is the only use for attribute + * memory. However, some cards require their drivers to dance in both + * common and/or attribute memory and this interface (and setting the + * offset interface) exist for such cards. + */ +int +exca_mem_set_flags(struct exca_softc *sc, struct resource *res, uint32_t flags) +{ + int win; + + win = exca_mem_findmap(sc, res); + if (win < 0) { + device_printf(sc->dev, + "set_res_flags: specified resource not active\n"); + return (ENOENT); + } + + sc->mem[win].kind = flags; + exca_do_mem_map(sc, win); + return (0); +} + +/* + * Given a resource, go ahead and unmap it if we can find it in the + * resrouce list that's used. + */ +int +exca_mem_unmap_res(struct exca_softc *sc, struct resource *res) +{ + int win; + + win = exca_mem_findmap(sc, res); + if (win < 0) + return (ENOENT); + exca_mem_unmap(sc, win); + return (0); +} + +/* + * Set the offset of the memory. We use this for reading the CIS and + * frobbing the pccard's pccard registers (POR, etc). Some drivers + * need to access this functionality as well, since they have receive + * buffers defined in the attribute memory. Thankfully, these cards + * are few and fare between. Some cards also have common memory that + * is large and only map a small portion of it at a time (but these cards + * are rare, the more common case being to have just a small amount + * of common memory that the driver needs to bcopy data from in order to + * get at it. + */ +int +exca_mem_set_offset(struct exca_softc *sc, struct resource *res, + uint32_t cardaddr, uint32_t *deltap) +{ + int win; + uint32_t delta; + + win = exca_mem_findmap(sc, res); + if (win < 0) { + device_printf(sc->dev, + "set_memory_offset: specified resource not active\n"); + return (ENOENT); + } + sc->mem[win].cardaddr = cardaddr; + delta = cardaddr % EXCA_MEM_PAGESIZE; + if (deltap) + *deltap = delta; + cardaddr -= delta; + sc->mem[win].realsize = sc->mem[win].size + delta + + EXCA_MEM_PAGESIZE - 1; + sc->mem[win].realsize = sc->mem[win].realsize - + (sc->mem[win].realsize % EXCA_MEM_PAGESIZE); + sc->mem[win].offset = cardaddr - sc->mem[win].addr; + exca_do_mem_map(sc, win); + return (0); +} + + +/* I/O */ + +#define EXCA_IOINFO(NUM) { \ + EXCA_IOADDR ## NUM ## _START_LSB, \ + EXCA_IOADDR ## NUM ## _START_MSB, \ + EXCA_IOADDR ## NUM ## _STOP_LSB, \ + EXCA_IOADDR ## NUM ## _STOP_MSB, \ + EXCA_ADDRWIN_ENABLE_IO ## NUM, \ + EXCA_IOCTL_IO ## NUM ## _WAITSTATE \ + | EXCA_IOCTL_IO ## NUM ## _ZEROWAIT \ + | EXCA_IOCTL_IO ## NUM ## _IOCS16SRC_MASK \ + | EXCA_IOCTL_IO ## NUM ## _DATASIZE_MASK, \ + { \ + EXCA_IOCTL_IO ## NUM ## _IOCS16SRC_CARD, \ + EXCA_IOCTL_IO ## NUM ## _IOCS16SRC_DATASIZE \ + | EXCA_IOCTL_IO ## NUM ## _DATASIZE_8BIT, \ + EXCA_IOCTL_IO ## NUM ## _IOCS16SRC_DATASIZE \ + | EXCA_IOCTL_IO ## NUM ## _DATASIZE_16BIT, \ + } \ +} + +static struct io_map_index_st { + int start_lsb; + int start_msb; + int stop_lsb; + int stop_msb; + int ioenable; + int ioctlmask; + int ioctlbits[3]; /* indexed by PCCARD_WIDTH_* */ +} io_map_index[] = { + EXCA_IOINFO(0), + EXCA_IOINFO(1), +}; +#undef EXCA_IOINFO + +static void +exca_do_io_map(struct exca_softc *sc, int win) +{ + struct io_map_index_st *map; + + struct pccard_io_handle *io; + + map = &io_map_index[win]; + io = &sc->io[win]; + exca_write(sc, map->start_lsb, io->addr & 0xff); + exca_write(sc, map->start_msb, (io->addr >> 8) & 0xff); + + exca_write(sc, map->stop_lsb, (io->addr + io->size - 1) & 0xff); + exca_write(sc, map->stop_msb, ((io->addr + io->size - 1) >> 8) & 0xff); + + exca_clrb(sc, EXCA_IOCTL, map->ioctlmask); + exca_setb(sc, EXCA_IOCTL, map->ioctlbits[io->width]); + + exca_setb(sc, EXCA_ADDRWIN_ENABLE, map->ioenable); +#ifdef EXCA_DEBUG + { + int r1, r2, r3, r4; + r1 = exca_read(sc, map->start_msb); + r2 = exca_read(sc, map->start_lsb); + r3 = exca_read(sc, map->stop_msb); + r4 = exca_read(sc, map->stop_lsb); + DPRINTF("exca_do_io_map window %d: %02x%02x %02x%02x " + "(%08x+%08x)\n", win, r1, r2, r3, r4, + io->addr, io->size); + } +#endif +} + +int +exca_io_map(struct exca_softc *sc, int width, struct resource *r) +{ + int win; +#ifdef EXCA_DEBUG + static char *width_names[] = { "auto", "io8", "io16"}; +#endif + for (win=0; win < EXCA_IO_WINS; win++) { + if ((sc->ioalloc & (1 << win)) == 0) { + sc->ioalloc |= (1 << win); + break; + } + } + if (win >= EXCA_IO_WINS) + return (1); + + sc->io[win].iot = rman_get_bustag(r); + sc->io[win].ioh = rman_get_bushandle(r); + sc->io[win].addr = rman_get_start(r); + sc->io[win].size = rman_get_end(r) - sc->io[win].addr + 1; + sc->io[win].flags = 0; + sc->io[win].width = width; + DPRINTF("exca_io_map window %d %s port %x+%x\n", + win, width_names[width], sc->io[win].addr, + sc->io[win].size); + exca_do_io_map(sc, win); + + return (0); +} + +static void +exca_io_unmap(struct exca_softc *sc, int window) +{ + if (window >= EXCA_IO_WINS) + panic("exca_io_unmap: window out of range"); + + exca_clrb(sc, EXCA_ADDRWIN_ENABLE, io_map_index[window].ioenable); + + sc->ioalloc &= ~(1 << window); + + sc->io[window].iot = 0; + sc->io[window].ioh = 0; + sc->io[window].addr = 0; + sc->io[window].size = 0; + sc->io[window].flags = 0; + sc->io[window].width = 0; +} + +static int +exca_io_findmap(struct exca_softc *sc, struct resource *res) +{ + int win; + + for (win = 0; win < EXCA_IO_WINS; win++) { + if (sc->io[win].iot == rman_get_bustag(res) && + sc->io[win].addr == rman_get_start(res) && + sc->io[win].size == rman_get_size(res)) + return (win); + } + return (-1); +} + + +int +exca_io_unmap_res(struct exca_softc *sc, struct resource *res) +{ + int win; + + win = exca_io_findmap(sc, res); + if (win < 0) + return (ENOENT); + exca_io_unmap(sc, win); + return (0); +} + +/* Misc */ + +/* + * If interrupts are enabled, then we should be able to just wait for + * an interrupt routine to wake us up. Busy waiting shouldn't be + * necessary. Sadly, not all legacy ISA cards support an interrupt + * for the busy state transitions, at least according to their datasheets, + * so we busy wait a while here.. + */ +static void +exca_wait_ready(struct exca_softc *sc) +{ + int i; + DEVPRINTF(sc->dev, "exca_wait_ready: status 0x%02x\n", + exca_read(sc, EXCA_IF_STATUS)); + for (i = 0; i < 10000; i++) { + if (exca_read(sc, EXCA_IF_STATUS) & EXCA_IF_STATUS_READY) + return; + DELAY(500); + } + device_printf(sc->dev, "ready never happened, status = %02x\n", + exca_read(sc, EXCA_IF_STATUS)); +} + +/* + * Reset the card. Ideally, we'd do a lot of this via interrupts. + * However, many PC Cards will deassert the ready signal. This means + * that they are asserting an interrupt. This makes it hard to + * do anything but a busy wait here. One could argue that these + * such cards are broken, or that the bridge that allows this sort + * of interrupt through isn't quite what you'd want (and may be a standards + * violation). However, such arguing would leave a huge class of pc cards + * and bridges out of reach for use in the system. + * + * Maybe I should reevaluate the above based on the power bug I fixed + * in OLDCARD. + */ +void +exca_reset(struct exca_softc *sc, device_t child) +{ + int cardtype; + int win; + + /* enable socket i/o */ + exca_setb(sc, EXCA_PWRCTL, EXCA_PWRCTL_OE); + + exca_write(sc, EXCA_INTR, EXCA_INTR_ENABLE); + /* hold reset for 30ms */ + DELAY(30*1000); + /* clear the reset flag */ + exca_setb(sc, EXCA_INTR, EXCA_INTR_RESET); + /* wait 20ms as per pc card standard (r2.01) section 4.3.6 */ + DELAY(20*1000); + + exca_wait_ready(sc); + + /* disable all address windows */ + exca_write(sc, EXCA_ADDRWIN_ENABLE, 0); + + CARD_GET_TYPE(child, &cardtype); + exca_setb(sc, EXCA_INTR, (cardtype == PCCARD_IFTYPE_IO) ? + EXCA_INTR_CARDTYPE_IO : EXCA_INTR_CARDTYPE_MEM); + DEVPRINTF(sc->dev, "card type is %s\n", + (cardtype == PCCARD_IFTYPE_IO) ? "io" : "mem"); + + /* reinstall all the memory and io mappings */ + for (win = 0; win < EXCA_MEM_WINS; ++win) + if (sc->memalloc & (1 << win)) + exca_do_mem_map(sc, win); + for (win = 0; win < EXCA_IO_WINS; ++win) + if (sc->ioalloc & (1 << win)) + exca_do_io_map(sc, win); +} + +/* + * Initialize the exca_softc data structure for the first time. + */ +void +exca_init(struct exca_softc *sc, device_t dev, + bus_space_tag_t bst, bus_space_handle_t bsh, uint32_t offset) +{ + sc->dev = dev; + sc->memalloc = 0; + sc->ioalloc = 0; + sc->bst = bst; + sc->bsh = bsh; + sc->offset = offset; + sc->flags = 0; +} + +/* + * Probe the expected slots. We maybe should set the ID for each of these + * slots too while we're at it. But maybe that belongs to a separate + * function. + * + * Callers must charantee that there are at least EXCA_NSLOTS (4) in + * the array that they pass the address of the first element in the + * "exca" parameter. + */ +int +exca_probe_slots(device_t dev, struct exca_softc *exca) +{ + int rid; + struct resource *res; + int err; + bus_space_tag_t iot; + bus_space_handle_t ioh; + int i; + + err = ENXIO; + rid = 0; + res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, EXCA_IOSIZE, + RF_ACTIVE); + if (res == NULL) + return (ENXIO); + iot = rman_get_bustag(res); + ioh = rman_get_bushandle(res); + for (i = 0; i < EXCA_NSLOTS; i++) { + exca_init(&exca[i], dev, iot, ioh, i * EXCA_SOCKET_SIZE); + if (exca_is_pcic(&exca[i])) { + err = 0; + exca[i].flags |= EXCA_SOCKET_PRESENT; + } + } + bus_release_resource(dev, SYS_RES_IOPORT, rid, res); + return (err); +} + +int +exca_is_pcic(struct exca_softc *sc) +{ + /* XXX */ + return (0); +} + +static int exca_modevent(module_t mod, int cmd, void *arg) +{ + return 0; +} +DEV_MODULE(exca, exca_modevent, NULL); +MODULE_VERSION(exca, 1); diff --git a/sys/dev/pccard/exca/excareg.h b/sys/dev/pccard/exca/excareg.h new file mode 100644 index 0000000000..ffb2741040 --- /dev/null +++ b/sys/dev/pccard/exca/excareg.h @@ -0,0 +1,427 @@ +/* $NetBSD: i82365reg.h,v 1.3 1998/12/20 17:53:28 nathanw Exp $ */ +/* $FreeBSD: src/sys/dev/exca/excareg.h,v 1.2 2002/07/26 08:01:08 imp Exp $ */ +/* $DragonFly: src/sys/dev/pccard/exca/excareg.h,v 1.1 2004/02/10 07:55:47 joerg Exp $ */ + +/* + * Copyright (c) 2002 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 ``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. + * + * This software may be derived from NetBSD i82365.c and other files with + * the following copyright: + * + * 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 _SYS_DEV_EXCA_EXCAREG_H +#define _SYS_DEV_EXCA_EXCAREG_H + +/* + * All information is from the intel 82365sl PC Card Interface Controller + * (PCIC) data sheet, marked "preliminary". Order number 290423-002, January + * 1993. + */ + +#define EXCA_IOSIZE 2 + +#define EXCA_REG_INDEX 0 +#define EXCA_REG_DATA 1 + +#define EXCA_NSLOTS 4 /* 2 in 2 chips */ + +/* + * I/o ports + */ +#define EXCA_INDEX0 0x3e0 + +/* + * The PCIC allows two chips to share the same address. In order not to run + * afoul of the bsd device model, this driver will treat those chips as + * the same device. + */ + +#define EXCA_CHIP0_BASE 0x00 +#define EXCA_CHIP1_BASE 0x80 + +/* Each PCIC chip can drive two sockets */ + +#define EXCA_SOCKET_SIZE 0x40 +#define EXCA_SOCKETA_INDEX 0x00 +#define EXCA_SOCKETB_INDEX EXCA_SOCKET_SIZE + +/* general setup registers */ + +#define EXCA_IDENT 0x00 /* RO */ +#define EXCA_IDENT_IFTYPE_MASK 0xC0 +#define EXCA_IDENT_IFTYPE_IO_ONLY 0x00 +#define EXCA_IDENT_IFTYPE_MEM_ONLY 0x40 +#define EXCA_IDENT_IFTYPE_MEM_AND_IO 0x80 +#define EXCA_IDENT_IFTYPE_RESERVED 0xC0 +#define EXCA_IDENT_ZERO 0x30 +#define EXCA_IDENT_REV_MASK 0x0F +#define EXCA_IDENT_REV_I82365SLR0 0x02 +#define EXCA_IDENT_REV_I82365SLR1 0x03 + +#define EXCA_IF_STATUS 0x01 /* RO */ +#define EXCA_IF_STATUS_GPI 0x80 /* General Purpose Input */ +#define EXCA_IF_STATUS_POWERACTIVE 0x40 +#define EXCA_IF_STATUS_READY 0x20 /* really READY/!BUSY */ +#define EXCA_IF_STATUS_MEM_WP 0x10 +#define EXCA_IF_STATUS_CARDDETECT_MASK 0x0C +#define EXCA_IF_STATUS_CARDDETECT_PRESENT 0x0C +#define EXCA_IF_STATUS_BATTERY_MASK 0x03 +#define EXCA_IF_STATUS_BATTERY_DEAD1 0x00 +#define EXCA_IF_STATUS_BATTERY_DEAD2 0x01 +#define EXCA_IF_STATUS_BATTERY_WARNING 0x02 +#define EXCA_IF_STATUS_BATTERY_GOOD 0x03 + +#define EXCA_PWRCTL 0x02 /* RW */ +#define EXCA_PWRCTL_OE 0x80 /* output enable */ +#define EXCA_PWRCTL_DISABLE_RESETDRV 0x40 +#define EXCA_PWRCTL_AUTOSWITCH_ENABLE 0x20 +#define EXCA_PWRCTL_PWR_ENABLE 0x10 +#define EXCA_PWRCTL_VPP2_MASK 0x0C +/* XXX these are a little unclear from the data sheet */ +#define EXCA_PWRCTL_VPP2_RESERVED 0x0C +#define EXCA_PWRCTL_VPP2_EN1 0x08 +#define EXCA_PWRCTL_VPP2_EN0 0x04 +#define EXCA_PWRCTL_VPP2_ENX 0x00 +#define EXCA_PWRCTL_VPP1_MASK 0x03 +/* XXX these are a little unclear from the data sheet */ +#define EXCA_PWRCTL_VPP1_RESERVED 0x03 +#define EXCA_PWRCTL_VPP1_EN1 0x02 +#define EXCA_PWRCTL_VPP1_EN0 0x01 +#define EXCA_PWRCTL_VPP1_ENX 0x00 + +#define EXCA_CSC 0x04 /* RW */ +#define EXCA_CSC_ZERO 0xE0 +#define EXCA_CSC_GPI 0x10 +#define EXCA_CSC_CD 0x08 /* Card Detect Change */ +#define EXCA_CSC_READY 0x04 +#define EXCA_CSC_BATTWARN 0x02 +#define EXCA_CSC_BATTDEAD 0x01 /* for memory cards */ +#define EXCA_CSC_RI 0x01 /* for i/o cards */ + +#define EXCA_ADDRWIN_ENABLE 0x06 /* RW */ +#define EXCA_ADDRWIN_ENABLE_IO1 0x80 +#define EXCA_ADDRWIN_ENABLE_IO0 0x40 +#define EXCA_ADDRWIN_ENABLE_MEMCS16 0x20 /* rtfds if you care */ +#define EXCA_ADDRWIN_ENABLE_MEM4 0x10 +#define EXCA_ADDRWIN_ENABLE_MEM3 0x08 +#define EXCA_ADDRWIN_ENABLE_MEM2 0x04 +#define EXCA_ADDRWIN_ENABLE_MEM1 0x02 +#define EXCA_ADDRWIN_ENABLE_MEM0 0x01 + +#define EXCA_CARD_DETECT 0x16 /* RW */ +#define EXCA_CARD_DETECT_RESERVED 0xC0 +#define EXCA_CARD_DETECT_SW_INTR 0x20 +#define EXCA_CARD_DETECT_RESUME_ENABLE 0x10 +#define EXCA_CARD_DETECT_GPI_TRANSCTL 0x08 +#define EXCA_CARD_DETECT_GPI_ENABLE 0x04 +#define EXCA_CARD_DETECT_CFGRST_ENABLE 0x02 +#define EXCA_CARD_DETECT_MEMDLY_INHIBIT 0x01 + +/* interrupt registers */ + +#define EXCA_INTR 0x03 /* RW */ +#define EXCA_INTR_RI_ENABLE 0x80 +#define EXCA_INTR_RESET 0x40 /* active low (zero) */ +#define EXCA_INTR_CARDTYPE_MASK 0x20 +#define EXCA_INTR_CARDTYPE_IO 0x20 +#define EXCA_INTR_CARDTYPE_MEM 0x00 +#define EXCA_INTR_ENABLE 0x10 +#define EXCA_INTR_IRQ_MASK 0x0F +#define EXCA_INTR_IRQ_SHIFT 0 +#define EXCA_INTR_IRQ_NONE 0x00 +#define EXCA_INTR_IRQ_RESERVED1 0x01 +#define EXCA_INTR_IRQ_RESERVED2 0x02 +#define EXCA_INTR_IRQ3 0x03 +#define EXCA_INTR_IRQ4 0x04 +#define EXCA_INTR_IRQ5 0x05 +#define EXCA_INTR_IRQ_RESERVED6 0x06 +#define EXCA_INTR_IRQ7 0x07 +#define EXCA_INTR_IRQ_RESERVED8 0x08 +#define EXCA_INTR_IRQ9 0x09 +#define EXCA_INTR_IRQ10 0x0A +#define EXCA_INTR_IRQ11 0x0B +#define EXCA_INTR_IRQ12 0x0C +#define EXCA_INTR_IRQ_RESERVED13 0x0D +#define EXCA_INTR_IRQ14 0x0E +#define EXCA_INTR_IRQ15 0x0F + +#define EXCA_INTR_IRQ_VALIDMASK 0xDEB8 /* 1101 1110 1011 1000 */ + +#define EXCA_CSC_INTR 0x05 /* RW */ +#define EXCA_CSC_INTR_IRQ_MASK 0xF0 +#define EXCA_CSC_INTR_IRQ_SHIFT 4 +#define EXCA_CSC_INTR_IRQ_NONE 0x00 +#define EXCA_CSC_INTR_IRQ_RESERVED1 0x10 +#define EXCA_CSC_INTR_IRQ_RESERVED2 0x20 +#define EXCA_CSC_INTR_IRQ3 0x30 +#define EXCA_CSC_INTR_IRQ4 0x40 +#define EXCA_CSC_INTR_IRQ5 0x50 +#define EXCA_CSC_INTR_IRQ_RESERVED6 0x60 +#define EXCA_CSC_INTR_IRQ7 0x70 +#define EXCA_CSC_INTR_IRQ_RESERVED8 0x80 +#define EXCA_CSC_INTR_IRQ9 0x90 +#define EXCA_CSC_INTR_IRQ10 0xA0 +#define EXCA_CSC_INTR_IRQ11 0xB0 +#define EXCA_CSC_INTR_IRQ12 0xC0 +#define EXCA_CSC_INTR_IRQ_RESERVED13 0xD0 +#define EXCA_CSC_INTR_IRQ14 0xE0 +#define EXCA_CSC_INTR_IRQ15 0xF0 +#define EXCA_CSC_INTR_CD_ENABLE 0x08 +#define EXCA_CSC_INTR_READY_ENABLE 0x04 +#define EXCA_CSC_INTR_BATTWARN_ENABLE 0x02 +#define EXCA_CSC_INTR_BATTDEAD_ENABLE 0x01 /* for memory cards */ +#define EXCA_CSC_INTR_RI_ENABLE 0x01 /* for I/O cards */ + +#define EXCA_CSC_INTR_IRQ_VALIDMASK 0xDEB8 /* 1101 1110 1011 1000 */ + +/* I/O registers */ + +#define EXCA_IO_WINS 2 + +#define EXCA_IOCTL 0x07 /* RW */ +#define EXCA_IOCTL_IO1_WAITSTATE 0x80 +#define EXCA_IOCTL_IO1_ZEROWAIT 0x40 +#define EXCA_IOCTL_IO1_IOCS16SRC_MASK 0x20 +#define EXCA_IOCTL_IO1_IOCS16SRC_CARD 0x20 +#define EXCA_IOCTL_IO1_IOCS16SRC_DATASIZE 0x00 +#define EXCA_IOCTL_IO1_DATASIZE_MASK 0x10 +#define EXCA_IOCTL_IO1_DATASIZE_16BIT 0x10 +#define EXCA_IOCTL_IO1_DATASIZE_8BIT 0x00 +#define EXCA_IOCTL_IO0_WAITSTATE 0x08 +#define EXCA_IOCTL_IO0_ZEROWAIT 0x04 +#define EXCA_IOCTL_IO0_IOCS16SRC_MASK 0x02 +#define EXCA_IOCTL_IO0_IOCS16SRC_CARD 0x02 +#define EXCA_IOCTL_IO0_IOCS16SRC_DATASIZE 0x00 +#define EXCA_IOCTL_IO0_DATASIZE_MASK 0x01 +#define EXCA_IOCTL_IO0_DATASIZE_16BIT 0x01 +#define EXCA_IOCTL_IO0_DATASIZE_8BIT 0x00 + +#define EXCA_IOADDR0_START_LSB 0x08 +#define EXCA_IOADDR0_START_MSB 0x09 +#define EXCA_IOADDR0_STOP_LSB 0x0A +#define EXCA_IOADDR0_STOP_MSB 0x0B +#define EXCA_IOADDR1_START_LSB 0x0C +#define EXCA_IOADDR1_START_MSB 0x0D +#define EXCA_IOADDR1_STOP_LSB 0x0E +#define EXCA_IOADDR1_STOP_MSB 0x0F + +/* memory registers */ + +/* + * memory window addresses refer to bits A23-A12 of the ISA system memory + * address. This is a shift of 12 bits. The LSB contains A19-A12, and the + * MSB contains A23-A20, plus some other bits. + */ + +#define EXCA_MEM_WINS 5 + +#define EXCA_MEM_SHIFT 12 +#define EXCA_MEM_PAGESIZE (1<bst, sc->bsh, sc->offset + reg)); +} + +static __inline void +exca_write(struct exca_softc *sc, int reg, uint8_t val) +{ + return (bus_space_write_1(sc->bst, sc->bsh, sc->offset + reg, val)); +} + +static __inline void +exca_setb(struct exca_softc *sc, int reg, uint8_t mask) +{ + exca_write(sc, reg, exca_read(sc, reg) | mask); +} + +static __inline void +exca_clrb(struct exca_softc *sc, int reg, uint8_t mask) +{ + exca_write(sc, reg, exca_read(sc, reg) & ~mask); +} + +#endif /* !_SYS_DEV_EXCA_EXCAVAR_H */ diff --git a/sys/dev/pccard/pccbb/Makefile b/sys/dev/pccard/pccbb/Makefile new file mode 100644 index 0000000000..77a2131c0c --- /dev/null +++ b/sys/dev/pccard/pccbb/Makefile @@ -0,0 +1,8 @@ +# $DragonFly: src/sys/dev/pccard/pccbb/Makefile,v 1.1 2004/02/10 07:55:47 joerg Exp $ + +KMOD= cbb +SRCS= pccbb.c \ + device_if.h bus_if.h pci_if.h pcib_if.h power_if.h card_if.h +NOMAN= + +.include diff --git a/sys/dev/pccard/pccbb/pccbb.c b/sys/dev/pccard/pccbb/pccbb.c new file mode 100644 index 0000000000..dc88a13204 --- /dev/null +++ b/sys/dev/pccard/pccbb/pccbb.c @@ -0,0 +1,1977 @@ +/* + * Copyright (c) 2002 M. Warner Losh. + * Copyright (c) 2000,2001 Jonathan Chen. + * 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, + * without modification, immediately at the beginning of the file. + * 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: src/sys/dev/pccbb/pccbb.c,v 1.64 2002/11/23 23:09:45 imp Exp $ + * $DragonFly: src/sys/dev/pccard/pccbb/pccbb.c,v 1.1 2004/02/10 07:55:47 joerg Exp $ + */ + +/* + * Copyright (c) 1998, 1999 and 2000 + * HAYAKAWA Koichi. 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 HAYAKAWA Koichi. + * 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. + */ + +/* + * Driver for PCI to CardBus Bridge chips + * + * References: + * TI Datasheets: + * http://www-s.ti.com/cgi-bin/sc/generic2.cgi?family=PCI+CARDBUS+CONTROLLERS + * + * Written by Jonathan Chen + * The author would like to acknowledge: + * * HAYAKAWA Koichi: Author of the NetBSD code for the same thing + * * Warner Losh: Newbus/newcard guru and author of the pccard side of things + * * YAMAMOTO Shigeru: Author of another FreeBSD cardbus driver + * * David Cross: Author of the initial ugly hack for a specific cardbus card + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#include "power_if.h" +#include "card_if.h" +#include "pcib_if.h" + +#define DPRINTF(x) do { if (cbb_debug) printf x; } while (0) +#define DEVPRINTF(x) do { if (cbb_debug) device_printf x; } while (0) + +#define PCI_MASK_CONFIG(DEV,REG,MASK,SIZE) \ + pci_write_config(DEV, REG, pci_read_config(DEV, REG, SIZE) MASK, SIZE) +#define PCI_MASK2_CONFIG(DEV,REG,MASK1,MASK2,SIZE) \ + pci_write_config(DEV, REG, ( \ + pci_read_config(DEV, REG, SIZE) MASK1) MASK2, SIZE) + +#define CBB_START_MEM 0x88000000 +#define CBB_START_32_IO 0x1000 +#define CBB_START_16_IO 0x100 + +struct yenta_chipinfo { + uint32_t yc_id; + const char *yc_name; + int yc_chiptype; +} yc_chipsets[] = { + /* Texas Instruments chips */ + {PCIC_ID_TI1031, "TI1031 PCI-PC Card Bridge", CB_TI113X}, + {PCIC_ID_TI1130, "TI1130 PCI-CardBus Bridge", CB_TI113X}, + {PCIC_ID_TI1131, "TI1131 PCI-CardBus Bridge", CB_TI113X}, + + {PCIC_ID_TI1210, "TI1210 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1211, "TI1211 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1220, "TI1220 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1221, "TI1221 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1225, "TI1225 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1250, "TI1250 PCI-CardBus Bridge", CB_TI125X}, + {PCIC_ID_TI1251, "TI1251 PCI-CardBus Bridge", CB_TI125X}, + {PCIC_ID_TI1251B,"TI1251B PCI-CardBus Bridge",CB_TI125X}, + {PCIC_ID_TI1260, "TI1260 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1260B,"TI1260B PCI-CardBus Bridge",CB_TI12XX}, + {PCIC_ID_TI1410, "TI1410 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1420, "TI1420 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1421, "TI1421 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1450, "TI1450 PCI-CardBus Bridge", CB_TI125X}, /*SIC!*/ + {PCIC_ID_TI1451, "TI1451 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1510, "TI1510 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI1520, "TI1520 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI4410, "TI4410 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI4450, "TI4450 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI4451, "TI4451 PCI-CardBus Bridge", CB_TI12XX}, + {PCIC_ID_TI4510, "TI4510 PCI-CardBus Bridge", CB_TI12XX}, + + /* Ricoh chips */ + {PCIC_ID_RICOH_RL5C465, "RF5C465 PCI-CardBus Bridge", CB_RF5C46X}, + {PCIC_ID_RICOH_RL5C466, "RF5C466 PCI-CardBus Bridge", CB_RF5C46X}, + {PCIC_ID_RICOH_RL5C475, "RF5C475 PCI-CardBus Bridge", CB_RF5C47X}, + {PCIC_ID_RICOH_RL5C476, "RF5C476 PCI-CardBus Bridge", CB_RF5C47X}, + {PCIC_ID_RICOH_RL5C477, "RF5C477 PCI-CardBus Bridge", CB_RF5C47X}, + {PCIC_ID_RICOH_RL5C478, "RF5C478 PCI-CardBus Bridge", CB_RF5C47X}, + + /* Toshiba products */ + {PCIC_ID_TOPIC95, "ToPIC95 PCI-CardBus Bridge", CB_TOPIC95}, + {PCIC_ID_TOPIC95B, "ToPIC95B PCI-CardBus Bridge", CB_TOPIC95}, + {PCIC_ID_TOPIC97, "ToPIC97 PCI-CardBus Bridge", CB_TOPIC97}, + {PCIC_ID_TOPIC100, "ToPIC100 PCI-CardBus Bridge", CB_TOPIC97}, + + /* Cirrus Logic */ + {PCIC_ID_CLPD6832, "CLPD6832 PCI-CardBus Bridge", CB_CIRRUS}, + {PCIC_ID_CLPD6833, "CLPD6833 PCI-CardBus Bridge", CB_CIRRUS}, + {PCIC_ID_CLPD6834, "CLPD6834 PCI-CardBus Bridge", CB_CIRRUS}, + + /* 02Micro */ + {PCIC_ID_OZ6832, "O2Micro OZ6832/6833 PCI-CardBus Bridge", CB_CIRRUS}, + {PCIC_ID_OZ6860, "O2Micro OZ6836/6860 PCI-CardBus Bridge", CB_CIRRUS}, + {PCIC_ID_OZ6872, "O2Micro OZ6812/6872 PCI-CardBus Bridge", CB_CIRRUS}, + {PCIC_ID_OZ6912, "O2Micro OZ6912/6972 PCI-CardBus Bridge", CB_CIRRUS}, + {PCIC_ID_OZ6922, "O2Micro OZ6822 PCI-CardBus Bridge", CB_CIRRUS}, + {PCIC_ID_OZ6933, "O2Micro OZ6833 PCI-CardBus Bridge", CB_CIRRUS}, + + /* sentinel */ + {0 /* null id */, "unknown", CB_UNKNOWN}, +}; + +/* sysctl vars */ +SYSCTL_NODE(_hw, OID_AUTO, cbb, CTLFLAG_RD, 0, "CBB parameters"); + +/* There's no way to say TUNEABLE_LONG to get the right types */ +u_long cbb_start_mem = CBB_START_MEM; +TUNABLE_INT("hw.cbb.start_memory", (int *)&cbb_start_mem); +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_memory, CTLFLAG_RW, + &cbb_start_mem, CBB_START_MEM, + "Starting address for memory allocations"); + +u_long cbb_start_16_io = CBB_START_16_IO; +TUNABLE_INT("hw.cbb.start_16_io", (int *)&cbb_start_16_io); +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_16_io, CTLFLAG_RW, + &cbb_start_16_io, CBB_START_16_IO, + "Starting ioport for 16-bit cards"); + +u_long cbb_start_32_io = CBB_START_32_IO; +TUNABLE_INT("hw.cbb.start_32_io", (int *)&cbb_start_32_io); +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_32_io, CTLFLAG_RW, + &cbb_start_32_io, CBB_START_32_IO, + "Starting ioport for 32-bit cards"); + +int cbb_debug = 0; +TUNABLE_INT("hw.cbb.debug", &cbb_debug); +SYSCTL_ULONG(_hw_cbb, OID_AUTO, debug, CTLFLAG_RW, &cbb_debug, 0, + "Verbose cardbus bridge debugging"); + +static int cbb_chipset(uint32_t pci_id, const char **namep); +static int cbb_probe(device_t brdev); +static void cbb_chipinit(struct cbb_softc *sc); +static int cbb_attach(device_t brdev); +static int cbb_detach(device_t brdev); +static int cbb_shutdown(device_t brdev); +static void cbb_driver_added(device_t brdev, driver_t *driver); +static void cbb_child_detached(device_t brdev, device_t child); +static void cbb_event_thread(void *arg); +static void cbb_insert(struct cbb_softc *sc); +static void cbb_removal(struct cbb_softc *sc); +static void cbb_intr(void *arg); +static int cbb_detect_voltage(device_t brdev); +static int cbb_power(device_t brdev, int volts); +static void cbb_cardbus_reset(device_t brdev); +static int cbb_cardbus_power_enable_socket(device_t brdev, + device_t child); +static void cbb_cardbus_power_disable_socket(device_t brdev, + device_t child); +static int cbb_cardbus_io_open(device_t brdev, int win, uint32_t start, + uint32_t end); +static int cbb_cardbus_mem_open(device_t brdev, int win, + uint32_t start, uint32_t end); +static void cbb_cardbus_auto_open(struct cbb_softc *sc, int type); +static int cbb_cardbus_activate_resource(device_t brdev, device_t child, + int type, int rid, struct resource *res); +static int cbb_cardbus_deactivate_resource(device_t brdev, + device_t child, int type, int rid, struct resource *res); +static struct resource *cbb_cardbus_alloc_resource(device_t brdev, + device_t child, int type, int *rid, u_long start, + u_long end, u_long count, uint flags); +static int cbb_cardbus_release_resource(device_t brdev, device_t child, + int type, int rid, struct resource *res); +static int cbb_power_enable_socket(device_t brdev, device_t child); +static void cbb_power_disable_socket(device_t brdev, device_t child); +static int cbb_activate_resource(device_t brdev, device_t child, + int type, int rid, struct resource *r); +static int cbb_deactivate_resource(device_t brdev, device_t child, + int type, int rid, struct resource *r); +static struct resource *cbb_alloc_resource(device_t brdev, device_t child, + int type, int *rid, u_long start, u_long end, u_long count, + uint flags); +static int cbb_release_resource(device_t brdev, device_t child, + int type, int rid, struct resource *r); +static int cbb_read_ivar(device_t brdev, device_t child, int which, + uintptr_t *result); +static int cbb_write_ivar(device_t brdev, device_t child, int which, + uintptr_t value); +static int cbb_maxslots(device_t brdev); +static uint32_t cbb_read_config(device_t brdev, int b, int s, int f, + int reg, int width); +static void cbb_write_config(device_t brdev, int b, int s, int f, + int reg, uint32_t val, int width); + +/* + */ +static __inline void +cbb_set(struct cbb_softc *sc, uint32_t reg, uint32_t val) +{ + bus_space_write_4(sc->bst, sc->bsh, reg, val); +} + +static __inline uint32_t +cbb_get(struct cbb_softc *sc, uint32_t reg) +{ + return (bus_space_read_4(sc->bst, sc->bsh, reg)); +} + +static __inline void +cbb_setb(struct cbb_softc *sc, uint32_t reg, uint32_t bits) +{ + cbb_set(sc, reg, cbb_get(sc, reg) | bits); +} + +static __inline void +cbb_clrb(struct cbb_softc *sc, uint32_t reg, uint32_t bits) +{ + cbb_set(sc, reg, cbb_get(sc, reg) & ~bits); +} + +static void +cbb_remove_res(struct cbb_softc *sc, struct resource *res) +{ + struct cbb_reslist *rle; + + SLIST_FOREACH(rle, &sc->rl, link) { + if (rle->res == res) { + SLIST_REMOVE(&sc->rl, rle, cbb_reslist, link); + free(rle, M_DEVBUF); + return; + } + } +} + +static struct resource * +cbb_find_res(struct cbb_softc *sc, int type, int rid) +{ + struct cbb_reslist *rle; + + SLIST_FOREACH(rle, &sc->rl, link) + if (SYS_RES_MEMORY == rle->type && rid == rle->rid) + return (rle->res); + return (NULL); +} + +static void +cbb_insert_res(struct cbb_softc *sc, struct resource *res, int type, + int rid) +{ + struct cbb_reslist *rle; + + /* + * Need to record allocated resource so we can iterate through + * it later. + */ + rle = malloc(sizeof(struct cbb_reslist), M_DEVBUF, M_NOWAIT); + if (!res) + panic("cbb_cardbus_alloc_resource: can't record entry!"); + rle->res = res; + rle->type = type; + rle->rid = rid; + SLIST_INSERT_HEAD(&sc->rl, rle, link); +} + +static void +cbb_destroy_res(struct cbb_softc *sc) +{ + struct cbb_reslist *rle; + + while ((rle = SLIST_FIRST(&sc->rl)) != NULL) { + device_printf(sc->dev, "Danger Will Robinson: Resource " + "left allocated! This is a bug... " + "(rid=%x, type=%d, addr=%lx)\n", rle->rid, rle->type, + rman_get_start(rle->res)); + SLIST_REMOVE_HEAD(&sc->rl, link); + free(rle, M_DEVBUF); + } +} + +/************************************************************************/ +/* Probe/Attach */ +/************************************************************************/ + +static int +cbb_chipset(uint32_t pci_id, const char **namep) +{ + struct yenta_chipinfo *ycp; + + for (ycp = yc_chipsets; ycp->yc_id != 0 && pci_id != ycp->yc_id; ++ycp) + continue; + if (namep != NULL) + *namep = ycp->yc_name; + return (ycp->yc_chiptype); +} + +static int +cbb_probe(device_t brdev) +{ + const char *name; + uint32_t progif; + uint32_t subclass; + + /* + * Do we know that we support the chipset? If so, then we + * accept the device. + */ + if (cbb_chipset(pci_get_devid(brdev), &name) != CB_UNKNOWN) { + device_set_desc(brdev, name); + return (0); + } + + /* + * We do support generic CardBus bridges. All that we've seen + * to date have progif 0 (the Yenta spec, and successors mandate + * this). We do not support PCI PCMCIA bridges (with one exception) + * with this driver since they generally are I/O mapped. Those + * are supported by the pcic driver. This should help us be more + * future proof. + */ + subclass = pci_get_subclass(brdev); + progif = pci_get_progif(brdev); + if (subclass == PCIS_BRIDGE_CARDBUS && progif == 0) { + device_set_desc(brdev, "PCI-CardBus Bridge"); + return (0); + } + return (ENXIO); +} + + +static void +cbb_chipinit(struct cbb_softc *sc) +{ + uint32_t mux, sysctrl; + + /* Set CardBus latency timer */ + if (pci_read_config(sc->dev, PCIR_SECLAT_1, 1) < 0x20) + pci_write_config(sc->dev, PCIR_SECLAT_1, 0x20, 1); + + /* Set PCI latency timer */ + if (pci_read_config(sc->dev, PCIR_LATTIMER, 1) < 0x20) + pci_write_config(sc->dev, PCIR_LATTIMER, 0x20, 1); + + /* Enable memory access */ + PCI_MASK_CONFIG(sc->dev, PCIR_COMMAND, + | PCIM_CMD_MEMEN + | PCIM_CMD_PORTEN + | PCIM_CMD_BUSMASTEREN, 2); + + /* disable Legacy IO */ + switch (sc->chipset) { + case CB_RF5C46X: + PCI_MASK_CONFIG(sc->dev, CBBR_BRIDGECTRL, + & ~(CBBM_BRIDGECTRL_RL_3E0_EN | + CBBM_BRIDGECTRL_RL_3E2_EN), 2); + break; + default: + pci_write_config(sc->dev, CBBR_LEGACY, 0x0, 4); + break; + } + + /* Use PCI interrupt for interrupt routing */ + PCI_MASK2_CONFIG(sc->dev, CBBR_BRIDGECTRL, + & ~(CBBM_BRIDGECTRL_MASTER_ABORT | + CBBM_BRIDGECTRL_INTR_IREQ_EN), + | CBBM_BRIDGECTRL_WRITE_POST_EN, + 2); + + /* + * XXX this should be a function table, ala OLDCARD. This means + * that we could more easily support ISA interrupts for pccard + * cards if we had to. + */ + switch (sc->chipset) { + case CB_TI113X: + /* + * The TI 1031, TI 1130 and TI 1131 all require another bit + * be set to enable PCI routing of interrupts, and then + * a bit for each of the CSC and Function interrupts we + * want routed. + */ + PCI_MASK_CONFIG(sc->dev, CBBR_CBCTRL, + | CBBM_CBCTRL_113X_PCI_INTR | + CBBM_CBCTRL_113X_PCI_CSC | CBBM_CBCTRL_113X_PCI_IRQ_EN, + 1); + PCI_MASK_CONFIG(sc->dev, CBBR_DEVCTRL, + & ~(CBBM_DEVCTRL_INT_SERIAL | + CBBM_DEVCTRL_INT_PCI), 1); + break; + case CB_TI12XX: + /* + * Some TI 12xx (and [14][45]xx) based pci cards + * sometimes have issues with the MFUNC register not + * being initialized due to a bad EEPROM on board. + * Laptops that this matters on have this register + * properly initialized. + * + * The TI125X parts have a different register. + */ + mux = pci_read_config(sc->dev, CBBR_MFUNC, 4); + sysctrl = pci_read_config(sc->dev, CBBR_SYSCTRL, 4); + if (mux == 0) { + mux = (mux & ~CBBM_MFUNC_PIN0) | + CBBM_MFUNC_PIN0_INTA; + if ((sysctrl & CBBM_SYSCTRL_INTRTIE) == 0) + mux = (mux & ~CBBM_MFUNC_PIN1) | + CBBM_MFUNC_PIN1_INTB; + pci_write_config(sc->dev, CBBR_MFUNC, mux, 4); + } + /*FALLTHROUGH*/ + case CB_TI125X: + /* + * Disable zoom video. Some machines initialize this + * improperly and exerpience has shown that this helps + * on some machines. + */ + pci_write_config(sc->dev, CBBR_MMCTRL, 0, 4); + break; + case CB_TOPIC97: + /* + * Disable Zoom Video, ToPIC 97, 100. + */ + pci_write_config(sc->dev, CBBR_TOPIC_ZV_CONTROL, 0, 1); + /* + * ToPIC 97, 100 + * At offset 0xa1: INTERRUPT CONTROL register + * 0x1: Turn on INT interrupts. + */ + PCI_MASK_CONFIG(sc->dev, CBBR_TOPIC_INTCTRL, + | CBBM_TOPIC_INTCTRL_INTIRQSEL, 1); + goto topic_common; + case CB_TOPIC95: + /* + * SOCKETCTRL appears to be TOPIC 95/B specific + */ + PCI_MASK_CONFIG(sc->dev, CBBR_TOPIC_SOCKETCTRL, + | CBBM_TOPIC_SOCKETCTRL_SCR_IRQSEL, 4); + + topic_common:; + /* + * At offset 0xa0: SLOT CONTROL + * 0x80 Enable CardBus Functionality + * 0x40 Enable CardBus and PC Card registers + * 0x20 Lock ID in exca regs + * 0x10 Write protect ID in config regs + * Clear the rest of the bits, which defaults the slot + * in legacy mode to 0x3e0 and offset 0. (legacy + * mode is determined elsewhere) + */ + pci_write_config(sc->dev, CBBR_TOPIC_SLOTCTRL, + CBBM_TOPIC_SLOTCTRL_SLOTON | + CBBM_TOPIC_SLOTCTRL_SLOTEN | + CBBM_TOPIC_SLOTCTRL_ID_LOCK | + CBBM_TOPIC_SLOTCTRL_ID_WP, 1); + + /* + * At offset 0xa3 Card Detect Control Register + * 0x80 CARDBUS enbale + * 0x01 Cleared for hardware change detect + */ + PCI_MASK2_CONFIG(sc->dev, CBBR_TOPIC_CDC, + | CBBM_TOPIC_CDC_CARDBUS, + & ~CBBM_TOPIC_CDC_SWDETECT, 4); + break; + } + + /* + * Need to tell ExCA registers to route via PCI interrupts. There + * are two ways to do this. Once is to set INTR_ENABLE and the + * other is to set CSC to 0. Since both methods are mutually + * compatible, we do both. + */ + exca_write(&sc->exca, EXCA_INTR, EXCA_INTR_ENABLE); + exca_write(&sc->exca, EXCA_CSC_INTR, 0); + + /* close all memory and io windows */ + pci_write_config(sc->dev, CBBR_MEMBASE0, 0xffffffff, 4); + pci_write_config(sc->dev, CBBR_MEMLIMIT0, 0, 4); + pci_write_config(sc->dev, CBBR_MEMBASE1, 0xffffffff, 4); + pci_write_config(sc->dev, CBBR_MEMLIMIT1, 0, 4); + pci_write_config(sc->dev, CBBR_IOBASE0, 0xffffffff, 4); + pci_write_config(sc->dev, CBBR_IOLIMIT0, 0, 4); + pci_write_config(sc->dev, CBBR_IOBASE1, 0xffffffff, 4); + pci_write_config(sc->dev, CBBR_IOLIMIT1, 0, 4); +} + +static int +cbb_attach(device_t brdev) +{ + struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev); + int rid; + + lockinit(&sc->lock, 0, "cbb", 0, 0); + sc->chipset = cbb_chipset(pci_get_devid(brdev), NULL); + sc->dev = brdev; + sc->cbdev = NULL; + sc->pccarddev = NULL; + sc->secbus = pci_read_config(brdev, PCIR_SECBUS_2, 1); + sc->subbus = pci_read_config(brdev, PCIR_SUBBUS_2, 1); + SLIST_INIT(&sc->rl); + STAILQ_INIT(&sc->intr_handlers); + +#ifndef BURN_THE_BOATS + /* + * The PCI bus code should assign us memory in the absense + * of the BIOS doing so. However, 'should' isn't 'is,' so we kludge + * up something here until the PCI/acpi code properly assigns the + * resource. + */ +#endif + rid = CBBR_SOCKBASE; + sc->base_res = bus_alloc_resource(brdev, SYS_RES_MEMORY, &rid, + 0, ~0, 1, RF_ACTIVE); + if (!sc->base_res) { +#ifdef BURN_THE_BOATS + device_printf(brdev, "Could not map register memory\n"); + return (ENOMEM); +#else + uint32_t sockbase; + /* + * Generally, the BIOS will assign this memory for us. + * However, newer BIOSes do not because the MS design + * documents have mandated that this is for the OS + * to assign rather than the BIOS. This driver shouldn't + * be doing this, but until the pci bus code (or acpi) + * does this, we allow CardBus bridges to work on more + * machines. + */ + sockbase = pci_read_config(brdev, rid, 4); + if (sockbase < 0x100000 || sockbase >= 0xfffffff0) { + pci_write_config(brdev, rid, 0xffffffff, 4); + sockbase = pci_read_config(brdev, rid, 4); + sockbase = (sockbase & 0xfffffff0) & + -(sockbase & 0xfffffff0); + sc->base_res = bus_generic_alloc_resource( + device_get_parent(brdev), brdev, SYS_RES_MEMORY, + &rid, cbb_start_mem, ~0, sockbase, + RF_ACTIVE|rman_make_alignment_flags(sockbase)); + if (!sc->base_res) { + device_printf(brdev, + "Could not grab register memory\n"); + return (ENOMEM); + } + sc->flags |= CBB_KLUDGE_ALLOC; + pci_write_config(brdev, CBBR_SOCKBASE, + rman_get_start(sc->base_res), 4); + DEVPRINTF((brdev, "PCI Memory allocated: %08lx\n", + rman_get_start(sc->base_res))); + } else { + device_printf(brdev, "Could not map register memory\n"); + goto err; + } +#endif + } + + sc->bst = rman_get_bustag(sc->base_res); + sc->bsh = rman_get_bushandle(sc->base_res); + exca_init(&sc->exca, brdev, sc->bst, sc->bsh, CBB_EXCA_OFFSET); + sc->exca.flags |= EXCA_HAS_MEMREG_WIN; + cbb_chipinit(sc); + + /* attach children */ + sc->cbdev = device_add_child(brdev, "cardbus", -1); + if (sc->cbdev == NULL) + DEVPRINTF((brdev, "WARNING: cannot add cardbus bus.\n")); + else if (device_probe_and_attach(sc->cbdev) != 0) { + DEVPRINTF((brdev, "WARNING: cannot attach cardbus bus!\n")); + sc->cbdev = NULL; + } + + sc->pccarddev = device_add_child(brdev, "pccard", -1); + if (sc->pccarddev == NULL) + DEVPRINTF((brdev, "WARNING: cannot add pccard bus.\n")); + else if (device_probe_and_attach(sc->pccarddev) != 0) { + DEVPRINTF((brdev, "WARNING: cannot attach pccard bus.\n")); + sc->pccarddev = NULL; + } + + /* Map and establish the interrupt. */ + rid = 0; + sc->irq_res = bus_alloc_resource(brdev, SYS_RES_IRQ, &rid, 0, ~0, 1, + RF_SHAREABLE | RF_ACTIVE); + if (sc->irq_res == NULL) { + printf("cbb: Unable to map IRQ...\n"); + goto err; + return (ENOMEM); + } + + if (bus_setup_intr(brdev, sc->irq_res, INTR_TYPE_AV, cbb_intr, sc, + &sc->intrhand)) { + device_printf(brdev, "couldn't establish interrupt"); + goto err; + } + + /* reset 16-bit pcmcia bus */ + exca_clrb(&sc->exca, EXCA_INTR, EXCA_INTR_RESET); + + /* turn off power */ + cbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); + + /* CSC Interrupt: Card detect interrupt on */ + cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD); + + /* reset interrupt */ + cbb_set(sc, CBB_SOCKET_EVENT, cbb_get(sc, CBB_SOCKET_EVENT)); + + /* Start the thread */ + if (kthread_create(cbb_event_thread, sc, &sc->event_thread, + "%s%d", device_get_name(sc->dev), device_get_unit(sc->dev))) { + device_printf (sc->dev, "unable to create event thread.\n"); + panic ("cbb_create_event_thread"); + } + + return (0); +err: + if (sc->irq_res) + bus_release_resource(brdev, SYS_RES_IRQ, 0, sc->irq_res); + if (sc->base_res) { + if (sc->flags & CBB_KLUDGE_ALLOC) + bus_generic_release_resource(device_get_parent(brdev), + brdev, SYS_RES_MEMORY, CBBR_SOCKBASE, + sc->base_res); + else + bus_release_resource(brdev, SYS_RES_MEMORY, + CBBR_SOCKBASE, sc->base_res); + } + return (ENOMEM); +} + +static int +cbb_detach(device_t brdev) +{ + struct cbb_softc *sc = device_get_softc(brdev); + int numdevs; + device_t *devlist; + int tmp; + int error; + + device_get_children(brdev, &devlist, &numdevs); + + error = 0; + for (tmp = 0; tmp < numdevs; tmp++) { + if (device_detach(devlist[tmp]) == 0) + device_delete_child(brdev, devlist[tmp]); + else + error++; + } + free(devlist, M_TEMP); + if (error > 0) + return (ENXIO); + + lockmgr(&sc->lock, LK_EXCLUSIVE, 0, curthread); + bus_teardown_intr(brdev, sc->irq_res, sc->intrhand); + sc->flags |= CBB_KTHREAD_DONE; + if (sc->flags & CBB_KTHREAD_RUNNING) { + wakeup(sc); + tsleep(sc, 0, "pccbb", 0); + } + lockmgr(&sc->lock, LK_RELEASE, 0, curthread); + + bus_release_resource(brdev, SYS_RES_IRQ, 0, sc->irq_res); + if (sc->flags & CBB_KLUDGE_ALLOC) + bus_generic_release_resource(device_get_parent(brdev), + brdev, SYS_RES_MEMORY, CBBR_SOCKBASE, + sc->base_res); + else + bus_release_resource(brdev, SYS_RES_MEMORY, + CBBR_SOCKBASE, sc->base_res); + return (0); +} + +static int +cbb_shutdown(device_t brdev) +{ + struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev); + /* properly reset everything at shutdown */ + + PCI_MASK_CONFIG(brdev, CBBR_BRIDGECTRL, |CBBM_BRIDGECTRL_RESET, 2); + exca_clrb(&sc->exca, EXCA_INTR, EXCA_INTR_RESET); + + cbb_set(sc, CBB_SOCKET_MASK, 0); + + cbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); + + exca_write(&sc->exca, EXCA_ADDRWIN_ENABLE, 0); + pci_write_config(brdev, CBBR_MEMBASE0, 0, 4); + pci_write_config(brdev, CBBR_MEMLIMIT0, 0, 4); + pci_write_config(brdev, CBBR_MEMBASE1, 0, 4); + pci_write_config(brdev, CBBR_MEMLIMIT1, 0, 4); + pci_write_config(brdev, CBBR_IOBASE0, 0, 4); + pci_write_config(brdev, CBBR_IOLIMIT0, 0, 4); + pci_write_config(brdev, CBBR_IOBASE1, 0, 4); + pci_write_config(brdev, CBBR_IOLIMIT1, 0, 4); + pci_write_config(brdev, PCIR_COMMAND, 0, 2); + return (0); +} + +static int +cbb_setup_intr(device_t dev, device_t child, struct resource *irq, + int flags, driver_intr_t *intr, void *arg, void **cookiep) +{ + struct cbb_intrhand *ih; + struct cbb_softc *sc = device_get_softc(dev); + + /* + * You aren't allowed to have fast interrupts for pccard/cardbus + * things since those interrupts are PCI and shared. Since we use + * the PCI interrupt for the status change interrupts, it can't be + * free for use by the driver. Fast interrupts must not be shared. + */ + ih = malloc(sizeof(struct cbb_intrhand), M_DEVBUF, M_NOWAIT); + if (ih == NULL) + return (ENOMEM); + *cookiep = ih; + ih->intr = intr; + ih->arg = arg; + STAILQ_INSERT_TAIL(&sc->intr_handlers, ih, entries); + /* + * XXX we should do what old card does to ensure that we don't + * XXX call the function's interrupt routine(s). + */ + /* + * XXX need to turn on ISA interrupts, if we ever support them, but + * XXX for now that's all we need to do. + */ + return (0); +} + +static int +cbb_teardown_intr(device_t dev, device_t child, struct resource *irq, + void *cookie) +{ + struct cbb_intrhand *ih; + struct cbb_softc *sc = device_get_softc(dev); + + /* XXX Need to do different things for ISA interrupts. */ + ih = (struct cbb_intrhand *) cookie; + STAILQ_REMOVE(&sc->intr_handlers, ih, cbb_intrhand, entries); + free(ih, M_DEVBUF); + return (0); +} + + +static void +cbb_driver_added(device_t brdev, driver_t *driver) +{ + struct cbb_softc *sc = device_get_softc(brdev); + device_t *devlist; + int tmp; + int numdevs; + int wake; + uint32_t sockstate; + + DEVICE_IDENTIFY(driver, brdev); + device_get_children(brdev, &devlist, &numdevs); + wake = 0; + sockstate = cbb_get(sc, CBB_SOCKET_STATE); + for (tmp = 0; tmp < numdevs; tmp++) { + if (device_get_state(devlist[tmp]) == DS_NOTPRESENT && + device_probe_and_attach(devlist[tmp]) == 0) { + if (devlist[tmp] == NULL) + /* NOTHING */; + else if (strcmp(driver->name, "cardbus") == 0) { + sc->cbdev = devlist[tmp]; + if (((sockstate & CBB_SOCKET_STAT_CD) == 0) && + (sockstate & CBB_SOCKET_STAT_CB)) + wake++; + } else if (strcmp(driver->name, "pccard") == 0) { + sc->pccarddev = devlist[tmp]; + if (((sockstate & CBB_SOCKET_STAT_CD) == 0) && + (sockstate & CBB_SOCKET_STAT_16BIT)) + wake++; + } else + device_printf(brdev, + "Unsupported child bus: %s\n", + driver->name); + } + } + free(devlist, M_TEMP); + + if (wake > 0) { + if ((cbb_get(sc, CBB_SOCKET_STATE) & CBB_SOCKET_STAT_CD) + == 0) { + wakeup(sc); + } + } +} + +static void +cbb_child_detached(device_t brdev, device_t child) +{ + struct cbb_softc *sc = device_get_softc(brdev); + + if (child == sc->cbdev) + sc->cbdev = NULL; + else if (child == sc->pccarddev) + sc->pccarddev = NULL; + else + device_printf(brdev, "Unknown child detached: %s %p/%p\n", + device_get_nameunit(child), sc->cbdev, sc->pccarddev); +} + +/************************************************************************/ +/* Kthreads */ +/************************************************************************/ + +static void +cbb_event_thread(void *arg) +{ + struct cbb_softc *sc = arg; + uint32_t status; + int err; + + /* + * We take out Giant here because we need it deep, down in + * the bowels of the vm system for mapping the memory we need + * to read the CIS. We also need it for kthread_exit, which + * drops it. + */ + sc->flags |= CBB_KTHREAD_RUNNING; + while (1) { + /* + * Check to see if we have anything first so that + * if there's a card already inserted, we do the + * right thing. + */ + lockmgr(&sc->lock, LK_EXCLUSIVE, 0, curthread); + if (sc->flags & CBB_KTHREAD_DONE) + break; + + status = cbb_get(sc, CBB_SOCKET_STATE); + /* mtx_lock(&Giant); */ + if ((status & CBB_SOCKET_STAT_CD) == 0) + cbb_insert(sc); + else + cbb_removal(sc); + lockmgr(&sc->lock, LK_RELEASE, 0, curthread); + /* mtx_unlock(&Giant); */ + + /* + * Wait until it has been 1s since the last time we + * get an interrupt. We handle the rest of the interrupt + * at the top of the loop. + */ + err = tsleep(sc, 0, "pccbb", 0); + while (err != EWOULDBLOCK && + (sc->flags & CBB_KTHREAD_DONE) == 0) + err = tsleep(sc, 0, "pccbb", 1 * hz); + } + lockmgr(&sc->lock, LK_RELEASE, 0, curthread); + sc->flags &= ~CBB_KTHREAD_RUNNING; + /* mtx_lock(&Giant); */ + kthread_exit(); +} + +/************************************************************************/ +/* Insert/removal */ +/************************************************************************/ + +static void +cbb_insert(struct cbb_softc *sc) +{ + uint32_t sockevent, sockstate; + + sockevent = cbb_get(sc, CBB_SOCKET_EVENT); + sockstate = cbb_get(sc, CBB_SOCKET_STATE); + + DEVPRINTF((sc->dev, "card inserted: event=0x%08x, state=%08x\n", + sockevent, sockstate)); + + if (sockstate & CBB_SOCKET_STAT_16BIT) { + if (sc->pccarddev != NULL) { + sc->flags |= CBB_16BIT_CARD; + sc->flags |= CBB_CARD_OK; + if (CARD_ATTACH_CARD(sc->pccarddev) != 0) { + device_printf(sc->dev, + "PC Card card activation failed\n"); + sc->flags &= ~CBB_CARD_OK; + } + } else { + device_printf(sc->dev, + "PC Card inserted, but no pccard bus.\n"); + } + } else if (sockstate & CBB_SOCKET_STAT_CB) { + if (sc->cbdev != NULL) { + sc->flags &= ~CBB_16BIT_CARD; + sc->flags |= CBB_CARD_OK; + if (CARD_ATTACH_CARD(sc->cbdev) != 0) { + device_printf(sc->dev, + "CardBus card activation failed\n"); + sc->flags &= ~CBB_CARD_OK; + } + } else { + device_printf(sc->dev, + "CardBus card inserted, but no cardbus bus.\n"); + } + } else { + /* + * We should power the card down, and try again a couple of + * times if this happens. XXX + */ + device_printf (sc->dev, "Unsupported card type detected\n"); + } +} + +static void +cbb_removal(struct cbb_softc *sc) +{ + if (sc->flags & CBB_16BIT_CARD) { + if (sc->pccarddev != NULL) + CARD_DETACH_CARD(sc->pccarddev); + } else { + if (sc->cbdev != NULL) + CARD_DETACH_CARD(sc->cbdev); + } + cbb_destroy_res(sc); +} + +/************************************************************************/ +/* Interrupt Handler */ +/************************************************************************/ + +static void +cbb_intr(void *arg) +{ + struct cbb_softc *sc = arg; + uint32_t sockevent; + struct cbb_intrhand *ih; + + /* + * This ISR needs work XXX + */ + sockevent = cbb_get(sc, CBB_SOCKET_EVENT); + if (sockevent) { + /* ack the interrupt */ + cbb_setb(sc, CBB_SOCKET_EVENT, sockevent); + + /* + * If anything has happened to the socket, we assume that + * the card is no longer OK, and we shouldn't call its + * ISR. We set CARD_OK as soon as we've attached the + * card. This helps in a noisy eject, which happens + * all too often when users are ejecting their PC Cards. + * + * We use this method in preference to checking to see if + * the card is still there because the check suffers from + * a race condition in the bouncing case. Prior versions + * of the pccard software used a similar trick and achieved + * excellent results. + */ + if (sockevent & CBB_SOCKET_EVENT_CD) { + lockmgr(&sc->lock, LK_EXCLUSIVE, 0, curthread); + sc->flags &= ~CBB_CARD_OK; + lockmgr(&sc->lock, LK_RELEASE, 0, curthread); + wakeup(sc); + } + if (sockevent & CBB_SOCKET_EVENT_CSTS) { + DPRINTF((" cstsevent occured: 0x%08x\n", + cbb_get(sc, CBB_SOCKET_STATE))); + } + if (sockevent & CBB_SOCKET_EVENT_POWER) { + DPRINTF((" pwrevent occured: 0x%08x\n", + cbb_get(sc, CBB_SOCKET_STATE))); + } + /* Other bits? */ + } + if (sc->flags & CBB_CARD_OK) { + STAILQ_FOREACH(ih, &sc->intr_handlers, entries) { + (*ih->intr)(ih->arg); + } + + } +} + +/************************************************************************/ +/* Generic Power functions */ +/************************************************************************/ + +static int +cbb_detect_voltage(device_t brdev) +{ + struct cbb_softc *sc = device_get_softc(brdev); + uint32_t psr; + int vol = CARD_UKN_CARD; + + psr = cbb_get(sc, CBB_SOCKET_STATE); + + if (psr & CBB_SOCKET_STAT_5VCARD) + vol |= CARD_5V_CARD; + if (psr & CBB_SOCKET_STAT_3VCARD) + vol |= CARD_3V_CARD; + if (psr & CBB_SOCKET_STAT_XVCARD) + vol |= CARD_XV_CARD; + if (psr & CBB_SOCKET_STAT_YVCARD) + vol |= CARD_YV_CARD; + + return (vol); +} + +static int +cbb_power(device_t brdev, int volts) +{ + uint32_t status, sock_ctrl; + struct cbb_softc *sc = device_get_softc(brdev); + int timeout; + uint32_t sockevent; + + DEVPRINTF((sc->dev, "cbb_power: %s and %s [%x]\n", + (volts & CARD_VCCMASK) == CARD_VCC_UC ? "CARD_VCC_UC" : + (volts & CARD_VCCMASK) == CARD_VCC_5V ? "CARD_VCC_5V" : + (volts & CARD_VCCMASK) == CARD_VCC_3V ? "CARD_VCC_3V" : + (volts & CARD_VCCMASK) == CARD_VCC_XV ? "CARD_VCC_XV" : + (volts & CARD_VCCMASK) == CARD_VCC_YV ? "CARD_VCC_YV" : + (volts & CARD_VCCMASK) == CARD_VCC_0V ? "CARD_VCC_0V" : + "VCC-UNKNOWN", + (volts & CARD_VPPMASK) == CARD_VPP_UC ? "CARD_VPP_UC" : + (volts & CARD_VPPMASK) == CARD_VPP_12V ? "CARD_VPP_12V" : + (volts & CARD_VPPMASK) == CARD_VPP_VCC ? "CARD_VPP_VCC" : + (volts & CARD_VPPMASK) == CARD_VPP_0V ? "CARD_VPP_0V" : + "VPP-UNKNOWN", + volts)); + + status = cbb_get(sc, CBB_SOCKET_STATE); + sock_ctrl = cbb_get(sc, CBB_SOCKET_CONTROL); + + switch (volts & CARD_VCCMASK) { + case CARD_VCC_UC: + break; + case CARD_VCC_5V: + if (CBB_SOCKET_STAT_5VCARD & status) { /* check 5 V card */ + sock_ctrl &= ~CBB_SOCKET_CTRL_VCCMASK; + sock_ctrl |= CBB_SOCKET_CTRL_VCC_5V; + } else { + device_printf(sc->dev, + "BAD voltage request: no 5 V card\n"); + } + break; + case CARD_VCC_3V: + if (CBB_SOCKET_STAT_3VCARD & status) { + sock_ctrl &= ~CBB_SOCKET_CTRL_VCCMASK; + sock_ctrl |= CBB_SOCKET_CTRL_VCC_3V; + } else { + device_printf(sc->dev, + "BAD voltage request: no 3.3 V card\n"); + } + break; + case CARD_VCC_0V: + sock_ctrl &= ~CBB_SOCKET_CTRL_VCCMASK; + break; + default: + return (0); /* power NEVER changed */ + break; + } + + switch (volts & CARD_VPPMASK) { + case CARD_VPP_UC: + break; + case CARD_VPP_0V: + sock_ctrl &= ~CBB_SOCKET_CTRL_VPPMASK; + break; + case CARD_VPP_VCC: + sock_ctrl &= ~CBB_SOCKET_CTRL_VPPMASK; + sock_ctrl |= ((sock_ctrl >> 4) & 0x07); + break; + case CARD_VPP_12V: + sock_ctrl &= ~CBB_SOCKET_CTRL_VPPMASK; + sock_ctrl |= CBB_SOCKET_CTRL_VPP_12V; + break; + } + + if (cbb_get(sc, CBB_SOCKET_CONTROL) == sock_ctrl) + return (1); /* no change necessary */ + + cbb_set(sc, CBB_SOCKET_CONTROL, sock_ctrl); + status = cbb_get(sc, CBB_SOCKET_STATE); + + /* + * XXX This busy wait is bogus. We should wait for a power + * interrupt and then whine if the status is bad. If we're + * worried about the card not coming up, then we should also + * schedule a timeout which we can cacel in the power interrupt. + */ + timeout = 20; + do { + DELAY(20*1000); + sockevent = cbb_get(sc, CBB_SOCKET_EVENT); + } while (!(sockevent & CBB_SOCKET_EVENT_POWER) && --timeout > 0); + /* reset event status */ + /* XXX should only reset EVENT_POWER */ + cbb_set(sc, CBB_SOCKET_EVENT, sockevent); + if (timeout < 0) { + printf ("VCC supply failed.\n"); + return (0); + } + + /* XXX + * delay 400 ms: thgough the standard defines that the Vcc set-up time + * is 20 ms, some PC-Card bridge requires longer duration. + * XXX Note: We should check the stutus AFTER the delay to give time + * for things to stabilize. + */ + DELAY(400*1000); + + if (status & CBB_SOCKET_STAT_BADVCC) { + device_printf(sc->dev, + "bad Vcc request. ctrl=0x%x, status=0x%x\n", + sock_ctrl ,status); + printf("cbb_power: %s and %s [%x]\n", + (volts & CARD_VCCMASK) == CARD_VCC_UC ? "CARD_VCC_UC" : + (volts & CARD_VCCMASK) == CARD_VCC_5V ? "CARD_VCC_5V" : + (volts & CARD_VCCMASK) == CARD_VCC_3V ? "CARD_VCC_3V" : + (volts & CARD_VCCMASK) == CARD_VCC_XV ? "CARD_VCC_XV" : + (volts & CARD_VCCMASK) == CARD_VCC_YV ? "CARD_VCC_YV" : + (volts & CARD_VCCMASK) == CARD_VCC_0V ? "CARD_VCC_0V" : + "VCC-UNKNOWN", + (volts & CARD_VPPMASK) == CARD_VPP_UC ? "CARD_VPP_UC" : + (volts & CARD_VPPMASK) == CARD_VPP_12V ? "CARD_VPP_12V": + (volts & CARD_VPPMASK) == CARD_VPP_VCC ? "CARD_VPP_VCC": + (volts & CARD_VPPMASK) == CARD_VPP_0V ? "CARD_VPP_0V" : + "VPP-UNKNOWN", + volts); + return (0); + } + return (1); /* power changed correctly */ +} + +/* + * detect the voltage for the card, and set it. Since the power + * used is the square of the voltage, lower voltages is a big win + * and what Windows does (and what Microsoft prefers). The MS paper + * also talks about preferring the CIS entry as well. + */ +static int +cbb_do_power(device_t brdev) +{ + int voltage; + + /* Prefer lowest voltage supported */ + voltage = cbb_detect_voltage(brdev); + cbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); + if (voltage & CARD_YV_CARD) + cbb_power(brdev, CARD_VCC_YV | CARD_VPP_VCC); + else if (voltage & CARD_XV_CARD) + cbb_power(brdev, CARD_VCC_XV | CARD_VPP_VCC); + else if (voltage & CARD_3V_CARD) + cbb_power(brdev, CARD_VCC_3V | CARD_VPP_VCC); + else if (voltage & CARD_5V_CARD) + cbb_power(brdev, CARD_VCC_5V | CARD_VPP_VCC); + else { + device_printf(brdev, "Unknown card voltage\n"); + return (ENXIO); + } + return (0); +} + +/************************************************************************/ +/* CardBus power functions */ +/************************************************************************/ + +static void +cbb_cardbus_reset(device_t brdev) +{ + struct cbb_softc *sc = device_get_softc(brdev); + int delay_us; + + delay_us = sc->chipset == CB_RF5C47X ? 400*1000 : 20*1000; + + PCI_MASK_CONFIG(brdev, CBBR_BRIDGECTRL, |CBBM_BRIDGECTRL_RESET, 2); + + DELAY(delay_us); + + /* If a card exists, unreset it! */ + if ((cbb_get(sc, CBB_SOCKET_STATE) & CBB_SOCKET_STAT_CD) == 0) { + PCI_MASK_CONFIG(brdev, CBBR_BRIDGECTRL, + &~CBBM_BRIDGECTRL_RESET, 2); + DELAY(delay_us); + } +} + +static int +cbb_cardbus_power_enable_socket(device_t brdev, device_t child) +{ + struct cbb_softc *sc = device_get_softc(brdev); + int err; + + if ((cbb_get(sc, CBB_SOCKET_STATE) & CBB_SOCKET_STAT_CD) == + CBB_SOCKET_STAT_CD) + return (ENODEV); + + err = cbb_do_power(brdev); + if (err) + return (err); + cbb_cardbus_reset(brdev); + return (0); +} + +static void +cbb_cardbus_power_disable_socket(device_t brdev, device_t child) +{ + cbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); + cbb_cardbus_reset(brdev); +} + +/************************************************************************/ +/* CardBus Resource */ +/************************************************************************/ + +static int +cbb_cardbus_io_open(device_t brdev, int win, uint32_t start, uint32_t end) +{ + int basereg; + int limitreg; + + if ((win < 0) || (win > 1)) { + DEVPRINTF((brdev, + "cbb_cardbus_io_open: window out of range %d\n", win)); + return (EINVAL); + } + + basereg = win * 8 + CBBR_IOBASE0; + limitreg = win * 8 + CBBR_IOLIMIT0; + + pci_write_config(brdev, basereg, start, 4); + pci_write_config(brdev, limitreg, end, 4); + return (0); +} + +static int +cbb_cardbus_mem_open(device_t brdev, int win, uint32_t start, uint32_t end) +{ + int basereg; + int limitreg; + + if ((win < 0) || (win > 1)) { + DEVPRINTF((brdev, + "cbb_cardbus_mem_open: window out of range %d\n", win)); + return (EINVAL); + } + + basereg = win*8 + CBBR_MEMBASE0; + limitreg = win*8 + CBBR_MEMLIMIT0; + + pci_write_config(brdev, basereg, start, 4); + pci_write_config(brdev, limitreg, end, 4); + return (0); +} + +/* + * XXX The following function belongs in the pci bus layer. + */ +static void +cbb_cardbus_auto_open(struct cbb_softc *sc, int type) +{ + uint32_t starts[2]; + uint32_t ends[2]; + struct cbb_reslist *rle; + int align; + int prefetchable[2]; + uint32_t reg; + + starts[0] = starts[1] = 0xffffffff; + ends[0] = ends[1] = 0; + + if (type == SYS_RES_MEMORY) + align = CBB_MEMALIGN; + else if (type == SYS_RES_IOPORT) + align = CBB_IOALIGN; + else + align = 1; + + SLIST_FOREACH(rle, &sc->rl, link) { + if (rle->type != type) + ; + else if (rle->res == NULL) { + device_printf(sc->dev, "WARNING: Resource not reserved? " + "(type=%d, addr=%lx)\n", + rle->type, rman_get_start(rle->res)); + } else if (!(rman_get_flags(rle->res) & RF_ACTIVE)) { + /* XXX */ + } else if (starts[0] == 0xffffffff) { + starts[0] = rman_get_start(rle->res); + ends[0] = rman_get_end(rle->res); + prefetchable[0] = + rman_get_flags(rle->res) & RF_PREFETCHABLE; + } else if (rman_get_end(rle->res) > ends[0] && + rman_get_start(rle->res) - ends[0] < + CBB_AUTO_OPEN_SMALLHOLE && prefetchable[0] == + (rman_get_flags(rle->res) & RF_PREFETCHABLE)) { + ends[0] = rman_get_end(rle->res); + } else if (rman_get_start(rle->res) < starts[0] && + starts[0] - rman_get_end(rle->res) < + CBB_AUTO_OPEN_SMALLHOLE && prefetchable[0] == + (rman_get_flags(rle->res) & RF_PREFETCHABLE)) { + starts[0] = rman_get_start(rle->res); + } else if (starts[1] == 0xffffffff) { + starts[1] = rman_get_start(rle->res); + ends[1] = rman_get_end(rle->res); + prefetchable[1] = + rman_get_flags(rle->res) & RF_PREFETCHABLE; + } else if (rman_get_end(rle->res) > ends[1] && + rman_get_start(rle->res) - ends[1] < + CBB_AUTO_OPEN_SMALLHOLE && prefetchable[1] == + (rman_get_flags(rle->res) & RF_PREFETCHABLE)) { + ends[1] = rman_get_end(rle->res); + } else if (rman_get_start(rle->res) < starts[1] && + starts[1] - rman_get_end(rle->res) < + CBB_AUTO_OPEN_SMALLHOLE && prefetchable[1] == + (rman_get_flags(rle->res) & RF_PREFETCHABLE)) { + starts[1] = rman_get_start(rle->res); + } else { + uint32_t diffs[2]; + int win; + + diffs[0] = diffs[1] = 0xffffffff; + if (rman_get_start(rle->res) > ends[0]) + diffs[0] = rman_get_start(rle->res) - ends[0]; + else if (rman_get_end(rle->res) < starts[0]) + diffs[0] = starts[0] - rman_get_end(rle->res); + if (rman_get_start(rle->res) > ends[1]) + diffs[1] = rman_get_start(rle->res) - ends[1]; + else if (rman_get_end(rle->res) < starts[1]) + diffs[1] = starts[1] - rman_get_end(rle->res); + + win = (diffs[0] <= diffs[1])?0:1; + if (rman_get_start(rle->res) > ends[win]) + ends[win] = rman_get_end(rle->res); + else if (rman_get_end(rle->res) < starts[win]) + starts[win] = rman_get_start(rle->res); + if (!(rman_get_flags(rle->res) & RF_PREFETCHABLE)) + prefetchable[win] = 0; + } + + if (starts[0] != 0xffffffff) + starts[0] -= starts[0] % align; + if (starts[1] != 0xffffffff) + starts[1] -= starts[1] % align; + if (ends[0] % align != 0) + ends[0] += align - ends[0]%align - 1; + if (ends[1] % align != 0) + ends[1] += align - ends[1]%align - 1; + } + + if (type == SYS_RES_MEMORY) { + cbb_cardbus_mem_open(sc->dev, 0, starts[0], ends[0]); + cbb_cardbus_mem_open(sc->dev, 1, starts[1], ends[1]); + reg = pci_read_config(sc->dev, CBBR_BRIDGECTRL, 2); + reg &= ~(CBBM_BRIDGECTRL_PREFETCH_0| + CBBM_BRIDGECTRL_PREFETCH_1); + reg |= (prefetchable[0]?CBBM_BRIDGECTRL_PREFETCH_0:0)| + (prefetchable[1]?CBBM_BRIDGECTRL_PREFETCH_1:0); + pci_write_config(sc->dev, CBBR_BRIDGECTRL, reg, 2); + } else if (type == SYS_RES_IOPORT) { + cbb_cardbus_io_open(sc->dev, 0, starts[0], ends[0]); + cbb_cardbus_io_open(sc->dev, 1, starts[1], ends[1]); + } +} + +static int +cbb_cardbus_activate_resource(device_t brdev, device_t child, int type, + int rid, struct resource *res) +{ + int ret; + + ret = BUS_ACTIVATE_RESOURCE(device_get_parent(brdev), child, + type, rid, res); + if (ret != 0) + return (ret); + cbb_cardbus_auto_open(device_get_softc(brdev), type); + return (0); +} + +static int +cbb_cardbus_deactivate_resource(device_t brdev, device_t child, int type, + int rid, struct resource *res) +{ + int ret; + + ret = BUS_DEACTIVATE_RESOURCE(device_get_parent(brdev), child, + type, rid, res); + if (ret != 0) + return (ret); + cbb_cardbus_auto_open(device_get_softc(brdev), type); + return (0); +} + +static struct resource * +cbb_cardbus_alloc_resource(device_t brdev, device_t child, int type, + int *rid, u_long start, u_long end, u_long count, uint flags) +{ + struct cbb_softc *sc = device_get_softc(brdev); + int tmp; + struct resource *res; + + switch (type) { + case SYS_RES_IRQ: + tmp = rman_get_start(sc->irq_res); + if (start > tmp || end < tmp || count != 1) { + device_printf(child, "requested interrupt %ld-%ld," + "count = %ld not supported by cbb\n", + start, end, count); + return (NULL); + } + start = end = tmp; + break; + case SYS_RES_IOPORT: + if (start <= cbb_start_32_io) + start = cbb_start_32_io; + if (end < start) + end = start; + break; + case SYS_RES_MEMORY: + if (start <= cbb_start_mem) + start = cbb_start_mem; + if (end < start) + end = start; + break; + } + + res = BUS_ALLOC_RESOURCE(device_get_parent(brdev), child, type, rid, + start, end, count, flags & ~RF_ACTIVE); + if (res == NULL) { + printf("cbb alloc res fail\n"); + return (NULL); + } + cbb_insert_res(sc, res, type, *rid); + if (flags & RF_ACTIVE) + if (bus_activate_resource(child, type, *rid, res) != 0) { + bus_release_resource(child, type, *rid, res); + return (NULL); + } + + return (res); +} + +static int +cbb_cardbus_release_resource(device_t brdev, device_t child, int type, + int rid, struct resource *res) +{ + struct cbb_softc *sc = device_get_softc(brdev); + int error; + + if (rman_get_flags(res) & RF_ACTIVE) { + error = bus_deactivate_resource(child, type, rid, res); + if (error != 0) + return (error); + } + cbb_remove_res(sc, res); + return (BUS_RELEASE_RESOURCE(device_get_parent(brdev), child, + type, rid, res)); +} + +/************************************************************************/ +/* PC Card Power Functions */ +/************************************************************************/ + +static int +cbb_pcic_power_enable_socket(device_t brdev, device_t child) +{ + struct cbb_softc *sc = device_get_softc(brdev); + int err; + + DPRINTF(("cbb_pcic_socket_enable:\n")); + + /* power down/up the socket to reset */ + err = cbb_do_power(brdev); + if (err) + return (err); + exca_reset(&sc->exca, child); + + return (0); +} + +static void +cbb_pcic_power_disable_socket(device_t brdev, device_t child) +{ + struct cbb_softc *sc = device_get_softc(brdev); + + DPRINTF(("cbb_pcic_socket_disable\n")); + + /* reset signal asserting... */ + exca_clrb(&sc->exca, EXCA_INTR, EXCA_INTR_RESET); + DELAY(2*1000); + + /* power down the socket */ + cbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); + exca_clrb(&sc->exca, EXCA_PWRCTL, EXCA_PWRCTL_OE); + + /* wait 300ms until power fails (Tpf). */ + DELAY(300 * 1000); +} + +/************************************************************************/ +/* POWER methods */ +/************************************************************************/ + +static int +cbb_power_enable_socket(device_t brdev, device_t child) +{ + struct cbb_softc *sc = device_get_softc(brdev); + + if (sc->flags & CBB_16BIT_CARD) + return (cbb_pcic_power_enable_socket(brdev, child)); + else + return (cbb_cardbus_power_enable_socket(brdev, child)); +} + +static void +cbb_power_disable_socket(device_t brdev, device_t child) +{ + struct cbb_softc *sc = device_get_softc(brdev); + if (sc->flags & CBB_16BIT_CARD) + cbb_pcic_power_disable_socket(brdev, child); + else + cbb_cardbus_power_disable_socket(brdev, child); +} +static int +cbb_pcic_activate_resource(device_t brdev, device_t child, int type, int rid, + struct resource *res) +{ + int err; + struct cbb_softc *sc = device_get_softc(brdev); + if (!(rman_get_flags(res) & RF_ACTIVE)) { /* not already activated */ + switch (type) { + case SYS_RES_IOPORT: + err = exca_io_map(&sc->exca, 0, res); + break; + case SYS_RES_MEMORY: + err = exca_mem_map(&sc->exca, 0, res); + break; + default: + err = 0; + break; + } + if (err) + return (err); + + } + return (BUS_ACTIVATE_RESOURCE(device_get_parent(brdev), child, + type, rid, res)); +} + +static int +cbb_pcic_deactivate_resource(device_t brdev, device_t child, int type, + int rid, struct resource *res) +{ + struct cbb_softc *sc = device_get_softc(brdev); + + if (rman_get_flags(res) & RF_ACTIVE) { /* if activated */ + switch (type) { + case SYS_RES_IOPORT: + if (exca_io_unmap_res(&sc->exca, res)) + return (ENOENT); + break; + case SYS_RES_MEMORY: + if (exca_mem_unmap_res(&sc->exca, res)) + return (ENOENT); + break; + } + } + return (BUS_DEACTIVATE_RESOURCE(device_get_parent(brdev), child, + type, rid, res)); +} + +static struct resource * +cbb_pcic_alloc_resource(device_t brdev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, uint flags) +{ + struct resource *res = NULL; + struct cbb_softc *sc = device_get_softc(brdev); + int tmp; + + switch (type) { + case SYS_RES_MEMORY: + if (start < cbb_start_mem) + start = cbb_start_mem; + if (end < start) + end = start; + flags = (flags & ~RF_ALIGNMENT_MASK) | + rman_make_alignment_flags(CBB_MEMALIGN); + break; + case SYS_RES_IOPORT: + if (start < cbb_start_16_io) + start = cbb_start_16_io; + if (end < start) + end = start; + break; + case SYS_RES_IRQ: + tmp = rman_get_start(sc->irq_res); + if (start > tmp || end < tmp || count != 1) { + device_printf(child, "requested interrupt %ld-%ld," + "count = %ld not supported by cbb\n", + start, end, count); + return (NULL); + } + flags |= RF_SHAREABLE; + start = end = rman_get_start(sc->irq_res); + break; + } + res = BUS_ALLOC_RESOURCE(device_get_parent(brdev), child, type, rid, + start, end, count, flags & ~RF_ACTIVE); + if (res == NULL) + return (NULL); + cbb_insert_res(sc, res, type, *rid); + if (flags & RF_ACTIVE) { + if (bus_activate_resource(child, type, *rid, res) != 0) { + bus_release_resource(child, type, *rid, res); + return (NULL); + } + } + + return (res); +} + +static int +cbb_pcic_release_resource(device_t brdev, device_t child, int type, + int rid, struct resource *res) +{ + struct cbb_softc *sc = device_get_softc(brdev); + int error; + + if (rman_get_flags(res) & RF_ACTIVE) { + error = bus_deactivate_resource(child, type, rid, res); + if (error != 0) + return (error); + } + cbb_remove_res(sc, res); + return (BUS_RELEASE_RESOURCE(device_get_parent(brdev), child, + type, rid, res)); +} + +/************************************************************************/ +/* PC Card methods */ +/************************************************************************/ + +static int +cbb_pcic_set_res_flags(device_t brdev, device_t child, int type, int rid, + uint32_t flags) +{ + struct cbb_softc *sc = device_get_softc(brdev); + struct resource *res; + + if (type != SYS_RES_MEMORY) + return (EINVAL); + res = cbb_find_res(sc, type, rid); + if (res == NULL) { + device_printf(brdev, + "set_res_flags: specified rid not found\n"); + return (ENOENT); + } + return (exca_mem_set_flags(&sc->exca, res, flags)); +} + +static int +cbb_pcic_set_memory_offset(device_t brdev, device_t child, int rid, + uint32_t cardaddr, uint32_t *deltap) +{ + struct cbb_softc *sc = device_get_softc(brdev); + struct resource *res; + + res = cbb_find_res(sc, SYS_RES_MEMORY, rid); + if (res == NULL) { + device_printf(brdev, + "set_memory_offset: specified rid not found\n"); + return (ENOENT); + } + return (exca_mem_set_offset(&sc->exca, res, cardaddr, deltap)); +} + +/************************************************************************/ +/* BUS Methods */ +/************************************************************************/ + + +static int +cbb_activate_resource(device_t brdev, device_t child, int type, int rid, + struct resource *r) +{ + struct cbb_softc *sc = device_get_softc(brdev); + + if (sc->flags & CBB_16BIT_CARD) + return (cbb_pcic_activate_resource(brdev, child, type, rid, r)); + else + return (cbb_cardbus_activate_resource(brdev, child, type, rid, + r)); +} + +static int +cbb_deactivate_resource(device_t brdev, device_t child, int type, + int rid, struct resource *r) +{ + struct cbb_softc *sc = device_get_softc(brdev); + + if (sc->flags & CBB_16BIT_CARD) + return (cbb_pcic_deactivate_resource(brdev, child, type, + rid, r)); + else + return (cbb_cardbus_deactivate_resource(brdev, child, type, + rid, r)); +} + +static struct resource * +cbb_alloc_resource(device_t brdev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, uint flags) +{ + struct cbb_softc *sc = device_get_softc(brdev); + + if (sc->flags & CBB_16BIT_CARD) + return (cbb_pcic_alloc_resource(brdev, child, type, rid, + start, end, count, flags)); + else + return (cbb_cardbus_alloc_resource(brdev, child, type, rid, + start, end, count, flags)); +} + +static int +cbb_release_resource(device_t brdev, device_t child, int type, int rid, + struct resource *r) +{ + struct cbb_softc *sc = device_get_softc(brdev); + + if (sc->flags & CBB_16BIT_CARD) + return (cbb_pcic_release_resource(brdev, child, type, + rid, r)); + else + return (cbb_cardbus_release_resource(brdev, child, type, + rid, r)); +} + +static int +cbb_read_ivar(device_t brdev, device_t child, int which, uintptr_t *result) +{ + struct cbb_softc *sc = device_get_softc(brdev); + + switch (which) { + case PCIB_IVAR_BUS: + *result = sc->secbus; + return (0); + } + return (ENOENT); +} + +static int +cbb_write_ivar(device_t brdev, device_t child, int which, uintptr_t value) +{ + struct cbb_softc *sc = device_get_softc(brdev); + + switch (which) { + case PCIB_IVAR_BUS: + sc->secbus = value; + break; + } + return (ENOENT); +} + +/************************************************************************/ +/* PCI compat methods */ +/************************************************************************/ + +static int +cbb_maxslots(device_t brdev) +{ + return (0); +} + +static uint32_t +cbb_read_config(device_t brdev, int b, int s, int f, int reg, int width) +{ + /* + * Pass through to the next ppb up the chain (i.e. our grandparent). + */ + return (PCIB_READ_CONFIG(device_get_parent(device_get_parent(brdev)), + b, s, f, reg, width)); +} + +static void +cbb_write_config(device_t brdev, int b, int s, int f, int reg, uint32_t val, + int width) +{ + /* + * Pass through to the next ppb up the chain (i.e. our grandparent). + */ + PCIB_WRITE_CONFIG(device_get_parent(device_get_parent(brdev)), + b, s, f, reg, val, width); +} + +static int +cbb_suspend(device_t self) +{ + int error = 0; + struct cbb_softc *sc = device_get_softc(self); + + cbb_setb(sc, CBB_SOCKET_MASK, 0); /* Quiet hardware */ + bus_teardown_intr(self, sc->irq_res, sc->intrhand); + sc->flags &= ~CBB_CARD_OK; /* Card is bogus now */ + error = bus_generic_suspend(self); + return (error); +} + +static int +cbb_resume(device_t self) +{ + int error = 0; + struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(self); + uint32_t tmp; + + /* + * Some BIOSes will not save the BARs for the pci chips, so we + * must do it ourselves. If the BAR is reset to 0 for an I/O + * device, it will read back as 0x1, so no explicit test for + * memory devices are needed. + * + * Note: The PCI bus code should do this automatically for us on + * suspend/resume, but until it does, we have to cope. + */ + pci_write_config(self, CBBR_SOCKBASE, rman_get_start(sc->base_res), 4); + DEVPRINTF((self, "PCI Memory allocated: %08lx\n", + rman_get_start(sc->base_res))); + + cbb_chipinit(sc); + + /* reset interrupt -- Do we really need to do this? */ + tmp = cbb_get(sc, CBB_SOCKET_EVENT); + cbb_set(sc, CBB_SOCKET_EVENT, tmp); + + /* re-establish the interrupt. */ + if (bus_setup_intr(self, sc->irq_res, INTR_TYPE_AV, cbb_intr, sc, + &sc->intrhand)) { + device_printf(self, "couldn't re-establish interrupt"); + bus_release_resource(self, SYS_RES_IRQ, 0, sc->irq_res); + bus_release_resource(self, SYS_RES_MEMORY, CBBR_SOCKBASE, + sc->base_res); + sc->irq_res = NULL; + sc->base_res = NULL; + return (ENOMEM); + } + + /* CSC Interrupt: Card detect interrupt on */ + cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD); + + /* Signal the thread to wakeup. */ + wakeup(sc); + + error = bus_generic_resume(self); + + return (error); +} + +static int +cbb_child_present(device_t self) +{ + struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(self); + uint32_t sockstate; + + sockstate = cbb_get(sc, CBB_SOCKET_STATE); + return ((sockstate & CBB_SOCKET_STAT_CD) != 0 && + (sc->flags & CBB_CARD_OK) != 0); +} + +static device_method_t cbb_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, cbb_probe), + DEVMETHOD(device_attach, cbb_attach), + DEVMETHOD(device_detach, cbb_detach), + DEVMETHOD(device_shutdown, cbb_shutdown), + DEVMETHOD(device_suspend, cbb_suspend), + DEVMETHOD(device_resume, cbb_resume), + + /* bus methods */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_read_ivar, cbb_read_ivar), + DEVMETHOD(bus_write_ivar, cbb_write_ivar), + DEVMETHOD(bus_alloc_resource, cbb_alloc_resource), + DEVMETHOD(bus_release_resource, cbb_release_resource), + DEVMETHOD(bus_activate_resource, cbb_activate_resource), + DEVMETHOD(bus_deactivate_resource, cbb_deactivate_resource), + DEVMETHOD(bus_driver_added, cbb_driver_added), + DEVMETHOD(bus_child_detached, cbb_child_detached), + DEVMETHOD(bus_setup_intr, cbb_setup_intr), + DEVMETHOD(bus_teardown_intr, cbb_teardown_intr), + DEVMETHOD(bus_child_present, cbb_child_present), + + /* 16-bit card interface */ + DEVMETHOD(card_set_res_flags, cbb_pcic_set_res_flags), + DEVMETHOD(card_set_memory_offset, cbb_pcic_set_memory_offset), + + /* power interface */ + DEVMETHOD(power_enable_socket, cbb_power_enable_socket), + DEVMETHOD(power_disable_socket, cbb_power_disable_socket), + + /* pcib compatibility interface */ + DEVMETHOD(pcib_maxslots, cbb_maxslots), + DEVMETHOD(pcib_read_config, cbb_read_config), + DEVMETHOD(pcib_write_config, cbb_write_config), + {0,0} +}; + +static driver_t cbb_driver = { + "cbb", + cbb_methods, + sizeof(struct cbb_softc) +}; + +static devclass_t cbb_devclass; + +DRIVER_MODULE(cbb, pci, cbb_driver, cbb_devclass, 0, 0); +MODULE_VERSION(cbb, 1); +MODULE_DEPEND(cbb, exca, 1, 1, 1); diff --git a/sys/bus/pccard/pccbb/pccbbdevid.h b/sys/dev/pccard/pccbb/pccbbdevid.h similarity index 87% rename from sys/bus/pccard/pccbb/pccbbdevid.h rename to sys/dev/pccard/pccbb/pccbbdevid.h index 3816ead7d7..b672f7a05a 100644 --- a/sys/bus/pccard/pccbb/pccbbdevid.h +++ b/sys/dev/pccard/pccbb/pccbbdevid.h @@ -23,20 +23,19 @@ * (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: src/sys/dev/pccbb/pccbbdevid.h,v 1.1.2.6 2003/02/26 18:42:01 imp Exp $ - * $DragonFly: src/sys/bus/pccard/pccbb/Attic/pccbbdevid.h,v 1.2 2003/06/17 04:28:29 dillon Exp $ + * $FreeBSD: src/sys/dev/pccbb/pccbbdevid.h,v 1.9 2002/08/10 06:35:03 imp Exp $ + * $DragonFly: src/sys/dev/pccard/pccbb/pccbbdevid.h,v 1.1 2004/02/10 07:55:47 joerg Exp $ */ /* Vendor/Device IDs */ +#define PCIC_ID_INTEL_82092AA 0x12218086ul /* 16bit I/O */ #define PCIC_ID_CLPD6729 0x11001013ul /* 16bit I/O */ #define PCIC_ID_CLPD6832 0x11101013ul #define PCIC_ID_CLPD6833 0x11131013ul #define PCIC_ID_CLPD6834 0x11121013ul -#define PCIC_ID_INTEL_82092AA_0 0x12218086ul /* 16bit I/O */ -#define PCIC_ID_INTEL_82092AA_1 0x12228086ul /* 16bit I/O */ -#define PCIC_ID_OMEGA_82C094 0x1221119bul /* 16bit I/O */ -#define PCIC_ID_OZ6729 0x67291217ul /* 16bit I/O */ -#define PCIC_ID_OZ6730 0x673A1217ul /* 16bit I/O */ +#define PCIC_ID_OMEGA_82C094 0x1221119bul /* 16bit I/O */ +#define PCIC_ID_OZ6729 0x67291217ul +#define PCIC_ID_OZ6730 0x673A1217ul #define PCIC_ID_OZ6832 0x68321217ul /* Also 6833 */ #define PCIC_ID_OZ6860 0x68361217ul /* Also 6836 */ #define PCIC_ID_OZ6872 0x68721217ul /* Also 6812 */ @@ -49,7 +48,6 @@ #define PCIC_ID_RICOH_RL5C476 0x04761180ul #define PCIC_ID_RICOH_RL5C477 0x04771180ul #define PCIC_ID_RICOH_RL5C478 0x04781180ul -#define PCIC_ID_SMC_34C90 0xb10610b3ul /* XXX */ #define PCIC_ID_TI1031 0xac13104cul #define PCIC_ID_TI1130 0xac12104cul #define PCIC_ID_TI1131 0xac15104cul @@ -83,6 +81,7 @@ * Other ID, from sources too vague to be reliable * Mfg model PCI ID * smc/Databook DB87144 0x310610b3 + * SMC/databook smc34c90 0xb10610b3 * Omega/Trident 82c194 0x01941023 * Omega/Trident 82c722 0x07221023? * Opti 82c814 0xc8141045 diff --git a/sys/dev/pccard/pccbb/pccbbreg.h b/sys/dev/pccard/pccbb/pccbbreg.h new file mode 100644 index 0000000000..19fc85f04a --- /dev/null +++ b/sys/dev/pccard/pccbb/pccbbreg.h @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2000,2001 Jonathan Chen. + * 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, + * without modification, immediately at the beginning of the file. + * 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: src/sys/dev/pccbb/pccbbreg.h,v 1.12 2002/11/23 23:09:45 imp Exp $ + * $DragonFly: src/sys/dev/pccard/pccbb/pccbbreg.h,v 1.1 2004/02/10 07:55:47 joerg Exp $ + */ + +/* + * Copyright (c) 1998, 1999 and 2000 + * HAYAKAWA Koichi. 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 HAYAKAWA Koichi. + * 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. + */ + +/* + * Register definitions for PCI to Cardbus Bridge chips + */ + + +/* PCI header registers */ +#define CBBR_SOCKBASE 0x10 /* len=4 */ + +#define CBBR_MEMBASE0 0x1c /* len=4 */ +#define CBBR_MEMLIMIT0 0x20 /* len=4 */ +#define CBBR_MEMBASE1 0x24 /* len=4 */ +#define CBBR_MEMLIMIT1 0x28 /* len=4 */ +#define CBBR_IOBASE0 0x2c /* len=4 */ +#define CBBR_IOLIMIT0 0x30 /* len=4 */ +#define CBBR_IOBASE1 0x34 /* len=4 */ +#define CBBR_IOLIMIT1 0x38 /* len=4 */ +#define CBB_MEMALIGN 4096 +#define CBB_IOALIGN 4 + +#define CBBR_INTRLINE 0x3c /* len=1 */ +#define CBBR_INTRPIN 0x3d /* len=1 */ +#define CBBR_BRIDGECTRL 0x3e /* len=2 */ +# define CBBM_BRIDGECTRL_MASTER_ABORT 0x0020 +# define CBBM_BRIDGECTRL_RESET 0x0040 +# define CBBM_BRIDGECTRL_INTR_IREQ_EN 0x0080 +# define CBBM_BRIDGECTRL_PREFETCH_0 0x0100 +# define CBBM_BRIDGECTRL_PREFETCH_1 0x0200 +# define CBBM_BRIDGECTRL_WRITE_POST_EN 0x0400 + /* additional bit for RF5C46[567] */ +# define CBBM_BRIDGECTRL_RL_3E0_EN 0x0800 +# define CBBM_BRIDGECTRL_RL_3E2_EN 0x1000 + +#define CBBR_LEGACY 0x44 /* len=4 */ + +/* TI * */ +#define CBBR_SYSCTRL 0x80 /* len=4 */ +# define CBBM_SYSCTRL_INTRTIE 0x20000000u + +/* TI [14][245]xx */ +#define CBBR_MMCTRL 0x84 /* len=4 */ + +/* TI 12xx/14xx/15xx (except 1250/1251/1251B/1450) */ +#define CBBR_MFUNC 0x8c /* len=4 */ +# define CBBM_MFUNC_PIN0 0x0000000f +# define CBBM_MFUNC_PIN0_INTA 0x02 +# define CBBM_MFUNC_PIN1 0x000000f0 +# define CBBM_MFUNC_PIN1_INTB 0x20 +# define CBBM_MFUNC_PIN2 0x00000f00 +# define CBBM_MFUNC_PIN3 0x0000f000 +# define CBBM_MFUNC_PIN4 0x000f0000 +# define CBBM_MFUNC_PIN5 0x00f00000 +# define CBBM_MFUNC_PIN6 0x0f000000 + +#define CBBR_CBCTRL 0x91 /* len=1 */ + /* bits for TI 113X */ +# define CBBM_CBCTRL_113X_RI_EN 0x80 +# define CBBM_CBCTRL_113X_ZV_EN 0x40 +# define CBBM_CBCTRL_113X_PCI_IRQ_EN 0x20 +# define CBBM_CBCTRL_113X_PCI_INTR 0x10 +# define CBBM_CBCTRL_113X_PCI_CSC 0x08 +# define CBBM_CBCTRL_113X_PCI_CSC_D 0x04 +# define CBBM_CBCTRL_113X_SPEAKER_EN 0x02 +# define CBBM_CBCTRL_113X_INTR_DET 0x01 + /* TI [14][245]xx */ +# define CBBM_CBCTRL_12XX_RI_EN 0x80 +# define CBBM_CBCTRL_12XX_ZV_EN 0x40 +# define CBBM_CBCTRL_12XX_AUD2MUX 0x04 +# define CBBM_CBCTRL_12XX_SPEAKER_EN 0x02 +# define CBBM_CBCTRL_12XX_INTR_DET 0x01 +#define CBBR_DEVCTRL 0x92 /* len=1 */ +# define CBBM_DEVCTRL_INT_SERIAL 0x04 +# define CBBM_DEVCTRL_INT_PCI 0x02 + +/* ToPIC 95 ONLY */ +#define CBBR_TOPIC_SOCKETCTRL 0x90 +# define CBBM_TOPIC_SOCKETCTRL_SCR_IRQSEL 0x00000001 /* PCI intr */ +/* ToPIC 97, 100 */ +#define CBBR_TOPIC_ZV_CONTROL 0x9c /* 1 byte */ +# define CBBM_TOPIC_ZVC_ENABLE 0x1 + +/* TOPIC 95+ */ +#define CBBR_TOPIC_SLOTCTRL 0xa0 /* 1 byte */ +# define CBBM_TOPIC_SLOTCTRL_SLOTON 0x80 +# define CBBM_TOPIC_SLOTCTRL_SLOTEN 0x40 +# define CBBM_TOPIC_SLOTCTRL_ID_LOCK 0x20 +# define CBBM_TOPIC_SLOTCTRL_ID_WP 0x10 +# define CBBM_TOPIC_SLOTCTRL_PORT_MASK 0x0c +# define CBBM_TOPIC_SLOTCTRL_PORT_SHIFT 2 +# define CBBM_TOPIC_SLOTCTRL_OSF_MASK 0x03 +# define CBBM_TOPIC_SLOTCTRL_OSF_SHIFT 0 + +/* TOPIC 95+ */ +#define CBBR_TOPIC_INTCTRL 0xa1 /* 1 byte */ +# define CBBM_TOPIC_INTCTRL_INTB 0x20 +# define CBBM_TOPIC_INTCTRL_INTA 0x10 +# define CBBM_TOPIC_INTCTRL_INT_MASK 0x30 +/* The following bits may be for ToPIC 95 only */ +# define CBBM_TOPIC_INTCTRL_CLOCK_MASK 0x0c +# define CBBM_TOPIC_INTCTRL_CLOCK_2 0x08 /* PCI Clk/2 */ +# define CBBM_TOPIC_INTCTRL_CLOCK_1 0x04 /* PCI Clk */ +# define CBBM_TOPIC_INTCTRL_CLOCK_0 0x00 /* no clock */ +/* ToPIC97, 100 defines the following bits */ +# define CBBM_TOPIC_INTCTRL_STSIRQNP 0x04 +# define CBBM_TOPIC_INTCTRL_IRQNP 0x02 +# define CBBM_TOPIC_INTCTRL_INTIRQSEL 0x01 + +/* TOPIC 95+ */ +#define CBBR_TOPIC_CDC 0xa3 /* 1 byte */ +# define CBBM_TOPIC_CDC_CARDBUS 0x80 +# define CBBM_TOPIC_CDC_VS1 0x04 +# define CBBM_TOPIC_CDC_VS2 0x02 +# define CBBM_TOPIC_CDC_SWDETECT 0x01 + +/* Socket definitions */ +#define CBB_SOCKET_EVENT_CSTS 0x01 /* Card Status Change */ +#define CBB_SOCKET_EVENT_CD1 0x02 /* Card Detect 1 */ +#define CBB_SOCKET_EVENT_CD2 0x04 /* Card Detect 2 */ +#define CBB_SOCKET_EVENT_CD 0x06 /* Card Detect all */ +#define CBB_SOCKET_EVENT_POWER 0x08 /* Power Cycle */ + +#define CBB_SOCKET_MASK_CSTS 0x01 /* Card Status Change */ +#define CBB_SOCKET_MASK_CD 0x06 /* Card Detect */ +#define CBB_SOCKET_MASK_POWER 0x08 /* Power Cycle */ +#define CBB_SOCKET_MASK_ALL 0x0F /* all of the above */ + +#define CBB_SOCKET_STAT_CARDSTS 0x00000001 /* Card Status Change */ +#define CBB_SOCKET_STAT_CD1 0x00000002 /* Card Detect 1 */ +#define CBB_SOCKET_STAT_CD2 0x00000004 /* Card Detect 2 */ +#define CBB_SOCKET_STAT_CD 0x00000006 /* Card Detect all */ +#define CBB_SOCKET_STAT_PWRCYCLE 0x00000008 /* Power Cycle */ +#define CBB_SOCKET_STAT_16BIT 0x00000010 /* 16-bit Card */ +#define CBB_SOCKET_STAT_CB 0x00000020 /* Cardbus Card */ +#define CBB_SOCKET_STAT_IREQ 0x00000040 /* Ready */ +#define CBB_SOCKET_STAT_NOTCARD 0x00000080 /* Unrecognized Card */ +#define CBB_SOCKET_STAT_DATALOST 0x00000100 /* Data Lost */ +#define CBB_SOCKET_STAT_BADVCC 0x00000200 /* Bad VccRequest */ +#define CBB_SOCKET_STAT_5VCARD 0x00000400 /* 5 V Card */ +#define CBB_SOCKET_STAT_3VCARD 0x00000800 /* 3.3 V Card */ +#define CBB_SOCKET_STAT_XVCARD 0x00001000 /* X.X V Card */ +#define CBB_SOCKET_STAT_YVCARD 0x00002000 /* Y.Y V Card */ +#define CBB_SOCKET_STAT_5VSOCK 0x10000000 /* 5 V Socket */ +#define CBB_SOCKET_STAT_3VSOCK 0x20000000 /* 3.3 V Socket */ +#define CBB_SOCKET_STAT_XVSOCK 0x40000000 /* X.X V Socket */ +#define CBB_SOCKET_STAT_YVSOCK 0x80000000 /* Y.Y V Socket */ + +#define CBB_SOCKET_CTRL_VPPMASK 0x07 +#define CBB_SOCKET_CTRL_VPP_OFF 0x00 +#define CBB_SOCKET_CTRL_VPP_12V 0x01 +#define CBB_SOCKET_CTRL_VPP_5V 0x02 +#define CBB_SOCKET_CTRL_VPP_3V 0x03 +#define CBB_SOCKET_CTRL_VPP_XV 0x04 +#define CBB_SOCKET_CTRL_VPP_YV 0x05 + +#define CBB_SOCKET_CTRL_VCCMASK 0x70 +#define CBB_SOCKET_CTRL_VCC_OFF 0x00 +#define CBB_SOCKET_CTRL_VCC_5V 0x20 +#define CBB_SOCKET_CTRL_VCC_3V 0x30 +#define CBB_SOCKET_CTRL_VCC_XV 0x40 +#define CBB_SOCKET_CTRL_VCC_YV 0x50 + +#define CBB_SOCKET_CTRL_STOPCLK 0x80 + +#include + +#define CBB_SOCKET_EVENT 0x00 +#define CBB_SOCKET_MASK 0x04 +#define CBB_SOCKET_STATE 0x08 +#define CBB_SOCKET_FORCE 0x0c +#define CBB_SOCKET_CONTROL 0x10 +#define CBB_SOCKET_POWER 0x14 + +#define CBB_EXCA_OFFSET 0x800 /* offset for exca regs */ diff --git a/sys/dev/pccard/pccbb/pccbbvar.h b/sys/dev/pccard/pccbb/pccbbvar.h new file mode 100644 index 0000000000..7f80f03dd5 --- /dev/null +++ b/sys/dev/pccard/pccbb/pccbbvar.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2000,2001 Jonathan Chen. + * 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, + * without modification, immediately at the beginning of the file. + * 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: src/sys/dev/pccbb/pccbbvar.h,v 1.15 2002/10/07 23:11:29 imp Exp $ + * $DragonFly: src/sys/dev/pccard/pccbb/pccbbvar.h,v 1.1 2004/02/10 07:55:47 joerg Exp $ + */ + +/* + * Structure definitions for the Cardbus Bridge driver + */ + +struct cbb_intrhand { + driver_intr_t *intr; + void *arg; + STAILQ_ENTRY(cbb_intrhand) entries; +}; + +struct cbb_reslist { + SLIST_ENTRY(cbb_reslist) link; + struct resource *res; + int type; + int rid; + /* note: unlike the regular resource list, there can be + * duplicate rid's in the same list. However, the + * combination of rid and res->r_dev should be unique. + */ + bus_addr_t cardaddr; /* for 16-bit pccard memory */ +}; + +#define CBB_AUTO_OPEN_SMALLHOLE 0x100 + +struct cbb_softc { + device_t dev; + struct exca_softc exca; + struct resource *base_res; + struct resource *irq_res; + void *intrhand; + bus_space_tag_t bst; + bus_space_handle_t bsh; + u_int8_t secbus; + u_int8_t subbus; + struct lock lock; + u_int32_t flags; +#define CBB_CARD_OK 0x08000000 +#define CBB_KLUDGE_ALLOC 0x10000000 +#define CBB_16BIT_CARD 0x20000000 +#define CBB_KTHREAD_RUNNING 0x40000000 +#define CBB_KTHREAD_DONE 0x80000000 + int chipset; /* chipset id */ +#define CB_UNKNOWN 0 /* NOT Cardbus-PCI bridge */ +#define CB_TI113X 1 /* TI PCI1130/1131 */ +#define CB_TI12XX 2 /* TI PCI12xx/14xx/44xx/15xx/45xx */ +#define CB_TI125X 3 /* TI PCI1250/1251(B)/1450 */ +#define CB_RF5C47X 4 /* RICOH RF5C475/476/477 */ +#define CB_RF5C46X 5 /* RICOH RF5C465/466/467 */ +#define CB_CIRRUS 6 /* Cirrus Logic CLPD683x */ +#define CB_TOPIC95 7 /* Toshiba ToPIC95 */ +#define CB_TOPIC97 8 /* Toshiba ToPIC97/100 */ + SLIST_HEAD(, cbb_reslist) rl; + STAILQ_HEAD(, cbb_intrhand) intr_handlers; + + device_t cbdev; + device_t pccarddev; + + struct thread *event_thread; +}; + +/* result of detect_card */ +#define CARD_UKN_CARD 0x00 +#define CARD_5V_CARD 0x01 +#define CARD_3V_CARD 0x02 +#define CARD_XV_CARD 0x04 +#define CARD_YV_CARD 0x08 + +/* for power_socket */ +#define CARD_VCC_UC 0x0000 +#define CARD_VCC_3V 0x0001 +#define CARD_VCC_XV 0x0002 +#define CARD_VCC_YV 0x0003 +#define CARD_VCC_0V 0x0004 +#define CARD_VCC_5V 0x0005 +#define CARD_VCCMASK 0x000f +#define CARD_VPP_UC 0x0000 +#define CARD_VPP_VCC 0x0010 +#define CARD_VPP_12V 0x0030 +#define CARD_VPP_0V 0x0040 +#define CARD_VPPMASK 0x00f0 diff --git a/sys/dev/pccard/pcic/Makefile b/sys/dev/pccard/pcic/Makefile new file mode 100644 index 0000000000..12276f1325 --- /dev/null +++ b/sys/dev/pccard/pcic/Makefile @@ -0,0 +1,8 @@ +# $DragonFly: src/sys/dev/pccard/pcic/Attic/Makefile,v 1.1 2004/02/10 07:55:47 joerg Exp $ + +KMOD= pcic +SRCS= i82365.c i82365_isa.c \ + device_if.h bus_if.h isa_if.h power_if.h card_if.h +NOMAN= + +.include diff --git a/sys/dev/misc/pcic/i82365.c b/sys/dev/pccard/pcic/i82365.c similarity index 92% rename from sys/dev/misc/pcic/i82365.c rename to sys/dev/pccard/pcic/i82365.c index c1a4bf76f0..4bd0305afc 100644 --- a/sys/dev/misc/pcic/i82365.c +++ b/sys/dev/pccard/pcic/i82365.c @@ -1,6 +1,6 @@ /* $NetBSD: i82365.c,v 1.25 1999/10/15 06:07:27 haya Exp $ */ -/* $FreeBSD: src/sys/dev/pcic/i82365.c,v 1.16.2.1 2000/05/23 03:57:02 imp Exp $ */ -/* $DragonFly: src/sys/dev/misc/pcic/Attic/i82365.c,v 1.7 2004/01/08 10:06:29 joerg Exp $ */ +/* $FreeBSD: src/sys/dev/pcic/i82365.c,v 1.37 2002/11/17 04:52:37 imp Exp $ */ +/* $DragonFly: src/sys/dev/pccard/pcic/Attic/i82365.c,v 1.1 2004/02/10 07:55:47 joerg Exp $ */ /* * Copyright (c) 1997 Marc Horowitz. All rights reserved. @@ -46,18 +46,17 @@ #include -#include #include +#include #include -#include /* We shouldn't need to include the following, but sadly we do for now */ /* XXX */ #include #include -#include "i82365reg.h" -#include "i82365var.h" +#include +#include #include "card_if.h" @@ -65,14 +64,16 @@ #ifdef PCICDEBUG int pcic_debug = 1; -#define DPRINTF(arg) if (pcic_debug) printf arg; -#define DEVPRINTF(arg) if (pcic_debug) device_printf arg; +#define DPRINTF(arg) if (pcic_debug) printf arg; else ; +#define DEVPRINTF(arg) if (pcic_debug) device_printf arg; else ; #else #define DPRINTF(arg) #define DEVPRINTF(arg) #endif -#define DETACH_FORCE 0x1 +#define VERBOSE(arg) if (bootverbose) printf arg; else ; + +#define N(a) (sizeof(a)/sizeof(a[0])) #define PCIC_VENDOR_UNKNOWN 0 #define PCIC_VENDOR_I82365SLR0 1 @@ -80,6 +81,7 @@ int pcic_debug = 1; #define PCIC_VENDOR_CIRRUS_PD6710 3 #define PCIC_VENDOR_CIRRUS_PD672X 4 +#define PCIC_H2SOFTC(h) ((struct pcic_softc *)h->sc) /* * Individual drivers will allocate their own memory and io regions. Memory * regions must be a multiple of 4k, aligned on a 4k boundary. @@ -88,15 +90,13 @@ int pcic_debug = 1; #define PCIC_MEM_ALIGN PCIC_MEM_PAGESIZE static void pcic_init_socket(struct pcic_handle *); - static void pcic_intr_socket(struct pcic_handle *); -static void pcic_deactivate(device_t dev); static int pcic_activate(device_t dev); static void pcic_intr(void *arg); static void pcic_attach_card(struct pcic_handle *); -static void pcic_detach_card(struct pcic_handle *, int); +static void pcic_detach_card(struct pcic_handle *); static void pcic_chip_do_mem_map(struct pcic_handle *, int); static void pcic_chip_do_io_map(struct pcic_handle *, int); @@ -199,35 +199,32 @@ pcic_vendor_to_string(int vendor) static int pcic_activate(device_t dev) { - struct pcic_softc *sc = (struct pcic_softc *) - device_get_softc(dev); + struct pcic_softc *sc = PCIC_SOFTC(dev); int err; sc->port_rid = 0; sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid, 0, ~0, PCIC_IOSIZE, RF_ACTIVE); if (!sc->port_res) { -#ifdef PCIC_DEBUG device_printf(dev, "Cannot allocate ioport\n"); -#endif return ENOMEM; } sc->irq_rid = 0; sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid, 0, ~0, 1, RF_ACTIVE); - if (!sc->irq_res) { -#ifdef PCIC_DEBUG - device_printf(dev, "Cannot allocate irq\n"); -#endif - pcic_deactivate(dev); - return ENOMEM; - } - sc->irq = rman_get_start(sc->irq_res); - if ((err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, pcic_intr, - sc, &sc->intrhand)) != 0) { - pcic_deactivate(dev); - return err; + if (sc->irq_res) { + sc->irq = rman_get_start(sc->irq_res); + if ((err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC, + pcic_intr, sc, &sc->intrhand)) != 0) { + device_printf(dev, "Cannot setup intr\n"); + pcic_deactivate(dev); + return err; + } + } else { + printf("Polling not supported\n"); + /* XXX Do polling */ + return (ENXIO); } /* XXX This might not be needed in future, get it directly from @@ -235,10 +232,8 @@ pcic_activate(device_t dev) sc->mem_rid = 0; sc->mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->mem_rid, 0, ~0, 1 << 13, RF_ACTIVE); - if (!sc->mem_res) { -#ifdef PCIC_DEBUG + if (sc->mem_res == NULL) { device_printf(dev, "Cannot allocate mem\n"); -#endif pcic_deactivate(dev); return ENOMEM; } @@ -251,10 +246,10 @@ pcic_activate(device_t dev) return (0); } -static void +void pcic_deactivate(device_t dev) { - struct pcic_softc *sc = device_get_softc(dev); + struct pcic_softc *sc = PCIC_SOFTC(dev); if (sc->intrhand) bus_teardown_intr(dev, sc->irq_res, sc->intrhand); @@ -277,27 +272,29 @@ pcic_deactivate(device_t dev) int pcic_attach(device_t dev) { - struct pcic_softc *sc = (struct pcic_softc *) - device_get_softc(dev); + struct pcic_softc *sc = PCIC_SOFTC(dev); struct pcic_handle *h; int vendor, count, i, reg, error; sc->dev = dev; /* Activate our resources */ - if ((error = pcic_activate(dev)) != 0) + if ((error = pcic_activate(dev)) != 0) { + printf("pcic_attach (active) returns %d\n", error); return error; + } /* now check for each controller/socket */ /* * this could be done with a loop, but it would violate the - * abstraction... so? --imp + * abstraction... --- unknown + * I don't see the abstraction... --imp */ count = 0; - DPRINTF(("pcic ident regs:")); + VERBOSE(("pcic ident regs:")); sc->handle[0].sc = sc; sc->handle[0].sock = C0SA; @@ -314,7 +311,7 @@ pcic_attach(device_t dev) } sc->handle[0].laststate = PCIC_LASTSTATE_EMPTY; - DPRINTF((" 0x%02x", reg)); + VERBOSE((" 0x%02x", reg)); sc->handle[1].sc = sc; sc->handle[1].sock = C0SB; @@ -331,7 +328,7 @@ pcic_attach(device_t dev) } sc->handle[1].laststate = PCIC_LASTSTATE_EMPTY; - DPRINTF((" 0x%02x", reg)); + VERBOSE((" 0x%02x", reg)); /* * The CL-PD6729 has only one controller and always returns 0 @@ -356,7 +353,7 @@ pcic_attach(device_t dev) } sc->handle[2].laststate = PCIC_LASTSTATE_EMPTY; - DPRINTF((" 0x%02x", reg)); + VERBOSE((" 0x%02x", reg)); sc->handle[3].sc = sc; sc->handle[3].sock = C1SB; @@ -374,14 +371,16 @@ pcic_attach(device_t dev) } sc->handle[3].laststate = PCIC_LASTSTATE_EMPTY; - DPRINTF((" 0x%02x\n", reg)); + VERBOSE((" 0x%02x\n", reg)); } else { sc->handle[2].flags = 0; sc->handle[3].flags = 0; } - if (count == 0) - panic("pcic_attach: attach found no sockets"); + if (count == 0) { + printf("pcic_attach: attach found no sockets\n"); + return (ENXIO); + } /* establish the interrupt */ @@ -489,8 +488,8 @@ pcic_create_event_thread(void *arg) } if (kthread_create(pcic_event_thread, h, &h->event_thread, - "%s,%s", device_get_name(h->sc->dev), cs)) { - device_printf(h->sc->dev, + "%s,%s", device_get_name(PCIC_H2SOFTC(h)->dev), cs)) { + device_printf(PCIC_H2SOFTC(h)->dev, "cannot create event thread for sock 0x%02x\n", h->sock); panic("pcic_create_event_thread"); } @@ -565,7 +564,7 @@ pcic_event_thread(void *arg) splx(s); DEVPRINTF((h->dev, "removal event\n")); - pcic_detach_card(h, DETACH_FORCE); + pcic_detach_card(h); break; default: @@ -635,8 +634,6 @@ pcic_intr(void *arg) struct pcic_softc *sc = arg; int i; - DEVPRINTF((sc->dev, "intr\n")); - for (i = 0; i < PCIC_NSLOTS; i++) if (sc->handle[i].flags & PCIC_FLAG_SOCKETP) pcic_intr_socket(&sc->handle[i]); @@ -674,10 +671,8 @@ pcic_intr_socket(struct pcic_handle *h) if (h->laststate == PCIC_LASTSTATE_PRESENT) { /* Deactivate the card now. */ DEVPRINTF((h->dev, "detaching card\n")); - pcic_detach_card(h, DETACH_FORCE); - - DEVPRINTF((h->dev, - "enqueing REMOVAL event\n")); + pcic_detach_card(h); + DEVPRINTF((h->dev,"enqueing REMOVAL event\n")); pcic_queue_event(h, PCIC_EVENT_REMOVAL); } h->laststate = ((statreg & PCIC_IF_STATUS_CARDDETECT_MASK) == 0) @@ -716,29 +711,22 @@ pcic_queue_event(struct pcic_handle *h, int event) static void pcic_attach_card(struct pcic_handle *h) { - DPRINTF(("pcic_attach_card h %p h->dev %p %s %s\n", h, h->dev, - device_get_name(h->dev), device_get_name(device_get_parent(h->dev)))); if (!(h->flags & PCIC_FLAG_CARDP)) { /* call the MI attach function */ CARD_ATTACH_CARD(h->dev); - h->flags |= PCIC_FLAG_CARDP; } else { - DPRINTF(("pcic_attach_card: already attached")); + DPRINTF(("pcic_attach_card: already attached\n")); } } static void -pcic_detach_card(struct pcic_handle *h, int flags) +pcic_detach_card(struct pcic_handle *h) { - if (h->flags & PCIC_FLAG_CARDP) { h->flags &= ~PCIC_FLAG_CARDP; - /* call the MI detach function */ - CARD_DETACH_CARD(h->dev, flags); - } else { - DPRINTF(("pcic_detach_card: already detached")); + CARD_DETACH_CARD(h->dev); } } @@ -898,8 +886,7 @@ pcic_chip_mem_map(struct pcic_handle *h, int kind, bus_addr_t card_addr, int i, win; win = -1; - for (i = 0; i < (sizeof(mem_map_index) / sizeof(mem_map_index[0])); - i++) { + for (i = 0; i < N(mem_map_index); i++) { if ((h->memalloc & (1 << i)) == 0) { win = i; h->memalloc |= (1 << i); @@ -950,7 +937,7 @@ pcic_chip_mem_unmap(struct pcic_handle *h, int window) { int reg; - if (window >= (sizeof(mem_map_index) / sizeof(mem_map_index[0]))) + if (window >= N(mem_map_index)) panic("pcic_chip_mem_unmap: window out of range"); reg = pcic_read(h, PCIC_ADDRWIN_ENABLE); @@ -968,14 +955,11 @@ pcic_chip_io_alloc(struct pcic_handle *h, bus_addr_t start, bus_size_t size, bus_space_handle_t ioh; bus_addr_t ioaddr; int flags = 0; - struct pcic_softc *sc = h->sc; /* * Allocate some arbitrary I/O space. */ - - iot = sc->iot; - + iot = h->ph_bus_t; ioaddr = start; if (start) { ioh = start; @@ -1083,14 +1067,11 @@ 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. */ win = -1; - for (i = 0; i < (sizeof(io_map_index) / sizeof(io_map_index[0])); i++) { + for (i = 0; i < N(io_map_index); i++) { if ((h->ioalloc & (1 << i)) == 0) { win = i; h->ioalloc |= (1 << i); @@ -1103,21 +1084,9 @@ pcic_chip_io_map(struct pcic_handle *h, int width, bus_addr_t offset, *windowp = win; -#if 0 - /* XXX this is pretty gross */ - if (sc->iot != pcihp->iot) - panic("pcic_chip_io_map iot is bogus"); -#endif - DPRINTF(("pcic_chip_io_map window %d %s port %lx+%lx\n", win, width_names[width], (u_long) ioaddr, (u_long) size)); - /* XXX wtf is this doing here? */ - - printf(" port 0x%lx", (u_long) ioaddr); - if (size > 1) - printf("-0x%lx", (u_long) ioaddr + (u_long) size - 1); - h->io[win].addr = ioaddr; h->io[win].size = size; h->io[win].width = width; @@ -1132,7 +1101,7 @@ pcic_chip_io_unmap(struct pcic_handle *h, int window) { int reg; - if (window >= (sizeof(io_map_index) / sizeof(io_map_index[0]))) + if (window >= N(io_map_index)) panic("pcic_chip_io_unmap: window out of range"); reg = pcic_read(h, PCIC_ADDRWIN_ENABLE); @@ -1269,7 +1238,6 @@ int pcic_disable_socket(device_t dev, device_t child) { struct pcic_handle *h = pcic_get_handle(dev, child); - DPRINTF(("pcic_chip_socket_disable\n")); /* power down the socket */ @@ -1314,7 +1282,7 @@ pcic_activate_resource(device_t dev, device_t child, int type, int rid, bus_addr_t off; struct pcic_handle *h = pcic_get_handle(dev, child); - sz = rman_get_end(r) - rman_get_start(r) + 1; + sz = rman_get_size(r); switch (type) { case SYS_RES_IOPORT: win = rid; @@ -1423,7 +1391,7 @@ pcic_alloc_resource(device_t dev, device_t child, int type, int *rid, count, flags); if (r == NULL) return r; - sz = rman_get_end(r) - rman_get_start(r) + 1; + sz = rman_get_size(r); switch (type) { case SYS_RES_IOPORT: err = pcic_chip_io_alloc(h, rman_get_start(r), sz, 0, @@ -1493,7 +1461,6 @@ pcic_set_res_flags(device_t dev, device_t child, int type, int rid, { struct pcic_handle *h = pcic_get_handle(dev, child); - 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; @@ -1503,10 +1470,11 @@ pcic_set_res_flags(device_t dev, device_t child, int type, int rid, } int -pcic_set_memory_offset(device_t dev, device_t child, int rid, - u_int32_t offset, u_int32_t* deltap) +pcic_set_memory_offset(device_t dev, device_t child, int rid, u_int32_t offset, + u_int32_t *deltap) { - return 0; + /* XXX BAD XXX */ + return EIO; } static void @@ -1519,4 +1487,35 @@ pcic_start_threads(void *arg) } } +int +pcic_detach(device_t dev) +{ + device_t *kids; + int nkids; + int i; + int ret; + + pcic_deactivate(dev); + ret = bus_generic_detach(dev); + if (ret != 0) + return (ret); + /* + * Normally, one wouldn't delete the children. However, detach + * merely detaches the children w/o deleting them. So if + * we were to reattach, we add additional children and wind up + * with duplicates. So, we remove them here following the + * implicit "if you add it in attach, you should delete it in + * detach" rule that may or may not be documented. + */ + device_get_children(dev, &kids, &nkids); + for (i = 0; i < nkids; i++) { + if ((ret = device_delete_child(dev, kids[i])) != 0) + device_printf(dev, "delete of %s failed: %d\n", + device_get_nameunit(kids[i]), ret); + } + free(kids, M_TEMP); + return 0; +} + SYSINIT(pcic, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, pcic_start_threads, 0); +MODULE_VERSION(pcic, 1); diff --git a/sys/dev/misc/pcic/i82365_isa.c b/sys/dev/pccard/pcic/i82365_isa.c similarity index 81% rename from sys/dev/misc/pcic/i82365_isa.c rename to sys/dev/pccard/pcic/i82365_isa.c index 39635639cd..22d8b083f0 100644 --- a/sys/dev/misc/pcic/i82365_isa.c +++ b/sys/dev/pccard/pcic/i82365_isa.c @@ -1,7 +1,7 @@ /* $NetBSD: i82365_isasubr.c,v 1.3 1999/10/15 06:07:27 haya Exp $ */ /* $NetBSD: i82365_isa.c,v 1.11 1998/06/09 07:25:00 thorpej Exp $ */ -/* $FreeBSD: src/sys/dev/pcic/i82365_isa.c,v 1.13.2.1 2000/05/23 03:57:02 imp Exp $ */ -/* $DragonFly: src/sys/dev/misc/pcic/Attic/i82365_isa.c,v 1.4 2003/08/15 08:32:29 dillon Exp $ */ +/* $FreeBSD: src/sys/dev/pcic/i82365_isa.c,v 1.24 2002/05/30 17:37:46 takawata Exp $ */ +/* $DragonFly: src/sys/dev/pccard/pcic/Attic/i82365_isa.c,v 1.1 2004/02/10 07:55:47 joerg Exp $ */ /* * Copyright (c) 1998 Bill Sommerfeld. All rights reserved. @@ -51,8 +51,8 @@ #include #include -#include "i82365reg.h" -#include "i82365var.h" +#include +#include #include "power_if.h" #include "card_if.h" @@ -61,12 +61,6 @@ * Configurable parameters. *****************************************************************************/ -#if 0 -#include "opt_pcic_isa_alloc_iobase.h" -#include "opt_pcic_isa_alloc_iosize.h" -#include "opt_pcic_isa_intr_alloc_mask.h" -#endif - /* * Default I/O allocation range. If both are set to non-zero, these * values will be used instead. Otherwise, the code attempts to probe @@ -106,8 +100,10 @@ int pcic_isa_intr_alloc_mask = PCIC_ISA_INTR_ALLOC_MASK; * End of configurable parameters. *****************************************************************************/ +#define PCICISADEBUG 1 + #ifdef PCICISADEBUG -int pcicisa_debug = 0 /* XXX */ ; +int pcicisa_debug = PCICISADEBUG; #define DPRINTF(arg) if (pcicisa_debug) printf arg; #define DEVPRINTF(arg) if (pcicisa_debug) device_printf arg; #else @@ -116,18 +112,20 @@ int pcicisa_debug = 0 /* XXX */ ; #endif static struct isa_pnp_id pcic_ids[] = { + {PCIC_PNP_ACTIONTEC, NULL}, /* AEI0218 */ + {PCIC_PNP_IBM3765, NULL}, /* IBM3765 */ {PCIC_PNP_82365, NULL}, /* PNP0E00 */ {PCIC_PNP_CL_PD6720, NULL}, /* PNP0E01 */ {PCIC_PNP_VLSI_82C146, NULL}, /* PNP0E02 */ {PCIC_PNP_82365_CARDBUS, NULL}, /* PNP0E03 */ + {PCIC_PNP_SCM_SWAPBOX, NULL}, /* SCM0469 */ {0} }; static void pcic_isa_bus_width_probe (device_t dev) { - struct pcic_softc *sc = (struct pcic_softc *) - device_get_softc(dev); + struct pcic_softc *sc = PCIC_SOFTC(dev); bus_space_handle_t ioh_high; int i, iobuswidth, tmp1, tmp2; int rid; @@ -138,7 +136,7 @@ pcic_isa_bus_width_probe (device_t dev) struct resource *r; base = rman_get_start(sc->port_res); - length = rman_get_end(sc->port_res) - rman_get_end(sc->port_res) + 1; + length = rman_get_size(sc->port_res); iot = sc->iot; ioh = sc->ioh; @@ -227,6 +225,7 @@ pcic_isa_bus_width_probe (device_t dev) } } +#if 0 static int pcic_isa_check(device_t dev, u_int16_t addr) { @@ -273,34 +272,16 @@ pcic_isa_check(device_t dev, u_int16_t addr) return (found); } - -static void -pcic_isa_identify(driver_t *driver, device_t parent) -{ - device_t child; - u_int16_t ioaddrs[] = { 0x3e0, 0x3e2, 0x3e4, 0x3e6, 0 }; - u_int16_t ioaddr; - int i; - - for (i = 0; ioaddrs[i]; i++) { - ioaddr = ioaddrs[i]; - if (pcic_isa_check(parent, ioaddr)) { - child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, - "pcic", -1); - device_set_driver(child, driver); -/* XXX */ - bus_set_resource(child, SYS_RES_IRQ, 0, 10, 1); - bus_set_resource(child, SYS_RES_MEMORY, 0, 0xd0000, 1 << 12); - bus_set_resource(child, SYS_RES_IOPORT, 0, ioaddr, - PCIC_IOSIZE); - } - } -} +#endif static int pcic_isa_probe(device_t dev) { int error; + struct resource *res; + int rid; + int i; + u_long mem; /* Check isapnp ids */ error = ISA_PNP_PROBE(device_get_parent(dev), dev, pcic_ids); @@ -308,17 +289,62 @@ pcic_isa_probe(device_t dev) return (ENXIO); /* If we had some other problem. */ - if (!(error == 0 || error == ENOENT)) { + if (!(error == 0 || error == ENOENT)) return (error); - } /* If we have the resources we need then we're good to go. */ - if ((bus_get_resource_start(dev, SYS_RES_IOPORT, 0) != 0) && - (bus_get_resource_start(dev, SYS_RES_IRQ, 0) != 0)) { - return (0); + if (bus_get_resource_start(dev, SYS_RES_IOPORT, 0) == 0) + return (ENXIO); + rid = 0; + res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, RF_ACTIVE); + if (res == NULL) { + /* + * No IRQ specified, find one. This can be due to the PnP + * data not specifying any IRQ + */ + for (i = 0; i < 16; i++) { + if (((1 << i) & PCIC_INTR_IRQ_VALIDMASK) == 0) + continue; + res = bus_alloc_resource(dev, SYS_RES_IRQ, + &rid, i, i, 1, RF_ACTIVE); + if (res != NULL) + break; + } + if (res == NULL) + return (ENXIO); + mem = rman_get_start(res); + bus_release_resource(dev, SYS_RES_IRQ, rid, res); + bus_set_resource(dev, SYS_RES_IRQ, 0, i, 1); + } else { + bus_release_resource(dev, SYS_RES_IRQ, rid, res); } - - return (ENXIO); + /* XXX This might not be needed in future, get it directly from + * XXX parent */ + rid = 0; + res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, + 1 << 13, RF_ACTIVE); + if (res == NULL) { + /* + * We failed to get memory. Since this XXX comment above + * indicates that this is transient, we try to get a hunk + * of memory in the isa hole. Sure would be nice if there + * were some MI constants for this. + */ + res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, + 0xa0000, 0xdffff, 1 << 13, RF_ACTIVE); + if (res != NULL) { + mem = rman_get_start(res); + bus_release_resource(dev, SYS_RES_MEMORY, rid, res); + bus_set_resource(dev, SYS_RES_MEMORY, 0, mem, 1 << 13); + } + } else { + bus_release_resource(dev, SYS_RES_MEMORY, rid, res); + } + if (res == NULL) { + device_printf(dev, "Cannot allocate mem\n"); + return ENOMEM; + } + return (0); } static int @@ -328,19 +354,18 @@ pcic_isa_attach(device_t dev) if ((err = pcic_attach(dev)) == 0) pcic_isa_bus_width_probe (dev); - return err; } static int pcic_isa_detach(device_t dev) { + pcic_detach(dev); return 0; } static device_method_t pcic_isa_methods[] = { /* Device interface */ - DEVMETHOD(device_identify, pcic_isa_identify), DEVMETHOD(device_probe, pcic_isa_probe), DEVMETHOD(device_attach, pcic_isa_attach), DEVMETHOD(device_detach, pcic_isa_detach), @@ -377,3 +402,4 @@ static driver_t pcic_driver = { static devclass_t pcic_devclass; DRIVER_MODULE(pcic, isa, pcic_driver, pcic_devclass, 0, 0); +MODULE_DEPEND(pcic, pccard, 1, 1, 1); diff --git a/sys/dev/misc/pcic/i82365reg.h b/sys/dev/pccard/pcic/i82365reg.h similarity index 98% rename from sys/dev/misc/pcic/i82365reg.h rename to sys/dev/pccard/pcic/i82365reg.h index f7388f02ba..cfcafc0250 100644 --- a/sys/dev/misc/pcic/i82365reg.h +++ b/sys/dev/pccard/pcic/i82365reg.h @@ -1,6 +1,6 @@ /* $NetBSD: i82365reg.h,v 1.3 1998/12/20 17:53:28 nathanw Exp $ */ -/* $FreeBSD: src/sys/dev/pcic/i82365reg.h,v 1.3.2.4 2001/07/09 07:19:58 imp Exp $ */ -/* $DragonFly: src/sys/dev/misc/pcic/Attic/i82365reg.h,v 1.2 2003/06/17 04:28:29 dillon Exp $ */ +/* $FreeBSD: src/sys/dev/pcic/i82365reg.h,v 1.10 2001/06/16 06:10:53 imp Exp $ */ +/* $DragonFly: src/sys/dev/pccard/pcic/Attic/i82365reg.h,v 1.1 2004/02/10 07:55:47 joerg Exp $ */ /* * Copyright (c) 1997 Marc Horowitz. All rights reserved. diff --git a/sys/dev/misc/pcic/i82365var.h b/sys/dev/pccard/pcic/i82365var.h similarity index 80% rename from sys/dev/misc/pcic/i82365var.h rename to sys/dev/pccard/pcic/i82365var.h index ee5e8182c7..b335f02c2c 100644 --- a/sys/dev/misc/pcic/i82365var.h +++ b/sys/dev/pccard/pcic/i82365var.h @@ -1,6 +1,7 @@ /* $NetBSD: i82365var.h,v 1.8 1999/10/15 06:07:27 haya Exp $ */ -/* $FreeBSD: src/sys/dev/pcic/i82365var.h,v 1.15.2.1 2000/05/23 03:57:02 imp Exp $ */ -/* $DragonFly: src/sys/dev/misc/pcic/Attic/i82365var.h,v 1.6 2004/01/08 10:06:29 joerg Exp $ */ +/* $FreeBSD: src/sys/dev/pcic/i82365var.h,v 1.26 2001/01/07 16:31:07 imp Exp $ */ +/* $DragonFly: src/sys/dev/pccard/pcic/Attic/i82365var.h,v 1.1 2004/02/10 07:55:47 joerg Exp $ */ + /* * Copyright (c) 1997 Marc Horowitz. All rights reserved. @@ -33,7 +34,7 @@ #include -#include "i82365reg.h" +#include struct proc; @@ -46,18 +47,20 @@ struct pcic_event { #define PCIC_EVENT_INSERTION 0 #define PCIC_EVENT_REMOVAL 1 +struct proc; + struct pcic_handle { - struct pcic_softc *sc; + void *sc; device_t dev; bus_space_tag_t ph_bus_t; /* I/O or MEM? I don't mind */ bus_space_handle_t ph_bus_h; - u_int8_t (* ph_read)(struct pcic_handle*, int); - void (* ph_write)(struct pcic_handle *, int, u_int8_t); + u_int8_t (*ph_read)(struct pcic_handle*, int); + void (*ph_write)(struct pcic_handle *, int, u_int8_t); int vendor; int sock; int flags; - int laststate; + int laststate; int memalloc; struct pccard_mem_handle mem[PCIC_MEM_WINS]; /* XXX BAD XXX */ int ioalloc; @@ -135,40 +138,8 @@ char *pcic_vendor_to_string(int); int pcic_attach(device_t dev); -#if 0 - -static __inline int pcic_read(struct pcic_handle *, int); -static __inline int -pcic_read(h, idx) - struct pcic_handle *h; - int idx; -{ - if (idx != -1) - bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_INDEX, - h->sock + idx); - return (bus_space_read_1(h->sc->iot, h->sc->ioh, PCIC_REG_DATA)); -} - -static __inline void pcic_write(struct pcic_handle *, int, int); -static __inline void -pcic_write(h, idx, data) - struct pcic_handle *h; - int idx; - int data; -{ - if (idx != -1) - bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_INDEX, - h->sock + idx); - bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_DATA, (data)); -} -#else -#define pcic_read(h, idx) \ - (*(h)->ph_read)((h), (idx)) - -#define pcic_write(h, idx, data) \ - (*(h)->ph_write)((h), (idx), (data)) - -#endif +#define pcic_read(h, idx) (*(h)->ph_read)((h), (idx)) +#define pcic_write(h, idx, data) (*(h)->ph_write)((h), (idx), (data)) /* * bus/device/etc routines @@ -177,8 +148,10 @@ int pcic_activate_resource(device_t dev, device_t child, int type, int rid, struct resource *r); struct resource *pcic_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); +void pcic_deactivate(device_t dev); int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid, struct resource *r); +int pcic_detach(device_t dev); int pcic_release_resource(device_t dev, device_t child, int type, int rid, struct resource *r); int pcic_setup_intr(device_t dev, device_t child, struct resource *irq, @@ -192,4 +165,6 @@ int pcic_disable_socket(device_t dev, device_t child); int pcic_set_res_flags(device_t dev, device_t child, int type, int rid, u_int32_t flags); int pcic_set_memory_offset(device_t dev, device_t child, int rid, - u_int32_t offset, u_int32_t* deltap); + u_int32_t offset, u_int32_t *deltap); + +#define PCIC_SOFTC(d) (struct pcic_softc *) device_get_softc(d) diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index bc84380d5b..9c9c62038c 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -16,7 +16,7 @@ # in doubt as to the purpose or necessity of a line, check first in LINT. # # $FreeBSD: src/sys/i386/conf/GENERIC,v 1.246.2.54 2003/04/28 03:41:46 simokawa Exp $ -# $DragonFly: src/sys/i386/conf/Attic/GENERIC,v 1.8 2004/01/27 18:26:43 dillon Exp $ +# $DragonFly: src/sys/i386/conf/Attic/GENERIC,v 1.9 2004/02/10 07:55:47 joerg Exp $ machine i386 cpu I386_CPU @@ -171,9 +171,9 @@ device npx0 at nexus? port IO_NPX irq 13 device apm0 at nexus? disable flags 0x20 # Advanced Power Management # PCCARD (PCMCIA) support -device card -device pcic0 at isa? irq 0 port 0x3e0 iomem 0xd0000 -device pcic1 at isa? irq 0 port 0x3e2 iomem 0xd4000 disable +device pccard +device cardbus +device cbb # Serial (COM) ports device sio0 at isa? port IO_COM1 flags 0x10 irq 4 diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT index f16c8ded1b..8d945558d7 100644 --- a/sys/i386/conf/LINT +++ b/sys/i386/conf/LINT @@ -3,7 +3,7 @@ # as much of the source tree as it can. # # $FreeBSD: src/sys/i386/conf/LINT,v 1.749.2.144 2003/06/04 17:56:59 sam Exp $ -# $DragonFly: src/sys/i386/conf/Attic/LINT,v 1.20 2004/02/06 15:31:58 hmp Exp $ +# $DragonFly: src/sys/i386/conf/Attic/LINT,v 1.21 2004/02/10 07:55:47 joerg Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -2048,11 +2048,13 @@ device bktr # # PCCARD/PCMCIA # -# card: pccard slots -# pcic: isa/pccard bridge -device pcic0 at isa? -device pcic1 at isa? -device card +# pccard: pccard slots +# pcic: isa/pccard bridge (OLDCARD) +# cardbus/cbb: cardbus bridge (NEWCARD) +device pccard +device cardbus +device cbb +device pcic # You may need to reset all pccards after resuming options PCIC_RESUME_RESET # reset after resume -- 2.41.0