STRUCT OTG_FSM(9)
π NAME
struct otg_fsm β the OTG state machine, built exactly the way the OTG spec says, no cap. It's from the Kernel API Manual, section 9, and it's lowkey the blueprint for how a device flips between host and gadget energy. β¨
πΈ SYNOPSIS
struct otg_fsm {
int id;
int adp_change;
int power_up;
int a_srp_det;
int a_vbus_vld;
int b_conn;
int a_bus_resume;
int a_bus_suspend;
int a_conn;
int b_se0_srp;
int b_ssend_srp;
int b_sess_vld;
int test_device;
int a_bus_drop;
int a_bus_req;
int b_bus_req;
int a_sess_vld;
int b_bus_resume;
int b_bus_suspend;
int drv_vbus;
int loc_conn;
int loc_sof;
int adp_prb;
int adp_sns;
int data_pulse;
int a_set_b_hnp_en;
int b_srp_done;
int b_hnp_enable;
int a_clr_err;
int a_bus_drop_inf;
int a_bus_req_inf;
int a_clr_err_inf;
int b_bus_req_inf;
int a_suspend_req_inf;
int a_wait_vrise_tmout;
int a_wait_vfall_tmout;
int a_wait_bcon_tmout;
int a_aidl_bdis_tmout;
int b_ase0_brst_tmout;
int a_bidl_adis_tmout;
struct otg_fsm_ops *ops;
struct usb_otg *otg;
int protocol;
struct mutex lock;
u8 *host_req_flag;
struct delayed_work hnp_polling_work;
bool hnp_work_inited;
bool state_changed;
};
π¦ MEMBERS
Okay bestie, here's the full roster β every field, every vibe, nothing skipped. π«Ά
idβ TRUE for B-device, FALSE for A-device. That's the whole personality check right there.adp_changeβ TRUE when the current ADP measurement (n), compared to the ADP measurement taken at n-2, differs by more thanCADP_THR. Yes, it's doing math behind your back. πpower_upβ TRUE when the OTG device first powers up its USB system and an ADP measurement is taken if ADP capable.a_srp_detβ TRUE if the A-device detects SRP.a_vbus_vldβ TRUE when VBUS voltage is in regulation. Iconic, stable, well-behaved. πb_connβ TRUE if the A-device detects a connection from the B-device.a_bus_resumeβ TRUE when the B-device detects that the A-device is signaling a resume (K state) B-Device state inputs.a_bus_suspendβ TRUE when the B-device detects that the A-device has put the bus into suspend.a_connβ TRUE if the B-device detects a connection from the A-device.b_se0_srpβ TRUE when the line has been at SE0 for more than the minimum time before generating SRP.b_ssend_srpβ TRUE when the VBUS has been belowVOTG_SESS_VLDfor more than the minimum time before generating SRP.b_sess_vldβ TRUE when the B-device detects that the voltage on VBUS is aboveVOTG_SESS_VLD.test_deviceβ TRUE when the B-device switches to B-Host and detects an OTG test device. This must be set by the host/hub driver β no freelancing, fr fr.a_bus_dropβ TRUE when the A-device application needs to power down the bus.a_bus_reqβ TRUE when the A-device application wants to use the bus. FALSE to suspend the bus.b_bus_reqβ TRUE during the time that the Application running on the B-device wants to use the bus.a_sess_vldβ TRUE if the A-device detects that VBUS is aboveVA_SESS_VLD.b_bus_resumeβ TRUE when the A-device detects that the B-device is signaling resume on the bus.b_bus_suspendβ TRUE when the A-device detects that the B-device has put the bus into suspend.drv_vbusβ TRUE when the A-device is driving VBUS.loc_connβ TRUE when the local device has signaled that it is connected to the bus.loc_sofβ TRUE when the local device is generating activity on the bus.adp_prbβ TRUE when the local device is in the process of doing ADP probing.adp_snsβ TRUE when the B-device is in the process of carrying out ADP sensing.data_pulseβ TRUE when the B-device is performing data line pulsing.a_set_b_hnp_enβ covered down in Internal Variables, keep scrolling bestie πb_srp_doneβ also internal, it's down there β¬οΈb_hnp_enableβ internal too π«a_clr_errβ internal, but spicy πΆοΈ
β¨ DESCRIPTION β¨
Here's the lil map of the whole struct, grouped exactly how the kernel groups it. πΊοΈ
OTG hardware Inputs
Common inputs for A and B device
A-Device state inputs
Application inputs (A-Device)
Application inputs (B-Device)
Auxiliary inputs (OTG v1.3 only. Obsolete now.)
Heads up π β that last group is OTG v1.3 only and obsolete now. It's giving "kept around for the lore".
OTG Output status. Read only for users. Updated by OTG FSM helpers defined in this file
Read-only for users, okay? π The OTG FSM helpers in this file do the updating β you do not touch.
Outputs for Both A and B device
Outputs for B-device state
Internal Variables
These are the ones living in the walls, but we still stan them:
a_set_b_hnp_enβ TRUE when the A-device has successfully set theb_hnp_enablebit in the B-device. Unused as OTG fsm usesotg->host->b_hnp_enableinstead.b_srp_doneβ TRUE when the B-device has completed initiating SRP.b_hnp_enableβ TRUE when the B-device has accepted theSetFeature(b_hnp_enable)B-device. Unused as OTG fsm usesotg->gadget->b_hnp_enableinstead.a_clr_errβ Asserted (by application ?) to cleara_vbus_errdue to an overcurrent condition and causes the A-device to transition toa_wait_vfall.
π SEE ALSO
- Kernel file
./include/linux/usb/otg-fsm.hβ go read it, iykyk π§
That's the whole page, bestie β no notes, no crumbs left behind. π This gem comes to you from ./include/linux/usb, dated October 2026, and it goes by struct otg_fsm(9). Slay it responsibly. ππ₯
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms