blob: 18cf01719ae0d0def752f9a039bb4f82f0bf699a [file] [log] [blame]
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001/*
2 * This file is part of wl1271
3 *
4 * Copyright (C) 2008-2009 Nokia Corporation
5 *
6 * Contact: Luciano Coelho <luciano.coelho@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
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +020024#include <linux/irq.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030025#include <linux/module.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030026#include <linux/crc7.h>
27#include <linux/spi/spi.h>
Ohad Ben-Cohenc1f9a092010-09-16 13:16:02 +020028#include <linux/wl12xx.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090029#include <linux/slab.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030030
Shahar Levi00d20102010-11-08 11:20:10 +000031#include "wl12xx.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030032#include "wl12xx_80211.h"
Shahar Levi00d20102010-11-08 11:20:10 +000033#include "io.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030034
Shahar Levi00d20102010-11-08 11:20:10 +000035#include "reg.h"
Teemu Paasikivi760d9692010-02-22 08:38:25 +020036
37#define WSPI_CMD_READ 0x40000000
38#define WSPI_CMD_WRITE 0x00000000
39#define WSPI_CMD_FIXED 0x20000000
40#define WSPI_CMD_BYTE_LENGTH 0x1FFE0000
41#define WSPI_CMD_BYTE_LENGTH_OFFSET 17
42#define WSPI_CMD_BYTE_ADDR 0x0001FFFF
43
44#define WSPI_INIT_CMD_CRC_LEN 5
45
46#define WSPI_INIT_CMD_START 0x00
47#define WSPI_INIT_CMD_TX 0x40
48/* the extra bypass bit is sampled by the TNET as '1' */
49#define WSPI_INIT_CMD_BYPASS_BIT 0x80
50#define WSPI_INIT_CMD_FIXEDBUSY_LEN 0x07
51#define WSPI_INIT_CMD_EN_FIXEDBUSY 0x80
52#define WSPI_INIT_CMD_DIS_FIXEDBUSY 0x00
53#define WSPI_INIT_CMD_IOD 0x40
54#define WSPI_INIT_CMD_IP 0x20
55#define WSPI_INIT_CMD_CS 0x10
56#define WSPI_INIT_CMD_WS 0x08
57#define WSPI_INIT_CMD_WSPI 0x01
58#define WSPI_INIT_CMD_END 0x01
59
60#define WSPI_INIT_CMD_LEN 8
61
62#define HW_ACCESS_WSPI_FIXED_BUSY_LEN \
63 ((WL1271_BUSY_WORD_LEN - 4) / sizeof(u32))
64#define HW_ACCESS_WSPI_INIT_CMD_MASK 0
65
Ido Yariv5c57a902010-09-30 13:28:26 +020066/* HW limitation: maximum possible chunk size is 4095 bytes */
67#define WSPI_MAX_CHUNK_SIZE 4092
68
69#define WSPI_MAX_NUM_OF_CHUNKS (WL1271_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE)
70
Teemu Paasikivib42f91b2010-02-22 08:38:24 +020071static inline struct spi_device *wl_to_spi(struct wl1271 *wl)
Teemu Paasikivi8197b712010-02-22 08:38:23 +020072{
73 return wl->if_priv;
74}
75
76static struct device *wl1271_spi_wl_to_dev(struct wl1271 *wl)
77{
78 return &(wl_to_spi(wl)->dev);
79}
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030080
Teemu Paasikivi760d9692010-02-22 08:38:25 +020081static void wl1271_spi_disable_interrupts(struct wl1271 *wl)
Teemu Paasikivi54f7e502010-02-22 08:38:22 +020082{
83 disable_irq(wl->irq);
84}
85
Teemu Paasikivi760d9692010-02-22 08:38:25 +020086static void wl1271_spi_enable_interrupts(struct wl1271 *wl)
Teemu Paasikivi54f7e502010-02-22 08:38:22 +020087{
88 enable_irq(wl->irq);
89}
90
Teemu Paasikivi760d9692010-02-22 08:38:25 +020091static void wl1271_spi_reset(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030092{
93 u8 *cmd;
94 struct spi_transfer t;
95 struct spi_message m;
96
97 cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL);
98 if (!cmd) {
99 wl1271_error("could not allocate cmd for spi reset");
100 return;
101 }
102
103 memset(&t, 0, sizeof(t));
104 spi_message_init(&m);
105
106 memset(cmd, 0xff, WSPI_INIT_CMD_LEN);
107
108 t.tx_buf = cmd;
109 t.len = WSPI_INIT_CMD_LEN;
110 spi_message_add_tail(&t, &m);
111
Teemu Paasikivi8197b712010-02-22 08:38:23 +0200112 spi_sync(wl_to_spi(wl), &m);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300113
114 wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN);
Dan Carpenter0dd38662010-12-21 07:00:13 +0300115 kfree(cmd);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300116}
117
Teemu Paasikivi760d9692010-02-22 08:38:25 +0200118static void wl1271_spi_init(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300119{
120 u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd;
121 struct spi_transfer t;
122 struct spi_message m;
123
124 cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL);
125 if (!cmd) {
126 wl1271_error("could not allocate cmd for spi init");
127 return;
128 }
129
130 memset(crc, 0, sizeof(crc));
131 memset(&t, 0, sizeof(t));
132 spi_message_init(&m);
133
134 /*
135 * Set WSPI_INIT_COMMAND
136 * the data is being send from the MSB to LSB
137 */
138 cmd[2] = 0xff;
139 cmd[3] = 0xff;
140 cmd[1] = WSPI_INIT_CMD_START | WSPI_INIT_CMD_TX;
141 cmd[0] = 0;
142 cmd[7] = 0;
143 cmd[6] |= HW_ACCESS_WSPI_INIT_CMD_MASK << 3;
144 cmd[6] |= HW_ACCESS_WSPI_FIXED_BUSY_LEN & WSPI_INIT_CMD_FIXEDBUSY_LEN;
145
146 if (HW_ACCESS_WSPI_FIXED_BUSY_LEN == 0)
147 cmd[5] |= WSPI_INIT_CMD_DIS_FIXEDBUSY;
148 else
149 cmd[5] |= WSPI_INIT_CMD_EN_FIXEDBUSY;
150
151 cmd[5] |= WSPI_INIT_CMD_IOD | WSPI_INIT_CMD_IP | WSPI_INIT_CMD_CS
152 | WSPI_INIT_CMD_WSPI | WSPI_INIT_CMD_WS;
153
154 crc[0] = cmd[1];
155 crc[1] = cmd[0];
156 crc[2] = cmd[7];
157 crc[3] = cmd[6];
158 crc[4] = cmd[5];
159
160 cmd[4] |= crc7(0, crc, WSPI_INIT_CMD_CRC_LEN) << 1;
161 cmd[4] |= WSPI_INIT_CMD_END;
162
163 t.tx_buf = cmd;
164 t.len = WSPI_INIT_CMD_LEN;
165 spi_message_add_tail(&t, &m);
166
Teemu Paasikivi8197b712010-02-22 08:38:23 +0200167 spi_sync(wl_to_spi(wl), &m);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300168 wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN);
Kulikov Vasiliybb123612010-07-31 20:33:59 +0400169 kfree(cmd);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300170}
171
Juuso Oikarinen545f1da2009-10-08 21:56:23 +0300172#define WL1271_BUSY_WORD_TIMEOUT 1000
173
Juuso Oikarinen259da432010-03-26 12:53:18 +0200174static int wl1271_spi_read_busy(struct wl1271 *wl)
Juuso Oikarinen545f1da2009-10-08 21:56:23 +0300175{
176 struct spi_transfer t[1];
177 struct spi_message m;
178 u32 *busy_buf;
179 int num_busy_bytes = 0;
180
Juuso Oikarinen545f1da2009-10-08 21:56:23 +0300181 /*
182 * Read further busy words from SPI until a non-busy word is
183 * encountered, then read the data itself into the buffer.
184 */
Juuso Oikarinen545f1da2009-10-08 21:56:23 +0300185
186 num_busy_bytes = WL1271_BUSY_WORD_TIMEOUT;
187 busy_buf = wl->buffer_busyword;
188 while (num_busy_bytes) {
189 num_busy_bytes--;
190 spi_message_init(&m);
191 memset(t, 0, sizeof(t));
192 t[0].rx_buf = busy_buf;
193 t[0].len = sizeof(u32);
Juuso Oikarinen259da432010-03-26 12:53:18 +0200194 t[0].cs_change = true;
Juuso Oikarinen545f1da2009-10-08 21:56:23 +0300195 spi_message_add_tail(&t[0], &m);
Teemu Paasikivi8197b712010-02-22 08:38:23 +0200196 spi_sync(wl_to_spi(wl), &m);
Juuso Oikarinen545f1da2009-10-08 21:56:23 +0300197
Juuso Oikarinen259da432010-03-26 12:53:18 +0200198 if (*busy_buf & 0x1)
199 return 0;
Juuso Oikarinen545f1da2009-10-08 21:56:23 +0300200 }
201
202 /* The SPI bus is unresponsive, the read failed. */
Juuso Oikarinen545f1da2009-10-08 21:56:23 +0300203 wl1271_error("SPI read busy-word timeout!\n");
Juuso Oikarinen259da432010-03-26 12:53:18 +0200204 return -ETIMEDOUT;
Juuso Oikarinen545f1da2009-10-08 21:56:23 +0300205}
206
Teemu Paasikivi760d9692010-02-22 08:38:25 +0200207static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
Juuso Oikarinen259da432010-03-26 12:53:18 +0200208 size_t len, bool fixed)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300209{
Ido Yariv5c57a902010-09-30 13:28:26 +0200210 struct spi_transfer t[2];
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300211 struct spi_message m;
Juuso Oikarinen545f1da2009-10-08 21:56:23 +0300212 u32 *busy_buf;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300213 u32 *cmd;
Ido Yariv5c57a902010-09-30 13:28:26 +0200214 u32 chunk_len;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300215
Ido Yariv5c57a902010-09-30 13:28:26 +0200216 while (len > 0) {
217 chunk_len = min((size_t)WSPI_MAX_CHUNK_SIZE, len);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300218
Ido Yariv5c57a902010-09-30 13:28:26 +0200219 cmd = &wl->buffer_cmd;
220 busy_buf = wl->buffer_busyword;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300221
Ido Yariv5c57a902010-09-30 13:28:26 +0200222 *cmd = 0;
223 *cmd |= WSPI_CMD_READ;
224 *cmd |= (chunk_len << WSPI_CMD_BYTE_LENGTH_OFFSET) &
225 WSPI_CMD_BYTE_LENGTH;
226 *cmd |= addr & WSPI_CMD_BYTE_ADDR;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300227
Ido Yariv5c57a902010-09-30 13:28:26 +0200228 if (fixed)
229 *cmd |= WSPI_CMD_FIXED;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300230
Ido Yariv5c57a902010-09-30 13:28:26 +0200231 spi_message_init(&m);
232 memset(t, 0, sizeof(t));
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300233
Ido Yariv5c57a902010-09-30 13:28:26 +0200234 t[0].tx_buf = cmd;
235 t[0].len = 4;
236 t[0].cs_change = true;
237 spi_message_add_tail(&t[0], &m);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300238
Ido Yariv5c57a902010-09-30 13:28:26 +0200239 /* Busy and non busy words read */
240 t[1].rx_buf = busy_buf;
241 t[1].len = WL1271_BUSY_WORD_LEN;
242 t[1].cs_change = true;
243 spi_message_add_tail(&t[1], &m);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300244
Ido Yariv5c57a902010-09-30 13:28:26 +0200245 spi_sync(wl_to_spi(wl), &m);
246
247 if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1) &&
248 wl1271_spi_read_busy(wl)) {
249 memset(buf, 0, chunk_len);
250 return;
251 }
252
253 spi_message_init(&m);
254 memset(t, 0, sizeof(t));
255
256 t[0].rx_buf = buf;
257 t[0].len = chunk_len;
258 t[0].cs_change = true;
259 spi_message_add_tail(&t[0], &m);
260
261 spi_sync(wl_to_spi(wl), &m);
262
263 wl1271_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd));
264 wl1271_dump(DEBUG_SPI, "spi_read buf <- ", buf, chunk_len);
265
266 if (!fixed)
267 addr += chunk_len;
268 buf += chunk_len;
269 len -= chunk_len;
Juuso Oikarinen259da432010-03-26 12:53:18 +0200270 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300271}
272
Teemu Paasikivi760d9692010-02-22 08:38:25 +0200273static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf,
Juuso Oikarinen74621412009-10-12 15:08:54 +0300274 size_t len, bool fixed)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300275{
Ido Yariv5c57a902010-09-30 13:28:26 +0200276 struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS];
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300277 struct spi_message m;
Ido Yariv5c57a902010-09-30 13:28:26 +0200278 u32 commands[WSPI_MAX_NUM_OF_CHUNKS];
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300279 u32 *cmd;
Ido Yariv5c57a902010-09-30 13:28:26 +0200280 u32 chunk_len;
281 int i;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300282
Ido Yariv5c57a902010-09-30 13:28:26 +0200283 WARN_ON(len > WL1271_AGGR_BUFFER_SIZE);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300284
285 spi_message_init(&m);
286 memset(t, 0, sizeof(t));
287
Ido Yariv5c57a902010-09-30 13:28:26 +0200288 cmd = &commands[0];
289 i = 0;
290 while (len > 0) {
291 chunk_len = min((size_t)WSPI_MAX_CHUNK_SIZE, len);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300292
Ido Yariv5c57a902010-09-30 13:28:26 +0200293 *cmd = 0;
294 *cmd |= WSPI_CMD_WRITE;
295 *cmd |= (chunk_len << WSPI_CMD_BYTE_LENGTH_OFFSET) &
296 WSPI_CMD_BYTE_LENGTH;
297 *cmd |= addr & WSPI_CMD_BYTE_ADDR;
298
299 if (fixed)
300 *cmd |= WSPI_CMD_FIXED;
301
302 t[i].tx_buf = cmd;
303 t[i].len = sizeof(*cmd);
304 spi_message_add_tail(&t[i++], &m);
305
306 t[i].tx_buf = buf;
307 t[i].len = chunk_len;
308 spi_message_add_tail(&t[i++], &m);
309
310 wl1271_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd));
311 wl1271_dump(DEBUG_SPI, "spi_write buf -> ", buf, chunk_len);
312
313 if (!fixed)
314 addr += chunk_len;
315 buf += chunk_len;
316 len -= chunk_len;
317 cmd++;
318 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300319
Teemu Paasikivi8197b712010-02-22 08:38:23 +0200320 spi_sync(wl_to_spi(wl), &m);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300321}
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200322
Ido Yariva6208652011-03-01 15:14:41 +0200323static irqreturn_t wl1271_hardirq(int irq, void *cookie)
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200324{
Ido Yariva6208652011-03-01 15:14:41 +0200325 struct wl1271 *wl = cookie;
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200326 unsigned long flags;
327
328 wl1271_debug(DEBUG_IRQ, "IRQ");
329
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200330 /* complete the ELP completion */
331 spin_lock_irqsave(&wl->wl_lock, flags);
Ido Yariva6208652011-03-01 15:14:41 +0200332 set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200333 if (wl->elp_compl) {
334 complete(wl->elp_compl);
335 wl->elp_compl = NULL;
336 }
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200337 spin_unlock_irqrestore(&wl->wl_lock, flags);
338
Ido Yariva6208652011-03-01 15:14:41 +0200339 return IRQ_WAKE_THREAD;
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200340}
341
Ohad Ben-Cohen2cc78ff2010-09-16 01:22:04 +0200342static int wl1271_spi_set_power(struct wl1271 *wl, bool enable)
Teemu Paasikivibecd5512010-03-18 12:26:27 +0200343{
344 if (wl->set_power)
345 wl->set_power(enable);
Ohad Ben-Cohen2cc78ff2010-09-16 01:22:04 +0200346
347 return 0;
Teemu Paasikivibecd5512010-03-18 12:26:27 +0200348}
349
Teemu Paasikivi8197b712010-02-22 08:38:23 +0200350static struct wl1271_if_operations spi_ops = {
351 .read = wl1271_spi_raw_read,
352 .write = wl1271_spi_raw_write,
353 .reset = wl1271_spi_reset,
354 .init = wl1271_spi_init,
Teemu Paasikivibecd5512010-03-18 12:26:27 +0200355 .power = wl1271_spi_set_power,
Teemu Paasikivi8197b712010-02-22 08:38:23 +0200356 .dev = wl1271_spi_wl_to_dev,
357 .enable_irq = wl1271_spi_enable_interrupts,
358 .disable_irq = wl1271_spi_disable_interrupts
359};
360
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200361static int __devinit wl1271_probe(struct spi_device *spi)
362{
363 struct wl12xx_platform_data *pdata;
364 struct ieee80211_hw *hw;
365 struct wl1271 *wl;
366 int ret;
367
368 pdata = spi->dev.platform_data;
369 if (!pdata) {
370 wl1271_error("no platform data");
371 return -ENODEV;
372 }
373
374 hw = wl1271_alloc_hw();
375 if (IS_ERR(hw))
376 return PTR_ERR(hw);
377
378 wl = hw->priv;
379
380 dev_set_drvdata(&spi->dev, wl);
Teemu Paasikivi8197b712010-02-22 08:38:23 +0200381 wl->if_priv = spi;
382
383 wl->if_ops = &spi_ops;
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200384
385 /* This is the only SPI value that we need to set here, the rest
386 * comes from the board-peripherals file */
387 spi->bits_per_word = 32;
388
389 ret = spi_setup(spi);
390 if (ret < 0) {
391 wl1271_error("spi_setup failed");
392 goto out_free;
393 }
394
395 wl->set_power = pdata->set_power;
396 if (!wl->set_power) {
397 wl1271_error("set power function missing in platform data");
398 ret = -ENODEV;
399 goto out_free;
400 }
401
Ohad Ben-Cohen15cea992010-09-16 01:31:51 +0200402 wl->ref_clock = pdata->board_ref_clock;
403
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200404 wl->irq = spi->irq;
405 if (wl->irq < 0) {
406 wl1271_error("irq missing in platform data");
407 ret = -ENODEV;
408 goto out_free;
409 }
410
Ido Yariva6208652011-03-01 15:14:41 +0200411 ret = request_threaded_irq(wl->irq, wl1271_hardirq, wl1271_irq,
Ido Yariv2da69b82011-03-01 15:14:42 +0200412 IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
Ido Yariva6208652011-03-01 15:14:41 +0200413 DRIVER_NAME, wl);
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200414 if (ret < 0) {
415 wl1271_error("request_irq() failed: %d", ret);
416 goto out_free;
417 }
418
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200419 disable_irq(wl->irq);
420
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200421 ret = wl1271_init_ieee80211(wl);
422 if (ret)
Juuso Oikarinena1dd8182010-03-18 12:26:31 +0200423 goto out_irq;
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200424
425 ret = wl1271_register_hw(wl);
426 if (ret)
Juuso Oikarinena1dd8182010-03-18 12:26:31 +0200427 goto out_irq;
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200428
429 wl1271_notice("initialized");
430
431 return 0;
432
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200433 out_irq:
434 free_irq(wl->irq, wl);
435
436 out_free:
Teemu Paasikivi3b56dd62010-03-18 12:26:46 +0200437 wl1271_free_hw(wl);
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200438
439 return ret;
440}
441
442static int __devexit wl1271_remove(struct spi_device *spi)
443{
444 struct wl1271 *wl = dev_get_drvdata(&spi->dev);
445
Teemu Paasikivi3b56dd62010-03-18 12:26:46 +0200446 wl1271_unregister_hw(wl);
Juuso Oikarinen4e23b112010-08-13 04:46:48 +0200447 free_irq(wl->irq, wl);
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200448 wl1271_free_hw(wl);
449
450 return 0;
451}
452
453
454static struct spi_driver wl1271_spi_driver = {
455 .driver = {
Luciano Coelho7fdd50d2010-03-26 12:53:10 +0200456 .name = "wl1271_spi",
Teemu Paasikivi2d5e82b2010-02-22 08:38:21 +0200457 .bus = &spi_bus_type,
458 .owner = THIS_MODULE,
459 },
460
461 .probe = wl1271_probe,
462 .remove = __devexit_p(wl1271_remove),
463};
464
465static int __init wl1271_init(void)
466{
467 int ret;
468
469 ret = spi_register_driver(&wl1271_spi_driver);
470 if (ret < 0) {
471 wl1271_error("failed to register spi driver: %d", ret);
472 goto out;
473 }
474
475out:
476 return ret;
477}
478
479static void __exit wl1271_exit(void)
480{
481 spi_unregister_driver(&wl1271_spi_driver);
482
483 wl1271_notice("unloaded");
484}
485
486module_init(wl1271_init);
487module_exit(wl1271_exit);
488
489MODULE_LICENSE("GPL");
490MODULE_AUTHOR("Luciano Coelho <luciano.coelho@nokia.com>");
491MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>");
492MODULE_FIRMWARE(WL1271_FW_NAME);
Arik Nemtsovd75387c2011-01-17 10:16:00 +0100493MODULE_FIRMWARE(WL1271_AP_FW_NAME);
Ameya Palandef148cfd2010-07-05 17:12:38 +0300494MODULE_ALIAS("spi:wl1271");