commit 17083477ed4da412daba5fa19db2ede7d8fd28ce Author: Jiri Slaby Date: Thu Jun 21 11:34:27 2007 +0200 insertable module now (basic pci init) diff --git a/ath/if_ath_pci.c b/ath/if_ath_pci.c index dc414f1..2a9f98d 100644 --- a/ath/if_ath_pci.c +++ b/ath/if_ath_pci.c @@ -80,23 +80,23 @@ MODULE_PARM_DESC(xchanmode, "Enable/disable extended channel mode"); * the HAL check them by defining a probe method. */ static struct pci_device_id ath_pci_id_table[] __devinitdata = { - { PCI_VDEVICE(ATHEROS, 0x0207) }, /* 5210 early */ - { PCI_VDEVICE(ATHEROS, 0x0007) }, /* 5210 */ - { PCI_VDEVICE(ATHEROS, 0x0011) }, /* 5311 */ - { PCI_VDEVICE(ATHEROS, 0x0012) }, /* 5211 */ - { PCI_VDEVICE(ATHEROS, 0x0013) }, /* 5212 */ - { PCI_VDEVICE(3COM_2, 0x0013) }, /* 3com 5212 */ - { PCI_VDEVICE(3COM, 0x0013) }, /* 3com 3CRDAG675 5212 */ - { PCI_VDEVICE(ATHEROS, 0x1014) }, /* IBM minipci 5212 */ - { PCI_VDEVICE(ATHEROS, 0x0014) }, /* 5212 combatible */ - { PCI_VDEVICE(ATHEROS, 0x0015) }, /* 5212 combatible */ - { PCI_VDEVICE(ATHEROS, 0x0016) }, /* 5212 combatible */ - { PCI_VDEVICE(ATHEROS, 0x0017) }, /* 5212 combatible */ - { PCI_VDEVICE(ATHEROS, 0x0018) }, /* 5212 combatible */ - { PCI_VDEVICE(ATHEROS, 0x0019) }, /* 5212 combatible */ - { PCI_VDEVICE(ATHEROS, 0x001a) }, /* 2413 Griffin-lite */ - { PCI_VDEVICE(ATHEROS, 0x001b) }, /* 5413 Eagle */ - { PCI_VDEVICE(ATHEROS, 0x001c) }, /* 5424 Condor (PCI-E)*/ + { PCI_VDEVICE(ATHEROS, 0x0207), .driver_data = AR5K_AR5210 }, /* 5210 early */ + { PCI_VDEVICE(ATHEROS, 0x0007), .driver_data = AR5K_AR5210 }, /* 5210 */ + { PCI_VDEVICE(ATHEROS, 0x0011), .driver_data = AR5K_AR5211 }, /* 5311 */ + { PCI_VDEVICE(ATHEROS, 0x0012), .driver_data = AR5K_AR5211 }, /* 5211 */ + { PCI_VDEVICE(ATHEROS, 0x0013), .driver_data = AR5K_AR5212 }, /* 5212 */ + { PCI_VDEVICE(3COM_2, 0x0013), .driver_data = AR5K_AR5212 }, /* 3com 5212 */ + { PCI_VDEVICE(3COM, 0x0013), .driver_data = AR5K_AR5212 }, /* 3com 3CRDAG675 5212 */ + { PCI_VDEVICE(ATHEROS, 0x1014), .driver_data = AR5K_AR5212 }, /* IBM minipci 5212 */ + { PCI_VDEVICE(ATHEROS, 0x0014), .driver_data = AR5K_AR5212 }, + { PCI_VDEVICE(ATHEROS, 0x0015), .driver_data = AR5K_AR5212 }, + { PCI_VDEVICE(ATHEROS, 0x0016), .driver_data = AR5K_AR5212 }, + { PCI_VDEVICE(ATHEROS, 0x0017), .driver_data = AR5K_AR5212 }, + { PCI_VDEVICE(ATHEROS, 0x0018), .driver_data = AR5K_AR5212 }, + { PCI_VDEVICE(ATHEROS, 0x0019), .driver_data = AR5K_AR5212 }, + { PCI_VDEVICE(ATHEROS, 0x001a), .driver_data = AR5K_AR5212 }, /* 2413 Griffin-lite */ + { PCI_VDEVICE(ATHEROS, 0x001b), .driver_data = AR5K_AR5212 }, /* 5413 Eagle */ + { PCI_VDEVICE(ATHEROS, 0x001c), .driver_data = AR5K_AR5212 }, /* 5424 Condor (PCI-E)*/ { 0 } }; MODULE_DEVICE_TABLE(pci, ath_pci_id_table); @@ -168,6 +168,8 @@ static irqreturn_t ath_intr(int irq, void *dev_id) DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid; ignored\n", __func__); return IRQ_NONE; } + return IRQ_HANDLED; + if (!ath_hw_irq_pending(ah)) /* shared irq, not for us */ return IRQ_NONE; if ((dev->flags & (IFF_RUNNING|IFF_UP)) != (IFF_RUNNING|IFF_UP)) { @@ -264,29 +266,11 @@ static int ath_attach(struct pci_dev *pdev, struct ieee80211_hw *hw) struct ath_hal *ah; enum ath5k_status status; int error = 0, i; - u8 csz; DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, pdev->device); + return 0; /* - * Cache line size is used to size and align various - * structures used to communicate with the hardware. - */ - pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &csz); - /* XXX assert csz is non-zero */ - sc->sc_cachelsz = csz << 2; /* convert to bytes */ - - ATH_LOCK_INIT(sc); - ATH_TXBUF_LOCK_INIT(sc); - -/* tasklet_init(&sc->sc_rxtq, ath_rx_tasklet, (unsigned long)hw); - tasklet_init(&sc->sc_rxorntq, ath_rxorn_tasklet, (unsigned long)hw); - tasklet_init(&sc->sc_fataltq, ath_fatal_tasklet, (unsigned long)hw); - tasklet_init(&sc->sc_bmisstq, ath_bmiss_tasklet, (unsigned long)hw); - tasklet_init(&sc->sc_bstuckq, ath_bstuck_tasklet, (unsigned long)hw); - tasklet_init(&sc->sc_radartq, ath_radar_tasklet, (unsigned long)hw);*/ - - /* * Attach the hal */ ah = ath5k_hw_init(pdev->device, sc, sc->sc_iobase, &status); @@ -663,13 +647,11 @@ bad: return error; } -static int ath_detach(struct ieee80211_hw *hw) +static void ath_detach(struct ieee80211_hw *hw) { - struct ath_softc *sc = hw->priv; -// struct ieee80211com *ic = &sc->sc_ic; +// struct ath_softc *sc = hw->priv; // ath_stop(hw); - sc->sc_invalid = 1; /* * NB: the order of these is important: * o call the 802.11 layer before detaching the hal to @@ -686,7 +668,7 @@ static int ath_detach(struct ieee80211_hw *hw) // ath_rate_detach(sc->sc_rc); // ath_desc_free(sc); // ath_tx_cleanup(sc); - ath5k_hw_detach(sc->sc_ah); +// ath5k_hw_detach(sc->sc_ah); /* * NB: can't reclaim these until after ieee80211_ifdetach @@ -696,8 +678,19 @@ static int ath_detach(struct ieee80211_hw *hw) // ath_dynamic_sysctl_unregister(sc); // ath_rawdev_detach(sc); // unregister_netdev(dev); +} - return 0; +static const char *ath_chip_name(u8 mac_version) +{ + switch (mac_version) { + case AR5K_AR5210: + return "AR5210"; + case AR5K_AR5211: + return "AR5211"; + case AR5K_AR5212: + return "AR5212"; + } + return "Unknown"; } static int __devinit ath_pci_probe(struct pci_dev *pdev, @@ -706,19 +699,18 @@ static int __devinit ath_pci_probe(struct pci_dev *pdev, void __iomem *mem; struct ath_softc *sc; struct ieee80211_hw *hw; - const char *athname; - int retval; + int ret; u8 csz; - retval = pci_enable_device(pdev); - if (retval) { + ret = pci_enable_device(pdev); + if (ret) { dev_err(&pdev->dev, "can't enable device\n"); goto err; } /* XXX 32-bit addressing only */ - retval = pci_set_dma_mask(pdev, DMA_32BIT_MASK); - if (retval) { + ret = pci_set_dma_mask(pdev, DMA_32BIT_MASK); + if (ret) { dev_err(&pdev->dev, "32-bit DMA not available\n"); goto err_dis; } @@ -754,8 +746,8 @@ static int __devinit ath_pci_probe(struct pci_dev *pdev, */ pci_write_config_byte(pdev, 0x41, 0); - retval = pci_request_region(pdev, 0, "ath"); - if (retval) { + ret = pci_request_region(pdev, 0, "ath"); + if (ret) { dev_err(&pdev->dev, "cannot reserve PCI memory region\n"); goto err_dis; } @@ -763,12 +755,14 @@ static int __devinit ath_pci_probe(struct pci_dev *pdev, mem = pci_iomap(pdev, 0, 0); if (!mem) { dev_err(&pdev->dev, "cannot remap PCI memory region\n") ; + ret = -EIO; goto err_reg; } hw = ieee80211_alloc_hw(sizeof(*sc), &ath_hw_ops); if (hw == NULL) { dev_err(&pdev->dev, "cannot allocate ieee80211_hw\n"); + ret = -ENOMEM; goto err_map; } @@ -782,21 +776,30 @@ static int __devinit ath_pci_probe(struct pci_dev *pdev, */ sc->sc_invalid = 1; sc->sc_iobase = mem; - sc->sc_bdev = pdev; + sc->sc_cachelsz = csz * sizeof(u32); /* convert to bytes */ + mutex_init(&sc->lock); + spin_lock_init(&sc->sc_txbuflock); + +/* tasklet_init(&sc->sc_rxtq, ath_rx_tasklet, (unsigned long)hw); + tasklet_init(&sc->sc_rxorntq, ath_rxorn_tasklet, (unsigned long)hw); + tasklet_init(&sc->sc_fataltq, ath_fatal_tasklet, (unsigned long)hw); + tasklet_init(&sc->sc_bmisstq, ath_bmiss_tasklet, (unsigned long)hw); + tasklet_init(&sc->sc_bstuckq, ath_bstuck_tasklet, (unsigned long)hw); + tasklet_init(&sc->sc_radartq, ath_radar_tasklet, (unsigned long)hw);*/ pci_set_drvdata(pdev, hw); - if (request_irq(pdev->irq, ath_intr, IRQF_SHARED, "ath", sc)) { + ret = request_irq(pdev->irq, ath_intr, IRQF_SHARED, "ath", sc); + if (ret) { dev_err(&pdev->dev, "request_irq failed\n"); goto err_free; } - if (ath_attach(pdev, hw) != 0) + ret = ath_attach(pdev, hw); + if (ret) goto err_irq; - athname = ath_hal_probe(id->vendor, id->device); - dev_info(&pdev->dev, "%s: irq=%d\n", - athname ? athname : "Atheros ???", pdev->irq); + dev_info(&pdev->dev, "%s chip found\n", ath_chip_name(id->driver_data)); /* ready to process interrupts */ sc->sc_invalid = 0; @@ -813,7 +816,7 @@ err_reg: err_dis: pci_disable_device(pdev); err: - return retval; + return ret; } static void __devexit ath_pci_remove(struct pci_dev *pdev) @@ -977,15 +980,10 @@ static struct ctl_table_header *ath_sysctl_header; /* * Module glue. */ -static char version[] = ATH_PCI_VERSION " (EXPERIMENTAL)"; -static char dev_info[] = "ath_pci"; - static int __init init_ath_pci(void) { int ret; - printk(KERN_INFO "%s: %s\n", dev_info, version); - ret = pci_register_driver(&ath_pci_drv_id); if (ret) { printk(KERN_ERR "ath_pci: can't register pci driver\n"); @@ -1001,8 +999,6 @@ static void __exit exit_ath_pci(void) if (ath_sysctl_header) unregister_sysctl_table(ath_sysctl_header); pci_unregister_driver(&ath_pci_drv_id); - - printk(KERN_INFO "%s: driver unloaded\n", dev_info); } module_init(init_ath_pci); @@ -1012,3 +1008,4 @@ MODULE_AUTHOR("Errno Consulting, Sam Leffler"); MODULE_DESCRIPTION("Support for Atheros 802.11 wireless LAN cards."); MODULE_SUPPORTED_DEVICE("Atheros WLAN cards"); MODULE_LICENSE("Dual BSD/GPL"); +MODULE_VERSION(ATH_PCI_VERSION " (EXPERIMENTAL)"); diff --git a/ath/if_athvar.h b/ath/if_athvar.h index 2a5aedc..55e3df7 100644 --- a/ath/if_athvar.h +++ b/ath/if_athvar.h @@ -178,8 +178,8 @@ struct ath_txq { struct ath_softc { void __iomem *sc_iobase; /* address of the device */ - struct semaphore sc_lock; /* dev-level lock */ - struct net_device_stats sc_devstats; /* device statistics */ + struct mutex lock; /* dev-level lock */ +// struct net_device_stats sc_devstats; /* device statistics */ struct ath_stats sc_stats; /* private statistics */ struct ieee80211_hw *hw; /* IEEE 802.11 common */ @@ -196,7 +196,6 @@ struct ath_softc { enum ieee80211_state, int); void (*sc_node_free)(struct ieee80211_node *); #endif - void *sc_bdev; /* associated bus device */ struct ath_desc *sc_desc; /* TX/RX descriptors */ size_t sc_desc_len; /* size of TX/RX descriptors */ u16 sc_cachelsz; /* cache line size */ @@ -305,24 +304,14 @@ struct ath_softc { struct ctl_table *sc_sysctls; }; -#define ATH_LOCK_INIT(_sc) \ - init_MUTEX(&(_sc)->sc_lock) -#define ATH_LOCK_DESTROY(_sc) -#define ATH_LOCK(_sc) down(&(_sc)->sc_lock) -#define ATH_UNLOCK(_sc) up(&(_sc)->sc_lock) -#define ATH_LOCK_ASSERT(_sc) -//TODO: KASSERT(spin_is_locked(&(_sc)->sc_lock), ("buf not locked!")) - #define ATH_TXQ_SETUP(sc, i) ((sc)->sc_txqsetup & (1<sc_txbuflock) -#define ATH_TXBUF_LOCK_DESTROY(_sc) #define ATH_TXBUF_LOCK(_sc) spin_lock(&(_sc)->sc_txbuflock) #define ATH_TXBUF_UNLOCK(_sc) spin_unlock(&(_sc)->sc_txbuflock) #define ATH_TXBUF_LOCK_BH(_sc) spin_lock_bh(&(_sc)->sc_txbuflock) #define ATH_TXBUF_UNLOCK_BH(_sc) spin_unlock_bh(&(_sc)->sc_txbuflock) #define ATH_TXBUF_LOCK_ASSERT(_sc) \ - KASSERT(spin_is_locked(&(_sc)->sc_txbuflock), ("txbuf not locked!")) + KASSERT(spin_is_locked(&(_sc)->sc_txbuflock), "txbuf not locked!") int ath_ioctl_ethtool(struct ath_softc *, int, void __user *); void ath_sysctl_register(void); diff --git a/openhal/ath5k.h b/openhal/ath5k.h index 451c3cc..97cc7cc 100644 --- a/openhal/ath5k.h +++ b/openhal/ath5k.h @@ -1066,7 +1066,6 @@ struct ath_hal { typedef bool (ath5k_rfgain_t)(struct ath_hal *, struct ath5k_channel *, u_int); /* General Functions */ -const char *ath_hal_probe(u16 vendor, u16 device); u16 ath_hal_computetxtime(struct ath_hal *hal, const struct ath5k_rate_table *rates, u32 frame_length, u16 rate_index, bool short_preamble); unsigned int ath_hal_getwirelessmodes(struct ath_hal *hal, enum ieee80211_countrycode country) ; /* Attach/Detach Functions */ diff --git a/openhal/ath5k_hw.c b/openhal/ath5k_hw.c index a56d14e..1aba99b 100644 --- a/openhal/ath5k_hw.c +++ b/openhal/ath5k_hw.c @@ -150,37 +150,6 @@ static const struct ath5k_ini_rfgain ath5k_rfg[] = AR5K_INI_RFGAIN; General Functions \*******************/ -/* - * Perform a lookup if the device is supported by the HAL - * and return the chip name. - * TODO:Left here for combatibility, change it in at5k - */ -const char * -ath_hal_probe(u16 vendor, u16 device) -{ - int i; - - /* - * Perform a linear search on the table of supported devices - */ - for (i = 0; i < ARRAY_SIZE(ath5k_known_products); i++) { - if (vendor == ath5k_known_products[i].vendor && - device == ath5k_known_products[i].device){ - switch (ath5k_known_products[i].mac_version) { - case AR5K_AR5210: - return("AR5210"); - case AR5K_AR5211: - return("AR5211"); - case AR5K_AR5212: - return("AR5212"); - default: - return ""; - } - } - } - - return NULL; -} /* * Calculate transmition time of a frame