@@ -149,37 +149,39 @@ static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter)
149149 */
150150static int mwifiex_pcie_suspend (struct device * dev )
151151{
152- struct mwifiex_adapter * adapter ;
153- struct pcie_service_card * card ;
154152 struct pci_dev * pdev = to_pci_dev (dev );
153+ struct pcie_service_card * card = pci_get_drvdata (pdev );
154+ struct mwifiex_adapter * adapter ;
155+ struct mwifiex_private * priv ;
156+ const struct mwifiex_pcie_card_reg * reg ;
157+ u32 fw_status ;
158+ int ret ;
155159
156- card = pci_get_drvdata (pdev );
157160
158161 /* Might still be loading firmware */
159162 wait_for_completion (& card -> fw_done );
160163
161164 adapter = card -> adapter ;
162- if (!adapter ) {
163- dev_err (dev , "adapter is not valid\n" );
165+ if (!adapter || !adapter -> priv_num )
164166 return 0 ;
165- }
166167
167- mwifiex_enable_wake (adapter );
168+ reg = card -> pcie .reg ;
169+ if (reg )
170+ ret = mwifiex_read_reg (adapter , reg -> fw_status , & fw_status );
171+ else
172+ fw_status = -1 ;
173+
174+ if (fw_status == FIRMWARE_READY_PCIE && !adapter -> mfg_mode ) {
175+ mwifiex_deauthenticate_all (adapter );
168176
169- /* Enable the Host Sleep */
170- if (!mwifiex_enable_hs (adapter )) {
171- mwifiex_dbg (adapter , ERROR ,
172- "cmd: failed to suspend\n" );
173- clear_bit (MWIFIEX_IS_HS_ENABLING , & adapter -> work_flags );
174- mwifiex_disable_wake (adapter );
175- return - EFAULT ;
176- }
177+ priv = mwifiex_get_priv (adapter , MWIFIEX_BSS_ROLE_ANY );
177178
178- flush_workqueue (adapter -> workqueue );
179+ mwifiex_disable_auto_ds (priv );
180+
181+ mwifiex_init_shutdown_fw (priv , MWIFIEX_FUNC_SHUTDOWN );
182+ }
179183
180- /* Indicate device suspended */
181- set_bit (MWIFIEX_IS_SUSPENDED , & adapter -> work_flags );
182- clear_bit (MWIFIEX_IS_HS_ENABLING , & adapter -> work_flags );
184+ mwifiex_remove_card (adapter );
183185
184186 return 0 ;
185187}
@@ -194,30 +196,29 @@ static int mwifiex_pcie_suspend(struct device *dev)
194196 */
195197static int mwifiex_pcie_resume (struct device * dev )
196198{
197- struct mwifiex_adapter * adapter ;
198- struct pcie_service_card * card ;
199199 struct pci_dev * pdev = to_pci_dev (dev );
200+ struct pcie_service_card * card = pci_get_drvdata (pdev );
201+ int ret ;
200202
201- card = pci_get_drvdata (pdev );
203+ pr_debug ("info: vendor=0x%4.04X device=0x%4.04X rev=%d\n" ,
204+ pdev -> vendor , pdev -> device , pdev -> revision );
202205
203- if (!card -> adapter ) {
204- dev_err (dev , "adapter structure is not valid\n" );
205- return 0 ;
206- }
206+ init_completion (& card -> fw_done );
207207
208- adapter = card -> adapter ;
208+ card -> dev = pdev ;
209209
210- if (!test_bit (MWIFIEX_IS_SUSPENDED , & adapter -> work_flags )) {
211- mwifiex_dbg (adapter , WARN ,
212- "Device already resumed\n" );
213- return 0 ;
210+ /* device tree node parsing and platform specific configuration */
211+ if (pdev -> dev .of_node ) {
212+ ret = mwifiex_pcie_probe_of (& pdev -> dev );
213+ if (ret )
214+ return ret ;
214215 }
215216
216- clear_bit ( MWIFIEX_IS_SUSPENDED , & adapter -> work_flags );
217-
218- mwifiex_cancel_hs ( mwifiex_get_priv ( adapter , MWIFIEX_BSS_ROLE_STA ),
219- MWIFIEX_ASYNC_CMD ) ;
220- mwifiex_disable_wake ( adapter );
217+ if ( mwifiex_add_card ( card , & card -> fw_done , & pcie_ops ,
218+ MWIFIEX_PCIE , & pdev -> dev )) {
219+ pr_err ( "%s failed\n" , __func__ );
220+ return -1 ;
221+ }
221222
222223 return 0 ;
223224}
@@ -271,6 +272,8 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
271272 return -1 ;
272273 }
273274
275+ pdev -> bus -> self -> bridge_d3 = false;
276+
274277 return 0 ;
275278}
276279
0 commit comments