17 #include <linux/pci.h>
18 #include <linux/slab.h>
23 #include <linux/module.h>
89 "please get a LM86(PCI) firmware a try again.\n");
98 left =
min((
u32)0x1000, remains);
102 device_addr += 0x1000;
136 static void p54p_refill_rx_ring(
struct ieee80211_hw *dev,
147 limit = ring_limit -
limit;
149 i = idx % ring_limit;
150 while (limit-- > 1) {
156 skb = dev_alloc_skb(priv->
common.rx_mtu + 32);
160 mapping = pci_map_single(priv->
pdev,
161 skb_tail_pointer(skb),
165 if (pci_dma_mapping_error(priv->
pdev, mapping)) {
168 "RX DMA Mapping error\n");
197 i = (*index) % ring_limit;
217 "exceeds length threshold.\n");
219 len = priv->
common.rx_mtu;
222 pci_dma_sync_single_for_cpu(priv->
pdev, dma_addr,
227 pci_unmap_single(priv->
pdev, dma_addr,
233 pci_dma_sync_single_for_device(priv->
pdev, dma_addr,
242 p54p_refill_rx_ring(dev, ring_index, ring, ring_limit, rx_buf, *index);
255 i = (*index) % ring_limit;
281 static void p54p_tasklet(
unsigned long dev_id)
305 static irqreturn_t p54p_interrupt(
int irq,
void *dev_id)
320 tasklet_schedule(&priv->
tasklet);
341 mapping = pci_map_single(priv->
pdev, skb->
data, skb->
len,
343 if (pci_dma_mapping_error(priv->
pdev, mapping)) {
344 spin_unlock_irqrestore(&priv->
lock, flags);
346 dev_err(&priv->
pdev->dev,
"TX DMA mapping error\n");
359 spin_unlock_irqrestore(&priv->
lock, flags);
385 pci_unmap_single(priv->
pdev,
396 pci_unmap_single(priv->
pdev,
407 pci_unmap_single(priv->
pdev,
419 pci_unmap_single(priv->
pdev,
428 memset(ring_control, 0,
sizeof(*ring_control));
440 dev_err(&priv->
pdev->dev,
"failed to register IRQ handler\n");
445 err = p54p_upload_firmware(dev);
453 p54p_refill_rx_ring(dev, 0, priv->
ring_control->rx_data,
456 p54p_refill_rx_ring(dev, 2, priv->
ring_control->rx_mgmt,
491 static void p54p_firmware_step2(
const struct firmware *
fw,
500 dev_err(&pdev->
dev,
"Cannot find firmware (isl3886pci)\n");
507 err = p54p_open(dev);
537 device_unlock(parent);
548 unsigned long mem_addr, mem_len;
554 dev_err(&pdev->
dev,
"Cannot enable new PCI device\n");
560 if (mem_len <
sizeof(
struct p54p_csr)) {
561 dev_err(&pdev->
dev,
"Too short PCI resources\n");
562 goto err_disable_dev;
567 dev_err(&pdev->
dev,
"Cannot obtain PCI resources\n");
568 goto err_disable_dev;
573 dev_err(&pdev->
dev,
"No suitable DMA available\n");
580 pci_write_config_byte(pdev, 0x40, 0);
581 pci_write_config_byte(pdev, 0x41, 0);
585 dev_err(&pdev->
dev,
"ieee80211 alloc failed\n");
594 SET_IEEE80211_DEV(dev, &pdev->
dev);
595 pci_set_drvdata(pdev, dev);
599 dev_err(&pdev->
dev,
"Cannot map device memory\n");
607 dev_err(&pdev->
dev,
"Cannot allocate rings\n");
611 priv->
common.open = p54p_open;
612 priv->
common.stop = p54p_stop;
613 priv->
common.tx = p54p_tx;
620 priv, p54p_firmware_step2);
631 pci_set_drvdata(pdev,
NULL);
684 static const struct dev_pm_ops p54pci_pm_ops = {
686 .resume = p54p_resume,
687 .freeze = p54p_suspend,
689 .poweroff = p54p_suspend,
690 .restore = p54p_resume,
693 #define P54P_PM_OPS (&p54pci_pm_ops)
695 #define P54P_PM_OPS (NULL)
700 .id_table = p54p_table,