usb: phy: Rename "B-device session end SRP" OTG FSM input
[firefly-linux-kernel-4.4.55.git] / drivers / usb / phy / phy-fsm-usb.h
index 0f3f7d87f887821495eb27d7a3b51e5078bec853..2f185ed0f54f4d8658b4992307391871abbabbb8 100644 (file)
 #define PROTO_HOST     (1)
 #define PROTO_GADGET   (2)
 
+enum otg_fsm_timer {
+       /* Standard OTG timers */
+       A_WAIT_VRISE,
+       A_WAIT_VFALL,
+       A_WAIT_BCON,
+       A_AIDL_BDIS,
+       B_ASE0_BRST,
+       A_BIDL_ADIS,
+
+       /* Auxiliary timers */
+       B_SE0_SRP,
+       B_SRP_FAIL,
+       A_WAIT_ENUM,
+
+       NUM_OTG_FSM_TIMERS,
+};
+
 /* OTG state machine according to the OTG spec */
 struct otg_fsm {
        /* Input */
+       int a_bus_drop;
+       int a_bus_req;
        int a_bus_resume;
        int a_bus_suspend;
        int a_conn;
+       int b_bus_req;
        int a_sess_vld;
        int a_srp_det;
        int a_vbus_vld;
@@ -47,7 +67,7 @@ struct otg_fsm {
        int b_bus_suspend;
        int b_conn;
        int b_se0_srp;
-       int b_sess_end;
+       int b_ssend_srp;
        int b_sess_vld;
        int id;
 
@@ -55,19 +75,22 @@ struct otg_fsm {
        int a_set_b_hnp_en;
        int b_srp_done;
        int b_hnp_enable;
+       int a_clr_err;
 
        /* 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;
 
        /* Informative variables */
-       int a_bus_drop;
-       int a_bus_req;
-       int a_clr_err;
-       int a_suspend_req;
-       int b_bus_req;
+       int a_bus_drop_inf;
+       int a_bus_req_inf;
+       int a_clr_err_inf;
+       int a_suspend_req_inf;
+       int b_bus_req_inf;
 
        /* Output */
        int drv_vbus;
@@ -88,8 +111,8 @@ struct otg_fsm_ops {
        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    (*add_timer)(struct otg_fsm *fsm, void *timer);
-       void    (*del_timer)(struct otg_fsm *fsm, void *timer);
+       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);
 };
@@ -144,7 +167,7 @@ static inline int otg_start_pulse(struct otg_fsm *fsm)
        return 0;
 }
 
-static inline int otg_add_timer(struct otg_fsm *fsm, void *timer)
+static inline int otg_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer timer)
 {
        if (!fsm->ops->add_timer)
                return -EOPNOTSUPP;
@@ -152,7 +175,7 @@ static inline int otg_add_timer(struct otg_fsm *fsm, void *timer)
        return 0;
 }
 
-static inline int otg_del_timer(struct otg_fsm *fsm, void *timer)
+static inline int otg_del_timer(struct otg_fsm *fsm, enum otg_fsm_timer timer)
 {
        if (!fsm->ops->del_timer)
                return -EOPNOTSUPP;
@@ -160,9 +183,18 @@ static inline int otg_del_timer(struct otg_fsm *fsm, void *timer)
        return 0;
 }
 
-int otg_statemachine(struct otg_fsm *fsm);
+static inline int otg_start_host(struct otg_fsm *fsm, int on)
+{
+       if (!fsm->ops->start_host)
+               return -EOPNOTSUPP;
+       return fsm->ops->start_host(fsm, on);
+}
 
-/* Defined by device specific driver, for different timer implementation */
-extern struct fsl_otg_timer *a_wait_vrise_tmr, *a_wait_bcon_tmr,
-       *a_aidl_bdis_tmr, *b_ase0_brst_tmr, *b_se0_srp_tmr, *b_srp_fail_tmr,
-       *a_wait_enum_tmr;
+static inline int otg_start_gadget(struct otg_fsm *fsm, int on)
+{
+       if (!fsm->ops->start_gadget)
+               return -EOPNOTSUPP;
+       return fsm->ops->start_gadget(fsm, on);
+}
+
+int otg_statemachine(struct otg_fsm *fsm);