xref: /openbmc/u-boot/drivers/usb/musb-new/ti-musb.c (revision 522e0354)
183d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
228b8d5fdSMugunthan V N /*
328b8d5fdSMugunthan V N  * MISC driver for TI MUSB Glue.
428b8d5fdSMugunthan V N  *
528b8d5fdSMugunthan V N  * (C) Copyright 2016
628b8d5fdSMugunthan V N  *     Texas Instruments Incorporated, <www.ti.com>
728b8d5fdSMugunthan V N  */
828b8d5fdSMugunthan V N #include <common.h>
928b8d5fdSMugunthan V N #include <command.h>
1028b8d5fdSMugunthan V N #include <console.h>
1128b8d5fdSMugunthan V N #include <dm.h>
1228b8d5fdSMugunthan V N #include <linux/usb/otg.h>
1328b8d5fdSMugunthan V N #include <dm/device-internal.h>
1428b8d5fdSMugunthan V N #include <dm/lists.h>
1528b8d5fdSMugunthan V N 
16ae6acf9fSMugunthan V N #include <asm/io.h>
17ae6acf9fSMugunthan V N #include <asm/omap_musb.h>
18ae6acf9fSMugunthan V N #include "musb_uboot.h"
19ae6acf9fSMugunthan V N 
2028b8d5fdSMugunthan V N DECLARE_GLOBAL_DATA_PTR;
2128b8d5fdSMugunthan V N 
22fd09c205SSven Schwermer #if CONFIG_IS_ENABLED(DM_USB)
23ae6acf9fSMugunthan V N /* USB 2.0 PHY Control */
24ae6acf9fSMugunthan V N #define CM_PHY_PWRDN			(1 << 0)
25ae6acf9fSMugunthan V N #define CM_PHY_OTG_PWRDN		(1 << 1)
26ae6acf9fSMugunthan V N #define OTGVDET_EN			(1 << 19)
27ae6acf9fSMugunthan V N #define OTGSESSENDEN			(1 << 20)
28ae6acf9fSMugunthan V N 
29*7d98dbccSJean-Jacques Hiblot #define AM335X_USB0_CTRL	0x0
30ae6acf9fSMugunthan V N #define AM335X_USB1_CTRL	0x8
31ae6acf9fSMugunthan V N 
ti_musb_set_phy_power(struct udevice * dev,u8 on)32*7d98dbccSJean-Jacques Hiblot static void ti_musb_set_phy_power(struct udevice *dev, u8 on)
33*7d98dbccSJean-Jacques Hiblot {
34*7d98dbccSJean-Jacques Hiblot 	struct ti_musb_platdata *platdata = dev_get_platdata(dev);
35*7d98dbccSJean-Jacques Hiblot 
36*7d98dbccSJean-Jacques Hiblot 	if (!platdata->ctrl_mod_base)
37*7d98dbccSJean-Jacques Hiblot 		return;
38*7d98dbccSJean-Jacques Hiblot 
39*7d98dbccSJean-Jacques Hiblot 	if (on) {
40*7d98dbccSJean-Jacques Hiblot 		clrsetbits_le32(platdata->ctrl_mod_base,
41*7d98dbccSJean-Jacques Hiblot 				CM_PHY_PWRDN | CM_PHY_OTG_PWRDN,
42*7d98dbccSJean-Jacques Hiblot 				OTGVDET_EN | OTGSESSENDEN);
43*7d98dbccSJean-Jacques Hiblot 	} else {
44*7d98dbccSJean-Jacques Hiblot 		clrsetbits_le32(platdata->ctrl_mod_base, 0,
45*7d98dbccSJean-Jacques Hiblot 				CM_PHY_PWRDN | CM_PHY_OTG_PWRDN);
46*7d98dbccSJean-Jacques Hiblot 	}
47*7d98dbccSJean-Jacques Hiblot }
48*7d98dbccSJean-Jacques Hiblot 
49*7d98dbccSJean-Jacques Hiblot #if CONFIG_IS_ENABLED(OF_CONTROL)
50ae6acf9fSMugunthan V N 
ti_musb_get_usb_index(int node)51ae6acf9fSMugunthan V N static int ti_musb_get_usb_index(int node)
52ae6acf9fSMugunthan V N {
53ae6acf9fSMugunthan V N 	const void *fdt = gd->fdt_blob;
54ae6acf9fSMugunthan V N 	int i = 0;
55ae6acf9fSMugunthan V N 	char path[64];
56ae6acf9fSMugunthan V N 	const char *alias_path;
57ae6acf9fSMugunthan V N 	char alias[16];
58ae6acf9fSMugunthan V N 
59ae6acf9fSMugunthan V N 	fdt_get_path(fdt, node, path, sizeof(path));
60ae6acf9fSMugunthan V N 
61ae6acf9fSMugunthan V N 	do {
62ae6acf9fSMugunthan V N 		snprintf(alias, sizeof(alias), "usb%d", i);
63ae6acf9fSMugunthan V N 		alias_path = fdt_get_alias(fdt, alias);
64ae6acf9fSMugunthan V N 		if (alias_path == NULL) {
65ae6acf9fSMugunthan V N 			debug("USB index not found\n");
66ae6acf9fSMugunthan V N 			return -ENOENT;
67ae6acf9fSMugunthan V N 		}
68ae6acf9fSMugunthan V N 
69ae6acf9fSMugunthan V N 		if (!strcmp(path, alias_path))
70ae6acf9fSMugunthan V N 			return i;
71ae6acf9fSMugunthan V N 
72ae6acf9fSMugunthan V N 		i++;
73ae6acf9fSMugunthan V N 	} while (alias_path);
74ae6acf9fSMugunthan V N 
75ae6acf9fSMugunthan V N 	return -ENOENT;
76ae6acf9fSMugunthan V N }
77ae6acf9fSMugunthan V N 
ti_musb_ofdata_to_platdata(struct udevice * dev)78ae6acf9fSMugunthan V N static int ti_musb_ofdata_to_platdata(struct udevice *dev)
79ae6acf9fSMugunthan V N {
80ae6acf9fSMugunthan V N 	struct ti_musb_platdata *platdata = dev_get_platdata(dev);
81ae6acf9fSMugunthan V N 	const void *fdt = gd->fdt_blob;
82e160f7d4SSimon Glass 	int node = dev_of_offset(dev);
83ae6acf9fSMugunthan V N 	int phys;
84ae6acf9fSMugunthan V N 	int ctrl_mod;
85ae6acf9fSMugunthan V N 	int usb_index;
86*7d98dbccSJean-Jacques Hiblot 	struct musb_hdrc_config *musb_config;
87ae6acf9fSMugunthan V N 
88a821c4afSSimon Glass 	platdata->base = (void *)devfdt_get_addr_index(dev, 1);
89ae6acf9fSMugunthan V N 
90ae6acf9fSMugunthan V N 	phys = fdtdec_lookup_phandle(fdt, node, "phys");
91ae6acf9fSMugunthan V N 	ctrl_mod = fdtdec_lookup_phandle(fdt, phys, "ti,ctrl_mod");
92ae6acf9fSMugunthan V N 	platdata->ctrl_mod_base = (void *)fdtdec_get_addr(fdt, ctrl_mod, "reg");
93ae6acf9fSMugunthan V N 	usb_index = ti_musb_get_usb_index(node);
94ae6acf9fSMugunthan V N 	switch (usb_index) {
95ae6acf9fSMugunthan V N 	case 1:
96ae6acf9fSMugunthan V N 		platdata->ctrl_mod_base += AM335X_USB1_CTRL;
97*7d98dbccSJean-Jacques Hiblot 		break;
98ae6acf9fSMugunthan V N 	case 0:
99*7d98dbccSJean-Jacques Hiblot 		platdata->ctrl_mod_base += AM335X_USB0_CTRL;
100*7d98dbccSJean-Jacques Hiblot 		break;
101ae6acf9fSMugunthan V N 	default:
102ae6acf9fSMugunthan V N 		break;
103ae6acf9fSMugunthan V N 	}
104ae6acf9fSMugunthan V N 
105*7d98dbccSJean-Jacques Hiblot 	musb_config = malloc(sizeof(struct musb_hdrc_config));
106*7d98dbccSJean-Jacques Hiblot 	memset(musb_config, 0, sizeof(struct musb_hdrc_config));
107*7d98dbccSJean-Jacques Hiblot 
108*7d98dbccSJean-Jacques Hiblot 	musb_config->multipoint = fdtdec_get_int(fdt, node,
109*7d98dbccSJean-Jacques Hiblot 						 "mentor,multipoint", -1);
110*7d98dbccSJean-Jacques Hiblot 	if (musb_config->multipoint < 0) {
1119b643e31SMasahiro Yamada 		pr_err("MUSB multipoint DT entry missing\n");
112ae6acf9fSMugunthan V N 		return -ENOENT;
113ae6acf9fSMugunthan V N 	}
114ae6acf9fSMugunthan V N 
115*7d98dbccSJean-Jacques Hiblot 	musb_config->dyn_fifo = 1;
116ae6acf9fSMugunthan V N 
117*7d98dbccSJean-Jacques Hiblot 	musb_config->num_eps = fdtdec_get_int(fdt, node, "mentor,num-eps",
118*7d98dbccSJean-Jacques Hiblot 					      -1);
119*7d98dbccSJean-Jacques Hiblot 	if (musb_config->num_eps < 0) {
1209b643e31SMasahiro Yamada 		pr_err("MUSB num-eps DT entry missing\n");
121ae6acf9fSMugunthan V N 		return -ENOENT;
122ae6acf9fSMugunthan V N 	}
123ae6acf9fSMugunthan V N 
124*7d98dbccSJean-Jacques Hiblot 	musb_config->ram_bits = fdtdec_get_int(fdt, node, "mentor,ram-bits",
125*7d98dbccSJean-Jacques Hiblot 					       -1);
126*7d98dbccSJean-Jacques Hiblot 	if (musb_config->ram_bits < 0) {
1279b643e31SMasahiro Yamada 		pr_err("MUSB ram-bits DT entry missing\n");
128ae6acf9fSMugunthan V N 		return -ENOENT;
129ae6acf9fSMugunthan V N 	}
130ae6acf9fSMugunthan V N 
131*7d98dbccSJean-Jacques Hiblot 	platdata->plat.config = musb_config;
132ae6acf9fSMugunthan V N 
133ae6acf9fSMugunthan V N 	platdata->plat.power = fdtdec_get_int(fdt, node, "mentor,power", -1);
134ae6acf9fSMugunthan V N 	if (platdata->plat.power < 0) {
1359b643e31SMasahiro Yamada 		pr_err("MUSB mentor,power DT entry missing\n");
136ae6acf9fSMugunthan V N 		return -ENOENT;
137ae6acf9fSMugunthan V N 	}
138ae6acf9fSMugunthan V N 
139ae6acf9fSMugunthan V N 	platdata->plat.platform_ops = &musb_dsps_ops;
140ae6acf9fSMugunthan V N 
141ae6acf9fSMugunthan V N 	return 0;
142ae6acf9fSMugunthan V N }
143*7d98dbccSJean-Jacques Hiblot #endif
144ae6acf9fSMugunthan V N 
ti_musb_host_probe(struct udevice * dev)145ae6acf9fSMugunthan V N static int ti_musb_host_probe(struct udevice *dev)
146ae6acf9fSMugunthan V N {
147ae6acf9fSMugunthan V N 	struct musb_host_data *host = dev_get_priv(dev);
148ae6acf9fSMugunthan V N 	struct ti_musb_platdata *platdata = dev_get_platdata(dev);
149ae6acf9fSMugunthan V N 	struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
150ae6acf9fSMugunthan V N 	int ret;
151ae6acf9fSMugunthan V N 
152ae6acf9fSMugunthan V N 	priv->desc_before_addr = true;
153ae6acf9fSMugunthan V N 
154ae6acf9fSMugunthan V N 	host->host = musb_init_controller(&platdata->plat,
155*7d98dbccSJean-Jacques Hiblot 					  NULL,
156ae6acf9fSMugunthan V N 					  platdata->base);
157ae6acf9fSMugunthan V N 	if (!host->host)
158ae6acf9fSMugunthan V N 		return -EIO;
159ae6acf9fSMugunthan V N 
160*7d98dbccSJean-Jacques Hiblot 	ti_musb_set_phy_power(dev, 1);
161ae6acf9fSMugunthan V N 	ret = musb_lowlevel_init(host);
162ae6acf9fSMugunthan V N 
163ae6acf9fSMugunthan V N 	return ret;
164ae6acf9fSMugunthan V N }
165ae6acf9fSMugunthan V N 
ti_musb_host_remove(struct udevice * dev)166ae6acf9fSMugunthan V N static int ti_musb_host_remove(struct udevice *dev)
167ae6acf9fSMugunthan V N {
168ae6acf9fSMugunthan V N 	struct musb_host_data *host = dev_get_priv(dev);
169ae6acf9fSMugunthan V N 
170ae6acf9fSMugunthan V N 	musb_stop(host->host);
171*7d98dbccSJean-Jacques Hiblot 	ti_musb_set_phy_power(dev, 0);
172ae6acf9fSMugunthan V N 
173ae6acf9fSMugunthan V N 	return 0;
174ae6acf9fSMugunthan V N }
175ae6acf9fSMugunthan V N 
176*7d98dbccSJean-Jacques Hiblot #if CONFIG_IS_ENABLED(OF_CONTROL)
ti_musb_host_ofdata_to_platdata(struct udevice * dev)177ae6acf9fSMugunthan V N static int ti_musb_host_ofdata_to_platdata(struct udevice *dev)
178ae6acf9fSMugunthan V N {
179ae6acf9fSMugunthan V N 	struct ti_musb_platdata *platdata = dev_get_platdata(dev);
180ae6acf9fSMugunthan V N 	const void *fdt = gd->fdt_blob;
181e160f7d4SSimon Glass 	int node = dev_of_offset(dev);
182ae6acf9fSMugunthan V N 	int ret;
183ae6acf9fSMugunthan V N 
184ae6acf9fSMugunthan V N 	ret = ti_musb_ofdata_to_platdata(dev);
185ae6acf9fSMugunthan V N 	if (ret) {
1869b643e31SMasahiro Yamada 		pr_err("platdata dt parse error\n");
187ae6acf9fSMugunthan V N 		return ret;
188ae6acf9fSMugunthan V N 	}
189ae6acf9fSMugunthan V N 
190ae6acf9fSMugunthan V N 	platdata->plat.mode = MUSB_HOST;
191ae6acf9fSMugunthan V N 
192ae6acf9fSMugunthan V N 	return 0;
193ae6acf9fSMugunthan V N }
194*7d98dbccSJean-Jacques Hiblot #endif
195ae6acf9fSMugunthan V N 
196ae6acf9fSMugunthan V N U_BOOT_DRIVER(ti_musb_host) = {
197ae6acf9fSMugunthan V N 	.name	= "ti-musb-host",
198ae6acf9fSMugunthan V N 	.id	= UCLASS_USB,
199*7d98dbccSJean-Jacques Hiblot #if CONFIG_IS_ENABLED(OF_CONTROL)
200ae6acf9fSMugunthan V N 	.ofdata_to_platdata = ti_musb_host_ofdata_to_platdata,
201*7d98dbccSJean-Jacques Hiblot #endif
202ae6acf9fSMugunthan V N 	.probe = ti_musb_host_probe,
203ae6acf9fSMugunthan V N 	.remove = ti_musb_host_remove,
204ae6acf9fSMugunthan V N 	.ops	= &musb_usb_ops,
205ae6acf9fSMugunthan V N 	.platdata_auto_alloc_size = sizeof(struct ti_musb_platdata),
206ae6acf9fSMugunthan V N 	.priv_auto_alloc_size = sizeof(struct musb_host_data),
207ae6acf9fSMugunthan V N };
208ae6acf9fSMugunthan V N 
209*7d98dbccSJean-Jacques Hiblot #if CONFIG_IS_ENABLED(DM_USB_GADGET)
210*7d98dbccSJean-Jacques Hiblot struct ti_musb_peripheral {
211*7d98dbccSJean-Jacques Hiblot 	struct musb *periph;
212*7d98dbccSJean-Jacques Hiblot };
213*7d98dbccSJean-Jacques Hiblot 
214*7d98dbccSJean-Jacques Hiblot #if CONFIG_IS_ENABLED(OF_CONTROL)
ti_musb_peripheral_ofdata_to_platdata(struct udevice * dev)215*7d98dbccSJean-Jacques Hiblot static int ti_musb_peripheral_ofdata_to_platdata(struct udevice *dev)
216*7d98dbccSJean-Jacques Hiblot {
217*7d98dbccSJean-Jacques Hiblot 	struct ti_musb_platdata *platdata = dev_get_platdata(dev);
218*7d98dbccSJean-Jacques Hiblot 	const void *fdt = gd->fdt_blob;
219*7d98dbccSJean-Jacques Hiblot 	int node = dev_of_offset(dev);
220*7d98dbccSJean-Jacques Hiblot 	int ret;
221*7d98dbccSJean-Jacques Hiblot 
222*7d98dbccSJean-Jacques Hiblot 	ret = ti_musb_ofdata_to_platdata(dev);
223*7d98dbccSJean-Jacques Hiblot 	if (ret) {
224*7d98dbccSJean-Jacques Hiblot 		pr_err("platdata dt parse error\n");
225*7d98dbccSJean-Jacques Hiblot 		return ret;
226*7d98dbccSJean-Jacques Hiblot 	}
227*7d98dbccSJean-Jacques Hiblot 	platdata->plat.mode = MUSB_PERIPHERAL;
228*7d98dbccSJean-Jacques Hiblot 
229*7d98dbccSJean-Jacques Hiblot 	return 0;
230*7d98dbccSJean-Jacques Hiblot }
231*7d98dbccSJean-Jacques Hiblot #endif
232*7d98dbccSJean-Jacques Hiblot 
dm_usb_gadget_handle_interrupts(struct udevice * dev)233*7d98dbccSJean-Jacques Hiblot int dm_usb_gadget_handle_interrupts(struct udevice *dev)
234*7d98dbccSJean-Jacques Hiblot {
235*7d98dbccSJean-Jacques Hiblot 	struct ti_musb_peripheral *priv = dev_get_priv(dev);
236*7d98dbccSJean-Jacques Hiblot 
237*7d98dbccSJean-Jacques Hiblot 	priv->periph->isr(0, priv->periph);
238*7d98dbccSJean-Jacques Hiblot 
239*7d98dbccSJean-Jacques Hiblot 	return 0;
240*7d98dbccSJean-Jacques Hiblot }
241*7d98dbccSJean-Jacques Hiblot 
ti_musb_peripheral_probe(struct udevice * dev)242*7d98dbccSJean-Jacques Hiblot static int ti_musb_peripheral_probe(struct udevice *dev)
243*7d98dbccSJean-Jacques Hiblot {
244*7d98dbccSJean-Jacques Hiblot 	struct ti_musb_peripheral *priv = dev_get_priv(dev);
245*7d98dbccSJean-Jacques Hiblot 	struct ti_musb_platdata *platdata = dev_get_platdata(dev);
246*7d98dbccSJean-Jacques Hiblot 	int ret;
247*7d98dbccSJean-Jacques Hiblot 
248*7d98dbccSJean-Jacques Hiblot 	priv->periph = musb_init_controller(&platdata->plat,
249*7d98dbccSJean-Jacques Hiblot 					    NULL,
250*7d98dbccSJean-Jacques Hiblot 					    platdata->base);
251*7d98dbccSJean-Jacques Hiblot 	if (!priv->periph)
252*7d98dbccSJean-Jacques Hiblot 		return -EIO;
253*7d98dbccSJean-Jacques Hiblot 
254*7d98dbccSJean-Jacques Hiblot 	ti_musb_set_phy_power(dev, 1);
255*7d98dbccSJean-Jacques Hiblot 	musb_gadget_setup(priv->periph);
256*7d98dbccSJean-Jacques Hiblot 	return usb_add_gadget_udc((struct device *)dev, &priv->periph->g);
257*7d98dbccSJean-Jacques Hiblot }
258*7d98dbccSJean-Jacques Hiblot 
ti_musb_peripheral_remove(struct udevice * dev)259*7d98dbccSJean-Jacques Hiblot static int ti_musb_peripheral_remove(struct udevice *dev)
260*7d98dbccSJean-Jacques Hiblot {
261*7d98dbccSJean-Jacques Hiblot 	struct ti_musb_peripheral *priv = dev_get_priv(dev);
262*7d98dbccSJean-Jacques Hiblot 
263*7d98dbccSJean-Jacques Hiblot 	usb_del_gadget_udc(&priv->periph->g);
264*7d98dbccSJean-Jacques Hiblot 	ti_musb_set_phy_power(dev, 0);
265*7d98dbccSJean-Jacques Hiblot 
266*7d98dbccSJean-Jacques Hiblot 	return 0;
267*7d98dbccSJean-Jacques Hiblot }
268*7d98dbccSJean-Jacques Hiblot 
269*7d98dbccSJean-Jacques Hiblot U_BOOT_DRIVER(ti_musb_peripheral) = {
270*7d98dbccSJean-Jacques Hiblot 	.name	= "ti-musb-peripheral",
271*7d98dbccSJean-Jacques Hiblot 	.id	= UCLASS_USB_GADGET_GENERIC,
272*7d98dbccSJean-Jacques Hiblot #if CONFIG_IS_ENABLED(OF_CONTROL)
273*7d98dbccSJean-Jacques Hiblot 	.ofdata_to_platdata = ti_musb_peripheral_ofdata_to_platdata,
274*7d98dbccSJean-Jacques Hiblot #endif
275*7d98dbccSJean-Jacques Hiblot 	.probe = ti_musb_peripheral_probe,
276*7d98dbccSJean-Jacques Hiblot 	.remove = ti_musb_peripheral_remove,
277*7d98dbccSJean-Jacques Hiblot 	.ops	= &musb_usb_ops,
278*7d98dbccSJean-Jacques Hiblot 	.platdata_auto_alloc_size = sizeof(struct ti_musb_platdata),
279*7d98dbccSJean-Jacques Hiblot 	.priv_auto_alloc_size = sizeof(struct ti_musb_peripheral),
280*7d98dbccSJean-Jacques Hiblot 	.flags = DM_FLAG_PRE_RELOC,
281*7d98dbccSJean-Jacques Hiblot };
282*7d98dbccSJean-Jacques Hiblot #endif
283*7d98dbccSJean-Jacques Hiblot 
284*7d98dbccSJean-Jacques Hiblot #if CONFIG_IS_ENABLED(OF_CONTROL)
ti_musb_wrapper_bind(struct udevice * parent)28528b8d5fdSMugunthan V N static int ti_musb_wrapper_bind(struct udevice *parent)
28628b8d5fdSMugunthan V N {
28728b8d5fdSMugunthan V N 	const void *fdt = gd->fdt_blob;
28828b8d5fdSMugunthan V N 	int node;
28928b8d5fdSMugunthan V N 	int ret;
29028b8d5fdSMugunthan V N 
291e160f7d4SSimon Glass 	for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
29228b8d5fdSMugunthan V N 	     node = fdt_next_subnode(fdt, node)) {
29328b8d5fdSMugunthan V N 		struct udevice *dev;
29428b8d5fdSMugunthan V N 		const char *name = fdt_get_name(fdt, node, NULL);
29528b8d5fdSMugunthan V N 		enum usb_dr_mode dr_mode;
29628b8d5fdSMugunthan V N 		struct driver *drv;
29728b8d5fdSMugunthan V N 
29828b8d5fdSMugunthan V N 		if (strncmp(name, "usb@", 4))
29928b8d5fdSMugunthan V N 			continue;
30028b8d5fdSMugunthan V N 
30128b8d5fdSMugunthan V N 		dr_mode = usb_get_dr_mode(node);
30228b8d5fdSMugunthan V N 		switch (dr_mode) {
30328b8d5fdSMugunthan V N 		case USB_DR_MODE_PERIPHERAL:
30428b8d5fdSMugunthan V N 			/* Bind MUSB device */
305*7d98dbccSJean-Jacques Hiblot 			ret = device_bind_driver_to_node(parent,
306*7d98dbccSJean-Jacques Hiblot 							 "ti-musb-peripheral",
307*7d98dbccSJean-Jacques Hiblot 							 name,
308*7d98dbccSJean-Jacques Hiblot 							 offset_to_ofnode(node),
309*7d98dbccSJean-Jacques Hiblot 							 &dev);
310*7d98dbccSJean-Jacques Hiblot 			if (ret)
311*7d98dbccSJean-Jacques Hiblot 				pr_err("musb - not able to bind usb peripheral node\n");
31228b8d5fdSMugunthan V N 			break;
31328b8d5fdSMugunthan V N 		case USB_DR_MODE_HOST:
31428b8d5fdSMugunthan V N 			/* Bind MUSB host */
315*7d98dbccSJean-Jacques Hiblot 			ret = device_bind_driver_to_node(parent,
316*7d98dbccSJean-Jacques Hiblot 							 "ti-musb-host",
317*7d98dbccSJean-Jacques Hiblot 							 name,
318*7d98dbccSJean-Jacques Hiblot 							 offset_to_ofnode(node),
319*7d98dbccSJean-Jacques Hiblot 							 &dev);
320*7d98dbccSJean-Jacques Hiblot 			if (ret)
3219b643e31SMasahiro Yamada 				pr_err("musb - not able to bind usb host node\n");
32228b8d5fdSMugunthan V N 			break;
32328b8d5fdSMugunthan V N 		default:
32428b8d5fdSMugunthan V N 			break;
32528b8d5fdSMugunthan V N 		};
32628b8d5fdSMugunthan V N 	}
32728b8d5fdSMugunthan V N 	return 0;
32828b8d5fdSMugunthan V N }
32928b8d5fdSMugunthan V N 
33028b8d5fdSMugunthan V N static const struct udevice_id ti_musb_ids[] = {
33128b8d5fdSMugunthan V N 	{ .compatible = "ti,am33xx-usb" },
33228b8d5fdSMugunthan V N 	{ }
33328b8d5fdSMugunthan V N };
33428b8d5fdSMugunthan V N 
33528b8d5fdSMugunthan V N U_BOOT_DRIVER(ti_musb_wrapper) = {
33628b8d5fdSMugunthan V N 	.name	= "ti-musb-wrapper",
33728b8d5fdSMugunthan V N 	.id	= UCLASS_MISC,
33828b8d5fdSMugunthan V N 	.of_match = ti_musb_ids,
33928b8d5fdSMugunthan V N 	.bind = ti_musb_wrapper_bind,
34028b8d5fdSMugunthan V N };
341*7d98dbccSJean-Jacques Hiblot #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
34228b8d5fdSMugunthan V N 
343fd09c205SSven Schwermer #endif /* CONFIG_IS_ENABLED(DM_USB) */
344