18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2014 Freescale Semiconductor, Inc.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author: Jun Li
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __DRIVERS_USB_CHIPIDEA_OTG_FSM_H
98c2ecf20Sopenharmony_ci#define __DRIVERS_USB_CHIPIDEA_OTG_FSM_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/usb/otg-fsm.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/*
148c2ecf20Sopenharmony_ci *  A-DEVICE timing  constants
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* Wait for VBUS Rise  */
188c2ecf20Sopenharmony_ci#define TA_WAIT_VRISE        (100)	/* a_wait_vrise: section 7.1.2
198c2ecf20Sopenharmony_ci					 * a_wait_vrise_tmr: section 7.4.5.1
208c2ecf20Sopenharmony_ci					 * TA_VBUS_RISE <= 100ms, section 4.4
218c2ecf20Sopenharmony_ci					 * Table 4-1: Electrical Characteristics
228c2ecf20Sopenharmony_ci					 * ->DC Electrical Timing
238c2ecf20Sopenharmony_ci					 */
248c2ecf20Sopenharmony_ci/* Wait for VBUS Fall  */
258c2ecf20Sopenharmony_ci#define TA_WAIT_VFALL        (1000)	/* a_wait_vfall: section 7.1.7
268c2ecf20Sopenharmony_ci					 * a_wait_vfall_tmr: section: 7.4.5.2
278c2ecf20Sopenharmony_ci					 */
288c2ecf20Sopenharmony_ci/* Wait for B-Connect */
298c2ecf20Sopenharmony_ci#define TA_WAIT_BCON         (10000)	/* a_wait_bcon: section 7.1.3
308c2ecf20Sopenharmony_ci					 * TA_WAIT_BCON: should be between 1100
318c2ecf20Sopenharmony_ci					 * and 30000 ms, section 5.5, Table 5-1
328c2ecf20Sopenharmony_ci					 */
338c2ecf20Sopenharmony_ci/* A-Idle to B-Disconnect */
348c2ecf20Sopenharmony_ci#define TA_AIDL_BDIS         (5000)	/* a_suspend min 200 ms, section 5.2.1
358c2ecf20Sopenharmony_ci					 * TA_AIDL_BDIS: section 5.5, Table 5-1
368c2ecf20Sopenharmony_ci					 */
378c2ecf20Sopenharmony_ci/* B-Idle to A-Disconnect */
388c2ecf20Sopenharmony_ci#define TA_BIDL_ADIS         (500)	/* TA_BIDL_ADIS: section 5.2.1
398c2ecf20Sopenharmony_ci					 * 500ms is used for B switch to host
408c2ecf20Sopenharmony_ci					 * for safe
418c2ecf20Sopenharmony_ci					 */
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*
448c2ecf20Sopenharmony_ci * B-device timing constants
458c2ecf20Sopenharmony_ci */
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci/* Data-Line Pulse Time*/
488c2ecf20Sopenharmony_ci#define TB_DATA_PLS          (10)	/* b_srp_init,continue 5~10ms
498c2ecf20Sopenharmony_ci					 * section:5.1.3
508c2ecf20Sopenharmony_ci					 */
518c2ecf20Sopenharmony_ci/* SRP Fail Time  */
528c2ecf20Sopenharmony_ci#define TB_SRP_FAIL          (6000)	/* b_srp_init,fail time 5~6s
538c2ecf20Sopenharmony_ci					 * section:5.1.6
548c2ecf20Sopenharmony_ci					 */
558c2ecf20Sopenharmony_ci/* A-SE0 to B-Reset  */
568c2ecf20Sopenharmony_ci#define TB_ASE0_BRST         (155)	/* minimum 155 ms, section:5.3.1 */
578c2ecf20Sopenharmony_ci/* SE0 Time Before SRP */
588c2ecf20Sopenharmony_ci#define TB_SE0_SRP           (1000)	/* b_idle,minimum 1s, section:5.1.2 */
598c2ecf20Sopenharmony_ci/* SSEND time before SRP */
608c2ecf20Sopenharmony_ci#define TB_SSEND_SRP         (1500)	/* minimum 1.5 sec, section:5.1.2 */
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define TB_AIDL_BDIS         (20)	/* 4ms ~ 150ms, section 5.2.1 */
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_USB_OTG_FSM)
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciint ci_hdrc_otg_fsm_init(struct ci_hdrc *ci);
678c2ecf20Sopenharmony_ciint ci_otg_fsm_work(struct ci_hdrc *ci);
688c2ecf20Sopenharmony_ciirqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci);
698c2ecf20Sopenharmony_civoid ci_hdrc_otg_fsm_start(struct ci_hdrc *ci);
708c2ecf20Sopenharmony_civoid ci_hdrc_otg_fsm_remove(struct ci_hdrc *ci);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#else
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic inline int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
758c2ecf20Sopenharmony_ci{
768c2ecf20Sopenharmony_ci	return 0;
778c2ecf20Sopenharmony_ci}
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_cistatic inline int ci_otg_fsm_work(struct ci_hdrc *ci)
808c2ecf20Sopenharmony_ci{
818c2ecf20Sopenharmony_ci	return -ENXIO;
828c2ecf20Sopenharmony_ci}
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_cistatic inline irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci)
858c2ecf20Sopenharmony_ci{
868c2ecf20Sopenharmony_ci	return IRQ_NONE;
878c2ecf20Sopenharmony_ci}
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_cistatic inline void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci)
908c2ecf20Sopenharmony_ci{
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci}
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_cistatic inline void ci_hdrc_otg_fsm_remove(struct ci_hdrc *ci)
958c2ecf20Sopenharmony_ci{
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci}
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci#endif
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#endif /* __DRIVERS_USB_CHIPIDEA_OTG_FSM_H */
102