diff options
author | Jean-Jacques Hiblot <jjhiblot@ti.com> | 2018-11-29 10:52:49 +0100 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2018-12-07 16:31:45 +0100 |
commit | 93991cf1969077108ae36e90acb3cd25a6a449ac (patch) | |
tree | 95ad984525be29779bd31d0a9206ce5937e324fb | |
parent | 446e3a205b871943736e22565092771fac98a9a4 (diff) | |
download | u-boot-93991cf1969077108ae36e90acb3cd25a6a449ac.zip u-boot-93991cf1969077108ae36e90acb3cd25a6a449ac.tar.gz u-boot-93991cf1969077108ae36e90acb3cd25a6a449ac.tar.bz2 |
dwc3-generic: Add select_dr_mode operation
The select_dr_mode operation is executed when the glue driver is probed.
The role of this optional function is to configure the operating mode
of the controller at the glue level.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
-rw-r--r-- | drivers/usb/dwc3/dwc3-generic.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 7be0187..6d9be9b 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -8,6 +8,7 @@ */ #include <common.h> +#include <asm-generic/io.h> #include <dm.h> #include <dm/device-internal.h> #include <dm/lists.h> @@ -110,6 +111,12 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = { struct dwc3_glue_data { struct clk_bulk clks; struct reset_ctl_bulk resets; + fdt_addr_t regs; +}; + +struct dwc3_glue_ops { + void (*select_dr_mode)(struct udevice *dev, int index, + enum usb_dr_mode mode); }; static int dwc3_glue_bind(struct udevice *parent) @@ -205,9 +212,14 @@ static int dwc3_glue_clk_init(struct udevice *dev, static int dwc3_glue_probe(struct udevice *dev) { + struct dwc3_glue_ops *ops = (struct dwc3_glue_ops *)dev_get_driver_data(dev); struct dwc3_glue_data *glue = dev_get_platdata(dev); + struct udevice *child = NULL; + int index = 0; int ret; + glue->regs = dev_read_addr(dev); + ret = dwc3_glue_clk_init(dev, glue); if (ret) return ret; @@ -216,6 +228,20 @@ static int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; + ret = device_find_first_child(dev, &child); + if (ret) + return ret; + + while (child) { + enum usb_dr_mode dr_mode; + + dr_mode = usb_get_dr_mode(dev_of_offset(child)); + device_find_next_child(&child); + if (ops && ops->select_dr_mode) + ops->select_dr_mode(dev, index, dr_mode); + index++; + } + return 0; } |