diff options
Diffstat (limited to 'drivers/net/wireless/rtlwifi/pci.c')
-rw-r--r-- | drivers/net/wireless/rtlwifi/pci.c | 63 |
1 files changed, 18 insertions, 45 deletions
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 56f12358389d..eb61061821e4 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c | |||
@@ -27,6 +27,7 @@ | |||
27 | * | 27 | * |
28 | *****************************************************************************/ | 28 | *****************************************************************************/ |
29 | 29 | ||
30 | #include <linux/export.h> | ||
30 | #include "core.h" | 31 | #include "core.h" |
31 | #include "wifi.h" | 32 | #include "wifi.h" |
32 | #include "pci.h" | 33 | #include "pci.h" |
@@ -218,7 +219,6 @@ static void rtl_pci_disable_aspm(struct ieee80211_hw *hw) | |||
218 | struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); | 219 | struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); |
219 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | 220 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
220 | u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor; | 221 | u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor; |
221 | u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport; | ||
222 | u8 num4bytes = pcipriv->ndis_adapter.num4bytes; | 222 | u8 num4bytes = pcipriv->ndis_adapter.num4bytes; |
223 | /*Retrieve original configuration settings. */ | 223 | /*Retrieve original configuration settings. */ |
224 | u8 linkctrl_reg = pcipriv->ndis_adapter.linkctrl_reg; | 224 | u8 linkctrl_reg = pcipriv->ndis_adapter.linkctrl_reg; |
@@ -254,9 +254,8 @@ static void rtl_pci_disable_aspm(struct ieee80211_hw *hw) | |||
254 | udelay(50); | 254 | udelay(50); |
255 | 255 | ||
256 | /*4 Disable Pci Bridge ASPM */ | 256 | /*4 Disable Pci Bridge ASPM */ |
257 | rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, | 257 | pci_write_config_byte(rtlpci->pdev, (num4bytes << 2), |
258 | pcicfg_addrport + (num4bytes << 2)); | 258 | pcibridge_linkctrlreg); |
259 | rtl_pci_raw_write_port_uchar(PCI_CONF_DATA, pcibridge_linkctrlreg); | ||
260 | 259 | ||
261 | udelay(50); | 260 | udelay(50); |
262 | } | 261 | } |
@@ -277,7 +276,6 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw) | |||
277 | u8 pcibridge_devnum = pcipriv->ndis_adapter.pcibridge_devnum; | 276 | u8 pcibridge_devnum = pcipriv->ndis_adapter.pcibridge_devnum; |
278 | u8 pcibridge_funcnum = pcipriv->ndis_adapter.pcibridge_funcnum; | 277 | u8 pcibridge_funcnum = pcipriv->ndis_adapter.pcibridge_funcnum; |
279 | u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor; | 278 | u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor; |
280 | u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport; | ||
281 | u8 num4bytes = pcipriv->ndis_adapter.num4bytes; | 279 | u8 num4bytes = pcipriv->ndis_adapter.num4bytes; |
282 | u16 aspmlevel; | 280 | u16 aspmlevel; |
283 | u8 u_pcibridge_aspmsetting; | 281 | u8 u_pcibridge_aspmsetting; |
@@ -293,8 +291,6 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw) | |||
293 | } | 291 | } |
294 | 292 | ||
295 | /*4 Enable Pci Bridge ASPM */ | 293 | /*4 Enable Pci Bridge ASPM */ |
296 | rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, | ||
297 | pcicfg_addrport + (num4bytes << 2)); | ||
298 | 294 | ||
299 | u_pcibridge_aspmsetting = | 295 | u_pcibridge_aspmsetting = |
300 | pcipriv->ndis_adapter.pcibridge_linkctrlreg | | 296 | pcipriv->ndis_adapter.pcibridge_linkctrlreg | |
@@ -303,7 +299,8 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw) | |||
303 | if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL) | 299 | if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL) |
304 | u_pcibridge_aspmsetting &= ~BIT(0); | 300 | u_pcibridge_aspmsetting &= ~BIT(0); |
305 | 301 | ||
306 | rtl_pci_raw_write_port_uchar(PCI_CONF_DATA, u_pcibridge_aspmsetting); | 302 | pci_write_config_byte(rtlpci->pdev, (num4bytes << 2), |
303 | u_pcibridge_aspmsetting); | ||
307 | 304 | ||
308 | RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, | 305 | RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, |
309 | ("PlatformEnableASPM():PciBridge busnumber[%x], " | 306 | ("PlatformEnableASPM():PciBridge busnumber[%x], " |
@@ -335,25 +332,18 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw) | |||
335 | 332 | ||
336 | static bool rtl_pci_get_amd_l1_patch(struct ieee80211_hw *hw) | 333 | static bool rtl_pci_get_amd_l1_patch(struct ieee80211_hw *hw) |
337 | { | 334 | { |
338 | struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); | 335 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
339 | u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport; | ||
340 | 336 | ||
341 | bool status = false; | 337 | bool status = false; |
342 | u8 offset_e0; | 338 | u8 offset_e0; |
343 | unsigned offset_e4; | 339 | unsigned offset_e4; |
344 | 340 | ||
345 | rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, | 341 | pci_write_config_byte(rtlpci->pdev, 0xe0, 0xa0); |
346 | pcicfg_addrport + 0xE0); | ||
347 | rtl_pci_raw_write_port_uchar(PCI_CONF_DATA, 0xA0); | ||
348 | 342 | ||
349 | rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, | 343 | pci_read_config_byte(rtlpci->pdev, 0xe0, &offset_e0); |
350 | pcicfg_addrport + 0xE0); | ||
351 | rtl_pci_raw_read_port_uchar(PCI_CONF_DATA, &offset_e0); | ||
352 | 344 | ||
353 | if (offset_e0 == 0xA0) { | 345 | if (offset_e0 == 0xA0) { |
354 | rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, | 346 | pci_read_config_dword(rtlpci->pdev, 0xe4, &offset_e4); |
355 | pcicfg_addrport + 0xE4); | ||
356 | rtl_pci_raw_read_port_ulong(PCI_CONF_DATA, &offset_e4); | ||
357 | if (offset_e4 & BIT(23)) | 347 | if (offset_e4 & BIT(23)) |
358 | status = true; | 348 | status = true; |
359 | } | 349 | } |
@@ -364,17 +354,15 @@ static bool rtl_pci_get_amd_l1_patch(struct ieee80211_hw *hw) | |||
364 | static void rtl_pci_get_linkcontrol_field(struct ieee80211_hw *hw) | 354 | static void rtl_pci_get_linkcontrol_field(struct ieee80211_hw *hw) |
365 | { | 355 | { |
366 | struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); | 356 | struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); |
357 | struct rtl_pci *rtlpci = rtl_pcidev(pcipriv); | ||
367 | u8 capabilityoffset = pcipriv->ndis_adapter.pcibridge_pciehdr_offset; | 358 | u8 capabilityoffset = pcipriv->ndis_adapter.pcibridge_pciehdr_offset; |
368 | u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport; | ||
369 | u8 linkctrl_reg; | 359 | u8 linkctrl_reg; |
370 | u8 num4bbytes; | 360 | u8 num4bbytes; |
371 | 361 | ||
372 | num4bbytes = (capabilityoffset + 0x10) / 4; | 362 | num4bbytes = (capabilityoffset + 0x10) / 4; |
373 | 363 | ||
374 | /*Read Link Control Register */ | 364 | /*Read Link Control Register */ |
375 | rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, | 365 | pci_read_config_byte(rtlpci->pdev, (num4bbytes << 2), &linkctrl_reg); |
376 | pcicfg_addrport + (num4bbytes << 2)); | ||
377 | rtl_pci_raw_read_port_uchar(PCI_CONF_DATA, &linkctrl_reg); | ||
378 | 366 | ||
379 | pcipriv->ndis_adapter.pcibridge_linkctrlreg = linkctrl_reg; | 367 | pcipriv->ndis_adapter.pcibridge_linkctrlreg = linkctrl_reg; |
380 | } | 368 | } |
@@ -488,7 +476,7 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw) | |||
488 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | 476 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
489 | struct sk_buff *skb = NULL; | 477 | struct sk_buff *skb = NULL; |
490 | struct ieee80211_tx_info *info = NULL; | 478 | struct ieee80211_tx_info *info = NULL; |
491 | int tid; /* should be int */ | 479 | int tid; |
492 | 480 | ||
493 | if (!rtlpriv->rtlhal.earlymode_enable) | 481 | if (!rtlpriv->rtlhal.earlymode_enable) |
494 | return; | 482 | return; |
@@ -1538,7 +1526,7 @@ static int rtl_pci_start(struct ieee80211_hw *hw) | |||
1538 | 1526 | ||
1539 | rtl_init_rx_config(hw); | 1527 | rtl_init_rx_config(hw); |
1540 | 1528 | ||
1541 | /*should after adapter start and interrupt enable. */ | 1529 | /*should be after adapter start and interrupt enable. */ |
1542 | set_hal_start(rtlhal); | 1530 | set_hal_start(rtlhal); |
1543 | 1531 | ||
1544 | RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); | 1532 | RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); |
@@ -1559,7 +1547,7 @@ static void rtl_pci_stop(struct ieee80211_hw *hw) | |||
1559 | u8 RFInProgressTimeOut = 0; | 1547 | u8 RFInProgressTimeOut = 0; |
1560 | 1548 | ||
1561 | /* | 1549 | /* |
1562 | *should before disable interrrupt&adapter | 1550 | *should be before disable interrupt&adapter |
1563 | *and will do it immediately. | 1551 | *and will do it immediately. |
1564 | */ | 1552 | */ |
1565 | set_hal_stop(rtlhal); | 1553 | set_hal_stop(rtlhal); |
@@ -1718,10 +1706,6 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev, | |||
1718 | PCI_SLOT(bridge_pdev->devfn); | 1706 | PCI_SLOT(bridge_pdev->devfn); |
1719 | pcipriv->ndis_adapter.pcibridge_funcnum = | 1707 | pcipriv->ndis_adapter.pcibridge_funcnum = |
1720 | PCI_FUNC(bridge_pdev->devfn); | 1708 | PCI_FUNC(bridge_pdev->devfn); |
1721 | pcipriv->ndis_adapter.pcicfg_addrport = | ||
1722 | (pcipriv->ndis_adapter.pcibridge_busnum << 16) | | ||
1723 | (pcipriv->ndis_adapter.pcibridge_devnum << 11) | | ||
1724 | (pcipriv->ndis_adapter.pcibridge_funcnum << 8) | (1 << 31); | ||
1725 | pcipriv->ndis_adapter.pcibridge_pciehdr_offset = | 1709 | pcipriv->ndis_adapter.pcibridge_pciehdr_offset = |
1726 | pci_pcie_cap(bridge_pdev); | 1710 | pci_pcie_cap(bridge_pdev); |
1727 | pcipriv->ndis_adapter.num4bytes = | 1711 | pcipriv->ndis_adapter.num4bytes = |
@@ -2010,36 +1994,25 @@ call rtl_mac_stop() from the mac80211 | |||
2010 | suspend function first, So there is | 1994 | suspend function first, So there is |
2011 | no need to call hw_disable here. | 1995 | no need to call hw_disable here. |
2012 | ****************************************/ | 1996 | ****************************************/ |
2013 | int rtl_pci_suspend(struct pci_dev *pdev, pm_message_t state) | 1997 | int rtl_pci_suspend(struct device *dev) |
2014 | { | 1998 | { |
1999 | struct pci_dev *pdev = to_pci_dev(dev); | ||
2015 | struct ieee80211_hw *hw = pci_get_drvdata(pdev); | 2000 | struct ieee80211_hw *hw = pci_get_drvdata(pdev); |
2016 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 2001 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
2017 | 2002 | ||
2018 | rtlpriv->cfg->ops->hw_suspend(hw); | 2003 | rtlpriv->cfg->ops->hw_suspend(hw); |
2019 | rtl_deinit_rfkill(hw); | 2004 | rtl_deinit_rfkill(hw); |
2020 | 2005 | ||
2021 | pci_save_state(pdev); | ||
2022 | pci_disable_device(pdev); | ||
2023 | pci_set_power_state(pdev, PCI_D3hot); | ||
2024 | return 0; | 2006 | return 0; |
2025 | } | 2007 | } |
2026 | EXPORT_SYMBOL(rtl_pci_suspend); | 2008 | EXPORT_SYMBOL(rtl_pci_suspend); |
2027 | 2009 | ||
2028 | int rtl_pci_resume(struct pci_dev *pdev) | 2010 | int rtl_pci_resume(struct device *dev) |
2029 | { | 2011 | { |
2030 | int ret; | 2012 | struct pci_dev *pdev = to_pci_dev(dev); |
2031 | struct ieee80211_hw *hw = pci_get_drvdata(pdev); | 2013 | struct ieee80211_hw *hw = pci_get_drvdata(pdev); |
2032 | struct rtl_priv *rtlpriv = rtl_priv(hw); | 2014 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
2033 | 2015 | ||
2034 | pci_set_power_state(pdev, PCI_D0); | ||
2035 | ret = pci_enable_device(pdev); | ||
2036 | if (ret) { | ||
2037 | RT_ASSERT(false, ("ERR: <======\n")); | ||
2038 | return ret; | ||
2039 | } | ||
2040 | |||
2041 | pci_restore_state(pdev); | ||
2042 | |||
2043 | rtlpriv->cfg->ops->hw_resume(hw); | 2016 | rtlpriv->cfg->ops->hw_resume(hw); |
2044 | rtl_init_rfkill(hw); | 2017 | rtl_init_rfkill(hw); |
2045 | return 0; | 2018 | return 0; |