From: Enric Balletbo i Serra <enric.balletbo@collabora.com> To: Rob Herring <robh+dt@kernel.org>, Kishon Vijay Abraham I <kishon@ti.com>, Brian Norris <briannorris@chromium.org> Cc: Heiko Stuebner <heiko@sntech.de>, dianders@chromium.org, Chris Zhong <zyw@rock-chips.com>, William wu <wulf@rock-chips.com>, hl@rock-chips.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH v3 4/6] phy: rockchip-typec: force to USB2 if DP at 4 lanes mode Date: Fri, 16 Feb 2018 13:09:54 +0100 [thread overview] Message-ID: <20180216120956.19034-4-enric.balletbo@collabora.com> (raw) In-Reply-To: <20180216120956.19034-1-enric.balletbo@collabora.com> From: Chris Zhong <zyw@rock-chips.com> The usb3tousb2_en BIT will be clear to 0 in probe(), it make USB controller work at USB3 mode, and if the USB phy is turned on with DP only mode(4 lanes DP), the rockchip_usb3_phy_power_on() will return directly, so usb3_host_disable and usb3_host_port these 2 BIT will keep a same value as coreboot. In coreboot, these 3 BITs are set as USB2 mode, but now one of the bits is changed to USB3, it make USB controller work at a unknown status. These 3 BITs should be changed to USB2, if the Type-C works at 4 lanes mode, and then switch it back to USB3 mode, when USB disconnect. Signed-off-by: Chris Zhong <zyw@rock-chips.com> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> --- Changes since v2: - None. Changes since v1: - Use the registers offsets from the driver not the DT. drivers/phy/rockchip/phy-rockchip-typec.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c index 54dc52a948ef..9bc4d4bd46d3 100644 --- a/drivers/phy/rockchip/phy-rockchip-typec.c +++ b/drivers/phy/rockchip/phy-rockchip-typec.c @@ -853,6 +853,18 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy) return mode; } +static int tcphy_cfg_usb3_to_usb2_only(struct rockchip_typec_phy *tcphy, + bool value) +{ + struct rockchip_usb3phy_port_cfg *cfg = tcphy->port_cfgs; + + property_enable(tcphy, &cfg->usb3tousb2_en, value); + property_enable(tcphy, &cfg->usb3_host_disable, value); + property_enable(tcphy, &cfg->usb3_host_port, !value); + + return 0; +} + static int rockchip_usb3_phy_power_on(struct phy *phy) { struct rockchip_typec_phy *tcphy = phy_get_drvdata(phy); @@ -870,8 +882,10 @@ static int rockchip_usb3_phy_power_on(struct phy *phy) } /* DP-only mode; fall back to USB2 */ - if (!(new_mode & (MODE_DFP_USB | MODE_UFP_USB))) + if (!(new_mode & (MODE_DFP_USB | MODE_UFP_USB))) { + tcphy_cfg_usb3_to_usb2_only(tcphy, true); goto unlock_ret; + } if (tcphy->mode == new_mode) goto unlock_ret; @@ -887,9 +901,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); + tcphy_cfg_usb3_to_usb2_only(tcphy, false); goto unlock_ret; } usleep_range(10, 20); @@ -910,6 +924,7 @@ static int rockchip_usb3_phy_power_off(struct phy *phy) struct rockchip_typec_phy *tcphy = phy_get_drvdata(phy); mutex_lock(&tcphy->lock); + tcphy_cfg_usb3_to_usb2_only(tcphy, false); if (tcphy->mode == MODE_DISCONNECT) goto unlock; -- 2.15.1
WARNING: multiple messages have this Message-ID (diff)
From: enric.balletbo@collabora.com (Enric Balletbo i Serra) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 4/6] phy: rockchip-typec: force to USB2 if DP at 4 lanes mode Date: Fri, 16 Feb 2018 13:09:54 +0100 [thread overview] Message-ID: <20180216120956.19034-4-enric.balletbo@collabora.com> (raw) In-Reply-To: <20180216120956.19034-1-enric.balletbo@collabora.com> From: Chris Zhong <zyw@rock-chips.com> The usb3tousb2_en BIT will be clear to 0 in probe(), it make USB controller work at USB3 mode, and if the USB phy is turned on with DP only mode(4 lanes DP), the rockchip_usb3_phy_power_on() will return directly, so usb3_host_disable and usb3_host_port these 2 BIT will keep a same value as coreboot. In coreboot, these 3 BITs are set as USB2 mode, but now one of the bits is changed to USB3, it make USB controller work at a unknown status. These 3 BITs should be changed to USB2, if the Type-C works at 4 lanes mode, and then switch it back to USB3 mode, when USB disconnect. Signed-off-by: Chris Zhong <zyw@rock-chips.com> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> --- Changes since v2: - None. Changes since v1: - Use the registers offsets from the driver not the DT. drivers/phy/rockchip/phy-rockchip-typec.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c index 54dc52a948ef..9bc4d4bd46d3 100644 --- a/drivers/phy/rockchip/phy-rockchip-typec.c +++ b/drivers/phy/rockchip/phy-rockchip-typec.c @@ -853,6 +853,18 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy) return mode; } +static int tcphy_cfg_usb3_to_usb2_only(struct rockchip_typec_phy *tcphy, + bool value) +{ + struct rockchip_usb3phy_port_cfg *cfg = tcphy->port_cfgs; + + property_enable(tcphy, &cfg->usb3tousb2_en, value); + property_enable(tcphy, &cfg->usb3_host_disable, value); + property_enable(tcphy, &cfg->usb3_host_port, !value); + + return 0; +} + static int rockchip_usb3_phy_power_on(struct phy *phy) { struct rockchip_typec_phy *tcphy = phy_get_drvdata(phy); @@ -870,8 +882,10 @@ static int rockchip_usb3_phy_power_on(struct phy *phy) } /* DP-only mode; fall back to USB2 */ - if (!(new_mode & (MODE_DFP_USB | MODE_UFP_USB))) + if (!(new_mode & (MODE_DFP_USB | MODE_UFP_USB))) { + tcphy_cfg_usb3_to_usb2_only(tcphy, true); goto unlock_ret; + } if (tcphy->mode == new_mode) goto unlock_ret; @@ -887,9 +901,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); + tcphy_cfg_usb3_to_usb2_only(tcphy, false); goto unlock_ret; } usleep_range(10, 20); @@ -910,6 +924,7 @@ static int rockchip_usb3_phy_power_off(struct phy *phy) struct rockchip_typec_phy *tcphy = phy_get_drvdata(phy); mutex_lock(&tcphy->lock); + tcphy_cfg_usb3_to_usb2_only(tcphy, false); if (tcphy->mode == MODE_DISCONNECT) goto unlock; -- 2.15.1
next prev parent reply other threads:[~2018-02-16 12:11 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-02-16 12:09 [PATCH v3 1/6] phy: rockchip-typec: deprecate some DT properties for various register fields Enric Balletbo i Serra 2018-02-16 12:09 ` Enric Balletbo i Serra 2018-02-16 12:09 ` Enric Balletbo i Serra 2018-02-16 12:09 ` [PATCH v3 2/6] dt-bindings: phy-rockchip-typec: deprecate some register properties Enric Balletbo i Serra 2018-02-16 12:09 ` Enric Balletbo i Serra 2018-02-16 12:09 ` Enric Balletbo i Serra 2018-02-17 0:07 ` Heiko Stuebner 2018-02-17 0:07 ` Heiko Stuebner 2018-02-19 20:02 ` Rob Herring 2018-02-19 20:02 ` Rob Herring 2018-02-19 20:02 ` Rob Herring 2018-02-16 12:09 ` [PATCH v3 3/6] phy: rockchip-typec: enable usb3 host during usb3 phy power on Enric Balletbo i Serra 2018-02-16 12:09 ` Enric Balletbo i Serra 2018-02-17 0:08 ` Heiko Stuebner 2018-02-17 0:08 ` Heiko Stuebner 2018-02-17 0:08 ` Heiko Stuebner 2018-02-16 12:09 ` Enric Balletbo i Serra [this message] 2018-02-16 12:09 ` [PATCH v3 4/6] phy: rockchip-typec: force to USB2 if DP at 4 lanes mode Enric Balletbo i Serra 2018-02-17 0:09 ` Heiko Stuebner 2018-02-17 0:09 ` Heiko Stuebner 2018-02-17 0:09 ` Heiko Stuebner 2018-02-16 12:09 ` [PATCH v3 5/6] phy: rockchip-typec: support DP phy switch Enric Balletbo i Serra 2018-02-16 12:09 ` Enric Balletbo i Serra 2018-02-17 0:10 ` Heiko Stuebner 2018-02-17 0:10 ` Heiko Stuebner 2018-02-17 0:10 ` Heiko Stuebner 2018-02-16 12:09 ` [PATCH v3 6/6] drm/rockchip: cdn-dp: remove the " Enric Balletbo i Serra 2018-02-16 12:09 ` Enric Balletbo i Serra 2018-02-17 0:10 ` Heiko Stuebner 2018-02-17 0:10 ` Heiko Stuebner 2018-02-17 0:10 ` Heiko Stuebner 2018-03-16 11:02 ` Heiko Stuebner 2018-03-16 11:02 ` Heiko Stuebner 2018-02-17 0:06 ` [PATCH v3 1/6] phy: rockchip-typec: deprecate some DT properties for various register fields Heiko Stuebner 2018-02-17 0:06 ` Heiko Stuebner
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180216120956.19034-4-enric.balletbo@collabora.com \ --to=enric.balletbo@collabora.com \ --cc=briannorris@chromium.org \ --cc=devicetree@vger.kernel.org \ --cc=dianders@chromium.org \ --cc=heiko@sntech.de \ --cc=hl@rock-chips.com \ --cc=kernel@collabora.com \ --cc=kishon@ti.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-rockchip@lists.infradead.org \ --cc=robh+dt@kernel.org \ --cc=wulf@rock-chips.com \ --cc=zyw@rock-chips.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.