forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/net/wireless/intel/iwlwifi/iwl-io.c
....@@ -1,9 +1,13 @@
11 /******************************************************************************
22 *
3
+ * This file is provided under a dual BSD/GPLv2 license. When using or
4
+ * redistributing this file, you may do so under either license.
5
+ *
6
+ * GPL LICENSE SUMMARY
7
+ *
38 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
49 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
5
- *
6
- * Portions of this file are derived from the ipw3945 project.
10
+ * Copyright(C) 2018 - 2019 Intel Corporation
711 *
812 * This program is free software; you can redistribute it and/or modify it
913 * under the terms of version 2 of the GNU General Public License as
....@@ -14,16 +18,45 @@
1418 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
1519 * more details.
1620 *
17
- * You should have received a copy of the GNU General Public License along with
18
- * this program; if not, write to the Free Software Foundation, Inc.,
19
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20
- *
2121 * The full GNU General Public License is included in this distribution in the
22
- * file called LICENSE.
22
+ * file called COPYING.
2323 *
2424 * Contact Information:
2525 * Intel Linux Wireless <linuxwifi@intel.com>
2626 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27
+ *
28
+ * BSD LICENSE
29
+ *
30
+ * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
31
+ * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
32
+ * Copyright (C) 2018 - 2019 Intel Corporation
33
+ * All rights reserved.
34
+ *
35
+ * Redistribution and use in source and binary forms, with or without
36
+ * modification, are permitted provided that the following conditions
37
+ * are met:
38
+ *
39
+ * * Redistributions of source code must retain the above copyright
40
+ * notice, this list of conditions and the following disclaimer.
41
+ * * Redistributions in binary form must reproduce the above copyright
42
+ * notice, this list of conditions and the following disclaimer in
43
+ * the documentation and/or other materials provided with the
44
+ * distribution.
45
+ * * Neither the name Intel Corporation nor the names of its
46
+ * contributors may be used to endorse or promote products derived
47
+ * from this software without specific prior written permission.
48
+ *
49
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
50
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
51
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
52
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
53
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
54
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
55
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
57
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
58
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
59
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2760 *
2861 *****************************************************************************/
2962 #include <linux/delay.h>
....@@ -241,12 +274,15 @@
241274
242275 void iwl_force_nmi(struct iwl_trans *trans)
243276 {
244
- if (trans->cfg->device_family < IWL_DEVICE_FAMILY_9000)
277
+ if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_9000)
245278 iwl_write_prph(trans, DEVICE_SET_NMI_REG,
246279 DEVICE_SET_NMI_VAL_DRV);
280
+ else if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210)
281
+ iwl_write_umac_prph(trans, UREG_NIC_SET_NMI_DRIVER,
282
+ UREG_NIC_SET_NMI_DRIVER_NMI_FROM_DRIVER_MSK);
247283 else
248
- iwl_write_prph(trans, UREG_NIC_SET_NMI_DRIVER,
249
- UREG_NIC_SET_NMI_DRIVER_NMI_FROM_DRIVER_MSK);
284
+ iwl_write_umac_prph(trans, UREG_DOORBELL_TO_ISR6,
285
+ UREG_DOORBELL_TO_ISR6_NMI_BIT);
250286 }
251287 IWL_EXPORT_SYMBOL(iwl_force_nmi);
252288
....@@ -392,7 +428,7 @@
392428 FH_TSSR_TX_ERROR_REG
393429 };
394430
395
- if (trans->cfg->mq_rx_supported)
431
+ if (trans->trans_cfg->mq_rx_supported)
396432 return iwl_dump_rfh(trans, buf);
397433
398434 #ifdef CONFIG_IWLWIFI_DEBUGFS
....@@ -425,3 +461,43 @@
425461
426462 return 0;
427463 }
464
+
465
+int iwl_finish_nic_init(struct iwl_trans *trans,
466
+ const struct iwl_cfg_trans_params *cfg_trans)
467
+{
468
+ int err;
469
+
470
+ if (cfg_trans->bisr_workaround) {
471
+ /* ensure the TOP FSM isn't still in previous reset */
472
+ mdelay(2);
473
+ }
474
+
475
+ /*
476
+ * Set "initialization complete" bit to move adapter from
477
+ * D0U* --> D0A* (powered-up active) state.
478
+ */
479
+ iwl_set_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
480
+
481
+ if (cfg_trans->device_family == IWL_DEVICE_FAMILY_8000)
482
+ udelay(2);
483
+
484
+ /*
485
+ * Wait for clock stabilization; once stabilized, access to
486
+ * device-internal resources is supported, e.g. iwl_write_prph()
487
+ * and accesses to uCode SRAM.
488
+ */
489
+ err = iwl_poll_bit(trans, CSR_GP_CNTRL,
490
+ CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
491
+ CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
492
+ 25000);
493
+ if (err < 0)
494
+ IWL_DEBUG_INFO(trans, "Failed to wake NIC\n");
495
+
496
+ if (cfg_trans->bisr_workaround) {
497
+ /* ensure BISR shift has finished */
498
+ udelay(200);
499
+ }
500
+
501
+ return err < 0 ? err : 0;
502
+}
503
+IWL_EXPORT_SYMBOL(iwl_finish_nic_init);