diff options
author | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2011-07-10 08:30:15 -0400 |
---|---|---|
committer | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2011-07-21 10:29:22 -0400 |
commit | 392f8b789a4c96b39d527ff8ea5ceba20cd79d56 (patch) | |
tree | 709e65b40107affc0fa0ad4842a4fccb132ccfeb /drivers/net/wireless | |
parent | 48d42c426947d8ffba0caa3cf9c58be6903302e0 (diff) |
iwlagn: move more functions from the start flow to the transport layer
Basically all the nic_init flow should be in the transport layer.
iwl_prepare_card_hw will move to the transport too in a separate patch.
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 102 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-ucode.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn.c | 49 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn.h | 5 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-dev.h | 16 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c | 12 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-trans.c | 164 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-trans.h | 21 |
8 files changed, 178 insertions, 193 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 339a89ca4d79..6ed0eae4c543 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c | |||
@@ -606,59 +606,6 @@ struct iwl_mod_params iwlagn_mod_params = { | |||
606 | /* the rest are 0 by default */ | 606 | /* the rest are 0 by default */ |
607 | }; | 607 | }; |
608 | 608 | ||
609 | static void iwlagn_set_pwr_vmain(struct iwl_priv *priv) | ||
610 | { | ||
611 | /* | ||
612 | * (for documentation purposes) | ||
613 | * to set power to V_AUX, do: | ||
614 | |||
615 | if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) | ||
616 | iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, | ||
617 | APMG_PS_CTRL_VAL_PWR_SRC_VAUX, | ||
618 | ~APMG_PS_CTRL_MSK_PWR_SRC); | ||
619 | */ | ||
620 | |||
621 | iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, | ||
622 | APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, | ||
623 | ~APMG_PS_CTRL_MSK_PWR_SRC); | ||
624 | } | ||
625 | |||
626 | /*TODO: this function should move to transport layer */ | ||
627 | int iwlagn_hw_nic_init(struct iwl_priv *priv) | ||
628 | { | ||
629 | unsigned long flags; | ||
630 | |||
631 | /* nic_init */ | ||
632 | spin_lock_irqsave(&priv->lock, flags); | ||
633 | iwl_apm_init(priv); | ||
634 | |||
635 | /* Set interrupt coalescing calibration timer to default (512 usecs) */ | ||
636 | iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF); | ||
637 | |||
638 | spin_unlock_irqrestore(&priv->lock, flags); | ||
639 | |||
640 | iwlagn_set_pwr_vmain(priv); | ||
641 | |||
642 | priv->cfg->lib->nic_config(priv); | ||
643 | |||
644 | /* Allocate the RX queue, or reset if it is already allocated */ | ||
645 | trans_rx_init(priv); | ||
646 | |||
647 | /* Allocate or reset and init all Tx and Command queues */ | ||
648 | if (trans_tx_init(priv)) | ||
649 | return -ENOMEM; | ||
650 | |||
651 | if (priv->cfg->base_params->shadow_reg_enable) { | ||
652 | /* enable shadow regs in HW */ | ||
653 | iwl_set_bit(priv, CSR_MAC_SHADOW_REG_CTRL, | ||
654 | 0x800FFFFF); | ||
655 | } | ||
656 | |||
657 | set_bit(STATUS_INIT, &priv->status); | ||
658 | |||
659 | return 0; | ||
660 | } | ||
661 | |||
662 | int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) | 609 | int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) |
663 | { | 610 | { |
664 | int idx = 0; | 611 | int idx = 0; |
@@ -2092,52 +2039,3 @@ void iwlagn_remove_notification(struct iwl_priv *priv, | |||
2092 | list_del(&wait_entry->list); | 2039 | list_del(&wait_entry->list); |
2093 | spin_unlock_bh(&priv->_agn.notif_wait_lock); | 2040 | spin_unlock_bh(&priv->_agn.notif_wait_lock); |
2094 | } | 2041 | } |
2095 | |||
2096 | int iwlagn_start_device(struct iwl_priv *priv) | ||
2097 | { | ||
2098 | int ret; | ||
2099 | |||
2100 | priv->ucode_owner = IWL_OWNERSHIP_DRIVER; | ||
2101 | |||
2102 | if ((priv->cfg->sku & EEPROM_SKU_CAP_AMT_ENABLE) && | ||
2103 | iwl_prepare_card_hw(priv)) { | ||
2104 | IWL_WARN(priv, "Exit HW not ready\n"); | ||
2105 | return -EIO; | ||
2106 | } | ||
2107 | |||
2108 | /* If platform's RF_KILL switch is NOT set to KILL */ | ||
2109 | if (iwl_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) | ||
2110 | clear_bit(STATUS_RF_KILL_HW, &priv->status); | ||
2111 | else | ||
2112 | set_bit(STATUS_RF_KILL_HW, &priv->status); | ||
2113 | |||
2114 | if (iwl_is_rfkill(priv)) { | ||
2115 | wiphy_rfkill_set_hw_state(priv->hw->wiphy, true); | ||
2116 | iwl_enable_interrupts(priv); | ||
2117 | return -ERFKILL; | ||
2118 | } | ||
2119 | |||
2120 | iwl_write32(priv, CSR_INT, 0xFFFFFFFF); | ||
2121 | |||
2122 | ret = iwlagn_hw_nic_init(priv); | ||
2123 | if (ret) { | ||
2124 | IWL_ERR(priv, "Unable to init nic\n"); | ||
2125 | return ret; | ||
2126 | } | ||
2127 | |||
2128 | /* make sure rfkill handshake bits are cleared */ | ||
2129 | iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); | ||
2130 | iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, | ||
2131 | CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); | ||
2132 | |||
2133 | /* clear (again), then enable host interrupts */ | ||
2134 | iwl_write32(priv, CSR_INT, 0xFFFFFFFF); | ||
2135 | iwl_enable_interrupts(priv); | ||
2136 | |||
2137 | /* really make sure rfkill handshake bits are cleared */ | ||
2138 | iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); | ||
2139 | iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); | ||
2140 | |||
2141 | return 0; | ||
2142 | } | ||
2143 | |||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c index 667cfb7002d0..e4b2f78775f4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c | |||
@@ -478,7 +478,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, | |||
478 | int ret; | 478 | int ret; |
479 | enum iwlagn_ucode_type old_type; | 479 | enum iwlagn_ucode_type old_type; |
480 | 480 | ||
481 | ret = iwlagn_start_device(priv); | 481 | ret = trans_start_device(priv); |
482 | if (ret) | 482 | if (ret) |
483 | return ret; | 483 | return ret; |
484 | 484 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 9ba5fcd82880..d0f6875c64ae 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -1798,55 +1798,6 @@ static void iwl_down(struct iwl_priv *priv) | |||
1798 | iwl_cancel_deferred_work(priv); | 1798 | iwl_cancel_deferred_work(priv); |
1799 | } | 1799 | } |
1800 | 1800 | ||
1801 | #define HW_READY_TIMEOUT (50) | ||
1802 | |||
1803 | /* Note: returns poll_bit return value, which is >= 0 if success */ | ||
1804 | static int iwl_set_hw_ready(struct iwl_priv *priv) | ||
1805 | { | ||
1806 | int ret; | ||
1807 | |||
1808 | iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, | ||
1809 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); | ||
1810 | |||
1811 | /* See if we got it */ | ||
1812 | ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, | ||
1813 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, | ||
1814 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, | ||
1815 | HW_READY_TIMEOUT); | ||
1816 | |||
1817 | IWL_DEBUG_INFO(priv, "hardware%s ready\n", ret < 0 ? " not" : ""); | ||
1818 | return ret; | ||
1819 | } | ||
1820 | |||
1821 | /* Note: returns standard 0/-ERROR code */ | ||
1822 | int iwl_prepare_card_hw(struct iwl_priv *priv) | ||
1823 | { | ||
1824 | int ret; | ||
1825 | |||
1826 | IWL_DEBUG_INFO(priv, "iwl_prepare_card_hw enter\n"); | ||
1827 | |||
1828 | ret = iwl_set_hw_ready(priv); | ||
1829 | if (ret >= 0) | ||
1830 | return 0; | ||
1831 | |||
1832 | /* If HW is not ready, prepare the conditions to check again */ | ||
1833 | iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, | ||
1834 | CSR_HW_IF_CONFIG_REG_PREPARE); | ||
1835 | |||
1836 | ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, | ||
1837 | ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, | ||
1838 | CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); | ||
1839 | |||
1840 | if (ret < 0) | ||
1841 | return ret; | ||
1842 | |||
1843 | /* HW should be ready by now, check again. */ | ||
1844 | ret = iwl_set_hw_ready(priv); | ||
1845 | if (ret >= 0) | ||
1846 | return 0; | ||
1847 | return ret; | ||
1848 | } | ||
1849 | |||
1850 | #define MAX_HW_RESTARTS 5 | 1801 | #define MAX_HW_RESTARTS 5 |
1851 | 1802 | ||
1852 | static int __iwl_up(struct iwl_priv *priv) | 1803 | static int __iwl_up(struct iwl_priv *priv) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 0a8417a2c29a..ffb6bd2e02a9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h | |||
@@ -122,12 +122,10 @@ static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd) | |||
122 | hdr->data_valid = 1; | 122 | hdr->data_valid = 1; |
123 | } | 123 | } |
124 | 124 | ||
125 | /* TODO: this one should be API of the transport layer */ | ||
125 | int iwl_prepare_card_hw(struct iwl_priv *priv); | 126 | int iwl_prepare_card_hw(struct iwl_priv *priv); |
126 | 127 | ||
127 | int iwlagn_start_device(struct iwl_priv *priv); | ||
128 | |||
129 | /* tx queue */ | 128 | /* tx queue */ |
130 | /*TODO: this one should go to transport layer */ | ||
131 | void iwl_free_tfds_in_queue(struct iwl_priv *priv, | 129 | void iwl_free_tfds_in_queue(struct iwl_priv *priv, |
132 | int sta_id, int tid, int freed); | 130 | int sta_id, int tid, int freed); |
133 | 131 | ||
@@ -158,7 +156,6 @@ int iwlagn_hw_valid_rtc_data_addr(u32 addr); | |||
158 | int iwlagn_send_tx_power(struct iwl_priv *priv); | 156 | int iwlagn_send_tx_power(struct iwl_priv *priv); |
159 | void iwlagn_temperature(struct iwl_priv *priv); | 157 | void iwlagn_temperature(struct iwl_priv *priv); |
160 | u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv); | 158 | u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv); |
161 | int iwlagn_hw_nic_init(struct iwl_priv *priv); | ||
162 | int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv); | 159 | int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv); |
163 | int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control); | 160 | int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control); |
164 | void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control); | 161 | void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index b18a9a88d7be..ca154344bed1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -1234,13 +1234,13 @@ struct iwl_trans; | |||
1234 | 1234 | ||
1235 | /** | 1235 | /** |
1236 | * struct iwl_trans_ops - transport specific operations | 1236 | * struct iwl_trans_ops - transport specific operations |
1237 | * @rx_init: inits the rx memory, allocate it if needed | 1237 | * @start_device: allocates and inits all the resources for the transport |
1238 | * @rx_free: frees the rx memory | 1238 | * layer. |
1239 | * @tx_init:inits the tx memory, allocate if needed | ||
1240 | * @tx_start: starts and configures all the Tx fifo - usually done once the fw | 1239 | * @tx_start: starts and configures all the Tx fifo - usually done once the fw |
1241 | * is alive. | 1240 | * is alive. |
1242 | * @tx_free: frees the tx memory | ||
1243 | * @stop_device:stops the whole device (embedded CPU put to reset) | 1241 | * @stop_device:stops the whole device (embedded CPU put to reset) |
1242 | * @rx_free: frees the rx memory | ||
1243 | * @tx_free: frees the tx memory | ||
1244 | * @send_cmd:send a host command | 1244 | * @send_cmd:send a host command |
1245 | * @send_cmd_pdu:send a host command: flags can be CMD_* | 1245 | * @send_cmd_pdu:send a host command: flags can be CMD_* |
1246 | * @get_tx_cmd: returns a pointer to a new Tx cmd for the upper layer use | 1246 | * @get_tx_cmd: returns a pointer to a new Tx cmd for the upper layer use |
@@ -1257,14 +1257,12 @@ struct iwl_trans; | |||
1257 | * irq, tasklet etc... | 1257 | * irq, tasklet etc... |
1258 | */ | 1258 | */ |
1259 | struct iwl_trans_ops { | 1259 | struct iwl_trans_ops { |
1260 | int (*rx_init)(struct iwl_priv *priv); | ||
1261 | void (*rx_free)(struct iwl_priv *priv); | ||
1262 | 1260 | ||
1263 | int (*tx_init)(struct iwl_priv *priv); | 1261 | int (*start_device)(struct iwl_priv *priv); |
1262 | void (*stop_device)(struct iwl_priv *priv); | ||
1264 | void (*tx_start)(struct iwl_priv *priv); | 1263 | void (*tx_start)(struct iwl_priv *priv); |
1265 | void (*tx_free)(struct iwl_priv *priv); | 1264 | void (*tx_free)(struct iwl_priv *priv); |
1266 | 1265 | void (*rx_free)(struct iwl_priv *priv); | |
1267 | void (*stop_device)(struct iwl_priv *priv); | ||
1268 | 1266 | ||
1269 | int (*send_cmd)(struct iwl_priv *priv, struct iwl_host_cmd *cmd); | 1267 | int (*send_cmd)(struct iwl_priv *priv, struct iwl_host_cmd *cmd); |
1270 | 1268 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c index 9cecb1076280..7dac6ee23250 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c | |||
@@ -35,15 +35,9 @@ | |||
35 | #include "iwl-dev.h" | 35 | #include "iwl-dev.h" |
36 | #include "iwl-core.h" | 36 | #include "iwl-core.h" |
37 | #include "iwl-io.h" | 37 | #include "iwl-io.h" |
38 | #include "iwl-sta.h" | ||
39 | #include "iwl-helpers.h" | 38 | #include "iwl-helpers.h" |
40 | #include "iwl-trans-int-pcie.h" | 39 | #include "iwl-trans-int-pcie.h" |
41 | 40 | ||
42 | /* TODO:this file should _not_ include the external API header file | ||
43 | * (iwl-trans.h). This is needed as a W/A until reclaim functions will move to | ||
44 | * the transport layer */ | ||
45 | #include "iwl-trans.h" | ||
46 | |||
47 | /** | 41 | /** |
48 | * iwl_trans_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array | 42 | * iwl_trans_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array |
49 | */ | 43 | */ |
@@ -339,7 +333,11 @@ int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q, | |||
339 | } | 333 | } |
340 | 334 | ||
341 | /*TODO: this functions should NOT be exported from trans module - export it | 335 | /*TODO: this functions should NOT be exported from trans module - export it |
342 | * until the reclaim flow will be brought to the transport module too */ | 336 | * until the reclaim flow will be brought to the transport module too. |
337 | * Add a declaration to make sparse happy */ | ||
338 | void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_priv *priv, | ||
339 | struct iwl_tx_queue *txq); | ||
340 | |||
343 | void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_priv *priv, | 341 | void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_priv *priv, |
344 | struct iwl_tx_queue *txq) | 342 | struct iwl_tx_queue *txq) |
345 | { | 343 | { |
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.c b/drivers/net/wireless/iwlwifi/iwl-trans.c index bddc12d27d06..e9c7de9f8e0f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans.c | |||
@@ -177,7 +177,7 @@ static void iwl_trans_rx_hw_init(struct iwl_priv *priv, | |||
177 | iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF); | 177 | iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF); |
178 | } | 178 | } |
179 | 179 | ||
180 | static int iwl_trans_rx_init(struct iwl_priv *priv) | 180 | static int iwl_rx_init(struct iwl_priv *priv) |
181 | { | 181 | { |
182 | struct iwl_rx_queue *rxq = &priv->rxq; | 182 | struct iwl_rx_queue *rxq = &priv->rxq; |
183 | int i, err; | 183 | int i, err; |
@@ -530,7 +530,7 @@ error: | |||
530 | 530 | ||
531 | return ret; | 531 | return ret; |
532 | } | 532 | } |
533 | static int iwl_trans_tx_init(struct iwl_priv *priv) | 533 | static int iwl_tx_init(struct iwl_priv *priv) |
534 | { | 534 | { |
535 | int ret; | 535 | int ret; |
536 | int txq_id, slots_num; | 536 | int txq_id, slots_num; |
@@ -574,6 +574,156 @@ error: | |||
574 | return ret; | 574 | return ret; |
575 | } | 575 | } |
576 | 576 | ||
577 | static void iwl_set_pwr_vmain(struct iwl_priv *priv) | ||
578 | { | ||
579 | /* | ||
580 | * (for documentation purposes) | ||
581 | * to set power to V_AUX, do: | ||
582 | |||
583 | if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) | ||
584 | iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, | ||
585 | APMG_PS_CTRL_VAL_PWR_SRC_VAUX, | ||
586 | ~APMG_PS_CTRL_MSK_PWR_SRC); | ||
587 | */ | ||
588 | |||
589 | iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, | ||
590 | APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, | ||
591 | ~APMG_PS_CTRL_MSK_PWR_SRC); | ||
592 | } | ||
593 | |||
594 | static int iwl_nic_init(struct iwl_priv *priv) | ||
595 | { | ||
596 | unsigned long flags; | ||
597 | |||
598 | /* nic_init */ | ||
599 | spin_lock_irqsave(&priv->lock, flags); | ||
600 | iwl_apm_init(priv); | ||
601 | |||
602 | /* Set interrupt coalescing calibration timer to default (512 usecs) */ | ||
603 | iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF); | ||
604 | |||
605 | spin_unlock_irqrestore(&priv->lock, flags); | ||
606 | |||
607 | iwl_set_pwr_vmain(priv); | ||
608 | |||
609 | priv->cfg->lib->nic_config(priv); | ||
610 | |||
611 | /* Allocate the RX queue, or reset if it is already allocated */ | ||
612 | iwl_rx_init(priv); | ||
613 | |||
614 | /* Allocate or reset and init all Tx and Command queues */ | ||
615 | if (iwl_tx_init(priv)) | ||
616 | return -ENOMEM; | ||
617 | |||
618 | if (priv->cfg->base_params->shadow_reg_enable) { | ||
619 | /* enable shadow regs in HW */ | ||
620 | iwl_set_bit(priv, CSR_MAC_SHADOW_REG_CTRL, | ||
621 | 0x800FFFFF); | ||
622 | } | ||
623 | |||
624 | set_bit(STATUS_INIT, &priv->status); | ||
625 | |||
626 | return 0; | ||
627 | } | ||
628 | |||
629 | #define HW_READY_TIMEOUT (50) | ||
630 | |||
631 | /* Note: returns poll_bit return value, which is >= 0 if success */ | ||
632 | static int iwl_set_hw_ready(struct iwl_priv *priv) | ||
633 | { | ||
634 | int ret; | ||
635 | |||
636 | iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, | ||
637 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); | ||
638 | |||
639 | /* See if we got it */ | ||
640 | ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, | ||
641 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, | ||
642 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, | ||
643 | HW_READY_TIMEOUT); | ||
644 | |||
645 | IWL_DEBUG_INFO(priv, "hardware%s ready\n", ret < 0 ? " not" : ""); | ||
646 | return ret; | ||
647 | } | ||
648 | |||
649 | /* Note: returns standard 0/-ERROR code */ | ||
650 | int iwl_prepare_card_hw(struct iwl_priv *priv) | ||
651 | { | ||
652 | int ret; | ||
653 | |||
654 | IWL_DEBUG_INFO(priv, "iwl_prepare_card_hw enter\n"); | ||
655 | |||
656 | ret = iwl_set_hw_ready(priv); | ||
657 | if (ret >= 0) | ||
658 | return 0; | ||
659 | |||
660 | /* If HW is not ready, prepare the conditions to check again */ | ||
661 | iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, | ||
662 | CSR_HW_IF_CONFIG_REG_PREPARE); | ||
663 | |||
664 | ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, | ||
665 | ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, | ||
666 | CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); | ||
667 | |||
668 | if (ret < 0) | ||
669 | return ret; | ||
670 | |||
671 | /* HW should be ready by now, check again. */ | ||
672 | ret = iwl_set_hw_ready(priv); | ||
673 | if (ret >= 0) | ||
674 | return 0; | ||
675 | return ret; | ||
676 | } | ||
677 | |||
678 | static int iwl_trans_start_device(struct iwl_priv *priv) | ||
679 | { | ||
680 | int ret; | ||
681 | |||
682 | priv->ucode_owner = IWL_OWNERSHIP_DRIVER; | ||
683 | |||
684 | if ((priv->cfg->sku & EEPROM_SKU_CAP_AMT_ENABLE) && | ||
685 | iwl_prepare_card_hw(priv)) { | ||
686 | IWL_WARN(priv, "Exit HW not ready\n"); | ||
687 | return -EIO; | ||
688 | } | ||
689 | |||
690 | /* If platform's RF_KILL switch is NOT set to KILL */ | ||
691 | if (iwl_read32(priv, CSR_GP_CNTRL) & | ||
692 | CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) | ||
693 | clear_bit(STATUS_RF_KILL_HW, &priv->status); | ||
694 | else | ||
695 | set_bit(STATUS_RF_KILL_HW, &priv->status); | ||
696 | |||
697 | if (iwl_is_rfkill(priv)) { | ||
698 | wiphy_rfkill_set_hw_state(priv->hw->wiphy, true); | ||
699 | iwl_enable_interrupts(priv); | ||
700 | return -ERFKILL; | ||
701 | } | ||
702 | |||
703 | iwl_write32(priv, CSR_INT, 0xFFFFFFFF); | ||
704 | |||
705 | ret = iwl_nic_init(priv); | ||
706 | if (ret) { | ||
707 | IWL_ERR(priv, "Unable to init nic\n"); | ||
708 | return ret; | ||
709 | } | ||
710 | |||
711 | /* make sure rfkill handshake bits are cleared */ | ||
712 | iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); | ||
713 | iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, | ||
714 | CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); | ||
715 | |||
716 | /* clear (again), then enable host interrupts */ | ||
717 | iwl_write32(priv, CSR_INT, 0xFFFFFFFF); | ||
718 | iwl_enable_interrupts(priv); | ||
719 | |||
720 | /* really make sure rfkill handshake bits are cleared */ | ||
721 | iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); | ||
722 | iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); | ||
723 | |||
724 | return 0; | ||
725 | } | ||
726 | |||
577 | /* | 727 | /* |
578 | * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask | 728 | * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask |
579 | * must be called under priv->lock and mac access | 729 | * must be called under priv->lock and mac access |
@@ -972,14 +1122,12 @@ static void iwl_trans_free(struct iwl_priv *priv) | |||
972 | } | 1122 | } |
973 | 1123 | ||
974 | static const struct iwl_trans_ops trans_ops = { | 1124 | static const struct iwl_trans_ops trans_ops = { |
975 | .rx_init = iwl_trans_rx_init, | 1125 | .start_device = iwl_trans_start_device, |
976 | .rx_free = iwl_trans_rx_free, | 1126 | .stop_device = iwl_trans_stop_device, |
977 | |||
978 | .tx_init = iwl_trans_tx_init, | ||
979 | .tx_start = iwl_trans_tx_start, | 1127 | .tx_start = iwl_trans_tx_start, |
980 | .tx_free = iwl_trans_tx_free, | ||
981 | 1128 | ||
982 | .stop_device = iwl_trans_stop_device, | 1129 | .rx_free = iwl_trans_rx_free, |
1130 | .tx_free = iwl_trans_tx_free, | ||
983 | 1131 | ||
984 | .send_cmd = iwl_send_cmd, | 1132 | .send_cmd = iwl_send_cmd, |
985 | .send_cmd_pdu = iwl_send_cmd_pdu, | 1133 | .send_cmd_pdu = iwl_send_cmd_pdu, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 215f4d5f30bf..9e801d8963d1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h | |||
@@ -64,19 +64,14 @@ | |||
64 | /*This file includes the declaration that are exported from the transport | 64 | /*This file includes the declaration that are exported from the transport |
65 | * layer */ | 65 | * layer */ |
66 | 66 | ||
67 | static inline int trans_rx_init(struct iwl_priv *priv) | 67 | static inline int trans_start_device(struct iwl_priv *priv) |
68 | { | 68 | { |
69 | return priv->trans.ops->rx_init(priv); | 69 | return priv->trans.ops->start_device(priv); |
70 | } | 70 | } |
71 | 71 | ||
72 | static inline void trans_rx_free(struct iwl_priv *priv) | 72 | static inline void trans_stop_device(struct iwl_priv *priv) |
73 | { | ||
74 | priv->trans.ops->rx_free(priv); | ||
75 | } | ||
76 | |||
77 | static inline int trans_tx_init(struct iwl_priv *priv) | ||
78 | { | 73 | { |
79 | return priv->trans.ops->tx_init(priv); | 74 | priv->trans.ops->stop_device(priv); |
80 | } | 75 | } |
81 | 76 | ||
82 | static inline void trans_tx_start(struct iwl_priv *priv) | 77 | static inline void trans_tx_start(struct iwl_priv *priv) |
@@ -84,14 +79,14 @@ static inline void trans_tx_start(struct iwl_priv *priv) | |||
84 | priv->trans.ops->tx_start(priv); | 79 | priv->trans.ops->tx_start(priv); |
85 | } | 80 | } |
86 | 81 | ||
87 | static inline void trans_tx_free(struct iwl_priv *priv) | 82 | static inline void trans_rx_free(struct iwl_priv *priv) |
88 | { | 83 | { |
89 | priv->trans.ops->tx_free(priv); | 84 | priv->trans.ops->rx_free(priv); |
90 | } | 85 | } |
91 | 86 | ||
92 | static inline void trans_stop_device(struct iwl_priv *priv) | 87 | static inline void trans_tx_free(struct iwl_priv *priv) |
93 | { | 88 | { |
94 | priv->trans.ops->stop_device(priv); | 89 | priv->trans.ops->tx_free(priv); |
95 | } | 90 | } |
96 | 91 | ||
97 | static inline int trans_send_cmd(struct iwl_priv *priv, | 92 | static inline int trans_send_cmd(struct iwl_priv *priv, |