@@ -27,12 +27,15 @@ struct dwc3_properties {
2727 * @res: resource for the DWC3 core mmio region
2828 * @ignore_clocks_and_resets: clocks and resets defined for the device should
2929 * be ignored by the DWC3 core, as they are managed by the glue
30+ * @skip_core_init_mode: Skip the finial initialization of the target mode, as
31+ * it must be managed by the glue
3032 * @properties: dwc3 software manage properties
3133 */
3234struct dwc3_probe_data {
3335 struct dwc3 * dwc ;
3436 struct resource * res ;
3537 bool ignore_clocks_and_resets ;
38+ bool skip_core_init_mode ;
3639 struct dwc3_properties properties ;
3740};
3841
@@ -74,4 +77,117 @@ int dwc3_pm_resume(struct dwc3 *dwc);
7477void dwc3_pm_complete (struct dwc3 * dwc );
7578int dwc3_pm_prepare (struct dwc3 * dwc );
7679
80+
81+ /* All of the following functions must only be used with skip_core_init_mode */
82+
83+ /**
84+ * dwc3_core_init - Initialize DWC3 core hardware
85+ * @dwc: Pointer to DWC3 controller context
86+ *
87+ * Configures and initializes the core hardware, usually done by dwc3_core_probe.
88+ * This function is provided for platforms that use skip_core_init_mode and need
89+ * to finalize the core initialization after some platform-specific setup.
90+ * It must only be called when using skip_core_init_mode and before
91+ * dwc3_host_init or dwc3_gadget_init.
92+ *
93+ * Return: 0 on success, negative error code on failure
94+ */
95+ int dwc3_core_init (struct dwc3 * dwc );
96+
97+ /**
98+ * dwc3_core_exit - Shut down DWC3 core hardware
99+ * @dwc: Pointer to DWC3 controller context
100+ *
101+ * Disables and cleans up the core hardware state. This is usually handled
102+ * internally by dwc3 and must only be called when using skip_core_init_mode
103+ * and only after dwc3_core_init. Afterwards, dwc3_core_init may be called
104+ * again.
105+ */
106+ void dwc3_core_exit (struct dwc3 * dwc );
107+
108+ /**
109+ * dwc3_host_init - Initialize host mode operation
110+ * @dwc: Pointer to DWC3 controller context
111+ *
112+ * Initializes the controller for USB host mode operation, usually done by
113+ * dwc3_core_probe or from within the dwc3 USB role switch callback.
114+ * This function is provided for platforms that use skip_core_init_mode and need
115+ * to finalize the host initialization after some platform-specific setup.
116+ * It must not be called before dwc3_core_init or when skip_core_init_mode is
117+ * not used. It must also not be called when gadget or host mode has already
118+ * been initialized.
119+ *
120+ * Return: 0 on success, negative error code on failure
121+ */
122+ int dwc3_host_init (struct dwc3 * dwc );
123+
124+ /**
125+ * dwc3_host_exit - Shut down host mode operation
126+ * @dwc: Pointer to DWC3 controller context
127+ *
128+ * Disables and cleans up host mode resources, usually done by
129+ * the dwc3 USB role switch callback before switching controller mode.
130+ * It must only be called when skip_core_init_mode is used and only after
131+ * dwc3_host_init.
132+ */
133+ void dwc3_host_exit (struct dwc3 * dwc );
134+
135+ /**
136+ * dwc3_gadget_init - Initialize gadget mode operation
137+ * @dwc: Pointer to DWC3 controller context
138+ *
139+ * Initializes the controller for USB gadget mode operation, usually done by
140+ * dwc3_core_probe or from within the dwc3 USB role switch callback. This
141+ * function is provided for platforms that use skip_core_init_mode and need to
142+ * finalize the gadget initialization after some platform-specific setup.
143+ * It must not be called before dwc3_core_init or when skip_core_init_mode is
144+ * not used. It must also not be called when gadget or host mode has already
145+ * been initialized.
146+ *
147+ * Return: 0 on success, negative error code on failure
148+ */
149+ int dwc3_gadget_init (struct dwc3 * dwc );
150+
151+ /**
152+ * dwc3_gadget_exit - Shut down gadget mode operation
153+ * @dwc: Pointer to DWC3 controller context
154+ *
155+ * Disables and cleans up gadget mode resources, usually done by
156+ * the dwc3 USB role switch callback before switching controller mode.
157+ * It must only be called when skip_core_init_mode is used and only after
158+ * dwc3_gadget_init.
159+ */
160+ void dwc3_gadget_exit (struct dwc3 * dwc );
161+
162+ /**
163+ * dwc3_enable_susphy - Control SUSPHY status for all USB ports
164+ * @dwc: Pointer to DWC3 controller context
165+ * @enable: True to enable SUSPHY, false to disable
166+ *
167+ * Enables or disables the USB3 PHY SUSPEND and USB2 PHY SUSPHY feature for
168+ * all available ports.
169+ * This is usually handled by the dwc3 core code and should only be used
170+ * when skip_core_init_mode is used and the glue layer needs to manage SUSPHY
171+ * settings itself, e.g., due to platform-specific requirements during mode
172+ * switches.
173+ */
174+ void dwc3_enable_susphy (struct dwc3 * dwc , bool enable );
175+
176+ /**
177+ * dwc3_set_prtcap - Set the USB controller PRTCAP mode
178+ * @dwc: Pointer to DWC3 controller context
179+ * @mode: Target mode, must be one of DWC3_GCTL_PRTCAP_{HOST,DEVICE,OTG}
180+ * @ignore_susphy: If true, skip disabling the SUSPHY and keep the current state
181+ *
182+ * Updates PRTCAP of the controller and current_dr_role inside the dwc3
183+ * structure. For DRD controllers, this also disables SUSPHY unless explicitly
184+ * told to skip via the ignore_susphy parameter.
185+ *
186+ * This is usually handled by the dwc3 core code and should only be used
187+ * when skip_core_init_mode is used and the glue layer needs to manage mode
188+ * transitions itself due to platform-specific requirements. It must be called
189+ * with the correct mode before calling dwc3_host_init or dwc3_gadget_init.
190+ */
191+ void dwc3_set_prtcap (struct dwc3 * dwc , u32 mode , bool ignore_susphy );
192+
77193#endif
0 commit comments