xref: /linux/include/linux/usb/chipidea.h (revision 16caf1fa37db4722d8d8c7bc26177279949d75a6)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2e443b333SAlexander Shishkin /*
3e443b333SAlexander Shishkin  * Platform data for the chipidea USB dual role controller
4e443b333SAlexander Shishkin  */
5e443b333SAlexander Shishkin 
6e443b333SAlexander Shishkin #ifndef __LINUX_USB_CHIPIDEA_H
7e443b333SAlexander Shishkin #define __LINUX_USB_CHIPIDEA_H
8e443b333SAlexander Shishkin 
93ecb3e09SIvan T. Ivanov #include <linux/extcon.h>
10a2c3d690SRichard Zhao #include <linux/usb/otg.h>
11a2c3d690SRichard Zhao 
128e22978cSAlexander Shishkin struct ci_hdrc;
133ecb3e09SIvan T. Ivanov 
143ecb3e09SIvan T. Ivanov /**
153ecb3e09SIvan T. Ivanov  * struct ci_hdrc_cable - structure for external connector cable state tracking
165cc49268SStephen Boyd  * @connected: true if cable is connected, false otherwise
173ecb3e09SIvan T. Ivanov  * @changed: set to true when extcon event happen
18a89b94b5SStephen Boyd  * @enabled: set to true if we've enabled the vbus or id interrupt
193ecb3e09SIvan T. Ivanov  * @edev: device which generate events
203ecb3e09SIvan T. Ivanov  * @ci: driver state of the chipidea device
213ecb3e09SIvan T. Ivanov  * @nb: hold event notification callback
223ecb3e09SIvan T. Ivanov  * @conn: used for notification registration
233ecb3e09SIvan T. Ivanov  */
243ecb3e09SIvan T. Ivanov struct ci_hdrc_cable {
255cc49268SStephen Boyd 	bool				connected;
263ecb3e09SIvan T. Ivanov 	bool				changed;
27a89b94b5SStephen Boyd 	bool				enabled;
283ecb3e09SIvan T. Ivanov 	struct extcon_dev		*edev;
293ecb3e09SIvan T. Ivanov 	struct ci_hdrc			*ci;
303ecb3e09SIvan T. Ivanov 	struct notifier_block		nb;
313ecb3e09SIvan T. Ivanov };
323ecb3e09SIvan T. Ivanov 
338e22978cSAlexander Shishkin struct ci_hdrc_platform_data {
34e443b333SAlexander Shishkin 	const char	*name;
35e443b333SAlexander Shishkin 	/* offset of the capability registers */
36e443b333SAlexander Shishkin 	uintptr_t	 capoffset;
37bd841986SAlexander Shishkin 	unsigned	 power_budget;
381e5e2d3dSAntoine Tenart 	struct phy	*phy;
391e5e2d3dSAntoine Tenart 	/* old usb_phy interface */
40ef44cb42SAntoine Tenart 	struct usb_phy	*usb_phy;
4140dcd0e8SMichael Grzeschik 	enum usb_phy_interface phy_mode;
42e443b333SAlexander Shishkin 	unsigned long	 flags;
438e22978cSAlexander Shishkin #define CI_HDRC_REGS_SHARED		BIT(0)
448022d3d5SPeter Chen #define CI_HDRC_DISABLE_DEVICE_STREAMING	BIT(1)
451f874edcSPeter Chen #define CI_HDRC_SUPPORTS_RUNTIME_PM	BIT(2)
468022d3d5SPeter Chen #define CI_HDRC_DISABLE_HOST_STREAMING	BIT(3)
478022d3d5SPeter Chen #define CI_HDRC_DISABLE_STREAMING (CI_HDRC_DISABLE_DEVICE_STREAMING |	\
488022d3d5SPeter Chen 		CI_HDRC_DISABLE_HOST_STREAMING)
49577b232fSPeter Chen 	/*
50577b232fSPeter Chen 	 * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1,
51577b232fSPeter Chen 	 * but otg is not supported (no register otgsc).
52577b232fSPeter Chen 	 */
53577b232fSPeter Chen #define CI_HDRC_DUAL_ROLE_NOT_OTG	BIT(4)
54ed8f8318SPeter Chen #define CI_HDRC_IMX28_WRITE_FIX		BIT(5)
554f6743d5SMichael Grzeschik #define CI_HDRC_FORCE_FULLSPEED		BIT(6)
566adb9b7bSLi Jun #define CI_HDRC_TURN_VBUS_EARLY_ON	BIT(7)
5728362673SPeter Chen #define CI_HDRC_SET_NON_ZERO_TTHA	BIT(8)
5865668718SPeter Chen #define CI_HDRC_OVERRIDE_AHB_BURST	BIT(9)
5996625eadSPeter Chen #define CI_HDRC_OVERRIDE_TX_BURST	BIT(10)
6096625eadSPeter Chen #define CI_HDRC_OVERRIDE_RX_BURST	BIT(11)
618feb3680SStephen Boyd #define CI_HDRC_OVERRIDE_PHY_CONTROL	BIT(12) /* Glue layer manages phy */
62581821aeSDmitry Osipenko #define CI_HDRC_REQUIRES_ALIGNED_DMA	BIT(13)
63691962d1SSascha Hauer 	enum usb_dr_mode	dr_mode;
648e22978cSAlexander Shishkin #define CI_HDRC_CONTROLLER_RESET_EVENT		0
658e22978cSAlexander Shishkin #define CI_HDRC_CONTROLLER_STOPPED_EVENT	1
6611893daeSStephen Boyd 	int	(*notify_event) (struct ci_hdrc *ci, unsigned event);
671542d9c3SPeter Chen 	struct regulator	*reg_vbus;
6879742351SLi Jun 	struct usb_otg_caps	ci_otg_caps;
69f6a9ff07SPeter Chen 	bool			tpl_support;
70df96ed8dSPeter Chen 	/* interrupt threshold setting */
71df96ed8dSPeter Chen 	u32			itc_setting;
7265668718SPeter Chen 	u32			ahb_burst_config;
7396625eadSPeter Chen 	u32			tx_burst_size;
7496625eadSPeter Chen 	u32			rx_burst_size;
753ecb3e09SIvan T. Ivanov 
763ecb3e09SIvan T. Ivanov 	/* VBUS and ID signal state tracking, using extcon framework */
773ecb3e09SIvan T. Ivanov 	struct ci_hdrc_cable		vbus_extcon;
783ecb3e09SIvan T. Ivanov 	struct ci_hdrc_cable		id_extcon;
791fbf4628SFabio Estevam 	u32			phy_clkgate_delay_us;
80*16caf1faSLoic Poulain 
81*16caf1faSLoic Poulain 	/* pins */
82*16caf1faSLoic Poulain 	struct pinctrl *pctl;
83*16caf1faSLoic Poulain 	struct pinctrl_state *pins_default;
84*16caf1faSLoic Poulain 	struct pinctrl_state *pins_host;
85*16caf1faSLoic Poulain 	struct pinctrl_state *pins_device;
86e443b333SAlexander Shishkin };
87e443b333SAlexander Shishkin 
88e443b333SAlexander Shishkin /* Default offset of capability registers */
89e443b333SAlexander Shishkin #define DEF_CAPOFFSET		0x100
90e443b333SAlexander Shishkin 
918e22978cSAlexander Shishkin /* Add ci hdrc device */
928e22978cSAlexander Shishkin struct platform_device *ci_hdrc_add_device(struct device *dev,
93cbc6dc2aSRichard Zhao 			struct resource *res, int nres,
948e22978cSAlexander Shishkin 			struct ci_hdrc_platform_data *platdata);
958e22978cSAlexander Shishkin /* Remove ci hdrc device */
968e22978cSAlexander Shishkin void ci_hdrc_remove_device(struct platform_device *pdev);
97cbc6dc2aSRichard Zhao 
98e443b333SAlexander Shishkin #endif
99