summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-moorestown-ericsson-mbm-driver.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-moorestown-ericsson-mbm-driver.patch')
-rw-r--r--meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-moorestown-ericsson-mbm-driver.patch465
1 files changed, 465 insertions, 0 deletions
diff --git a/meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-moorestown-ericsson-mbm-driver.patch b/meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-moorestown-ericsson-mbm-driver.patch
new file mode 100644
index 0000000000..f34e2804df
--- /dev/null
+++ b/meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-moorestown-ericsson-mbm-driver.patch
@@ -0,0 +1,465 @@
1From b9a664ffe791221bd2d7bc625f8b288d7dc8549a Mon Sep 17 00:00:00 2001
2From: Jacob Pan <jacob.jun.pan@intel.com>
3Date: Mon, 4 Jan 2010 11:04:34 -0800
4Subject: [PATCH 057/104] Ericsson MBM Driver
5
6Signed-off-by: Jacob Pan <jacob.jun.pan@intel.com>
7---
8 drivers/net/usb/Kconfig | 17 ++
9 drivers/net/usb/Makefile | 1 +
10 drivers/net/usb/mbm.c | 375 ++++++++++++++++++++++++++++++++++++++++++++
11 drivers/net/usb/usbnet.c | 3 +
12 include/linux/usb/usbnet.h | 1 +
13 5 files changed, 397 insertions(+), 0 deletions(-)
14 create mode 100644 drivers/net/usb/mbm.c
15
16diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
17index 32d9356..adb6d4c 100644
18--- a/drivers/net/usb/Kconfig
19+++ b/drivers/net/usb/Kconfig
20@@ -361,6 +361,23 @@ config USB_HSO
21 To compile this driver as a module, choose M here: the
22 module will be called hso.
23
24+config USB_NET_MBM
25+ tristate "Ericsson Mobile Broadband Module"
26+ depends on USB_USBNET
27+ select USB_NET_CDCETHER
28+ default y
29+ help
30+ Choose this option to support Mobile Broadband devices from
31+ Ericsson MBM, Mobile Broadband Module.
32+ This driver should work with at least the following devices:
33+ * Ericsson Mobile Broadband Minicard
34+ * Ericsson F3507g Wireless Module
35+ * Ericsson F3607gw Broadband Module
36+ * Dell Wireless 5530 HSPA
37+ * Toshiba F3507g
38+ * Sony Ericsson EC400
39+ * Sony Ericsson MD400
40+
41 config USB_NET_INT51X1
42 tristate "Intellon PLC based usb adapter"
43 depends on USB_USBNET
44diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
45index e17afb7..82d5f60 100644
46--- a/drivers/net/usb/Makefile
47+++ b/drivers/net/usb/Makefile
48@@ -18,6 +18,7 @@ obj-$(CONFIG_USB_NET_PLUSB) += plusb.o
49 obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o
50 obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o
51 obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o
52+obj-$(CONFIG_USB_NET_MBM) += mbm.o
53 obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o
54 obj-$(CONFIG_USB_USBNET) += usbnet.o
55 obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o
56diff --git a/drivers/net/usb/mbm.c b/drivers/net/usb/mbm.c
57new file mode 100644
58index 0000000..4bb909b
59--- /dev/null
60+++ b/drivers/net/usb/mbm.c
61@@ -0,0 +1,375 @@
62+/* -*- linux-c -*-
63+ * Copyright (C) 2008 Carl Nordbeck <Carl.Nordbeck@ericsson.com>
64+ *
65+ * This program is free software; you can redistribute it and/or modify
66+ * it under the terms of the GNU General Public License as published by
67+ * the Free Software Foundation; either version 2 of the License, or
68+ * (at your option) any later version.
69+ *
70+ * This program is distributed in the hope that it will be useful,
71+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
72+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
73+ * GNU General Public License for more details.
74+ *
75+ * You should have received a copy of the GNU General Public License
76+ * along with this program; if not, write to the Free Software
77+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
78+ */
79+
80+#include <linux/module.h>
81+#include <linux/init.h>
82+#include <linux/netdevice.h>
83+#include <linux/ctype.h>
84+#include <linux/ethtool.h>
85+#include <linux/workqueue.h>
86+#include <linux/mii.h>
87+#include <linux/crc32.h>
88+#include <linux/usb.h>
89+#include <linux/usb/cdc.h>
90+#include <linux/usb/usbnet.h>
91+
92+#define DRIVER_VERSION "0.03"
93+
94+/* Bogus speed for bugy HSPA modems */
95+#define TX_LINK_SPEED 0x001E8480 /* 2.0 Mbps */
96+#define RX_LINK_SPEED 0x006DDD00 /* 7.2 Mbps */
97+#define FIX_SPEED 0x00989680 /* 10.0 Mbps */
98+
99+struct mbm_data {
100+ unsigned int rx_speed;
101+ unsigned int tx_speed;
102+ unsigned int connect;
103+};
104+
105+static const u8 mbm_guid[16] = {
106+ 0xa3, 0x17, 0xa8, 0x8b, 0x04, 0x5e, 0x4f, 0x01,
107+ 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a,
108+};
109+static void dumpspeed(struct usbnet *dev, __le32 *speeds)
110+{
111+ struct mbm_data *data = (void *)&dev->data;
112+
113+ data->rx_speed = __le32_to_cpu(speeds[0]);
114+ data->tx_speed = __le32_to_cpu(speeds[1]);
115+
116+ if (data->rx_speed == FIX_SPEED && data->tx_speed == FIX_SPEED) {
117+/* Bogus speed for buggy HSPA modems */
118+ dev_info(&dev->udev->dev,
119+ "link speeds: %u kbps RX, %u kbps TX\n",
120+ RX_LINK_SPEED / 1000, TX_LINK_SPEED / 1000);
121+
122+ data->rx_speed = RX_LINK_SPEED;
123+ data->tx_speed = TX_LINK_SPEED;
124+ } else
125+ dev_info(&dev->udev->dev,
126+ "link speeds: %u kbps RX, %u kbps TX\n",
127+ __le32_to_cpu(speeds[0]) / 1000,
128+ __le32_to_cpu(speeds[1]) / 1000);
129+}
130+
131+static void mbm_status(struct usbnet *dev, struct urb *urb)
132+{
133+ struct mbm_data *data = (void *)&dev->data;
134+ struct usb_cdc_notification *event;
135+
136+ if (urb->actual_length < sizeof(*event))
137+ return;
138+
139+ /* SPEED_CHANGE can get split into two 8-byte packets */
140+ if (test_and_clear_bit(EVENT_STS_SPLIT, &dev->flags)) {
141+ dumpspeed(dev, (__le32 *) urb->transfer_buffer);
142+ return;
143+ }
144+
145+ event = urb->transfer_buffer;
146+ switch (event->bNotificationType) {
147+ case USB_CDC_NOTIFY_NETWORK_CONNECTION:
148+ data->connect = event->wValue;
149+ if (netif_msg_timer(dev))
150+ dev_dbg(&dev->udev->dev, "CDC: carrier %s\n",
151+ data->connect ? "on" : "off");
152+ if (event->wValue)
153+ netif_carrier_on(dev->net);
154+ else
155+ netif_carrier_off(dev->net);
156+ break;
157+ case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
158+ if (netif_msg_timer(dev))
159+ dev_dbg(&dev->udev->dev, "CDC: speed change (len %d)\n",
160+ urb->actual_length);
161+ if (urb->actual_length != (sizeof(*event) + 8))
162+ set_bit(EVENT_STS_SPLIT, &dev->flags);
163+ else
164+ dumpspeed(dev, (__le32 *) &event[1]);
165+ break;
166+ default:
167+ dev_err(&dev->udev->dev, "CDC: unexpected notification %02x!\n",
168+ event->bNotificationType);
169+ break;
170+ }
171+}
172+
173+static u8 nibble(unsigned char c)
174+{
175+ if (likely(isdigit(c)))
176+ return c - '0';
177+ c = toupper(c);
178+ if (likely(isxdigit(c)))
179+ return 10 + c - 'A';
180+ return 0;
181+}
182+
183+static inline int
184+get_ethernet_addr(struct usbnet *dev, struct usb_cdc_ether_desc *e)
185+{
186+ int tmp, i;
187+ unsigned char buf[13];
188+
189+ tmp = usb_string(dev->udev, e->iMACAddress, buf, sizeof(buf));
190+ if (tmp != 12) {
191+ dev_dbg(&dev->udev->dev,
192+ "bad MAC string %d fetch, %d\n", e->iMACAddress, tmp);
193+ if (tmp >= 0)
194+ tmp = -EINVAL;
195+ return tmp;
196+ }
197+ for (i = tmp = 0; i < 6; i++, tmp += 2)
198+ dev->net->dev_addr[i] =
199+ (nibble(buf[tmp]) << 4) + nibble(buf[tmp + 1]);
200+ return 0;
201+}
202+
203+static void mbm_get_drvinfo(struct net_device *net,
204+ struct ethtool_drvinfo *info)
205+{
206+ struct usbnet *dev = netdev_priv(net);
207+
208+ strncpy(info->driver, dev->driver_name, sizeof(info->driver));
209+ strncpy(info->version, DRIVER_VERSION, sizeof(info->version));
210+ strncpy(info->fw_version, dev->driver_info->description,
211+ sizeof(info->fw_version));
212+ usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
213+}
214+
215+static struct ethtool_ops mbm_ethtool_ops = {
216+ .get_drvinfo = mbm_get_drvinfo,
217+ .get_link = usbnet_get_link,
218+ .get_msglevel = usbnet_get_msglevel,
219+ .set_msglevel = usbnet_set_msglevel,
220+ .get_settings = usbnet_get_settings,
221+ .set_settings = usbnet_set_settings,
222+ .nway_reset = usbnet_nway_reset,
223+};
224+
225+static int mbm_check_connect(struct usbnet *dev)
226+{
227+ struct mbm_data *data = (void *)&dev->data;
228+
229+ return !data->connect;
230+}
231+
232+static int mbm_bind(struct usbnet *dev, struct usb_interface *intf)
233+{
234+ struct cdc_state *info = (void *)&dev->data;
235+ struct usb_driver *driver = driver_of(intf);
236+ struct usb_interface_descriptor *d = NULL;
237+ struct usb_cdc_mdlm_desc *desc = NULL;
238+ struct usb_cdc_mdlm_detail_desc *detail = NULL;
239+ struct mbm_data *data = NULL;
240+
241+ u8 *buf = intf->cur_altsetting->extra;
242+ int len = intf->cur_altsetting->extralen;
243+ int status;
244+
245+ memset(info, 0, sizeof(*info));
246+ info->control = intf;
247+ while (len > 3) {
248+ if (buf[1] != USB_DT_CS_INTERFACE)
249+ goto next_desc;
250+
251+ switch (buf[2]) {
252+ case USB_CDC_MDLM_TYPE:
253+ if (info->header)
254+ goto bad_desc;
255+
256+ desc = (void *)buf;
257+
258+ if (desc->bLength != sizeof(*desc))
259+ goto bad_desc;
260+
261+ if (memcmp(&desc->bGUID, mbm_guid, 16))
262+ goto bad_desc;
263+ break;
264+ case USB_CDC_MDLM_DETAIL_TYPE:
265+ if (detail)
266+ goto bad_desc;
267+
268+ detail = (void *)buf;
269+
270+ if (detail->bGuidDescriptorType == 0) {
271+ if (detail->bLength < (sizeof(*detail) + 1))
272+ goto bad_desc;
273+ }
274+ break;
275+ case USB_CDC_UNION_TYPE:
276+ if (info->u)
277+ goto bad_desc;
278+
279+ info->u = (void *)buf;
280+
281+ if (info->u->bLength != sizeof(*info->u))
282+ goto bad_desc;
283+
284+ info->control = usb_ifnum_to_if(dev->udev,
285+ info->u->
286+ bMasterInterface0);
287+ info->data =
288+ usb_ifnum_to_if(dev->udev,
289+ info->u->bSlaveInterface0);
290+ if (!info->control || !info->data) {
291+ dev_dbg(&intf->dev,
292+ "master #%u/%p slave #%u/%p\n",
293+ info->u->bMasterInterface0,
294+ info->control,
295+ info->u->bSlaveInterface0, info->data);
296+ goto bad_desc;
297+ }
298+
299+ /* a data interface altsetting does the real i/o */
300+ d = &info->data->cur_altsetting->desc;
301+ if (d->bInterfaceClass != USB_CLASS_CDC_DATA)
302+ goto bad_desc;
303+ break;
304+ case USB_CDC_ETHERNET_TYPE:
305+ if (info->ether)
306+ goto bad_desc;
307+
308+ info->ether = (void *)buf;
309+ if (info->ether->bLength != sizeof(*info->ether))
310+ goto bad_desc;
311+ dev->hard_mtu =
312+ le16_to_cpu(info->ether->wMaxSegmentSize);
313+ break;
314+ }
315+next_desc:
316+ len -= buf[0]; /* bLength */
317+ buf += buf[0];
318+ }
319+
320+ if (!desc || !detail) {
321+ dev_dbg(&intf->dev, "missing cdc mdlm %s%sdescriptor\n",
322+ desc ? "" : "func ", detail ? "" : "detail ");
323+ goto bad_desc;
324+ }
325+
326+ if (!info->u || (!info->ether)) {
327+ dev_dbg(&intf->dev, "missing cdc %s%s%sdescriptor\n",
328+ info->header ? "" : "header ",
329+ info->u ? "" : "union ", info->ether ? "" : "ether ");
330+ goto bad_desc;
331+ }
332+
333+ status = usb_driver_claim_interface(driver, info->data, dev);
334+ if (status < 0) {
335+ dev_dbg(&intf->dev, "Failed claimin interface\n");
336+ return status;
337+ }
338+ status = usbnet_get_endpoints(dev, info->data);
339+ if (status < 0) {
340+ dev_dbg(&intf->dev, "Failed get endpoints\n");
341+ usb_set_intfdata(info->data, NULL);
342+ usb_driver_release_interface(driver, info->data);
343+ return status;
344+ }
345+
346+ dev->status = NULL;
347+ if (info->control->cur_altsetting->desc.bNumEndpoints == 1) {
348+ struct usb_endpoint_descriptor *desc;
349+
350+ dev->status = &info->control->cur_altsetting->endpoint[0];
351+ desc = &dev->status->desc;
352+ if (!usb_endpoint_is_int_in(desc)
353+ || (le16_to_cpu(desc->wMaxPacketSize)
354+ < sizeof(struct usb_cdc_notification))
355+ || !desc->bInterval) {
356+ dev_dbg(&intf->dev, "bad notification endpoint\n");
357+ dev->status = NULL;
358+ }
359+ }
360+ usb_set_intfdata(intf, data);
361+ dev->net->ethtool_ops = &mbm_ethtool_ops;
362+
363+ status = get_ethernet_addr(dev, info->ether);
364+ if (status < 0) {
365+ usb_set_intfdata(info->data, NULL);
366+ usb_driver_release_interface(driver_of(intf), info->data);
367+ return status;
368+ }
369+
370+ return 0;
371+
372+bad_desc:
373+ dev_info(&dev->udev->dev, "unsupported MDLM descriptors\n");
374+ return -ENODEV;
375+}
376+
377+static const struct driver_info mbm_info = {
378+ .description = "Mobile Broadband Network Device",
379+ .flags = FLAG_MBN,
380+ .check_connect = mbm_check_connect,
381+ .bind = mbm_bind,
382+ .unbind = usbnet_cdc_unbind,
383+ .status = mbm_status,
384+};
385+
386+static const struct usb_device_id products[] = {
387+ {
388+ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM,
389+ USB_CDC_PROTO_NONE),
390+ .driver_info = (unsigned long)&mbm_info,
391+ },
392+
393+ {}, /* END */
394+};
395+
396+MODULE_DEVICE_TABLE(usb, products);
397+
398+int mbm_suspend(struct usb_interface *intf, pm_message_t message)
399+{
400+ dev_dbg(&intf->dev, "mbm%d_suspend\n", intf->minor);
401+ return usbnet_suspend(intf, message);
402+}
403+
404+int mbm_resume(struct usb_interface *intf)
405+{
406+ dev_dbg(&intf->dev, "mbm%d_resume\n", intf->minor);
407+ return usbnet_resume(intf);
408+}
409+
410+static struct usb_driver usbmbm_driver = {
411+ .name = "mbm",
412+ .id_table = products,
413+ .probe = usbnet_probe,
414+ .disconnect = usbnet_disconnect,
415+ .suspend = mbm_suspend,
416+ .resume = mbm_resume,
417+ .supports_autosuspend = 1,
418+};
419+
420+static int __init usbmbm_init(void)
421+{
422+ return usb_register(&usbmbm_driver);
423+}
424+
425+module_init(usbmbm_init);
426+
427+static void __exit usbmbm_exit(void)
428+{
429+ usb_deregister(&usbmbm_driver);
430+}
431+
432+module_exit(usbmbm_exit);
433+
434+MODULE_AUTHOR("Carl Nordbeck");
435+MODULE_DESCRIPTION("Ericsson Mobile Broadband");
436+MODULE_LICENSE("GPL");
437diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
438index 035fab0..4733b73 100644
439--- a/drivers/net/usb/usbnet.c
440+++ b/drivers/net/usb/usbnet.c
441@@ -1371,6 +1371,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
442 /* WWAN devices should always be named "wwan%d" */
443 if ((dev->driver_info->flags & FLAG_WWAN) != 0)
444 strcpy(net->name, "wwan%d");
445+ /* MB devices should always be named "mb%d" */
446+ if (dev->driver_info->flags & FLAG_MBN)
447+ strcpy (net->name, "mb%d");
448
449 /* maybe the remote can't receive an Ethernet MTU */
450 if (net->mtu > (dev->hard_mtu - net->hard_header_len))
451diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
452index 8ce6135..e47afbf 100644
453--- a/include/linux/usb/usbnet.h
454+++ b/include/linux/usb/usbnet.h
455@@ -94,6 +94,7 @@ struct driver_info {
456 #define FLAG_AVOID_UNLINK_URBS 0x0100 /* don't unlink urbs at usbnet_stop() */
457 #define FLAG_SEND_ZLP 0x0200 /* hw requires ZLPs are sent */
458 #define FLAG_WWAN 0x0400 /* use "wwan%d" names */
459+#define FLAG_MBN 0x0800 /* use "mb%d" names */
460
461 #define FLAG_LINK_INTR 0x0800 /* updates link (carrier) status */
462
463--
4641.6.2.5
465