xref: /linux/include/linux/usb/chipidea.h (revision 74ce1896c6c65b2f8cccbf59162d542988835835)
1 /*
2  * Platform data for the chipidea USB dual role controller
3  */
4 
5 #ifndef __LINUX_USB_CHIPIDEA_H
6 #define __LINUX_USB_CHIPIDEA_H
7 
8 #include <linux/extcon.h>
9 #include <linux/usb/otg.h>
10 
11 struct ci_hdrc;
12 
13 /**
14  * struct ci_hdrc_cable - structure for external connector cable state tracking
15  * @connected: true if cable is connected, false otherwise
16  * @changed: set to true when extcon event happen
17  * @enabled: set to true if we've enabled the vbus or id interrupt
18  * @edev: device which generate events
19  * @ci: driver state of the chipidea device
20  * @nb: hold event notification callback
21  * @conn: used for notification registration
22  */
23 struct ci_hdrc_cable {
24 	bool				connected;
25 	bool				changed;
26 	bool				enabled;
27 	struct extcon_dev		*edev;
28 	struct ci_hdrc			*ci;
29 	struct notifier_block		nb;
30 };
31 
32 struct ci_hdrc_platform_data {
33 	const char	*name;
34 	/* offset of the capability registers */
35 	uintptr_t	 capoffset;
36 	unsigned	 power_budget;
37 	struct phy	*phy;
38 	/* old usb_phy interface */
39 	struct usb_phy	*usb_phy;
40 	enum usb_phy_interface phy_mode;
41 	unsigned long	 flags;
42 #define CI_HDRC_REGS_SHARED		BIT(0)
43 #define CI_HDRC_DISABLE_DEVICE_STREAMING	BIT(1)
44 #define CI_HDRC_SUPPORTS_RUNTIME_PM	BIT(2)
45 #define CI_HDRC_DISABLE_HOST_STREAMING	BIT(3)
46 #define CI_HDRC_DISABLE_STREAMING (CI_HDRC_DISABLE_DEVICE_STREAMING |	\
47 		CI_HDRC_DISABLE_HOST_STREAMING)
48 	/*
49 	 * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1,
50 	 * but otg is not supported (no register otgsc).
51 	 */
52 #define CI_HDRC_DUAL_ROLE_NOT_OTG	BIT(4)
53 #define CI_HDRC_IMX28_WRITE_FIX		BIT(5)
54 #define CI_HDRC_FORCE_FULLSPEED		BIT(6)
55 #define CI_HDRC_TURN_VBUS_EARLY_ON	BIT(7)
56 #define CI_HDRC_SET_NON_ZERO_TTHA	BIT(8)
57 #define CI_HDRC_OVERRIDE_AHB_BURST	BIT(9)
58 #define CI_HDRC_OVERRIDE_TX_BURST	BIT(10)
59 #define CI_HDRC_OVERRIDE_RX_BURST	BIT(11)
60 #define CI_HDRC_OVERRIDE_PHY_CONTROL	BIT(12) /* Glue layer manages phy */
61 #define CI_HDRC_REQUIRES_ALIGNED_DMA	BIT(13)
62 	enum usb_dr_mode	dr_mode;
63 #define CI_HDRC_CONTROLLER_RESET_EVENT		0
64 #define CI_HDRC_CONTROLLER_STOPPED_EVENT	1
65 	int	(*notify_event) (struct ci_hdrc *ci, unsigned event);
66 	struct regulator	*reg_vbus;
67 	struct usb_otg_caps	ci_otg_caps;
68 	bool			tpl_support;
69 	/* interrupt threshold setting */
70 	u32			itc_setting;
71 	u32			ahb_burst_config;
72 	u32			tx_burst_size;
73 	u32			rx_burst_size;
74 
75 	/* VBUS and ID signal state tracking, using extcon framework */
76 	struct ci_hdrc_cable		vbus_extcon;
77 	struct ci_hdrc_cable		id_extcon;
78 	u32			phy_clkgate_delay_us;
79 };
80 
81 /* Default offset of capability registers */
82 #define DEF_CAPOFFSET		0x100
83 
84 /* Add ci hdrc device */
85 struct platform_device *ci_hdrc_add_device(struct device *dev,
86 			struct resource *res, int nres,
87 			struct ci_hdrc_platform_data *platdata);
88 /* Remove ci hdrc device */
89 void ci_hdrc_remove_device(struct platform_device *pdev);
90 
91 #endif
92