1*28b8d5fdSMugunthan V N /* 2*28b8d5fdSMugunthan V N * MISC driver for TI MUSB Glue. 3*28b8d5fdSMugunthan V N * 4*28b8d5fdSMugunthan V N * (C) Copyright 2016 5*28b8d5fdSMugunthan V N * Texas Instruments Incorporated, <www.ti.com> 6*28b8d5fdSMugunthan V N * 7*28b8d5fdSMugunthan V N * SPDX-License-Identifier: GPL-2.0+ 8*28b8d5fdSMugunthan V N */ 9*28b8d5fdSMugunthan V N #include <common.h> 10*28b8d5fdSMugunthan V N #include <command.h> 11*28b8d5fdSMugunthan V N #include <console.h> 12*28b8d5fdSMugunthan V N #include <dm.h> 13*28b8d5fdSMugunthan V N #include <linux/usb/otg.h> 14*28b8d5fdSMugunthan V N #include <dm/device-internal.h> 15*28b8d5fdSMugunthan V N #include <dm/lists.h> 16*28b8d5fdSMugunthan V N 17*28b8d5fdSMugunthan V N DECLARE_GLOBAL_DATA_PTR; 18*28b8d5fdSMugunthan V N 19*28b8d5fdSMugunthan V N #ifdef CONFIG_DM_USB 20*28b8d5fdSMugunthan V N 21*28b8d5fdSMugunthan V N static int ti_musb_wrapper_bind(struct udevice *parent) 22*28b8d5fdSMugunthan V N { 23*28b8d5fdSMugunthan V N const void *fdt = gd->fdt_blob; 24*28b8d5fdSMugunthan V N int node; 25*28b8d5fdSMugunthan V N int ret; 26*28b8d5fdSMugunthan V N 27*28b8d5fdSMugunthan V N for (node = fdt_first_subnode(fdt, parent->of_offset); node > 0; 28*28b8d5fdSMugunthan V N node = fdt_next_subnode(fdt, node)) { 29*28b8d5fdSMugunthan V N struct udevice *dev; 30*28b8d5fdSMugunthan V N const char *name = fdt_get_name(fdt, node, NULL); 31*28b8d5fdSMugunthan V N enum usb_dr_mode dr_mode; 32*28b8d5fdSMugunthan V N struct driver *drv; 33*28b8d5fdSMugunthan V N 34*28b8d5fdSMugunthan V N if (strncmp(name, "usb@", 4)) 35*28b8d5fdSMugunthan V N continue; 36*28b8d5fdSMugunthan V N 37*28b8d5fdSMugunthan V N dr_mode = usb_get_dr_mode(node); 38*28b8d5fdSMugunthan V N switch (dr_mode) { 39*28b8d5fdSMugunthan V N case USB_DR_MODE_PERIPHERAL: 40*28b8d5fdSMugunthan V N /* Bind MUSB device */ 41*28b8d5fdSMugunthan V N break; 42*28b8d5fdSMugunthan V N case USB_DR_MODE_HOST: 43*28b8d5fdSMugunthan V N /* Bind MUSB host */ 44*28b8d5fdSMugunthan V N break; 45*28b8d5fdSMugunthan V N default: 46*28b8d5fdSMugunthan V N break; 47*28b8d5fdSMugunthan V N }; 48*28b8d5fdSMugunthan V N } 49*28b8d5fdSMugunthan V N return 0; 50*28b8d5fdSMugunthan V N } 51*28b8d5fdSMugunthan V N 52*28b8d5fdSMugunthan V N static const struct udevice_id ti_musb_ids[] = { 53*28b8d5fdSMugunthan V N { .compatible = "ti,am33xx-usb" }, 54*28b8d5fdSMugunthan V N { } 55*28b8d5fdSMugunthan V N }; 56*28b8d5fdSMugunthan V N 57*28b8d5fdSMugunthan V N U_BOOT_DRIVER(ti_musb_wrapper) = { 58*28b8d5fdSMugunthan V N .name = "ti-musb-wrapper", 59*28b8d5fdSMugunthan V N .id = UCLASS_MISC, 60*28b8d5fdSMugunthan V N .of_match = ti_musb_ids, 61*28b8d5fdSMugunthan V N .bind = ti_musb_wrapper_bind, 62*28b8d5fdSMugunthan V N }; 63*28b8d5fdSMugunthan V N 64*28b8d5fdSMugunthan V N #endif /* CONFIG_DM_USB */ 65