1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Intel Wireless WiMAX Connection 2400m
4*4882a593Smuzhiyun * Linux driver model glue for USB device, reset & fw upload
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
7*4882a593Smuzhiyun * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8*4882a593Smuzhiyun * Yanir Lubetkin <yanirx.lubetkin@intel.com>
9*4882a593Smuzhiyun *
10*4882a593Smuzhiyun * See i2400m-usb.h for a general description of this driver.
11*4882a593Smuzhiyun *
12*4882a593Smuzhiyun * This file implements driver model glue, and hook ups for the
13*4882a593Smuzhiyun * generic driver to implement the bus-specific functions (device
14*4882a593Smuzhiyun * communication setup/tear down, firmware upload and resetting).
15*4882a593Smuzhiyun *
16*4882a593Smuzhiyun * ROADMAP
17*4882a593Smuzhiyun *
18*4882a593Smuzhiyun * i2400mu_probe()
19*4882a593Smuzhiyun * alloc_netdev()...
20*4882a593Smuzhiyun * i2400mu_netdev_setup()
21*4882a593Smuzhiyun * i2400mu_init()
22*4882a593Smuzhiyun * i2400m_netdev_setup()
23*4882a593Smuzhiyun * i2400m_setup()...
24*4882a593Smuzhiyun *
25*4882a593Smuzhiyun * i2400mu_disconnect
26*4882a593Smuzhiyun * i2400m_release()
27*4882a593Smuzhiyun * free_netdev()
28*4882a593Smuzhiyun *
29*4882a593Smuzhiyun * i2400mu_suspend()
30*4882a593Smuzhiyun * i2400m_cmd_enter_powersave()
31*4882a593Smuzhiyun * i2400mu_notification_release()
32*4882a593Smuzhiyun *
33*4882a593Smuzhiyun * i2400mu_resume()
34*4882a593Smuzhiyun * i2400mu_notification_setup()
35*4882a593Smuzhiyun *
36*4882a593Smuzhiyun * i2400mu_bus_dev_start() Called by i2400m_dev_start() [who is
37*4882a593Smuzhiyun * i2400mu_tx_setup() called by i2400m_setup()]
38*4882a593Smuzhiyun * i2400mu_rx_setup()
39*4882a593Smuzhiyun * i2400mu_notification_setup()
40*4882a593Smuzhiyun *
41*4882a593Smuzhiyun * i2400mu_bus_dev_stop() Called by i2400m_dev_stop() [who is
42*4882a593Smuzhiyun * i2400mu_notification_release() called by i2400m_release()]
43*4882a593Smuzhiyun * i2400mu_rx_release()
44*4882a593Smuzhiyun * i2400mu_tx_release()
45*4882a593Smuzhiyun *
46*4882a593Smuzhiyun * i2400mu_bus_reset() Called by i2400m_reset
47*4882a593Smuzhiyun * __i2400mu_reset()
48*4882a593Smuzhiyun * __i2400mu_send_barker()
49*4882a593Smuzhiyun * usb_reset_device()
50*4882a593Smuzhiyun */
51*4882a593Smuzhiyun #include "i2400m-usb.h"
52*4882a593Smuzhiyun #include <linux/wimax/i2400m.h>
53*4882a593Smuzhiyun #include <linux/debugfs.h>
54*4882a593Smuzhiyun #include <linux/slab.h>
55*4882a593Smuzhiyun #include <linux/module.h>
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun #define D_SUBMODULE usb
59*4882a593Smuzhiyun #include "usb-debug-levels.h"
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun static char i2400mu_debug_params[128];
62*4882a593Smuzhiyun module_param_string(debug, i2400mu_debug_params, sizeof(i2400mu_debug_params),
63*4882a593Smuzhiyun 0644);
64*4882a593Smuzhiyun MODULE_PARM_DESC(debug,
65*4882a593Smuzhiyun "String of space-separated NAME:VALUE pairs, where NAMEs "
66*4882a593Smuzhiyun "are the different debug submodules and VALUE are the "
67*4882a593Smuzhiyun "initial debug value to set.");
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun /* Our firmware file name */
70*4882a593Smuzhiyun static const char *i2400mu_bus_fw_names_5x50[] = {
71*4882a593Smuzhiyun #define I2400MU_FW_FILE_NAME_v1_5 "i2400m-fw-usb-1.5.sbcf"
72*4882a593Smuzhiyun I2400MU_FW_FILE_NAME_v1_5,
73*4882a593Smuzhiyun #define I2400MU_FW_FILE_NAME_v1_4 "i2400m-fw-usb-1.4.sbcf"
74*4882a593Smuzhiyun I2400MU_FW_FILE_NAME_v1_4,
75*4882a593Smuzhiyun NULL,
76*4882a593Smuzhiyun };
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun static const char *i2400mu_bus_fw_names_6050[] = {
80*4882a593Smuzhiyun #define I6050U_FW_FILE_NAME_v1_5 "i6050-fw-usb-1.5.sbcf"
81*4882a593Smuzhiyun I6050U_FW_FILE_NAME_v1_5,
82*4882a593Smuzhiyun NULL,
83*4882a593Smuzhiyun };
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun static
i2400mu_bus_dev_start(struct i2400m * i2400m)87*4882a593Smuzhiyun int i2400mu_bus_dev_start(struct i2400m *i2400m)
88*4882a593Smuzhiyun {
89*4882a593Smuzhiyun int result;
90*4882a593Smuzhiyun struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
91*4882a593Smuzhiyun struct device *dev = &i2400mu->usb_iface->dev;
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
94*4882a593Smuzhiyun result = i2400mu_tx_setup(i2400mu);
95*4882a593Smuzhiyun if (result < 0)
96*4882a593Smuzhiyun goto error_usb_tx_setup;
97*4882a593Smuzhiyun result = i2400mu_rx_setup(i2400mu);
98*4882a593Smuzhiyun if (result < 0)
99*4882a593Smuzhiyun goto error_usb_rx_setup;
100*4882a593Smuzhiyun result = i2400mu_notification_setup(i2400mu);
101*4882a593Smuzhiyun if (result < 0)
102*4882a593Smuzhiyun goto error_notif_setup;
103*4882a593Smuzhiyun d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
104*4882a593Smuzhiyun return result;
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun error_notif_setup:
107*4882a593Smuzhiyun i2400mu_rx_release(i2400mu);
108*4882a593Smuzhiyun error_usb_rx_setup:
109*4882a593Smuzhiyun i2400mu_tx_release(i2400mu);
110*4882a593Smuzhiyun error_usb_tx_setup:
111*4882a593Smuzhiyun d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
112*4882a593Smuzhiyun return result;
113*4882a593Smuzhiyun }
114*4882a593Smuzhiyun
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun static
i2400mu_bus_dev_stop(struct i2400m * i2400m)117*4882a593Smuzhiyun void i2400mu_bus_dev_stop(struct i2400m *i2400m)
118*4882a593Smuzhiyun {
119*4882a593Smuzhiyun struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
120*4882a593Smuzhiyun struct device *dev = &i2400mu->usb_iface->dev;
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
123*4882a593Smuzhiyun i2400mu_notification_release(i2400mu);
124*4882a593Smuzhiyun i2400mu_rx_release(i2400mu);
125*4882a593Smuzhiyun i2400mu_tx_release(i2400mu);
126*4882a593Smuzhiyun d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
127*4882a593Smuzhiyun }
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun
130*4882a593Smuzhiyun /*
131*4882a593Smuzhiyun * Sends a barker buffer to the device
132*4882a593Smuzhiyun *
133*4882a593Smuzhiyun * This helper will allocate a kmalloced buffer and use it to transmit
134*4882a593Smuzhiyun * (then free it). Reason for this is that other arches cannot use
135*4882a593Smuzhiyun * stack/vmalloc/text areas for DMA transfers.
136*4882a593Smuzhiyun *
137*4882a593Smuzhiyun * Error recovery here is simpler: anything is considered a hard error
138*4882a593Smuzhiyun * and will move the reset code to use a last-resort bus-based reset.
139*4882a593Smuzhiyun */
140*4882a593Smuzhiyun static
__i2400mu_send_barker(struct i2400mu * i2400mu,const __le32 * barker,size_t barker_size,unsigned endpoint)141*4882a593Smuzhiyun int __i2400mu_send_barker(struct i2400mu *i2400mu,
142*4882a593Smuzhiyun const __le32 *barker,
143*4882a593Smuzhiyun size_t barker_size,
144*4882a593Smuzhiyun unsigned endpoint)
145*4882a593Smuzhiyun {
146*4882a593Smuzhiyun struct usb_endpoint_descriptor *epd = NULL;
147*4882a593Smuzhiyun int pipe, actual_len, ret;
148*4882a593Smuzhiyun struct device *dev = &i2400mu->usb_iface->dev;
149*4882a593Smuzhiyun void *buffer;
150*4882a593Smuzhiyun int do_autopm = 1;
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun ret = usb_autopm_get_interface(i2400mu->usb_iface);
153*4882a593Smuzhiyun if (ret < 0) {
154*4882a593Smuzhiyun dev_err(dev, "RESET: can't get autopm: %d\n", ret);
155*4882a593Smuzhiyun do_autopm = 0;
156*4882a593Smuzhiyun }
157*4882a593Smuzhiyun ret = -ENOMEM;
158*4882a593Smuzhiyun buffer = kmalloc(barker_size, GFP_KERNEL);
159*4882a593Smuzhiyun if (buffer == NULL)
160*4882a593Smuzhiyun goto error_kzalloc;
161*4882a593Smuzhiyun epd = usb_get_epd(i2400mu->usb_iface, endpoint);
162*4882a593Smuzhiyun pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
163*4882a593Smuzhiyun memcpy(buffer, barker, barker_size);
164*4882a593Smuzhiyun retry:
165*4882a593Smuzhiyun ret = usb_bulk_msg(i2400mu->usb_dev, pipe, buffer, barker_size,
166*4882a593Smuzhiyun &actual_len, 200);
167*4882a593Smuzhiyun switch (ret) {
168*4882a593Smuzhiyun case 0:
169*4882a593Smuzhiyun if (actual_len != barker_size) { /* Too short? drop it */
170*4882a593Smuzhiyun dev_err(dev, "E: %s: short write (%d B vs %zu "
171*4882a593Smuzhiyun "expected)\n",
172*4882a593Smuzhiyun __func__, actual_len, barker_size);
173*4882a593Smuzhiyun ret = -EIO;
174*4882a593Smuzhiyun }
175*4882a593Smuzhiyun break;
176*4882a593Smuzhiyun case -EPIPE:
177*4882a593Smuzhiyun /*
178*4882a593Smuzhiyun * Stall -- maybe the device is choking with our
179*4882a593Smuzhiyun * requests. Clear it and give it some time. If they
180*4882a593Smuzhiyun * happen to often, it might be another symptom, so we
181*4882a593Smuzhiyun * reset.
182*4882a593Smuzhiyun *
183*4882a593Smuzhiyun * No error handling for usb_clear_halt(0; if it
184*4882a593Smuzhiyun * works, the retry works; if it fails, this switch
185*4882a593Smuzhiyun * does the error handling for us.
186*4882a593Smuzhiyun */
187*4882a593Smuzhiyun if (edc_inc(&i2400mu->urb_edc,
188*4882a593Smuzhiyun 10 * EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
189*4882a593Smuzhiyun dev_err(dev, "E: %s: too many stalls in "
190*4882a593Smuzhiyun "URB; resetting device\n", __func__);
191*4882a593Smuzhiyun usb_queue_reset_device(i2400mu->usb_iface);
192*4882a593Smuzhiyun /* fallthrough */
193*4882a593Smuzhiyun } else {
194*4882a593Smuzhiyun usb_clear_halt(i2400mu->usb_dev, pipe);
195*4882a593Smuzhiyun msleep(10); /* give the device some time */
196*4882a593Smuzhiyun goto retry;
197*4882a593Smuzhiyun }
198*4882a593Smuzhiyun fallthrough;
199*4882a593Smuzhiyun case -EINVAL: /* while removing driver */
200*4882a593Smuzhiyun case -ENODEV: /* dev disconnect ... */
201*4882a593Smuzhiyun case -ENOENT: /* just ignore it */
202*4882a593Smuzhiyun case -ESHUTDOWN: /* and exit */
203*4882a593Smuzhiyun case -ECONNRESET:
204*4882a593Smuzhiyun ret = -ESHUTDOWN;
205*4882a593Smuzhiyun break;
206*4882a593Smuzhiyun default: /* Some error? */
207*4882a593Smuzhiyun if (edc_inc(&i2400mu->urb_edc,
208*4882a593Smuzhiyun EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
209*4882a593Smuzhiyun dev_err(dev, "E: %s: maximum errors in URB "
210*4882a593Smuzhiyun "exceeded; resetting device\n",
211*4882a593Smuzhiyun __func__);
212*4882a593Smuzhiyun usb_queue_reset_device(i2400mu->usb_iface);
213*4882a593Smuzhiyun } else {
214*4882a593Smuzhiyun dev_warn(dev, "W: %s: cannot send URB: %d\n",
215*4882a593Smuzhiyun __func__, ret);
216*4882a593Smuzhiyun goto retry;
217*4882a593Smuzhiyun }
218*4882a593Smuzhiyun }
219*4882a593Smuzhiyun kfree(buffer);
220*4882a593Smuzhiyun error_kzalloc:
221*4882a593Smuzhiyun if (do_autopm)
222*4882a593Smuzhiyun usb_autopm_put_interface(i2400mu->usb_iface);
223*4882a593Smuzhiyun return ret;
224*4882a593Smuzhiyun }
225*4882a593Smuzhiyun
226*4882a593Smuzhiyun
227*4882a593Smuzhiyun /*
228*4882a593Smuzhiyun * Reset a device at different levels (warm, cold or bus)
229*4882a593Smuzhiyun *
230*4882a593Smuzhiyun * @i2400m: device descriptor
231*4882a593Smuzhiyun * @reset_type: soft, warm or bus reset (I2400M_RT_WARM/SOFT/BUS)
232*4882a593Smuzhiyun *
233*4882a593Smuzhiyun * Warm and cold resets get a USB reset if they fail.
234*4882a593Smuzhiyun *
235*4882a593Smuzhiyun * Warm reset:
236*4882a593Smuzhiyun *
237*4882a593Smuzhiyun * The device will be fully reset internally, but won't be
238*4882a593Smuzhiyun * disconnected from the USB bus (so no reenumeration will
239*4882a593Smuzhiyun * happen). Firmware upload will be necessary.
240*4882a593Smuzhiyun *
241*4882a593Smuzhiyun * The device will send a reboot barker in the notification endpoint
242*4882a593Smuzhiyun * that will trigger the driver to reinitialize the state
243*4882a593Smuzhiyun * automatically from notif.c:i2400m_notification_grok() into
244*4882a593Smuzhiyun * i2400m_dev_bootstrap_delayed().
245*4882a593Smuzhiyun *
246*4882a593Smuzhiyun * Cold and bus (USB) reset:
247*4882a593Smuzhiyun *
248*4882a593Smuzhiyun * The device will be fully reset internally, disconnected from the
249*4882a593Smuzhiyun * USB bus an a reenumeration will happen. Firmware upload will be
250*4882a593Smuzhiyun * necessary. Thus, we don't do any locking or struct
251*4882a593Smuzhiyun * reinitialization, as we are going to be fully disconnected and
252*4882a593Smuzhiyun * reenumerated.
253*4882a593Smuzhiyun *
254*4882a593Smuzhiyun * Note we need to return -ENODEV if a warm reset was requested and we
255*4882a593Smuzhiyun * had to resort to a bus reset. See i2400m_op_reset(), wimax_reset()
256*4882a593Smuzhiyun * and wimax_dev->op_reset.
257*4882a593Smuzhiyun *
258*4882a593Smuzhiyun * WARNING: no driver state saved/fixed
259*4882a593Smuzhiyun */
260*4882a593Smuzhiyun static
i2400mu_bus_reset(struct i2400m * i2400m,enum i2400m_reset_type rt)261*4882a593Smuzhiyun int i2400mu_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
262*4882a593Smuzhiyun {
263*4882a593Smuzhiyun int result;
264*4882a593Smuzhiyun struct i2400mu *i2400mu =
265*4882a593Smuzhiyun container_of(i2400m, struct i2400mu, i2400m);
266*4882a593Smuzhiyun struct device *dev = i2400m_dev(i2400m);
267*4882a593Smuzhiyun static const __le32 i2400m_WARM_BOOT_BARKER[4] = {
268*4882a593Smuzhiyun cpu_to_le32(I2400M_WARM_RESET_BARKER),
269*4882a593Smuzhiyun cpu_to_le32(I2400M_WARM_RESET_BARKER),
270*4882a593Smuzhiyun cpu_to_le32(I2400M_WARM_RESET_BARKER),
271*4882a593Smuzhiyun cpu_to_le32(I2400M_WARM_RESET_BARKER),
272*4882a593Smuzhiyun };
273*4882a593Smuzhiyun static const __le32 i2400m_COLD_BOOT_BARKER[4] = {
274*4882a593Smuzhiyun cpu_to_le32(I2400M_COLD_RESET_BARKER),
275*4882a593Smuzhiyun cpu_to_le32(I2400M_COLD_RESET_BARKER),
276*4882a593Smuzhiyun cpu_to_le32(I2400M_COLD_RESET_BARKER),
277*4882a593Smuzhiyun cpu_to_le32(I2400M_COLD_RESET_BARKER),
278*4882a593Smuzhiyun };
279*4882a593Smuzhiyun
280*4882a593Smuzhiyun d_fnstart(3, dev, "(i2400m %p rt %u)\n", i2400m, rt);
281*4882a593Smuzhiyun if (rt == I2400M_RT_WARM)
282*4882a593Smuzhiyun result = __i2400mu_send_barker(
283*4882a593Smuzhiyun i2400mu, i2400m_WARM_BOOT_BARKER,
284*4882a593Smuzhiyun sizeof(i2400m_WARM_BOOT_BARKER),
285*4882a593Smuzhiyun i2400mu->endpoint_cfg.bulk_out);
286*4882a593Smuzhiyun else if (rt == I2400M_RT_COLD)
287*4882a593Smuzhiyun result = __i2400mu_send_barker(
288*4882a593Smuzhiyun i2400mu, i2400m_COLD_BOOT_BARKER,
289*4882a593Smuzhiyun sizeof(i2400m_COLD_BOOT_BARKER),
290*4882a593Smuzhiyun i2400mu->endpoint_cfg.reset_cold);
291*4882a593Smuzhiyun else if (rt == I2400M_RT_BUS) {
292*4882a593Smuzhiyun result = usb_reset_device(i2400mu->usb_dev);
293*4882a593Smuzhiyun switch (result) {
294*4882a593Smuzhiyun case 0:
295*4882a593Smuzhiyun case -EINVAL: /* device is gone */
296*4882a593Smuzhiyun case -ENODEV:
297*4882a593Smuzhiyun case -ENOENT:
298*4882a593Smuzhiyun case -ESHUTDOWN:
299*4882a593Smuzhiyun result = 0;
300*4882a593Smuzhiyun break; /* We assume the device is disconnected */
301*4882a593Smuzhiyun default:
302*4882a593Smuzhiyun dev_err(dev, "USB reset failed (%d), giving up!\n",
303*4882a593Smuzhiyun result);
304*4882a593Smuzhiyun }
305*4882a593Smuzhiyun } else {
306*4882a593Smuzhiyun result = -EINVAL; /* shut gcc up in certain arches */
307*4882a593Smuzhiyun BUG();
308*4882a593Smuzhiyun }
309*4882a593Smuzhiyun if (result < 0
310*4882a593Smuzhiyun && result != -EINVAL /* device is gone */
311*4882a593Smuzhiyun && rt != I2400M_RT_BUS) {
312*4882a593Smuzhiyun /*
313*4882a593Smuzhiyun * Things failed -- resort to lower level reset, that
314*4882a593Smuzhiyun * we queue in another context; the reason for this is
315*4882a593Smuzhiyun * that the pre and post reset functionality requires
316*4882a593Smuzhiyun * the i2400m->init_mutex; RT_WARM and RT_COLD can
317*4882a593Smuzhiyun * come from areas where i2400m->init_mutex is taken.
318*4882a593Smuzhiyun */
319*4882a593Smuzhiyun dev_err(dev, "%s reset failed (%d); trying USB reset\n",
320*4882a593Smuzhiyun rt == I2400M_RT_WARM ? "warm" : "cold", result);
321*4882a593Smuzhiyun usb_queue_reset_device(i2400mu->usb_iface);
322*4882a593Smuzhiyun result = -ENODEV;
323*4882a593Smuzhiyun }
324*4882a593Smuzhiyun d_fnend(3, dev, "(i2400m %p rt %u) = %d\n", i2400m, rt, result);
325*4882a593Smuzhiyun return result;
326*4882a593Smuzhiyun }
327*4882a593Smuzhiyun
i2400mu_get_drvinfo(struct net_device * net_dev,struct ethtool_drvinfo * info)328*4882a593Smuzhiyun static void i2400mu_get_drvinfo(struct net_device *net_dev,
329*4882a593Smuzhiyun struct ethtool_drvinfo *info)
330*4882a593Smuzhiyun {
331*4882a593Smuzhiyun struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
332*4882a593Smuzhiyun struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
333*4882a593Smuzhiyun struct usb_device *udev = i2400mu->usb_dev;
334*4882a593Smuzhiyun
335*4882a593Smuzhiyun strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
336*4882a593Smuzhiyun strlcpy(info->fw_version, i2400m->fw_name ? : "",
337*4882a593Smuzhiyun sizeof(info->fw_version));
338*4882a593Smuzhiyun usb_make_path(udev, info->bus_info, sizeof(info->bus_info));
339*4882a593Smuzhiyun }
340*4882a593Smuzhiyun
341*4882a593Smuzhiyun static const struct ethtool_ops i2400mu_ethtool_ops = {
342*4882a593Smuzhiyun .get_drvinfo = i2400mu_get_drvinfo,
343*4882a593Smuzhiyun .get_link = ethtool_op_get_link,
344*4882a593Smuzhiyun };
345*4882a593Smuzhiyun
346*4882a593Smuzhiyun static
i2400mu_netdev_setup(struct net_device * net_dev)347*4882a593Smuzhiyun void i2400mu_netdev_setup(struct net_device *net_dev)
348*4882a593Smuzhiyun {
349*4882a593Smuzhiyun struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
350*4882a593Smuzhiyun struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
351*4882a593Smuzhiyun i2400mu_init(i2400mu);
352*4882a593Smuzhiyun i2400m_netdev_setup(net_dev);
353*4882a593Smuzhiyun net_dev->ethtool_ops = &i2400mu_ethtool_ops;
354*4882a593Smuzhiyun }
355*4882a593Smuzhiyun
356*4882a593Smuzhiyun
357*4882a593Smuzhiyun /*
358*4882a593Smuzhiyun * Debug levels control; see debug.h
359*4882a593Smuzhiyun */
360*4882a593Smuzhiyun struct d_level D_LEVEL[] = {
361*4882a593Smuzhiyun D_SUBMODULE_DEFINE(usb),
362*4882a593Smuzhiyun D_SUBMODULE_DEFINE(fw),
363*4882a593Smuzhiyun D_SUBMODULE_DEFINE(notif),
364*4882a593Smuzhiyun D_SUBMODULE_DEFINE(rx),
365*4882a593Smuzhiyun D_SUBMODULE_DEFINE(tx),
366*4882a593Smuzhiyun };
367*4882a593Smuzhiyun size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
368*4882a593Smuzhiyun
369*4882a593Smuzhiyun static
i2400mu_debugfs_add(struct i2400mu * i2400mu)370*4882a593Smuzhiyun void i2400mu_debugfs_add(struct i2400mu *i2400mu)
371*4882a593Smuzhiyun {
372*4882a593Smuzhiyun struct dentry *dentry = i2400mu->i2400m.wimax_dev.debugfs_dentry;
373*4882a593Smuzhiyun
374*4882a593Smuzhiyun dentry = debugfs_create_dir("i2400m-usb", dentry);
375*4882a593Smuzhiyun i2400mu->debugfs_dentry = dentry;
376*4882a593Smuzhiyun
377*4882a593Smuzhiyun d_level_register_debugfs("dl_", usb, dentry);
378*4882a593Smuzhiyun d_level_register_debugfs("dl_", fw, dentry);
379*4882a593Smuzhiyun d_level_register_debugfs("dl_", notif, dentry);
380*4882a593Smuzhiyun d_level_register_debugfs("dl_", rx, dentry);
381*4882a593Smuzhiyun d_level_register_debugfs("dl_", tx, dentry);
382*4882a593Smuzhiyun
383*4882a593Smuzhiyun /* Don't touch these if you don't know what you are doing */
384*4882a593Smuzhiyun debugfs_create_u8("rx_size_auto_shrink", 0600, dentry,
385*4882a593Smuzhiyun &i2400mu->rx_size_auto_shrink);
386*4882a593Smuzhiyun
387*4882a593Smuzhiyun debugfs_create_size_t("rx_size", 0600, dentry, &i2400mu->rx_size);
388*4882a593Smuzhiyun }
389*4882a593Smuzhiyun
390*4882a593Smuzhiyun
391*4882a593Smuzhiyun static struct device_type i2400mu_type = {
392*4882a593Smuzhiyun .name = "wimax",
393*4882a593Smuzhiyun };
394*4882a593Smuzhiyun
395*4882a593Smuzhiyun /*
396*4882a593Smuzhiyun * Probe a i2400m interface and register it
397*4882a593Smuzhiyun *
398*4882a593Smuzhiyun * @iface: USB interface to link to
399*4882a593Smuzhiyun * @id: USB class/subclass/protocol id
400*4882a593Smuzhiyun * @returns: 0 if ok, < 0 errno code on error.
401*4882a593Smuzhiyun *
402*4882a593Smuzhiyun * Alloc a net device, initialize the bus-specific details and then
403*4882a593Smuzhiyun * calls the bus-generic initialization routine. That will register
404*4882a593Smuzhiyun * the wimax and netdev devices, upload the firmware [using
405*4882a593Smuzhiyun * _bus_bm_*()], call _bus_dev_start() to finalize the setup of the
406*4882a593Smuzhiyun * communication with the device and then will start to talk to it to
407*4882a593Smuzhiyun * finnish setting it up.
408*4882a593Smuzhiyun */
409*4882a593Smuzhiyun static
i2400mu_probe(struct usb_interface * iface,const struct usb_device_id * id)410*4882a593Smuzhiyun int i2400mu_probe(struct usb_interface *iface,
411*4882a593Smuzhiyun const struct usb_device_id *id)
412*4882a593Smuzhiyun {
413*4882a593Smuzhiyun int result;
414*4882a593Smuzhiyun struct net_device *net_dev;
415*4882a593Smuzhiyun struct device *dev = &iface->dev;
416*4882a593Smuzhiyun struct i2400m *i2400m;
417*4882a593Smuzhiyun struct i2400mu *i2400mu;
418*4882a593Smuzhiyun struct usb_device *usb_dev = interface_to_usbdev(iface);
419*4882a593Smuzhiyun
420*4882a593Smuzhiyun if (iface->cur_altsetting->desc.bNumEndpoints < 4)
421*4882a593Smuzhiyun return -ENODEV;
422*4882a593Smuzhiyun
423*4882a593Smuzhiyun if (usb_dev->speed != USB_SPEED_HIGH)
424*4882a593Smuzhiyun dev_err(dev, "device not connected as high speed\n");
425*4882a593Smuzhiyun
426*4882a593Smuzhiyun /* Allocate instance [calls i2400m_netdev_setup() on it]. */
427*4882a593Smuzhiyun result = -ENOMEM;
428*4882a593Smuzhiyun net_dev = alloc_netdev(sizeof(*i2400mu), "wmx%d", NET_NAME_UNKNOWN,
429*4882a593Smuzhiyun i2400mu_netdev_setup);
430*4882a593Smuzhiyun if (net_dev == NULL) {
431*4882a593Smuzhiyun dev_err(dev, "no memory for network device instance\n");
432*4882a593Smuzhiyun goto error_alloc_netdev;
433*4882a593Smuzhiyun }
434*4882a593Smuzhiyun SET_NETDEV_DEV(net_dev, dev);
435*4882a593Smuzhiyun SET_NETDEV_DEVTYPE(net_dev, &i2400mu_type);
436*4882a593Smuzhiyun i2400m = net_dev_to_i2400m(net_dev);
437*4882a593Smuzhiyun i2400mu = container_of(i2400m, struct i2400mu, i2400m);
438*4882a593Smuzhiyun i2400m->wimax_dev.net_dev = net_dev;
439*4882a593Smuzhiyun i2400mu->usb_dev = usb_get_dev(usb_dev);
440*4882a593Smuzhiyun i2400mu->usb_iface = iface;
441*4882a593Smuzhiyun usb_set_intfdata(iface, i2400mu);
442*4882a593Smuzhiyun
443*4882a593Smuzhiyun i2400m->bus_tx_block_size = I2400MU_BLK_SIZE;
444*4882a593Smuzhiyun /*
445*4882a593Smuzhiyun * Room required in the Tx queue for USB message to accommodate
446*4882a593Smuzhiyun * a smallest payload while allocating header space is 16 bytes.
447*4882a593Smuzhiyun * Adding this room for the new tx message increases the
448*4882a593Smuzhiyun * possibilities of including any payload with size <= 16 bytes.
449*4882a593Smuzhiyun */
450*4882a593Smuzhiyun i2400m->bus_tx_room_min = I2400MU_BLK_SIZE;
451*4882a593Smuzhiyun i2400m->bus_pl_size_max = I2400MU_PL_SIZE_MAX;
452*4882a593Smuzhiyun i2400m->bus_setup = NULL;
453*4882a593Smuzhiyun i2400m->bus_dev_start = i2400mu_bus_dev_start;
454*4882a593Smuzhiyun i2400m->bus_dev_stop = i2400mu_bus_dev_stop;
455*4882a593Smuzhiyun i2400m->bus_release = NULL;
456*4882a593Smuzhiyun i2400m->bus_tx_kick = i2400mu_bus_tx_kick;
457*4882a593Smuzhiyun i2400m->bus_reset = i2400mu_bus_reset;
458*4882a593Smuzhiyun i2400m->bus_bm_retries = I2400M_USB_BOOT_RETRIES;
459*4882a593Smuzhiyun i2400m->bus_bm_cmd_send = i2400mu_bus_bm_cmd_send;
460*4882a593Smuzhiyun i2400m->bus_bm_wait_for_ack = i2400mu_bus_bm_wait_for_ack;
461*4882a593Smuzhiyun i2400m->bus_bm_mac_addr_impaired = 0;
462*4882a593Smuzhiyun
463*4882a593Smuzhiyun switch (id->idProduct) {
464*4882a593Smuzhiyun case USB_DEVICE_ID_I6050:
465*4882a593Smuzhiyun case USB_DEVICE_ID_I6050_2:
466*4882a593Smuzhiyun case USB_DEVICE_ID_I6150:
467*4882a593Smuzhiyun case USB_DEVICE_ID_I6150_2:
468*4882a593Smuzhiyun case USB_DEVICE_ID_I6150_3:
469*4882a593Smuzhiyun case USB_DEVICE_ID_I6250:
470*4882a593Smuzhiyun i2400mu->i6050 = 1;
471*4882a593Smuzhiyun break;
472*4882a593Smuzhiyun default:
473*4882a593Smuzhiyun break;
474*4882a593Smuzhiyun }
475*4882a593Smuzhiyun
476*4882a593Smuzhiyun if (i2400mu->i6050) {
477*4882a593Smuzhiyun i2400m->bus_fw_names = i2400mu_bus_fw_names_6050;
478*4882a593Smuzhiyun i2400mu->endpoint_cfg.bulk_out = 0;
479*4882a593Smuzhiyun i2400mu->endpoint_cfg.notification = 3;
480*4882a593Smuzhiyun i2400mu->endpoint_cfg.reset_cold = 2;
481*4882a593Smuzhiyun i2400mu->endpoint_cfg.bulk_in = 1;
482*4882a593Smuzhiyun } else {
483*4882a593Smuzhiyun i2400m->bus_fw_names = i2400mu_bus_fw_names_5x50;
484*4882a593Smuzhiyun i2400mu->endpoint_cfg.bulk_out = 0;
485*4882a593Smuzhiyun i2400mu->endpoint_cfg.notification = 1;
486*4882a593Smuzhiyun i2400mu->endpoint_cfg.reset_cold = 2;
487*4882a593Smuzhiyun i2400mu->endpoint_cfg.bulk_in = 3;
488*4882a593Smuzhiyun }
489*4882a593Smuzhiyun #ifdef CONFIG_PM
490*4882a593Smuzhiyun iface->needs_remote_wakeup = 1; /* autosuspend (15s delay) */
491*4882a593Smuzhiyun device_init_wakeup(dev, 1);
492*4882a593Smuzhiyun pm_runtime_set_autosuspend_delay(&usb_dev->dev, 15000);
493*4882a593Smuzhiyun usb_enable_autosuspend(usb_dev);
494*4882a593Smuzhiyun #endif
495*4882a593Smuzhiyun
496*4882a593Smuzhiyun result = i2400m_setup(i2400m, I2400M_BRI_MAC_REINIT);
497*4882a593Smuzhiyun if (result < 0) {
498*4882a593Smuzhiyun dev_err(dev, "cannot setup device: %d\n", result);
499*4882a593Smuzhiyun goto error_setup;
500*4882a593Smuzhiyun }
501*4882a593Smuzhiyun i2400mu_debugfs_add(i2400mu);
502*4882a593Smuzhiyun return 0;
503*4882a593Smuzhiyun
504*4882a593Smuzhiyun error_setup:
505*4882a593Smuzhiyun usb_set_intfdata(iface, NULL);
506*4882a593Smuzhiyun usb_put_dev(i2400mu->usb_dev);
507*4882a593Smuzhiyun free_netdev(net_dev);
508*4882a593Smuzhiyun error_alloc_netdev:
509*4882a593Smuzhiyun return result;
510*4882a593Smuzhiyun }
511*4882a593Smuzhiyun
512*4882a593Smuzhiyun
513*4882a593Smuzhiyun /*
514*4882a593Smuzhiyun * Disconnect a i2400m from the system.
515*4882a593Smuzhiyun *
516*4882a593Smuzhiyun * i2400m_stop() has been called before, so al the rx and tx contexts
517*4882a593Smuzhiyun * have been taken down already. Make sure the queue is stopped,
518*4882a593Smuzhiyun * unregister netdev and i2400m, free and kill.
519*4882a593Smuzhiyun */
520*4882a593Smuzhiyun static
i2400mu_disconnect(struct usb_interface * iface)521*4882a593Smuzhiyun void i2400mu_disconnect(struct usb_interface *iface)
522*4882a593Smuzhiyun {
523*4882a593Smuzhiyun struct i2400mu *i2400mu = usb_get_intfdata(iface);
524*4882a593Smuzhiyun struct i2400m *i2400m = &i2400mu->i2400m;
525*4882a593Smuzhiyun struct net_device *net_dev = i2400m->wimax_dev.net_dev;
526*4882a593Smuzhiyun struct device *dev = &iface->dev;
527*4882a593Smuzhiyun
528*4882a593Smuzhiyun d_fnstart(3, dev, "(iface %p i2400m %p)\n", iface, i2400m);
529*4882a593Smuzhiyun
530*4882a593Smuzhiyun debugfs_remove_recursive(i2400mu->debugfs_dentry);
531*4882a593Smuzhiyun i2400m_release(i2400m);
532*4882a593Smuzhiyun usb_set_intfdata(iface, NULL);
533*4882a593Smuzhiyun usb_put_dev(i2400mu->usb_dev);
534*4882a593Smuzhiyun free_netdev(net_dev);
535*4882a593Smuzhiyun d_fnend(3, dev, "(iface %p i2400m %p) = void\n", iface, i2400m);
536*4882a593Smuzhiyun }
537*4882a593Smuzhiyun
538*4882a593Smuzhiyun
539*4882a593Smuzhiyun /*
540*4882a593Smuzhiyun * Get the device ready for USB port or system standby and hibernation
541*4882a593Smuzhiyun *
542*4882a593Smuzhiyun * USB port and system standby are handled the same.
543*4882a593Smuzhiyun *
544*4882a593Smuzhiyun * When the system hibernates, the USB device is powered down and then
545*4882a593Smuzhiyun * up, so we don't really have to do much here, as it will be seen as
546*4882a593Smuzhiyun * a reconnect. Still for simplicity we consider this case the same as
547*4882a593Smuzhiyun * suspend, so that the device has a chance to do notify the base
548*4882a593Smuzhiyun * station (if connected).
549*4882a593Smuzhiyun *
550*4882a593Smuzhiyun * So at the end, the three cases require common handling.
551*4882a593Smuzhiyun *
552*4882a593Smuzhiyun * If at the time of this call the device's firmware is not loaded,
553*4882a593Smuzhiyun * nothing has to be done. Note we can be "loose" about not reading
554*4882a593Smuzhiyun * i2400m->updown under i2400m->init_mutex. If it happens to change
555*4882a593Smuzhiyun * inmediately, other parts of the call flow will fail and effectively
556*4882a593Smuzhiyun * catch it.
557*4882a593Smuzhiyun *
558*4882a593Smuzhiyun * If the firmware is loaded, we need to:
559*4882a593Smuzhiyun *
560*4882a593Smuzhiyun * - tell the device to go into host interface power save mode, wait
561*4882a593Smuzhiyun * for it to ack
562*4882a593Smuzhiyun *
563*4882a593Smuzhiyun * This is quite more interesting than it is; we need to execute a
564*4882a593Smuzhiyun * command, but this time, we don't want the code in usb-{tx,rx}.c
565*4882a593Smuzhiyun * to call the usb_autopm_get/put_interface() barriers as it'd
566*4882a593Smuzhiyun * deadlock, so we need to decrement i2400mu->do_autopm, that acts
567*4882a593Smuzhiyun * as a poor man's semaphore. Ugly, but it works.
568*4882a593Smuzhiyun *
569*4882a593Smuzhiyun * As well, the device might refuse going to sleep for whichever
570*4882a593Smuzhiyun * reason. In this case we just fail. For system suspend/hibernate,
571*4882a593Smuzhiyun * we *can't* fail. We check PMSG_IS_AUTO to see if the
572*4882a593Smuzhiyun * suspend call comes from the USB stack or from the system and act
573*4882a593Smuzhiyun * in consequence.
574*4882a593Smuzhiyun *
575*4882a593Smuzhiyun * - stop the notification endpoint polling
576*4882a593Smuzhiyun */
577*4882a593Smuzhiyun static
i2400mu_suspend(struct usb_interface * iface,pm_message_t pm_msg)578*4882a593Smuzhiyun int i2400mu_suspend(struct usb_interface *iface, pm_message_t pm_msg)
579*4882a593Smuzhiyun {
580*4882a593Smuzhiyun int result = 0;
581*4882a593Smuzhiyun struct device *dev = &iface->dev;
582*4882a593Smuzhiyun struct i2400mu *i2400mu = usb_get_intfdata(iface);
583*4882a593Smuzhiyun unsigned is_autosuspend = 0;
584*4882a593Smuzhiyun struct i2400m *i2400m = &i2400mu->i2400m;
585*4882a593Smuzhiyun
586*4882a593Smuzhiyun #ifdef CONFIG_PM
587*4882a593Smuzhiyun if (PMSG_IS_AUTO(pm_msg))
588*4882a593Smuzhiyun is_autosuspend = 1;
589*4882a593Smuzhiyun #endif
590*4882a593Smuzhiyun
591*4882a593Smuzhiyun d_fnstart(3, dev, "(iface %p pm_msg %u)\n", iface, pm_msg.event);
592*4882a593Smuzhiyun rmb(); /* see i2400m->updown's documentation */
593*4882a593Smuzhiyun if (i2400m->updown == 0)
594*4882a593Smuzhiyun goto no_firmware;
595*4882a593Smuzhiyun if (i2400m->state == I2400M_SS_DATA_PATH_CONNECTED && is_autosuspend) {
596*4882a593Smuzhiyun /* ugh -- the device is connected and this suspend
597*4882a593Smuzhiyun * request is an autosuspend one (not a system standby
598*4882a593Smuzhiyun * / hibernate).
599*4882a593Smuzhiyun *
600*4882a593Smuzhiyun * The only way the device can go to standby is if the
601*4882a593Smuzhiyun * link with the base station is in IDLE mode; that
602*4882a593Smuzhiyun * were the case, we'd be in status
603*4882a593Smuzhiyun * I2400M_SS_CONNECTED_IDLE. But we are not.
604*4882a593Smuzhiyun *
605*4882a593Smuzhiyun * If we *tell* him to go power save now, it'll reset
606*4882a593Smuzhiyun * as a precautionary measure, so if this is an
607*4882a593Smuzhiyun * autosuspend thing, say no and it'll come back
608*4882a593Smuzhiyun * later, when the link is IDLE
609*4882a593Smuzhiyun */
610*4882a593Smuzhiyun result = -EBADF;
611*4882a593Smuzhiyun d_printf(1, dev, "fw up, link up, not-idle, autosuspend: "
612*4882a593Smuzhiyun "not entering powersave\n");
613*4882a593Smuzhiyun goto error_not_now;
614*4882a593Smuzhiyun }
615*4882a593Smuzhiyun d_printf(1, dev, "fw up: entering powersave\n");
616*4882a593Smuzhiyun atomic_dec(&i2400mu->do_autopm);
617*4882a593Smuzhiyun result = i2400m_cmd_enter_powersave(i2400m);
618*4882a593Smuzhiyun atomic_inc(&i2400mu->do_autopm);
619*4882a593Smuzhiyun if (result < 0 && !is_autosuspend) {
620*4882a593Smuzhiyun /* System suspend, can't fail */
621*4882a593Smuzhiyun dev_err(dev, "failed to suspend, will reset on resume\n");
622*4882a593Smuzhiyun result = 0;
623*4882a593Smuzhiyun }
624*4882a593Smuzhiyun if (result < 0)
625*4882a593Smuzhiyun goto error_enter_powersave;
626*4882a593Smuzhiyun i2400mu_notification_release(i2400mu);
627*4882a593Smuzhiyun d_printf(1, dev, "powersave requested\n");
628*4882a593Smuzhiyun error_enter_powersave:
629*4882a593Smuzhiyun error_not_now:
630*4882a593Smuzhiyun no_firmware:
631*4882a593Smuzhiyun d_fnend(3, dev, "(iface %p pm_msg %u) = %d\n",
632*4882a593Smuzhiyun iface, pm_msg.event, result);
633*4882a593Smuzhiyun return result;
634*4882a593Smuzhiyun }
635*4882a593Smuzhiyun
636*4882a593Smuzhiyun
637*4882a593Smuzhiyun static
i2400mu_resume(struct usb_interface * iface)638*4882a593Smuzhiyun int i2400mu_resume(struct usb_interface *iface)
639*4882a593Smuzhiyun {
640*4882a593Smuzhiyun int ret = 0;
641*4882a593Smuzhiyun struct device *dev = &iface->dev;
642*4882a593Smuzhiyun struct i2400mu *i2400mu = usb_get_intfdata(iface);
643*4882a593Smuzhiyun struct i2400m *i2400m = &i2400mu->i2400m;
644*4882a593Smuzhiyun
645*4882a593Smuzhiyun d_fnstart(3, dev, "(iface %p)\n", iface);
646*4882a593Smuzhiyun rmb(); /* see i2400m->updown's documentation */
647*4882a593Smuzhiyun if (i2400m->updown == 0) {
648*4882a593Smuzhiyun d_printf(1, dev, "fw was down, no resume needed\n");
649*4882a593Smuzhiyun goto out;
650*4882a593Smuzhiyun }
651*4882a593Smuzhiyun d_printf(1, dev, "fw was up, resuming\n");
652*4882a593Smuzhiyun i2400mu_notification_setup(i2400mu);
653*4882a593Smuzhiyun /* USB has flow control, so we don't need to give it time to
654*4882a593Smuzhiyun * come back; otherwise, we'd use something like a get-state
655*4882a593Smuzhiyun * command... */
656*4882a593Smuzhiyun out:
657*4882a593Smuzhiyun d_fnend(3, dev, "(iface %p) = %d\n", iface, ret);
658*4882a593Smuzhiyun return ret;
659*4882a593Smuzhiyun }
660*4882a593Smuzhiyun
661*4882a593Smuzhiyun
662*4882a593Smuzhiyun static
i2400mu_reset_resume(struct usb_interface * iface)663*4882a593Smuzhiyun int i2400mu_reset_resume(struct usb_interface *iface)
664*4882a593Smuzhiyun {
665*4882a593Smuzhiyun int result;
666*4882a593Smuzhiyun struct device *dev = &iface->dev;
667*4882a593Smuzhiyun struct i2400mu *i2400mu = usb_get_intfdata(iface);
668*4882a593Smuzhiyun struct i2400m *i2400m = &i2400mu->i2400m;
669*4882a593Smuzhiyun
670*4882a593Smuzhiyun d_fnstart(3, dev, "(iface %p)\n", iface);
671*4882a593Smuzhiyun result = i2400m_dev_reset_handle(i2400m, "device reset on resume");
672*4882a593Smuzhiyun d_fnend(3, dev, "(iface %p) = %d\n", iface, result);
673*4882a593Smuzhiyun return result < 0 ? result : 0;
674*4882a593Smuzhiyun }
675*4882a593Smuzhiyun
676*4882a593Smuzhiyun
677*4882a593Smuzhiyun /*
678*4882a593Smuzhiyun * Another driver or user space is triggering a reset on the device
679*4882a593Smuzhiyun * which contains the interface passed as an argument. Cease IO and
680*4882a593Smuzhiyun * save any device state you need to restore.
681*4882a593Smuzhiyun *
682*4882a593Smuzhiyun * If you need to allocate memory here, use GFP_NOIO or GFP_ATOMIC, if
683*4882a593Smuzhiyun * you are in atomic context.
684*4882a593Smuzhiyun */
685*4882a593Smuzhiyun static
i2400mu_pre_reset(struct usb_interface * iface)686*4882a593Smuzhiyun int i2400mu_pre_reset(struct usb_interface *iface)
687*4882a593Smuzhiyun {
688*4882a593Smuzhiyun struct i2400mu *i2400mu = usb_get_intfdata(iface);
689*4882a593Smuzhiyun return i2400m_pre_reset(&i2400mu->i2400m);
690*4882a593Smuzhiyun }
691*4882a593Smuzhiyun
692*4882a593Smuzhiyun
693*4882a593Smuzhiyun /*
694*4882a593Smuzhiyun * The reset has completed. Restore any saved device state and begin
695*4882a593Smuzhiyun * using the device again.
696*4882a593Smuzhiyun *
697*4882a593Smuzhiyun * If you need to allocate memory here, use GFP_NOIO or GFP_ATOMIC, if
698*4882a593Smuzhiyun * you are in atomic context.
699*4882a593Smuzhiyun */
700*4882a593Smuzhiyun static
i2400mu_post_reset(struct usb_interface * iface)701*4882a593Smuzhiyun int i2400mu_post_reset(struct usb_interface *iface)
702*4882a593Smuzhiyun {
703*4882a593Smuzhiyun struct i2400mu *i2400mu = usb_get_intfdata(iface);
704*4882a593Smuzhiyun return i2400m_post_reset(&i2400mu->i2400m);
705*4882a593Smuzhiyun }
706*4882a593Smuzhiyun
707*4882a593Smuzhiyun
708*4882a593Smuzhiyun static
709*4882a593Smuzhiyun struct usb_device_id i2400mu_id_table[] = {
710*4882a593Smuzhiyun { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050) },
711*4882a593Smuzhiyun { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050_2) },
712*4882a593Smuzhiyun { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150) },
713*4882a593Smuzhiyun { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150_2) },
714*4882a593Smuzhiyun { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150_3) },
715*4882a593Smuzhiyun { USB_DEVICE(0x8086, USB_DEVICE_ID_I6250) },
716*4882a593Smuzhiyun { USB_DEVICE(0x8086, 0x0181) },
717*4882a593Smuzhiyun { USB_DEVICE(0x8086, 0x1403) },
718*4882a593Smuzhiyun { USB_DEVICE(0x8086, 0x1405) },
719*4882a593Smuzhiyun { USB_DEVICE(0x8086, 0x0180) },
720*4882a593Smuzhiyun { USB_DEVICE(0x8086, 0x0182) },
721*4882a593Smuzhiyun { USB_DEVICE(0x8086, 0x1406) },
722*4882a593Smuzhiyun { USB_DEVICE(0x8086, 0x1403) },
723*4882a593Smuzhiyun { },
724*4882a593Smuzhiyun };
725*4882a593Smuzhiyun MODULE_DEVICE_TABLE(usb, i2400mu_id_table);
726*4882a593Smuzhiyun
727*4882a593Smuzhiyun
728*4882a593Smuzhiyun static
729*4882a593Smuzhiyun struct usb_driver i2400mu_driver = {
730*4882a593Smuzhiyun .name = KBUILD_MODNAME,
731*4882a593Smuzhiyun .suspend = i2400mu_suspend,
732*4882a593Smuzhiyun .resume = i2400mu_resume,
733*4882a593Smuzhiyun .reset_resume = i2400mu_reset_resume,
734*4882a593Smuzhiyun .probe = i2400mu_probe,
735*4882a593Smuzhiyun .disconnect = i2400mu_disconnect,
736*4882a593Smuzhiyun .pre_reset = i2400mu_pre_reset,
737*4882a593Smuzhiyun .post_reset = i2400mu_post_reset,
738*4882a593Smuzhiyun .id_table = i2400mu_id_table,
739*4882a593Smuzhiyun .supports_autosuspend = 1,
740*4882a593Smuzhiyun };
741*4882a593Smuzhiyun
742*4882a593Smuzhiyun static
i2400mu_driver_init(void)743*4882a593Smuzhiyun int __init i2400mu_driver_init(void)
744*4882a593Smuzhiyun {
745*4882a593Smuzhiyun d_parse_params(D_LEVEL, D_LEVEL_SIZE, i2400mu_debug_params,
746*4882a593Smuzhiyun "i2400m_usb.debug");
747*4882a593Smuzhiyun return usb_register(&i2400mu_driver);
748*4882a593Smuzhiyun }
749*4882a593Smuzhiyun module_init(i2400mu_driver_init);
750*4882a593Smuzhiyun
751*4882a593Smuzhiyun
752*4882a593Smuzhiyun static
i2400mu_driver_exit(void)753*4882a593Smuzhiyun void __exit i2400mu_driver_exit(void)
754*4882a593Smuzhiyun {
755*4882a593Smuzhiyun usb_deregister(&i2400mu_driver);
756*4882a593Smuzhiyun }
757*4882a593Smuzhiyun module_exit(i2400mu_driver_exit);
758*4882a593Smuzhiyun
759*4882a593Smuzhiyun MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
760*4882a593Smuzhiyun MODULE_DESCRIPTION("Driver for USB based Intel Wireless WiMAX Connection 2400M "
761*4882a593Smuzhiyun "(5x50 & 6050)");
762*4882a593Smuzhiyun MODULE_LICENSE("GPL");
763*4882a593Smuzhiyun MODULE_FIRMWARE(I2400MU_FW_FILE_NAME_v1_5);
764*4882a593Smuzhiyun MODULE_FIRMWARE(I6050U_FW_FILE_NAME_v1_5);
765