RK3588 EC200A-CN【4G模块】调试

1、修改kernel


diff --git a/arch/arm64/boot/dts/rockchip/rk3588-nvr-demo.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-nvr-demo.dtsi
index d8a7a43cdfa0..772f16633148 100755
--- a/arch/arm64/boot/dts/rockchip/rk3588-nvr-demo.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-nvr-demo.dtsi
@@ -187,6 +187,13 @@
                status = "okay";
        };
        
+       lk4g_gpio {
+               compatible = "rockchip,lk4g_gpio";
+               pinctrl-0 = <&mod4g_pins>;
+               pwr_4g = <&gpio1 RK_PB0 GPIO_ACTIVE_HIGH>;
+               rst_4g = <&gpio1 RK_PA7 GPIO_ACTIVE_HIGH>;
+               status = "okay";
+       };
 };
 
 &pwm11 {
@@ -207,7 +214,7 @@
        reset-gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>;
        vpcie3v3-supply = <&vcc3v3_pcie30>;
        rockchip,init-delay-ms = <100>;
-       status = "disabled";
+       status = "okay";
 };
 
 &pcie2x1l2 {
@@ -792,6 +799,13 @@
                };
        };
        
+       lk4g_pins {
+               mod4g_pins: mod4g-pins {
+                       rockchip,pins = <1 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>,
+                                               <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_none>;
+               };
+       };
+       
        hdmi {
                hdmirx_det: hdmirx-det {
                        rockchip,pins = <1 RK_PD5 RK_FUNC_GPIO &pcfg_pull_up>;
diff --git a/arch/arm64/configs/rk3588_nvr.config b/arch/arm64/configs/rk3588_nvr.config
index 79ffd373d61e..a0e41797dd71 100644
--- a/arch/arm64/configs/rk3588_nvr.config
+++ b/arch/arm64/configs/rk3588_nvr.config
@@ -27,7 +27,7 @@ CONFIG_ROCKCHIP_CLK_COMPENSATION=y
 # CONFIG_USB_ACM is not set
 # CONFIG_USB_CONFIGFS_ACM is not set
 # CONFIG_USB_CONFIGFS_MASS_STORAGE is not set
-# CONFIG_USB_SERIAL is not set
+CONFIG_USB_SERIAL=y
 # CONFIG_WLAN is not set
 CONFIG_DMABUF_CACHE=y
 CONFIG_ASYNC_CORE=y
diff --git a/arch/arm64/configs/rockchip_linux_defconfig b/arch/arm64/configs/rockchip_linux_defconfig
index db5fdc8f6d1a..d07c618855cd 100644
--- a/arch/arm64/configs/rockchip_linux_defconfig
+++ b/arch/arm64/configs/rockchip_linux_defconfig
@@ -1,3 +1,17 @@
+CONFIG_USB_NET_DRIVERS=y
+CONFIG_USB_USBNET=y
+CONFIG_USB_NET_QMI_WWAN=y
+CONFIG_USB_WDM=y
+CONFIG_USB_USBNET=y
+CONFIG_NET_CDCETHER=y
+#CONFIG_NET_RNDIS_HOST=y
+CONFIG_PPP=y
+CONFIG_PPP_ASYNC=y
+CONFIG_PPP_SYNC_TTY=y
+CONFIG_PPP_DEFLATE=y
+CONFIG_USB_SERIAL=y
+CONFIG_USB_SERIAL_WWAN=y
+CONFIG_USB_SERIAL_OPTION=y
 CONFIG_R8169=y
 CONFIG_VIDEO_ROCKCHIP_HDMIRX=y
 CONFIG_DEFAULT_HOSTNAME="localhost"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 3944ae6552d3..397d1946790d 100755
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -64,3 +64,4 @@ obj-y                         += rockchip/
 obj-y += lkir.o
 obj-y += lkir_send.o
 obj-y += lkes7243.o
+obj-y += lk4g_gpio.o
diff --git a/drivers/misc/lk4g_gpio.c b/drivers/misc/lk4g_gpio.c
new file mode 100755
index 000000000000..8a2f8ce1ccdf
--- /dev/null
+++ b/drivers/misc/lk4g_gpio.c
@@ -0,0 +1,198 @@
+/*^M
+ * linux/drivers/hwmon/lkencodeic.c^M
+ *^M
+ * 3-Axis Orientation/Motion Detection Sensor support^M
+ *^M
+ * Copyright (C) 2009-2010 LenKeng Ltd.^M
+ *^M
+ * This program is free software; you can redistribute it and/or modify^M
+ * it under the terms of the GNU General Public License as published by^M
+ * the Free Software Foundation; either version 2 of the License, or^M
+ * (at your option) any later version.^M
+ *^M
+ * This program is distributed in the hope that it will be useful,^M
+ * but WITHOUT ANY WARRANTY; without even the implied warranty ofdddfsafasfasfasfsafd^M
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the^M
+ * GNU General Public License for more details.^M
+ *^M
+ * You should have received a copy of the GNU General Public License^M
+ * along with this program; if not, write to the Free Software^M
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.^M
+ */^M
+^M
+#include <linux/module.h>^M
+#include <linux/slab.h>^M
+#include <linux/interrupt.h>^M
+#include <linux/irq.h>^M
+#include <linux/delay.h>^M
+#include <linux/i2c.h>^M
+#include <linux/err.h>^M
+#include <linux/input-polldev.h>^M
+#include <linux/device.h>^M
+#include <linux/uaccess.h>^M
+#include <linux/timer.h>^M
+#include <linux/timex.h>^M
+#include <linux/rtc.h>^M
+#include <linux/platform_device.h>^M
+#include <linux/miscdevice.h>^M
+//#include <linux/lkec.h>^M
+#include <linux/gpio.h>^M
+#include <linux/of_gpio.h>^M
+^M
+#include <linux/wakelock.h>^M
+^M
+#include <linux/timekeeping.h>^M
+^M
+//static struct pwm_device     *pwm;^M
+^M
+typedef unsigned char  uchar;^M
+typedef char           schar;^M
+typedef unsigned char  uint8;^M
+typedef signed char    int8;^M
+typedef unsigned short uint16;^M
+typedef short          int16;^M
+typedef unsigned int   uint32;^M
+typedef int            int32;^M
+^M
+#define GPIO_RST_HIGH  _IO('k', 0)^M
+#define GPIO_RST_LOW   _IO('k', 1)^M
+#define GPIO_PWR_HIGH  _IO('k', 2)^M
+#define GPIO_PWR_LOW   _IO('k', 3)^M
+^M
+static int gpio_pwr_4g;^M
+static int gpio_rst_4g;^M
+^M
+static long lk4g_gpio_ioctl(struct file * file, unsigned int cmd, unsigned long arg)^M
+{^M
+       switch (cmd) {^M
+               case GPIO_RST_HIGH:^M
+            gpio_direction_output(gpio_rst_4g, 1);^M
+            break;^M
+        ^M
+        case GPIO_RST_LOW:^M
+            gpio_direction_output(gpio_rst_4g, 0);^M
+            break;^M
+        ^M
+        case GPIO_PWR_HIGH:^M
+            gpio_direction_output(gpio_pwr_4g, 1);^M
+            break;^M
+        ^M
+        case GPIO_PWR_LOW:^M
+            gpio_direction_output(gpio_pwr_4g, 0);^M
+            break;^M
+               break;^M
+       }^M
+       return 0;^M
+}^M
+^M
+^M
+static struct file_operations lk4g_gpio_fops = {^M
+       .owner = THIS_MODULE,^M
+       //.open = lk4g_gpio_open,^M
+       //.release = lk4g_gpio_release,^M
+       .unlocked_ioctl = lk4g_gpio_ioctl,^M
+    //.read = lk4g_gpio_read,^M
+    //.write = lk4g_gpio_write,^M
+};^M
+^M
+static struct miscdevice lk4g_gpio_device = {^M
+       .minor = MISC_DYNAMIC_MINOR,^M
+       .name = "lk4g_gpio",^M
+       .fops = &lk4g_gpio_fops,^M
+};^M
+^M
+static int  lk4g_gpio_probe(struct platform_device *pdev)^M
+{^M
+    struct device_node *np = pdev->dev.of_node;^M
+       int ret;^M
+    int err;^M
+       ^M
+       printk("====lk4g_gpio_probe==\n");^M
+^M
+       gpio_pwr_4g = of_get_named_gpio(np, "pwr_4g", 0);^M
+       if (!gpio_is_valid(gpio_pwr_4g)) {^M
+               dev_err(&pdev->dev, "invalid host gpio%d\n", gpio_pwr_4g);^M
+       } else {^M
+               err = devm_gpio_request(&pdev->dev, gpio_pwr_4g, "pwr_4g");^M
+               if (err) {^M
+                       dev_err(&pdev->dev,^M
+                               "failed to request GPIO%d for pwr_4g\n",^M
+                               gpio_pwr_4g);^M
+                       ret = err;^M
+               }^M
+               gpio_direction_output(gpio_pwr_4g, 1);^M
+               printk("====gpio_pwr_4g==\n");^M
+       }^M
+       ^M
+       gpio_rst_4g = of_get_named_gpio(np, "rst_4g", 0);^M
+       if (!gpio_is_valid(gpio_rst_4g)) {^M
+               dev_err(&pdev->dev, "invalid host gpio%d\n", gpio_rst_4g);^M
+       } else {^M
+               err = devm_gpio_request(&pdev->dev, gpio_rst_4g, "rst_4g");^M
+               if (err) {^M
+                       dev_err(&pdev->dev,^M
+                               "failed to request GPIO%d for rst_4g\n",^M
+                               gpio_rst_4g);^M
+                       ret = err;^M
+               }^M
+               gpio_direction_output(gpio_rst_4g, 1);^M
+               printk("====rst_4g==\n");^M
+       }^M
+       ret = misc_register(&lk4g_gpio_device);^M
+       if (ret) {^M
+               pr_err("lkgsv_probe: lk4g_gpio_device register failed\n");^M
+               goto misc_register_failed;^M
+       }^M
+       ^M
+       return 0;^M
+       ^M
+misc_register_failed:^M
+       misc_deregister(&lk4g_gpio_device);^M
+       return -1;^M
+}^M
+^M
+static int  lk4g_gpio_remove(struct platform_device *pdev)^M
+{^M
+       misc_deregister(&lk4g_gpio_device);^M
+       return 0;^M
+}^M
+^M
+static struct of_device_id lk4g_gpio_of_match[] = {^M
+       { .compatible = "rockchip,lk4g_gpio" },^M
+       { }^M
+};^M
+^M
+static struct platform_driver lk4g_gpio_driver = {^M
+       .probe = lk4g_gpio_probe,^M
+    .remove            = lk4g_gpio_remove, ^M
+    .driver            = {^M
+        .name  = "lk4g_gpio", ^M
+               .of_match_table = of_match_ptr(lk4g_gpio_of_match),^M
+               .owner  = THIS_MODULE,^M
+       },^M
+};^M
+^M
+static int lk4g_gpio_init(void)^M
+{^M
+       int retval = 0;^M
+^M
+       retval = platform_driver_register(&lk4g_gpio_driver);^M
+       if (retval < 0) {^M
+               printk(KERN_ERR "%s retval=%d\n", __func__, retval);^M
+               return retval;^M
+       }^M
+       return 0;^M
+}^M
+^M
+static void lk4g_gpio_exit(void)^M
+{^M
+       platform_driver_unregister(&lk4g_gpio_driver);^M
+}^M
+^M
+module_init(lk4g_gpio_init); ^M
+module_exit(lk4g_gpio_exit);^M
+^M
+MODULE_AUTHOR("LenKeng,Inc.");^M
+MODULE_DESCRIPTION("lk4g_gpio driver");^M
+MODULE_LICENSE("GPL");^M
+^M
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
old mode 100644
new mode 100755
index b878f4c87fee..67bd7c27ef07
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -587,6 +587,9 @@ static void option_instat_callback(struct urb *urb);
 
 
 static const struct usb_device_id option_ids[] = {
+#if 1 //Added by Quectel
+        {USB_DEVICE(0x2C7C, 0x6005)  },
+#endif
        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
@@ -2161,6 +2164,9 @@ static struct usb_serial_driver option_1port_device = {
        .suspend           = usb_wwan_suspend,
        .resume            = usb_wwan_resume,
 #endif
+#if 1 //Added by Quectel
+        .reset_resume      = usb_wwan_resume,
+#endif
 };
 
 static struct usb_serial_driver * const serial_drivers[] = {
@@ -2203,6 +2209,23 @@ static int option_probe(struct usb_serial *serial,
        if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2)
                return -ENODEV;
 
+#if 1 //Added by Quectel
+     if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)) {
+         __u16 idProduct = le16_to_cpu(serial->dev->descriptor.idProduct);
+         struct usb_interface_descriptor *intf = &serial->interface->cur_altsetting->desc;
+         if (intf->bInterfaceClass != 0xFF || intf->bInterfaceSubClass == 0x42) {
+             //ECM, RNDIS, NCM, MBIM, ACM, UAC, ADB
+             return -ENODEV;
+         }
+        if ((idProduct&0xF000) == 0x0000) {
+         //MDM interface 4 is QMI
+         if (intf->bInterfaceNumber == 4 && intf->bNumEndpoints == 3
+            && intf->bInterfaceSubClass == 0xFF && intf->bInterfaceProtocol == 0xFF)
+             return -ENODEV;
+        }
+    }
+#endif
+
        /* Store the device flags so we can use them during attach. */
        usb_set_serial_data(serial, (void *)device_flags);
 
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
old mode 100644
new mode 100755
index b2285d5a869d..33826cdcedb3
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -476,6 +476,13 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
        usb_fill_bulk_urb(urb, serial->dev,
                          usb_sndbulkpipe(serial->dev, endpoint) | dir,
                          buf, len, callback, ctx);
+        #if 1 //Added by Quectel for zero packet
+        if (dir == USB_DIR_OUT) {
+            struct usb_device_descriptor *desc = &serial->dev->descriptor;
+            if (desc->idVendor == cpu_to_le16(0x2C7C))
+                urb->transfer_flags |= URB_ZERO_PACKET;
+        }
+        #endif
 
        if (intfdata->use_zlp && dir == USB_DIR_OUT)
                urb->transfer_flags |= URB_ZERO_PACKET;

2、配置网卡接口类型

EC200A只有这两种拨号方式,LINUX系统自带都支持

echo "AT+QCFG=\"usbnet\",1" > /dev/ttyUSB2

3、拨号

echo -en "AT+QNETDEVCTL=1,1,1\r\n" > /dev/ttyUSB2

最后可以ping'百度成功,就代表拨号成功

4、调试命令

[root@RK3588:/]# lsusb
Bus 005 Device 001: ID 1d6b:0002
Bus 003 Device 001: ID 1d6b:0001
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 003: ID 2c7c:6005
Bus 006 Device 001: ID 1d6b:0003
Bus 001 Device 002: ID 1a86:8092
Bus 004 Device 001: ID 1d6b:0001
Bus 002 Device 001: ID 1d6b:0002
[root@RK3588:/]# ls -ll /dev/ttyUSB
ls: cannot access '/dev/ttyUSB': No such file or directory
[root@RK3588:/]# ls -ll /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Jan  1 00:00 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Jan  1 00:00 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 Jan  1 00:00 /dev/ttyUSB2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值