From patchwork Mon Jul 16 12:49:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 944371 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="ZmVdqS6y"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41TjtF4zLRz9s29 for ; Mon, 16 Jul 2018 22:49:57 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3336DC22113; Mon, 16 Jul 2018 12:49:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 710B9C21E35; Mon, 16 Jul 2018 12:49:52 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4768EC21E35; Mon, 16 Jul 2018 12:49:51 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id D2F2DC21C4A for ; Mon, 16 Jul 2018 12:49:50 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id t6-v6so31768710wrn.7 for ; Mon, 16 Jul 2018 05:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=fID00iB3aZRSHU5eBH97GfY6D/6XdBQmYZcwNmm9zYM=; b=ZmVdqS6y84ejgttOcjS5ZThlX7jlZmtUP7bNgGls91lfVRaZIXcKzIMM9H4uH3vbto 9cPj810d7bgI9BMlw+UVVCL3n/MR52QCa9EXPN9CtPCnip0aKOCsRlBCqYQU3pr2x0nP LoLxY4eHB+RDM84MuLjp3nY/646kWNqMnDfhlIykmkcIq+dKwkiX42Q9niSgwkk3aN5g jBs3/UV8y1CPAPHWwEUqjEZdx+Da9t4eGXFfoYvPaHcWp6b8ntoQSYu/OMIDhlChg2F/ Ti0MMnQYz5mV/Z5poJc4ariBXNjpjg6VpTkrNGt1tdOf/v3hACblmYlhdM1pHck1TEkg f7zw== 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; bh=fID00iB3aZRSHU5eBH97GfY6D/6XdBQmYZcwNmm9zYM=; b=PuI/+fhfJE+43zPp0Ipv1U7H6J4BxzB3pj1ZNC2wBtiAsdzkThux69dq4z1Llj8QVX Cwlx0ngQjb2pGlAgKr8YboZXz/SL1deZ5324RCIDoHa68tpIso1RAmoQj0odYHW4hmvN Tu2WLdWFuWUrT+6yws6icRhyyFFG8eMUQj56qLifKgwWPO4N7yFLYGLpb4aqj3+6Shmi amJg0oDM6q6EpKvE8CvwMEf+auOeUUn1VyHWi2SbAPUSMulUUkqxZrFH24Yg+jl/rRd8 l5BiX3BP82AlRralSpwhaR4atYG96DaptJuG8Urm3PeV7O6boAMe+3h0ERzxrgreYDUV 6Q0w== X-Gm-Message-State: AOUpUlEL04233I7keXzod1ne4oYzOwthjtkvD4oFiqKlEfl/AeFwDUxv uYkGbmbjD0kz+HD5ff32TZO4tECw X-Google-Smtp-Source: AAOMgpcUlTIZpXafpmbkEL1lIocMVvfozcS2vFeZpNO/8+C6WWbsYv5U2S45X96txp/bysqjYHs46g== X-Received: by 2002:adf:c98d:: with SMTP id f13-v6mr11853416wrh.148.1531745390547; Mon, 16 Jul 2018 05:49:50 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id 127-v6sm17390221wmd.18.2018.07.16.05.49.49 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 16 Jul 2018 05:49:49 -0700 (PDT) From: Michal Simek To: Marek Vasut , u-boot@lists.denx.de Date: Mon, 16 Jul 2018 14:49:48 +0200 Message-Id: <01df4ad7088bfa97ec7f0b2da004651750b94b36.1531745384.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.9.1 Cc: Mugunthan V N , Vipul Kumar Subject: [U-Boot] [RESEND PATCH] usb: dwc3: convert to livetree X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Vipul Kumar Update the DWC3 USB driver to support a live tree. Signed-off-by: Vipul Kumar Tested-by: Michal Simek Signed-off-by: Michal Simek --- drivers/usb/common/common.c | 11 +++++------ drivers/usb/dwc3/dwc3-generic.c | 17 +++++++---------- drivers/usb/host/xhci-dwc3.c | 3 ++- drivers/usb/host/xhci-zynqmp.c | 3 +-- include/linux/usb/otg.h | 6 ++++-- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index a55def5aba67..3dea79bc555b 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -10,6 +10,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -20,13 +21,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_get_property(node, "dr_mode", NULL); if (!dr_mode) { pr_err("usb dr_mode not found\n"); return USB_DR_MODE_UNKNOWN; @@ -48,13 +48,12 @@ static const char *const speed_names[] = { [USB_SPEED_SUPER] = "super-speed", }; -enum usb_device_speed usb_get_maximum_speed(int node) +enum usb_device_speed usb_get_maximum_speed(ofnode node) { - const void *fdt = gd->fdt_blob; const char *max_speed; int i; - max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL); + max_speed = ofnode_get_property(node, "maximum-speed", NULL); if (!max_speed) { pr_err("usb maximum-speed not found\n"); return USB_SPEED_UNKNOWN; diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index ca63eac3d98e..ef72c8c017c4 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -61,18 +61,17 @@ static int dwc3_generic_peripheral_remove(struct udevice *dev) static int dwc3_generic_peripheral_ofdata_to_platdata(struct udevice *dev) { struct dwc3 *priv = dev_get_priv(dev); - int node = dev_of_offset(dev); - priv->regs = (void *)devfdt_get_addr(dev); + priv->regs = (void *)dev_read_addr(dev); priv->regs += DWC3_GLOBALS_REGS_START; - priv->maximum_speed = usb_get_maximum_speed(node); + priv->maximum_speed = usb_get_maximum_speed(dev->node); if (priv->maximum_speed == USB_SPEED_UNKNOWN) { pr_err("Invalid usb maximum speed\n"); return -ENODEV; } - priv->dr_mode = usb_get_dr_mode(node); + priv->dr_mode = usb_get_dr_mode(dev->node); if (priv->dr_mode == USB_DR_MODE_UNKNOWN) { pr_err("Invalid usb mode setup\n"); return -ENODEV; @@ -100,13 +99,11 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = { static int dwc3_generic_bind(struct udevice *parent) { - const void *fdt = gd->fdt_blob; - int node; + ofnode node; int ret; - for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0; - node = fdt_next_subnode(fdt, node)) { - const char *name = fdt_get_name(fdt, node, NULL); + dev_for_each_subnode(node, parent) { + const char *name = (char *)ofnode_get_name(node); enum usb_dr_mode dr_mode; struct udevice *dev; const char *driver; @@ -133,7 +130,7 @@ static int dwc3_generic_bind(struct udevice *parent) }; ret = device_bind_driver_to_node(parent, driver, name, - offset_to_ofnode(node), &dev); + node, &dev); if (ret) { debug("%s: not able to bind usb device mode\n", __func__); diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c index 80754d76d03f..cbab436d3b7b 100644 --- a/drivers/usb/host/xhci-dwc3.c +++ b/drivers/usb/host/xhci-dwc3.c @@ -202,6 +202,7 @@ static int xhci_dwc3_probe(struct udevice *dev) struct dwc3 *dwc3_reg; enum usb_dr_mode dr_mode; int ret; + ofnode node; hccr = (struct xhci_hccr *)((uintptr_t)dev_read_addr(dev)); hcor = (struct xhci_hcor *)((uintptr_t)hccr + @@ -215,7 +216,7 @@ static int xhci_dwc3_probe(struct udevice *dev) dwc3_core_init(dwc3_reg); - dr_mode = usb_get_dr_mode(dev_of_offset(dev)); + dr_mode = usb_get_dr_mode(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/host/xhci-zynqmp.c b/drivers/usb/host/xhci-zynqmp.c index e44e1ae1d915..5a5b8703c9a4 100644 --- a/drivers/usb/host/xhci-zynqmp.c +++ b/drivers/usb/host/xhci-zynqmp.c @@ -121,10 +121,9 @@ static int xhci_usb_remove(struct udevice *dev) static int xhci_usb_ofdata_to_platdata(struct udevice *dev) { struct zynqmp_xhci_platdata *plat = dev_get_platdata(dev); - const void *blob = gd->fdt_blob; /* Get the base address for XHCI controller from the device node */ - plat->hcd_base = fdtdec_get_addr(blob, dev_of_offset(dev), "reg"); + plat->hcd_base = dev_read_addr(dev); if (plat->hcd_base == FDT_ADDR_T_NONE) { debug("Can't get the XHCI register base address\n"); return -ENXIO; diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index d2604c5cafba..baf4d9150687 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, @@ -23,7 +25,7 @@ enum usb_dr_mode { * 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 @@ -32,6 +34,6 @@ enum usb_dr_mode usb_get_dr_mode(int node); * The function gets phy interface string from property 'maximum-speed', * and returns the correspondig enum usb_device_speed */ -enum usb_device_speed usb_get_maximum_speed(int node); +enum usb_device_speed usb_get_maximum_speed(ofnode node); #endif /* __LINUX_USB_OTG_H */