/** *structotg_fsm-OTGstatemachineaccordingtotheOTGspec * *OTGhardwareInputs * *CommoninputsforAandBdevice *@id:TRUEforB-device,FALSEforA-device. *@adp_change:TRUEwhencurrentADPmeasurement(n)value,comparedtothe *ADPmeasurementtakenatn-2,differsbymorethanCADP_THR *@power_up:TRUEwhentheOTGdevicefirstpowersupitsUSBsystemand *ADPmeasurementtakenifADPcapable * *A-Devicestateinputs *@a_srp_det:TRUEiftheA-devicedetectsSRP *@a_vbus_vld:TRUEwhenVBUSvoltageisinregulation *@b_conn:TRUEiftheA-devicedetectsconnectionfromtheB-device *@a_bus_resume:TRUEwhentheB-devicedetectsthattheA-deviceissignaling *aresume(Kstate) *B-Devicestateinputs *@a_bus_suspend:TRUEwhentheB-devicedetectsthattheA-devicehasputthe *busintosuspend *@a_conn:TRUEiftheB-devicedetectsaconnectionfromtheA-device *@b_se0_srp:TRUEwhenthelinehasbeenatSE0formorethantheminimum *timebeforegeneratingSRP *@b_ssend_srp:TRUEwhentheVBUShasbeenbelowVOTG_SESS_VLDformorethan *theminimumtimebeforegeneratingSRP *@b_sess_vld:TRUEwhentheB-devicedetectsthatthevoltageonVBUSis *aboveVOTG_SESS_VLD *@test_device:TRUEwhentheB-deviceswitchestoB-HostanddetectsanOTG *testdevice.Thismustbesetbyhost/hubdriver * *Applicationinputs(A-Device) *@a_bus_drop:TRUEwhenA-deviceapplicationneedstopowerdownthebus *@a_bus_req:TRUEwhenA-deviceapplicationwantstousethebus. *FALSEtosuspendthebus * *Applicationinputs(B-Device) *@b_bus_req:TRUEduringthetimethattheApplicationrunningonthe *B-devicewantstousethebus * *Auxiliaryinputs(OTGv1.3only.Obsoletenow.) *@a_sess_vld:TRUEiftheA-devicedetectsthatVBUSisaboveVA_SESS_VLD *@b_bus_suspend:TRUEwhentheA-devicedetectsthattheB-devicehasput *thebusintosuspend *@b_bus_resume:TRUEwhentheA-devicedetectsthattheB-deviceissignaling *resumeonthebus * *OTGOutputstatus.Readonlyforusers.UpdatedbyOTGFSMhelpersdefined *inthisfile * *OutputsforBothAandBdevice *@drv_vbus:TRUEwhenA-deviceisdrivingVBUS *@loc_conn:TRUEwhenthelocaldevicehassignaledthatitisconnected *tothebus *@loc_sof:TRUEwhenthelocaldeviceisgeneratingactivityonthebus *@adp_prb:TRUEwhenthelocaldeviceisintheprocessofdoing *ADPprobing * *OutputsforB-devicestate *@adp_sns:TRUEwhentheB-deviceisintheprocessofcarryingout *ADPsensing *@data_pulse:TRUEwhentheB-deviceisperformingdatalinepulsing * *InternalVariables * *a_set_b_hnp_en:TRUEwhentheA-devicehassuccessfullysetthe *b_hnp_enablebitintheB-device. *UnusedasOTGfsmusesotg->host->b_hnp_enableinstead *b_srp_done:TRUEwhentheB-devicehascompletedinitiatingSRP *b_hnp_enable:TRUEwhentheB-devicehasacceptedthe *SetFeature(b_hnp_enable)B-device. *UnusedasOTGfsmusesotg->gadget->b_hnp_enableinstead *a_clr_err:Asserted(byapplication?)tocleara_vbus_errduetoan *overcurrentconditionandcausestheA-devicetotransition *toa_wait_vfall
*/ struct otg_fsm { /* Input */ 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;
/* Auxiliary inputs */ int a_sess_vld; int b_bus_resume; int b_bus_suspend;
/* Output */ int drv_vbus; int loc_conn; int loc_sof; int adp_prb; int adp_sns; int data_pulse;
/* Internal variables */ int a_set_b_hnp_en; int b_srp_done; int b_hnp_enable; int a_clr_err;
/* Informative variables. All unused as of now */ int a_bus_drop_inf; int a_bus_req_inf; int a_clr_err_inf; int b_bus_req_inf; /* Auxiliary informative variables */ int a_suspend_req_inf;
/* Timeout indicator for timers */ 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;
/* Current usb protocol used: 0:undefine; 1:host; 2:client */ int protocol; struct mutex lock;
u8 *host_req_flag; struct delayed_work hnp_polling_work; bool hnp_work_inited; bool state_changed;
};
struct otg_fsm_ops { void (*chrg_vbus)(struct otg_fsm *fsm, int on); void (*drv_vbus)(struct otg_fsm *fsm, int on); void (*loc_conn)(struct otg_fsm *fsm, int on); void (*loc_sof)(struct otg_fsm *fsm, int on); void (*start_pulse)(struct otg_fsm *fsm); void (*start_adp_prb)(struct otg_fsm *fsm); void (*start_adp_sns)(struct otg_fsm *fsm); void (*add_timer)(struct otg_fsm *fsm, enum otg_fsm_timer timer); void (*del_timer)(struct otg_fsm *fsm, enum otg_fsm_timer timer); int (*start_host)(struct otg_fsm *fsm, int on); int (*start_gadget)(struct otg_fsm *fsm, int on);
};
staticinlineint otg_chrg_vbus(struct otg_fsm *fsm, int on)
{ if (!fsm->ops->chrg_vbus) return -EOPNOTSUPP;
fsm->ops->chrg_vbus(fsm, on); return0;
}
staticinlineint otg_drv_vbus(struct otg_fsm *fsm, int on)
{ if (!fsm->ops->drv_vbus) return -EOPNOTSUPP; if (fsm->drv_vbus != on) {
fsm->drv_vbus = on;
fsm->ops->drv_vbus(fsm, on);
} return0;
}
staticinlineint otg_loc_conn(struct otg_fsm *fsm, int on)
{ if (!fsm->ops->loc_conn) return -EOPNOTSUPP; if (fsm->loc_conn != on) {
fsm->loc_conn = on;
fsm->ops->loc_conn(fsm, on);
} return0;
}
staticinlineint otg_loc_sof(struct otg_fsm *fsm, int on)
{ if (!fsm->ops->loc_sof) return -EOPNOTSUPP; if (fsm->loc_sof != on) {
fsm->loc_sof = on;
fsm->ops->loc_sof(fsm, on);
} return0;
}
staticinlineint otg_start_pulse(struct otg_fsm *fsm)
{ if (!fsm->ops->start_pulse) return -EOPNOTSUPP; if (!fsm->data_pulse) {
fsm->data_pulse = 1;
fsm->ops->start_pulse(fsm);
} return0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.