2 * This file is part of wl12xx
4 * Copyright (C) 2009-2010 Nokia Corporation
5 * Copyright (C) 2011 Texas Instruments Inc.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 #include "../wlcore/cmd.h"
24 #include "../wlcore/debug.h"
29 int wl1271_cmd_ext_radio_parms(struct wl1271 *wl)
31 struct wl1271_ext_radio_parms_cmd *ext_radio_parms;
32 struct wl12xx_priv *priv = wl->priv;
33 struct wl12xx_conf_rf *rf = &priv->conf.rf;
39 ext_radio_parms = kzalloc(sizeof(*ext_radio_parms), GFP_KERNEL);
43 ext_radio_parms->test.id = TEST_CMD_INI_FILE_RF_EXTENDED_PARAM;
45 memcpy(ext_radio_parms->tx_per_channel_power_compensation_2,
46 rf->tx_per_channel_power_compensation_2,
47 CONF_TX_PWR_COMPENSATION_LEN_2);
48 memcpy(ext_radio_parms->tx_per_channel_power_compensation_5,
49 rf->tx_per_channel_power_compensation_5,
50 CONF_TX_PWR_COMPENSATION_LEN_5);
52 wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_EXT_RADIO_PARAM: ",
53 ext_radio_parms, sizeof(*ext_radio_parms));
55 ret = wl1271_cmd_test(wl, ext_radio_parms, sizeof(*ext_radio_parms), 0);
57 wl1271_warning("TEST_CMD_INI_FILE_RF_EXTENDED_PARAM failed");
59 kfree(ext_radio_parms);
63 int wl1271_cmd_general_parms(struct wl1271 *wl)
65 struct wl1271_general_parms_cmd *gen_parms;
66 struct wl1271_ini_general_params *gp =
67 &((struct wl1271_nvs_file *)wl->nvs)->general_params;
74 if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
75 wl1271_warning("FEM index from INI out of bounds");
79 gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL);
83 gen_parms->test.id = TEST_CMD_INI_FILE_GENERAL_PARAM;
85 memcpy(&gen_parms->general_params, gp, sizeof(*gp));
87 if (gp->tx_bip_fem_auto_detect)
90 /* Override the REF CLK from the NVS with the one from platform data */
91 gen_parms->general_params.ref_clock = wl->ref_clock;
93 ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), answer);
95 wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
99 gp->tx_bip_fem_manufacturer =
100 gen_parms->general_params.tx_bip_fem_manufacturer;
102 if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
103 wl1271_warning("FEM index from FW out of bounds");
108 wl1271_debug(DEBUG_CMD, "FEM autodetect: %s, manufacturer: %d\n",
109 answer ? "auto" : "manual", gp->tx_bip_fem_manufacturer);
116 int wl128x_cmd_general_parms(struct wl1271 *wl)
118 struct wl128x_general_parms_cmd *gen_parms;
119 struct wl128x_ini_general_params *gp =
120 &((struct wl128x_nvs_file *)wl->nvs)->general_params;
127 if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
128 wl1271_warning("FEM index from ini out of bounds");
132 gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL);
136 gen_parms->test.id = TEST_CMD_INI_FILE_GENERAL_PARAM;
138 memcpy(&gen_parms->general_params, gp, sizeof(*gp));
140 if (gp->tx_bip_fem_auto_detect)
143 /* Replace REF and TCXO CLKs with the ones from platform data */
144 gen_parms->general_params.ref_clock = wl->ref_clock;
145 gen_parms->general_params.tcxo_ref_clock = wl->tcxo_clock;
147 ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), answer);
149 wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
153 gp->tx_bip_fem_manufacturer =
154 gen_parms->general_params.tx_bip_fem_manufacturer;
156 if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
157 wl1271_warning("FEM index from FW out of bounds");
162 wl1271_debug(DEBUG_CMD, "FEM autodetect: %s, manufacturer: %d\n",
163 answer ? "auto" : "manual", gp->tx_bip_fem_manufacturer);
170 int wl1271_cmd_radio_parms(struct wl1271 *wl)
172 struct wl1271_nvs_file *nvs = (struct wl1271_nvs_file *)wl->nvs;
173 struct wl1271_radio_parms_cmd *radio_parms;
174 struct wl1271_ini_general_params *gp = &nvs->general_params;
180 radio_parms = kzalloc(sizeof(*radio_parms), GFP_KERNEL);
184 radio_parms->test.id = TEST_CMD_INI_FILE_RADIO_PARAM;
186 /* 2.4GHz parameters */
187 memcpy(&radio_parms->static_params_2, &nvs->stat_radio_params_2,
188 sizeof(struct wl1271_ini_band_params_2));
189 memcpy(&radio_parms->dyn_params_2,
190 &nvs->dyn_radio_params_2[gp->tx_bip_fem_manufacturer].params,
191 sizeof(struct wl1271_ini_fem_params_2));
193 /* 5GHz parameters */
194 memcpy(&radio_parms->static_params_5,
195 &nvs->stat_radio_params_5,
196 sizeof(struct wl1271_ini_band_params_5));
197 memcpy(&radio_parms->dyn_params_5,
198 &nvs->dyn_radio_params_5[gp->tx_bip_fem_manufacturer].params,
199 sizeof(struct wl1271_ini_fem_params_5));
201 wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_RADIO_PARAM: ",
202 radio_parms, sizeof(*radio_parms));
204 ret = wl1271_cmd_test(wl, radio_parms, sizeof(*radio_parms), 0);
206 wl1271_warning("CMD_INI_FILE_RADIO_PARAM failed");
212 int wl128x_cmd_radio_parms(struct wl1271 *wl)
214 struct wl128x_nvs_file *nvs = (struct wl128x_nvs_file *)wl->nvs;
215 struct wl128x_radio_parms_cmd *radio_parms;
216 struct wl128x_ini_general_params *gp = &nvs->general_params;
222 radio_parms = kzalloc(sizeof(*radio_parms), GFP_KERNEL);
226 radio_parms->test.id = TEST_CMD_INI_FILE_RADIO_PARAM;
228 /* 2.4GHz parameters */
229 memcpy(&radio_parms->static_params_2, &nvs->stat_radio_params_2,
230 sizeof(struct wl128x_ini_band_params_2));
231 memcpy(&radio_parms->dyn_params_2,
232 &nvs->dyn_radio_params_2[gp->tx_bip_fem_manufacturer].params,
233 sizeof(struct wl128x_ini_fem_params_2));
235 /* 5GHz parameters */
236 memcpy(&radio_parms->static_params_5,
237 &nvs->stat_radio_params_5,
238 sizeof(struct wl128x_ini_band_params_5));
239 memcpy(&radio_parms->dyn_params_5,
240 &nvs->dyn_radio_params_5[gp->tx_bip_fem_manufacturer].params,
241 sizeof(struct wl128x_ini_fem_params_5));
243 radio_parms->fem_vendor_and_options = nvs->fem_vendor_and_options;
245 wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_RADIO_PARAM: ",
246 radio_parms, sizeof(*radio_parms));
248 ret = wl1271_cmd_test(wl, radio_parms, sizeof(*radio_parms), 0);
250 wl1271_warning("CMD_INI_FILE_RADIO_PARAM failed");