From patchwork Mon May 11 07:57:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 1178 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 4F8063F9E5 for ; Mon, 11 May 2020 09:57:35 +0200 (CEST) Received: by mail-pj1-f70.google.com with SMTP id l11sf16582989pjz.4 for ; Mon, 11 May 2020 00:57:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1589183854; cv=pass; d=google.com; s=arc-20160816; b=tJlV6qhsGaEuJKbXIDlNCGIj3pHa5K+OwPYdzykIVMb+cR5CTYohIy6xUe3EnT3CLd ikJMgQ7LVG4zSjgA2kzQpvlx2bZ/eApr/6kIaufqEulFVkNCDqll78RVB1mfU6k8zu7F oHu4ijhYczXW7RblBjnMghWXjtGynuIjKe1KuYIMmK+dGGyldvAac9JQ4y5hj9GpMY61 8wrObGtbbjRfQcWybv+vuf3SZg0OeyOvIviuehwhSonqUKt486yhO/aYrwXTS0E4XfAm YZ2UpYTffU3ZZrtvbiur5mLEXgIhTfnhiZVIJWhmcWYDSTuCOMVDu6g+haCpNGEt+Bdu rhvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:sender:dkim-signature; bh=NGIv+ek+GCnfSEv+ZMQXmcjvAcezHwldlpCU+GINmiI=; b=Yr/srR5wxqVF56KdW9qfgFdyroLSR7/Zv7Tlvg9iVgKsaweCmFMAmpZMZzvTruBi/e f35cOTMmljTydF/6G8HirRx3X8Ybm1zlsY480Z55BjEDpz4ox3/cWgTAEpf+WZw0RyFq KIIn2I6febCzTuk3ZU72jxeBComi1/9YvHXbtA7WZ2jGsh2R0S7tfsM5LADjUXXNaxUs 1GxKIowt+1UmIIVPWD1xOjc/64pF+z+tOQNVt3vyeqJLaOc6Z9zyGuqm/mwCRAxrwTmN qA9P5gNmS8+j0Uh6AikUYqaLgSNQD3oz7LKvc0FyncpBFfZt1zQom3DyX1Yz9/96SGVx 06WA== ARC-Authentication-Results: i=2; mx.google.com; spf=pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.134 as permitted sender) smtp.mailfrom=frank.wang@rock-chips.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=NGIv+ek+GCnfSEv+ZMQXmcjvAcezHwldlpCU+GINmiI=; b=PiQO6tRCIIyGQTuYzUeZhat23DmIhj2GTrRDWnzJrK1+pdmZOoPB+EGDXSvJ/MjDdZ +ZsAH5a31r9pw/bf6nBUAN/0sQ2C9ZZoPubcLrobymZMeWLZ2ZU+9yOeBhdq7f3BKn9A snL32jeHLegOyp2Lw9t8lnO5aKiNcSLysoBKg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=NGIv+ek+GCnfSEv+ZMQXmcjvAcezHwldlpCU+GINmiI=; b=Cbd5TenvmXQfT2I5sCMEBtfCerhnJl7Svcmn8jf+tRkzZCuJDWnULXxToNagxqy/hF 8p8z9If52G5rXB9Cyx5xcYbQsRlN+aFLQpZ4bZNw9wViieYzjYWCiD8ODBJUX57kLPfU anrbHnZ5drvvFB/lXkoV3olnPcPpqq8Oqbd0YWVaIxc2Ix9onaRssTouhUDzYp9PSS54 xpItu70PpZNKOSuz7m3ndMle4lIpCoZItrOtKeFzABy1kqCUQHPomaw7yHbOoRNfvdaf zVnp8TGSnf1Gr0jasUiq2JMq1lsZMMA9rRLpSTozjtLn+BpFf+oCKowtIyVz8ig+V31c nwQA== Sender: linux-amarula@amarulasolutions.com X-Gm-Message-State: AGi0Pub04ysm+T5NclsFMlP/lO2KQf0w+2dwBQ779nxQ3TjboJZdxI0s GTjQpF7vhTqLkTHgk01tV5eblj/f X-Google-Smtp-Source: APiQypKDq3Krt6VwWvmtqyU1uXnzbyzhqGPKb8Rot2YqH94GhiKP4oIcnq49rj1mTtCnO1zZ5AJzIg== X-Received: by 2002:aa7:9d90:: with SMTP id f16mr15449585pfq.48.1589183854082; Mon, 11 May 2020 00:57:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:7b82:: with SMTP id w2ls4672581pll.1.gmail; Mon, 11 May 2020 00:57:33 -0700 (PDT) X-Received: by 2002:a17:90b:3751:: with SMTP id ne17mr20101190pjb.114.1589183853674; Mon, 11 May 2020 00:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589183853; cv=none; d=google.com; s=arc-20160816; b=VxAdfwLaezFfiI3/PN7hDfj5HBRsCBcKYchY/9topnrAw+IUI4ElTiB03vQgRT9QUS Sg1ocJ5nknqlnzGa+Uyjy+p29Q97Nxo1U56c4RjJh+/OBptIZlyV21bQBPPeTq10JwUy 880RkFv/KdJrVO8IUnH4L0qHC8fTAGr+c1il7MD19FaAuN0J6CCCaPLgu7yVOFUDqCMq 4kMvuRnuRdEKsOQ7PinxQ4lTsnFWKRgRMrli/Wucb2oNDXa/UmSzS0I0GGYX6AwQSESm J3Mgo45glkpwNiCqzAEdbUUQhqbW49d0zjSo+HHYcgvMoif2WxXs/qNW6gbTdtBAmJR+ /MBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=36aEMnW5RrfrLCDZ/dxiJwsiQY1IO4K+MMt/lPSgVAM=; b=ixDCjkz5BA8nkA9ln6O0+Oa2ZfV61koRX/oOgb4Uymb+/+HoGvMziXwAxckgBbjo7j Exx7iXWeXaSkuXE/qzxz8P8fOX3zIFffZHzIV+6xult9rFFiEWmC3yu6VUgO2hj0ZXUR 07w1MQwl5SKR225T33FWHOvbroJRtt/AkvDfz1U0DhYOb2PaWqx+TcAFW3zedgSpBjJi /A02jJ8heAEIfjFwjoamOMywholMAnC8EWBOymJ7fg54Hg03d7GJcIE8Myt4WawDFD4+ c49DbdhyTGv/6mgoO43V7fZUgBEHQ3YKP60CKFtK3ZmkHEdk/BSyLp1fezTrSp1aC9Wz XWLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.134 as permitted sender) smtp.mailfrom=frank.wang@rock-chips.com Received: from lucky1.263xmail.com (lucky1.263xmail.com. [211.157.147.134]) by mx.google.com with ESMTPS id y7si7603314pju.71.2020.05.11.00.57.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2020 00:57:33 -0700 (PDT) Received-SPF: pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.134 as permitted sender) client-ip=211.157.147.134; Received: from localhost (unknown [192.168.167.209]) by lucky1.263xmail.com (Postfix) with ESMTP id 9D291A4C9F; Mon, 11 May 2020 15:57:31 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P21665T139939416696576S1589183847395463_; Mon, 11 May 2020 15:57:31 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <676c015d1c9f8c67e14285f35cea79ff> X-RL-SENDER: frank.wang@rock-chips.com X-SENDER: wmc@rock-chips.com X-LOGIN-NAME: frank.wang@rock-chips.com X-FST-TO: heiko@sntech.de X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: Frank Wang To: heiko@sntech.de, marex@denx.de, bmeng.cn@gmail.com, philipp.tomsich@theobroma-systems.com, klaus.goger@theobroma-systems.com, jagan@amarulasolutions.com, sjg@chromium.org, kever.yang@rock-chips.com Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, marek.belisko@gmail.com, william.wu@rock-chips.com, jianing.ren@rock-chips.com, chenjh@rock-chips.com, wmc@rock-chips.com, Frank Wang Subject: [PATCH v4 12/16] usb: dwc3: add make compatible for rockchip platform Date: Mon, 11 May 2020 15:57:21 +0800 Message-Id: <20200511075725.26665-3-frank.wang@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200511075725.26665-1-frank.wang@rock-chips.com> References: <20200511075330.26462-1-frank.wang@rock-chips.com> <20200511075725.26665-1-frank.wang@rock-chips.com> X-Original-Sender: frank.wang@rock-chips.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of frank.wang@rock-chips.com designates 211.157.147.134 as permitted sender) smtp.mailfrom=frank.wang@rock-chips.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , RK3399 Type-C PHY is required that must hold whole USB3.0 OTG controller in resetting to hold pipe power state in P2 before initializing the PHY. This commit fixed it and added device compatible for rockchip platform. Signed-off-by: Frank Wang Signed-off-by: Jagan Teki --- drivers/usb/dwc3/dwc3-generic.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index eabd53a36d..359460eb13 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -24,6 +24,12 @@ #include #include +struct dwc3_glue_data { + struct clk_bulk clks; + struct reset_ctl_bulk resets; + fdt_addr_t regs; +}; + struct dwc3_generic_plat { fdt_addr_t base; u32 maximum_speed; @@ -47,6 +53,7 @@ static int dwc3_generic_probe(struct udevice *dev, int rc; struct dwc3_generic_plat *plat = dev_get_platdata(dev); struct dwc3 *dwc3 = &priv->dwc3; + struct dwc3_glue_data *glue = dev_get_platdata(dev->parent); dwc3->dev = dev; dwc3->maximum_speed = plat->maximum_speed; @@ -55,10 +62,22 @@ static int dwc3_generic_probe(struct udevice *dev, dwc3_of_parse(dwc3); #endif + /* + * It must hold whole USB3.0 OTG controller in resetting to hold pipe + * power state in P2 before initializing TypeC PHY on RK3399 platform. + */ + if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3")) { + reset_assert_bulk(&glue->resets); + udelay(1); + } + rc = dwc3_setup_phy(dev, &priv->phys); if (rc) return rc; + if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3")) + reset_deassert_bulk(&glue->resets); + priv->base = map_physmem(plat->base, DWC3_OTG_REGS_END, MAP_NOCACHE); dwc3->regs = priv->base + DWC3_GLOBALS_REGS_START; @@ -186,12 +205,6 @@ U_BOOT_DRIVER(dwc3_generic_host) = { }; #endif -struct dwc3_glue_data { - struct clk_bulk clks; - struct reset_ctl_bulk resets; - fdt_addr_t regs; -}; - struct dwc3_glue_ops { void (*select_dr_mode)(struct udevice *dev, int index, enum usb_dr_mode mode); @@ -394,6 +407,12 @@ static int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; + if (glue->resets.count < 1) { + ret = dwc3_glue_reset_init(child, glue); + if (ret) + return ret; + } + while (child) { enum usb_dr_mode dr_mode; @@ -424,6 +443,8 @@ static const struct udevice_id dwc3_glue_ids[] = { { .compatible = "ti,dwc3", .data = (ulong)&ti_ops }, { .compatible = "ti,am437x-dwc3", .data = (ulong)&ti_ops }, { .compatible = "ti,am654-dwc3" }, + { .compatible = "rockchip,rk3328-dwc3" }, + { .compatible = "rockchip,rk3399-dwc3" }, { } };