forlinx OKV1.3开发板上移植EC20

EC20是无线4G模块,某项目需要在linux系统下支持该模块,根据网上的一些文章,自己完成了移植并实现了功能,将过程记录下来。

1. 添加VID和PID

打开内核文件drivers/usb/serial/option.c
为option_ids[]添加以下内容

#if 1 //Added by Quectel
        { USB_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */
        { USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
        { USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC25/EC20 R2.0 */
        { USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */
        { USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20 */
        { USB_DEVICE(0x2C7C, 0x0191) }, /* Quectel EG91 */
        { USB_DEVICE(0x2C7C, 0x0195) }, /* Quectel EG95 */
        { USB_DEVICE(0x2C7C, 0x0306) }, /* Quectel EG06/EP06/EM06 */
        { USB_DEVICE(0x2C7C, 0x0296) }, /* Quectel BG96 */
#endif

2、注释掉qcserial.c里面的同名内容

由于使用EC20的ID是USB_DEVICE(0x05C6, 0x9003)和USB_DEVICE(0x05C6, 0x9215),所以注释掉qcserial.c里面的同名内容
drivers/usb/serial/qcserial.c
对应上面EC20配置项,注释掉同名的05C6 0x9215注释掉05C6 0x9215同样的原因要去掉drivers/net/usb/qmi_wwan.c里面的冲突内容。

3、添加0包处理

drivers/usb/serial/usb_wwan.c

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(0x05C6) && desc->idProduct == cpu_to_le16(0x9090))
                        urb->transfer_flags |= URB_ZERO_PACKET;
                if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9003))
                        urb->transfer_flags |= URB_ZERO_PACKET;
                if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9215))
                        urb->transfer_flags |= URB_ZERO_PACKET;
                if (desc->idVendor == cpu_to_le16(0x2C7C))
                        urb->transfer_flags |= URB_ZERO_PACKET;
        }
        #endif

如图
代码添加位置

4、添加Reset Resume回调

这一块是linux设备的电源管理相关,当soc休眠后,一些USB控制器将掉电或复位,MCU退出休眠时,USB不能恢复,所以要添加以下语句
对于版本在3.5以下的内核版本在文件/drivers/usb/serial/usb-serial.c中添加
添加代码位置

5、使用GobiNet或者QMI WWAN

使用这两个驱动还要修改drivers/usb/serial/option.c文件
代码添加位置

6、确认 USB driver for GSM and CDMA modems编入内核

在这里插入图片描述同时在makefile中将对应的模块编入内核

obj-y += GobiNet.o 
GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o 

重新生成内核,并烧录后,可以测试官方的拨号脚本。

猜你喜欢

转载自blog.csdn.net/weixin_40983190/article/details/84940071
今日推荐