public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Michael Trimarchi <michael@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] rockchip: rk3288: Fix dwc2 gadget registration
Date: Wed, 13 Nov 2019 17:07:48 +0100	[thread overview]
Message-ID: <20191113160748.19244-1-michael@amarulasolutions.com> (raw)

rk3288 needs phy registration in order to work or the board
just hang

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 arch/arm/mach-rockchip/board.c         | 12 ++++++++
 arch/arm/mach-rockchip/rk3288/rk3288.c | 39 ++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
index 8ca3463731..37ae37ff34 100644
--- a/arch/arm/mach-rockchip/board.c
+++ b/arch/arm/mach-rockchip/board.c
@@ -59,6 +59,12 @@ static struct dwc2_plat_otg_data otg_data = {
 	.tx_fifo_sz	= 128,
 };
 
+
+__weak int board_usb_phy_init(int node, struct dwc2_plat_otg_data *otg_data)
+{
+	return 0;
+}
+
 int board_usb_init(int index, enum usb_init_type init)
 {
 	int node;
@@ -84,6 +90,12 @@ int board_usb_init(int index, enum usb_init_type init)
 	}
 	otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
 
+	node = board_usb_phy_init(node, &otg_data);
+	if (node < 0) {
+		debug("Not found usb_otg phy\n");
+		return -ENODEV;
+	}
+
 	return dwc2_udc_probe(&otg_data);
 }
 
diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c b/arch/arm/mach-rockchip/rk3288/rk3288.c
index 002d1508e5..6d93214e7c 100644
--- a/arch/arm/mach-rockchip/rk3288/rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
@@ -184,6 +184,45 @@ static void rk3288_detect_reset_reason(void)
 	rk_clrreg(&cru->cru_glb_rst_st, GLB_RST_ST_MASK);
 }
 
+#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
+#include <usb.h>
+#include <usb/dwc2_udc.h>
+
+int board_usb_phy_init(int node, struct dwc2_plat_otg_data *otg_data)
+{
+	int phy_node;
+	const void *blob = gd->fdt_blob;
+	u32 grf_phy_offset;
+
+	node = fdtdec_lookup_phandle(blob, node, "phys");
+	if (node <= 0) {
+		debug("Not found usb phy device\n");
+		return -ENODEV;
+	}
+
+	phy_node = fdt_parent_offset(blob, node);
+	if (phy_node <= 0) {
+		debug("Not found usb phy device\n");
+		return -ENODEV;
+	}
+
+	otg_data->phy_of_node = phy_node;
+	grf_phy_offset = fdtdec_get_addr(blob, node, "reg");
+
+	/* find the grf node */
+	node = fdt_node_offset_by_compatible(blob, -1, "rockchip,rk3288-grf");
+	if (node <= 0) {
+		debug("Not found grf device\n");
+		return -ENODEV;
+	}
+	otg_data->regs_phy = grf_phy_offset +
+				fdtdec_get_addr(blob, node, "reg");
+
+	return 0;
+}
+
+#endif
+
 __weak int rk3288_board_late_init(void)
 {
 	return 0;
-- 
2.17.1

             reply	other threads:[~2019-11-13 16:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 16:07 Michael Trimarchi [this message]
2019-11-14  7:15 ` [U-Boot] [PATCH] rockchip: rk3288: Fix dwc2 gadget registration Kever Yang
2019-11-14  7:29   ` Michael Nazzareno Trimarchi
2019-11-14  7:49     ` Michael Nazzareno Trimarchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191113160748.19244-1-michael@amarulasolutions.com \
    --to=michael@amarulasolutions.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox