usb: phy: rockchip: get the otg node correctly
In the commit 525293385cca ("rockchip: board: rework board
usb init"), it correct the way to find the otg node. This
patch do the same thing here.
Change-Id: I27c66f48d9f6c99f1d6e45c2b83d2bcd6365a1f3
Signed-off-by: William Wu <william.wu@rock-chips.com>
This commit is contained in:
parent
294ad6176b
commit
da1b89c5ac
|
|
@ -7,6 +7,7 @@
|
|||
#include <common.h>
|
||||
#include <asm/arch/clock.h>
|
||||
#include <asm/io.h>
|
||||
#include <dm.h>
|
||||
#include <fdtdec.h>
|
||||
#include <syscon.h>
|
||||
|
||||
|
|
@ -84,34 +85,44 @@ static int otg_phy_parse(struct dwc2_udc *dev)
|
|||
{
|
||||
int node, phy_node;
|
||||
u32 grf_base, grf_offset;
|
||||
const char *mode;
|
||||
bool matched = false;
|
||||
const void *blob = gd->fdt_blob;
|
||||
const fdt32_t *reg;
|
||||
fdt_addr_t addr;
|
||||
struct dwc2_plat_otg_data *pdata = dev->pdata;
|
||||
|
||||
/* Find the usb_otg node */
|
||||
node = fdt_node_offset_by_compatible(blob, -1, "snps,dwc2");
|
||||
while (node > 0) {
|
||||
mode = fdt_getprop(blob, node, "dr_mode", NULL);
|
||||
if (mode && strcmp(mode, "otg") == 0) {
|
||||
matched = true;
|
||||
break;
|
||||
|
||||
retry:
|
||||
if (node > 0) {
|
||||
reg = fdt_getprop(blob, node, "reg", NULL);
|
||||
if (!reg)
|
||||
return -EINVAL;
|
||||
|
||||
addr = fdt_translate_address(blob, node, reg);
|
||||
if (addr == OF_BAD_ADDR) {
|
||||
pr_err("Not found usb_otg address\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
node = fdt_node_offset_by_compatible(blob, node, "snps,dwc2");
|
||||
}
|
||||
|
||||
if (!matched) {
|
||||
#if defined(CONFIG_ROCKCHIP_RK3288)
|
||||
if (addr != 0xff580000) {
|
||||
node = fdt_node_offset_by_compatible(blob, node,
|
||||
"snps,dwc2");
|
||||
goto retry;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
/*
|
||||
* With kernel dtb support, rk3288 dwc2 otg node
|
||||
* use the rockchip legacy dwc2 driver "dwc_otg_310"
|
||||
* with the compatible "rockchip,rk3288_usb20_otg".
|
||||
*/
|
||||
#if defined(CONFIG_ROCKCHIP_RK3288)
|
||||
node = fdt_node_offset_by_compatible(blob, -1,
|
||||
"rockchip,rk3288_usb20_otg");
|
||||
if (node > 0) {
|
||||
matched = true;
|
||||
} else {
|
||||
#endif
|
||||
if (node < 0) {
|
||||
pr_err("Not found usb_otg device\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue