aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ti/wl12xx
diff options
context:
space:
mode:
authorLuciano Coelho <coelho@ti.com>2011-12-01 17:47:45 -0500
committerLuciano Coelho <coelho@ti.com>2012-04-12 01:44:00 -0400
commit9d68d1eea7fb4d05b5bd037da6a66329d640b2f1 (patch)
treed60942724706a9e74f05280f068b52be66b5044e /drivers/net/wireless/ti/wl12xx
parentf83985bb5f8f0f25d44ab7b108a709a52aa1c5e0 (diff)
wlcore/wl12xx: add hw_init operation
Move all the wl12xx-specific hw initialization procedures into a new hw_init op. Move some commands and ACX functions to wl12xx. Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers/net/wireless/ti/wl12xx')
-rw-r--r--drivers/net/wireless/ti/wl12xx/Makefile2
-rw-r--r--drivers/net/wireless/ti/wl12xx/acx.c53
-rw-r--r--drivers/net/wireless/ti/wl12xx/acx.h36
-rw-r--r--drivers/net/wireless/ti/wl12xx/cmd.c252
-rw-r--r--drivers/net/wireless/ti/wl12xx/cmd.h110
-rw-r--r--drivers/net/wireless/ti/wl12xx/main.c40
6 files changed, 492 insertions, 1 deletions
diff --git a/drivers/net/wireless/ti/wl12xx/Makefile b/drivers/net/wireless/ti/wl12xx/Makefile
index 1df22d55943e..87f64b14db35 100644
--- a/drivers/net/wireless/ti/wl12xx/Makefile
+++ b/drivers/net/wireless/ti/wl12xx/Makefile
@@ -1,3 +1,3 @@
1wl12xx-objs = main.o 1wl12xx-objs = main.o cmd.o acx.o
2 2
3obj-$(CONFIG_WL12XX) += wl12xx.o 3obj-$(CONFIG_WL12XX) += wl12xx.o
diff --git a/drivers/net/wireless/ti/wl12xx/acx.c b/drivers/net/wireless/ti/wl12xx/acx.c
new file mode 100644
index 000000000000..bea06b2d7bf4
--- /dev/null
+++ b/drivers/net/wireless/ti/wl12xx/acx.c
@@ -0,0 +1,53 @@
1/*
2 * This file is part of wl12xx
3 *
4 * Copyright (C) 2008-2009 Nokia Corporation
5 * Copyright (C) 2011 Texas Instruments Inc.
6 *
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.
10 *
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.
15 *
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
19 * 02110-1301 USA
20 *
21 */
22
23#include "../wlcore/cmd.h"
24#include "../wlcore/debug.h"
25#include "../wlcore/acx.h"
26
27#include "acx.h"
28
29int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap)
30{
31 struct wl1271_acx_host_config_bitmap *bitmap_conf;
32 int ret;
33
34 bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
35 if (!bitmap_conf) {
36 ret = -ENOMEM;
37 goto out;
38 }
39
40 bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
41
42 ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
43 bitmap_conf, sizeof(*bitmap_conf));
44 if (ret < 0) {
45 wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
46 goto out;
47 }
48
49out:
50 kfree(bitmap_conf);
51
52 return ret;
53}
diff --git a/drivers/net/wireless/ti/wl12xx/acx.h b/drivers/net/wireless/ti/wl12xx/acx.h
new file mode 100644
index 000000000000..d1f5aba0afce
--- /dev/null
+++ b/drivers/net/wireless/ti/wl12xx/acx.h
@@ -0,0 +1,36 @@
1/*
2 * This file is part of wl12xx
3 *
4 * Copyright (C) 1998-2009, 2011 Texas Instruments. All rights reserved.
5 * Copyright (C) 2008-2010 Nokia Corporation
6 *
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.
10 *
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.
15 *
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
19 * 02110-1301 USA
20 *
21 */
22
23#ifndef __WL12XX_ACX_H__
24#define __WL12XX_ACX_H__
25
26#include "../wlcore/wlcore.h"
27
28struct wl1271_acx_host_config_bitmap {
29 struct acx_header header;
30
31 __le32 host_cfg_bitmap;
32} __packed;
33
34int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap);
35
36#endif /* __WL12XX_ACX_H__ */
diff --git a/drivers/net/wireless/ti/wl12xx/cmd.c b/drivers/net/wireless/ti/wl12xx/cmd.c
new file mode 100644
index 000000000000..e46512d185a6
--- /dev/null
+++ b/drivers/net/wireless/ti/wl12xx/cmd.c
@@ -0,0 +1,252 @@
1/*
2 * This file is part of wl12xx
3 *
4 * Copyright (C) 2009-2010 Nokia Corporation
5 * Copyright (C) 2011 Texas Instruments Inc.
6 *
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.
10 *
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.
15 *
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
19 * 02110-1301 USA
20 *
21 */
22
23#include "../wlcore/cmd.h"
24#include "../wlcore/debug.h"
25
26#include "cmd.h"
27
28int wl1271_cmd_ext_radio_parms(struct wl1271 *wl)
29{
30 struct wl1271_ext_radio_parms_cmd *ext_radio_parms;
31 struct conf_rf_settings *rf = &wl->conf.rf;
32 int ret;
33
34 if (!wl->nvs)
35 return -ENODEV;
36
37 ext_radio_parms = kzalloc(sizeof(*ext_radio_parms), GFP_KERNEL);
38 if (!ext_radio_parms)
39 return -ENOMEM;
40
41 ext_radio_parms->test.id = TEST_CMD_INI_FILE_RF_EXTENDED_PARAM;
42
43 memcpy(ext_radio_parms->tx_per_channel_power_compensation_2,
44 rf->tx_per_channel_power_compensation_2,
45 CONF_TX_PWR_COMPENSATION_LEN_2);
46 memcpy(ext_radio_parms->tx_per_channel_power_compensation_5,
47 rf->tx_per_channel_power_compensation_5,
48 CONF_TX_PWR_COMPENSATION_LEN_5);
49
50 wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_EXT_RADIO_PARAM: ",
51 ext_radio_parms, sizeof(*ext_radio_parms));
52
53 ret = wl1271_cmd_test(wl, ext_radio_parms, sizeof(*ext_radio_parms), 0);
54 if (ret < 0)
55 wl1271_warning("TEST_CMD_INI_FILE_RF_EXTENDED_PARAM failed");
56
57 kfree(ext_radio_parms);
58 return ret;
59}
60
61int wl1271_cmd_general_parms(struct wl1271 *wl)
62{
63 struct wl1271_general_parms_cmd *gen_parms;
64 struct wl1271_ini_general_params *gp =
65 &((struct wl1271_nvs_file *)wl->nvs)->general_params;
66 bool answer = false;
67 int ret;
68
69 if (!wl->nvs)
70 return -ENODEV;
71
72 if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
73 wl1271_warning("FEM index from INI out of bounds");
74 return -EINVAL;
75 }
76
77 gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL);
78 if (!gen_parms)
79 return -ENOMEM;
80
81 gen_parms->test.id = TEST_CMD_INI_FILE_GENERAL_PARAM;
82
83 memcpy(&gen_parms->general_params, gp, sizeof(*gp));
84
85 if (gp->tx_bip_fem_auto_detect)
86 answer = true;
87
88 /* Override the REF CLK from the NVS with the one from platform data */
89 gen_parms->general_params.ref_clock = wl->ref_clock;
90
91 ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), answer);
92 if (ret < 0) {
93 wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
94 goto out;
95 }
96
97 gp->tx_bip_fem_manufacturer =
98 gen_parms->general_params.tx_bip_fem_manufacturer;
99
100 if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
101 wl1271_warning("FEM index from FW out of bounds");
102 ret = -EINVAL;
103 goto out;
104 }
105
106 wl1271_debug(DEBUG_CMD, "FEM autodetect: %s, manufacturer: %d\n",
107 answer ? "auto" : "manual", gp->tx_bip_fem_manufacturer);
108
109out:
110 kfree(gen_parms);
111 return ret;
112}
113
114int wl128x_cmd_general_parms(struct wl1271 *wl)
115{
116 struct wl128x_general_parms_cmd *gen_parms;
117 struct wl128x_ini_general_params *gp =
118 &((struct wl128x_nvs_file *)wl->nvs)->general_params;
119 bool answer = false;
120 int ret;
121
122 if (!wl->nvs)
123 return -ENODEV;
124
125 if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
126 wl1271_warning("FEM index from ini out of bounds");
127 return -EINVAL;
128 }
129
130 gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL);
131 if (!gen_parms)
132 return -ENOMEM;
133
134 gen_parms->test.id = TEST_CMD_INI_FILE_GENERAL_PARAM;
135
136 memcpy(&gen_parms->general_params, gp, sizeof(*gp));
137
138 if (gp->tx_bip_fem_auto_detect)
139 answer = true;
140
141 /* Replace REF and TCXO CLKs with the ones from platform data */
142 gen_parms->general_params.ref_clock = wl->ref_clock;
143 gen_parms->general_params.tcxo_ref_clock = wl->tcxo_clock;
144
145 ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), answer);
146 if (ret < 0) {
147 wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
148 goto out;
149 }
150
151 gp->tx_bip_fem_manufacturer =
152 gen_parms->general_params.tx_bip_fem_manufacturer;
153
154 if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) {
155 wl1271_warning("FEM index from FW out of bounds");
156 ret = -EINVAL;
157 goto out;
158 }
159
160 wl1271_debug(DEBUG_CMD, "FEM autodetect: %s, manufacturer: %d\n",
161 answer ? "auto" : "manual", gp->tx_bip_fem_manufacturer);
162
163out:
164 kfree(gen_parms);
165 return ret;
166}
167
168int wl1271_cmd_radio_parms(struct wl1271 *wl)
169{
170 struct wl1271_nvs_file *nvs = (struct wl1271_nvs_file *)wl->nvs;
171 struct wl1271_radio_parms_cmd *radio_parms;
172 struct wl1271_ini_general_params *gp = &nvs->general_params;
173 int ret;
174
175 if (!wl->nvs)
176 return -ENODEV;
177
178 radio_parms = kzalloc(sizeof(*radio_parms), GFP_KERNEL);
179 if (!radio_parms)
180 return -ENOMEM;
181
182 radio_parms->test.id = TEST_CMD_INI_FILE_RADIO_PARAM;
183
184 /* 2.4GHz parameters */
185 memcpy(&radio_parms->static_params_2, &nvs->stat_radio_params_2,
186 sizeof(struct wl1271_ini_band_params_2));
187 memcpy(&radio_parms->dyn_params_2,
188 &nvs->dyn_radio_params_2[gp->tx_bip_fem_manufacturer].params,
189 sizeof(struct wl1271_ini_fem_params_2));
190
191 /* 5GHz parameters */
192 memcpy(&radio_parms->static_params_5,
193 &nvs->stat_radio_params_5,
194 sizeof(struct wl1271_ini_band_params_5));
195 memcpy(&radio_parms->dyn_params_5,
196 &nvs->dyn_radio_params_5[gp->tx_bip_fem_manufacturer].params,
197 sizeof(struct wl1271_ini_fem_params_5));
198
199 wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_RADIO_PARAM: ",
200 radio_parms, sizeof(*radio_parms));
201
202 ret = wl1271_cmd_test(wl, radio_parms, sizeof(*radio_parms), 0);
203 if (ret < 0)
204 wl1271_warning("CMD_INI_FILE_RADIO_PARAM failed");
205
206 kfree(radio_parms);
207 return ret;
208}
209
210int wl128x_cmd_radio_parms(struct wl1271 *wl)
211{
212 struct wl128x_nvs_file *nvs = (struct wl128x_nvs_file *)wl->nvs;
213 struct wl128x_radio_parms_cmd *radio_parms;
214 struct wl128x_ini_general_params *gp = &nvs->general_params;
215 int ret;
216
217 if (!wl->nvs)
218 return -ENODEV;
219
220 radio_parms = kzalloc(sizeof(*radio_parms), GFP_KERNEL);
221 if (!radio_parms)
222 return -ENOMEM;
223
224 radio_parms->test.id = TEST_CMD_INI_FILE_RADIO_PARAM;
225
226 /* 2.4GHz parameters */
227 memcpy(&radio_parms->static_params_2, &nvs->stat_radio_params_2,
228 sizeof(struct wl128x_ini_band_params_2));
229 memcpy(&radio_parms->dyn_params_2,
230 &nvs->dyn_radio_params_2[gp->tx_bip_fem_manufacturer].params,
231 sizeof(struct wl128x_ini_fem_params_2));
232
233 /* 5GHz parameters */
234 memcpy(&radio_parms->static_params_5,
235 &nvs->stat_radio_params_5,
236 sizeof(struct wl128x_ini_band_params_5));
237 memcpy(&radio_parms->dyn_params_5,
238 &nvs->dyn_radio_params_5[gp->tx_bip_fem_manufacturer].params,
239 sizeof(struct wl128x_ini_fem_params_5));
240
241 radio_parms->fem_vendor_and_options = nvs->fem_vendor_and_options;
242
243 wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_RADIO_PARAM: ",
244 radio_parms, sizeof(*radio_parms));
245
246 ret = wl1271_cmd_test(wl, radio_parms, sizeof(*radio_parms), 0);
247 if (ret < 0)
248 wl1271_warning("CMD_INI_FILE_RADIO_PARAM failed");
249
250 kfree(radio_parms);
251 return ret;
252}
diff --git a/drivers/net/wireless/ti/wl12xx/cmd.h b/drivers/net/wireless/ti/wl12xx/cmd.h
new file mode 100644
index 000000000000..ff458302ab04
--- /dev/null
+++ b/drivers/net/wireless/ti/wl12xx/cmd.h
@@ -0,0 +1,110 @@
1/*
2 * This file is part of wl12xx
3 *
4 * Copyright (C) 1998-2009, 2011 Texas Instruments. All rights reserved.
5 * Copyright (C) 2009 Nokia Corporation
6 *
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.
10 *
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.
15 *
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
19 * 02110-1301 USA
20 *
21 */
22
23#ifndef __WL12XX_CMD_H__
24#define __WL12XX_CMD_H__
25
26#define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
27#define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
28
29struct wl1271_general_parms_cmd {
30 struct wl1271_cmd_header header;
31
32 struct wl1271_cmd_test_header test;
33
34 struct wl1271_ini_general_params general_params;
35
36 u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
37 u8 sr_sen_n_p;
38 u8 sr_sen_n_p_gain;
39 u8 sr_sen_nrn;
40 u8 sr_sen_prn;
41 u8 padding[3];
42} __packed;
43
44struct wl128x_general_parms_cmd {
45 struct wl1271_cmd_header header;
46
47 struct wl1271_cmd_test_header test;
48
49 struct wl128x_ini_general_params general_params;
50
51 u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
52 u8 sr_sen_n_p;
53 u8 sr_sen_n_p_gain;
54 u8 sr_sen_nrn;
55 u8 sr_sen_prn;
56 u8 padding[3];
57} __packed;
58
59struct wl1271_radio_parms_cmd {
60 struct wl1271_cmd_header header;
61
62 struct wl1271_cmd_test_header test;
63
64 /* Static radio parameters */
65 struct wl1271_ini_band_params_2 static_params_2;
66 struct wl1271_ini_band_params_5 static_params_5;
67
68 /* Dynamic radio parameters */
69 struct wl1271_ini_fem_params_2 dyn_params_2;
70 u8 padding2;
71 struct wl1271_ini_fem_params_5 dyn_params_5;
72 u8 padding3[2];
73} __packed;
74
75struct wl128x_radio_parms_cmd {
76 struct wl1271_cmd_header header;
77
78 struct wl1271_cmd_test_header test;
79
80 /* Static radio parameters */
81 struct wl128x_ini_band_params_2 static_params_2;
82 struct wl128x_ini_band_params_5 static_params_5;
83
84 u8 fem_vendor_and_options;
85
86 /* Dynamic radio parameters */
87 struct wl128x_ini_fem_params_2 dyn_params_2;
88 u8 padding2;
89 struct wl128x_ini_fem_params_5 dyn_params_5;
90} __packed;
91
92#define TEST_CMD_INI_FILE_RF_EXTENDED_PARAM 0x26
93
94struct wl1271_ext_radio_parms_cmd {
95 struct wl1271_cmd_header header;
96
97 struct wl1271_cmd_test_header test;
98
99 u8 tx_per_channel_power_compensation_2[CONF_TX_PWR_COMPENSATION_LEN_2];
100 u8 tx_per_channel_power_compensation_5[CONF_TX_PWR_COMPENSATION_LEN_5];
101 u8 padding[3];
102} __packed;
103
104int wl1271_cmd_general_parms(struct wl1271 *wl);
105int wl128x_cmd_general_parms(struct wl1271 *wl);
106int wl1271_cmd_radio_parms(struct wl1271 *wl);
107int wl128x_cmd_radio_parms(struct wl1271 *wl);
108int wl1271_cmd_ext_radio_parms(struct wl1271 *wl);
109
110#endif /* __WL12XX_CMD_H__ */
diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
index 00ecd2ad495a..9b2f40cd58d7 100644
--- a/drivers/net/wireless/ti/wl12xx/main.c
+++ b/drivers/net/wireless/ti/wl12xx/main.c
@@ -36,6 +36,8 @@
36#include "../wlcore/boot.h" 36#include "../wlcore/boot.h"
37 37
38#include "reg.h" 38#include "reg.h"
39#include "cmd.h"
40#include "acx.h"
39 41
40#define WL12XX_TX_HW_BLOCK_SPARE_DEFAULT 1 42#define WL12XX_TX_HW_BLOCK_SPARE_DEFAULT 1
41#define WL12XX_TX_HW_BLOCK_GEM_SPARE 2 43#define WL12XX_TX_HW_BLOCK_GEM_SPARE 2
@@ -800,6 +802,43 @@ static void wl12xx_tx_delayed_compl(struct wl1271 *wl)
800 wl1271_tx_complete(wl); 802 wl1271_tx_complete(wl);
801} 803}
802 804
805static int wl12xx_hw_init(struct wl1271 *wl)
806{
807 int ret;
808
809 if (wl->chip.id == CHIP_ID_1283_PG20) {
810 u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE;
811
812 ret = wl128x_cmd_general_parms(wl);
813 if (ret < 0)
814 goto out;
815 ret = wl128x_cmd_radio_parms(wl);
816 if (ret < 0)
817 goto out;
818
819 if (wl->quirks & WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN)
820 /* Enable SDIO padding */
821 host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
822
823 /* Must be before wl1271_acx_init_mem_config() */
824 ret = wl1271_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap);
825 if (ret < 0)
826 goto out;
827 } else {
828 ret = wl1271_cmd_general_parms(wl);
829 if (ret < 0)
830 goto out;
831 ret = wl1271_cmd_radio_parms(wl);
832 if (ret < 0)
833 goto out;
834 ret = wl1271_cmd_ext_radio_parms(wl);
835 if (ret < 0)
836 goto out;
837 }
838out:
839 return ret;
840}
841
803static bool wl12xx_mac_in_fuse(struct wl1271 *wl) 842static bool wl12xx_mac_in_fuse(struct wl1271 *wl)
804{ 843{
805 bool supported = false; 844 bool supported = false;
@@ -875,6 +914,7 @@ static struct wlcore_ops wl12xx_ops = {
875 .get_rx_packet_len = wl12xx_get_rx_packet_len, 914 .get_rx_packet_len = wl12xx_get_rx_packet_len,
876 .tx_immediate_compl = NULL, 915 .tx_immediate_compl = NULL,
877 .tx_delayed_compl = wl12xx_tx_delayed_compl, 916 .tx_delayed_compl = wl12xx_tx_delayed_compl,
917 .hw_init = wl12xx_hw_init,
878 .get_pg_ver = wl12xx_get_pg_ver, 918 .get_pg_ver = wl12xx_get_pg_ver,
879 .get_mac = wl12xx_get_mac, 919 .get_mac = wl12xx_get_mac,
880}; 920};