^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * IPWireless 3G PCMCIA Network Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Original code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * by Stephen Blackheath <stephen@blacksapphire.com>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Ben Martel <benm@symmetric.co.nz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyrighted as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Copyright (C) 2004 by Symmetric Systems Ltd (NZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Various driver changes and rewrites, port to new kernels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Copyright (C) 2006-2007 Jiri Kosina
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Misc code cleanups and updates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Copyright (C) 2007 David Sterba
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "hardware.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "network.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "main.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "tty.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <pcmcia/cisreg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <pcmcia/device_id.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <pcmcia/ss.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <pcmcia/ds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static const struct pcmcia_device_id ipw_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) PCMCIA_DEVICE_MANF_CARD(0x02f2, 0x0100),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) PCMCIA_DEVICE_MANF_CARD(0x02f2, 0x0200),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) PCMCIA_DEVICE_NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) MODULE_DEVICE_TABLE(pcmcia, ipw_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static void ipwireless_detach(struct pcmcia_device *link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * Module params
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* Debug mode: more verbose, print sent/recv bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int ipwireless_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) int ipwireless_loopback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int ipwireless_out_queue = 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) module_param_named(debug, ipwireless_debug, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) module_param_named(loopback, ipwireless_loopback, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) module_param_named(out_queue, ipwireless_out_queue, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) MODULE_PARM_DESC(debug, "switch on debug messages [0]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) MODULE_PARM_DESC(loopback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) "debug: enable ras_raw channel [0]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) MODULE_PARM_DESC(out_queue, "debug: set size of outgoing PPP queue [10]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* Executes in process context. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static void signalled_reboot_work(struct work_struct *work_reboot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct ipw_dev *ipw = container_of(work_reboot, struct ipw_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) work_reboot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct pcmcia_device *link = ipw->link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) pcmcia_reset_card(link->socket);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static void signalled_reboot_callback(void *callback_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct ipw_dev *ipw = (struct ipw_dev *) callback_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /* Delegate to process context. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) schedule_work(&ipw->work_reboot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct ipw_dev *ipw = priv_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* 0x40 causes it to generate level mode interrupts. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* 0x04 enables IREQ pin. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) p_dev->config_index |= 0x44;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) p_dev->io_lines = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) ret = pcmcia_request_io(p_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (!request_region(p_dev->resource[0]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) resource_size(p_dev->resource[0]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) IPWIRELESS_PCCARD_NAME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) ret = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) p_dev->resource[2]->flags |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM | WIN_ENABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) ret = pcmcia_request_window(p_dev, p_dev->resource[2], 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) goto exit1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) ret = pcmcia_map_mem_page(p_dev, p_dev->resource[2], p_dev->card_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) goto exit1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) ipw->is_v2_card = resource_size(p_dev->resource[2]) == 0x100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) ipw->common_memory = ioremap(p_dev->resource[2]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) resource_size(p_dev->resource[2]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (!ipw->common_memory) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) goto exit1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if (!request_mem_region(p_dev->resource[2]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) resource_size(p_dev->resource[2]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) IPWIRELESS_PCCARD_NAME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ret = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) goto exit2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) p_dev->resource[3]->flags |= WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_AM |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) WIN_ENABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) p_dev->resource[3]->end = 0; /* this used to be 0x1000 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) ret = pcmcia_request_window(p_dev, p_dev->resource[3], 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) goto exit3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) ret = pcmcia_map_mem_page(p_dev, p_dev->resource[3], 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) goto exit3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) ipw->attr_memory = ioremap(p_dev->resource[3]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) resource_size(p_dev->resource[3]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (!ipw->attr_memory) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) goto exit3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) if (!request_mem_region(p_dev->resource[3]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) resource_size(p_dev->resource[3]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) IPWIRELESS_PCCARD_NAME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ret = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) goto exit4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) exit4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) iounmap(ipw->attr_memory);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) exit3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) release_mem_region(p_dev->resource[2]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) resource_size(p_dev->resource[2]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) exit2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) iounmap(ipw->common_memory);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) exit1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) release_region(p_dev->resource[0]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) resource_size(p_dev->resource[0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) pcmcia_disable_device(p_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static int config_ipwireless(struct ipw_dev *ipw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) struct pcmcia_device *link = ipw->link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) ipw->is_v2_card = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) link->config_flags |= CONF_AUTO_SET_IO | CONF_AUTO_SET_IOMEM |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) CONF_ENABLE_IRQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ret = pcmcia_loop_config(link, ipwireless_probe, ipw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) INIT_WORK(&ipw->work_reboot, signalled_reboot_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) ipwireless_init_hardware_v1(ipw->hardware, link->resource[0]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) ipw->attr_memory, ipw->common_memory,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) ipw->is_v2_card, signalled_reboot_callback,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) ipw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) ret = pcmcia_request_irq(link, ipwireless_interrupt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": Card type %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) ipw->is_v2_card ? "V2/V3" : "V1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) printk(KERN_INFO IPWIRELESS_PCCARD_NAME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) ": I/O ports %pR, irq %d\n", link->resource[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) (unsigned int) link->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (ipw->attr_memory && ipw->common_memory)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) printk(KERN_INFO IPWIRELESS_PCCARD_NAME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ": attr memory %pR, common memory %pR\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) link->resource[3],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) link->resource[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) ipw->network = ipwireless_network_create(ipw->hardware);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) if (!ipw->network)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) ipw->tty = ipwireless_tty_create(ipw->hardware, ipw->network);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (!ipw->tty)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) ipwireless_init_hardware_v2_v3(ipw->hardware);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * Do the RequestConfiguration last, because it enables interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * Then we don't get any interrupts before we're ready for them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) ret = pcmcia_enable_device(link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (ipw->common_memory) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) release_mem_region(link->resource[2]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) resource_size(link->resource[2]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) iounmap(ipw->common_memory);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) if (ipw->attr_memory) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) release_mem_region(link->resource[3]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) resource_size(link->resource[3]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) iounmap(ipw->attr_memory);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) pcmcia_disable_device(link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static void release_ipwireless(struct ipw_dev *ipw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) release_region(ipw->link->resource[0]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) resource_size(ipw->link->resource[0]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) if (ipw->common_memory) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) release_mem_region(ipw->link->resource[2]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) resource_size(ipw->link->resource[2]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) iounmap(ipw->common_memory);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) if (ipw->attr_memory) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) release_mem_region(ipw->link->resource[3]->start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) resource_size(ipw->link->resource[3]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) iounmap(ipw->attr_memory);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) pcmcia_disable_device(ipw->link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * ipwireless_attach() creates an "instance" of the driver, allocating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * local data structures for one device (one interface). The device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * is registered with Card Services.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * The pcmcia_device structure is initialized, but we don't actually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * configure the card at this point -- we wait until we receive a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * card insertion event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static int ipwireless_attach(struct pcmcia_device *link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) struct ipw_dev *ipw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) ipw = kzalloc(sizeof(struct ipw_dev), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if (!ipw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) ipw->link = link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) link->priv = ipw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) ipw->hardware = ipwireless_hardware_create();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) if (!ipw->hardware) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) kfree(ipw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) /* RegisterClient will call config_ipwireless */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) ret = config_ipwireless(ipw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) if (ret != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) ipwireless_detach(link);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) * This deletes a driver "instance". The device is de-registered with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * Card Services. If it has been released, all local data structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) * are freed. Otherwise, the structures will be freed when the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) * is released.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) static void ipwireless_detach(struct pcmcia_device *link)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) struct ipw_dev *ipw = link->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) release_ipwireless(ipw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) if (ipw->tty != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) ipwireless_tty_free(ipw->tty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) if (ipw->network != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) ipwireless_network_free(ipw->network);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) if (ipw->hardware != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) ipwireless_hardware_free(ipw->hardware);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) kfree(ipw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static struct pcmcia_driver me = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) .probe = ipwireless_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) .remove = ipwireless_detach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) .name = IPWIRELESS_PCCARD_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) .id_table = ipw_ids
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) * Module insertion : initialisation of the module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * Register the card with cardmgr...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) static int __init init_ipwireless(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) ret = ipwireless_tty_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) ret = pcmcia_register_driver(&me);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) ipwireless_tty_release();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * Module removal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static void __exit exit_ipwireless(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) pcmcia_unregister_driver(&me);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) ipwireless_tty_release();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) module_init(init_ipwireless);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) module_exit(exit_ipwireless);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) MODULE_AUTHOR(IPWIRELESS_PCMCIA_AUTHOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) MODULE_DESCRIPTION(IPWIRELESS_PCCARD_NAME " " IPWIRELESS_PCMCIA_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) MODULE_LICENSE("GPL");