9x07-usb state拔出usb线后状态仍为CONFIGURED,影响休眠(已解决)
问题描述:拔出usb线后usb没有进入lpm模式,导致系统无法休眠
/ # cat /proc/cmdline
cat /proc/cmdline
noinitrd ro console=NULL androidboot.hardware=qcom ehci-hcd.park=3 msm_rtb.filter=0x37 lpm_levels.sleep_disabled=1 early
con=msm_hsl_uart,0x78b1000 androidboot.serialno=3b9980 androidboot.authorized_kernel=true androidboot.baseband=msm rootf
stype=ubifs rootflags=bulk_read root=ubi0:rootfs ubi.mtd=14 custapp=/dev/ubi2_0
此时执行休眠提示
sh: write error: Device or resource busy
************************************************************
去掉lpm_levels.sleep_disabled=1后,设置 # echo off > /sys/power/autosleep (或者去掉CONFIG_PM_AUTOSLEEP)
执行休眠结果
/sys/devices/virtual/android_usb/android0 # echo mem > /sys/power/state
[ 471.726138] PM: suspend entry 1980-01-06 00:07:54.413190146 UTC
[ 471.731040] PM: Syncing filesystems ... done.
[ 471.761237] Freezing user space processes ...
[ 471.777456] Error: returning -512 value
[ 471.783461] mbim_read: Waiting failed
[ 471.791890] (elapsed 0.016 seconds) done.
[ 471.794883] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
[ 471.804475] Suspending console(s) (use no_console_suspend to debug)
[ 471.824526] msm_otg 78d9000.usb: Abort PM suspend!! (USB is outside LPM)
[ 471.824574] dpm_run_callback(): platform_pm_suspend+0x0/0x54 returns -16
[ 471.824600] PM: Device 78d9000.usb failed to suspend: error -16
[ 471.824621] PM: Some devices failed to suspend, or early wake event detected
[ 471.837781] PM: resume of devices complete after 13.111 msecs
[ 471.870450] Restarting tasks ... done.
[ 471.896264] cpufreq: Frequency violation fixed for CPU0
[ 471.900527] Abort: Some devices failed to suspend, or early wake event detected
[ 471.914510] PM: suspend exit 1980-01-06 00:07:54.601557125 UTC
sh: write error: Device or resource busy
/sys/devices/virtual/android_usb/android0 #
********************************************************************************************
去掉dts里hsic相关的配置,去掉vbus_otg-supply = <&smb358_otg_vreg>及smb的配置
/sys/power # echo off > autosleep
/sys/power # echo mem > state
[ 123.758308] PM: suspend entry 1980-01-06 01:37:37.417375487 UTC
[ 123.763212] PM: Syncing filesystems ... done.
[ 123.790947] Freezing user space processes ...
[ 123.810440] mbim_read: Waiting failed
[ 123.818858] (elapsed 0.013 seconds) done.
[ 123.821852] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
[ 123.831426] Suspending console(s) (use no_console_suspend to debug)
[ 123.852721] msm_otg 78d9000.usb: Abort PM suspend!! (USB is outside LPM)
[ 123.852770] dpm_run_callback(): platform_pm_suspend+0x0/0x54 returns -16
[ 123.852796] PM: Device 78d9000.usb failed to suspend: error -16
[ 123.852818] PM: Some devices failed to suspend, or early wake event detected
[ 123.865932] PM: resume of devices complete after 13.065 msecs
[ 123.898676] Restarting tasks ...
[ 123.905102] msm_otg 78d9000.usb: ep_set_halt: Unable to halt EP while suspended
[ 123.911576] msm_otg 78d9000.usb: ep_set_halt: Unable to halt EP while suspended
[ 123.934291] done.
[ 123.946347] cpufreq: Frequency violation fixed for CPU0
[ 123.950615] Abort: Some devices failed to suspend, or early wake event detected
[ 123.965856] PM: suspend exit 1980-01-06 01:37:37.624923612 UTC
sh: write error: Device or resource busy
***********************************************************************************************************
可以使用这个指令打印usb状态机的log:echo file phy-msm-usb.c +p > /sys/kernel/debug/dynamic_debug/control
考虑LPM对usb的控制,特别是vbus部分,由于没有采用smb芯片,应配置成pmic引脚监测vbus的方式
参考文档 MDM9x07\BSP\PMIC\80_NH740_69_VBUS_DETECTION_USING_PMIC.pdf
主要有3点修改:
1. deconfig文件增加CONFIG_GPIO_USB_DETECT=y
2. dts增加pmic的mpp引脚监测
/* MPP pin 2 config for VBUS_DETECT interrupt line */
&pm8019_mpps {
mpp@a100 {
qcom,mode = <0>; /* Digital input */qcom,vin-sel = <3>; /* 1.8V (L11) */qcom,src-sel = <0>; /* QPNP_PIN_SEL_FUNC_CONSTANT */qcom,pull = <1>; /* No Pull */qcom,master-en = <1>; /*Enable GPIO*/status = "ok";
};
};
3.dts禁掉smb358-charger,启用usb_detect
smb358_otg_vreg: smb358-charger@57 {
status = "disabled";
};
usb_detect {
compatible = "qcom,gpio-usbdetect";
interrupt-parent = <&spmi_bus>;
interrupts = <0x0 0xA1 0x0>; /* PMD9607 MPP 2 */
interrupt-names = "vbus_det_irq";
};
执行结果
/sys/power # [ 940.576199] msm_otg 78d9000.usb: phy_reset: success
[ 940.686731] msm_otg 78d9000.usb: USB exited from low power mode
[ 940.698794] msm_hsusb msm_hsusb: CI13XXX_CONTROLLER_RESET_EVENT received
[ 940.704699] msm_hsusb msm_hsusb: CI13XXX_CONTROLLER_CONNECT_EVENT received
[ 940.918915] udc_irq: USB reset interrupt is delayed
[ 940.922874] msm_otg 78d9000.usb: Avail curr from USB = 100
[ 940.929077] android_work: android_work: did not send uevent (0 0 00000000)
[ 941.008406] android_work: android_work: sent uevent USB_STATE=CONNECTED
[ 941.024581] android_work: android_work: sent uevent USB_STATE=DISCONNECTED
[ 941.122982] android_work: android_work: sent uevent USB_STATE=CONNECTED
[ 941.164584] android_usb gadget: high-speed config #1: 86000c8.android_usb
[ 941.170432] diag: USB channel diag connected
[ 941.175045] msm_otg 78d9000.usb: Avail curr from USB = 500
[ 941.182885] gbam_connect_work: gbam_connect_work: Bam channel is not ready
[ 941.234697] android_work: android_work: sent uevent USB_STATE=CONFIGURED
/sys/power #
/sys/power # [ 945.770367] gser_suspend: Un-supported transport: TTY
[ 945.774456] msm_otg 78d9000.usb: Avail curr from USB = 2
[ 945.779715] msm_hsusb msm_hsusb: CI13XXX_CONTROLLER_SUSPEND_EVENT received
[ 945.786985] diag: USB channel diag disconnected
[ 945.792630] gbam_disconnect_work: gbam_disconnect_work: Bam channel is not opened
[ 945.802721] android_work: android_work: sent uevent USB_STATE=DISCONNECTED
[ 945.844687] msm_hsusb msm_hsusb: CI13XXX_CONTROLLER_DISCONNECT_EVENT received
[ 945.858531] msm_otg 78d9000.usb: Avail curr from USB = 0
[ 947.019999] msm_otg 78d9000.usb: USB in low power mode
usb拔掉后可以正常转入DISCONNECTED态