hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/wireless/intel/iwlwifi/fw/init.c
....@@ -6,6 +6,7 @@
66 * GPL LICENSE SUMMARY
77 *
88 * Copyright(c) 2017 Intel Deutschland GmbH
9
+ * Copyright(c) 2019 - 2020 Intel Corporation
910 *
1011 * This program is free software; you can redistribute it and/or modify
1112 * it under the terms of version 2 of the GNU General Public License as
....@@ -26,6 +27,7 @@
2627 * BSD LICENSE
2728 *
2829 * Copyright(c) 2017 Intel Deutschland GmbH
30
+ * Copyright(c) 2019 - 2020 Intel Corporation
2931 * All rights reserved.
3032 *
3133 * Redistribution and use in source and binary forms, with or without
....@@ -60,11 +62,16 @@
6062 #include "dbg.h"
6163 #include "debugfs.h"
6264
65
+#include "fw/api/soc.h"
66
+#include "fw/api/commands.h"
67
+
6368 void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans,
6469 const struct iwl_fw *fw,
6570 const struct iwl_fw_runtime_ops *ops, void *ops_ctx,
6671 struct dentry *dbgfs_dir)
6772 {
73
+ int i;
74
+
6875 memset(fwrt, 0, sizeof(*fwrt));
6976 fwrt->trans = trans;
7077 fwrt->fw = fw;
....@@ -72,7 +79,10 @@
7279 fwrt->dump.conf = FW_DBG_INVALID;
7380 fwrt->ops = ops;
7481 fwrt->ops_ctx = ops_ctx;
75
- INIT_DELAYED_WORK(&fwrt->dump.wk, iwl_fw_error_dump_wk);
82
+ for (i = 0; i < IWL_FW_RUNTIME_DUMP_WK_NUM; i++) {
83
+ fwrt->dump.wks[i].idx = i;
84
+ INIT_DELAYED_WORK(&fwrt->dump.wks[i].wk, iwl_fw_error_dump_wk);
85
+ }
7686 iwl_fwrt_dbgfs_register(fwrt, dbgfs_dir);
7787 }
7888 IWL_EXPORT_SYMBOL(iwl_fw_runtime_init);
....@@ -88,3 +98,52 @@
8898 iwl_fw_resume_timestamp(fwrt);
8999 }
90100 IWL_EXPORT_SYMBOL(iwl_fw_runtime_resume);
101
+
102
+/* set device type and latency */
103
+int iwl_set_soc_latency(struct iwl_fw_runtime *fwrt)
104
+{
105
+ struct iwl_soc_configuration_cmd cmd = {};
106
+ struct iwl_host_cmd hcmd = {
107
+ .id = iwl_cmd_id(SOC_CONFIGURATION_CMD, SYSTEM_GROUP, 0),
108
+ .data[0] = &cmd,
109
+ .len[0] = sizeof(cmd),
110
+ };
111
+ int ret;
112
+
113
+ /*
114
+ * In VER_1 of this command, the discrete value is considered
115
+ * an integer; In VER_2, it's a bitmask. Since we have only 2
116
+ * values in VER_1, this is backwards-compatible with VER_2,
117
+ * as long as we don't set any other bits.
118
+ */
119
+ if (!fwrt->trans->trans_cfg->integrated)
120
+ cmd.flags = cpu_to_le32(SOC_CONFIG_CMD_FLAGS_DISCRETE);
121
+
122
+ BUILD_BUG_ON(IWL_CFG_TRANS_LTR_DELAY_NONE !=
123
+ SOC_FLAGS_LTR_APPLY_DELAY_NONE);
124
+ BUILD_BUG_ON(IWL_CFG_TRANS_LTR_DELAY_200US !=
125
+ SOC_FLAGS_LTR_APPLY_DELAY_200);
126
+ BUILD_BUG_ON(IWL_CFG_TRANS_LTR_DELAY_2500US !=
127
+ SOC_FLAGS_LTR_APPLY_DELAY_2500);
128
+ BUILD_BUG_ON(IWL_CFG_TRANS_LTR_DELAY_1820US !=
129
+ SOC_FLAGS_LTR_APPLY_DELAY_1820);
130
+
131
+ if (fwrt->trans->trans_cfg->ltr_delay != IWL_CFG_TRANS_LTR_DELAY_NONE &&
132
+ !WARN_ON(!fwrt->trans->trans_cfg->integrated))
133
+ cmd.flags |= le32_encode_bits(fwrt->trans->trans_cfg->ltr_delay,
134
+ SOC_FLAGS_LTR_APPLY_DELAY_MASK);
135
+
136
+ if (iwl_fw_lookup_cmd_ver(fwrt->fw, IWL_ALWAYS_LONG_GROUP,
137
+ SCAN_REQ_UMAC,
138
+ IWL_FW_CMD_VER_UNKNOWN) >= 2 &&
139
+ fwrt->trans->trans_cfg->low_latency_xtal)
140
+ cmd.flags |= cpu_to_le32(SOC_CONFIG_CMD_FLAGS_LOW_LATENCY);
141
+
142
+ cmd.latency = cpu_to_le32(fwrt->trans->trans_cfg->xtal_latency);
143
+
144
+ ret = iwl_trans_send_cmd(fwrt->trans, &hcmd);
145
+ if (ret)
146
+ IWL_ERR(fwrt, "Failed to set soc latency: %d\n", ret);
147
+ return ret;
148
+}
149
+IWL_EXPORT_SYMBOL(iwl_set_soc_latency);