From: David Gibson <hidden> Date: 2005-01-12 05:29:48
Following are a bunch of patches which make a few more steps towards
the long overdue merge of the CVS orinoco driver into mainline. These
do make behavioural changes to the driver, but they should all be
trivial and largely cosmetic.
Jeff, please apply. Patches are against the netdev BK tree.
orinoco-printks
Update printk()s and other cosmetic strings
orinoco-carrier
Use netif_carrier_() functions instead of homegrown connected
flag
orinoco-delays
Use mdelay() and ssleep() instead of schedule_timeout() and
other more complicated idioms.
orinoco-free-orinocodev
Introduce free_orinocodev() function as a wrapper around
free_netdev()
orinoco-cleanup-hermes
Make cleanups to low-level driver code
orinoco-pccard-cleanups
Cleanup initialization for PCMCIA/PC-Card devices.
orinoco-modparm
Replace obsolete MODULE_PARM() constructions from orinoco.c
orinoco-pci-updates
Cleanup initialization for PCI/PLX/TMD devices.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson
From: David Gibson <hidden> Date: 2005-01-12 05:45:50
Reformats printk()s, comments, labels and other cosmetic strings in
the orinoco driver. Also moves, removes, and adds ratelimiting in
some places. Behavioural changes are trivial/cosmetic only. This
reduces the cosmetic/trivial differences between the current kernel
version, and the CVS version of the driver; one small step towards
full merge.
Signed-off-by: David Gibson <redacted>
Index: working-2.6/drivers/net/wireless/hermes.c
===================================================================
@@ -251,17 +255,16 @@}if(!hermes_present(hw)){-printk(KERN_WARNING"hermes @ %p: "-"Card removed while waiting for command completion.\n",-hw->iobase);+printk(KERN_WARNING"hermes @ %p: Card removed "+"while waiting for command 0x%04x completion.\n",+hw->iobase,cmd);err=-ENODEV;gotoout;}if(!(reg&HERMES_EV_CMD)){-printk(KERN_ERR"hermes @ %p: "-"Timeout waiting for command completion.\n",-hw->iobase);+printk(KERN_ERR"hermes @ %p: Timeout waiting for "+"command 0x%04x completion.\n",hw->iobase,cmd);err=-ETIMEDOUT;gotoout;}
@@ -481,14 +484,13 @@*length=rlength;if(rtype!=rid)-printk(KERN_WARNING"hermes @ %p: "-"hermes_read_ltv(): rid (0x%04x) does not match type (0x%04x)\n",-hw->iobase,rid,rtype);+printk(KERN_WARNING"hermes @ %p: %s(): "+"rid (0x%04x) does not match type (0x%04x)\n",+hw->iobase,__FUNCTION__,rid,rtype);if(HERMES_RECLEN_TO_BYTES(rlength)>bufsize)printk(KERN_WARNING"hermes @ %p: ""Truncating LTV record from %d to %d bytes. "-"(rid=0x%04x, len=0x%04x)\n",-hw->iobase,+"(rid=0x%04x, len=0x%04x)\n",hw->iobase,HERMES_RECLEN_TO_BYTES(rlength),bufsize,rid,rlength);nwords=min((unsigned)rlength-1,bufsize/2);
@@ -151,24 +151,18 @@/* Assert the reset until the card notice */hermes_write_regn(hw,PCI_COR,HERMES_PCI_COR_MASK);-printk(KERN_NOTICE"Reset done");timeout=jiffies+(HERMES_PCI_COR_ONT*HZ/1000);while(time_before(jiffies,timeout)){-printk(".");mdelay(1);}-printk(";\n");//mdelay(HERMES_PCI_COR_ONT);/* Give time for the card to recover from this hard effort */hermes_write_regn(hw,PCI_COR,0x0000);-printk(KERN_NOTICE"Clear Reset");timeout=jiffies+(HERMES_PCI_COR_OFFT*HZ/1000);while(time_before(jiffies,timeout)){-printk(".");mdelay(1);}-printk(";\n");//mdelay(HERMES_PCI_COR_OFFT);/* The card is ready when it's no longer busy */
@@ -245,7 +240,7 @@/* Perform a COR reset to start the card */if(orinoco_pci_cor_reset(priv)!=0){-printk(KERN_ERR"%s: Failed to start the card\n",dev->name);+printk(KERN_ERRPFX"Initial reset failed\n");err=-ETIMEDOUT;gotofail;}
@@ -256,7 +251,7 @@err=register_netdev(dev);if(err){-printk(KERN_ERR"%s: Failed to register net device\n",dev->name);+printk(KERN_ERRPFX"Failed to register net device\n");gotofail;}
@@ -127,7 +127,7 @@{spin_lock_irqsave(&priv->lock,*flags);if(priv->hw_unavailable){-printk(KERN_DEBUG"orinoco_lock() called with hw_unavailable (dev=%p)\n",+DEBUG(1,"orinoco_lock() called with hw_unavailable (dev=%p)\n",priv->ndev);spin_unlock_irqrestore(&priv->lock,*flags);return-EBUSY;
@@ -405,7 +405,7 @@last_ret=pcmcia_get_next_tuple(handle,&tuple);if(last_ret==CS_NO_MORE_ITEMS){printk(KERN_ERRPFX"GetNextTuple(): No matching "-"CIS configuration, maybe you need the "+"CIS configuration. Maybe you need the ""ignore_cis_vcc=1 parameter.\n");gotocs_failed;}
@@ -194,14 +193,14 @@hermes_t*hw;if(macio_resource_count(mdev)<1||macio_irq_count(mdev)<1){-printk(KERN_ERRPFX"wrong interrupt/addresses in OF tree\n");+printk(KERN_ERRPFX"Wrong interrupt/addresses in OF tree\n");return-ENODEV;}/* Allocate space for private device-specific data */dev=alloc_orinocodev(sizeof(*card),airport_hard_reset);if(!dev){-printk(KERN_ERRPFX"can't allocate device datas\n");+printk(KERN_ERRPFX"Cannot allocate network device\n");return-ENODEV;}priv=netdev_priv(dev);
@@ -241,7 +240,7 @@/* Reset it before we get the interrupt */hermes_init(hw);-if(request_irq(dev->irq,orinoco_interrupt,0,"Airport",dev)){+if(request_irq(dev->irq,orinoco_interrupt,0,dev->name,dev)){printk(KERN_ERRPFX"Couldn't get IRQ %d\n",dev->irq);gotofailed;}
@@ -252,7 +251,7 @@printk(KERN_ERRPFX"register_netdev() failed\n");gotofailed;}-printk(KERN_DEBUGPFX"card registered for interface %s\n",dev->name);+printk(KERN_DEBUGPFX"Card registered for interface %s\n",dev->name);card->ndev_registered=1;return0;failed:
@@ -167,15 +167,17 @@inti;err=pci_enable_device(pdev);-if(err)+if(err){+printk(KERN_ERRPFX"Cannot enable PCI device\n");return-EIO;+}/* Resource 2 is mapped to the PCMCIA space */attr_mem=ioremap(pci_resource_start(pdev,2),PAGE_SIZE);if(!attr_mem)-gotoout;+gotofail_resources;-printk(KERN_DEBUG"orinoco_plx: CIS: ");+printk(KERN_DEBUGPFX"CIS: ");for(i=0;i<16;i++){printk("%02X:",readw(attr_mem+i));}
@@ -185,10 +187,11 @@/* FIXME: we probably need to be smarted about this */memcpy_fromio(magic,attr_mem,16);if(memcmp(magic,cis_magic,16)!=0){-printk(KERN_ERR"orinoco_plx: The CIS value of Prism2 PC card is invalid.\n");+printk(KERN_ERRPFX"The CIS value of Prism2 PC "+"card is unexpected\n");err=-EIO;iounmap(attr_mem);-gotoout;+gotofail_resources;}/* PCMCIA COR is the first byte following CIS: this write should
@@ -199,8 +202,8 @@iounmap(attr_mem);if(reg!=COR_VALUE){-printk(KERN_ERR"orinoco_plx: Error setting COR value (reg=%x)\n",reg);-gotoout;+printk(KERN_ERRPFX"Error setting COR value (reg=%x)\n",reg);+gotofail_resources;}/* bjoern: We need to tell the card to enable interrupts, in
@@ -209,40 +212,39 @@addr=pci_resource_start(pdev,1);reg=inl(addr+PLX_INTCSR);if(reg&PLX_INTCSR_INTEN)-printk(KERN_DEBUG"orinoco_plx: "-"Local Interrupt already enabled\n");+printk(KERN_DEBUGPFX"Local Interrupt already enabled\n");else{reg|=PLX_INTCSR_INTEN;outl(reg,addr+PLX_INTCSR);reg=inl(addr+PLX_INTCSR);if(!(reg&PLX_INTCSR_INTEN)){-printk(KERN_ERR"orinoco_plx: "-"Couldn't enable Local Interrupts\n");-gotoout;+printk(KERN_ERRPFX"Couldn't enable Local Interrupts\n");+gotofail_resources;}}-/* and 3 to the PCMCIA slot I/O address space */+/* Resource 3 is mapped to the PCMCIA I/O address space */pccard_ioaddr=pci_resource_start(pdev,3);pccard_iolen=pci_resource_len(pdev,3);if(!request_region(pccard_ioaddr,pccard_iolen,DRIVER_NAME)){-printk(KERN_ERR"orinoco_plx: I/O resource 0x%lx @ 0x%lx busy\n",+printk(KERN_ERRPFX"I/O resource 0x%lx @ 0x%lx busy\n",pccard_iolen,pccard_ioaddr);err=-EBUSY;-gotoout;+gotofail_resources;}mem=pci_iomap(pdev,3,0);if(!mem){err=-ENOMEM;-gotoout1;+gotofail_map;}/* Allocate network device */dev=alloc_orinocodev(0,NULL);if(!dev){+printk(KERN_ERRPFX"Cannot allocate network device\n");err=-ENOMEM;-gotoout2;+gotofail_alloc;}priv=netdev_priv(dev);
@@ -836,8 +837,9 @@err=hermes_bap_pwrite(hw,USER_BAP,&hdr,sizeof(hdr),txfid,HERMES_802_3_OFFSET);if(err){-printk(KERN_ERR"%s: Error %d writing packet header to BAP\n",-dev->name,err);+if(net_ratelimit())+printk(KERN_ERR"%s: Error %d writing packet "+"header to BAP\n",dev->name,err);stats->tx_errors++;gotofail;}
@@ -1297,8 +1299,8 @@}break;default:-printk(KERN_DEBUG"%s: Unknown information frame received "-"(type %04x).\n",dev->name,type);+printk(KERN_DEBUG"%s: Unknown information frame received: "+"type 0x%04x, length %d\n",dev->name,type,len);/* We don't actually do anything about it */break;}
@@ -1307,7 +1309,7 @@staticvoid__orinoco_ev_infdrop(structnet_device*dev,hermes_t*hw){if(net_ratelimit())-printk(KERN_WARNING"%s: Information frame lost.\n",dev->name);+printk(KERN_DEBUG"%s: Information frame lost.\n",dev->name);}/********************************************************************/
@@ -1785,7 +1787,8 @@}if(p)-printk(KERN_WARNING"Multicast list is longer than mc_count\n");+printk(KERN_WARNING"%s: Multicast list is "+"longer than mc_count\n",dev->name);err=hermes_write_ltv(hw,USER_BAP,HERMES_RID_CNFGROUPADDRESSES,HERMES_BYTES_TO_RECLEN(priv->mc_count*ETH_ALEN),
@@ -2053,7 +2056,7 @@le16_to_cpus(&sta_id.variant);le16_to_cpus(&sta_id.major);le16_to_cpus(&sta_id.minor);-printk(KERN_DEBUG"%s: Station identity %04x:%04x:%04x:%04x\n",+printk(KERN_DEBUG"%s: Station identity %04x:%04x:%04x:%04x\n",dev->name,sta_id.id,sta_id.variant,sta_id.major,sta_id.minor);
@@ -3045,8 +3048,9 @@priv->mwo_robust=0;else{if(frq->fixed)-printk(KERN_WARNING"%s: Fixed fragmentation not \-supportedonthisfirmware.UsingMWOrobustinstead.\n", dev->name);+printk(KERN_WARNING"%s: Fixed fragmentation is "+"not supported on this firmware. "+"Using MWO robust instead.\n",dev->name);priv->mwo_robust=1;}}else{
@@ -3518,7 +3522,7 @@}/* Copy stats *//* In theory, we should disable irqs while copying the stats-*becausetherxpathmighupdateitinthemiddle...+*becausetherxpathmightupdateitinthemiddle...*Bah,whocare?-JeanII*/memcpy(&spy_stat,priv->spy_stat,sizeof(structiw_quality)*IW_MAX_SPY);
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
From: David Gibson <hidden> Date: 2005-01-12 05:33:19
Removes the orinoco driver's custom and dodgy "connected" variable
used to track whether or not we're associated with an AP. Replaces it
instead with netif_carrier_ok() settings.
Signed-off-by: David Gibson <redacted>
Index: working-2.6/drivers/net/wireless/orinoco.c
===================================================================
@@ -784,7 +784,7 @@return1;}-if(!priv->connected){+if(!netif_carrier_ok(dev)){/* Oops, the firmware hasn't established a connection,silentlydropthepacket(thisseemstobethesafestapproach).*/
@@ -1368,8 +1368,8 @@}/* firmware will have to reassociate */+netif_carrier_off(dev);priv->last_linkstatus=0xffff;-priv->connected=0;return0;}
@@ -1881,7 +1881,7 @@priv->hw_unavailable++;priv->last_linkstatus=0xffff;/* firmware will have to reassociate */-priv->connected=0;+netif_carrier_off(dev);orinoco_unlock(priv,&flags);
@@ -42,7 +42,6 @@/* driver state */intopen;u16last_linkstatus;-intconnected;/* Net device stuff */structnet_device*ndev;
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
From: David Gibson <hidden> Date: 2005-01-12 05:29:57
Use mdelay() or ssleep() instead of various silly more complicated
ways of delaying in the orinoco driver.
Signed-off-by: David Gibson <redacted>
Index: working-2.6/drivers/net/wireless/orinoco_pci.c
===================================================================
@@ -151,19 +151,11 @@/* Assert the reset until the card notice */hermes_write_regn(hw,PCI_COR,HERMES_PCI_COR_MASK);-timeout=jiffies+(HERMES_PCI_COR_ONT*HZ/1000);-while(time_before(jiffies,timeout)){-mdelay(1);-}-//mdelay(HERMES_PCI_COR_ONT);+mdelay(HERMES_PCI_COR_ONT);/* Give time for the card to recover from this hard effort */hermes_write_regn(hw,PCI_COR,0x0000);-timeout=jiffies+(HERMES_PCI_COR_OFFT*HZ/1000);-while(time_before(jiffies,timeout)){-mdelay(1);-}-//mdelay(HERMES_PCI_COR_OFFT);+mdelay(HERMES_PCI_COR_OFFT);/* The card is ready when it's no longer busy */timeout=jiffies+(HERMES_PCI_COR_BUSYT*HZ/1000);
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson
From: David Gibson <hidden> Date: 2005-01-12 05:32:35
Introduce a free_orinocodev() function into the orinoco driver, used
by the hardware type/initialization modules to free the device
structure in preference to directly calling free_netdev(). At the
moment free_orinocodev() just calls free_netdev(). Future merges will
make it clean up internal scanning state, so merging this now will
reduce the diff noise.
Signed-off-by: David Gibson <redacted>
Index: working-2.6/drivers/net/wireless/orinoco.h
===================================================================
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson
From: David Gibson <hidden> Date: 2005-01-12 05:36:44
Apply some cleanups to the low-level orinoco handling code in
hermes.[ch]. This cleans up some error handling code, corrects an
error code to something more accurate, and also increases a timeout
value. This last can (when the hardware plays up) cause long delays
with spinlocks held, which is bad, but is rather less prone to
prematurely giving up, which has the unfortunate habit of fatally
confusing the hardware in other ways :-/.
Signed-off-by: David Gibson <redacted>
Index: working-2.6/drivers/net/wireless/hermes.c
===================================================================
@@ -340,7 +340,7 @@#ifdef __KERNEL__/* Timeouts */-#define HERMES_BAP_BUSY_TIMEOUT (500) /* In iterations of ~1us */+#define HERMES_BAP_BUSY_TIMEOUT (10000) /* In iterations of ~1us *//* Basic control structure */typedefstructhermes{
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
From: David Gibson <hidden> Date: 2005-01-12 05:36:43
Cleanup the various bits of initialization code for PCMCIA / PC-Card
orinoco devices. This includes one important bugfix where we could
fail to take the lock in some circumstances.
Signed-off-by: David Gibson <redacted>
Index: working-2.6/drivers/net/wireless/orinoco_cs.c
===================================================================
@@ -54,19 +54,11 @@/* Module parameters */-/* The old way: bit map of interrupts to choose from */-/* This means pick from 15, 14, 12, 11, 10, 9, 7, 5, 4, and 3 */-staticuintirq_mask=0xdeb8;-/* Newer, simpler way of listing specific interrupts */-staticintirq_list[4]={-1};-/* Some D-Link cards have buggy CIS. They do work at 5v properly, but*don'thaveanyCISentryforit.Thisworkaroundit...*/staticintignore_cis_vcc;/* = 0 */--MODULE_PARM(irq_mask,"i");-MODULE_PARM(irq_list,"1-4i");-MODULE_PARM(ignore_cis_vcc,"i");+module_param(ignore_cis_vcc,int,0644);+MODULE_PARM_DESC(ignore_cis_vcc,"Allow voltage mismatch between card and socket");/********************************************************************//* Magic constants */
@@ -174,14 +167,11 @@link->priv=dev;/* Interrupt setup */-link->irq.Attributes=IRQ_TYPE_EXCLUSIVE;+link->irq.Attributes=IRQ_TYPE_EXCLUSIVE|IRQ_HANDLE_PRESENT;link->irq.IRQInfo1=IRQ_INFO2_VALID|IRQ_LEVEL_ID;-if(irq_list[0]==-1)-link->irq.IRQInfo2=irq_mask;-else-for(i=0;i<4;i++)-link->irq.IRQInfo2|=1<<irq_list[i];-link->irq.Handler=NULL;+link->irq.IRQInfo2=0xffffffff;/* Any ISA IRQ */+link->irq.Handler=orinoco_interrupt;+link->irq.Instance=dev;/* General socket configuration defaults can go here. In this*client,weassumeverylittle,andrelyontheCISfor
@@ -363,8 +355,7 @@dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;/* Do we need to allocate an interrupt? */-if(cfg->irq.IRQInfo1||dflt.irq.IRQInfo1)-link->conf.Attributes|=CONF_ENABLE_IRQ;+link->conf.Attributes|=CONF_ENABLE_IRQ;/* IO window settings */link->io.NumPorts1=link->io.NumPorts2=0;
@@ -390,8 +381,8 @@}/* This reserves IO space but doesn't actually enable it */-if(pcmcia_request_io(link->handle,&link->io)!=0)-gotonext_entry;+CFG_CHECK(RequestIO,+pcmcia_request_io(link->handle,&link->io));}
@@ -416,22 +407,7 @@*ahandlertotheinterrupt,unlessthe'Handler'memberof*theirqstructureisinitialized.*/-if(link->conf.Attributes&CONF_ENABLE_IRQ){-inti;--link->irq.Attributes=IRQ_TYPE_EXCLUSIVE|IRQ_HANDLE_PRESENT;-link->irq.IRQInfo1=IRQ_INFO2_VALID|IRQ_LEVEL_ID;-if(irq_list[0]==-1)-link->irq.IRQInfo2=irq_mask;-else-for(i=0;i<4;i++)-link->irq.IRQInfo2|=1<<irq_list[i];--link->irq.Handler=orinoco_interrupt;-link->irq.Instance=dev;--CS_CHECK(RequestIRQ,pcmcia_request_irq(link->handle,&link->irq));-}+CS_CHECK(RequestIRQ,pcmcia_request_irq(link->handle,&link->irq));/* We initialize the hermes structure before completing PCMCIA*configurationjustincasetheinterrupthandlergets
@@ -456,8 +432,6 @@SET_MODULE_OWNER(dev);card->node.major=card->node.minor=0;-/* register_netdev will give us an ethX name */-dev->name[0]='\0';/* Tell the stack we exist */if(register_netdev(dev)!=0){printk(KERN_ERRPFX"register_netdev() failed\n");
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
From: David Gibson <hidden> Date: 2005-01-12 05:36:43
Replace obsolete MODULE_PARM() with module_param() in the orinoco
driver.
Signed-off-by: David Gibson <redacted>
Index: working-2.6/drivers/net/wireless/orinoco.c
===================================================================
@@ -461,12 +461,14 @@/* Level of debugging. Used in the macros in orinoco.h */#ifdef ORINOCO_DEBUGintorinoco_debug=ORINOCO_DEBUG;-MODULE_PARM(orinoco_debug,"i");+module_param(orinoco_debug,int,0644);+MODULE_PARM_DESC(orinoco_debug,"Debug level");EXPORT_SYMBOL(orinoco_debug);#endifstaticintsuppress_linkstatus;/* = 0 */-MODULE_PARM(suppress_linkstatus,"i");+module_param(suppress_linkstatus,int,0644);+MODULE_PARM_DESC(suppress_linkstatus,"Don't log link status changes");/********************************************************************//* Compile time configuration and compatibility stuff */
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson
From: David Gibson <hidden> Date: 2005-01-12 05:41:43
Update the initialization code in the various PCI incarnations of the
orinoco driver. This applies similar initialization and shutdown
cleanups to the orinoco_pci, orinoco_plx and orinoco_tmd drivers. It
also adds COR reset support to the orinoco_plx and orinoco_tmd
drivers, improves PCI power management support in the orinoco_pci
driver and adds a couple of extra supported cards to the ID tables.
Signed-off-by: David Gibson <redacted>
Index: working-2.6/drivers/net/wireless/orinoco_pci.c
===================================================================
@@ -129,6 +129,11 @@#define HERMES_PCI_COR_OFFT (500) /* ms */#define HERMES_PCI_COR_BUSYT (500) /* ms */+/* Orinoco PCI specific data */+structorinoco_pci_card{+void__iomem*pci_ioaddr;+};+/**DoasoftresetofthePCIcardusingtheConfigurationOptionRegister*Weneedthistogetgoing...
@@ -164,8 +169,9 @@mdelay(1);reg=hermes_read_regn(hw,CMD);}-/* Did we timeout ? */-if(time_after_eq(jiffies,timeout)){++/* Still busy? */+if(reg&HERMES_CMD_BUSY){printk(KERN_ERRPFX"Busy timeout\n");return-ETIMEDOUT;}
@@ -142,26 +142,68 @@#include"hermes.h"#include"orinoco.h"-#define COR_OFFSET (0x3e0/2) /* COR attribute offset of Prism2 PC card */+#define COR_OFFSET (0x3e0) /* COR attribute offset of Prism2 PC card */#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */+#define COR_RESET (0x80) /* reset bit in the COR register */+#define PLX_RESET_TIME (500) /* milliseconds */#define PLX_INTCSR 0x4c /* Interrupt Control & Status Register */#define PLX_INTCSR_INTEN (1<<6) /* Interrupt Enable bit */-staticconstu16cis_magic[]={-0x0001,0x0003,0x0000,0x0000,0x00ff,0x0017,0x0004,0x0067+staticconstu8cis_magic[]={+0x01,0x03,0x00,0x00,0xff,0x17,0x04,0x67};+/* Orinoco PLX specific data */+structorinoco_plx_card{+void__iomem*attr_mem;+};++/*+*DoasoftresetofthecardusingtheConfigurationOptionRegister+*/+staticintorinoco_plx_cor_reset(structorinoco_private*priv)+{+hermes_t*hw=&priv->hw;+structorinoco_plx_card*card=priv->card;+u8__iomem*attr_mem=card->attr_mem;+unsignedlongtimeout;+u16reg;++writeb(COR_VALUE|COR_RESET,attr_mem+COR_OFFSET);+mdelay(1);++writeb(COR_VALUE,attr_mem+COR_OFFSET);+mdelay(1);++/* Just in case, wait more until the card is no longer busy */+timeout=jiffies+(PLX_RESET_TIME*HZ/1000);+reg=hermes_read_regn(hw,CMD);+while(time_before(jiffies,timeout)&&(reg&HERMES_CMD_BUSY)){+mdelay(1);+reg=hermes_read_regn(hw,CMD);+}++/* Did we timeout ? */+if(reg&HERMES_CMD_BUSY){+printk(KERN_ERRPFX"Busy timeout\n");+return-ETIMEDOUT;+}++return0;+}++staticintorinoco_plx_init_one(structpci_dev*pdev,conststructpci_device_id*ent){interr=0;-u16__iomem*attr_mem=NULL;-u32reg,addr;+u8__iomem*attr_mem=NULL;+u32csr_reg,plx_addr;structorinoco_private*priv=NULL;+structorinoco_plx_card*card;unsignedlongpccard_ioaddr=0;unsignedlongpccard_iolen=0;-u16magic[8];structnet_device*dev=NULL;void__iomem*mem;inti;
@@ -169,78 +211,38 @@err=pci_enable_device(pdev);if(err){printk(KERN_ERRPFX"Cannot enable PCI device\n");-return-EIO;+returnerr;}-/* Resource 2 is mapped to the PCMCIA space */-attr_mem=ioremap(pci_resource_start(pdev,2),PAGE_SIZE);-if(!attr_mem)+err=pci_request_regions(pdev,DRIVER_NAME);+if(err!=0){+printk(KERN_ERRPFX"Cannot obtain PCI resources\n");gotofail_resources;--printk(KERN_DEBUGPFX"CIS: ");-for(i=0;i<16;i++){-printk("%02X:",readw(attr_mem+i));}-printk("\n");--/* Verify whether PC card is present */-/* FIXME: we probably need to be smarted about this */-memcpy_fromio(magic,attr_mem,16);-if(memcmp(magic,cis_magic,16)!=0){-printk(KERN_ERRPFX"The CIS value of Prism2 PC "-"card is unexpected\n");-err=-EIO;-iounmap(attr_mem);-gotofail_resources;-}--/* PCMCIA COR is the first byte following CIS: this write should-*enableI/Omodeandselectlevel-triggeredinterrupts*/-writew(COR_VALUE,attr_mem+COR_OFFSET);-mdelay(1);-reg=readw(attr_mem+COR_OFFSET);-iounmap(attr_mem);-if(reg!=COR_VALUE){-printk(KERN_ERRPFX"Error setting COR value (reg=%x)\n",reg);-gotofail_resources;-}+/* Resource 1 is mapped to PLX-specific registers */+plx_addr=pci_resource_start(pdev,1);-/* bjoern: We need to tell the card to enable interrupts, in-casetheserialepromdidn'tdothisalready.Seethe-PLX9052databook,p8-1and8-24forreference.*/-addr=pci_resource_start(pdev,1);-reg=inl(addr+PLX_INTCSR);-if(reg&PLX_INTCSR_INTEN)-printk(KERN_DEBUGPFX"Local Interrupt already enabled\n");-else{-reg|=PLX_INTCSR_INTEN;-outl(reg,addr+PLX_INTCSR);-reg=inl(addr+PLX_INTCSR);-if(!(reg&PLX_INTCSR_INTEN)){-printk(KERN_ERRPFX"Couldn't enable Local Interrupts\n");-gotofail_resources;-}+/* Resource 2 is mapped to the PCMCIA attribute memory */+attr_mem=ioremap(pci_resource_start(pdev,2),+pci_resource_len(pdev,2));+if(!attr_mem){+printk(KERN_ERRPFX"Cannot remap PCMCIA space\n");+gotofail_map_attr;}/* Resource 3 is mapped to the PCMCIA I/O address space */pccard_ioaddr=pci_resource_start(pdev,3);pccard_iolen=pci_resource_len(pdev,3);-if(!request_region(pccard_ioaddr,pccard_iolen,DRIVER_NAME)){-printk(KERN_ERRPFX"I/O resource 0x%lx @ 0x%lx busy\n",-pccard_iolen,pccard_ioaddr);-err=-EBUSY;-gotofail_resources;-}mem=pci_iomap(pdev,3,0);if(!mem){err=-ENOMEM;-gotofail_map;+gotofail_map_io;}/* Allocate network device */-dev=alloc_orinocodev(0,NULL);+dev=alloc_orinocodev(sizeof(*card),orinoco_plx_cor_reset);if(!dev){printk(KERN_ERRPFX"Cannot allocate network device\n");err=-ENOMEM;
@@ -268,6 +272,43 @@}dev->irq=pdev->irq;+/* bjoern: We need to tell the card to enable interrupts, in+casetheserialepromdidn'tdothisalready.Seethe+PLX9052databook,p8-1and8-24forreference.*/+csr_reg=inl(plx_addr+PLX_INTCSR);+if(!(csr_reg&PLX_INTCSR_INTEN)){+csr_reg|=PLX_INTCSR_INTEN;+outl(csr_reg,plx_addr+PLX_INTCSR);+csr_reg=inl(plx_addr+PLX_INTCSR);+if(!(csr_reg&PLX_INTCSR_INTEN)){+printk(KERN_ERRPFX"Cannot enable interrupts\n");+gotofail;+}+}++err=orinoco_plx_cor_reset(priv);+if(err){+printk(KERN_ERRPFX"Initial reset failed\n");+gotofail;+}++printk(KERN_DEBUGPFX"CIS: ");+for(i=0;i<16;i++){+printk("%02X:",readb(attr_mem+2*i));+}+printk("\n");++/* Verify whether a supported PC card is present */+/* FIXME: we probably need to be smarted about this */+for(i=0;i<sizeof(cis_magic);i++){+if(cis_magic[i]!=readb(attr_mem+2*i)){+printk(KERN_ERRPFX"The CIS value of Prism2 PC "+"card is unexpected\n");+err=-EIO;+gotofail;+}+}+err=register_netdev(dev);if(err){printk(KERN_ERRPFX"Cannot register network device\n");
@@ -79,59 +79,89 @@#include"orinoco.h"#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */+#define COR_RESET (0x80) /* reset bit in the COR register */+#define TMD_RESET_TIME (500) /* milliseconds */++/* Orinoco TMD specific data */+structorinoco_tmd_card{+u32tmd_io;+};+++/*+*DoasoftresetofthecardusingtheConfigurationOptionRegister+*/+staticintorinoco_tmd_cor_reset(structorinoco_private*priv)+{+hermes_t*hw=&priv->hw;+structorinoco_tmd_card*card=priv->card;+u32addr=card->tmd_io;+unsignedlongtimeout;+u16reg;++outb(COR_VALUE|COR_RESET,addr);+mdelay(1);++outb(COR_VALUE,addr);+mdelay(1);++/* Just in case, wait more until the card is no longer busy */+timeout=jiffies+(TMD_RESET_TIME*HZ/1000);+reg=hermes_read_regn(hw,CMD);+while(time_before(jiffies,timeout)&&(reg&HERMES_CMD_BUSY)){+mdelay(1);+reg=hermes_read_regn(hw,CMD);+}++/* Did we timeout ? */+if(reg&HERMES_CMD_BUSY){+printk(KERN_ERRPFX"Busy timeout\n");+return-ETIMEDOUT;+}++return0;+}+staticintorinoco_tmd_init_one(structpci_dev*pdev,conststructpci_device_id*ent){interr=0;-u32reg,addr;structorinoco_private*priv=NULL;-unsignedlongpccard_ioaddr=0;-unsignedlongpccard_iolen=0;+structorinoco_tmd_card*card;structnet_device*dev=NULL;void__iomem*mem;err=pci_enable_device(pdev);if(err){printk(KERN_ERRPFX"Cannot enable PCI device\n");-return-EIO;+returnerr;}-printk(KERN_DEBUGPFX"TMD setup\n");-pccard_ioaddr=pci_resource_start(pdev,2);-pccard_iolen=pci_resource_len(pdev,2);-if(!request_region(pccard_ioaddr,pccard_iolen,DRIVER_NAME)){-printk(KERN_ERRPFX"I/O resource at 0x%lx len 0x%lx busy\n",-pccard_ioaddr,pccard_iolen);-err=-EBUSY;-gotoout;+err=pci_request_regions(pdev,DRIVER_NAME);+if(err!=0){+printk(KERN_ERRPFX"Cannot obtain PCI resources\n");+gotofail_resources;}-addr=pci_resource_start(pdev,1);-outb(COR_VALUE,addr);-mdelay(1);-reg=inb(addr);-if(reg!=COR_VALUE){-printk(KERN_ERRPFX"Error setting TMD COR values %x should be %x\n",reg,COR_VALUE);-err=-EIO;-gotoout2;++mem=pci_iomap(pdev,2,0);+if(!mem){+err=-ENOMEM;+gotofail_iomap;}/* Allocate network device */-dev=alloc_orinocodev(0,NULL);+dev=alloc_orinocodev(sizeof(*card),orinoco_tmd_cor_reset);if(!dev){printk(KERN_ERRPFX"Cannot allocate network device\n");err=-ENOMEM;-gotoout2;-}--mem=pci_iomap(pdev,2,0);-if(!mem){-err=-ENOMEM;-gotoout3;+gotofail_alloc;}priv=netdev_priv(dev);-dev->base_addr=pccard_ioaddr;+card=priv->card;+card->tmd_io=pci_resource_start(pdev,1);+dev->base_addr=pci_resource_start(pdev,2);SET_MODULE_OWNER(dev);SET_NETDEV_DEV(dev,&pdev->dev);
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson
From: Jeff Garzik <hidden> Date: 2005-02-02 01:48:50
David Gibson wrote:
Following are a bunch of patches which make a few more steps towards
the long overdue merge of the CVS orinoco driver into mainline. These
do make behavioural changes to the driver, but they should all be
trivial and largely cosmetic.
OK, the changes look good, but I was waiting for the previous stuff you
submitted to land in upstream.
Could I convince you to rediff and resend against the latest 2.6.x snapshot?
At the time you sent these, they conflicted with a previous cleanup you
had sent, and that I had applied.
Jeff
From: David Gibson <hidden> Date: 2005-02-10 02:53:58
On Tue, Feb 01, 2005 at 08:48:31PM -0500, Jeff Garzik wrote:
David Gibson wrote:
quoted
Following are a bunch of patches which make a few more steps towards
the long overdue merge of the CVS orinoco driver into mainline. These
do make behavioural changes to the driver, but they should all be
trivial and largely cosmetic.
OK, the changes look good, but I was waiting for the previous stuff you
submitted to land in upstream.
Could I convince you to rediff and resend against the latest 2.6.x snapshot?
At the time you sent these, they conflicted with a previous cleanup you
had sent, and that I had applied.
Ok, I'm a little confused. The last batch were all checked against
the then-current netdev-2.6 bk tree, or was the conflict with
something you'd applied between when I pulled the tree and you looked
at the patches? As far as I can tell all the previous batch of
patches I sent you are in netdev (plus a couple from this batch), but
most are still not in upstream.
I'm now not entirely clear on whether you want patches against the
netdev bk, or against Linus bk/snapshots.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson
From: David Gibson <hidden> Date: 2005-02-10 03:23:13
On Wed, Feb 09, 2005 at 10:07:08PM -0500, Jeff Garzik wrote:
David Gibson wrote:
quoted
I'm now not entirely clear on whether you want patches against the
netdev bk, or against Linus bk/snapshots.
Please send diff'd against vanilla Linus upstream.
Ok, in that case do you want me to resend the things which are in
netdev but not vanilla?
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist. NOT _the_ _other_ _way_
| _around_!
http://www.ozlabs.org/people/dgibson