From patchwork Thu Feb 8 15:20:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo i Serra X-Patchwork-Id: 10207271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C4366602D8 for ; Thu, 8 Feb 2018 15:21:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B46F829569 for ; Thu, 8 Feb 2018 15:21:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2D2629591; Thu, 8 Feb 2018 15:21:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6623729583 for ; Thu, 8 Feb 2018 15:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=skMvrtsGy0P2j3vxmc8K3rLlaoIeCuLCPEebZCI69VU=; b=dXc s0FgeO768GocdZcCQl6tECgd38xdQ0ZYeHv6f14Taz+QWD8tqL+pXbH+WPYLeUf7RXK/skT8CKObr xqAEjF+nx64j54HtNSyG5e1kedv5eKqRqxbLEVnC2xE2xYjixzwgIqUjoagEvrfRVjXH6hTKYHHSo HcY+gWZM87OxeBU/JUPOK0xKxcUh94FOfzY+zxoSbsyMyVDoFdu/FBdkqTCZ5ghOreWvzy6JW+Q6x S+uDXj2FYiex0fa2RvVfDye4MIKtG2hNWVZnEeHncX+mlkZTKiWdePxfBojzjy2yeAqea/HxBtgXe EizKaCIQeK2eoRp5/tjOoIbpxKt5K1Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ejo0p-00087U-Dg; Thu, 08 Feb 2018 15:21:23 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ejo0f-0007nL-56; Thu, 08 Feb 2018 15:21:17 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id BA3EC27268D From: Enric Balletbo i Serra To: Rob Herring , Kishon Vijay Abraham I , Brian Norris Subject: [PATCH 1/3] phy: rockchip-typec: enable usb3 host during usb3 phy power on Date: Thu, 8 Feb 2018 16:20:26 +0100 Message-Id: <20180208152028.9997-1-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.15.1 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, hl@rock-chips.com, dianders@chromium.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Chris Zhong , William wu , kernel@collabora.com, linux-arm-kernel@lists.infradead.org, Heiko Stuebner MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: William wu We have forced usb3 to work in usb2 only mode in firmware by setting usb3tousb2_en (bit3 of GRF_USB3PHY0/1_CON0) to 1, and setting host_u3_port_disable (bit0 of GRF_USB3OTG0/1_CON1) to 1 and host_u3_port (bit15~12 of GRF_USB3OTG0/1_CON1) to 0. So we need to re-enable usb3 host. Note that the RK3399 TRM suggests that we should keep the whole usb3 controller in reset for the duration of the Type-C PHY initialization. However, it's hard to assert the reset in the current framework of reset. And according to the TRM, it doesn't require that we should clear the usb3tousb2 bit before pipe ready. So let's enable the usb3 host after pipe ready to avoid the Type-C PHY initialization failure. Signed-off-by: William wu Signed-off-by: Enric Balletbo i Serra --- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 4 ++++ drivers/phy/rockchip/phy-rockchip-typec.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi index 2f2dee0e2f3c..6c72f8aca74c 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi @@ -1438,6 +1438,8 @@ rockchip,grf = <&grf>; rockchip,typec-conn-dir = <0xe580 0 16>; rockchip,usb3tousb2-en = <0xe580 3 19>; + rockchip,usb3-host-disable = <0x2434 0 16>; + rockchip,usb3-host-port = <0x2434 12 28>; rockchip,external-psm = <0xe588 14 30>; rockchip,pipe-status = <0xe5c0 0 0>; rockchip,uphy-dp-sel = <0x6268 19 19>; @@ -1468,6 +1470,8 @@ rockchip,grf = <&grf>; rockchip,typec-conn-dir = <0xe58c 0 16>; rockchip,usb3tousb2-en = <0xe58c 3 19>; + rockchip,usb3-host-disable = <0x2444 0 16>; + rockchip,usb3-host-port = <0x2444 12 28>; rockchip,external-psm = <0xe594 14 30>; rockchip,pipe-status = <0xe5c0 16 16>; rockchip,uphy-dp-sel = <0x6268 3 19>; diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c index 3ed44bee0fdc..cc07f528cc48 100644 --- a/drivers/phy/rockchip/phy-rockchip-typec.c +++ b/drivers/phy/rockchip/phy-rockchip-typec.c @@ -358,6 +358,8 @@ struct usb3phy_reg { struct rockchip_usb3phy_port_cfg { struct usb3phy_reg typec_conn_dir; struct usb3phy_reg usb3tousb2_en; + struct usb3phy_reg usb3_host_disable; + struct usb3phy_reg usb3_host_port; struct usb3phy_reg external_psm; struct usb3phy_reg pipe_status; struct usb3phy_reg uphy_dp_sel; @@ -853,6 +855,9 @@ static int rockchip_usb3_phy_power_on(struct phy *phy) regmap_read(tcphy->grf_regs, reg->offset, &val); if (!(val & BIT(reg->enable_bit))) { tcphy->mode |= new_mode & (MODE_DFP_USB | MODE_UFP_USB); + /* enable usb3 host */ + property_enable(tcphy, &cfg->usb3_host_disable, 0); + property_enable(tcphy, &cfg->usb3_host_port, 1); goto unlock_ret; } usleep_range(10, 20); @@ -1023,6 +1028,16 @@ static int tcphy_parse_dt(struct rockchip_typec_phy *tcphy, if (ret) return ret; + ret = tcphy_get_param(dev, &cfg->usb3_host_disable, + "rockchip,usb3-host-disable"); + if (ret) + return ret; + + ret = tcphy_get_param(dev, &cfg->usb3_host_port, + "rockchip,usb3-host-port"); + if (ret) + return ret; + ret = tcphy_get_param(dev, &cfg->external_psm, "rockchip,external-psm"); if (ret)