| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Driver for 802.11b cards using RAM-loadable Symbol firmware, such as | 
					
						
							| 
									
										
										
										
											2006-04-07 04:10:32 -04:00
										 |  |  |  * Symbol Wireless Networker LA4137, CompactFlash cards by Socket | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  |  * Communications and Intel PRO/Wireless 2011B. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The driver implements Symbol firmware download.  The rest is handled | 
					
						
							| 
									
										
										
										
											2009-02-04 23:05:48 +00:00
										 |  |  |  * in hermes.c and main.c. | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Utilities for downloading the Symbol firmware are available at | 
					
						
							|  |  |  |  * http://sourceforge.net/projects/orinoco/
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2002-2005 Pavel Roskin <proski@gnu.org> | 
					
						
							|  |  |  |  * Portions based on orinoco_cs.c: | 
					
						
							| 
									
										
										
										
											2011-07-13 11:19:57 -04:00
										 |  |  |  *	Copyright (C) David Gibson, Linuxcare Australia | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  |  * Portions based on Spectrum24tDnld.c from original spectrum24 driver: | 
					
						
							| 
									
										
										
										
											2011-07-13 11:19:57 -04:00
										 |  |  |  *	Copyright (C) Symbol Technologies. | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2009-02-04 23:05:48 +00:00
										 |  |  |  * See copyright notice in file main.c. | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define DRIVER_NAME "spectrum_cs"
 | 
					
						
							|  |  |  | #define PFX DRIVER_NAME ": "
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/module.h>
 | 
					
						
							|  |  |  | #include <linux/kernel.h>
 | 
					
						
							|  |  |  | #include <linux/init.h>
 | 
					
						
							| 
									
										
										
										
											2005-09-23 04:18:07 -04:00
										 |  |  | #include <linux/delay.h>
 | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | #include <pcmcia/cistpl.h>
 | 
					
						
							|  |  |  | #include <pcmcia/cisreg.h>
 | 
					
						
							|  |  |  | #include <pcmcia/ds.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "orinoco.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | /* Module stuff							    */ | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>"); | 
					
						
							|  |  |  | MODULE_DESCRIPTION("Driver for Symbol Spectrum24 Trilogy cards with firmware downloader"); | 
					
						
							|  |  |  | MODULE_LICENSE("Dual MPL/GPL"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Module parameters */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Some D-Link cards have buggy CIS. They do work at 5v properly, but
 | 
					
						
							|  |  |  |  * don't have any CIS entry for it. This workaround it... */ | 
					
						
							|  |  |  | static int ignore_cis_vcc; /* = 0 */ | 
					
						
							|  |  |  | module_param(ignore_cis_vcc, int, 0); | 
					
						
							|  |  |  | MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | /* Data structures						    */ | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* PCMCIA specific device information (goes in the card field of
 | 
					
						
							|  |  |  |  * struct orinoco_private */ | 
					
						
							|  |  |  | struct orinoco_pccard { | 
					
						
							| 
									
										
										
										
											2006-03-05 10:45:09 +01:00
										 |  |  | 	struct pcmcia_device	*p_dev; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | /* Function prototypes						    */ | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-31 17:26:06 +02:00
										 |  |  | static int spectrum_cs_config(struct pcmcia_device *link); | 
					
						
							| 
									
										
										
										
											2006-03-31 17:21:06 +02:00
										 |  |  | static void spectrum_cs_release(struct pcmcia_device *link); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Constants for the CISREG_CCSR register */ | 
					
						
							|  |  |  | #define HCR_RUN		0x07	/* run firmware after reset */
 | 
					
						
							|  |  |  | #define HCR_IDLE	0x0E	/* don't run firmware after reset */
 | 
					
						
							|  |  |  | #define HCR_MEM16	0x10	/* memory width bit, should be preserved */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Reset the card using configuration registers COR and CCSR. | 
					
						
							|  |  |  |  * If IDLE is 1, stop the firmware, so that it can be safely rewritten. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static int | 
					
						
							| 
									
										
										
										
											2006-03-31 17:21:06 +02:00
										 |  |  | spectrum_reset(struct pcmcia_device *link, int idle) | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | 	int ret; | 
					
						
							| 
									
										
										
										
											2010-07-24 12:23:21 +02:00
										 |  |  | 	u8 save_cor; | 
					
						
							|  |  |  | 	u8 ccsr; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Doing it if hardware is gone is guaranteed crash */ | 
					
						
							| 
									
										
										
										
											2006-08-22 18:55:44 +01:00
										 |  |  | 	if (!pcmcia_dev_present(link)) | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 		return -ENODEV; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Save original COR value */ | 
					
						
							| 
									
										
										
										
											2010-07-24 12:23:21 +02:00
										 |  |  | 	ret = pcmcia_read_config_byte(link, CISREG_COR, &save_cor); | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | 	if (ret) | 
					
						
							|  |  |  | 		goto failed; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Soft-Reset card */ | 
					
						
							| 
									
										
										
										
											2010-07-24 12:23:21 +02:00
										 |  |  | 	ret = pcmcia_write_config_byte(link, CISREG_COR, | 
					
						
							|  |  |  | 				(save_cor | COR_SOFT_RESET)); | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | 	if (ret) | 
					
						
							|  |  |  | 		goto failed; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	udelay(1000); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Read CCSR */ | 
					
						
							| 
									
										
										
										
											2010-07-24 12:23:21 +02:00
										 |  |  | 	ret = pcmcia_read_config_byte(link, CISREG_CCSR, &ccsr); | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | 	if (ret) | 
					
						
							|  |  |  | 		goto failed; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * Start or stop the firmware.  Memory width bit should be | 
					
						
							|  |  |  | 	 * preserved from the value we've just read. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-07-24 12:23:21 +02:00
										 |  |  | 	ccsr = (idle ? HCR_IDLE : HCR_RUN) | (ccsr & HCR_MEM16); | 
					
						
							|  |  |  | 	ret = pcmcia_write_config_byte(link, CISREG_CCSR, ccsr); | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | 	if (ret) | 
					
						
							|  |  |  | 		goto failed; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	udelay(1000); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Restore original COR configuration index */ | 
					
						
							| 
									
										
										
										
											2010-07-24 12:23:21 +02:00
										 |  |  | 	ret = pcmcia_write_config_byte(link, CISREG_COR, | 
					
						
							|  |  |  | 				(save_cor & ~COR_SOFT_RESET)); | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | 	if (ret) | 
					
						
							|  |  |  | 		goto failed; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	udelay(1000); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | failed: | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	return -ENODEV; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | /********************************************************************/ | 
					
						
							| 
									
										
										
										
											2011-07-13 11:19:57 -04:00
										 |  |  | /* Device methods						    */ | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | /********************************************************************/ | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | spectrum_cs_hard_reset(struct orinoco_private *priv) | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | 	struct orinoco_pccard *card = priv->card; | 
					
						
							|  |  |  | 	struct pcmcia_device *link = card->p_dev; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | 	/* Soft reset using COR and HCR */ | 
					
						
							|  |  |  | 	spectrum_reset(link, 0); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | spectrum_cs_stop_firmware(struct orinoco_private *priv, int idle) | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct orinoco_pccard *card = priv->card; | 
					
						
							| 
									
										
										
										
											2006-03-31 17:21:06 +02:00
										 |  |  | 	struct pcmcia_device *link = card->p_dev; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | 	return spectrum_reset(link, idle); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							| 
									
										
										
										
											2011-07-13 11:19:57 -04:00
										 |  |  | /* PCMCIA stuff							    */ | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | /********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-14 21:25:51 +01:00
										 |  |  | static int | 
					
						
							| 
									
										
										
										
											2006-03-31 17:26:06 +02:00
										 |  |  | spectrum_cs_probe(struct pcmcia_device *link) | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct orinoco_private *priv; | 
					
						
							|  |  |  | 	struct orinoco_pccard *card; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-03 10:27:34 +01:00
										 |  |  | 	priv = alloc_orinocodev(sizeof(*card), &link->dev, | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:23 +01:00
										 |  |  | 				spectrum_cs_hard_reset, | 
					
						
							|  |  |  | 				spectrum_cs_stop_firmware); | 
					
						
							|  |  |  | 	if (!priv) | 
					
						
							| 
									
										
										
										
											2005-11-14 21:25:51 +01:00
										 |  |  | 		return -ENOMEM; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	card = priv->card; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Link both structures together */ | 
					
						
							| 
									
										
										
										
											2006-03-31 17:21:06 +02:00
										 |  |  | 	card->p_dev = link; | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:23 +01:00
										 |  |  | 	link->priv = priv; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-31 17:26:06 +02:00
										 |  |  | 	return spectrum_cs_config(link); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | }				/* spectrum_cs_attach */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-31 17:21:06 +02:00
										 |  |  | static void spectrum_cs_detach(struct pcmcia_device *link) | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:23 +01:00
										 |  |  | 	struct orinoco_private *priv = link->priv; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-20 19:39:26 +01:00
										 |  |  | 	orinoco_if_del(priv); | 
					
						
							| 
									
										
										
										
											2006-05-01 02:13:24 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-02 00:09:29 +01:00
										 |  |  | 	spectrum_cs_release(link); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:23 +01:00
										 |  |  | 	free_orinocodev(priv); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | }				/* spectrum_cs_detach */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-02 14:28:43 +02:00
										 |  |  | static int spectrum_cs_config_check(struct pcmcia_device *p_dev, | 
					
						
							|  |  |  | 				    void *priv_data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-07-30 13:13:46 +02:00
										 |  |  | 	if (p_dev->config_index == 0) | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							| 
									
										
										
										
											2008-08-02 14:28:43 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-30 13:13:46 +02:00
										 |  |  | 	return pcmcia_request_io(p_dev); | 
					
						
							| 
									
										
										
										
											2008-08-02 14:28:43 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-31 17:26:06 +02:00
										 |  |  | static int | 
					
						
							| 
									
										
										
										
											2006-03-31 17:21:06 +02:00
										 |  |  | spectrum_cs_config(struct pcmcia_device *link) | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:23 +01:00
										 |  |  | 	struct orinoco_private *priv = link->priv; | 
					
						
							| 
									
										
										
										
											2011-07-13 11:19:57 -04:00
										 |  |  | 	struct hermes *hw = &priv->hw; | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | 	int ret; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	void __iomem *mem; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-30 13:13:46 +02:00
										 |  |  | 	link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC | | 
					
						
							|  |  |  | 		CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; | 
					
						
							| 
									
										
										
										
											2010-07-30 09:51:52 +02:00
										 |  |  | 	if (ignore_cis_vcc) | 
					
						
							|  |  |  | 		link->config_flags &= ~CONF_AUTO_CHECK_VCC; | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | 	ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL); | 
					
						
							|  |  |  | 	if (ret) { | 
					
						
							| 
									
										
										
										
											2008-08-02 14:28:43 +02:00
										 |  |  | 		if (!ignore_cis_vcc) | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 			printk(KERN_ERR PFX "GetNextTuple(): No matching " | 
					
						
							|  |  |  | 			       "CIS configuration.  Maybe you need the " | 
					
						
							|  |  |  | 			       "ignore_cis_vcc=1 parameter.\n"); | 
					
						
							| 
									
										
										
										
											2008-08-02 14:28:43 +02:00
										 |  |  | 		goto failed; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-24 15:58:54 +02:00
										 |  |  | 	mem = ioport_map(link->resource[0]->start, | 
					
						
							|  |  |  | 			resource_size(link->resource[0])); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	if (!mem) | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | 		goto failed; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-07 18:50:42 +00:00
										 |  |  | 	/* We initialize the hermes structure before completing PCMCIA
 | 
					
						
							|  |  |  | 	 * configuration just in case the interrupt handler gets | 
					
						
							|  |  |  | 	 * called. */ | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING); | 
					
						
							| 
									
										
										
										
											2010-05-01 14:05:43 +01:00
										 |  |  | 	hw->eeprom_pda = true; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-07 18:50:42 +00:00
										 |  |  | 	ret = pcmcia_request_irq(link, orinoco_interrupt); | 
					
						
							|  |  |  | 	if (ret) | 
					
						
							|  |  |  | 		goto failed; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-29 19:27:09 +02:00
										 |  |  | 	ret = pcmcia_enable_device(link); | 
					
						
							| 
									
										
										
										
											2009-10-24 15:53:36 +02:00
										 |  |  | 	if (ret) | 
					
						
							|  |  |  | 		goto failed; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-21 23:27:54 +01:00
										 |  |  | 	/* Reset card */ | 
					
						
							| 
									
										
										
										
											2009-01-25 23:08:43 +03:00
										 |  |  | 	if (spectrum_cs_hard_reset(priv) != 0) | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 		goto failed; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:24 +01:00
										 |  |  | 	/* Initialise the main driver */ | 
					
						
							|  |  |  | 	if (orinoco_init(priv) != 0) { | 
					
						
							|  |  |  | 		printk(KERN_ERR PFX "orinoco_init() failed\n"); | 
					
						
							|  |  |  | 		goto failed; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:28 +01:00
										 |  |  | 	/* Register an interface with the stack */ | 
					
						
							| 
									
										
										
										
											2010-07-24 15:58:54 +02:00
										 |  |  | 	if (orinoco_if_add(priv, link->resource[0]->start, | 
					
						
							| 
									
										
										
										
											2010-05-20 21:04:44 -07:00
										 |  |  | 			   link->irq, NULL) != 0) { | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:28 +01:00
										 |  |  | 		printk(KERN_ERR PFX "orinoco_if_add() failed\n"); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 		goto failed; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-31 17:26:06 +02:00
										 |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |  failed: | 
					
						
							|  |  |  | 	spectrum_cs_release(link); | 
					
						
							| 
									
										
										
										
											2006-03-31 17:26:06 +02:00
										 |  |  | 	return -ENODEV; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | }				/* spectrum_cs_config */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2006-03-31 17:21:06 +02:00
										 |  |  | spectrum_cs_release(struct pcmcia_device *link) | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:23 +01:00
										 |  |  | 	struct orinoco_private *priv = link->priv; | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	unsigned long flags; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* We're committed to taking the device away now, so mark the
 | 
					
						
							|  |  |  | 	 * hardware as unavailable */ | 
					
						
							| 
									
										
										
										
											2010-05-01 14:05:40 +01:00
										 |  |  | 	priv->hw.ops->lock_irqsave(&priv->lock, &flags); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	priv->hw_unavailable++; | 
					
						
							| 
									
										
										
										
											2010-05-01 14:05:40 +01:00
										 |  |  | 	priv->hw.ops->unlock_irqrestore(&priv->lock, &flags); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-31 17:21:06 +02:00
										 |  |  | 	pcmcia_disable_device(link); | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	if (priv->hw.iobase) | 
					
						
							|  |  |  | 		ioport_unmap(priv->hw.iobase); | 
					
						
							|  |  |  | }				/* spectrum_cs_release */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-14 21:21:18 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							| 
									
										
										
										
											2006-03-31 17:21:06 +02:00
										 |  |  | spectrum_cs_suspend(struct pcmcia_device *link) | 
					
						
							| 
									
										
										
										
											2005-11-14 21:21:18 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:23 +01:00
										 |  |  | 	struct orinoco_private *priv = link->priv; | 
					
						
							| 
									
										
										
										
											2005-11-14 21:21:18 +01:00
										 |  |  | 	int err = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Mark the device as stopped, to block IO until later */ | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:30 +01:00
										 |  |  | 	orinoco_down(priv); | 
					
						
							| 
									
										
										
										
											2005-11-14 21:21:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-01 02:13:28 -04:00
										 |  |  | 	return err; | 
					
						
							| 
									
										
										
										
											2005-11-14 21:21:18 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							| 
									
										
										
										
											2006-03-31 17:21:06 +02:00
										 |  |  | spectrum_cs_resume(struct pcmcia_device *link) | 
					
						
							| 
									
										
										
										
											2005-11-14 21:21:18 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:23 +01:00
										 |  |  | 	struct orinoco_private *priv = link->priv; | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:30 +01:00
										 |  |  | 	int err = orinoco_up(priv); | 
					
						
							| 
									
										
										
										
											2008-11-22 10:37:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-18 23:21:30 +01:00
										 |  |  | 	return err; | 
					
						
							| 
									
										
										
										
											2005-11-14 21:21:18 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | /* Module initialization					    */ | 
					
						
							|  |  |  | /********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-03 19:29:01 -07:00
										 |  |  | static const struct pcmcia_device_id spectrum_cs_ids[] = { | 
					
						
							| 
									
										
										
										
											2006-04-07 04:10:32 -04:00
										 |  |  | 	PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4137 */ | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */ | 
					
						
							| 
									
										
										
										
											2005-09-16 02:18:31 -04:00
										 |  |  | 	PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless LAN PC Card", 0x816cc815, 0x6fbf459a), /* 2011B, not 2011 */ | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	PCMCIA_DEVICE_NULL, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | MODULE_DEVICE_TABLE(pcmcia, spectrum_cs_ids); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct pcmcia_driver orinoco_driver = { | 
					
						
							|  |  |  | 	.owner		= THIS_MODULE, | 
					
						
							| 
									
										
										
										
											2010-08-08 11:36:26 +02:00
										 |  |  | 	.name		= DRIVER_NAME, | 
					
						
							| 
									
										
										
										
											2006-03-31 17:26:06 +02:00
										 |  |  | 	.probe		= spectrum_cs_probe, | 
					
						
							| 
									
										
										
										
											2005-11-14 21:23:14 +01:00
										 |  |  | 	.remove		= spectrum_cs_detach, | 
					
						
							| 
									
										
										
										
											2005-11-14 21:21:18 +01:00
										 |  |  | 	.suspend	= spectrum_cs_suspend, | 
					
						
							|  |  |  | 	.resume		= spectrum_cs_resume, | 
					
						
							| 
									
										
										
										
											2005-09-01 20:10:06 -04:00
										 |  |  | 	.id_table       = spectrum_cs_ids, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int __init | 
					
						
							|  |  |  | init_spectrum_cs(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return pcmcia_register_driver(&orinoco_driver); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void __exit | 
					
						
							|  |  |  | exit_spectrum_cs(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	pcmcia_unregister_driver(&orinoco_driver); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module_init(init_spectrum_cs); | 
					
						
							|  |  |  | module_exit(exit_spectrum_cs); |