blob: 7c1b843b63e9b7e41016a9a5e405fe6fe1cda339 [file] [log] [blame]
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -08001/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Linux driver model glue for the SDIO device, reset & fw upload
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
7 * Dirk Brandewie <dirk.j.brandewie@intel.com>
8 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
9 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License version
13 * 2 as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * 02110-1301, USA.
24 *
25 *
26 * See i2400m-sdio.h for a general description of this driver.
27 *
28 * This file implements driver model glue, and hook ups for the
29 * generic driver to implement the bus-specific functions (device
30 * communication setup/tear down, firmware upload and resetting).
31 *
32 * ROADMAP
33 *
34 * i2400m_probe()
35 * alloc_netdev()
36 * i2400ms_netdev_setup()
37 * i2400ms_init()
38 * i2400m_netdev_setup()
39 * i2400ms_enable_function()
40 * i2400m_setup()
41 *
42 * i2400m_remove()
43 * i2400m_release()
44 * free_netdev(net_dev)
45 *
46 * i2400ms_bus_reset() Called by i2400m->bus_reset
47 * __i2400ms_reset()
48 * __i2400ms_send_barker()
49 *
50 * i2400ms_bus_dev_start() Called by i2400m_dev_start() [who is
51 * i2400ms_tx_setup() called by i2400m_setup()]
52 * i2400ms_rx_setup()
53 *
54 * i2400ms_bus_dev_stop() Called by i2400m_dev_stop() [who is
55 * i2400ms_rx_release() is called by i2400m_release()]
56 * i2400ms_tx_release()
57 *
58 */
59
60#include <linux/debugfs.h>
Tomas Winkler51def0b2009-07-22 14:06:56 +000061#include <linux/mmc/sdio_ids.h>
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -080062#include <linux/mmc/sdio.h>
63#include <linux/mmc/sdio_func.h>
64#include "i2400m-sdio.h"
65#include <linux/wimax/i2400m.h>
66
67#define D_SUBMODULE main
68#include "sdio-debug-levels.h"
69
70/* IOE WiMAX function timeout in seconds */
71static int ioe_timeout = 2;
72module_param(ioe_timeout, int, 0);
73
Inaky Perez-Gonzalez1039abb2009-02-28 23:42:47 +000074/* Our firmware file name list */
75static const char *i2400ms_bus_fw_names[] = {
76#define I2400MS_FW_FILE_NAME "i2400m-fw-sdio-1.3.sbcf"
77 I2400MS_FW_FILE_NAME,
78 NULL
79};
80
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -080081
Dirk Brandewie1c0b2dd2009-05-21 11:56:35 -070082static const struct i2400m_poke_table i2400ms_pokes[] = {
83 I2400M_FW_POKE(0x6BE260, 0x00000088),
84 I2400M_FW_POKE(0x080550, 0x00000005),
85 I2400M_FW_POKE(0xAE0000, 0x00000000),
86 I2400M_FW_POKE(0x000000, 0x00000000), /* MUST be 0 terminated or bad
87 * things will happen */
88};
89
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -080090/*
91 * Enable the SDIO function
92 *
93 * Tries to enable the SDIO function; might fail if it is still not
94 * ready (in some hardware, the SDIO WiMAX function is only enabled
95 * when we ask it to explicitly doing). Tries until a timeout is
96 * reached.
97 *
Inaky Perez-Gonzalezc77ca952009-08-31 17:57:56 -070098 * The @maxtries argument indicates how many times (at most) it should
99 * be tried to enable the function. 0 means forever. This acts along
100 * with the timeout (ie: it'll stop trying as soon as the maximum
101 * number of tries is reached _or_ as soon as the timeout is reached).
102 *
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800103 * The reverse of this is...sdio_disable_function()
104 *
105 * Returns: 0 if the SDIO function was enabled, < 0 errno code on
106 * error (-ENODEV when it was unable to enable the function).
107 */
108static
Inaky Perez-Gonzalezc77ca952009-08-31 17:57:56 -0700109int i2400ms_enable_function(struct sdio_func *func, unsigned maxtries)
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800110{
111 u64 timeout;
112 int err;
113 struct device *dev = &func->dev;
Inaky Perez-Gonzalezc77ca952009-08-31 17:57:56 -0700114 unsigned tries = 0;
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800115
116 d_fnstart(3, dev, "(func %p)\n", func);
117 /* Setup timeout (FIXME: This needs to read the CIS table to
118 * get a real timeout) and then wait for the device to signal
119 * it is ready */
120 timeout = get_jiffies_64() + ioe_timeout * HZ;
121 err = -ENODEV;
122 while (err != 0 && time_before64(get_jiffies_64(), timeout)) {
123 sdio_claim_host(func);
Cindy H Kaof2696fb2009-08-17 19:17:58 -0700124 /*
125 * There is a sillicon bug on the IWMC3200, where the
126 * IOE timeout will cause problems on Moorestown
127 * platforms (system hang). We explicitly overwrite
128 * func->enable_timeout here to work around the issue.
129 */
130 if (func->device == SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX)
131 func->enable_timeout = IWMC3200_IOR_TIMEOUT;
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800132 err = sdio_enable_func(func);
133 if (0 == err) {
134 sdio_release_host(func);
135 d_printf(2, dev, "SDIO function enabled\n");
136 goto function_enabled;
137 }
138 d_printf(2, dev, "SDIO function failed to enable: %d\n", err);
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800139 sdio_release_host(func);
Inaky Perez-Gonzalezc77ca952009-08-31 17:57:56 -0700140 if (maxtries > 0 && ++tries >= maxtries) {
141 err = -ETIME;
142 break;
143 }
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800144 msleep(I2400MS_INIT_SLEEP_INTERVAL);
145 }
146 /* If timed out, device is not there yet -- get -ENODEV so
147 * the device driver core will retry later on. */
148 if (err == -ETIME) {
149 dev_err(dev, "Can't enable WiMAX function; "
150 " has the function been enabled?\n");
151 err = -ENODEV;
152 }
153function_enabled:
154 d_fnend(3, dev, "(func %p) = %d\n", func, err);
155 return err;
156}
157
158
159/*
160 * Setup driver resources needed to communicate with the device
161 *
162 * The fw needs some time to settle, and it was just uploaded,
163 * so give it a break first. I'd prefer to just wait for the device to
164 * send something, but seems the poking we do to enable SDIO stuff
165 * interferes with it, so just give it a break before starting...
166 */
167static
168int i2400ms_bus_dev_start(struct i2400m *i2400m)
169{
170 int result;
171 struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
172 struct sdio_func *func = i2400ms->func;
173 struct device *dev = &func->dev;
174
175 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
176 msleep(200);
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800177 result = i2400ms_tx_setup(i2400ms);
178 if (result < 0)
179 goto error_tx_setup;
180 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
181 return result;
182
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800183error_tx_setup:
Inaky Perez-Gonzalez16820c12009-05-07 01:02:39 -0700184 i2400ms_tx_release(i2400ms);
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800185 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
186 return result;
187}
188
189
190static
191void i2400ms_bus_dev_stop(struct i2400m *i2400m)
192{
193 struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
194 struct sdio_func *func = i2400ms->func;
195 struct device *dev = &func->dev;
196
197 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800198 i2400ms_tx_release(i2400ms);
199 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
200}
201
202
203/*
204 * Sends a barker buffer to the device
205 *
206 * This helper will allocate a kmalloced buffer and use it to transmit
207 * (then free it). Reason for this is that the SDIO host controller
208 * expects alignment (unknown exactly which) which the stack won't
209 * really provide and certain arches/host-controller combinations
210 * cannot use stack/vmalloc/text areas for DMA transfers.
211 */
212static
213int __i2400ms_send_barker(struct i2400ms *i2400ms,
214 const __le32 *barker, size_t barker_size)
215{
216 int ret;
217 struct sdio_func *func = i2400ms->func;
218 struct device *dev = &func->dev;
219 void *buffer;
220
221 ret = -ENOMEM;
222 buffer = kmalloc(I2400MS_BLK_SIZE, GFP_KERNEL);
223 if (buffer == NULL)
224 goto error_kzalloc;
225
226 memcpy(buffer, barker, barker_size);
227 sdio_claim_host(func);
228 ret = sdio_memcpy_toio(func, 0, buffer, I2400MS_BLK_SIZE);
229 sdio_release_host(func);
230
231 if (ret < 0)
232 d_printf(0, dev, "E: barker error: %d\n", ret);
233
234 kfree(buffer);
235error_kzalloc:
236 return ret;
237}
238
239
240/*
241 * Reset a device at different levels (warm, cold or bus)
242 *
243 * @i2400ms: device descriptor
244 * @reset_type: soft, warm or bus reset (I2400M_RT_WARM/SOFT/BUS)
245 *
246 * FIXME: not tested -- need to confirm expected effects
247 *
248 * Warm and cold resets get an SDIO reset if they fail (unimplemented)
249 *
250 * Warm reset:
251 *
252 * The device will be fully reset internally, but won't be
Dirk Brandewie81b182a2009-07-24 09:04:33 -0700253 * disconnected from the bus (so no reenumeration will
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800254 * happen). Firmware upload will be neccessary.
255 *
Dirk Brandewie81b182a2009-07-24 09:04:33 -0700256 * The device will send a reboot barker that will trigger the driver
257 * to reinitialize the state via __i2400m_dev_reset_handle.
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800258 *
Dirk Brandewie81b182a2009-07-24 09:04:33 -0700259 *
260 * Cold and bus reset:
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800261 *
262 * The device will be fully reset internally, disconnected from the
Dirk Brandewie81b182a2009-07-24 09:04:33 -0700263 * bus an a reenumeration will happen. Firmware upload will be
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800264 * neccessary. Thus, we don't do any locking or struct
265 * reinitialization, as we are going to be fully disconnected and
266 * reenumerated.
267 *
268 * Note we need to return -ENODEV if a warm reset was requested and we
269 * had to resort to a bus reset. See i2400m_op_reset(), wimax_reset()
270 * and wimax_dev->op_reset.
271 *
272 * WARNING: no driver state saved/fixed
273 */
274static
275int i2400ms_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
276{
Dirk Brandewie10b1de62009-05-12 07:54:00 -0700277 int result = 0;
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800278 struct i2400ms *i2400ms =
279 container_of(i2400m, struct i2400ms, i2400m);
280 struct device *dev = i2400m_dev(i2400m);
281 static const __le32 i2400m_WARM_BOOT_BARKER[4] = {
Harvey Harrisonee437772009-02-01 00:43:54 -0800282 cpu_to_le32(I2400M_WARM_RESET_BARKER),
283 cpu_to_le32(I2400M_WARM_RESET_BARKER),
284 cpu_to_le32(I2400M_WARM_RESET_BARKER),
285 cpu_to_le32(I2400M_WARM_RESET_BARKER),
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800286 };
287 static const __le32 i2400m_COLD_BOOT_BARKER[4] = {
Harvey Harrisonee437772009-02-01 00:43:54 -0800288 cpu_to_le32(I2400M_COLD_RESET_BARKER),
289 cpu_to_le32(I2400M_COLD_RESET_BARKER),
290 cpu_to_le32(I2400M_COLD_RESET_BARKER),
291 cpu_to_le32(I2400M_COLD_RESET_BARKER),
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800292 };
293
294 if (rt == I2400M_RT_WARM)
295 result = __i2400ms_send_barker(i2400ms, i2400m_WARM_BOOT_BARKER,
296 sizeof(i2400m_WARM_BOOT_BARKER));
297 else if (rt == I2400M_RT_COLD)
298 result = __i2400ms_send_barker(i2400ms, i2400m_COLD_BOOT_BARKER,
299 sizeof(i2400m_COLD_BOOT_BARKER));
300 else if (rt == I2400M_RT_BUS) {
301do_bus_reset:
Dirk Brandewie10b1de62009-05-12 07:54:00 -0700302 /* call netif_tx_disable() before sending IOE disable,
303 * so that all the tx from network layer are stopped
304 * while IOE is being reset. Make sure it is called
305 * only after register_netdev() was issued.
306 */
307 if (i2400m->wimax_dev.net_dev->reg_state == NETREG_REGISTERED)
308 netif_tx_disable(i2400m->wimax_dev.net_dev);
309
Inaky Perez-Gonzalez16820c12009-05-07 01:02:39 -0700310 i2400ms_rx_release(i2400ms);
Dirk Brandewie10b1de62009-05-12 07:54:00 -0700311 sdio_claim_host(i2400ms->func);
312 sdio_disable_func(i2400ms->func);
313 sdio_release_host(i2400ms->func);
314
315 /* Wait for the device to settle */
316 msleep(40);
317
Inaky Perez-Gonzalezc77ca952009-08-31 17:57:56 -0700318 result = i2400ms_enable_function(i2400ms->func, 0);
Inaky Perez-Gonzalez16820c12009-05-07 01:02:39 -0700319 if (result >= 0)
320 i2400ms_rx_setup(i2400ms);
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800321 } else
322 BUG();
323 if (result < 0 && rt != I2400M_RT_BUS) {
324 dev_err(dev, "%s reset failed (%d); trying SDIO reset\n",
325 rt == I2400M_RT_WARM ? "warm" : "cold", result);
326 rt = I2400M_RT_BUS;
327 goto do_bus_reset;
328 }
329 return result;
330}
331
332
333static
334void i2400ms_netdev_setup(struct net_device *net_dev)
335{
336 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
337 struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
338 i2400ms_init(i2400ms);
339 i2400m_netdev_setup(net_dev);
340}
341
342
343/*
344 * Debug levels control; see debug.h
345 */
346struct d_level D_LEVEL[] = {
347 D_SUBMODULE_DEFINE(main),
348 D_SUBMODULE_DEFINE(tx),
349 D_SUBMODULE_DEFINE(rx),
350 D_SUBMODULE_DEFINE(fw),
351};
352size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
353
354
355#define __debugfs_register(prefix, name, parent) \
356do { \
357 result = d_level_register_debugfs(prefix, name, parent); \
358 if (result < 0) \
359 goto error; \
360} while (0)
361
362
363static
364int i2400ms_debugfs_add(struct i2400ms *i2400ms)
365{
366 int result;
367 struct dentry *dentry = i2400ms->i2400m.wimax_dev.debugfs_dentry;
368
369 dentry = debugfs_create_dir("i2400m-usb", dentry);
370 result = PTR_ERR(dentry);
371 if (IS_ERR(dentry)) {
372 if (result == -ENODEV)
373 result = 0; /* No debugfs support */
374 goto error;
375 }
376 i2400ms->debugfs_dentry = dentry;
377 __debugfs_register("dl_", main, dentry);
378 __debugfs_register("dl_", tx, dentry);
379 __debugfs_register("dl_", rx, dentry);
380 __debugfs_register("dl_", fw, dentry);
381
382 return 0;
383
384error:
385 debugfs_remove_recursive(i2400ms->debugfs_dentry);
386 return result;
387}
388
389
Marcel Holtmann384912e2009-08-31 21:08:19 +0000390static struct device_type i2400ms_type = {
391 .name = "wimax",
392};
393
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800394/*
395 * Probe a i2400m interface and register it
396 *
397 * @func: SDIO function
398 * @id: SDIO device ID
399 * @returns: 0 if ok, < 0 errno code on error.
400 *
401 * Alloc a net device, initialize the bus-specific details and then
402 * calls the bus-generic initialization routine. That will register
403 * the wimax and netdev devices, upload the firmware [using
404 * _bus_bm_*()], call _bus_dev_start() to finalize the setup of the
405 * communication with the device and then will start to talk to it to
406 * finnish setting it up.
407 *
408 * Initialization is tricky; some instances of the hw are packed with
409 * others in a way that requires a third driver that enables the WiMAX
410 * function. In those cases, we can't enable the SDIO function and
411 * we'll return with -ENODEV. When the driver that enables the WiMAX
412 * function does its thing, it has to do a bus_rescan_devices() on the
413 * SDIO bus so this driver is called again to enumerate the WiMAX
414 * function.
415 */
416static
417int i2400ms_probe(struct sdio_func *func,
418 const struct sdio_device_id *id)
419{
420 int result;
421 struct net_device *net_dev;
422 struct device *dev = &func->dev;
423 struct i2400m *i2400m;
424 struct i2400ms *i2400ms;
425
426 /* Allocate instance [calls i2400m_netdev_setup() on it]. */
427 result = -ENOMEM;
428 net_dev = alloc_netdev(sizeof(*i2400ms), "wmx%d",
429 i2400ms_netdev_setup);
430 if (net_dev == NULL) {
431 dev_err(dev, "no memory for network device instance\n");
432 goto error_alloc_netdev;
433 }
434 SET_NETDEV_DEV(net_dev, dev);
Marcel Holtmann384912e2009-08-31 21:08:19 +0000435 SET_NETDEV_DEVTYPE(net_dev, &i2400ms_type);
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800436 i2400m = net_dev_to_i2400m(net_dev);
437 i2400ms = container_of(i2400m, struct i2400ms, i2400m);
438 i2400m->wimax_dev.net_dev = net_dev;
439 i2400ms->func = func;
440 sdio_set_drvdata(func, i2400ms);
441
442 i2400m->bus_tx_block_size = I2400MS_BLK_SIZE;
443 i2400m->bus_pl_size_max = I2400MS_PL_SIZE_MAX;
444 i2400m->bus_dev_start = i2400ms_bus_dev_start;
445 i2400m->bus_dev_stop = i2400ms_bus_dev_stop;
446 i2400m->bus_tx_kick = i2400ms_bus_tx_kick;
447 i2400m->bus_reset = i2400ms_bus_reset;
Inaky Perez-Gonzalezecddfd52009-06-03 16:13:14 +0800448 /* The iwmc3200-wimax sometimes requires the driver to try
449 * hard when we paint it into a corner. */
Dirk Brandewiec3083652009-08-13 13:48:29 -0700450 i2400m->bus_bm_retries = I2400M_SDIO_BOOT_RETRIES;
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800451 i2400m->bus_bm_cmd_send = i2400ms_bus_bm_cmd_send;
452 i2400m->bus_bm_wait_for_ack = i2400ms_bus_bm_wait_for_ack;
Inaky Perez-Gonzalez1039abb2009-02-28 23:42:47 +0000453 i2400m->bus_fw_names = i2400ms_bus_fw_names;
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800454 i2400m->bus_bm_mac_addr_impaired = 1;
Dirk Brandewie1c0b2dd2009-05-21 11:56:35 -0700455 i2400m->bus_bm_pokes_table = &i2400ms_pokes[0];
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800456
Inaky Perez-Gonzaleza0a4c4c2009-04-30 14:39:21 -0700457 sdio_claim_host(func);
458 result = sdio_set_block_size(func, I2400MS_BLK_SIZE);
459 sdio_release_host(func);
460 if (result < 0) {
461 dev_err(dev, "Failed to set block size: %d\n", result);
462 goto error_set_blk_size;
463 }
464
Inaky Perez-Gonzalezc77ca952009-08-31 17:57:56 -0700465 result = i2400ms_enable_function(i2400ms->func, 1);
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800466 if (result < 0) {
467 dev_err(dev, "Cannot enable SDIO function: %d\n", result);
468 goto error_func_enable;
469 }
470
Dirk Brandewiea134fd62009-08-18 08:51:52 -0700471 /*
472 * Before we are enabling the device interrupt register, make
473 * sure the buffer used during bootmode operation is setup so
474 * when the first D2H data interrupt comes, the memory is
475 * available for copying the D2H data.
476 */
477 result = i2400m_bm_buf_alloc(i2400m);
478 if (result < 0) {
479 dev_err(dev, "cannot allocate SDIO bootmode buffer\n");
480 goto error_bootmode_buf_setup;
481 }
482
Inaky Perez-Gonzalez16820c12009-05-07 01:02:39 -0700483 result = i2400ms_rx_setup(i2400ms);
484 if (result < 0)
485 goto error_rx_setup;
486
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800487 result = i2400m_setup(i2400m, I2400M_BRI_NO_REBOOT);
488 if (result < 0) {
489 dev_err(dev, "cannot setup device: %d\n", result);
490 goto error_setup;
491 }
492
493 result = i2400ms_debugfs_add(i2400ms);
494 if (result < 0) {
495 dev_err(dev, "cannot create SDIO debugfs: %d\n",
496 result);
497 goto error_debugfs_add;
498 }
499 return 0;
500
501error_debugfs_add:
502 i2400m_release(i2400m);
503error_setup:
Inaky Perez-Gonzalez16820c12009-05-07 01:02:39 -0700504 i2400ms_rx_release(i2400ms);
505error_rx_setup:
Dirk Brandewiea134fd62009-08-18 08:51:52 -0700506 i2400m_bm_buf_free(i2400m);
507error_bootmode_buf_setup:
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800508 sdio_claim_host(func);
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800509 sdio_disable_func(func);
510 sdio_release_host(func);
511error_func_enable:
Inaky Perez-Gonzaleza0a4c4c2009-04-30 14:39:21 -0700512error_set_blk_size:
513 sdio_set_drvdata(func, NULL);
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800514 free_netdev(net_dev);
515error_alloc_netdev:
516 return result;
517}
518
519
520static
521void i2400ms_remove(struct sdio_func *func)
522{
523 struct device *dev = &func->dev;
524 struct i2400ms *i2400ms = sdio_get_drvdata(func);
525 struct i2400m *i2400m = &i2400ms->i2400m;
526 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
527
528 d_fnstart(3, dev, "SDIO func %p\n", func);
529 debugfs_remove_recursive(i2400ms->debugfs_dentry);
Inaky Perez-Gonzalez16820c12009-05-07 01:02:39 -0700530 i2400ms_rx_release(i2400ms);
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800531 i2400m_release(i2400m);
532 sdio_set_drvdata(func, NULL);
533 sdio_claim_host(func);
534 sdio_disable_func(func);
535 sdio_release_host(func);
536 free_netdev(net_dev);
537 d_fnend(3, dev, "SDIO func %p\n", func);
538}
539
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800540static
541const struct sdio_device_id i2400ms_sdio_ids[] = {
Tomas Winkler51def0b2009-07-22 14:06:56 +0000542 /* Intel: i2400m WiMAX (iwmc3200) over SDIO */
543 { SDIO_DEVICE(SDIO_VENDOR_ID_INTEL,
544 SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX) },
545 { /* end: all zeroes */ },
Inaky Perez-Gonzaleza0848822008-12-20 16:57:55 -0800546};
547MODULE_DEVICE_TABLE(sdio, i2400ms_sdio_ids);
548
549
550static
551struct sdio_driver i2400m_sdio_driver = {
552 .name = KBUILD_MODNAME,
553 .probe = i2400ms_probe,
554 .remove = i2400ms_remove,
555 .id_table = i2400ms_sdio_ids,
556};
557
558
559static
560int __init i2400ms_driver_init(void)
561{
562 return sdio_register_driver(&i2400m_sdio_driver);
563}
564module_init(i2400ms_driver_init);
565
566
567static
568void __exit i2400ms_driver_exit(void)
569{
570 flush_scheduled_work(); /* for the stuff we schedule */
571 sdio_unregister_driver(&i2400m_sdio_driver);
572}
573module_exit(i2400ms_driver_exit);
574
575
576MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
577MODULE_DESCRIPTION("Intel 2400M WiMAX networking for SDIO");
578MODULE_LICENSE("GPL");
579MODULE_FIRMWARE(I2400MS_FW_FILE_NAME);