init.c revision 11eb54298fa7197cb4187f8a3474ead0709f76ff
1f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho/*
2f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * This file is part of wl1271
3f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho *
4f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * Copyright (C) 2009 Nokia Corporation
5f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho *
6f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * Contact: Luciano Coelho <luciano.coelho@nokia.com>
7f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho *
8f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * This program is free software; you can redistribute it and/or
9f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * modify it under the terms of the GNU General Public License
10f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * version 2 as published by the Free Software Foundation.
11f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho *
12f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * This program is distributed in the hope that it will be useful, but
13f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * WITHOUT ANY WARRANTY; without even the implied warranty of
14f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * General Public License for more details.
16f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho *
17f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * You should have received a copy of the GNU General Public License
18f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * along with this program; if not, write to the Free Software
19f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho * 02110-1301 USA
21f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho *
22f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho */
23f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
24f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho#include <linux/kernel.h>
25f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho#include <linux/module.h>
265a0e3ad6af8660be21ca98a971cd00f331318c05Tejun Heo#include <linux/slab.h>
27f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
28f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho#include "wl1271_init.h"
29f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho#include "wl12xx_80211.h"
30f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho#include "wl1271_acx.h"
31f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho#include "wl1271_cmd.h"
32f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho#include "wl1271_reg.h"
33f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
34f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelhostatic int wl1271_init_hwenc_config(struct wl1271 *wl)
35f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho{
36f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	int ret;
37f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
38f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_feature_cfg(wl);
39f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0) {
40f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		wl1271_warning("couldn't set feature config");
41f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
42f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	}
43f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
44f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_cmd_set_default_wep_key(wl, wl->default_key);
45f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0) {
46f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		wl1271_warning("couldn't set default key");
47f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
48f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	}
49f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
50f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	return 0;
51f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho}
52f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
5312419cce88fa591a846a542d35cff43b69d9e271Luciano Coelhoint wl1271_init_templates_config(struct wl1271 *wl)
54f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho{
55bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen	int ret, i;
5611eb54298fa7197cb4187f8a3474ead0709f76ffJuuso Oikarinen	size_t size;
57f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
58f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* send empty templates for fw memory reservation */
59f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL,
60bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen				      sizeof(struct wl12xx_probe_req_template),
61606c1487ac894798121bc2c64d27c1953c5a6210Juuso Oikarinen				      0, WL1271_RATE_AUTOMATIC);
62f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
63f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
64f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
6511eb54298fa7197cb4187f8a3474ead0709f76ffJuuso Oikarinen	size = sizeof(struct wl12xx_probe_req_template);
6611eb54298fa7197cb4187f8a3474ead0709f76ffJuuso Oikarinen	ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
6711eb54298fa7197cb4187f8a3474ead0709f76ffJuuso Oikarinen				      NULL, size, 0,
6811eb54298fa7197cb4187f8a3474ead0709f76ffJuuso Oikarinen				      WL1271_RATE_AUTOMATIC);
6911eb54298fa7197cb4187f8a3474ead0709f76ffJuuso Oikarinen	if (ret < 0)
7011eb54298fa7197cb4187f8a3474ead0709f76ffJuuso Oikarinen		return ret;
71abb0b3bfb2d2411034b721df21c31964265b851eTeemu Paasikivi
72f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
73bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen				      sizeof(struct wl12xx_null_data_template),
74606c1487ac894798121bc2c64d27c1953c5a6210Juuso Oikarinen				      0, WL1271_RATE_AUTOMATIC);
75f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
76f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
77f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
78f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL,
79bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen				      sizeof(struct wl12xx_ps_poll_template),
80606c1487ac894798121bc2c64d27c1953c5a6210Juuso Oikarinen				      0, WL1271_RATE_AUTOMATIC);
81f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
82f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
83f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
84f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
85f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho				      sizeof
86bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen				      (struct wl12xx_qos_null_data_template),
87606c1487ac894798121bc2c64d27c1953c5a6210Juuso Oikarinen				      0, WL1271_RATE_AUTOMATIC);
88f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
89f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
90f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
91f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL,
92f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho				      sizeof
93bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen				      (struct wl12xx_probe_resp_template),
94606c1487ac894798121bc2c64d27c1953c5a6210Juuso Oikarinen				      0, WL1271_RATE_AUTOMATIC);
95f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
96f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
97f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
98f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
99f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho				      sizeof
100bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen				      (struct wl12xx_beacon_template),
101606c1487ac894798121bc2c64d27c1953c5a6210Juuso Oikarinen				      0, WL1271_RATE_AUTOMATIC);
102f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
103f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
104f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
105bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen	for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
106bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen		ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL,
107606c1487ac894798121bc2c64d27c1953c5a6210Juuso Oikarinen					      WL1271_CMD_TEMPL_MAX_SIZE, i,
108606c1487ac894798121bc2c64d27c1953c5a6210Juuso Oikarinen					      WL1271_RATE_AUTOMATIC);
109bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen		if (ret < 0)
110bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen			return ret;
111bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen	}
112bfb24c9e16921f0e57fcec5180ffa20929832545Juuso Oikarinen
113f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	return 0;
114f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho}
115f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
116f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelhostatic int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
117f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho{
118f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	int ret;
119f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
1208793f9bb19c00b26532e37f1f516e1d9c7bc0476Juuso Oikarinen	ret = wl1271_acx_rx_msdu_life_time(wl);
121f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
122f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
123f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
124f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_rx_config(wl, config, filter);
125f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
126f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
127f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
128f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	return 0;
129f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho}
130f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
13112419cce88fa591a846a542d35cff43b69d9e271Luciano Coelhoint wl1271_init_phy_config(struct wl1271 *wl)
132f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho{
133f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	int ret;
134f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
135f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_pd_threshold(wl);
136f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
137f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
138f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
139f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
140f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
141f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
142f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
143c87dec9f189b884df215756e285b9281cf065206Juuso Oikarinen	ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
144f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
145f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
146f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
147f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_service_period_timeout(wl);
148f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
149f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
150f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
1518793f9bb19c00b26532e37f1f516e1d9c7bc0476Juuso Oikarinen	ret = wl1271_acx_rts_threshold(wl, wl->conf.rx.rts_threshold);
152f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
153f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
154f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
155f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	return 0;
156f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho}
157f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
158f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelhostatic int wl1271_init_beacon_filter(struct wl1271 *wl)
159f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho{
160f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	int ret;
161f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
1621922167b9de575d9d1a56be9b80f0fa3b22785f9Juuso Oikarinen	/* disable beacon filtering at this stage */
1631922167b9de575d9d1a56be9b80f0fa3b22785f9Juuso Oikarinen	ret = wl1271_acx_beacon_filter_opt(wl, false);
164f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
165f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
166f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
167f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_beacon_filter_table(wl);
168f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
169f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
170f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
171f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	return 0;
172f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho}
173f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
17412419cce88fa591a846a542d35cff43b69d9e271Luciano Coelhoint wl1271_init_pta(struct wl1271 *wl)
175f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho{
176f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	int ret;
177f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
1781b00f546fc4271d94c1bccb1955ce64d9ace1000Juuso Oikarinen	ret = wl1271_acx_sg_cfg(wl);
179f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
180f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
181f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
1827fc3a8647d2eaa8bc2f7ac7e9baff55199da7be6Juuso Oikarinen	ret = wl1271_acx_sg_enable(wl, wl->sg_enabled);
183f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
184f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
185f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
186f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	return 0;
187f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho}
188f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
18912419cce88fa591a846a542d35cff43b69d9e271Luciano Coelhoint wl1271_init_energy_detection(struct wl1271 *wl)
190f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho{
191f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	int ret;
192f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
193f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_cca_threshold(wl);
194f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
195f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
196f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
197f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	return 0;
198f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho}
199f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
200f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelhostatic int wl1271_init_beacon_broadcast(struct wl1271 *wl)
201f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho{
202f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	int ret;
203f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
204f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_bcn_dtim_options(wl);
205f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
206f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
207f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
208f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	return 0;
209f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho}
210f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
211f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelhoint wl1271_hw_init(struct wl1271 *wl)
212f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho{
213243eeb51eaa0a33caeff3e2275b2460eea5579ecKalle Valo	struct conf_tx_ac_category *conf_ac;
214f2054df5170734eacd1db82138c70746ec8387deKalle Valo	struct conf_tx_tid *conf_tid;
215243eeb51eaa0a33caeff3e2275b2460eea5579ecKalle Valo	int ret, i;
216f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
21798b5dd5ded8cb59b598b2c0c396100054779eda7Luciano Coelho	ret = wl1271_cmd_general_parms(wl);
2184a90406b876cade9bb8d9c95b048d60fb979ba6bLuciano Coelho	if (ret < 0)
219f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
220f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
22198b5dd5ded8cb59b598b2c0c396100054779eda7Luciano Coelho	ret = wl1271_cmd_radio_parms(wl);
2224a90406b876cade9bb8d9c95b048d60fb979ba6bLuciano Coelho	if (ret < 0)
223f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
224f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
225f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Template settings */
226f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_init_templates_config(wl);
227f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
228f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
229f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
230f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Default memory configuration */
231f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_init_mem_config(wl);
232f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
233f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		return ret;
234f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
235f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* RX config */
236f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_init_rx_config(wl,
237eb5b28d021a1b96050f7af46e9140eb0051cc6d8Juuso Oikarinen				    RX_CFG_PROMISCUOUS | RX_CFG_TSF,
238eb5b28d021a1b96050f7af46e9140eb0051cc6d8Juuso Oikarinen				    RX_FILTER_OPTION_DEF);
239f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
240f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	   RX_FILTER_OPTION_FILTER_ALL); */
241f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
242f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
243f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
244f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* PHY layer config */
245f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_init_phy_config(wl);
246f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
247f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
248f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
2496e92b416b0aa6a59629cc32ee2b27129d73b98b8Luciano Coelho	ret = wl1271_acx_dco_itrim_params(wl);
2506e92b416b0aa6a59629cc32ee2b27129d73b98b8Luciano Coelho	if (ret < 0)
2516e92b416b0aa6a59629cc32ee2b27129d73b98b8Luciano Coelho		goto out_free_memmap;
2526e92b416b0aa6a59629cc32ee2b27129d73b98b8Luciano Coelho
253344152361e6d14ade61d7f43678db7418cb445dbJuuso Oikarinen	/* Initialize connection monitoring thresholds */
2546ccbb92ead9379d7de2cc25cd950d15a8d22e0c9Juuso Oikarinen	ret = wl1271_acx_conn_monit_params(wl, false);
255344152361e6d14ade61d7f43678db7418cb445dbJuuso Oikarinen	if (ret < 0)
256344152361e6d14ade61d7f43678db7418cb445dbJuuso Oikarinen		goto out_free_memmap;
257344152361e6d14ade61d7f43678db7418cb445dbJuuso Oikarinen
258f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Beacon filtering */
259f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_init_beacon_filter(wl);
260f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
261f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
262f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
263f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Configure TX patch complete interrupt behavior */
264f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_tx_config_options(wl);
265f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
266f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
267f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
268f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* RX complete interrupt pacing */
269f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_init_rx_interrupt(wl);
270f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
271f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
272f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
273f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Bluetooth WLAN coexistence */
274f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_init_pta(wl);
275f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
276f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
277f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
278f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Energy detection */
279f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_init_energy_detection(wl);
280f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
281f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
282f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
283f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Beacons and boradcast settings */
284f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_init_beacon_broadcast(wl);
285f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
286f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
287f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
288f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Default fragmentation threshold */
289f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_frag_threshold(wl);
290f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
291f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
292f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
293f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Default TID configuration */
294f2054df5170734eacd1db82138c70746ec8387deKalle Valo	for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
295f2054df5170734eacd1db82138c70746ec8387deKalle Valo		conf_tid = &wl->conf.tx.tid_conf[i];
296f2054df5170734eacd1db82138c70746ec8387deKalle Valo		ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
297f2054df5170734eacd1db82138c70746ec8387deKalle Valo					 conf_tid->channel_type,
298f2054df5170734eacd1db82138c70746ec8387deKalle Valo					 conf_tid->tsid,
299f2054df5170734eacd1db82138c70746ec8387deKalle Valo					 conf_tid->ps_scheme,
300f2054df5170734eacd1db82138c70746ec8387deKalle Valo					 conf_tid->ack_policy,
301f2054df5170734eacd1db82138c70746ec8387deKalle Valo					 conf_tid->apsd_conf[0],
302f2054df5170734eacd1db82138c70746ec8387deKalle Valo					 conf_tid->apsd_conf[1]);
303f2054df5170734eacd1db82138c70746ec8387deKalle Valo		if (ret < 0)
304f2054df5170734eacd1db82138c70746ec8387deKalle Valo			goto out_free_memmap;
305f2054df5170734eacd1db82138c70746ec8387deKalle Valo	}
306f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
307f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Default AC configuration */
308243eeb51eaa0a33caeff3e2275b2460eea5579ecKalle Valo	for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
309243eeb51eaa0a33caeff3e2275b2460eea5579ecKalle Valo		conf_ac = &wl->conf.tx.ac_conf[i];
310243eeb51eaa0a33caeff3e2275b2460eea5579ecKalle Valo		ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
311243eeb51eaa0a33caeff3e2275b2460eea5579ecKalle Valo					conf_ac->cw_max, conf_ac->aifsn,
312243eeb51eaa0a33caeff3e2275b2460eea5579ecKalle Valo					conf_ac->tx_op_limit);
313243eeb51eaa0a33caeff3e2275b2460eea5579ecKalle Valo		if (ret < 0)
314243eeb51eaa0a33caeff3e2275b2460eea5579ecKalle Valo			goto out_free_memmap;
315243eeb51eaa0a33caeff3e2275b2460eea5579ecKalle Valo	}
316f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
317f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Configure TX rate classes */
318830fb67b8e37fb03cf703b4e1217fe30ce32d579Juuso Oikarinen	ret = wl1271_acx_rate_policies(wl);
319f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
320f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
321f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
322f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Enable data path */
32394210897e2b7df8446fdecd360342149e5b4a400Luciano Coelho	ret = wl1271_cmd_data_path(wl, 1);
324f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
325f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
326f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
327f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Configure for ELP power saving */
328f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
329f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
330f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
331f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
332f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	/* Configure HW encryption */
333f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	ret = wl1271_init_hwenc_config(wl);
334f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	if (ret < 0)
335f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho		goto out_free_memmap;
336f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
33738ad2d87d42ba847c100ef132e8e363513982c8bJuuso Oikarinen	/* configure PM */
33838ad2d87d42ba847c100ef132e8e363513982c8bJuuso Oikarinen	ret = wl1271_acx_pm_config(wl);
33938ad2d87d42ba847c100ef132e8e363513982c8bJuuso Oikarinen	if (ret < 0)
34038ad2d87d42ba847c100ef132e8e363513982c8bJuuso Oikarinen		goto out_free_memmap;
34138ad2d87d42ba847c100ef132e8e363513982c8bJuuso Oikarinen
342c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen	/* disable all keep-alive templates */
343c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen	for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
344c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen		ret = wl1271_acx_keep_alive_config(wl, i,
345c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen						   ACX_KEEP_ALIVE_TPL_INVALID);
346c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen		if (ret < 0)
347c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen			goto out_free_memmap;
348c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen	}
349c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen
350c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen	/* disable the keep-alive feature */
351c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen	ret = wl1271_acx_keep_alive_mode(wl, false);
352c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen	if (ret < 0)
353c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen		goto out_free_memmap;
354c18995540cc4d2c84d130581b8b6720b22ca16b5Juuso Oikarinen
35500236aedf1d2c49a18ae9ea00698d97705ff7289Juuso Oikarinen	/* Configure rssi/snr averaging weights */
35600236aedf1d2c49a18ae9ea00698d97705ff7289Juuso Oikarinen	ret = wl1271_acx_rssi_snr_avg_weights(wl);
35700236aedf1d2c49a18ae9ea00698d97705ff7289Juuso Oikarinen	if (ret < 0)
35800236aedf1d2c49a18ae9ea00698d97705ff7289Juuso Oikarinen		goto out_free_memmap;
35900236aedf1d2c49a18ae9ea00698d97705ff7289Juuso Oikarinen
360f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	return 0;
361f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
362f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho out_free_memmap:
363f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	kfree(wl->target_mem_map);
364344152361e6d14ade61d7f43678db7418cb445dbJuuso Oikarinen	wl->target_mem_map = NULL;
365f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho
366f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho	return ret;
367f5fc0f86b02afef1119b523623b4cde41475bc8cLuciano Coelho}
368