aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/bcm43xx/bcm43xx_main.c
diff options
context:
space:
mode:
authorMichael Buesch <mbuesch@freenet.de>2006-02-12 10:47:44 -0500
committerJohn W. Linville <linville@tuxdriver.com>2006-03-27 11:18:32 -0500
commit77db31ea4322f2dd12dc814d6664ae96517604c0 (patch)
tree358519550cf715249ba836d06eb651d1fdf86079 /drivers/net/wireless/bcm43xx/bcm43xx_main.c
parent5c57807afcc28a6b8fb579ef2c79e49f0b688425 (diff)
[PATCH] bcm43xx: Partially fix PIO code. Add Kconfig option for PIO or DMA mode (or both).
Signed-off-by: Michael Buesch <mbuesch@freenet.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/bcm43xx/bcm43xx_main.c')
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c69
1 files changed, 41 insertions, 28 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 4c4a2d71ca04..4e49da99818d 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -62,10 +62,15 @@ MODULE_LICENSE("GPL");
62extern char *nvram_get(char *name); 62extern char *nvram_get(char *name);
63#endif 63#endif
64 64
65/* Module parameters */ 65#if defined(CONFIG_BCM43XX_DMA) && defined(CONFIG_BCM43XX_PIO)
66static int modparam_pio; 66static int modparam_pio;
67module_param_named(pio, modparam_pio, int, 0444); 67module_param_named(pio, modparam_pio, int, 0444);
68MODULE_PARM_DESC(pio, "enable(1) / disable(0) PIO mode"); 68MODULE_PARM_DESC(pio, "enable(1) / disable(0) PIO mode");
69#elif defined(CONFIG_BCM43XX_DMA)
70# define modparam_pio 0
71#elif defined(CONFIG_BCM43XX_PIO)
72# define modparam_pio 1
73#endif
69 74
70static int modparam_bad_frames_preempt; 75static int modparam_bad_frames_preempt;
71module_param_named(bad_frames_preempt, modparam_bad_frames_preempt, int, 0444); 76module_param_named(bad_frames_preempt, modparam_bad_frames_preempt, int, 0444);
@@ -1528,7 +1533,8 @@ void bcm43xx_wireless_core_reset(struct bcm43xx_private *bcm, int connect_phy)
1528{ 1533{
1529 u32 flags = 0x00040000; 1534 u32 flags = 0x00040000;
1530 1535
1531 if ((bcm43xx_core_enabled(bcm)) && (!bcm->pio_mode)) { 1536 if ((bcm43xx_core_enabled(bcm)) &&
1537 !bcm43xx_using_pio(bcm)) {
1532//FIXME: Do we _really_ want #ifndef CONFIG_BCM947XX here? 1538//FIXME: Do we _really_ want #ifndef CONFIG_BCM947XX here?
1533#ifndef CONFIG_BCM947XX 1539#ifndef CONFIG_BCM947XX
1534 /* reset all used DMA controllers. */ 1540 /* reset all used DMA controllers. */
@@ -1635,7 +1641,7 @@ static inline void handle_irq_transmit_status(struct bcm43xx_private *bcm)
1635 } 1641 }
1636 //TODO: There are more (unknown) flags to test. see bcm43xx_main.h 1642 //TODO: There are more (unknown) flags to test. see bcm43xx_main.h
1637 1643
1638 if (bcm->pio_mode) 1644 if (bcm43xx_using_pio(bcm))
1639 bcm43xx_pio_handle_xmitstatus(bcm, &stat); 1645 bcm43xx_pio_handle_xmitstatus(bcm, &stat);
1640 else 1646 else
1641 bcm43xx_dma_handle_xmitstatus(bcm, &stat); 1647 bcm43xx_dma_handle_xmitstatus(bcm, &stat);
@@ -1933,7 +1939,7 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
1933 assert(!(dma_reason[1] & BCM43xx_DMAIRQ_RX_DONE)); 1939 assert(!(dma_reason[1] & BCM43xx_DMAIRQ_RX_DONE));
1934 assert(!(dma_reason[2] & BCM43xx_DMAIRQ_RX_DONE)); 1940 assert(!(dma_reason[2] & BCM43xx_DMAIRQ_RX_DONE));
1935 if (dma_reason[0] & BCM43xx_DMAIRQ_RX_DONE) { 1941 if (dma_reason[0] & BCM43xx_DMAIRQ_RX_DONE) {
1936 if (bcm->pio_mode) 1942 if (bcm43xx_using_pio(bcm))
1937 bcm43xx_pio_rx(bcm->current_core->pio->queue0); 1943 bcm43xx_pio_rx(bcm->current_core->pio->queue0);
1938 else 1944 else
1939 bcm43xx_dma_rx(bcm->current_core->dma->rx_ring0); 1945 bcm43xx_dma_rx(bcm->current_core->dma->rx_ring0);
@@ -1941,7 +1947,7 @@ static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
1941 } 1947 }
1942 if (dma_reason[3] & BCM43xx_DMAIRQ_RX_DONE) { 1948 if (dma_reason[3] & BCM43xx_DMAIRQ_RX_DONE) {
1943 if (likely(bcm->current_core->rev < 5)) { 1949 if (likely(bcm->current_core->rev < 5)) {
1944 if (bcm->pio_mode) 1950 if (bcm43xx_using_pio(bcm))
1945 bcm43xx_pio_rx(bcm->current_core->pio->queue3); 1951 bcm43xx_pio_rx(bcm->current_core->pio->queue3);
1946 else 1952 else
1947 bcm43xx_dma_rx(bcm->current_core->dma->rx_ring1); 1953 bcm43xx_dma_rx(bcm->current_core->dma->rx_ring1);
@@ -1999,7 +2005,7 @@ void bcm43xx_interrupt_ack(struct bcm43xx_private *bcm,
1999 bcm->dma_reason[3] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA4_REASON) 2005 bcm->dma_reason[3] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA4_REASON)
2000 & 0x0001dc00; 2006 & 0x0001dc00;
2001 2007
2002 if ((bcm->pio_mode) && 2008 if (bcm43xx_using_pio(bcm) &&
2003 (bcm->current_core->rev < 3) && 2009 (bcm->current_core->rev < 3) &&
2004 (!(reason & BCM43xx_IRQ_PIO_WORKAROUND))) { 2010 (!(reason & BCM43xx_IRQ_PIO_WORKAROUND))) {
2005 /* Apply a PIO specific workaround to the dma_reasons */ 2011 /* Apply a PIO specific workaround to the dma_reasons */
@@ -2624,7 +2630,7 @@ static int bcm43xx_chip_init(struct bcm43xx_private *bcm)
2624 value32 |= 0x100000; //FIXME: What's this? Is this correct? 2630 value32 |= 0x100000; //FIXME: What's this? Is this correct?
2625 bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, value32); 2631 bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, value32);
2626 2632
2627 if (bcm->pio_mode) { 2633 if (bcm43xx_using_pio(bcm)) {
2628 bcm43xx_write32(bcm, 0x0210, 0x00000100); 2634 bcm43xx_write32(bcm, 0x0210, 0x00000100);
2629 bcm43xx_write32(bcm, 0x0230, 0x00000100); 2635 bcm43xx_write32(bcm, 0x0230, 0x00000100);
2630 bcm43xx_write32(bcm, 0x0250, 0x00000100); 2636 bcm43xx_write32(bcm, 0x0250, 0x00000100);
@@ -3123,15 +3129,12 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm)
3123 if (bcm->current_core->rev >= 5) 3129 if (bcm->current_core->rev >= 5)
3124 bcm43xx_write16(bcm, 0x043C, 0x000C); 3130 bcm43xx_write16(bcm, 0x043C, 0x000C);
3125 3131
3126 if (!bcm->pio_mode) { 3132 if (bcm43xx_using_pio(bcm))
3127 err = bcm43xx_dma_init(bcm);
3128 if (err)
3129 goto err_chip_cleanup;
3130 } else {
3131 err = bcm43xx_pio_init(bcm); 3133 err = bcm43xx_pio_init(bcm);
3132 if (err) 3134 else
3133 goto err_chip_cleanup; 3135 err = bcm43xx_dma_init(bcm);
3134 } 3136 if (err)
3137 goto err_chip_cleanup;
3135 bcm43xx_write16(bcm, 0x0612, 0x0050); 3138 bcm43xx_write16(bcm, 0x0612, 0x0050);
3136 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x0416, 0x0050); 3139 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x0416, 0x0050);
3137 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x0414, 0x01F4); 3140 bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x0414, 0x01F4);
@@ -4001,8 +4004,8 @@ static inline int bcm43xx_tx(struct bcm43xx_private *bcm,
4001{ 4004{
4002 int err = -ENODEV; 4005 int err = -ENODEV;
4003 4006
4004 if (bcm->pio_mode) 4007 if (bcm43xx_using_pio(bcm))
4005 err = bcm43xx_pio_transfer_txb(bcm, txb); 4008 err = bcm43xx_pio_tx(bcm, txb);
4006 else 4009 else
4007 err = bcm43xx_dma_tx(bcm, txb); 4010 err = bcm43xx_dma_tx(bcm, txb);
4008 4011
@@ -4158,10 +4161,10 @@ static int bcm43xx_net_stop(struct net_device *net_dev)
4158 return 0; 4161 return 0;
4159} 4162}
4160 4163
4161static void bcm43xx_init_private(struct bcm43xx_private *bcm, 4164static int bcm43xx_init_private(struct bcm43xx_private *bcm,
4162 struct net_device *net_dev, 4165 struct net_device *net_dev,
4163 struct pci_dev *pci_dev, 4166 struct pci_dev *pci_dev,
4164 struct workqueue_struct *wq) 4167 struct workqueue_struct *wq)
4165{ 4168{
4166 bcm->ieee = netdev_priv(net_dev); 4169 bcm->ieee = netdev_priv(net_dev);
4167 bcm->softmac = ieee80211_priv(net_dev); 4170 bcm->softmac = ieee80211_priv(net_dev);
@@ -4190,13 +4193,17 @@ static void bcm43xx_init_private(struct bcm43xx_private *bcm,
4190 (unsigned long)bcm); 4193 (unsigned long)bcm);
4191 tasklet_disable_nosync(&bcm->isr_tasklet); 4194 tasklet_disable_nosync(&bcm->isr_tasklet);
4192 if (modparam_pio) { 4195 if (modparam_pio) {
4193 bcm->pio_mode = 1; 4196 bcm->__using_pio = 1;
4194 } else { 4197 } else {
4195 if (pci_set_dma_mask(pci_dev, DMA_30BIT_MASK) == 0) { 4198 if (pci_set_dma_mask(pci_dev, DMA_30BIT_MASK)) {
4196 bcm->pio_mode = 0; 4199#ifdef CONFIG_BCM43XX_PIO
4197 } else {
4198 printk(KERN_WARNING PFX "DMA not supported. Falling back to PIO.\n"); 4200 printk(KERN_WARNING PFX "DMA not supported. Falling back to PIO.\n");
4199 bcm->pio_mode = 1; 4201 bcm->__using_pio = 1;
4202#else
4203 printk(KERN_ERR PFX "FATAL: DMA not supported and PIO not configured. "
4204 "Recompile the driver with PIO support, please.\n");
4205 return -ENODEV;
4206#endif /* CONFIG_BCM43XX_PIO */
4200 } 4207 }
4201 } 4208 }
4202 bcm->rts_threshold = BCM43xx_DEFAULT_RTS_THRESHOLD; 4209 bcm->rts_threshold = BCM43xx_DEFAULT_RTS_THRESHOLD;
@@ -4210,6 +4217,8 @@ static void bcm43xx_init_private(struct bcm43xx_private *bcm,
4210 bcm->ieee->tx_headroom = sizeof(struct bcm43xx_txhdr); 4217 bcm->ieee->tx_headroom = sizeof(struct bcm43xx_txhdr);
4211 bcm->ieee->set_security = bcm43xx_ieee80211_set_security; 4218 bcm->ieee->set_security = bcm43xx_ieee80211_set_security;
4212 bcm->ieee->hard_start_xmit = bcm43xx_ieee80211_hard_start_xmit; 4219 bcm->ieee->hard_start_xmit = bcm43xx_ieee80211_hard_start_xmit;
4220
4221 return 0;
4213} 4222}
4214 4223
4215static int __devinit bcm43xx_init_one(struct pci_dev *pdev, 4224static int __devinit bcm43xx_init_one(struct pci_dev *pdev,
@@ -4261,7 +4270,9 @@ static int __devinit bcm43xx_init_one(struct pci_dev *pdev,
4261 err = -ENOMEM; 4270 err = -ENOMEM;
4262 goto err_free_netdev; 4271 goto err_free_netdev;
4263 } 4272 }
4264 bcm43xx_init_private(bcm, net_dev, pdev, wq); 4273 err = bcm43xx_init_private(bcm, net_dev, pdev, wq);
4274 if (err)
4275 goto err_destroy_wq;
4265 4276
4266 pci_set_drvdata(pdev, net_dev); 4277 pci_set_drvdata(pdev, net_dev);
4267 4278
@@ -4325,7 +4336,9 @@ static void bcm43xx_chip_reset(void *_bcm)
4325 bcm43xx_free_board(bcm); 4336 bcm43xx_free_board(bcm);
4326 bcm->firmware_norelease = 0; 4337 bcm->firmware_norelease = 0;
4327 bcm43xx_detach_board(bcm); 4338 bcm43xx_detach_board(bcm);
4328 bcm43xx_init_private(bcm, net_dev, pci_dev, wq); 4339 err = bcm43xx_init_private(bcm, net_dev, pci_dev, wq);
4340 if (err)
4341 goto failure;
4329 err = bcm43xx_attach_board(bcm); 4342 err = bcm43xx_attach_board(bcm);
4330 if (err) 4343 if (err)
4331 goto failure; 4344 goto failure;