Переглянути джерело

patches for simcom 7600 7500 Modems

Reinhard Russinger 6 роки тому
батько
коміт
55b1404af6

+ 1 - 1
board/GfA/Display001/BUILD

@@ -1 +1 @@
-641
+642

+ 300 - 0
board/GfA/Display001/linux_4.4.94_rt19/linux-029-simcom_7600_7500.patch

@@ -0,0 +1,300 @@
+diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
+index b5f0406..da20b14 100644
+--- a/drivers/net/usb/Makefile
++++ b/drivers/net/usb/Makefile
+@@ -26,7 +26,7 @@ obj-$(CONFIG_USB_NET_RNDIS_HOST)	+= rndis_host.o
+ obj-$(CONFIG_USB_NET_CDC_SUBSET)	+= cdc_subset.o
+ obj-$(CONFIG_USB_NET_ZAURUS)	+= zaurus.o
+ obj-$(CONFIG_USB_NET_MCS7830)	+= mcs7830.o
+-obj-$(CONFIG_USB_USBNET)	+= usbnet.o
++obj-$(CONFIG_USB_USBNET)	+= usbnet.o sim7500_sim7600_wwan.o
+ obj-$(CONFIG_USB_NET_INT51X1)	+= int51x1.o
+ obj-$(CONFIG_USB_CDC_PHONET)	+= cdc-phonet.o
+ obj-$(CONFIG_USB_NET_KALMIA)	+= kalmia.o
+diff --git a/drivers/net/usb/sim7500_sim7600_wwan.c b/drivers/net/usb/sim7500_sim7600_wwan.c
+new file mode 100644
+index 0000000..a70bcc0
+--- /dev/null
++++ b/drivers/net/usb/sim7500_sim7600_wwan.c
+@@ -0,0 +1,243 @@
++/*
++ * Copyright (c) 2016 Xiaobin Wang <xiaobin.wang@sim.com>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * version 2 as published by the Free Software Foundation.
++ */
++
++/*
++ * history 
++ * V1.00 - first release  - 20160822
++*/
++
++#include <linux/module.h>
++#include <linux/netdevice.h>
++#include <linux/ethtool.h>
++#include <linux/etherdevice.h>
++#include <linux/mii.h>
++#include <linux/usb.h>
++#include <linux/usb/cdc.h>
++#include <linux/usb/usbnet.h>
++
++
++/* very simplistic detection of IPv4 or IPv6 headers */
++static bool possibly_iphdr(const char *data)
++{
++	return (data[0] & 0xd0) == 0x40;
++}
++
++/* SIMCOM devices combine the "control" and "data" functions into a
++ * single interface with all three endpoints: interrupt + bulk in and
++ * out
++ */
++static int simcom_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
++{
++	int rv = -EINVAL;
++  
++	//struct usb_driver *subdriver = NULL;
++	atomic_t *pmcount = (void *)&dev->data[1];
++
++  /* ignore any interface with additional descriptors */
++	if (intf->cur_altsetting->extralen)
++		goto err;
++  
++	/* Some makes devices where the interface descriptors and endpoint
++	 * configurations of two or more interfaces are identical, even
++	 * though the functions are completely different.  If set, then
++	 * driver_info->data is a bitmap of acceptable interface numbers
++	 * allowing us to bind to one such interface without binding to
++	 * all of them
++	 */
++	if (dev->driver_info->data &&
++	    !test_bit(intf->cur_altsetting->desc.bInterfaceNumber, &dev->driver_info->data)) {
++		dev_info(&intf->dev, "not on our whitelist - ignored");
++		rv = -ENODEV;
++		goto err;
++	}
++
++	atomic_set(pmcount, 0);
++
++	/* collect all three endpoints */
++	rv = usbnet_get_endpoints(dev, intf);
++	if (rv < 0)
++		goto err;
++
++	/* require interrupt endpoint for subdriver */
++	if (!dev->status) {
++		rv = -EINVAL;
++		goto err;
++	}
++
++	/* can't let usbnet use the interrupt endpoint */
++	dev->status = NULL;
++
++	printk("simcom usbnet bind here\n");
++
++  /*
++   * SIMCOM SIM7600 only support the RAW_IP mode, so the host net driver would
++   * remove the arp so the packets can transmit to the modem
++  */
++  dev->net->flags |= IFF_NOARP;
++    
++  /* make MAC addr easily distinguishable from an IP header */
++	if (possibly_iphdr(dev->net->dev_addr)) {
++		dev->net->dev_addr[0] |= 0x02;	/* set local assignment bit */
++		dev->net->dev_addr[0] &= 0xbf;	/* clear "IP" bit */
++	}
++	
++  /*
++   * SIMCOM SIM7600 need set line state
++  */
++  usb_control_msg(
++      interface_to_usbdev(intf),
++      usb_sndctrlpipe(interface_to_usbdev(intf), 0),
++      0x22, //USB_CDC_REQ_SET_CONTROL_LINE_STATE
++      0x21, //USB_DIR_OUT | USB_TYPE_CLASS| USB_RECIP_INTERFACE
++      1, //line state 1
++      intf->cur_altsetting->desc.bInterfaceNumber,
++      NULL,0,100);
++
++err:
++	return rv;
++}
++
++static void simcom_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
++{
++	struct usb_driver *subdriver = (void *)dev->data[0];
++
++	if (subdriver && subdriver->disconnect)
++		subdriver->disconnect(intf);
++
++	dev->data[0] = (unsigned long)NULL;
++}
++
++#ifdef CONFIG_PM
++static int simcom_wwan_suspend(struct usb_interface *intf, pm_message_t message)
++{
++	struct usbnet *dev = usb_get_intfdata(intf);
++	int ret;
++
++	ret = usbnet_suspend(intf, message);
++	if (ret < 0)
++		goto err;
++		
++err:
++	return ret;
++}
++
++static int simcom_wwan_resume(struct usb_interface *intf)
++{
++	struct usbnet *dev = usb_get_intfdata(intf);
++	int ret = 0;
++	
++	ret = usbnet_resume(intf);
++
++err:
++	return ret;
++}
++#endif
++
++struct sk_buff *simcom_wwan_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
++{
++
++  //skip ethernet header 
++  if(skb_pull(skb, ETH_HLEN))
++  {
++    return skb;
++  }else
++  {
++    dev_err(&dev->intf->dev, "Packet Dropped\n");
++  }
++
++  if (skb != NULL)
++    dev_kfree_skb_any(skb);
++
++   return NULL;
++}
++
++static int simcom_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
++{
++  __be16 proto;
++
++  /* This check is no longer done by usbnet */
++  if (skb->len < dev->net->hard_header_len)
++    return 0;
++
++	switch (skb->data[0] & 0xf0) {
++	case 0x40:
++		//printk("packetv4 coming ,,,\n");
++		proto = htons(ETH_P_IP);
++		break;
++	case 0x60:
++		//printk("packetv6 coming ,,,\n");
++		proto = htons(ETH_P_IPV6);
++		break;
++	case 0x00:
++		//printk("packet coming ,,,\n");
++		if (is_multicast_ether_addr(skb->data))
++			return 1;
++		/* possibly bogus destination - rewrite just in case */
++		skb_reset_mac_header(skb);
++		goto fix_dest;
++	default:
++		/* pass along other packets without modifications */
++		return 1;
++	}
++	if (skb_headroom(skb) < ETH_HLEN)
++		return 0;
++	skb_push(skb, ETH_HLEN);
++	skb_reset_mac_header(skb);
++	eth_hdr(skb)->h_proto = proto;
++	memset(eth_hdr(skb)->h_source, 0, ETH_ALEN);
++fix_dest:
++	memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
++	return 1;
++}
++
++static const struct driver_info	simcom_wwan_usbnet_driver_info = {
++	.description	= "SIMCOM wwan/QMI device",
++	.flags		= FLAG_WWAN,
++	.bind		  = simcom_wwan_bind,
++	.unbind		= simcom_wwan_unbind,
++	.rx_fixup       = simcom_wwan_rx_fixup,
++	.tx_fixup       = simcom_wwan_tx_fixup,
++};
++
++static const struct usb_device_id products[] = {
++  {USB_DEVICE(0x1e0e, 0x9025), .driver_info = (unsigned long)&simcom_wwan_usbnet_driver_info },
++	{USB_DEVICE(0x1e0e, 0x9001), .driver_info = (unsigned long)&simcom_wwan_usbnet_driver_info },
++	{ } /* END */
++};
++
++MODULE_DEVICE_TABLE(usb, products);
++
++static struct usb_driver simcom_wwan_usb_driver = {
++	.name		        = "simcom_wwan",
++	.id_table	      = products,
++	.probe		      =	usbnet_probe,
++	.disconnect	    = usbnet_disconnect,
++#ifdef CONFIG_PM
++	.suspend	      = simcom_wwan_suspend,
++	.resume		      =	simcom_wwan_resume,
++	.reset_resume         = simcom_wwan_resume,
++	.supports_autosuspend = 1,
++#endif
++};
++
++static int __init simcom_wwan_init(void)
++{
++	return usb_register(&simcom_wwan_usb_driver);
++}
++module_init(simcom_wwan_init);
++
++static void __exit simcom_wwan_exit(void)
++{
++	usb_deregister(&simcom_wwan_usb_driver);
++}
++module_exit(simcom_wwan_exit);
++
++MODULE_AUTHOR("Xiaobin Wang <xiaobin.wang@sim.com>");
++MODULE_DESCRIPTION("SIM7600 RMNET WWAN driver");
++MODULE_LICENSE("GPL");
++
+diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
+index db3d34c..6c0e34f 100644
+--- a/drivers/usb/serial/option.c
++++ b/drivers/usb/serial/option.c
+@@ -100,6 +100,10 @@ static void option_instat_callback(struct urb *urb);
+ #define YISO_VENDOR_ID				0x0EAB
+ #define YISO_PRODUCT_U893			0xC893
+ 
++/* SImCom SIM7500_7600 */
++#define SIMCOM_SIM7600_VID			0x1E0E
++#define SIMCOM_SIM7600_PID			0x9001
++
+ /*
+  * NOVATEL WIRELESS PRODUCTS
+  *
+@@ -550,6 +554,11 @@ struct option_blacklist_info {
+ 	const unsigned long reserved;
+ };
+ 
++/* for SIM7600 modem for NDIS */
++static const struct option_blacklist_info simcom_sim7600_blacklist = {
++.reserved = BIT(5),
++};
++
+ static const struct option_blacklist_info four_g_w14_blacklist = {
+ 	.sendsetup = BIT(0) | BIT(1),
+ };
+@@ -1854,6 +1863,10 @@ static const struct usb_device_id option_ids[] = {
+ 	{ USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) },
+ 	{ USB_DEVICE(ALINK_VENDOR_ID, SIMCOM_PRODUCT_SIM7100E),
+ 	  .driver_info = (kernel_ulong_t)&simcom_sim7100e_blacklist },
++	/* for SIM7600 modem for NDIS */
++	{ USB_DEVICE(SIMCOM_SIM7600_VID, SIMCOM_SIM7600_PID),
++	  .driver_info = (kernel_ulong_t)& simcom_sim7600_blacklist
++	},
+ 	{ USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200),
+ 	  .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist
+ 	},