diff options
Diffstat (limited to 'drivers/pcmcia')
29 files changed, 3040 insertions, 2293 deletions
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 14e4124e152..6485f75d2fb 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -1,8 +1,5 @@ # -# PCMCIA bus subsystem configuration -# -# Right now the non-CardBus choices are not supported -# by the integrated kernel driver. +# PCCARD (PCMCIA/CardBus) bus subsystem configuration # menu "PCCARD (PCMCIA/CardBus) support" @@ -14,8 +11,8 @@ config PCCARD Say Y here if you want to attach PCMCIA- or PC-cards to your Linux computer. These are credit-card size devices such as network cards, modems or hard drives often used with laptops computers. There are - actually two varieties of these cards: the older 16 bit PCMCIA cards - and the newer 32 bit CardBus cards. + actually two varieties of these cards: 16 bit PCMCIA and 32 bit + CardBus cards. To compile this driver as modules, choose M here: the module will be called pcmcia_core. @@ -32,7 +29,7 @@ config PCMCIA_DEBUG The kernel command line options are: pcmcia_core.pc_debug=N - ds.pc_debug=N + pcmcia.pc_debug=N sa11xx_core.pc_debug=N The module option is called pc_debug=N @@ -42,22 +39,50 @@ config PCMCIA_DEBUG config PCMCIA tristate "16-bit PCMCIA support" + select CRC32 default y ---help--- This option enables support for 16-bit PCMCIA cards. Most older PC-cards are such 16-bit PCMCIA cards, so unless you know you're only using 32-bit CardBus cards, say Y or M here. - To use 16-bit PCMCIA cards, you will need supporting software from - David Hinds' pcmcia-cs package (see the file <file:Documentation/Changes> - for location). Please also read the PCMCIA-HOWTO, available from - <http://www.tldp.org/docs.html#howto>. + To use 16-bit PCMCIA cards, you will need supporting software in + most cases. (see the file <file:Documentation/Changes> for + location and details). To compile this driver as modules, choose M here: the module will be called pcmcia. If unsure, say Y. +config PCMCIA_LOAD_CIS + bool "Load CIS updates from userspace (EXPERIMENTAL)" + depends on PCMCIA && EXPERIMENTAL + select FW_LOADER + default y + help + Some PCMCIA cards require an updated Card Information Structure (CIS) + to be loaded from userspace to work correctly. If you say Y here, + and your userspace is arranged correctly, this will be loaded + automatically using the in-kernel firmware loader and the hotplug + subsystem, instead of relying on cardmgr from pcmcia-cs to do so. + + If unsure, say Y. + +config PCMCIA_IOCTL + bool "PCMCIA control ioctl (obsolete)" + depends on PCMCIA + default y + help + If you say Y here, the deprecated ioctl interface to the PCMCIA + subsystem will be built. It is needed by cardmgr and cardctl + (pcmcia-cs) to function properly. + + You should use the new pcmciautils package instead (see + <file:Documentation/Changes> for location and details). + + If unsure, say Y. + config CARDBUS bool "32-bit CardBus support" depends on PCI @@ -78,8 +103,7 @@ comment "PC-card bridges" config YENTA tristate "CardBus yenta-compatible bridge support" depends on PCI -#fixme: remove dependendcy on CARDBUS - depends on CARDBUS + select CARDBUS if !EMBEDDED select PCCARD_NONSTATIC ---help--- This option enables support for CardBus host bridges. Virtually diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 50c29361bc5..ef694c74dfb 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -10,7 +10,8 @@ pcmcia_core-y += cs.o cistpl.o rsrc_mgr.o socket_sysfs.o pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o obj-$(CONFIG_PCCARD) += pcmcia_core.o -pcmcia-y += ds.o pcmcia_compat.o +pcmcia-y += ds.o pcmcia_compat.o pcmcia_resource.o +pcmcia-$(CONFIG_PCMCIA_IOCTL) += pcmcia_ioctl.o obj-$(CONFIG_PCMCIA) += pcmcia.o obj-$(CONFIG_PCCARD_NONSTATIC) += rsrc_nonstatic.o diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c index 0a5c95807cf..470ef756252 100644 --- a/drivers/pcmcia/au1000_generic.c +++ b/drivers/pcmcia/au1000_generic.c @@ -388,6 +388,7 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); memset(skt, 0, sizeof(*skt)); + skt->socket.resource_ops = &pccard_static_ops; skt->socket.ops = &au1x00_pcmcia_operations; skt->socket.owner = ops->owner; skt->socket.dev.dev = dev; diff --git a/drivers/pcmcia/au1000_generic.h b/drivers/pcmcia/au1000_generic.h index 417bc1500ba..d5122b1ea94 100644 --- a/drivers/pcmcia/au1000_generic.h +++ b/drivers/pcmcia/au1000_generic.h @@ -22,7 +22,6 @@ #define __ASM_AU1000_PCMCIA_H /* include the world */ -#include <pcmcia/version.h> #include <pcmcia/cs_types.h> #include <pcmcia/cs.h> #include <pcmcia/ss.h> diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c index df19ce1ea4f..d414a3bb50b 100644 --- a/drivers/pcmcia/au1000_pb1x00.c +++ b/drivers/pcmcia/au1000_pb1x00.c @@ -33,7 +33,6 @@ #include <linux/version.h> #include <linux/types.h> -#include <pcmcia/version.h> #include <pcmcia/cs_types.h> #include <pcmcia/cs.h> #include <pcmcia/ss.h> diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c index 1dfc7765366..f113b69d699 100644 --- a/drivers/pcmcia/au1000_xxs1500.c +++ b/drivers/pcmcia/au1000_xxs1500.c @@ -38,7 +38,6 @@ #include <linux/version.h> #include <linux/types.h> -#include <pcmcia/version.h> #include <pcmcia/cs_types.h> #include <pcmcia/cs.h> #include <pcmcia/ss.h> diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c index 3ccb5247ec5..1d755e20880 100644 --- a/drivers/pcmcia/cardbus.c +++ b/drivers/pcmcia/cardbus.c @@ -31,7 +31,6 @@ #include <asm/io.h> #define IN_CARD_SERVICES -#include <pcmcia/version.h> #include <pcmcia/cs_types.h> #include <pcmcia/ss.h> #include <pcmcia/cs.h> diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index e29a6ddf2fd..3afb682255a 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -88,24 +88,38 @@ EXPORT_SYMBOL(release_cis_mem); static void __iomem * set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flags) { - pccard_mem_map *mem = &s->cis_mem; - if (!(s->features & SS_CAP_STATIC_MAP) && mem->res == NULL) { - mem->res = find_mem_region(0, s->map_size, s->map_size, 0, s); - if (mem->res == NULL) { - printk(KERN_NOTICE "cs: unable to map card memory!\n"); - return NULL; + pccard_mem_map *mem = &s->cis_mem; + int ret; + + if (!(s->features & SS_CAP_STATIC_MAP) && (mem->res == NULL)) { + mem->res = pcmcia_find_mem_region(0, s->map_size, s->map_size, 0, s); + if (mem->res == NULL) { + printk(KERN_NOTICE "cs: unable to map card memory!\n"); + return NULL; + } + s->cis_virt = NULL; } - s->cis_virt = ioremap(mem->res->start, s->map_size); - } - mem->card_start = card_offset; - mem->flags = flags; - s->ops->set_mem_map(s, mem); - if (s->features & SS_CAP_STATIC_MAP) { - if (s->cis_virt) - iounmap(s->cis_virt); - s->cis_virt = ioremap(mem->static_start, s->map_size); - } - return s->cis_virt; + + if (!(s->features & SS_CAP_STATIC_MAP) && (!s->cis_virt)) + s->cis_virt = ioremap(mem->res->start, s->map_size); + + mem->card_start = card_offset; + mem->flags = flags; + + ret = s->ops->set_mem_map(s, mem); + if (ret) { + iounmap(s->cis_virt); + s->cis_virt = NULL; + return NULL; + } + + if (s->features & SS_CAP_STATIC_MAP) { + if (s->cis_virt) + iounmap(s->cis_virt); + s->cis_virt = ioremap(mem->static_start, s->map_size); + } + + return s->cis_virt; } /*====================================================================== @@ -119,13 +133,13 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag #define IS_ATTR 1 #define IS_INDIRECT 8 -int read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, +int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, u_int len, void *ptr) { void __iomem *sys, *end; unsigned char *buf = ptr; - cs_dbg(s, 3, "read_cis_mem(%d, %#x, %u)\n", attr, addr, len); + cs_dbg(s, 3, "pcmcia_read_cis_mem(%d, %#x, %u)\n", attr, addr, len); if (attr & IS_INDIRECT) { /* Indirect accesses use a bunch of special registers at fixed @@ -182,14 +196,16 @@ int read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, *(u_char *)(ptr+2), *(u_char *)(ptr+3)); return 0; } +EXPORT_SYMBOL(pcmcia_read_cis_mem); + -void write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, +void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, u_int len, void *ptr) { void __iomem *sys, *end; unsigned char *buf = ptr; - cs_dbg(s, 3, "write_cis_mem(%d, %#x, %u)\n", attr, addr, len); + cs_dbg(s, 3, "pcmcia_write_cis_mem(%d, %#x, %u)\n", attr, addr, len); if (attr & IS_INDIRECT) { /* Indirect accesses use a bunch of special registers at fixed @@ -239,6 +255,8 @@ void write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, } } } +EXPORT_SYMBOL(pcmcia_write_cis_mem); + /*====================================================================== @@ -274,7 +292,7 @@ static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, ret = read_cb_mem(s, attr, addr, len, ptr); else #endif - ret = read_cis_mem(s, attr, addr, len, ptr); + ret = pcmcia_read_cis_mem(s, attr, addr, len, ptr); if (ret == 0) { /* Copy data into the cache */ @@ -348,7 +366,7 @@ int verify_cis_cache(struct pcmcia_socket *s) read_cb_mem(s, cis->attr, cis->addr, len, buf); else #endif - read_cis_mem(s, cis->attr, cis->addr, len, buf); + pcmcia_read_cis_mem(s, cis->attr, cis->addr, len, buf); if (memcmp(buf, cis->cache, len) != 0) { kfree(buf); @@ -381,6 +399,7 @@ int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) memcpy(s->fake_cis, cis->Data, cis->Length); return CS_SUCCESS; } +EXPORT_SYMBOL(pcmcia_replace_cis); /*====================================================================== diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 03fc885db1c..e39178fc59d 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -33,7 +33,6 @@ #include <asm/irq.h> #define IN_CARD_SERVICES -#include <pcmcia/version.h> #include <pcmcia/cs_types.h> #include <pcmcia/ss.h> #include <pcmcia/cs.h> @@ -43,36 +42,11 @@ #include <pcmcia/ds.h> #include "cs_internal.h" -#ifdef CONFIG_PCI -#define PCI_OPT " [pci]" -#else -#define PCI_OPT "" -#endif -#ifdef CONFIG_CARDBUS -#define CB_OPT " [cardbus]" -#else -#define CB_OPT "" -#endif -#ifdef CONFIG_PM -#define PM_OPT " [pm]" -#else -#define PM_OPT "" -#endif -#if !defined(CONFIG_CARDBUS) && !defined(CONFIG_PCI) && !defined(CONFIG_PM) -#define OPTIONS " none" -#else -#define OPTIONS PCI_OPT CB_OPT PM_OPT -#endif - -static const char *release = "Linux Kernel Card Services"; -static const char *options = "options: " OPTIONS; - -/*====================================================================*/ /* Module parameters */ MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); -MODULE_DESCRIPTION("Linux Kernel Card Services\noptions:" OPTIONS); +MODULE_DESCRIPTION("Linux Kernel Card Services"); MODULE_LICENSE("GPL"); #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444) @@ -89,9 +63,6 @@ INT_MODULE_PARM(unreset_limit, 30); /* unreset_check's */ /* Access speed for attribute memory windows */ INT_MODULE_PARM(cis_speed, 300); /* ns */ -/* Access speed for IO windows */ -INT_MODULE_PARM(io_speed, 0); /* ns */ - #ifdef DEBUG static int pc_debug; @@ -103,34 +74,26 @@ int cs_debug_level(int level) } #endif -/*====================================================================*/ socket_state_t dead_socket = { .csc_mask = SS_DETECT, }; +EXPORT_SYMBOL(dead_socket); /* List of all sockets, protected by a rwsem */ LIST_HEAD(pcmcia_socket_list); -DECLARE_RWSEM(pcmcia_socket_list_rwsem); EXPORT_SYMBOL(pcmcia_socket_list); -EXPORT_SYMBOL(pcmcia_socket_list_rwsem); - -#ifdef CONFIG_PCMCIA_PROBE -/* mask ofIRQs already reserved by other cards, we should avoid using them */ -static u8 pcmcia_used_irq[NR_IRQS]; -#endif - -/*==================================================================== +DECLARE_RWSEM(pcmcia_socket_list_rwsem); +EXPORT_SYMBOL(pcmcia_socket_list_rwsem); - Low-level PC Card interface drivers need to register with Card - Services using these calls. - -======================================================================*/ /** - * socket drivers are expected to use the following callbacks in their + * Low-level PCMCIA socket drivers need to register with the PCCard + * core using pcmcia_register_socket. + * + * socket drivers are expected to use the following callbacks in their * .drv struct: * - pcmcia_socket_dev_suspend * - pcmcia_socket_dev_resume @@ -230,8 +193,8 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) } /* try to obtain a socket number [yes, it gets ugly if we - * register more than 2^sizeof(unsigned int) pcmcia - * sockets... but the socket number is deprecated + * register more than 2^sizeof(unsigned int) pcmcia + * sockets... but the socket number is deprecated * anyways, so I don't care] */ down_write(&pcmcia_socket_list_rwsem); if (list_empty(&pcmcia_socket_list)) @@ -252,6 +215,13 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) list_add_tail(&socket->socket_list, &pcmcia_socket_list); up_write(&pcmcia_socket_list_rwsem); +#ifndef CONFIG_CARDBUS + /* + * If we do not support Cardbus, ensure that + * the Cardbus socket capability is disabled. + */ + socket->features &= ~SS_CAP_CARDBUS; +#endif /* set proper values in socket->dev */ socket->dev.class_data = socket; @@ -340,54 +310,49 @@ struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr) EXPORT_SYMBOL(pcmcia_get_socket_by_nr); -/*====================================================================== - - socket_setup() and shutdown_socket() are called by the main event - handler when card insertion and removal events are received. - socket_setup() turns on socket power and resets the socket, in two stages. - shutdown_socket() unconfigures a socket and turns off socket power. - -======================================================================*/ - +/** + * socket_setup() and shutdown_socket() are called by the main event + * handler when card insertion and removal events are received. + * socket_setup() turns on socket power and resets the socket, in two stages. + * shutdown_socket() unconfigures a socket and turns off socket power. + */ static void shutdown_socket(struct pcmcia_socket *s) { - cs_dbg(s, 1, "shutdown_socket\n"); - - /* Blank out the socket state */ - s->socket = dead_socket; - s->ops->init(s); - s->ops->set_socket(s, &s->socket); - s->irq.AssignedIRQ = s->irq.Config = 0; - s->lock_count = 0; - destroy_cis_cache(s); + cs_dbg(s, 1, "shutdown_socket\n"); + + /* Blank out the socket state */ + s->socket = dead_socket; + s->ops->init(s); + s->ops->set_socket(s, &s->socket); + s->irq.AssignedIRQ = s->irq.Config = 0; + s->lock_count = 0; + destroy_cis_cache(s); #ifdef CONFIG_CARDBUS - cb_free(s); + cb_free(s); #endif - s->functions = 0; - if (s->config) { - kfree(s->config); - s->config = NULL; - } - - { - int status; - s->ops->get_status(s, &status); - if (status & SS_POWERON) { - printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); + s->functions = 0; + if (s->config) { + kfree(s->config); + s->config = NULL; } - } -} /* shutdown_socket */ -/*====================================================================== + { + int status; + s->ops->get_status(s, &status); + if (status & SS_POWERON) { + printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); + } + } +} /* shutdown_socket */ - The central event handler. Send_event() sends an event to the - 16-bit subsystem, which then calls the relevant device drivers. - Parse_events() interprets the event bits from - a card status change report. Do_shutdown() handles the high - priority stuff associated with a card removal. - -======================================================================*/ +/** + * The central event handler. Send_event() sends an event to the + * 16-bit subsystem, which then calls the relevant device drivers. + * Parse_events() interprets the event bits from + * a card status change report. Do_shutdown() handles the high + * priority stuff associated with a card removal. + */ /* NOTE: send_event needs to be called with skt->sem held. */ @@ -490,11 +455,11 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) } if (status & SS_CARDBUS) { + if (!(skt->features & SS_CAP_CARDBUS)) { + cs_err(skt, "cardbus cards are not supported.\n"); + return CS_BAD_TYPE; + } skt->state |= SOCKET_CARDBUS; -#ifndef CONFIG_CARDBUS - cs_err(skt, "cardbus cards are not supported.\n"); - return CS_BAD_TYPE; -#endif } /* @@ -508,6 +473,10 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) cs_err(skt, "unsupported voltage key.\n"); return CS_BAD_TYPE; } + + if (skt->power_hook) + skt->power_hook(skt, HOOK_POWER_PRE); + skt->socket.flags = 0; skt->ops->set_socket(skt, &skt->socket); @@ -522,7 +491,12 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) return CS_BAD_TYPE; } - return socket_reset(skt); + status = socket_reset(skt); + + if (skt->power_hook) + skt->power_hook(skt, HOOK_POWER_POST); + + return status; } /* @@ -709,7 +683,7 @@ static int pccardd(void *__skt) } schedule(); - try_to_freeze(PF_FREEZE); + try_to_freeze(); if (!skt->thread) break; @@ -737,420 +711,9 @@ void pcmcia_parse_events(struct pcmcia_socket *s, u_int events) wake_up(&s->thread_wait); } } /* pcmcia_parse_events */ +EXPORT_SYMBOL(pcmcia_parse_events); -/*====================================================================== - - Special stuff for managing IO windows, because they are scarce. - -======================================================================*/ - -static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base, - ioaddr_t num, u_int lines) -{ - int i; - kio_addr_t try, align; - - align = (*base) ? (lines ? 1<<lines : 0) : 1; - if (align && (align < num)) { - if (*base) { - cs_dbg(s, 0, "odd IO request: num %#x align %#lx\n", - num, align); - align = 0; - } else - while (align && (align < num)) align <<= 1; - } - if (*base & ~(align-1)) { - cs_dbg(s, 0, "odd IO request: base %#x align %#lx\n", - *base, align); - align = 0; - } - if ((s->features & SS_CAP_STATIC_MAP) && s->io_offset) { - *base = s->io_offset | (*base & 0x0fff); - return 0; - } - /* Check for an already-allocated window that must conflict with - what was asked for. It is a hack because it does not catch all - potential conflicts, just the most obvious ones. */ - for (i = 0; i < MAX_IO_WIN; i++) - if ((s->io[i].NumPorts != 0) && - ((s->io[i].BasePort & (align-1)) == *base)) - return 1; - for (i = 0; i < MAX_IO_WIN; i++) { - if (s->io[i].NumPorts == 0) { - s->io[i].res = find_io_region(*base, num, align, s); - if (s->io[i].res) { - s->io[i].Attributes = attr; - s->io[i].BasePort = *base = s->io[i].res->start; - s->io[i].NumPorts = s->io[i].InUse = num; - break; - } else - return 1; - } else if (s->io[i].Attributes != attr) - continue; - /* Try to extend top of window */ - try = s->io[i].BasePort + s->io[i].NumPorts; - if ((*base == 0) || (*base == try)) - if (adjust_io_region(s->io[i].res, s->io[i].res->start, - s->io[i].res->end + num, s) == 0) { - *base = try; - s->io[i].NumPorts += num; - s->io[i].InUse += num; - break; - } - /* Try to extend bottom of window */ - try = s->io[i].BasePort - num; - if ((*base == 0) || (*base == try)) - if (adjust_io_region(s->io[i].res, s->io[i].res->start - num, - s->io[i].res->end, s) == 0) { - s->io[i].BasePort = *base = try; - s->io[i].NumPorts += num; - s->io[i].InUse += num; - break; - } - } - return (i == MAX_IO_WIN); -} /* alloc_io_space */ - -static void release_io_space(struct pcmcia_socket *s, ioaddr_t base, - ioaddr_t num) -{ - int i; - - for (i = 0; i < MAX_IO_WIN; i++) { - if ((s->io[i].BasePort <= base) && - (s->io[i].BasePort+s->io[i].NumPorts >= base+num)) { - s->io[i].InUse -= num; - /* Free the window if no one else is using it */ - if (s->io[i].InUse == 0) { - s->io[i].NumPorts = 0; - release_resource(s->io[i].res); - kfree(s->io[i].res); - s->io[i].res = NULL; - } - } - } -} - -/*====================================================================== - - Access_configuration_register() reads and writes configuration - registers in attribute memory. Memory window 0 is reserved for - this and the tuple reading services. - -======================================================================*/ - -int pccard_access_configuration_register(struct pcmcia_socket *s, - unsigned int function, - conf_reg_t *reg) -{ - config_t *c; - int addr; - u_char val; - - if (!s || !s->config) - return CS_NO_CARD; - - c = &s->config[function]; - - if (c == NULL) - return CS_NO_CARD; - - if (!(c->state & CONFIG_LOCKED)) - return CS_CONFIGURATION_LOCKED; - - addr = (c->ConfigBase + reg->Offset) >> 1; - - switch (reg->Action) { - case CS_READ: - read_cis_mem(s, 1, addr, 1, &val); - reg->Value = val; - break; - case CS_WRITE: - val = reg->Value; - write_cis_mem(s, 1, addr, 1, &val); - break; - default: - return CS_BAD_ARGS; - break; - } - return CS_SUCCESS; -} /* access_configuration_register */ -EXPORT_SYMBOL(pccard_access_configuration_register); - - -/*====================================================================*/ - -int pccard_get_configuration_info(struct pcmcia_socket *s, - unsigned int function, - config_info_t *config) -{ - config_t *c; - - if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - - config->Function = function; - -#ifdef CONFIG_CARDBUS - if (s->state & SOCKET_CARDBUS) { - memset(config, 0, sizeof(config_info_t)); - config->Vcc = s->socket.Vcc; - config->Vpp1 = config->Vpp2 = s->socket.Vpp; - config->Option = s->cb_dev->subordinate->number; - if (s->state & SOCKET_CARDBUS_CONFIG) { - config->Attributes = CONF_VALID_CLIENT; - config->IntType = INT_CARDBUS; - config->AssignedIRQ = s->irq.AssignedIRQ; - if (config->AssignedIRQ) - config->Attributes |= CONF_ENABLE_IRQ; - config->BasePort1 = s->io[0].BasePort; - config->NumPorts1 = s->io[0].NumPorts; - } - return CS_SUCCESS; - } -#endif - - c = (s->config != NULL) ? &s->config[function] : NULL; - - if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { - config->Attributes = 0; - config->Vcc = s->socket.Vcc; - config->Vpp1 = config->Vpp2 = s->socket.Vpp; - return CS_SUCCESS; - } - - /* !!! This is a hack !!! */ - memcpy(&config->Attributes, &c->Attributes, sizeof(config_t)); - config->Attributes |= CONF_VALID_CLIENT; - config->CardValues = c->CardValues; - config->IRQAttributes = c->irq.Attributes; - config->AssignedIRQ = s->irq.AssignedIRQ; - config->BasePort1 = c->io.BasePort1; - config->NumPorts1 = c->io.NumPorts1; - config->Attributes1 = c->io.Attributes1; - config->BasePort2 = c->io.BasePort2; - config->NumPorts2 = c->io.NumPorts2; - config->Attributes2 = c->io.Attributes2; - config->IOAddrLines = c->io.IOAddrLines; - - return CS_SUCCESS; -} /* get_configuration_info */ -EXPORT_SYMBOL(pccard_get_configuration_info); - -/*====================================================================== - - Return information about this version of Card Services. - -======================================================================*/ - -int pcmcia_get_card_services_info(servinfo_t *info) -{ - unsigned int socket_count = 0; - struct list_head *tmp; - info->Signature[0] = 'C'; - info->Signature[1] = 'S'; - down_read(&pcmcia_socket_list_rwsem); - list_for_each(tmp, &pcmcia_socket_list) - socket_count++; - up_read(&pcmcia_socket_list_rwsem); - info->Count = socket_count; - info->Revision = CS_RELEASE_CODE; - info->CSLevel = 0x0210; - info->VendorString = (char *)release; - return CS_SUCCESS; -} /* get_card_services_info */ - - -/*====================================================================*/ - -int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req) -{ - window_t *win; - int w; - - if (!s || !(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - for (w = idx; w < MAX_WIN; w++) - if (s->state & SOCKET_WIN_REQ(w)) break; - if (w == MAX_WIN) - return CS_NO_MORE_ITEMS; - win = &s->win[w]; - req->Base = win->ctl.res->start; - req->Size = win->ctl.res->end - win->ctl.res->start + 1; - req->AccessSpeed = win->ctl.speed; - req->Attributes = 0; - if (win->ctl.flags & MAP_ATTRIB) - req->Attributes |= WIN_MEMORY_TYPE_AM; - if (win->ctl.flags & MAP_ACTIVE) - req->Attributes |= WIN_ENABLE; - if (win->ctl.flags & MAP_16BIT) - req->Attributes |= WIN_DATA_WIDTH_16; - if (win->ctl.flags & MAP_USE_WAIT) - req->Attributes |= WIN_USE_WAIT; - *handle = win; - return CS_SUCCESS; -} /* get_window */ -EXPORT_SYMBOL(pcmcia_get_window); - -/*===================================================================== - - Return the PCI device associated with a card.. - -======================================================================*/ - -#ifdef CONFIG_CARDBUS - -struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s) -{ - if (!s || !(s->state & SOCKET_CARDBUS)) - return NULL; - - return s->cb_dev->subordinate; -} - -EXPORT_SYMBOL(pcmcia_lookup_bus); - -#endif - -/*====================================================================== - - Get the current socket state bits. We don't support the latched - SocketState yet: I haven't seen any point for it. - -======================================================================*/ - -int pccard_get_status(struct pcmcia_socket *s, unsigned int function, cs_status_t *status) -{ - config_t *c; |