blob: df6c60f0fd660426abb85fd7b3c626472238c66a [file] [log] [blame]
Kalle Valo2f01a1f2009-04-29 23:33:31 +03001/*
Kalle Valo80301cd2009-06-12 14:17:39 +03002 * This file is part of wl1251
Kalle Valo2f01a1f2009-04-29 23:33:31 +03003 *
4 * Copyright (C) 2009 Nokia Corporation
5 *
6 * Contact: Kalle Valo <kalle.valo@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#include <linux/kernel.h>
25#include <linux/module.h>
26
Kalle Valoef2f8d42009-06-12 14:17:19 +030027#include "wl1251_init.h"
Kalle Valo2f01a1f2009-04-29 23:33:31 +030028#include "wl12xx_80211.h"
Kalle Valoef2f8d42009-06-12 14:17:19 +030029#include "wl1251_acx.h"
30#include "wl1251_cmd.h"
Kalle Valo2f01a1f2009-04-29 23:33:31 +030031
Kalle Valo80301cd2009-06-12 14:17:39 +030032int wl1251_hw_init_hwenc_config(struct wl1251 *wl)
Kalle Valo2f01a1f2009-04-29 23:33:31 +030033{
34 int ret;
35
Kalle Valo80301cd2009-06-12 14:17:39 +030036 ret = wl1251_acx_feature_cfg(wl);
Kalle Valo2f01a1f2009-04-29 23:33:31 +030037 if (ret < 0) {
Kalle Valo80301cd2009-06-12 14:17:39 +030038 wl1251_warning("couldn't set feature config");
Kalle Valo2f01a1f2009-04-29 23:33:31 +030039 return ret;
40 }
41
Kalle Valo80301cd2009-06-12 14:17:39 +030042 ret = wl1251_acx_default_key(wl, wl->default_key);
Kalle Valo2f01a1f2009-04-29 23:33:31 +030043 if (ret < 0) {
Kalle Valo80301cd2009-06-12 14:17:39 +030044 wl1251_warning("couldn't set default key");
Kalle Valo2f01a1f2009-04-29 23:33:31 +030045 return ret;
46 }
47
48 return 0;
49}
50
Kalle Valo80301cd2009-06-12 14:17:39 +030051int wl1251_hw_init_templates_config(struct wl1251 *wl)
Kalle Valo2f01a1f2009-04-29 23:33:31 +030052{
53 int ret;
54 u8 partial_vbm[PARTIAL_VBM_MAX];
55
56 /* send empty templates for fw memory reservation */
Kalle Valo80301cd2009-06-12 14:17:39 +030057 ret = wl1251_cmd_template_set(wl, CMD_PROBE_REQ, NULL,
Kalle Valo2f01a1f2009-04-29 23:33:31 +030058 sizeof(struct wl12xx_probe_req_template));
59 if (ret < 0)
60 return ret;
61
Kalle Valo80301cd2009-06-12 14:17:39 +030062 ret = wl1251_cmd_template_set(wl, CMD_NULL_DATA, NULL,
Kalle Valo2f01a1f2009-04-29 23:33:31 +030063 sizeof(struct wl12xx_null_data_template));
64 if (ret < 0)
65 return ret;
66
Kalle Valo80301cd2009-06-12 14:17:39 +030067 ret = wl1251_cmd_template_set(wl, CMD_PS_POLL, NULL,
Kalle Valo2f01a1f2009-04-29 23:33:31 +030068 sizeof(struct wl12xx_ps_poll_template));
69 if (ret < 0)
70 return ret;
71
Kalle Valo80301cd2009-06-12 14:17:39 +030072 ret = wl1251_cmd_template_set(wl, CMD_QOS_NULL_DATA, NULL,
Kalle Valo2f01a1f2009-04-29 23:33:31 +030073 sizeof
74 (struct wl12xx_qos_null_data_template));
75 if (ret < 0)
76 return ret;
77
Kalle Valo80301cd2009-06-12 14:17:39 +030078 ret = wl1251_cmd_template_set(wl, CMD_PROBE_RESP, NULL,
Kalle Valo2f01a1f2009-04-29 23:33:31 +030079 sizeof
80 (struct wl12xx_probe_resp_template));
81 if (ret < 0)
82 return ret;
83
Kalle Valo80301cd2009-06-12 14:17:39 +030084 ret = wl1251_cmd_template_set(wl, CMD_BEACON, NULL,
Kalle Valo2f01a1f2009-04-29 23:33:31 +030085 sizeof
86 (struct wl12xx_beacon_template));
87 if (ret < 0)
88 return ret;
89
90 /* tim templates, first reserve space then allocate an empty one */
91 memset(partial_vbm, 0, PARTIAL_VBM_MAX);
Kalle Valo80301cd2009-06-12 14:17:39 +030092 ret = wl1251_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, PARTIAL_VBM_MAX, 0);
Kalle Valo2f01a1f2009-04-29 23:33:31 +030093 if (ret < 0)
94 return ret;
95
Kalle Valo80301cd2009-06-12 14:17:39 +030096 ret = wl1251_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, 1, 0);
Kalle Valo2f01a1f2009-04-29 23:33:31 +030097 if (ret < 0)
98 return ret;
99
100 return 0;
101}
102
Kalle Valo80301cd2009-06-12 14:17:39 +0300103int wl1251_hw_init_rx_config(struct wl1251 *wl, u32 config, u32 filter)
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300104{
105 int ret;
106
Kalle Valo80301cd2009-06-12 14:17:39 +0300107 ret = wl1251_acx_rx_msdu_life_time(wl, RX_MSDU_LIFETIME_DEF);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300108 if (ret < 0)
109 return ret;
110
Kalle Valo80301cd2009-06-12 14:17:39 +0300111 ret = wl1251_acx_rx_config(wl, config, filter);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300112 if (ret < 0)
113 return ret;
114
115 return 0;
116}
117
Kalle Valo80301cd2009-06-12 14:17:39 +0300118int wl1251_hw_init_phy_config(struct wl1251 *wl)
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300119{
120 int ret;
121
Kalle Valo80301cd2009-06-12 14:17:39 +0300122 ret = wl1251_acx_pd_threshold(wl);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300123 if (ret < 0)
124 return ret;
125
Kalle Valo80301cd2009-06-12 14:17:39 +0300126 ret = wl1251_acx_slot(wl, DEFAULT_SLOT_TIME);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300127 if (ret < 0)
128 return ret;
129
Kalle Valo80301cd2009-06-12 14:17:39 +0300130 ret = wl1251_acx_group_address_tbl(wl);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300131 if (ret < 0)
132 return ret;
133
Kalle Valo80301cd2009-06-12 14:17:39 +0300134 ret = wl1251_acx_service_period_timeout(wl);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300135 if (ret < 0)
136 return ret;
137
Kalle Valo80301cd2009-06-12 14:17:39 +0300138 ret = wl1251_acx_rts_threshold(wl, RTS_THRESHOLD_DEF);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300139 if (ret < 0)
140 return ret;
141
142 return 0;
143}
144
Kalle Valo80301cd2009-06-12 14:17:39 +0300145int wl1251_hw_init_beacon_filter(struct wl1251 *wl)
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300146{
147 int ret;
148
Kalle Valo80301cd2009-06-12 14:17:39 +0300149 ret = wl1251_acx_beacon_filter_opt(wl);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300150 if (ret < 0)
151 return ret;
152
Kalle Valo80301cd2009-06-12 14:17:39 +0300153 ret = wl1251_acx_beacon_filter_table(wl);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300154 if (ret < 0)
155 return ret;
156
157 return 0;
158}
159
Kalle Valo80301cd2009-06-12 14:17:39 +0300160int wl1251_hw_init_pta(struct wl1251 *wl)
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300161{
162 int ret;
163
Kalle Valo80301cd2009-06-12 14:17:39 +0300164 ret = wl1251_acx_sg_enable(wl);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300165 if (ret < 0)
166 return ret;
167
Kalle Valo80301cd2009-06-12 14:17:39 +0300168 ret = wl1251_acx_sg_cfg(wl);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300169 if (ret < 0)
170 return ret;
171
172 return 0;
173}
174
Kalle Valo80301cd2009-06-12 14:17:39 +0300175int wl1251_hw_init_energy_detection(struct wl1251 *wl)
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300176{
177 int ret;
178
Kalle Valo80301cd2009-06-12 14:17:39 +0300179 ret = wl1251_acx_cca_threshold(wl);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300180 if (ret < 0)
181 return ret;
182
183 return 0;
184}
185
Kalle Valo80301cd2009-06-12 14:17:39 +0300186int wl1251_hw_init_beacon_broadcast(struct wl1251 *wl)
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300187{
188 int ret;
189
Kalle Valo80301cd2009-06-12 14:17:39 +0300190 ret = wl1251_acx_bcn_dtim_options(wl);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300191 if (ret < 0)
192 return ret;
193
194 return 0;
195}
196
Kalle Valo80301cd2009-06-12 14:17:39 +0300197int wl1251_hw_init_power_auth(struct wl1251 *wl)
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300198{
Kalle Valo80301cd2009-06-12 14:17:39 +0300199 return wl1251_acx_sleep_auth(wl, WL1251_PSM_CAM);
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300200}