VBUS Detect on WP7702

Is there somewhere in linux to check if VBUS is hi ?
Using R15.1

how about this?


root@fx30:~# legato version
21.05.0.54b96444_0a6e18078edde5151619cb964564694d
root@fx30:~# dmesg | grep "low power mode"
//USB cable disconnected
[  614.003217] msm_otg 78d9000.usb: USB in low power mode
//USB cable connected
[ 1032.633019] msm_otg 78d9000.usb: USB exited from low power mode

Thanks
I see these, but is there any of the msm_otg files that contain this info ?
I am trying to setup a callback when this change

You can try this with older firmware

Or you can write a periodic timer function to read dmesg

Just found that you can check this file:


root@fx30:~# legato version
21.05.0.54b96444_0a6e18078edde5151619cb964564694d


//USB cable connected
root@fx30:~# cat  /sys/kernel/debug/msm_otg/otg_state
b_peripheral


//USB cable disconnected
root@fx30:~# cat  /sys/kernel/debug/msm_otg/otg_state
(null)

Thanks i will try that

That seems to be working,
I get 1 null when changing state but b_idle seems to be disconnect (reading once a second),

Is there any descriptions of the modes ?

const char *usb_otg_state_string(enum usb_otg_state state)
{
static const char *const names = {
[OTG_STATE_A_IDLE] = “a_idle”,
[OTG_STATE_A_WAIT_VRISE] = “a_wait_vrise”,
[OTG_STATE_A_WAIT_BCON] = “a_wait_bcon”,
[OTG_STATE_A_HOST] = “a_host”,
[OTG_STATE_A_SUSPEND] = “a_suspend”,
[OTG_STATE_A_PERIPHERAL] = “a_peripheral”,
[OTG_STATE_A_WAIT_VFALL] = “a_wait_vfall”,
[OTG_STATE_A_VBUS_ERR] = “a_vbus_err”,
[OTG_STATE_B_IDLE] = “b_idle”,
[OTG_STATE_B_SRP_INIT] = “b_srp_init”,
[OTG_STATE_B_PERIPHERAL] = “b_peripheral”,
[OTG_STATE_B_WAIT_ACON] = “b_wait_acon”,
[OTG_STATE_B_HOST] = “b_host”,
};

if (state < 0 || state >= ARRAY_SIZE(names))
	return "UNDEFINED";

return names[state];

}

how about this?
https://android.googlesource.com/kernel/msm/+/android-msm-bullhead-3.10-marshmallow-dr/Documentation/usb/msm_otg.txt