2007-09-26 03:11:01 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Linux device driver for PCI based Prism54
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
|
2008-08-24 22:30:38 +02:00
|
|
|
* Copyright (c) 2008, Christian Lamparter <chunkeey@web.de>
|
2007-09-26 03:11:01 +02:00
|
|
|
*
|
|
|
|
* Based on the islsm (softmac prism54) driver, which is:
|
|
|
|
* Copyright 2004-2006 Jean-Baptiste Note <jean-baptiste.note@m4x.org>, et al.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 09:04:11 +01:00
|
|
|
#include <linux/slab.h>
|
2007-09-26 03:11:01 +02:00
|
|
|
#include <linux/firmware.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/completion.h>
|
2011-07-03 21:21:01 +02:00
|
|
|
#include <linux/module.h>
|
2007-09-26 03:11:01 +02:00
|
|
|
#include <net/mac80211.h>
|
|
|
|
|
|
|
|
#include "p54.h"
|
2009-06-23 17:39:45 +02:00
|
|
|
#include "lmac.h"
|
2007-09-26 03:11:01 +02:00
|
|
|
#include "p54pci.h"
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>");
|
|
|
|
MODULE_DESCRIPTION("Prism54 PCI wireless driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_ALIAS("prism54pci");
|
2008-10-18 23:04:15 +02:00
|
|
|
MODULE_FIRMWARE("isl3886pci");
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2010-01-07 12:58:11 +01:00
|
|
|
static DEFINE_PCI_DEVICE_TABLE(p54p_table) = {
|
2007-09-26 03:11:01 +02:00
|
|
|
/* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
|
|
|
|
{ PCI_DEVICE(0x1260, 0x3890) },
|
|
|
|
/* 3COM 3CRWE154G72 Wireless LAN adapter */
|
|
|
|
{ PCI_DEVICE(0x10b7, 0x6001) },
|
|
|
|
/* Intersil PRISM Indigo Wireless LAN adapter */
|
|
|
|
{ PCI_DEVICE(0x1260, 0x3877) },
|
|
|
|
/* Intersil PRISM Javelin/Xbow Wireless LAN adapter */
|
|
|
|
{ PCI_DEVICE(0x1260, 0x3886) },
|
2010-06-13 14:22:23 +02:00
|
|
|
/* Intersil PRISM Xbow Wireless LAN adapter (Symbol AP-300) */
|
|
|
|
{ PCI_DEVICE(0x1260, 0xffff) },
|
2007-09-17 00:08:37 +02:00
|
|
|
{ },
|
2007-09-26 03:11:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, p54p_table);
|
|
|
|
|
|
|
|
static int p54p_upload_firmware(struct ieee80211_hw *dev)
|
|
|
|
{
|
|
|
|
struct p54p_priv *priv = dev->priv;
|
|
|
|
__le32 reg;
|
|
|
|
int err;
|
2007-12-22 04:02:23 +01:00
|
|
|
__le32 *data;
|
2007-09-26 03:11:01 +02:00
|
|
|
u32 remains, left, device_addr;
|
|
|
|
|
2007-12-22 04:02:23 +01:00
|
|
|
P54P_WRITE(int_enable, cpu_to_le32(0));
|
2007-09-26 03:11:01 +02:00
|
|
|
P54P_READ(int_enable);
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
reg = P54P_READ(ctrl_stat);
|
|
|
|
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
|
|
|
|
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RAMBOOT);
|
|
|
|
P54P_WRITE(ctrl_stat, reg);
|
|
|
|
P54P_READ(ctrl_stat);
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RESET);
|
|
|
|
P54P_WRITE(ctrl_stat, reg);
|
|
|
|
wmb();
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
|
|
|
|
P54P_WRITE(ctrl_stat, reg);
|
|
|
|
wmb();
|
|
|
|
|
2008-11-16 12:20:32 +01:00
|
|
|
/* wait for the firmware to reset properly */
|
|
|
|
mdelay(10);
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2008-11-16 12:20:32 +01:00
|
|
|
err = p54_parse_firmware(dev, priv->firmware);
|
|
|
|
if (err)
|
2008-09-01 22:48:41 +02:00
|
|
|
return err;
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2008-12-26 19:09:34 +01:00
|
|
|
if (priv->common.fw_interface != FW_LM86) {
|
|
|
|
dev_err(&priv->pdev->dev, "wrong firmware, "
|
|
|
|
"please get a LM86(PCI) firmware a try again.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2008-11-16 12:20:32 +01:00
|
|
|
data = (__le32 *) priv->firmware->data;
|
|
|
|
remains = priv->firmware->size;
|
2007-09-26 03:11:01 +02:00
|
|
|
device_addr = ISL38XX_DEV_FIRMWARE_ADDR;
|
|
|
|
while (remains) {
|
|
|
|
u32 i = 0;
|
|
|
|
left = min((u32)0x1000, remains);
|
|
|
|
P54P_WRITE(direct_mem_base, cpu_to_le32(device_addr));
|
|
|
|
P54P_READ(int_enable);
|
|
|
|
|
|
|
|
device_addr += 0x1000;
|
|
|
|
while (i < left) {
|
|
|
|
P54P_WRITE(direct_mem_win[i], *data++);
|
|
|
|
i += sizeof(u32);
|
|
|
|
}
|
|
|
|
|
|
|
|
remains -= left;
|
|
|
|
P54P_READ(int_enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
reg = P54P_READ(ctrl_stat);
|
|
|
|
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_CLKRUN);
|
|
|
|
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
|
|
|
|
reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RAMBOOT);
|
|
|
|
P54P_WRITE(ctrl_stat, reg);
|
|
|
|
P54P_READ(ctrl_stat);
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RESET);
|
|
|
|
P54P_WRITE(ctrl_stat, reg);
|
|
|
|
wmb();
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
|
|
|
|
P54P_WRITE(ctrl_stat, reg);
|
|
|
|
wmb();
|
|
|
|
udelay(10);
|
|
|
|
|
2008-09-01 22:48:51 +02:00
|
|
|
/* wait for the firmware to boot properly */
|
2007-09-26 03:11:01 +02:00
|
|
|
mdelay(100);
|
|
|
|
|
2008-09-01 22:48:51 +02:00
|
|
|
return 0;
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
|
2008-08-24 22:30:38 +02:00
|
|
|
static void p54p_refill_rx_ring(struct ieee80211_hw *dev,
|
|
|
|
int ring_index, struct p54p_desc *ring, u32 ring_limit,
|
2010-04-09 21:37:38 +02:00
|
|
|
struct sk_buff **rx_buf, u32 index)
|
2007-09-26 03:11:01 +02:00
|
|
|
{
|
|
|
|
struct p54p_priv *priv = dev->priv;
|
2007-11-02 06:55:36 +01:00
|
|
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
2008-08-24 22:30:38 +02:00
|
|
|
u32 limit, idx, i;
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2008-08-24 22:30:38 +02:00
|
|
|
idx = le32_to_cpu(ring_control->host_idx[ring_index]);
|
|
|
|
limit = idx;
|
2010-04-15 14:17:07 +02:00
|
|
|
limit -= index;
|
2008-08-24 22:30:38 +02:00
|
|
|
limit = ring_limit - limit;
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2008-08-24 22:30:38 +02:00
|
|
|
i = idx % ring_limit;
|
2007-09-26 03:11:01 +02:00
|
|
|
while (limit-- > 1) {
|
2008-08-24 22:30:38 +02:00
|
|
|
struct p54p_desc *desc = &ring[i];
|
2007-09-26 03:11:01 +02:00
|
|
|
|
|
|
|
if (!desc->host_addr) {
|
|
|
|
struct sk_buff *skb;
|
|
|
|
dma_addr_t mapping;
|
2008-09-01 22:48:41 +02:00
|
|
|
skb = dev_alloc_skb(priv->common.rx_mtu + 32);
|
2007-09-26 03:11:01 +02:00
|
|
|
if (!skb)
|
|
|
|
break;
|
|
|
|
|
|
|
|
mapping = pci_map_single(priv->pdev,
|
|
|
|
skb_tail_pointer(skb),
|
2008-09-01 22:48:41 +02:00
|
|
|
priv->common.rx_mtu + 32,
|
2007-09-26 03:11:01 +02:00
|
|
|
PCI_DMA_FROMDEVICE);
|
2010-01-17 23:17:29 +01:00
|
|
|
|
|
|
|
if (pci_dma_mapping_error(priv->pdev, mapping)) {
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
dev_err(&priv->pdev->dev,
|
|
|
|
"RX DMA Mapping error\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-09-26 03:11:01 +02:00
|
|
|
desc->host_addr = cpu_to_le32(mapping);
|
|
|
|
desc->device_addr = 0; // FIXME: necessary?
|
2008-09-01 22:48:41 +02:00
|
|
|
desc->len = cpu_to_le16(priv->common.rx_mtu + 32);
|
2007-09-26 03:11:01 +02:00
|
|
|
desc->flags = 0;
|
2008-08-24 22:30:38 +02:00
|
|
|
rx_buf[i] = skb;
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
|
2008-08-24 22:30:38 +02:00
|
|
|
i++;
|
2007-09-26 03:11:01 +02:00
|
|
|
idx++;
|
2008-08-24 22:30:38 +02:00
|
|
|
i %= ring_limit;
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wmb();
|
2008-08-24 22:30:38 +02:00
|
|
|
ring_control->host_idx[ring_index] = cpu_to_le32(idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void p54p_check_rx_ring(struct ieee80211_hw *dev, u32 *index,
|
|
|
|
int ring_index, struct p54p_desc *ring, u32 ring_limit,
|
|
|
|
struct sk_buff **rx_buf)
|
|
|
|
{
|
|
|
|
struct p54p_priv *priv = dev->priv;
|
|
|
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
|
|
|
struct p54p_desc *desc;
|
|
|
|
u32 idx, i;
|
|
|
|
|
|
|
|
i = (*index) % ring_limit;
|
|
|
|
(*index) = idx = le32_to_cpu(ring_control->device_idx[ring_index]);
|
|
|
|
idx %= ring_limit;
|
|
|
|
while (i != idx) {
|
|
|
|
u16 len;
|
|
|
|
struct sk_buff *skb;
|
2011-02-11 01:48:42 +01:00
|
|
|
dma_addr_t dma_addr;
|
2008-08-24 22:30:38 +02:00
|
|
|
desc = &ring[i];
|
|
|
|
len = le16_to_cpu(desc->len);
|
|
|
|
skb = rx_buf[i];
|
|
|
|
|
2008-08-31 22:15:40 +02:00
|
|
|
if (!skb) {
|
|
|
|
i++;
|
|
|
|
i %= ring_limit;
|
2008-08-24 22:30:38 +02:00
|
|
|
continue;
|
2008-08-31 22:15:40 +02:00
|
|
|
}
|
2010-01-18 00:07:38 +01:00
|
|
|
|
|
|
|
if (unlikely(len > priv->common.rx_mtu)) {
|
|
|
|
if (net_ratelimit())
|
|
|
|
dev_err(&priv->pdev->dev, "rx'd frame size "
|
|
|
|
"exceeds length threshold.\n");
|
|
|
|
|
|
|
|
len = priv->common.rx_mtu;
|
|
|
|
}
|
2011-02-11 01:48:42 +01:00
|
|
|
dma_addr = le32_to_cpu(desc->host_addr);
|
|
|
|
pci_dma_sync_single_for_cpu(priv->pdev, dma_addr,
|
|
|
|
priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE);
|
2008-08-24 22:30:38 +02:00
|
|
|
skb_put(skb, len);
|
|
|
|
|
|
|
|
if (p54_rx(dev, skb)) {
|
2011-02-11 01:48:42 +01:00
|
|
|
pci_unmap_single(priv->pdev, dma_addr,
|
|
|
|
priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE);
|
2008-08-24 22:30:38 +02:00
|
|
|
rx_buf[i] = NULL;
|
2011-02-11 01:48:42 +01:00
|
|
|
desc->host_addr = cpu_to_le32(0);
|
2008-08-24 22:30:38 +02:00
|
|
|
} else {
|
|
|
|
skb_trim(skb, 0);
|
2011-02-11 01:48:42 +01:00
|
|
|
pci_dma_sync_single_for_device(priv->pdev, dma_addr,
|
|
|
|
priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE);
|
2008-09-01 22:48:41 +02:00
|
|
|
desc->len = cpu_to_le16(priv->common.rx_mtu + 32);
|
2008-08-24 22:30:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
i %= ring_limit;
|
|
|
|
}
|
|
|
|
|
2010-04-09 21:37:38 +02:00
|
|
|
p54p_refill_rx_ring(dev, ring_index, ring, ring_limit, rx_buf, *index);
|
2008-08-24 22:30:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index,
|
|
|
|
int ring_index, struct p54p_desc *ring, u32 ring_limit,
|
2010-01-17 23:19:25 +01:00
|
|
|
struct sk_buff **tx_buf)
|
2008-08-24 22:30:38 +02:00
|
|
|
{
|
|
|
|
struct p54p_priv *priv = dev->priv;
|
|
|
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
|
|
|
struct p54p_desc *desc;
|
2010-01-17 23:19:25 +01:00
|
|
|
struct sk_buff *skb;
|
2008-08-24 22:30:38 +02:00
|
|
|
u32 idx, i;
|
|
|
|
|
|
|
|
i = (*index) % ring_limit;
|
2010-04-22 19:52:16 +02:00
|
|
|
(*index) = idx = le32_to_cpu(ring_control->device_idx[ring_index]);
|
2008-08-24 22:30:38 +02:00
|
|
|
idx %= ring_limit;
|
|
|
|
|
|
|
|
while (i != idx) {
|
|
|
|
desc = &ring[i];
|
2010-01-17 23:19:25 +01:00
|
|
|
|
|
|
|
skb = tx_buf[i];
|
2008-08-24 22:30:38 +02:00
|
|
|
tx_buf[i] = NULL;
|
|
|
|
|
|
|
|
pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),
|
|
|
|
le16_to_cpu(desc->len), PCI_DMA_TODEVICE);
|
|
|
|
|
|
|
|
desc->host_addr = 0;
|
|
|
|
desc->device_addr = 0;
|
|
|
|
desc->len = 0;
|
|
|
|
desc->flags = 0;
|
|
|
|
|
2010-01-22 08:01:11 +01:00
|
|
|
if (skb && FREE_AFTER_TX(skb))
|
2010-01-17 23:19:25 +01:00
|
|
|
p54_free_skb(dev, skb);
|
|
|
|
|
2008-08-24 22:30:38 +02:00
|
|
|
i++;
|
|
|
|
i %= ring_limit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-17 23:19:25 +01:00
|
|
|
static void p54p_tasklet(unsigned long dev_id)
|
2008-08-24 22:30:38 +02:00
|
|
|
{
|
|
|
|
struct ieee80211_hw *dev = (struct ieee80211_hw *)dev_id;
|
|
|
|
struct p54p_priv *priv = dev->priv;
|
|
|
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
|
|
|
|
p54pci: fix regression from prevent stuck rx-ring on slow system
This patch fixes a recently introduced use-after-free regression
from "p54pci: prevent stuck rx-ring on slow system".
Hans de Goede reported a use-after-free regression:
>BUG: unable to handle kernel paging request at 6b6b6b6b
>IP: [<e122284a>] p54p_check_tx_ring+0x84/0xb1 [p54pci]
>*pde = 00000000
>Oops: 0000 [#1] SMP
>EIP: 0060:[<e122284a>] EFLAGS: 00010286 CPU: 0
>EIP is at p54p_check_tx_ring+0x84/0xb1 [p54pci]
>EAX: 6b6b6b6b EBX: df10b170 ECX: 00000003 EDX: 00000001
>ESI: dc471500 EDI: d8acaeb0 EBP: c098be9c ESP: c098be84
> DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
>Process swapper (pid: 0, ti=c098a000 task=c09ccfe0 task.ti=c098a000)
>Call Trace:
> [<e1222b02>] ? p54p_tasklet+0xaa/0xb5 [p54pci]
> [<c0440568>] ? tasklet_action+0x78/0xcb
> [<c0440ed3>] ? __do_softirq+0xbc/0x173
Quote from comment #17:
"The problem is the innocent looking moving of the tx processing to
after the rx processing in the tasklet. Quoting from the changelog:
This patch does it the same way, except that it also prioritize
rx data processing, simply because tx routines *can* wait.
This is causing an issue with us referencing already freed memory,
because some skb's we transmit, we immediately receive back, such
as those for reading the eeprom (*) and getting stats.
What can happen because of the moving of the tx processing to after
the rx processing is that when the tasklet first runs after doing a
special skb tx (such as eeprom) we've already received the answer
to it.
Then the rx processing ends up calling p54_find_and_unlink_skb to
find the matching tx skb for the just received special rx skb and
frees the tx skb.
Then after the processing of the rx skb answer, and thus freeing
the tx skb, we go process the completed tx ring entires, and then
dereference the free-ed skb, to see if it should free free-ed by
p54p_check_tx_ring()."
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=583623
Bug-Identified-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-04-22 19:52:43 +02:00
|
|
|
p54p_check_tx_ring(dev, &priv->tx_idx_mgmt, 3, ring_control->tx_mgmt,
|
|
|
|
ARRAY_SIZE(ring_control->tx_mgmt),
|
|
|
|
priv->tx_buf_mgmt);
|
|
|
|
|
|
|
|
p54p_check_tx_ring(dev, &priv->tx_idx_data, 1, ring_control->tx_data,
|
|
|
|
ARRAY_SIZE(ring_control->tx_data),
|
|
|
|
priv->tx_buf_data);
|
|
|
|
|
2008-08-24 22:30:38 +02:00
|
|
|
p54p_check_rx_ring(dev, &priv->rx_idx_mgmt, 2, ring_control->rx_mgmt,
|
|
|
|
ARRAY_SIZE(ring_control->rx_mgmt), priv->rx_buf_mgmt);
|
|
|
|
|
|
|
|
p54p_check_rx_ring(dev, &priv->rx_idx_data, 0, ring_control->rx_data,
|
|
|
|
ARRAY_SIZE(ring_control->rx_data), priv->rx_buf_data);
|
|
|
|
|
|
|
|
wmb();
|
|
|
|
P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE));
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t p54p_interrupt(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct ieee80211_hw *dev = dev_id;
|
|
|
|
struct p54p_priv *priv = dev->priv;
|
|
|
|
__le32 reg;
|
|
|
|
|
|
|
|
reg = P54P_READ(int_ident);
|
2007-12-22 04:02:23 +01:00
|
|
|
if (unlikely(reg == cpu_to_le32(0xFFFFFFFF))) {
|
2010-01-17 23:19:25 +01:00
|
|
|
goto out;
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
P54P_WRITE(int_ack, reg);
|
|
|
|
|
|
|
|
reg &= P54P_READ(int_enable);
|
|
|
|
|
2010-01-17 23:19:25 +01:00
|
|
|
if (reg & cpu_to_le32(ISL38XX_INT_IDENT_UPDATE))
|
|
|
|
tasklet_schedule(&priv->tasklet);
|
|
|
|
else if (reg & cpu_to_le32(ISL38XX_INT_IDENT_INIT))
|
2007-09-26 03:11:01 +02:00
|
|
|
complete(&priv->boot_comp);
|
|
|
|
|
2010-01-17 23:19:25 +01:00
|
|
|
out:
|
2007-09-26 03:11:01 +02:00
|
|
|
return reg ? IRQ_HANDLED : IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
2008-12-14 15:05:42 +01:00
|
|
|
static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
|
2007-09-26 03:11:01 +02:00
|
|
|
{
|
2010-01-22 08:01:11 +01:00
|
|
|
unsigned long flags;
|
2007-09-26 03:11:01 +02:00
|
|
|
struct p54p_priv *priv = dev->priv;
|
2007-11-02 06:55:36 +01:00
|
|
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
2007-09-26 03:11:01 +02:00
|
|
|
struct p54p_desc *desc;
|
|
|
|
dma_addr_t mapping;
|
2011-05-07 11:16:08 +02:00
|
|
|
u32 idx, i;
|
2007-09-26 03:11:01 +02:00
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
2007-11-02 06:55:36 +01:00
|
|
|
idx = le32_to_cpu(ring_control->host_idx[1]);
|
|
|
|
i = idx % ARRAY_SIZE(ring_control->tx_data);
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2008-10-15 04:07:16 +02:00
|
|
|
mapping = pci_map_single(priv->pdev, skb->data, skb->len,
|
|
|
|
PCI_DMA_TODEVICE);
|
2010-01-17 23:17:29 +01:00
|
|
|
if (pci_dma_mapping_error(priv->pdev, mapping)) {
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
p54_free_skb(dev, skb);
|
|
|
|
dev_err(&priv->pdev->dev, "TX DMA mapping error\n");
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
priv->tx_buf_data[i] = skb;
|
|
|
|
|
2007-11-02 06:55:36 +01:00
|
|
|
desc = &ring_control->tx_data[i];
|
2007-09-26 03:11:01 +02:00
|
|
|
desc->host_addr = cpu_to_le32(mapping);
|
2008-10-22 22:41:55 +02:00
|
|
|
desc->device_addr = ((struct p54_hdr *)skb->data)->req_id;
|
2008-10-15 04:07:16 +02:00
|
|
|
desc->len = cpu_to_le16(skb->len);
|
2007-09-26 03:11:01 +02:00
|
|
|
desc->flags = 0;
|
|
|
|
|
|
|
|
wmb();
|
2007-11-02 06:55:36 +01:00
|
|
|
ring_control->host_idx[1] = cpu_to_le32(idx + 1);
|
2007-09-26 03:11:01 +02:00
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
|
|
|
|
P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE));
|
|
|
|
P54P_READ(dev_int);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void p54p_stop(struct ieee80211_hw *dev)
|
|
|
|
{
|
|
|
|
struct p54p_priv *priv = dev->priv;
|
2007-11-02 06:55:36 +01:00
|
|
|
struct p54p_ring_control *ring_control = priv->ring_control;
|
2007-09-26 03:11:01 +02:00
|
|
|
unsigned int i;
|
|
|
|
struct p54p_desc *desc;
|
|
|
|
|
2007-12-22 04:02:23 +01:00
|
|
|
P54P_WRITE(int_enable, cpu_to_le32(0));
|
2007-09-26 03:11:01 +02:00
|
|
|
P54P_READ(int_enable);
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
free_irq(priv->pdev->irq, dev);
|
|
|
|
|
2010-01-22 08:01:11 +01:00
|
|
|
tasklet_kill(&priv->tasklet);
|
|
|
|
|
2007-09-26 03:11:01 +02:00
|
|
|
P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET));
|
|
|
|
|
2008-08-24 22:30:38 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(priv->rx_buf_data); i++) {
|
2007-11-02 06:55:36 +01:00
|
|
|
desc = &ring_control->rx_data[i];
|
2007-09-26 03:11:01 +02:00
|
|
|
if (desc->host_addr)
|
2008-08-24 22:30:38 +02:00
|
|
|
pci_unmap_single(priv->pdev,
|
|
|
|
le32_to_cpu(desc->host_addr),
|
2008-09-01 22:48:41 +02:00
|
|
|
priv->common.rx_mtu + 32,
|
|
|
|
PCI_DMA_FROMDEVICE);
|
2008-08-24 22:30:38 +02:00
|
|
|
kfree_skb(priv->rx_buf_data[i]);
|
|
|
|
priv->rx_buf_data[i] = NULL;
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
|
2008-08-24 22:30:38 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(priv->rx_buf_mgmt); i++) {
|
|
|
|
desc = &ring_control->rx_mgmt[i];
|
|
|
|
if (desc->host_addr)
|
|
|
|
pci_unmap_single(priv->pdev,
|
|
|
|
le32_to_cpu(desc->host_addr),
|
2008-09-01 22:48:41 +02:00
|
|
|
priv->common.rx_mtu + 32,
|
|
|
|
PCI_DMA_FROMDEVICE);
|
2008-08-24 22:30:38 +02:00
|
|
|
kfree_skb(priv->rx_buf_mgmt[i]);
|
|
|
|
priv->rx_buf_mgmt[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(priv->tx_buf_data); i++) {
|
2007-11-02 06:55:36 +01:00
|
|
|
desc = &ring_control->tx_data[i];
|
2007-09-26 03:11:01 +02:00
|
|
|
if (desc->host_addr)
|
2008-08-24 22:30:38 +02:00
|
|
|
pci_unmap_single(priv->pdev,
|
|
|
|
le32_to_cpu(desc->host_addr),
|
|
|
|
le16_to_cpu(desc->len),
|
|
|
|
PCI_DMA_TODEVICE);
|
|
|
|
|
2008-10-15 04:07:16 +02:00
|
|
|
p54_free_skb(dev, priv->tx_buf_data[i]);
|
2008-08-24 22:30:38 +02:00
|
|
|
priv->tx_buf_data[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(priv->tx_buf_mgmt); i++) {
|
|
|
|
desc = &ring_control->tx_mgmt[i];
|
|
|
|
if (desc->host_addr)
|
|
|
|
pci_unmap_single(priv->pdev,
|
|
|
|
le32_to_cpu(desc->host_addr),
|
|
|
|
le16_to_cpu(desc->len),
|
|
|
|
PCI_DMA_TODEVICE);
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2008-10-15 04:07:16 +02:00
|
|
|
p54_free_skb(dev, priv->tx_buf_mgmt[i]);
|
2008-08-24 22:30:38 +02:00
|
|
|
priv->tx_buf_mgmt[i] = NULL;
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
|
2008-08-24 22:30:38 +02:00
|
|
|
memset(ring_control, 0, sizeof(*ring_control));
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
|
2008-10-22 14:19:56 +02:00
|
|
|
static int p54p_open(struct ieee80211_hw *dev)
|
|
|
|
{
|
|
|
|
struct p54p_priv *priv = dev->priv;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
init_completion(&priv->boot_comp);
|
2009-11-18 09:25:43 +01:00
|
|
|
err = request_irq(priv->pdev->irq, p54p_interrupt,
|
2008-10-22 14:19:56 +02:00
|
|
|
IRQF_SHARED, "p54pci", dev);
|
|
|
|
if (err) {
|
2009-03-05 21:30:37 +01:00
|
|
|
dev_err(&priv->pdev->dev, "failed to register IRQ handler\n");
|
2008-10-22 14:19:56 +02:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(priv->ring_control, 0, sizeof(*priv->ring_control));
|
|
|
|
err = p54p_upload_firmware(dev);
|
|
|
|
if (err) {
|
|
|
|
free_irq(priv->pdev->irq, dev);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
priv->rx_idx_data = priv->tx_idx_data = 0;
|
|
|
|
priv->rx_idx_mgmt = priv->tx_idx_mgmt = 0;
|
|
|
|
|
|
|
|
p54p_refill_rx_ring(dev, 0, priv->ring_control->rx_data,
|
2010-04-09 21:37:38 +02:00
|
|
|
ARRAY_SIZE(priv->ring_control->rx_data), priv->rx_buf_data, 0);
|
2008-10-22 14:19:56 +02:00
|
|
|
|
|
|
|
p54p_refill_rx_ring(dev, 2, priv->ring_control->rx_mgmt,
|
2010-04-09 21:37:38 +02:00
|
|
|
ARRAY_SIZE(priv->ring_control->rx_mgmt), priv->rx_buf_mgmt, 0);
|
2008-10-22 14:19:56 +02:00
|
|
|
|
|
|
|
P54P_WRITE(ring_control_base, cpu_to_le32(priv->ring_control_dma));
|
|
|
|
P54P_READ(ring_control_base);
|
|
|
|
wmb();
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
P54P_WRITE(int_enable, cpu_to_le32(ISL38XX_INT_IDENT_INIT));
|
|
|
|
P54P_READ(int_enable);
|
|
|
|
wmb();
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET));
|
|
|
|
P54P_READ(dev_int);
|
|
|
|
|
|
|
|
if (!wait_for_completion_interruptible_timeout(&priv->boot_comp, HZ)) {
|
2010-08-12 04:11:19 +02:00
|
|
|
wiphy_err(dev->wiphy, "Cannot boot firmware!\n");
|
2008-10-22 14:19:56 +02:00
|
|
|
p54p_stop(dev);
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
P54P_WRITE(int_enable, cpu_to_le32(ISL38XX_INT_IDENT_UPDATE));
|
|
|
|
P54P_READ(int_enable);
|
|
|
|
wmb();
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE));
|
|
|
|
P54P_READ(dev_int);
|
|
|
|
wmb();
|
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:16:42 +02:00
|
|
|
static void p54p_firmware_step2(const struct firmware *fw,
|
|
|
|
void *context)
|
|
|
|
{
|
|
|
|
struct p54p_priv *priv = context;
|
|
|
|
struct ieee80211_hw *dev = priv->common.hw;
|
|
|
|
struct pci_dev *pdev = priv->pdev;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!fw) {
|
|
|
|
dev_err(&pdev->dev, "Cannot find firmware (isl3886pci)\n");
|
|
|
|
err = -ENOENT;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->firmware = fw;
|
|
|
|
|
|
|
|
err = p54p_open(dev);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
err = p54_read_eeprom(dev);
|
|
|
|
p54p_stop(dev);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
err = p54_register_common(dev, &pdev->dev);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
complete(&priv->fw_loaded);
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
struct device *parent = pdev->dev.parent;
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
device_lock(parent);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This will indirectly result in a call to p54p_remove.
|
|
|
|
* Hence, we don't need to bother with freeing any
|
|
|
|
* allocated ressources at all.
|
|
|
|
*/
|
|
|
|
device_release_driver(&pdev->dev);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
device_unlock(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_dev_put(pdev);
|
|
|
|
}
|
|
|
|
|
2012-12-03 15:56:38 +01:00
|
|
|
static int p54p_probe(struct pci_dev *pdev,
|
2007-09-26 03:11:01 +02:00
|
|
|
const struct pci_device_id *id)
|
|
|
|
{
|
|
|
|
struct p54p_priv *priv;
|
|
|
|
struct ieee80211_hw *dev;
|
|
|
|
unsigned long mem_addr, mem_len;
|
|
|
|
int err;
|
|
|
|
|
2012-07-24 21:16:42 +02:00
|
|
|
pci_dev_get(pdev);
|
2007-09-26 03:11:01 +02:00
|
|
|
err = pci_enable_device(pdev);
|
|
|
|
if (err) {
|
2009-03-05 21:30:37 +01:00
|
|
|
dev_err(&pdev->dev, "Cannot enable new PCI device\n");
|
2007-09-26 03:11:01 +02:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
mem_addr = pci_resource_start(pdev, 0);
|
|
|
|
mem_len = pci_resource_len(pdev, 0);
|
|
|
|
if (mem_len < sizeof(struct p54p_csr)) {
|
2009-03-05 21:30:37 +01:00
|
|
|
dev_err(&pdev->dev, "Too short PCI resources\n");
|
2013-01-02 21:06:47 +01:00
|
|
|
err = -ENODEV;
|
2008-11-16 12:20:32 +01:00
|
|
|
goto err_disable_dev;
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
|
2008-08-08 21:17:37 +02:00
|
|
|
err = pci_request_regions(pdev, "p54pci");
|
2007-09-26 03:11:01 +02:00
|
|
|
if (err) {
|
2009-03-05 21:30:37 +01:00
|
|
|
dev_err(&pdev->dev, "Cannot obtain PCI resources\n");
|
2008-11-16 12:20:32 +01:00
|
|
|
goto err_disable_dev;
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
|
2013-01-02 21:06:47 +01:00
|
|
|
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
|
|
|
if (!err)
|
|
|
|
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
|
|
|
|
if (err) {
|
2009-03-05 21:30:37 +01:00
|
|
|
dev_err(&pdev->dev, "No suitable DMA available\n");
|
2007-09-26 03:11:01 +02:00
|
|
|
goto err_free_reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_set_master(pdev);
|
|
|
|
pci_try_set_mwi(pdev);
|
|
|
|
|
|
|
|
pci_write_config_byte(pdev, 0x40, 0);
|
|
|
|
pci_write_config_byte(pdev, 0x41, 0);
|
|
|
|
|
|
|
|
dev = p54_init_common(sizeof(*priv));
|
|
|
|
if (!dev) {
|
2009-03-05 21:30:37 +01:00
|
|
|
dev_err(&pdev->dev, "ieee80211 alloc failed\n");
|
2007-09-26 03:11:01 +02:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_free_reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv = dev->priv;
|
|
|
|
priv->pdev = pdev;
|
|
|
|
|
2012-07-24 21:16:42 +02:00
|
|
|
init_completion(&priv->fw_loaded);
|
2007-09-26 03:11:01 +02:00
|
|
|
SET_IEEE80211_DEV(dev, &pdev->dev);
|
|
|
|
pci_set_drvdata(pdev, dev);
|
|
|
|
|
|
|
|
priv->map = ioremap(mem_addr, mem_len);
|
|
|
|
if (!priv->map) {
|
2009-03-05 21:30:37 +01:00
|
|
|
dev_err(&pdev->dev, "Cannot map device memory\n");
|
|
|
|
err = -ENOMEM;
|
2007-09-26 03:11:01 +02:00
|
|
|
goto err_free_dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->ring_control = pci_alloc_consistent(pdev, sizeof(*priv->ring_control),
|
|
|
|
&priv->ring_control_dma);
|
|
|
|
if (!priv->ring_control) {
|
2009-03-05 21:30:37 +01:00
|
|
|
dev_err(&pdev->dev, "Cannot allocate rings\n");
|
2007-09-26 03:11:01 +02:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_iounmap;
|
|
|
|
}
|
|
|
|
priv->common.open = p54p_open;
|
|
|
|
priv->common.stop = p54p_stop;
|
|
|
|
priv->common.tx = p54p_tx;
|
|
|
|
|
|
|
|
spin_lock_init(&priv->lock);
|
2010-01-17 23:19:25 +01:00
|
|
|
tasklet_init(&priv->tasklet, p54p_tasklet, (unsigned long)dev);
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2012-07-24 21:16:42 +02:00
|
|
|
err = request_firmware_nowait(THIS_MODULE, 1, "isl3886pci",
|
|
|
|
&priv->pdev->dev, GFP_KERNEL,
|
|
|
|
priv, p54p_firmware_step2);
|
|
|
|
if (!err)
|
|
|
|
return 0;
|
2007-09-26 03:11:01 +02:00
|
|
|
|
|
|
|
pci_free_consistent(pdev, sizeof(*priv->ring_control),
|
|
|
|
priv->ring_control, priv->ring_control_dma);
|
|
|
|
|
|
|
|
err_iounmap:
|
|
|
|
iounmap(priv->map);
|
|
|
|
|
|
|
|
err_free_dev:
|
|
|
|
pci_set_drvdata(pdev, NULL);
|
2009-06-23 17:39:45 +02:00
|
|
|
p54_free_common(dev);
|
2007-09-26 03:11:01 +02:00
|
|
|
|
|
|
|
err_free_reg:
|
|
|
|
pci_release_regions(pdev);
|
2008-11-16 12:20:32 +01:00
|
|
|
err_disable_dev:
|
2007-09-26 03:11:01 +02:00
|
|
|
pci_disable_device(pdev);
|
2012-07-24 21:16:42 +02:00
|
|
|
pci_dev_put(pdev);
|
2007-09-26 03:11:01 +02:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-12-03 15:56:38 +01:00
|
|
|
static void p54p_remove(struct pci_dev *pdev)
|
2007-09-26 03:11:01 +02:00
|
|
|
{
|
|
|
|
struct ieee80211_hw *dev = pci_get_drvdata(pdev);
|
|
|
|
struct p54p_priv *priv;
|
|
|
|
|
|
|
|
if (!dev)
|
|
|
|
return;
|
|
|
|
|
|
|
|
priv = dev->priv;
|
2012-07-24 21:16:42 +02:00
|
|
|
wait_for_completion(&priv->fw_loaded);
|
|
|
|
p54_unregister_common(dev);
|
2008-11-16 12:20:32 +01:00
|
|
|
release_firmware(priv->firmware);
|
2007-09-26 03:11:01 +02:00
|
|
|
pci_free_consistent(pdev, sizeof(*priv->ring_control),
|
|
|
|
priv->ring_control, priv->ring_control_dma);
|
|
|
|
iounmap(priv->map);
|
|
|
|
pci_release_regions(pdev);
|
|
|
|
pci_disable_device(pdev);
|
2009-06-23 17:39:45 +02:00
|
|
|
p54_free_common(dev);
|
2007-09-26 03:11:01 +02:00
|
|
|
}
|
|
|
|
|
2012-11-29 23:27:16 +01:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2012-03-03 21:25:19 +01:00
|
|
|
static int p54p_suspend(struct device *device)
|
2007-09-26 03:11:01 +02:00
|
|
|
{
|
2012-03-03 21:25:19 +01:00
|
|
|
struct pci_dev *pdev = to_pci_dev(device);
|
2007-09-26 03:11:01 +02:00
|
|
|
|
|
|
|
pci_save_state(pdev);
|
2012-03-03 21:25:19 +01:00
|
|
|
pci_set_power_state(pdev, PCI_D3hot);
|
|
|
|
pci_disable_device(pdev);
|
2007-09-26 03:11:01 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-03 21:25:19 +01:00
|
|
|
static int p54p_resume(struct device *device)
|
2007-09-26 03:11:01 +02:00
|
|
|
{
|
2012-03-03 21:25:19 +01:00
|
|
|
struct pci_dev *pdev = to_pci_dev(device);
|
|
|
|
int err;
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2012-03-03 21:25:19 +01:00
|
|
|
err = pci_reenable_device(pdev);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
return pci_set_power_state(pdev, PCI_D0);
|
|
|
|
}
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2012-11-29 23:27:16 +01:00
|
|
|
static SIMPLE_DEV_PM_OPS(p54pci_pm_ops, p54p_suspend, p54p_resume);
|
2007-09-26 03:11:01 +02:00
|
|
|
|
2012-03-03 21:25:19 +01:00
|
|
|
#define P54P_PM_OPS (&p54pci_pm_ops)
|
|
|
|
#else
|
|
|
|
#define P54P_PM_OPS (NULL)
|
2012-11-29 23:27:16 +01:00
|
|
|
#endif /* CONFIG_PM_SLEEP */
|
2007-09-26 03:11:01 +02:00
|
|
|
|
|
|
|
static struct pci_driver p54p_driver = {
|
2008-08-08 21:17:37 +02:00
|
|
|
.name = "p54pci",
|
2007-09-26 03:11:01 +02:00
|
|
|
.id_table = p54p_table,
|
|
|
|
.probe = p54p_probe,
|
2012-12-03 15:56:38 +01:00
|
|
|
.remove = p54p_remove,
|
2012-03-03 21:25:19 +01:00
|
|
|
.driver.pm = P54P_PM_OPS,
|
2007-09-26 03:11:01 +02:00
|
|
|
};
|
|
|
|
|
2012-04-14 04:38:36 +02:00
|
|
|
module_pci_driver(p54p_driver);
|