From patchwork Thu Feb 20 02:32:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kever Yang X-Patchwork-Id: 1241129 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=M1fpV06R; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48NJZZ4Plgz9sRG for ; Thu, 20 Feb 2020 13:34:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EC49681541; Thu, 20 Feb 2020 03:33:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="M1fpV06R"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 126B381462; Thu, 20 Feb 2020 03:33:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DECF3813CE for ; Thu, 20 Feb 2020 03:32:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kever.yang@gmail.com Received: by mail-pj1-x1041.google.com with SMTP id d5so223232pjz.5 for ; Wed, 19 Feb 2020 18:32:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=bZK84/g7Jk3peGMsBJ+NOakTwHVjDPokZXp0kWflz5s=; b=M1fpV06Rq6QGTquizK4tzMEzf8p1894MG/cGwcsapnmgdxp0CSJ5fOTUi183w5Xy3B EdcuRDTaVQBFVOsmgZJJnVpS1e2/7xWIoI/9uY1ByfO9M8FQOKieNAdUja6VEEENFXUi Mu9Phr1aOXM/NNj38J1wrjika15cOAzw67XiyJ4PI+N/lKXiUwrzXOG9f833TIm5mHlF kWGcgxiQWXKNBITDM4wjy2w+H13gF9h935Vsvv2WsBqC7jI8+2MeLcFvlorZgshAq4kZ 6xXCQPg4Cr1se0fZHUHTJpdGY2wjAa9VNG+ndLctGZ/hwHCLwTMqUBwN/7ZgyQec35sw d1OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=bZK84/g7Jk3peGMsBJ+NOakTwHVjDPokZXp0kWflz5s=; b=gXNHiLl81B5GetxluH8HI314e6BDtS5A4l4gzqBnmL+IQB5fkruePpogizV/oivZYi 6Q0FicXYWrgyA0ItwoRpMndFB6oOm6Qf9Rjlq9DGkbs2/2CAebylB2UhV1Yqe1V68vrO aebRh6bb+Eo3c2GjB16VZTqcXG3dqRk4pd6JPRyaEu7sPOs1/whVsivvQ/jmtFoENqW+ NlZbHAKgzFxKSVdUD9LChGf7WrWwwvaXc8Zdv7TXKSwzNfoLQzS1rQz472WSuLP/Xzr6 Zf4IbY/MO0cwSV+6PGjnyzuZbmIy9HrZRRBzYlof0lJc+MqHBbV39h6vOHJ8YQw5MN8U NHRw== X-Gm-Message-State: APjAAAW5O5ZeLHeB989aBdWONtbrqPXVw0IAu1hPD+LXHDCcq3l5yh/z mzxCplRRdGujcapDTZBRztSUvFaw X-Google-Smtp-Source: APXvYqzFv09fhKFfEtuwfRaR9ykZTw8eS0mHRcYerJ3PdNHYjV8Sf0NwGY+L/NCVyBVTJ+AmJ7h88A== X-Received: by 2002:a17:902:7e4b:: with SMTP id a11mr28751109pln.61.1582165973300; Wed, 19 Feb 2020 18:32:53 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id w25sm952107pfi.106.2020.02.19.18.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 18:32:52 -0800 (PST) From: Kever Yang To: u-boot@lists.denx.de Cc: frank.wang@rock-chips.com, Kever Yang , Marek Vasut , Neil Armstrong Subject: [PATCH v2 6/9] usb: host: dwc3-sti-glue: Migrate to use ofnode API Date: Thu, 20 Feb 2020 10:32:21 +0800 Message-Id: <20200220023224.32146-7-kever.yang@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200220023224.32146-1-kever.yang@rock-chips.com> References: <20200220023224.32146-1-kever.yang@rock-chips.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Use ofnode_ instead of fdt_ or fdtdec_ APIs so that the driver can support live DT. Signed-off-by: Kever Yang --- Changes in v2: - fix build error for ofnode not define drivers/usb/host/dwc3-sti-glue.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c index ad7cf6e6b5..ae9573ab8a 100644 --- a/drivers/usb/host/dwc3-sti-glue.c +++ b/drivers/usb/host/dwc3-sti-glue.c @@ -10,8 +10,6 @@ #include #include #include -#include -#include #include #include #include @@ -109,8 +107,7 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev) int ret; u32 reg[4]; - ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), - "reg", reg, ARRAY_SIZE(reg)); + ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg)); if (ret) { pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", ret); return ret; @@ -153,24 +150,21 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev) static int sti_dwc3_glue_bind(struct udevice *dev) { struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev); - int dwc3_node; + ofnode node, dwc3_node; - /* check if one subnode is present */ - dwc3_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev)); - if (dwc3_node <= 0) { - pr_err("Can't find subnode for %s\n", dev->name); - return -ENODEV; + /* Find snps,dwc3 node from subnode */ + ofnode_for_each_subnode(node, dev->node) { + if (ofnode_device_is_compatible(node, "snps,dwc3")) + dwc3_node = node; } - /* check if the subnode compatible string is the dwc3 one*/ - if (fdt_node_check_compatible(gd->fdt_blob, dwc3_node, - "snps,dwc3") != 0) { + if (!ofnode_valid(node)) { pr_err("Can't find dwc3 subnode for %s\n", dev->name); return -ENODEV; } /* retrieve the DWC3 dual role mode */ - plat->mode = usb_get_dr_mode(dwc3_node); + plat->mode = usb_get_dr_mode(ofnode_to_offset(dwc3_node)); if (plat->mode == USB_DR_MODE_UNKNOWN) /* by default set dual role mode to HOST */ plat->mode = USB_DR_MODE_HOST;