diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2022-10-05 19:54:20 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2022-10-05 19:54:20 +0300 |
commit | ebcfaeeceaf1d60de48f0b3c17b057d54ef790e9 (patch) | |
tree | 7d45f077cecbe686e11d8e539fb5e89a0b9084c5 | |
parent | 2bca25eaeba6190efbfcb38ed169bd7ee43b5aaf (diff) | |
parent | 15e74c6c1ce2d388e967f32cdaa83ca034fa6452 (diff) | |
download | linux-ebcfaeeceaf1d60de48f0b3c17b057d54ef790e9.tar.xz |
Merge tag 'pcmcia-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux
Pull PCMCIA updates from Dominik Brodowski:
"Odd cleanups and fixes for v6.1
Remove the obsolete VR41XX and AT91RM9200 Compact Flash drivers, and
fix some minor coding issues (__init/__exit annotations, unused
variable)"
* tag 'pcmcia-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux:
pcmcia: remove AT91RM9200 Compact Flash driver
pcmcia: Removed unused variable control.
pcmcia: Add __init/__exit annotations to module init/exit funcs
pcmcia: at91_cf: make mc static
pcmcia: remove VR41XX PCMCIA driver
pcmcia: sa1100: Make sa11x0_drv_pcmcia_legacy_remove() return void
-rw-r--r-- | drivers/pcmcia/Kconfig | 13 | ||||
-rw-r--r-- | drivers/pcmcia/Makefile | 2 | ||||
-rw-r--r-- | drivers/pcmcia/at91_cf.c | 407 | ||||
-rw-r--r-- | drivers/pcmcia/i82092.c | 4 | ||||
-rw-r--r-- | drivers/pcmcia/omap_cf.c | 4 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_generic.c | 10 | ||||
-rw-r--r-- | drivers/pcmcia/vrc4171_card.c | 745 |
7 files changed, 8 insertions, 1177 deletions
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index bf495bf0f48a..1525023e49b6 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -240,10 +240,6 @@ config PCMCIA_PROBE bool default y if ISA && !ARCH_SA1100 && !PARISC -config PCMCIA_VRC4171 - tristate "NEC VRC4171 Card Controllers support" - depends on CPU_VR41XX && ISA && PCMCIA - config OMAP_CF tristate "OMAP CompactFlash Controller" depends on PCMCIA @@ -252,15 +248,6 @@ config OMAP_CF Say Y here to support the CompactFlash controller on OMAP. Note that this doesn't support "True IDE" mode. -config AT91_CF - tristate "AT91 CompactFlash Controller" - depends on PCI - depends on OF - depends on PCMCIA && ARCH_AT91 - help - Say Y here to support the CompactFlash controller on AT91 chips. - Or choose M to compile the driver as a module named "at91_cf". - config ELECTRA_CF tristate "Electra CompactFlash Controller" depends on PCMCIA && PPC_PASEMI diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index c59ddde42007..b3a2accf47af 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -29,9 +29,7 @@ obj-$(CONFIG_PCMCIA_SA11XX_BASE) += sa11xx_base.o obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o obj-$(CONFIG_PCMCIA_SA1111) += sa1111_cs.o obj-$(CONFIG_PCMCIA_BCM63XX) += bcm63xx_pcmcia.o -obj-$(CONFIG_PCMCIA_VRC4171) += vrc4171_card.o obj-$(CONFIG_OMAP_CF) += omap_cf.o -obj-$(CONFIG_AT91_CF) += at91_cf.o obj-$(CONFIG_ELECTRA_CF) += electra_cf.o obj-$(CONFIG_PCMCIA_ALCHEMY_DEVBOARD) += db1xxx_ss.o obj-$(CONFIG_PCMCIA_MAX1600) += max1600.o diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c deleted file mode 100644 index 92df2c2c5d07..000000000000 --- a/drivers/pcmcia/at91_cf.c +++ /dev/null @@ -1,407 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * at91_cf.c -- AT91 CompactFlash controller driver - * - * Copyright (C) 2005 David Brownell - */ - -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/platform_device.h> -#include <linux/errno.h> -#include <linux/init.h> -#include <linux/interrupt.h> -#include <linux/slab.h> -#include <linux/gpio.h> -#include <linux/io.h> -#include <linux/sizes.h> -#include <linux/mfd/syscon.h> -#include <linux/mfd/syscon/atmel-mc.h> -#include <linux/of.h> -#include <linux/of_device.h> -#include <linux/of_gpio.h> -#include <linux/pci.h> -#include <linux/regmap.h> - -#include <pcmcia/ss.h> - -/* - * A0..A10 work in each range; A23 indicates I/O space; A25 is CFRNW; - * some other bit in {A24,A22..A11} is nREG to flag memory access - * (vs attributes). So more than 2KB/region would just be waste. - * Note: These are offsets from the physical base address. - */ -#define CF_ATTR_PHYS (0) -#define CF_IO_PHYS (1 << 23) -#define CF_MEM_PHYS (0x017ff800) - -struct at91_cf_data { - int irq_pin; /* I/O IRQ */ - int det_pin; /* Card detect */ - int vcc_pin; /* power switching */ - int rst_pin; /* card reset */ - u8 chipselect; /* EBI Chip Select number */ - u8 flags; -#define AT91_CF_TRUE_IDE 0x01 -#define AT91_IDE_SWAP_A0_A2 0x02 -}; - -struct regmap *mc; - -/*--------------------------------------------------------------------------*/ - -struct at91_cf_socket { - struct pcmcia_socket socket; - - unsigned present:1; - - struct platform_device *pdev; - struct at91_cf_data *board; - - unsigned long phys_baseaddr; -}; - -static inline int at91_cf_present(struct at91_cf_socket *cf) -{ - return !gpio_get_value(cf->board->det_pin); -} - -/*--------------------------------------------------------------------------*/ - -static int at91_cf_ss_init(struct pcmcia_socket *s) -{ - return 0; -} - -static irqreturn_t at91_cf_irq(int irq, void *_cf) -{ - struct at91_cf_socket *cf = _cf; - - if (irq == gpio_to_irq(cf->board->det_pin)) { - unsigned present = at91_cf_present(cf); - - /* kick pccard as needed */ - if (present != cf->present) { - cf->present = present; - dev_dbg(&cf->pdev->dev, "card %s\n", - present ? "present" : "gone"); - pcmcia_parse_events(&cf->socket, SS_DETECT); - } - } - - return IRQ_HANDLED; -} - -static int at91_cf_get_status(struct pcmcia_socket *s, u_int *sp) -{ - struct at91_cf_socket *cf; - - if (!sp) - return -EINVAL; - - cf = container_of(s, struct at91_cf_socket, socket); - - /* NOTE: CF is always 3VCARD */ - if (at91_cf_present(cf)) { - int rdy = gpio_is_valid(cf->board->irq_pin); /* RDY/nIRQ */ - int vcc = gpio_is_valid(cf->board->vcc_pin); - - *sp = SS_DETECT | SS_3VCARD; - if (!rdy || gpio_get_value(cf->board->irq_pin)) - *sp |= SS_READY; - if (!vcc || gpio_get_value(cf->board->vcc_pin)) - *sp |= SS_POWERON; - } else - *sp = 0; - - return 0; -} - -static int -at91_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s) -{ - struct at91_cf_socket *cf; - - cf = container_of(sock, struct at91_cf_socket, socket); - - /* switch Vcc if needed and possible */ - if (gpio_is_valid(cf->board->vcc_pin)) { - switch (s->Vcc) { - case 0: - gpio_set_value(cf->board->vcc_pin, 0); - break; - case 33: - gpio_set_value(cf->board->vcc_pin, 1); - break; - default: - return -EINVAL; - } - } - - /* toggle reset if needed */ - gpio_set_value(cf->board->rst_pin, s->flags & SS_RESET); - - dev_dbg(&cf->pdev->dev, "Vcc %d, io_irq %d, flags %04x csc %04x\n", - s->Vcc, s->io_irq, s->flags, s->csc_mask); - - return 0; -} - -static int at91_cf_ss_suspend(struct pcmcia_socket *s) -{ - return at91_cf_set_socket(s, &dead_socket); -} - -/* we already mapped the I/O region */ -static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io) -{ - struct at91_cf_socket *cf; - u32 csr; - - cf = container_of(s, struct at91_cf_socket, socket); - io->flags &= (MAP_ACTIVE | MAP_16BIT | MAP_AUTOSZ); - - /* - * Use 16 bit accesses unless/until we need 8-bit i/o space. - * - * NOTE: this CF controller ignores IOIS16, so we can't really do - * MAP_AUTOSZ. The 16bit mode allows single byte access on either - * D0-D7 (even addr) or D8-D15 (odd), so it's close enough for many - * purposes (and handles ide-cs). - * - * The 8bit mode is needed for odd byte access on D0-D7. It seems - * some cards only like that way to get at the odd byte, despite - * CF 3.0 spec table 35 also giving the D8-D15 option. - */ - if (!(io->flags & (MAP_16BIT | MAP_AUTOSZ))) { - csr = AT91_MC_SMC_DBW_8; - dev_dbg(&cf->pdev->dev, "8bit i/o bus\n"); - } else { - csr = AT91_MC_SMC_DBW_16; - dev_dbg(&cf->pdev->dev, "16bit i/o bus\n"); - } - regmap_update_bits(mc, AT91_MC_SMC_CSR(cf->board->chipselect), - AT91_MC_SMC_DBW, csr); - - io->start = cf->socket.io_offset; - io->stop = io->start + SZ_2K - 1; - - return 0; -} - -/* pcmcia layer maps/unmaps mem regions */ -static int -at91_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map) -{ - struct at91_cf_socket *cf; - - if (map->card_start) - return -EINVAL; - - cf = container_of(s, struct at91_cf_socket, socket); - - map->flags &= (MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT); - if (map->flags & MAP_ATTRIB) - map->static_start = cf->phys_baseaddr + CF_ATTR_PHYS; - else - map->static_start = cf->phys_baseaddr + CF_MEM_PHYS; - - return 0; -} - -static struct pccard_operations at91_cf_ops = { - .init = at91_cf_ss_init, - .suspend = at91_cf_ss_suspend, - .get_status = at91_cf_get_status, - .set_socket = at91_cf_set_socket, - .set_io_map = at91_cf_set_io_map, - .set_mem_map = at91_cf_set_mem_map, -}; - -/*--------------------------------------------------------------------------*/ - -static const struct of_device_id at91_cf_dt_ids[] = { - { .compatible = "atmel,at91rm9200-cf" }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, at91_cf_dt_ids); - -static int at91_cf_probe(struct platform_device *pdev) -{ - struct at91_cf_socket *cf; - struct at91_cf_data *board; - struct resource *io; - struct resource realio; - int status; - - board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL); - if (!board) - return -ENOMEM; - - board->irq_pin = of_get_gpio(pdev->dev.of_node, 0); - board->det_pin = of_get_gpio(pdev->dev.of_node, 1); - board->vcc_pin = of_get_gpio(pdev->dev.of_node, 2); - board->rst_pin = of_get_gpio(pdev->dev.of_node, 3); - - mc = syscon_regmap_lookup_by_compatible("atmel,at91rm9200-sdramc"); - if (IS_ERR(mc)) - return PTR_ERR(mc); - - if (!gpio_is_valid(board->det_pin) || !gpio_is_valid(board->rst_pin)) - return -ENODEV; - - io = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!io) - return -ENODEV; - - cf = devm_kzalloc(&pdev->dev, sizeof(*cf), GFP_KERNEL); - if (!cf) - return -ENOMEM; - - cf->board = board; - cf->pdev = pdev; - cf->phys_baseaddr = io->start; - platform_set_drvdata(pdev, cf); - - /* must be a GPIO; ergo must trigger on both edges */ - status = devm_gpio_request(&pdev->dev, board->det_pin, "cf_det"); - if (status < 0) - return status; - - status = devm_request_irq(&pdev->dev, gpio_to_irq(board->det_pin), - at91_cf_irq, 0, "at91_cf detect", cf); - if (status < 0) - return status; - - device_init_wakeup(&pdev->dev, 1); - - status = devm_gpio_request(&pdev->dev, board->rst_pin, "cf_rst"); - if (status < 0) - goto fail0a; - - if (gpio_is_valid(board->vcc_pin)) { - status = devm_gpio_request(&pdev->dev, board->vcc_pin, "cf_vcc"); - if (status < 0) - goto fail0a; - } - - /* - * The card driver will request this irq later as needed. - * but it causes lots of "irqNN: nobody cared" messages - * unless we report that we handle everything (sigh). - * (Note: DK board doesn't wire the IRQ pin...) - */ - if (gpio_is_valid(board->irq_pin)) { - status = devm_gpio_request(&pdev->dev, board->irq_pin, "cf_irq"); - if (status < 0) - goto fail0a; - - status = devm_request_irq(&pdev->dev, gpio_to_irq(board->irq_pin), - at91_cf_irq, IRQF_SHARED, "at91_cf", cf); - if (status < 0) - goto fail0a; - cf->socket.pci_irq = gpio_to_irq(board->irq_pin); - } else - cf->socket.pci_irq = nr_irqs + 1; - - /* - * pcmcia layer only remaps "real" memory not iospace - * io_offset is set to 0x10000 to avoid the check in static_find_io(). - * */ - cf->socket.io_offset = 0x10000; - realio.start = cf->socket.io_offset; - realio.end = realio.start + SZ_64K - 1; - status = pci_remap_iospace(&realio, cf->phys_baseaddr + CF_IO_PHYS); - if (status) - goto fail0a; - - /* reserve chip-select regions */ - if (!devm_request_mem_region(&pdev->dev, io->start, resource_size(io), "at91_cf")) { - status = -ENXIO; - goto fail0a; - } - - dev_info(&pdev->dev, "irqs det #%d, io #%d\n", - gpio_to_irq(board->det_pin), gpio_to_irq(board->irq_pin)); - - cf->socket.owner = THIS_MODULE; - cf->socket.dev.parent = &pdev->dev; - cf->socket.ops = &at91_cf_ops; - cf->socket.resource_ops = &pccard_static_ops; - cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP - | SS_CAP_MEM_ALIGN; - cf->socket.map_size = SZ_2K; - cf->socket.io[0].res = io; - - status = pcmcia_register_socket(&cf->socket); - if (status < 0) - goto fail0a; - - return 0; - -fail0a: - device_init_wakeup(&pdev->dev, 0); - return status; -} - -static int at91_cf_remove(struct platform_device *pdev) -{ - struct at91_cf_socket *cf = platform_get_drvdata(pdev); - - pcmcia_unregister_socket(&cf->socket); - device_init_wakeup(&pdev->dev, 0); - - return 0; -} - -#ifdef CONFIG_PM - -static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg) -{ - struct at91_cf_socket *cf = platform_get_drvdata(pdev); - struct at91_cf_data *board = cf->board; - - if (device_may_wakeup(&pdev->dev)) { - enable_irq_wake(gpio_to_irq(board->det_pin)); - if (gpio_is_valid(board->irq_pin)) - enable_irq_wake(gpio_to_irq(board->irq_pin)); - } - return 0; -} - -static int at91_cf_resume(struct platform_device *pdev) -{ - struct at91_cf_socket *cf = platform_get_drvdata(pdev); - struct at91_cf_data *board = cf->board; - - if (device_may_wakeup(&pdev->dev)) { - disable_irq_wake(gpio_to_irq(board->det_pin)); - if (gpio_is_valid(board->irq_pin)) - disable_irq_wake(gpio_to_irq(board->irq_pin)); - } - - return 0; -} - -#else -#define at91_cf_suspend NULL -#define at91_cf_resume NULL -#endif - -static struct platform_driver at91_cf_driver = { - .driver = { - .name = "at91_cf", - .of_match_table = at91_cf_dt_ids, - }, - .probe = at91_cf_probe, - .remove = at91_cf_remove, - .suspend = at91_cf_suspend, - .resume = at91_cf_resume, -}; - -module_platform_driver(at91_cf_driver); - -MODULE_DESCRIPTION("AT91 Compact Flash Driver"); -MODULE_AUTHOR("David Brownell"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:at91_cf"); diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c index 192c9049d654..a335748bdef5 100644 --- a/drivers/pcmcia/i82092.c +++ b/drivers/pcmcia/i82092.c @@ -661,12 +661,12 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, return 0; } -static int i82092aa_module_init(void) +static int __init i82092aa_module_init(void) { return pci_register_driver(&i82092aa_pci_driver); } -static void i82092aa_module_exit(void) +static void __exit i82092aa_module_exit(void) { pci_unregister_driver(&i82092aa_pci_driver); if (sockets[0].io_base > 0) diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c index 1972a8f6fa8e..d3f827d4224a 100644 --- a/drivers/pcmcia/omap_cf.c +++ b/drivers/pcmcia/omap_cf.c @@ -124,8 +124,6 @@ static int omap_cf_get_status(struct pcmcia_socket *s, u_int *sp) static int omap_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s) { - u16 control; - /* REVISIT some non-OSK boards may support power switching */ switch (s->Vcc) { case 0: @@ -135,7 +133,7 @@ omap_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s) return -EINVAL; } - control = omap_readw(CF_CONTROL); + omap_readw(CF_CONTROL); if (s->flags & SS_RESET) omap_writew(CF_CONTROL_RESET, CF_CONTROL); else diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c index 47b060c57418..c2b6e828c2c6 100644 --- a/drivers/pcmcia/sa1100_generic.c +++ b/drivers/pcmcia/sa1100_generic.c @@ -125,7 +125,7 @@ static int sa11x0_drv_pcmcia_legacy_probe(struct platform_device *dev) return ret; } -static int sa11x0_drv_pcmcia_legacy_remove(struct platform_device *dev) +static void sa11x0_drv_pcmcia_legacy_remove(struct platform_device *dev) { struct skt_dev_info *sinfo = platform_get_drvdata(dev); int i; @@ -134,8 +134,6 @@ static int sa11x0_drv_pcmcia_legacy_remove(struct platform_device *dev) for (i = 0; i < sinfo->nskt; i++) soc_pcmcia_remove_one(&sinfo->skt[i]); - - return 0; } static int sa11x0_drv_pcmcia_probe(struct platform_device *pdev) @@ -167,8 +165,10 @@ static int sa11x0_drv_pcmcia_remove(struct platform_device *dev) { struct soc_pcmcia_socket *skt; - if (dev->id == -1) - return sa11x0_drv_pcmcia_legacy_remove(dev); + if (dev->id == -1) { + sa11x0_drv_pcmcia_legacy_remove(dev); + return 0; + } skt = platform_get_drvdata(dev); diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c deleted file mode 100644 index 177d77892144..000000000000 --- a/drivers/pcmcia/vrc4171_card.c +++ /dev/null @@ -1,745 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * vrc4171_card.c, NEC VRC4171 Card Controller driver for Socket Services. - * - * Copyright (C) 2003-2005 Yoichi Yuasa <yuasa@linux-mips.org> - */ -#include <linux/init.h> -#include <linux/ioport.h> -#include <linux/interrupt.h> -#include <linux/module.h> -#include <linux/spinlock.h> -#include <linux/types.h> -#include <linux/platform_device.h> - -#include <asm/io.h> - -#include <pcmcia/ss.h> - -#include "i82365.h" - -MODULE_DESCRIPTION("NEC VRC4171 Card Controllers driver for Socket Services"); -MODULE_AUTHOR("Yoichi Yuasa <yuasa@linux-mips.org>"); -MODULE_LICENSE("GPL"); - -#define CARD_MAX_SLOTS 2 -#define CARD_SLOTA 0 -#define CARD_SLOTB 1 -#define CARD_SLOTB_OFFSET 0x40 - -#define CARD_MEM_START 0x10000000 -#define CARD_MEM_END 0x13ffffff -#define CARD_MAX_MEM_OFFSET 0x3ffffff -#define CARD_MAX_MEM_SPEED 1000 - -#define CARD_CONTROLLER_INDEX 0x03e0 -#define CARD_CONTROLLER_DATA 0x03e1 - /* Power register */ - #define VPP_GET_VCC 0x01 - #define POWER_ENABLE 0x10 - #define CARD_VOLTAGE_SENSE 0x1f - #define VCC_3VORXV_CAPABLE 0x00 - #define VCC_XV_ONLY 0x01 - #define VCC_3V_CAPABLE 0x02 - #define VCC_5V_ONLY 0x03 - #define CARD_VOLTAGE_SELECT 0x2f - #define VCC_3V 0x01 - #define VCC_5V 0x00 - #define VCC_XV 0x02 - #define VCC_STATUS_3V 0x02 - #define VCC_STATUS_5V 0x01 - #define VCC_STATUS_XV 0x03 - #define GLOBAL_CONTROL 0x1e - #define EXWRBK 0x04 - #define IRQPM_EN 0x08 - #define CLRPMIRQ 0x10 - -#define INTERRUPT_STATUS 0x05fa - #define IRQ_A 0x02 - #define IRQ_B 0x04 - -#define CONFIGURATION1 0x05fe - #define SLOTB_CONFIG 0xc000 - #define SLOTB_NONE 0x0000 - #define SLOTB_PCCARD 0x4000 - #define SLOTB_CF 0x8000 - #define SLOTB_FLASHROM 0xc000 - -#define CARD_CONTROLLER_START CARD_CONTROLLER_INDEX -#define CARD_CONTROLLER_END CARD_CONTROLLER_DATA - -#define IO_MAX_MAPS 2 -#define MEM_MAX_MAPS 5 - -enum vrc4171_slot { - SLOT_PROBE = 0, - SLOT_NOPROBE_IO, - SLOT_NOPROBE_MEM, - SLOT_NOPROBE_ALL, - SLOT_INITIALIZED, -}; - -enum vrc4171_slotb { - SLOTB_IS_NONE, - SLOTB_IS_PCCARD, - SLOTB_IS_CF, - SLOTB_IS_FLASHROM, -}; - -struct vrc4171_socket { - enum vrc4171_slot slot; - struct pcmcia_socket pcmcia_socket; - char name[24]; - int csc_irq; - int io_irq; - spinlock_t lock; -}; - -static struct vrc4171_socket vrc4171_sockets[CARD_MAX_SLOTS]; -static enum vrc4171_slotb vrc4171_slotb = SLOTB_IS_NONE; -static char vrc4171_card_name[] = "NEC VRC4171 Card Controller"; -static unsigned int vrc4171_irq; -static uint16_t vrc4171_irq_mask = 0xdeb8; - -static struct resource vrc4171_card_resource[3] = { - { .name = vrc4171_card_name, - .start = CARD_CONTROLLER_START, - .end = CARD_CONTROLLER_END, - .flags = IORESOURCE_IO, }, - { .name = vrc4171_card_name, - .start = INTERRUPT_STATUS, - .end = INTERRUPT_STATUS, - .flags = IORESOURCE_IO, }, - { .name = vrc4171_card_name, - .start = CONFIGURATION1, - .end = CONFIGURATION1, - .flags = IORESOURCE_IO, }, -}; - -static struct platform_device vrc4171_card_device = { - .name = vrc4171_card_name, - .id = 0, - .num_resources = 3, - .resource = vrc4171_card_resource, -}; - -static inline uint16_t vrc4171_get_irq_status(void) -{ - return inw(INTERRUPT_STATUS); -} - -static inline void vrc4171_set_multifunction_pin(enum vrc4171_slotb config) -{ - uint16_t config1; - - config1 = inw(CONFIGURATION1); - config1 &= ~SLOTB_CONFIG; - - switch (config) { - case SLOTB_IS_NONE: - config1 |= SLOTB_NONE; - break; - case SLOTB_IS_PCCARD: - config1 |= SLOTB_PCCARD; - break; - case SLOTB_IS_CF: - config1 |= SLOTB_CF; - break; - case SLOTB_IS_FLASHROM: - config1 |= SLOTB_FLASHROM; - break; - default: - break; - } - - outw(config1, CONFIGURATION1); -} - -static inline uint8_t exca_read_byte(int slot, uint8_t index) -{ - if (slot == CARD_SLOTB) - index += CARD_SLOTB_OFFSET; - - outb(index, CARD_CONTROLLER_INDEX); - return inb(CARD_CONTROLLER_DATA); -} - -static inline uint16_t exca_read_word(int slot, uint8_t index) -{ - uint16_t data; - - if (slot == CARD_SLOTB) - index += CARD_SLOTB_OFFSET; - - outb(index++, CARD_CONTROLLER_INDEX); - data = inb(CARD_CONTROLLER_DATA); - - outb(index, CARD_CONTROLLER_INDEX); - data |= ((uint16_t)inb(CARD_CONTROLLER_DATA)) << 8; - - return data; -} - -static inline uint8_t exca_write_byte(int slot, uint8_t index, uint8_t data) -{ - if (slot == CARD_SLOTB) - index += CARD_SLOTB_OFFSET; - - outb(index, CARD_CONTROLLER_INDEX); - outb(data, CARD_CONTROLLER_DATA); - - return data; -} - -static inline uint16_t exca_write_word(int slot, uint8_t index, uint16_t data) -{ - if (slot == CARD_SLOTB) - index += CARD_SLOTB_OFFSET; - - outb(index++, CARD_CONTROLLER_INDEX); - outb(data, CARD_CONTROLLER_DATA); - - outb(index, CARD_CONTROLLER_INDEX); - outb((uint8_t)(data >> 8), CARD_CONTROLLER_DATA); - - return data; -} - -static inline int search_nonuse_irq(void) -{ - int i; - - for (i = 0; i < 16; i++) { - if (vrc4171_irq_mask & (1 << i)) { - vrc4171_irq_mask &= ~(1 << i); - return i; - } - } - - return -1; -} - -static int pccard_init(struct pcmcia_socket *sock) -{ - struct vrc4171_socket *socket; - unsigned int slot; - - sock->features |= SS_CAP_PCCARD | SS_CAP_PAGE_REGS; - sock->irq_mask = 0; - sock->map_size = 0x1000; - sock->pci_irq = vrc4171_irq; - - slot = sock->sock; - socket = &vrc4171_sockets[slot]; - socket->csc_irq = search_nonuse_irq(); - socket->io_irq = search_nonuse_irq(); - spin_lock_init(&socket->lock); - - return 0; -} - -static int pccard_get_status(struct pcmcia_socket *sock, u_int *value) -{ - unsigned int slot; - uint8_t status, sense; - u_int val = 0; - - if (sock == NULL || sock->sock >= CARD_MAX_SLOTS || value == NULL) - return -EINVAL; - - slot = sock->sock; - - status = exca_read_byte(slot, I365_STATUS); - if (exca_read_byte(slot, I365_INTCTL) & I365_PC_IOCARD) { - if (status & I365_CS_STSCHG) - val |= SS_STSCHG; - } else { - if (!(status & I365_CS_BVD1)) - val |= SS_BATDEAD; - else if ((status & (I365_CS_BVD1 | I365_CS_BVD2)) == I365_CS_BVD1) - val |= SS_BATWARN; - } - if ((status & I365_CS_DETECT) == I365_CS_DETECT) - val |= SS_DETECT; - if (status & I365_CS_WRPROT) - val |= SS_WRPROT; - if (status & I365_CS_READY) - val |= SS_READY; - if (status & I365_CS_POWERON) - val |= SS_POWERON; - - sense = exca_read_byte(slot, CARD_VOLTAGE_SENSE); - switch (sense) { - case VCC_3VORXV_CAPABLE: - val |= SS_3VCARD | SS_XVCARD; - break; - case VCC_XV_ONLY: - val |= SS_XVCARD; - break; - case VCC_3V_CAPABLE: - val |= SS_3VCARD; - break; - default: - /* 5V only */ - break; - } - - *value = val; - - return 0; -} - -static inline uint8_t set_Vcc_value(u_char Vcc) -{ - switch (Vcc) { - case 33: - return VCC_3V; - case 50: - return VCC_5V; - } - - /* Small voltage is chosen for safety. */ - return VCC_3V; -} - -static int pccard_set_socket(struct pcmcia_socket *sock, socket_state_t *state) -{ - struct vrc4171_socket *socket; - unsigned int slot; - uint8_t voltage, power, control, cscint; - - if (sock == NULL || sock->sock >= CARD_MAX_SLOTS || - (state->Vpp != state->Vcc && state->Vpp != 0) || - (state->Vcc != 50 && state->Vcc != 33 && state->Vcc != 0)) - return -EINVAL; - - slot = sock->sock; - socket = &vrc4171_sockets[slot]; - - spin_lock_irq(&socket->lock); - - voltage = set_Vcc_value(state->Vcc); - exca_write_byte(slot, CARD_VOLTAGE_SELECT, voltage); - - power = POWER_ENABLE; - if (state->Vpp == state->Vcc) - power |= VPP_GET_VCC; - if (state->flags & SS_OUTPUT_ENA) - power |= I365_PWR_OUT; - exca_write_byte(slot, I365_POWER, power); - - control = 0; - if (state->io_irq != 0) - control |= socket->io_irq; - if (state->flags & SS_IOCARD) - control |= I365_PC_IOCARD; - if (state->flags & SS_RESET) - control &= ~I365_PC_RESET; - else - control |= I365_PC_RESET; - exca_write_byte(slot, I365_INTCTL, control); - - cscint = 0; - exca_write_byte(slot, I365_CSCINT, cscint); - exca_read_byte(slot, I365_CSC); /* clear CardStatus change */ - if (state->csc_mask != 0) - cscint |= socket->csc_irq << 8; - if (state->flags & SS_IOCARD) { - if (state->csc_mask & SS_STSCHG) - cscint |= I365_CSC_STSCHG; - } else { - if (state->csc_mask & SS_BATDEAD) - cscint |= I365_CSC_BVD1; - if (state->csc_mask & SS_BATWARN) - cscint |= I365_CSC_BVD2; - } - if (state->csc_mask & SS_READY) - cscint |= I365_CSC_READY; - if (state->csc_mask & SS_DETECT) - cscint |= I365_CSC_DETECT; - exca_write_byte(slot, I365_CSCINT, cscint); - - spin_unlock_irq(&socket->lock); - - return 0; -} - -static int pccard_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io) -{ - unsigned int slot; - uint8_t ioctl, addrwin; - u_char map; - - if (sock == NULL || sock->sock >= CARD_MAX_SLOTS || - io == NULL || io->map >= IO_MAX_MAPS || - io->start > 0xffff || io->stop > 0xffff || io->start > io->stop) - return -EINVAL; - - slot = sock->sock; - map = io->map; - - addrwin = exca_read_byte(slot, I365_ADDRWIN); - if (addrwin & I365_ENA_IO(map)) { - addrwin &= ~I365_ENA_IO(map); - exca_write_byte(slot, I365_ADDRWIN, addrwin); - } - - exca_write_word(slot, I365_IO(map)+I365_W_START, io->start); - exca_write_word(slot, I365_IO(map)+I365_W_STOP, io->stop); - - ioctl = 0; - if (io->speed > 0) - ioctl |= I365_IOCTL_WAIT(map); - if (io->flags & MAP_16BIT) - ioctl |= I365_IOCTL_16BIT(map); - if (io->flags & MAP_AUTOSZ) - ioctl |= I365_IOCTL_IOCS16(map); - if (io->flags & MAP_0WS) - ioctl |= I365_IOCTL_0WS(map); - exca_write_byte(slot, I365_IOCTL, ioctl); - - if (io->flags & MAP_ACTIVE) { - addrwin |= I365_ENA_IO(map); - exca_write_byte(slot, I365_ADDRWIN, addrwin); - } - - return 0; -} - -static int pccard_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *mem) -{ - unsigned int slot; - uint16_t start, stop, offset; - uint8_t addrwin; - u_char map; - - if (sock == NULL || sock->sock >= CARD_MAX_SLOTS || - mem == NULL || mem->map >= MEM_MAX_MAPS || - mem->res->start < CARD_MEM_START || mem->res->start > CARD_MEM_END || - mem->res->end < CARD_MEM_START || mem->res->end > CARD_MEM_END || - mem->res->start > mem->res->end || - mem->card_start > CARD_MAX_MEM_OFFSET || - mem->speed > CARD_MAX_MEM_SPEED) - return -EINVAL; - - slot = sock->sock; - map = mem->map; - - addrwin = exca_read_byte(slot, I365_ADDRWIN); - if (addrwin & I365_ENA_MEM(map)) { - addrwin &= ~I365_ENA_MEM(map); - exca_write_byte(slot, I365_ADDRWIN, addrwin); - } - - start = (mem->res->start >> 12) & 0x3fff; - if (mem->flags & MAP_16BIT) - start |= I365_MEM_16BIT; - exca_write_word(slot, I365_MEM(map)+I365_W_START, start); - - stop = (mem->res->end >> 12) & 0x3fff; - switch (mem->speed) { - case 0: - break; - case 1: - stop |= I365_MEM_WS0; - break; - case 2: - stop |= I365_MEM_WS1; - break; - default: - stop |= I365_MEM_WS0 | I365_MEM_WS1; - break; - } - exca_write_word(slot, I365_MEM(map)+I365_W_STOP, stop); - - offset = (mem->card_start >> 12) & 0x3fff; - if (mem->flags & MAP_ATTRIB) - offset |= I365_MEM_REG; - if (mem->flags & MAP_WRPROT) - offset |= I365_MEM_WRPROT; - exca_write_word(slot, I365_MEM(map)+I365_W_OFF, offset); - - if (mem->flags & MAP_ACTIVE) { - addrwin |= I365_ENA_MEM(map); - exca_write_byte(slot, I365_ADDRWIN, addrwin); - } - - return 0; -} - -static struct pccard_operations vrc4171_pccard_operations = { - .init = pccard_init, - .get_status = pccard_get_status, - .set_socket = pccard_set_socket, - .set_io_map = pccard_set_io_map, - .set_mem_map = pccard_set_mem_map, -}; - -static inline unsigned int get_events(int slot) -{ - unsigned int events = 0; - uint8_t status, csc; - - status = exca_read_byte(slot, I365_STATUS); - csc = exca_read_byte(slot, I365_CSC); - - if (exca_read_byte(slot, I365_INTCTL) & I365_PC_IOCARD) { - if ((csc & I365_CSC_STSCHG) && (status & I365_CS_STSCHG)) - events |= SS_STSCHG; - } else { - if (csc & (I365_CSC_BVD1 | I365_CSC_BVD2)) { - if (!(status & I365_CS_BVD1)) - events |= SS_BATDEAD; - else if ((status & (I365_CS_BVD1 | I365_CS_BVD2)) == I365_CS_BVD1) - events |= SS_BATWARN; - } - } - if ((csc & I365_CSC_READY) && (status & I365_CS_READY)) - events |= SS_READY; - if ((csc & I365_CSC_DETECT) && ((status & I365_CS_DETECT) == I365_CS_DETECT)) - events |= SS_DETECT; - - return events; -} - -static irqreturn_t pccard_interrupt(int irq, void *dev_id) -{ - struct vrc4171_socket *socket; - unsigned int events; - irqreturn_t retval = IRQ_NONE; - uint16_t status; - - status = vrc4171_get_irq_status(); - if (status & IRQ_A) { - socket = &vrc4171_sockets[CARD_SLOTA]; - if (socket->slot == SLOT_INITIALIZED) { - if (status & (1 << socket->csc_irq)) { - events = get_events(CARD_SLOTA); - if (events != 0) { - pcmcia_parse_events(&socket->pcmcia_socket, events); - retval = IRQ_HANDLED; - } - } - } - } - - if (status & IRQ_B) { - socket = &vrc4171_sockets[CARD_SLOTB]; - if (socket->slot == SLOT_INITIALIZED) { - if (status & (1 << socket->csc_irq)) { - events = get_events(CARD_SLOTB); - if (events != 0) { - pcmcia_parse_events(&socket->pcmcia_socket, events); - retval = IRQ_HANDLED; - } - } - } - } - - return retval; -} - -static inline void reserve_using_irq(int slot) -{ - unsigned int irq; - - irq = exca_read_byte(slot, I365_INTCTL); - irq &= 0x0f; - vrc4171_irq_mask &= ~(1 << irq); - - irq = exca_read_byte(slot, I365_CSCINT); - irq = (irq & 0xf0) >> 4; - vrc4171_irq_mask &= ~(1 << irq); -} - -static int vrc4171_add_sockets(void) -{ - struct vrc4171_socket *socket; - int slot, retval; - - for (slot = 0; slot < CARD_MAX_SLOTS; slot++) { - if (slot == CARD_SLOTB && vrc4171_slotb == SLOTB_IS_NONE) - continue; - - socket = &vrc4171_sockets[slot]; - if (socket->slot != SLOT_PROBE) { - uint8_t addrwin; - - switch (socket->slot) { - case SLOT_NOPROBE_MEM: - addrwin = exca_read_byte(slot, I365_ADDRWIN); - addrwin &= 0x1f; - exca_write_byte(slot, I365_ADDRWIN, addrwin); - break; - case SLOT_NOPROBE_IO: - addrwin = exca_read_byte(slot, I365_ADDRWIN); - addrwin &= 0xc0; - exca_write_byte(slot, I365_ADDRWIN, addrwin); - break; - default: - break; - } - - reserve_using_irq(slot); - continue; - } - - sprintf(socket->name, "NEC VRC4171 Card Slot %1c", 'A' + slot); - socket->pcmcia_socket.dev.parent = &vrc4171_card_device.dev; - socket->pcmcia_socket.ops = &vrc4171_pccard_operations; - socket->pcmcia_socket.owner = THIS_MODULE; - - retval = pcmcia_register_socket(&socket->pcmcia_socket); - if (retval < 0) - return retval; - - exca_write_byte(slot, I365_ADDRWIN, 0); - exca_write_byte(slot, GLOBAL_CONTROL, 0); - - socket->slot = SLOT_INITIALIZED; - } - - return 0; -} - -static void vrc4171_remove_sockets(void) -{ - struct vrc4171_socket *socket; - int slot; - - for (slot = 0; slot < CARD_MAX_SLOTS; slot++) { - if (slot == CARD_SLOTB && vrc4171_slotb == SLOTB_IS_NONE) - continue; - - socket = &vrc4171_sockets[slot]; - if (socket->slot == SLOT_INITIALIZED) - pcmcia_unregister_socket(&socket->pcmcia_socket); - - socket->slot = SLOT_PROBE; - } -} - -static int vrc4171_card_setup(char *options) -{ - if (options == NULL || *options == '\0') - return 1; - - if (strncmp(options, "irq:", 4) == 0) { - int irq; - options += 4; - irq = simple_strtoul(options, &options, 0); - if (irq >= 0 && irq < nr_irqs) - vrc4171_irq = irq; - - if (*options != ',') - return 1; - options++; - } - - if (strncmp(options, "slota:", 6) == 0) { - options += 6; - if (*options != '\0') { - if (strncmp(options, "memnoprobe", 10) == 0) { - vrc4171_sockets[CARD_SLOTA].slot = SLOT_NOPROBE_MEM; - options += 10; - } else if (strncmp(options, "ionoprobe", 9) == 0) { - vrc4171_sockets[CARD_SLOTA].slot = SLOT_NOPROBE_IO; - options += 9; - } else if ( strncmp(options, "noprobe", 7) == 0) { - vrc4171_sockets[CARD_SLOTA].slot = SLOT_NOPROBE_ALL; - options += 7; - } - - if (*options != ',') - return 1; - options++; - } else - return 1; - - } - - if (strncmp(options, "slotb:", 6) == 0) { - options += 6; - if (*options != '\0') { - if (strncmp(options, "pccard", 6) == 0) { - vrc4171_slotb = SLOTB_IS_PCCARD; - options += 6; - } else if (strncmp(options, "cf", 2) == 0) { - vrc4171_slotb = SLOTB_IS_CF; - options += 2; - } else if (strncmp(options, "flashrom", 8) == 0) { - vrc4171_slotb = SLOTB_IS_FLASHROM; - options += 8; - } else if (strncmp(options, "none", 4) == 0) { - vrc4171_slotb = SLOTB_IS_NONE; - options += 4; - } - - if (*options != ',') - return 1; - options++; - - if (strncmp(options, "memnoprobe", 10) == 0) - vrc4171_sockets[CARD_SLOTB].slot = SLOT_NOPROBE_MEM; - if (strncmp(options, "ionoprobe", 9) == 0) - vrc4171_sockets[CARD_SLOTB].slot = SLOT_NOPROBE_IO; - if (strncmp(options, "noprobe", 7) == 0) - vrc4171_sockets[CARD_SLOTB].slot = SLOT_NOPROBE_ALL; - } - } - - return 1; -} - -__setup("vrc4171_card=", vrc4171_card_setup); - -static struct platform_driver vrc4171_card_driver = { - .driver = { - .name = vrc4171_card_name, - }, -}; - -static int vrc4171_card_init(void) -{ - int retval; - - retval = platform_driver_register(&vrc4171_card_driver); - if (retval < 0) - return retval; - - retval = platform_device_register(&vrc4171_card_device); - if (retval < 0) { - platform_driver_unregister(&vrc4171_card_driver); - return retval; - } - - vrc4171_set_multifunction_pin(vrc4171_slotb); - - retval = vrc4171_add_sockets(); - if (retval == 0) - retval = request_irq(vrc4171_irq, pccard_interrupt, IRQF_SHARED, - vrc4171_card_name, vrc4171_sockets); - - if (retval < 0) { - vrc4171_remove_sockets(); - platform_device_unregister(&vrc4171_card_device); - platform_driver_unregister(&vrc4171_card_driver); - return retval; - } - - printk(KERN_INFO "%s, connected to IRQ %d\n", - vrc4171_card_driver.driver.name, vrc4171_irq); - - return 0; -} - -static void vrc4171_card_exit(void) -{ - free_irq(vrc4171_irq, vrc4171_sockets); - vrc4171_remove_sockets(); - platform_device_unregister(&vrc4171_card_device); - platform_driver_unregister(&vrc4171_card_driver); -} - -module_init(vrc4171_card_init); -module_exit(vrc4171_card_exit); |