Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4487EC433F5 for ; Wed, 2 Feb 2022 23:09:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 091598390C; Thu, 3 Feb 2022 00:09:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=akkea.ca Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=akkea.ca header.i=@akkea.ca header.b="R5kqZNXr"; dkim=pass (1024-bit key) header.d=akkea.ca header.i=@akkea.ca header.b="R5kqZNXr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 05EA1838FE; Thu, 3 Feb 2022 00:09:24 +0100 (CET) Received: from node.akkea.ca (li1434-30.members.linode.com [45.33.107.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2F53783902 for ; Thu, 3 Feb 2022 00:09:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=akkea.ca Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=angus@akkea.ca Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id E3BD54E200E; Wed, 2 Feb 2022 23:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1643843355; bh=Wa1TJySalbHjTaBCXxhcQKW/K2X7EStzwsfElkG0QZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=R5kqZNXr4lwZNyjGqg2LUa/47YlYqistt2mbyG4MLsXNjjLM7sGSD46Az7xL+5NP5 w8OxF4e9PPOD40cRegkridiwXCevCGIrJZi3GgSDOJQNwsuX75f7/5yIB+uazby1WP V3TaR4hROckU5Ud6+gPs++BRXkElHbVDfRYahv4k= Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z94Ic2stOdbp; Wed, 2 Feb 2022 23:09:15 +0000 (UTC) Received: from midas.localdomain (S0106788a2041785e.gv.shawcable.net [24.108.106.191]) by node.akkea.ca (Postfix) with ESMTPSA id 098CA4E2006; Wed, 2 Feb 2022 23:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1643843355; bh=Wa1TJySalbHjTaBCXxhcQKW/K2X7EStzwsfElkG0QZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=R5kqZNXr4lwZNyjGqg2LUa/47YlYqistt2mbyG4MLsXNjjLM7sGSD46Az7xL+5NP5 w8OxF4e9PPOD40cRegkridiwXCevCGIrJZi3GgSDOJQNwsuX75f7/5yIB+uazby1WP V3TaR4hROckU5Ud6+gPs++BRXkElHbVDfRYahv4k= From: Angus Ainslie To: uboot-imx@nxp.com Cc: Marek Vasut , Simon Glass , Angus Ainslie , Kunihiko Hayashi , u-boot@lists.denx.de, kernel@puri.sm Subject: [PATCH 1/2] usb: dwc3: dwc3-generic: check the parent nodes Date: Wed, 2 Feb 2022 15:08:54 -0800 Message-Id: <20220202230855.2080973-2-angus@akkea.ca> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220202230855.2080973-1-angus@akkea.ca> References: <20220202230855.2080973-1-angus@akkea.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The kernel devicetree has definitions for port and hub nodes as subnodes to the USB devices. These subnodes don't contain all of the data required to properly configure the dwc3. Check the parent nodes if the data is not in the port/hub node. Here's an example from the librem5 kernel dts file &usb_dwc3_0 { #address-cells = <1>; #size-cells = <0>; dr_mode = "otg"; snps,dis_u3_susphy_quirk; status = "okay"; port@0 { reg = <0>; typec_hs: endpoint { remote-endpoint = <&usb_con_hs>; }; }; port@1 { reg = <1>; typec_ss: endpoint { remote-endpoint = <&usb_con_ss>; }; }; }; &usb_dwc3_1 { dr_mode = "host"; status = "okay"; #address-cells = <1>; #size-cells = <0>; /* Microchip USB2642 */ hub@1 { compatible = "usb424,2640"; reg = <1>; #address-cells = <1>; #size-cells = <0>; mass-storage@1 { compatible = "usb424,4041"; reg = <1>; }; }; }; Signed-off-by: Angus Ainslie --- drivers/usb/dwc3/dwc3-generic.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 8d53ba7790..01bd0ca190 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -110,7 +110,12 @@ static int dwc3_generic_of_to_plat(struct udevice *dev) struct dwc3_generic_plat *plat = dev_get_plat(dev); ofnode node = dev_ofnode(dev); - plat->base = dev_read_addr(dev); + if (!strncmp(dev->name, "port", 4) || !strncmp(dev->name, "hub", 3)) { + /* This is a leaf so check the parent */ + plat->base = dev_read_addr(dev->parent); + } else { + plat->base = dev_read_addr(dev); + } plat->maximum_speed = usb_get_maximum_speed(node); if (plat->maximum_speed == USB_SPEED_UNKNOWN) { @@ -120,8 +125,13 @@ static int dwc3_generic_of_to_plat(struct udevice *dev) plat->dr_mode = usb_get_dr_mode(node); if (plat->dr_mode == USB_DR_MODE_UNKNOWN) { - pr_err("Invalid usb mode setup\n"); - return -ENODEV; + /* might be a leaf so check the parent for mode */ + node = dev_ofnode(dev->parent); + plat->dr_mode = usb_get_dr_mode(node); + if (plat->dr_mode == USB_DR_MODE_UNKNOWN) { + pr_err("Invalid usb mode setup\n"); + return -ENODEV; + } } return 0; @@ -301,16 +311,20 @@ static int dwc3_glue_bind(struct udevice *parent) { ofnode node; int ret; + enum usb_dr_mode dr_mode; + + dr_mode = usb_get_dr_mode(dev_ofnode(parent)); ofnode_for_each_subnode(node, dev_ofnode(parent)) { const char *name = ofnode_get_name(node); - enum usb_dr_mode dr_mode; struct udevice *dev; const char *driver = NULL; debug("%s: subnode name: %s\n", __func__, name); - dr_mode = usb_get_dr_mode(node); + /* if the parent node doesn't have a mode check the leaf */ + if (!dr_mode) + dr_mode = usb_get_dr_mode(node); switch (dr_mode) { case USB_DR_MODE_PERIPHERAL: @@ -450,6 +464,7 @@ static const struct udevice_id dwc3_glue_ids[] = { { .compatible = "rockchip,rk3328-dwc3" }, { .compatible = "rockchip,rk3399-dwc3" }, { .compatible = "qcom,dwc3" }, + { .compatible = "fsl,imx8mq-dwc3" }, { .compatible = "intel,tangier-dwc3" }, { } }; -- 2.25.1