[Feature][ZXW-137][AUTOSUSPEND]add usb wakelock because p54u02 delete it

Only Configure:No
Affected branch:master
Affected module:autosuspend
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update:No

Change-Id: I643a3f680a27980b3f6ccce35492d7db2703a561
diff --git a/ap/app/zte_comm/zte_drv_ctrl/usb/zte_drv_usb_ctrl.c b/ap/app/zte_comm/zte_drv_ctrl/usb/zte_drv_usb_ctrl.c
index b27a915..77fb3b1 100755
--- a/ap/app/zte_comm/zte_drv_ctrl/usb/zte_drv_usb_ctrl.c
+++ b/ap/app/zte_comm/zte_drv_ctrl/usb/zte_drv_usb_ctrl.c
@@ -1820,7 +1820,74 @@
     return 0;

 }

 

+/*jb.qi add for usb wakelock on 20230918 start*/

+#define RPMSG_IOC_MAGIC     'R'

 

+/*ioctl cmd usd by device*/

+#define RPMSG_CREATE_CHANNEL          _IOW(RPMSG_IOC_MAGIC, 1, char *)

+#define RPMSG_GET_DATASIZE       _IOWR(RPMSG_IOC_MAGIC, 2, char *)

+#define RPMSG_SET_INT            _IOW(RPMSG_IOC_MAGIC, 3, char *)

+#define RPMSG_SET_INT_FLAG        _IOW(RPMSG_IOC_MAGIC, 4, char *)

+#define RPMSG_CLEAR_INT_FLAG      _IOW(RPMSG_IOC_MAGIC, 5, char *)

+#define RPMSG_SET_POLL_FLAG       _IOW(RPMSG_IOC_MAGIC, 6, char *)

+#define RPMSG_CLEAR_POLL_FLAG     _IOW(RPMSG_IOC_MAGIC, 7, char *)

+

+#define USB_PLUG_WAKE_CAP_DEV    "/dev/rpmsg50"

+

+int usbplug_fd = -1;

+

+int usbplug_icp_init(void)

+{

+    usbplug_fd = open(USB_PLUG_WAKE_CAP_DEV, O_RDWR);

+

+    if(0 > usbplug_fd){

+        printf("%s: open the channel(%s) error!\n", __func__, USB_PLUG_WAKE_CAP_DEV);

+        return -1;

+    }

+

+    if(0 > ioctl(usbplug_fd, RPMSG_CREATE_CHANNEL, 64)){

+        printf("%s: ioctl RPMSG_CREATE_CHANNEL fail!\n", __func__);

+        close(usbplug_fd);

+        usbplug_fd = -1;

+        return -1;

+    }

+

+    if(0 > ioctl(usbplug_fd, RPMSG_SET_INT_FLAG, NULL)){ //¿¿¿

+        printf("%s: ioctl RPMSG_SET_INT_FLAG fail!\n", __func__);

+        close(usbplug_fd);

+        usbplug_fd = -1;

+        return -1;

+    }

+

+    printf("yanming %s create success!\n",__func__);

+

+    return 0;

+}

+

+int usbplug_rpmsg_send(int value)

+{

+    int write_len = 0;

+    char usbplug_in[20]="usbplug_in";

+    char usbplug_out[20]="usbplug_out";

+

+    printf("usbplug_rpmsg_send value:%d\n",value);

+

+    if(value == 1){

+        write_len = write(usbplug_fd, usbplug_in, sizeof(usbplug_in));

+    }

+

+    if(value == 0){

+        write_len = write(usbplug_fd, usbplug_out, sizeof(usbplug_out));

+    }

+

+    if(write_len <0){

+        printf("usbplug rpmsg write FAIL\n");

+        close(usbplug_fd);

+    }

+

+    return write_len;

+}

+/*jb.qi add for usb wakelock on 20230918 end*/

 /*usbÈȰβåʼþ´¦Àí*/

 int usb_event_proc(unsigned short usb_msg, int usb_event)

 {

@@ -1853,6 +1920,7 @@
         {

             slog(USBCFGMNG_PRINT,SLOG_NORMAL, "[usbCfgMng] usb charger plugin \n");

         }

+	usbplug_rpmsg_send(1);//jb.qi add for usb wakelock on 20230918

         break;

     case MSG_CMD_DRV_USB_REMOVE:

         /*°Î³öʼþ´¦Àí*/

@@ -1870,6 +1938,7 @@
         {

             slog(USBCFGMNG_PRINT,SLOG_NORMAL, "[usbCfgMng] usb charger plugOut \n");

         }

+	usbplug_rpmsg_send(0);//jb.qi add for usb wakelock on 20230918

         break;

     default:

         break;

@@ -2023,6 +2092,15 @@
         slog(USBCFGMNG_PRINT,SLOG_ERR, "[usbCfgMng] warning: readfile %s fail \n", USB_PLUG_FILE_NAME);

         return -1;

     }

+    /*jb.qi add for usb wakelock on 20230918 start*/

+    printf("usbPlugtype:%d\n",usbPlugtype);

+    if(usbPlugtype == 1)

+	sc_cfg_set("usbplug_nv","1");

+   

+    if(usbPlugtype == 0)

+	sc_cfg_set("usbplug_nv","0");

+    usbplug_icp_init();

+    /*jb.qi add for usb wakelock on 20230918 end*/

     usb_usbCfgMngInit(usbPlugtype);

     if (usbPlugtype == 1 && cp_need_udisk == 1)

 		usb_sendUsbOperateRlt(2);