diff options
author | Shaun Ruffell <sruffell@digium.com> | 2012-03-21 16:33:51 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2012-03-21 16:33:51 +0000 |
commit | 4998f0fc56008a0f7d0426c3d5b10c3995441fff (patch) | |
tree | d8ee849d1ac479a79aad492081595a475292c5df | |
parent | e715aaf4b81fc3b3511fdd07877bb9b395d99ebc (diff) |
dahdi: Add dahdi_pci_disable_link_state for kernel < 2.6.25.
Will allow the ASPM (Active State Power Management) state to be disabled on
PCIe devices before kernel version 2.6.25.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10556 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r-- | drivers/dahdi/dahdi-base.c | 18 | ||||
-rw-r--r-- | include/dahdi/kernel.h | 17 |
2 files changed, 35 insertions, 0 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index 88e44be..6cb5ec8 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -10041,6 +10041,24 @@ failed_driver_init: return res; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) +#ifdef CONFIG_PCI +void dahdi_pci_disable_link_state(struct pci_dev *pdev, int state) +{ + u16 reg16; + int pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); + state &= (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); + if (!pos) + return; + pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, ®16); + reg16 &= ~(state); + pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); +} +EXPORT_SYMBOL(dahdi_pci_disable_link_state); +#endif /* CONFIG_PCI */ +#endif /* 2.6.25 */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) static inline void flush_find_master_work(void) { diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index ec7f90b..93d0046 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -65,6 +65,12 @@ #define DAHDI_IRQ_HANDLER(a) static irqreturn_t a(int irq, void *dev_id, struct pt_regs *regs) #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) +#ifdef CONFIG_PCI +#include <linux/pci-aspm.h> +#endif +#endif + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) #define HAVE_NET_DEVICE_OPS #endif @@ -1362,6 +1368,16 @@ static inline short dahdi_txtone_nextsample(struct dahdi_chan *ss) #define fatal_signal_pending(p) \ (signal_pending((p)) && sigismember(&(p)->pending.signal, SIGKILL)) +#ifdef CONFIG_PCI +#ifndef PCIE_LINK_STATE_L0S +#define PCIE_LINK_STATE_L0S 1 +#define PCIE_LINK_STATE_L1 2 +#define PCIE_LINK_STATE_CLKPM 4 +#endif +#define pci_disable_link_state dahdi_pci_disable_link_state +void dahdi_pci_disable_link_state(struct pci_dev *pdev, int state); +#endif /* CONFIG_PCI */ + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) #ifndef __packed @@ -1389,6 +1405,7 @@ static inline int strcasecmp(const char *s1, const char *s2) return c1 - c2; } #endif /* clamp_val */ + #endif /* 2.6.22 */ #endif /* 2.6.25 */ #endif /* 2.6.26 */ |