From patchwork Tue May 26 03:34:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 1242 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1B19D3F06D for ; Tue, 26 May 2020 05:35:25 +0200 (CEST) Received: by mail-pl1-f200.google.com with SMTP id f12sf14732858plt.9 for ; Mon, 25 May 2020 20:35:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1590464124; cv=pass; d=google.com; s=arc-20160816; b=f/J7Qjv3/Y+tuqp7Ob8XIF/0lV/raTD7pDjqIWhT8Bp5KhY8jkDIjFYKcJV9Lnha0o U7/D+75t1RGfQVI8vrqzN3NXjDbb47THoS9Fvq74ts/QgsacMUwJN2uqGz5l1EOSAcko tf7hyBO3ypobeiZO5RTQ+2dEkXhivRvaKeI/aSS0tgJjWegObB0plAKvsszsw4I/Tx46 zcOQl56yKcwuXe+WqygnUENez/+QzsSQ9t7NRVy7azmBZ7RzuFRYwzJcGBM+Mdt33092 kxWYU1LAZLRxuD2YgK3qqQ5acdVGX6/PDY4YN21ztSLNqFCSO97fQLHXl0uG12r2FUKq 0Sew== 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=SuQP7+IIuvUQIwfX7Behp9f4PxV9NJVsv0R/7M+Kw1Y=; b=XeDwk6mr2AzttrtZUbeJBK/y21pruzCqpPLuUfKCLyvFZyMot+oEuGqMxLtcZSlpEy 06/wbVRJn2vuCb3YnVcoqRd3KPDj/JiEQIuINgdhvcRkalNo/fv7RPkr/iFbIE0MAHPL 5dNXWKJs1bI1XHSgFC+ZtPxWxuQqAXYgvS3PJ+PXdYXZTh7RtohMFC334+1ZU87Zgftw jBmEd18abNZRZ12hpxAvFdD1GQG5o89kVE9GtUvLebb5KoeHpypJTwrWsr04YHbrxoGi nqJAAd18jhGd4f+hkNGT5A4LgqvZTUggzgPqb6rLlsCfnup8H9AHCJmi1eLu+xvTZ6+B G/nw== 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=SuQP7+IIuvUQIwfX7Behp9f4PxV9NJVsv0R/7M+Kw1Y=; b=kwWNrTW/W7qJTlqySbio2jYYgoxOzZORYgJwlznRsPpD7GZZivN3xtdm/H0Ss6aZ2+ Xum5MAAQW9fvM3yBdfeX5/drav8XTAvyBPzbdJ0EsTjNYjjQu5WUPC5s8gGJmnfhVrxD t8USsHuuy3AhFhF9+AIZf19m9MWRH8IJ6NfNg= 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=SuQP7+IIuvUQIwfX7Behp9f4PxV9NJVsv0R/7M+Kw1Y=; b=lQZs6TrbarMEiTJ0+soi+NamYzjL0dyf4Rlj2ifBBaqRJb4JbiwkKkGOh3KbrIDmLk xcNqTPWkyoeIl59v7R+oc74JF3eSuKn+wFXYrnat5ZKj0OxHCk4ue7so/BKWq+VkByQo K9nWvPM7fp11lTNAGG1Zioy8k0mGGUjoc6MCGW7c5AVDTDbsPKjVt9JT2ShRgx8v4iJc LZ5k1Rim9yribDR2b9vayQnLRx3dVqkEugU9R2/JLBy33E6AJB0DHjouEnjCs9PfbNJF txJbjadxx0Q0jPjqEa5BzeLivdWg6S74K0i4ehUvUw70wPlEzmbZLuPts52vvTLu31bs zMgw== Sender: linux-amarula@amarulasolutions.com X-Gm-Message-State: AOAM530ye0lPEYb42OqC/swkU1Z+fGal4ETRWaEjL52U93CyiuooJtBO IILtjcmZWNM3kU72/f1culslogLs X-Google-Smtp-Source: ABdhPJzf/CRIZkIJzX6jS5vfhAIBY3gJTq+/IPhm/FBXDxeRCiygJSHBV/3FF1rwmjaXJhfnP8Qabw== X-Received: by 2002:a17:90a:734b:: with SMTP id j11mr16584712pjs.114.1590464123843; Mon, 25 May 2020 20:35:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:aa7:9638:: with SMTP id r24ls3459941pfg.3.gmail; Mon, 25 May 2020 20:35:22 -0700 (PDT) X-Received: by 2002:a63:5f90:: with SMTP id t138mr28468425pgb.122.1590464122154; Mon, 25 May 2020 20:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590464122; cv=none; d=google.com; s=arc-20160816; b=BVNGJZ7LVfBPLzoRgEjABkBuDGYI3Q6+4N5F8en1d8POdg4ThsLiLcDUR7aErtgTAX dFjaYpQ1dbcFC1N6IbAK6386qkJs7gzDLnyPIsWDwk9afsTFOgnMgzLSBRPEGFsO1jNl 0TWdJgLwB9MdcWSuNL5eE8hOu4qcIx143xuKsR9EC3AHNfT6m8IquyhFoohc2JRwklp6 pGs6wqmowNfo+A5Jo4UHr1pR2m/8KwsQeLafOoLFmEHuCfGHp3dzIZSsr1Kjp5tZagpX GPCEExF580dU384PrGzT6NrkCO1rQ8iasITwE8s1zbE9DnRNqUQTmr5ohDUGTbpA8WOG hc/A== 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=nQe5YT1WoEnCyx+X7ZQ6x9FDZ0jnOGs/+pDcSunDCW8=; b=FEGeVOB8MMRzm9UNpdF0NkcKxcZiewomj4Zmt2Aa1t80F/r0YabQj1H+24T9wWcZDS qjI5XcG+6lFhUFZVmqV7qzUxGPP3Zkih8k7iRJhak4v+JozRjOMDMdF1PZ200V14DP5G 4n7l3XSCITTvb14LC7nN5BLxf2pdnC1h9UJIz0YyWf3r9fvk2YuzWvXnmqx4+tS7ITkj Tzt1wqym0OhcYCYEKmwFjHpCdOBE9WGexVxUKUJyV/1oC2gpQHxw0FWdKsvUmzkiOwfj onMHINhQjvE+60/DKxLQJK+EARYq8xKgaEExK9OG5pYCZVWWnWAxGzfdSbh6GTSPgGCI pLZA== 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 z15si16026328pjt.11.2020.05.25.20.35.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 May 2020 20:35:22 -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 BEAFBB1378; Tue, 26 May 2020 11:34:40 +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 P10491T139788594689792S1590464077143166_; Tue, 26 May 2020 11:34:40 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <98ba3b6fc941ca0f94b3df081685e846> 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 v6 12/16] usb: dwc3: add make compatible for rockchip platform Date: Tue, 26 May 2020 11:34:31 +0800 Message-Id: <20200526033435.20235-3-frank.wang@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200526033435.20235-1-frank.wang@rock-chips.com> References: <20200526033220.20047-1-frank.wang@rock-chips.com> <20200526033435.20235-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 Reviewed-by: Kever Yang --- 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..421e0be135 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 == 0) { + 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" }, { } };