aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2012-01-08 14:12:22 -0500
committerWey-Yi Guy <wey-yi.w.guy@intel.com>2012-02-02 17:37:06 -0500
commitaf634bee8c4a15629da5e114c491acb8ee50e1e9 (patch)
tree24e6f66308ddadeef4e39194e9261fa5ea03b648
parentcf6142975bcbb731bc131ee9d2a68b7561076545 (diff)
iwlwifi: kill bus_apm_config
This handler was called from the transport layer only. Merge it to the transport's apm_init. Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-bus.h7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-pci.c29
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie.c50
3 files changed, 46 insertions, 40 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h
index 2065c5b7416..d385f692ef1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-bus.h
+++ b/drivers/net/wireless/iwlwifi/iwl-bus.h
@@ -121,13 +121,11 @@ struct iwl_bus;
121/** 121/**
122 * struct iwl_bus_ops - bus specific operations 122 * struct iwl_bus_ops - bus specific operations
123 * @get_pm_support: must returns true if the bus can go to sleep 123 * @get_pm_support: must returns true if the bus can go to sleep
124 * @apm_config: will be called during the config of the APM
125 * @get_hw_id_string: prints the hw_id in the provided buffer 124 * @get_hw_id_string: prints the hw_id in the provided buffer
126 * @get_hw_id: get hw_id in u32 125 * @get_hw_id: get hw_id in u32
127 */ 126 */
128struct iwl_bus_ops { 127struct iwl_bus_ops {
129 bool (*get_pm_support)(struct iwl_bus *bus); 128 bool (*get_pm_support)(struct iwl_bus *bus);
130 void (*apm_config)(struct iwl_bus *bus);
131 void (*get_hw_id_string)(struct iwl_bus *bus, char buf[], int buf_len); 129 void (*get_hw_id_string)(struct iwl_bus *bus, char buf[], int buf_len);
132 u32 (*get_hw_id)(struct iwl_bus *bus); 130 u32 (*get_hw_id)(struct iwl_bus *bus);
133}; 131};
@@ -156,11 +154,6 @@ static inline bool bus_get_pm_support(struct iwl_bus *bus)
156 return bus->ops->get_pm_support(bus); 154 return bus->ops->get_pm_support(bus);
157} 155}
158 156
159static inline void bus_apm_config(struct iwl_bus *bus)
160{
161 bus->ops->apm_config(bus);
162}
163
164static inline void bus_get_hw_id_string(struct iwl_bus *bus, char buf[], 157static inline void bus_get_hw_id_string(struct iwl_bus *bus, char buf[],
165 int buf_len) 158 int buf_len)
166{ 159{
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c
index 6451739aed2..353022d406e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-pci.c
+++ b/drivers/net/wireless/iwlwifi/iwl-pci.c
@@ -106,34 +106,6 @@ static bool iwl_pci_is_pm_supported(struct iwl_bus *bus)
106 return !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); 106 return !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN);
107} 107}
108 108
109static void iwl_pci_apm_config(struct iwl_bus *bus)
110{
111 /*
112 * HW bug W/A for instability in PCIe bus L0S->L1 transition.
113 * Check if BIOS (or OS) enabled L1-ASPM on this device.
114 * If so (likely), disable L0S, so device moves directly L0->L1;
115 * costs negligible amount of power savings.
116 * If not (unlikely), enable L0S, so there is at least some
117 * power savings, even without L1.
118 */
119 u16 lctl = iwl_pciexp_link_ctrl(bus);
120
121 if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) ==
122 PCI_CFG_LINK_CTRL_VAL_L1_EN) {
123 /* L1-ASPM enabled; disable(!) L0S */
124 iwl_set_bit(trans(bus), CSR_GIO_REG,
125 CSR_GIO_REG_VAL_L0S_ENABLED);
126 dev_printk(KERN_INFO, trans(bus)->dev,
127 "L1 Enabled; Disabling L0S\n");
128 } else {
129 /* L1-ASPM disabled; enable(!) L0S */
130 iwl_clear_bit(trans(bus), CSR_GIO_REG,
131 CSR_GIO_REG_VAL_L0S_ENABLED);
132 dev_printk(KERN_INFO, trans(bus)->dev,
133 "L1 Disabled; Enabling L0S\n");
134 }
135}
136
137static void iwl_pci_get_hw_id_string(struct iwl_bus *bus, char buf[], 109static void iwl_pci_get_hw_id_string(struct iwl_bus *bus, char buf[],
138 int buf_len) 110 int buf_len)
139{ 111{
@@ -152,7 +124,6 @@ static u32 iwl_pci_get_hw_id(struct iwl_bus *bus)
152 124
153static const struct iwl_bus_ops bus_ops_pci = { 125static const struct iwl_bus_ops bus_ops_pci = {
154 .get_pm_support = iwl_pci_is_pm_supported, 126 .get_pm_support = iwl_pci_is_pm_supported,
155 .apm_config = iwl_pci_apm_config,
156 .get_hw_id_string = iwl_pci_get_hw_id_string, 127 .get_hw_id_string = iwl_pci_get_hw_id_string,
157 .get_hw_id = iwl_pci_get_hw_id, 128 .get_hw_id = iwl_pci_get_hw_id,
158}; 129};
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
index 1030a252405..c9fe8889ad8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
@@ -633,6 +633,51 @@ static void iwl_set_pwr_vmain(struct iwl_trans *trans)
633 ~APMG_PS_CTRL_MSK_PWR_SRC); 633 ~APMG_PS_CTRL_MSK_PWR_SRC);
634} 634}
635 635
636/* PCI registers */
637#define PCI_CFG_RETRY_TIMEOUT 0x041
638#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
639#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
640
641static u16 iwl_pciexp_link_ctrl(struct iwl_trans *trans)
642{
643 int pos;
644 u16 pci_lnk_ctl;
645 struct iwl_trans_pcie *trans_pcie =
646 IWL_TRANS_GET_PCIE_TRANS(trans);
647
648 struct pci_dev *pci_dev = trans_pcie->pci_dev;
649
650 pos = pci_pcie_cap(pci_dev);
651 pci_read_config_word(pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl);
652 return pci_lnk_ctl;
653}
654
655static void iwl_apm_config(struct iwl_trans *trans)
656{
657 /*
658 * HW bug W/A for instability in PCIe bus L0S->L1 transition.
659 * Check if BIOS (or OS) enabled L1-ASPM on this device.
660 * If so (likely), disable L0S, so device moves directly L0->L1;
661 * costs negligible amount of power savings.
662 * If not (unlikely), enable L0S, so there is at least some
663 * power savings, even without L1.
664 */
665 u16 lctl = iwl_pciexp_link_ctrl(trans);
666
667 if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) ==
668 PCI_CFG_LINK_CTRL_VAL_L1_EN) {
669 /* L1-ASPM enabled; disable(!) L0S */
670 iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
671 dev_printk(KERN_INFO, trans->dev,
672 "L1 Enabled; Disabling L0S\n");
673 } else {
674 /* L1-ASPM disabled; enable(!) L0S */
675 iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
676 dev_printk(KERN_INFO, trans->dev,
677 "L1 Disabled; Enabling L0S\n");
678 }
679}
680
636/* 681/*
637 * Start up NIC's basic functionality after it has been reset 682 * Start up NIC's basic functionality after it has been reset
638 * (e.g. after platform boot, or shutdown via iwl_apm_stop()) 683 * (e.g. after platform boot, or shutdown via iwl_apm_stop())
@@ -669,7 +714,7 @@ static int iwl_apm_init(struct iwl_trans *trans)
669 iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, 714 iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG,
670 CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); 715 CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A);
671 716
672 bus_apm_config(bus(trans)); 717 iwl_apm_config(trans);
673 718
674 /* Configure analog phase-lock-loop before activating to D0A */ 719 /* Configure analog phase-lock-loop before activating to D0A */
675 if (cfg(trans)->base_params->pll_cfg_val) 720 if (cfg(trans)->base_params->pll_cfg_val)
@@ -2187,9 +2232,6 @@ const struct iwl_trans_ops trans_ops_pcie = {
2187 .read32 = iwl_trans_pcie_read32, 2232 .read32 = iwl_trans_pcie_read32,
2188}; 2233};
2189 2234
2190/* PCI registers */
2191#define PCI_CFG_RETRY_TIMEOUT 0x041
2192
2193struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd, 2235struct iwl_trans *iwl_trans_pcie_alloc(struct iwl_shared *shrd,
2194 struct pci_dev *pdev, 2236 struct pci_dev *pdev,
2195 const struct pci_device_id *ent) 2237 const struct pci_device_id *ent)