From patchwork Thu Feb 20 02:32:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kever Yang X-Patchwork-Id: 1241130 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=85.214.62.61; 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=g1NK9k4K; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 48NJb00gGxz9sRG for ; Thu, 20 Feb 2020 13:34:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 31587813BE; Thu, 20 Feb 2020 03:33:51 +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="g1NK9k4K"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E13D281528; Thu, 20 Feb 2020 03:33:11 +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-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (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 91B89812C4 for ; Thu, 20 Feb 2020 03:33:00 +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-pl1-x644.google.com with SMTP id b22so914251pls.12 for ; Wed, 19 Feb 2020 18:33:00 -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=3/yYMI7fSW/fyeOL73uBPuMERIg8Zg8ILuMGFpLBr+Q=; b=g1NK9k4KYHDvu+aZ5LyAqPpZVUHzqmNvzTq11xh0WbF1kmcgoqT1Kb3HWmkSopi3jS WKaK4So/6pspYXWSr24HAKm9yNaClgJ2oXwZdbdjyCy1J8JcDNmn5yqrzwStOZV7JZeq zGXhn3d+9SBfBua7wuYs1L1kqNsddmBeG7DIJUc5DKS8l8IYGykdFp51JgDKYc/KWdyS PM5HFwhUUBUl00BD6nHIfVDJF1NmwQOvUEXSlfWfx4cjmPTQJS9+KxzRqi8KBVjxTlyp 8zsyHlRGqBOmBNwOeiQWPc2R8GXOT0FzWpFZLQwUX+sxCXjunYdPcqyxPrOdpFTHreNg rvrg== 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=3/yYMI7fSW/fyeOL73uBPuMERIg8Zg8ILuMGFpLBr+Q=; b=Z5Gs25SE5J9qMlPomeVXlhl1cYlbB76DF0twpM4RsGKwBseENYN/2h0gQUWdKZjtvT edDyWrm7c7IftvSbmsemHOtpfnyW+CpGWqLWh4hpUUH2Ak1giV2deNVLDBkvbYRM3DAK Ckyd2x3SRVVIX/4L62XejBiK3sd5Y/WdDbvzbH4s+zE7gRnNiGYsn0dq6mk/h1M6e2fs V1wk1VCzITqcKRHVaWaiZD6hq1tVhoSQe8xSei4cDVkrDCocYw1ESYEboSEoSyCVA+zo D2S04dbejaJ8fRBLtD+/NxUDEgFZlaI+GP3qMGJueXTrwpfWrOfI3Haw1O7EME+OsgJX tzIw== X-Gm-Message-State: APjAAAWju4MNG/1K6J2IXvk48p8zx/M+vRTG6KG3p836u2j4JanmLU8m Huvp6EsWEa3NL52oog9z6RTI+twS X-Google-Smtp-Source: APXvYqxwOjBPItx/MnXXzVEqRDqc3G82u6jsgix2bUA+QHIPfnDCQc/I2Pbqc0xfqXfrCS955u04WQ== X-Received: by 2002:a17:902:8343:: with SMTP id z3mr29815118pln.105.1582165978804; Wed, 19 Feb 2020 18:32:58 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id w25sm952107pfi.106.2020.02.19.18.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 18:32:58 -0800 (PST) From: Kever Yang To: u-boot@lists.denx.de Cc: frank.wang@rock-chips.com, Kever Yang , Adam Ford , Bin Meng , Igor Opaniuk , Jean-Jacques Hiblot , Lukasz Majewski , Marek Vasut , Neil Armstrong , Simon Glass , Vignesh Raghavendra , Ye Li , u-boot-amlogic@groups.io Subject: [PATCH v2 8/9] usb: Use ofnode as usb_get_dr_mode() parameter Date: Thu, 20 Feb 2020 10:32:23 +0800 Message-Id: <20200220023224.32146-9-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 ofnode is more common and no need to convert to offset after we migrate other API to use ofnode. Signed-off-by: Kever Yang Acked-by: Neil Armstrong --- Changes in v2: - add ofnode.h in otg.h to avoid build error drivers/usb/cdns3/core.c | 4 ++-- drivers/usb/common/common.c | 7 +++---- drivers/usb/dwc3/dwc3-generic.c | 6 +++--- drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +- drivers/usb/gadget/dwc2_udc_otg.c | 5 ++--- drivers/usb/host/dwc3-sti-glue.c | 2 +- drivers/usb/host/ehci-mx6.c | 2 +- drivers/usb/host/xhci-dwc3.c | 3 +-- drivers/usb/musb-new/ti-musb.c | 2 +- include/linux/usb/otg.h | 6 ++++-- 10 files changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 75c3d4f200..ce846488a8 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -108,7 +108,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns) enum usb_dr_mode dr_mode; int ret = 0; - dr_mode = usb_get_dr_mode(dev_of_offset(dev)); + dr_mode = usb_get_dr_mode(dev->node); cdns->role = USB_ROLE_NONE; /* @@ -398,7 +398,7 @@ int cdns3_bind(struct udevice *parent) } name = ofnode_get_name(node); - dr_mode = usb_get_dr_mode(ofnode_to_offset(node)); + dr_mode = usb_get_dr_mode(node); switch (dr_mode) { #if defined(CONFIG_SPL_USB_HOST_SUPPORT) || \ diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index a55def5aba..4300f711a9 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include @@ -20,13 +20,12 @@ static const char *const usb_dr_modes[] = { [USB_DR_MODE_OTG] = "otg", }; -enum usb_dr_mode usb_get_dr_mode(int node) +enum usb_dr_mode usb_get_dr_mode(ofnode node) { - const void *fdt = gd->fdt_blob; const char *dr_mode; int i; - dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL); + dr_mode = ofnode_read_string(node, "dr_mode"); if (!dr_mode) { pr_err("usb dr_mode not found\n"); return USB_DR_MODE_UNKNOWN; diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index ced0f53bfd..7178f12b47 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -98,7 +98,7 @@ static int dwc3_generic_ofdata_to_platdata(struct udevice *dev) plat->maximum_speed = USB_SPEED_SUPER; } - plat->dr_mode = usb_get_dr_mode(ofnode_to_offset(node)); + 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; @@ -295,7 +295,7 @@ static int dwc3_glue_bind(struct udevice *parent) debug("%s: subnode name: %s\n", __func__, name); - dr_mode = usb_get_dr_mode(ofnode_to_offset(node)); + dr_mode = usb_get_dr_mode(node); switch (dr_mode) { case USB_DR_MODE_PERIPHERAL: @@ -398,7 +398,7 @@ static int dwc3_glue_probe(struct udevice *dev) while (child) { enum usb_dr_mode dr_mode; - dr_mode = usb_get_dr_mode(dev_of_offset(child)); + dr_mode = usb_get_dr_mode(child->node); device_find_next_child(&child); if (ops && ops->select_dr_mode) ops->select_dr_mode(dev, index, dr_mode); diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c index 832bcd70ff..d4453f8784 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -393,7 +393,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev) } #endif - priv->otg_mode = usb_get_dr_mode(dev_of_offset(dev)); + priv->otg_mode = usb_get_dr_mode(dev->node); ret = dwc3_meson_g12a_usb_init(priv); if (ret) diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c index 496abf38e7..b9c814cf73 100644 --- a/drivers/usb/gadget/dwc2_udc_otg.c +++ b/drivers/usb/gadget/dwc2_udc_otg.c @@ -1039,13 +1039,12 @@ void dwc2_phy_shutdown(struct udevice *dev, struct phy *usb_phys, int num_phys) static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev) { struct dwc2_plat_otg_data *platdata = dev_get_platdata(dev); - int node = dev_of_offset(dev); ulong drvdata; void (*set_params)(struct dwc2_plat_otg_data *data); int ret; - if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL && - usb_get_dr_mode(node) != USB_DR_MODE_OTG) { + if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL && + usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) { dev_dbg(dev, "Invalid mode\n"); return -ENODEV; } diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c index ae9573ab8a..c99a1985cc 100644 --- a/drivers/usb/host/dwc3-sti-glue.c +++ b/drivers/usb/host/dwc3-sti-glue.c @@ -164,7 +164,7 @@ static int sti_dwc3_glue_bind(struct udevice *dev) } /* retrieve the DWC3 dual role mode */ - plat->mode = usb_get_dr_mode(ofnode_to_offset(dwc3_node)); + plat->mode = usb_get_dr_mode(dwc3_node); if (plat->mode == USB_DR_MODE_UNKNOWN) /* by default set dual role mode to HOST */ plat->mode = USB_DR_MODE_HOST; diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 1993ad620a..f2ceb51310 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -513,7 +513,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) struct usb_platdata *plat = dev_get_platdata(dev); enum usb_dr_mode dr_mode; - dr_mode = usb_get_dr_mode(dev_of_offset(dev)); + dr_mode = usb_get_dr_mode(dev->node); switch (dr_mode) { case USB_DR_MODE_HOST: diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c index c1c681ca6c..9fcfa39d4b 100644 --- a/drivers/usb/host/xhci-dwc3.c +++ b/drivers/usb/host/xhci-dwc3.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -155,7 +154,7 @@ static int xhci_dwc3_probe(struct udevice *dev) writel(reg, &dwc3_reg->g_usb2phycfg[0]); - dr_mode = usb_get_dr_mode(dev_of_offset(dev)); + dr_mode = usb_get_dr_mode(dev->node); if (dr_mode == USB_DR_MODE_UNKNOWN) /* by default set dual role mode to HOST */ dr_mode = USB_DR_MODE_HOST; diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c index 69252a7222..608facefa3 100644 --- a/drivers/usb/musb-new/ti-musb.c +++ b/drivers/usb/musb-new/ti-musb.c @@ -297,7 +297,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent) if (strncmp(name, "usb@", 4)) continue; - dr_mode = usb_get_dr_mode(ofnode_to_offset(node)); + dr_mode = usb_get_dr_mode(node); switch (dr_mode) { case USB_DR_MODE_PERIPHERAL: /* Bind MUSB device */ diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index d2604c5caf..4f1f8ceb54 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h @@ -9,6 +9,8 @@ #ifndef __LINUX_USB_OTG_H #define __LINUX_USB_OTG_H +#include + enum usb_dr_mode { USB_DR_MODE_UNKNOWN, USB_DR_MODE_HOST, @@ -18,12 +20,12 @@ enum usb_dr_mode { /** * usb_get_dr_mode() - Get dual role mode for given device - * @node: Node offset to the given device + * @node: ofnode of the given device * * The function gets phy interface string from property 'dr_mode', * and returns the correspondig enum usb_dr_mode */ -enum usb_dr_mode usb_get_dr_mode(int node); +enum usb_dr_mode usb_get_dr_mode(ofnode node); /** * usb_get_maximum_speed() - Get maximum speed for given device