Message ID | 20221214223733.648167-1-marijn.suijten@somainline.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp4763wrn; Wed, 14 Dec 2022 14:40:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf4pWDe1nVKv/ObZcX80VwYfKyIfrjBwvjoW1FHyPBUl6XepLXFwFCE1ts+KAWMBwNqqBHSC X-Received: by 2002:a17:902:ccd0:b0:186:f57d:8573 with SMTP id z16-20020a170902ccd000b00186f57d8573mr29665079ple.2.1671057636562; Wed, 14 Dec 2022 14:40:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671057636; cv=none; d=google.com; s=arc-20160816; b=aChbJG4iiEY35kWa2Dkguvw0e9HuAKQKeqwISCBVdtJjJt0eG1dpL2fGlqHbfiX6fk IpFwfGBBzl47OiBKaXm1nePhwf7UmKg2Pw8LpkOCoolIVy9ledJm7ZzDO++mrUWT7ZOJ aED3xViOlyeLQBlGcHAeEyDviV8qsvMheQ5wXpwMtxFILmqqwyI1JttgCz4KFJOt6z0i ye1+ZEaxWWagP/cADEUdehdII8jg5alOIQ0P8ELhn2/7MdXxV9R6nETDzJfNCHytMVyw MI0phD4CzesYnJyiqom77fT8NzFGzNBfbxyK8/Z+pAeqaH+vTv8ImQtCmGttcfCIkvim oFsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=IgTgxqakHRpmH15pxYA9GP+jTcNXPwW6HVCdTxpfcFk=; b=VRsDOhzrI2TizP0FVEg5vZw3Es0rtfQRrEPBKcHXfN1gKwX7Gt0eWontca37kKxYc0 e0vTXzSvWH60Zusi+gKNs4d6FNahl5A4cmOD6p5dGeb5Ti5cNdiElV1697JY0KchBaKq e85GCIxou2TSUpG8ywpebt/H0Qkd/F96gvDGDuIiyhMc7tTXC/4X20bEmE9VwH74aQxJ yHodxfPYPtoEFF++zkFbCp7vcJDFjWBYVRWAnI6xcYI1sXptzd8bMTEFSU3jIC49tNjc QQXt+G5hJJcZc13E5aZY0qwdlmq2NtCpFZU7pEUO0scC3LzCrmYzVM7ckAr/MQelAUEY hqOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a170902d48600b00189d12c0dd9si4459517plg.555.2022.12.14.14.40.20; Wed, 14 Dec 2022 14:40:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229550AbiLNWhx (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Wed, 14 Dec 2022 17:37:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbiLNWhv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 14 Dec 2022 17:37:51 -0500 Received: from relay03.th.seeweb.it (relay03.th.seeweb.it [5.144.164.164]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71D4036C62; Wed, 14 Dec 2022 14:37:49 -0800 (PST) Received: from localhost.localdomain (94-209-172-39.cable.dynamic.v4.ziggo.nl [94.209.172.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r1.th.seeweb.it (Postfix) with ESMTPSA id 5F54620376; Wed, 14 Dec 2022 23:37:47 +0100 (CET) From: Marijn Suijten <marijn.suijten@somainline.org> To: phone-devel@vger.kernel.org Cc: ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>, Konrad Dybcio <konrad.dybcio@somainline.org>, Martin Botka <martin.botka@somainline.org>, Jami Kettunen <jami.kettunen@somainline.org>, Marijn Suijten <marijn.suijten@somainline.org>, Michael Srba <Michael.Srba@seznam.cz>, Andy Gross <agross@kernel.org>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Vinod Koul <vkoul@kernel.org>, Kishon Vijay Abraham I <kishon@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, "Bryan O'Donoghue" <bryan.odonoghue@linaro.org>, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Revert "phy: qualcomm: usb28nm: Add MDM9607 init sequence" Date: Wed, 14 Dec 2022 23:37:32 +0100 Message-Id: <20221214223733.648167-1-marijn.suijten@somainline.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752230932617221721?= X-GMAIL-MSGID: =?utf-8?q?1752230932617221721?= |
Series |
Revert "phy: qualcomm: usb28nm: Add MDM9607 init sequence"
|
|
Commit Message
Marijn Suijten
Dec. 14, 2022, 10:37 p.m. UTC
This reverts commit 557a28811c7e0286d3816842032db5eb7bb5f156.
This commit introduced an init sequence from downstream DT [1] in the
driver. As mentioned by the comment above the HSPHY_INIT_CFG macro for
this sequence:
/*
* The macro is used to define an initialization sequence. Each tuple
* is meant to program 'value' into phy register at 'offset' with 'delay'
* in us followed.
*/
Instead of corresponding to offsets into the phy register, the sequence
read by the downstream driver [2] is passed into ulpi_write [3] which
crafts the address-value pair into a new value and writes it into the
same register at USB_ULPI_VIEWPORT [4]. In other words, this init
sequence is programmed into the hardware in a totally different way than
downstream and is unlikely to achieve the desired result, if the hsphy
is working at all.
An alternative method needs to be found to write these init values at
the desired location. Fortunately mdm9607 did not land upstream yet [5]
and should have its compatible revised to use the generic one, instead
of a compatible that writes wrong data to the wrong registers.
[1]: https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/arch/arm/boot/dts/qcom/mdm9607.dtsi#585
[2]: https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/drivers/usb/phy/phy-msm-usb.c#4183
[3]: https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/drivers/usb/phy/phy-msm-usb.c#468
[4]: https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/drivers/usb/phy/phy-msm-usb.c#418
[5]: https://lore.kernel.org/linux-arm-msm/20210805222812.40731-1-konrad.dybcio@somainline.org/
Reported-by: Michael Srba <Michael.Srba@seznam.cz>
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
---
.../devicetree/bindings/phy/qcom,usb-hs-28nm.yaml | 1 -
drivers/phy/qualcomm/phy-qcom-usb-hs-28nm.c | 13 -------------
2 files changed, 14 deletions(-)
Comments
On 14/12/2022 22:37, Marijn Suijten wrote: > This reverts commit 557a28811c7e0286d3816842032db5eb7bb5f156. > > This commit introduced an init sequence from downstream DT [1] in the > driver. As mentioned by the comment above the HSPHY_INIT_CFG macro for > this sequence: > > /* > * The macro is used to define an initialization sequence. Each tuple > * is meant to program 'value' into phy register at 'offset' with 'delay' > * in us followed. > */ > > Instead of corresponding to offsets into the phy register, the sequence > read by the downstream driver [2] is passed into ulpi_write [3] which > crafts the address-value pair into a new value and writes it into the > same register at USB_ULPI_VIEWPORT [4]. In other words, this init > sequence is programmed into the hardware in a totally different way than > downstream and is unlikely to achieve the desired result, if the hsphy > is working at all. > > An alternative method needs to be found to write these init values at > the desired location. Fortunately mdm9607 did not land upstream yet [5] > and should have its compatible revised to use the generic one, instead > of a compatible that writes wrong data to the wrong registers. > > [1]: https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/arch/arm/boot/dts/qcom/mdm9607.dtsi#585 > [2]: https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/drivers/usb/phy/phy-msm-usb.c#4183 > [3]: https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/drivers/usb/phy/phy-msm-usb.c#468 > [4]: https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/drivers/usb/phy/phy-msm-usb.c#418 > [5]: https://lore.kernel.org/linux-arm-msm/20210805222812.40731-1-konrad.dybcio@somainline.org/ > > Reported-by: Michael Srba <Michael.Srba@seznam.cz> > Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org> Hmm. I got a bit concerned qcs405 was broken too, which would be worrying since I remember testing this code, though not specifically turning off the PHY init, then again, there's a near zero chance the USB PHY would work after reset without the specified init seq. The original upstreamed code for qcs404/405 https://android.googlesource.com/kernel/msm/+/refs/heads/android-msm-coral-4.14-android10/arch/arm64/boot/dts/qcom/qcs405-usb.dtsi https://android.googlesource.com/kernel/msm/+/refs/heads/android-msm-coral-4.14-android10/drivers/usb/phy/phy-qcom-snps-28nm-hs.c Does a relative write to an offset of the PHY CSR CSR base is 0x7a000 https://android.googlesource.com/kernel/msm/+/refs/heads/android-msm-coral-4.14-android10/arch/arm64/boot/dts/qcom/qcs405-usb.dtsi#74 https://android.googlesource.com/kernel/msm/+/refs/heads/android-msm-coral-4.14-android10/drivers/usb/phy/phy-qcom-snps-28nm-hs.c#285 which will result in 0x7a000 + 0xc0 = 0x01, etc which for us upstream then is https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/qcom/qcs404.dtsi#L336 and https://github.com/torvalds/linux/blob/master/drivers/phy/qualcomm/phy-qcom-usb-hs-28nm.c#L388 Writing 0x7a000 + 0xc0 = 0x01, etc - a writel() in this case so that bit is fine. mdm9607 https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/arch/arm/boot/dts/qcom/mdm9607.dtsi#569 - compat string is CSR is @ 0x6c000 https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/drivers/usb/phy/phy-msm-usb.c#664 downstream PHY init seq https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/arch/arm/boot/dts/qcom/mdm9607.dtsi#585 and downstream driver PHY init write https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/drivers/usb/phy/phy-msm-usb.c#664 Which does writel_relaxed(ULPI_RUN | ULPI_WRITE | ULPI_ADDR(reg) | ULPI_DATA(val), USB_ULPI_VIEWPORT); Yep, you're right, we can't do a simple writeb(csr + reg, val); for mdm9607 but, also the qcs404 => compat = "qcom,usb-hs-28nm-femtophy" is doing the right thing. Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
On Wed, Dec 14, 2022 at 11:37:32PM +0100, Marijn Suijten wrote: > This reverts commit 557a28811c7e0286d3816842032db5eb7bb5f156. > > This commit introduced an init sequence from downstream DT [1] in the > driver. As mentioned by the comment above the HSPHY_INIT_CFG macro for > this sequence: > > /* > * The macro is used to define an initialization sequence. Each tuple > * is meant to program 'value' into phy register at 'offset' with 'delay' > * in us followed. > */ > > Instead of corresponding to offsets into the phy register, the sequence > read by the downstream driver [2] is passed into ulpi_write [3] which > crafts the address-value pair into a new value and writes it into the > same register at USB_ULPI_VIEWPORT [4]. In other words, this init > sequence is programmed into the hardware in a totally different way than > downstream and is unlikely to achieve the desired result, if the hsphy > is working at all. > Thanks for sending this, I've also been meaning to do this for quite some time :) Reviewed-by: Stephan Gerhold <stephan@gerhold.net> > An alternative method needs to be found to write these init values at > the desired location. Fortunately mdm9607 did not land upstream yet [5] > and should have its compatible revised to use the generic one, instead > of a compatible that writes wrong data to the wrong registers. > There is a simple solution to write the init values correctly: You can just use the ULPI PHY driver for MSM8916 (phy-qcom-usb-hs.c), which writes those init values correctly. If you look closely at downstream you can see that all targets with the "SNPS Femto PHY" (at least MSM8909, MDM9607, MSM8976) actually use a mixture of the code currently implemented in the mainline ULPI PHY driver (phy-qcom-usb-hs.c) and the actual Femto PHY driver (phy-qcom-usb-hs-28nm.c): - The device trees contains "qcom,dp-manual-pullup", which enables the ULPI_MISC_A_VBUSVLDEXT magic that is currently implemented partly in phy-qcom-usb-hs.c and partly in ci_hdrc_msm.c: - Downstream: https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/blob/29f81c613f4c853f4125ef189ede1f6d610653c0/drivers/usb/gadget/ci13xxx_msm.c#L113 - Mainline: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/phy/qualcomm/phy-qcom-usb-hs.c?h=v6.1#n92 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/chipidea/ci_hdrc_msm.c?h=v6.1#n117 - The ULPI init sequence is also implemented by phy-qcom-usb-hs.c in mainline: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/phy/qualcomm/phy-qcom-usb-hs.c?h=v6.1#n144 - The PHY CSR registers implemented by phy-qcom-usb-hs-28nm.c are only used to enter retention mode downstream (I guess some low-power mode where an USB device/host could still wake up the other host/device). We don't have support for proper support for retention on mainline (phy-qcom-usb-hs-28nm.c never enables the retention mode without fully powering off the PHY immediately after using the regulators). So I suggest that we simply use the ULPI PHY driver for MSM8916 at least for MSM8909 and MDM9607 (haven't checked MSM8976 in detail). I have tried it and it works without any problems on both MSM8909 and MDM9607. No driver changes needed! Thanks, Stephan
On 14-12-22, 23:37, Marijn Suijten wrote: > This reverts commit 557a28811c7e0286d3816842032db5eb7bb5f156. > > This commit introduced an init sequence from downstream DT [1] in the > driver. As mentioned by the comment above the HSPHY_INIT_CFG macro for > this sequence: > > /* > * The macro is used to define an initialization sequence. Each tuple > * is meant to program 'value' into phy register at 'offset' with 'delay' > * in us followed. > */ > > Instead of corresponding to offsets into the phy register, the sequence > read by the downstream driver [2] is passed into ulpi_write [3] which > crafts the address-value pair into a new value and writes it into the > same register at USB_ULPI_VIEWPORT [4]. In other words, this init > sequence is programmed into the hardware in a totally different way than > downstream and is unlikely to achieve the desired result, if the hsphy > is working at all. > > An alternative method needs to be found to write these init values at > the desired location. Fortunately mdm9607 did not land upstream yet [5] > and should have its compatible revised to use the generic one, instead > of a compatible that writes wrong data to the wrong registers. Applied after adding missing subsystem tag, thanks
On 2023-01-13 23:16:15, Vinod Koul wrote: > On 14-12-22, 23:37, Marijn Suijten wrote: > > This reverts commit 557a28811c7e0286d3816842032db5eb7bb5f156. > > > > This commit introduced an init sequence from downstream DT [1] in the > > driver. As mentioned by the comment above the HSPHY_INIT_CFG macro for > > this sequence: > > > > /* > > * The macro is used to define an initialization sequence. Each tuple > > * is meant to program 'value' into phy register at 'offset' with 'delay' > > * in us followed. > > */ > > > > Instead of corresponding to offsets into the phy register, the sequence > > read by the downstream driver [2] is passed into ulpi_write [3] which > > crafts the address-value pair into a new value and writes it into the > > same register at USB_ULPI_VIEWPORT [4]. In other words, this init > > sequence is programmed into the hardware in a totally different way than > > downstream and is unlikely to achieve the desired result, if the hsphy > > is working at all. > > > > An alternative method needs to be found to write these init values at > > the desired location. Fortunately mdm9607 did not land upstream yet [5] > > and should have its compatible revised to use the generic one, instead > > of a compatible that writes wrong data to the wrong registers. > > Applied after adding missing subsystem tag, thanks Thanks, it wasn't clear to me whether to suffix the title when already included in the Revert: "phy: qualcomm: ..." title :) - Marijn
On 16-01-23, 21:35, Marijn Suijten wrote: > On 2023-01-13 23:16:15, Vinod Koul wrote: > > On 14-12-22, 23:37, Marijn Suijten wrote: > > > This reverts commit 557a28811c7e0286d3816842032db5eb7bb5f156. > > > > > > This commit introduced an init sequence from downstream DT [1] in the > > > driver. As mentioned by the comment above the HSPHY_INIT_CFG macro for > > > this sequence: > > > > > > /* > > > * The macro is used to define an initialization sequence. Each tuple > > > * is meant to program 'value' into phy register at 'offset' with 'delay' > > > * in us followed. > > > */ > > > > > > Instead of corresponding to offsets into the phy register, the sequence > > > read by the downstream driver [2] is passed into ulpi_write [3] which > > > crafts the address-value pair into a new value and writes it into the > > > same register at USB_ULPI_VIEWPORT [4]. In other words, this init > > > sequence is programmed into the hardware in a totally different way than > > > downstream and is unlikely to achieve the desired result, if the hsphy > > > is working at all. > > > > > > An alternative method needs to be found to write these init values at > > > the desired location. Fortunately mdm9607 did not land upstream yet [5] > > > and should have its compatible revised to use the generic one, instead > > > of a compatible that writes wrong data to the wrong registers. > > > > Applied after adding missing subsystem tag, thanks > > Thanks, it wasn't clear to me whether to suffix the title when already > included in the Revert: "phy: qualcomm: ..." title :) A revert patch is a patch as well so the patch rules apply there as well, so should say "subsystem tag: other tags: Revert foo..." Thanks
On 2023-01-17 11:06:12, Vinod Koul wrote: <snip> > > Thanks, it wasn't clear to me whether to suffix the title when already > > included in the Revert: "phy: qualcomm: ..." title :) > > A revert patch is a patch as well so the patch rules apply there as well, > so should say "subsystem tag: other tags: Revert foo..." Ack, but then /keep/ "subsystem tag: other tags:" /within/ the Revert string, so "phy: qualcomm: Revert "phy: qualcomm: ...""? - Marijn
On 17-01-23, 10:19, Marijn Suijten wrote: > On 2023-01-17 11:06:12, Vinod Koul wrote: > <snip> > > > Thanks, it wasn't clear to me whether to suffix the title when already > > > included in the Revert: "phy: qualcomm: ..." title :) > > > > A revert patch is a patch as well so the patch rules apply there as well, > > so should say "subsystem tag: other tags: Revert foo..." > > Ack, but then /keep/ "subsystem tag: other tags:" /within/ the Revert > string, so "phy: qualcomm: Revert "phy: qualcomm: ...""? Ideally yes!
diff --git a/Documentation/devicetree/bindings/phy/qcom,usb-hs-28nm.yaml b/Documentation/devicetree/bindings/phy/qcom,usb-hs-28nm.yaml index abcc4373f39e..ca6a0836b53c 100644 --- a/Documentation/devicetree/bindings/phy/qcom,usb-hs-28nm.yaml +++ b/Documentation/devicetree/bindings/phy/qcom,usb-hs-28nm.yaml @@ -16,7 +16,6 @@ properties: compatible: enum: - qcom,usb-hs-28nm-femtophy - - qcom,usb-hs-28nm-mdm9607 reg: maxItems: 1 diff --git a/drivers/phy/qualcomm/phy-qcom-usb-hs-28nm.c b/drivers/phy/qualcomm/phy-qcom-usb-hs-28nm.c index 8807e59a1162..a52a9bf13b75 100644 --- a/drivers/phy/qualcomm/phy-qcom-usb-hs-28nm.c +++ b/drivers/phy/qualcomm/phy-qcom-usb-hs-28nm.c @@ -401,26 +401,13 @@ static const struct hsphy_init_seq init_seq_femtophy[] = { HSPHY_INIT_CFG(0x90, 0x60, 0), }; -static const struct hsphy_init_seq init_seq_mdm9607[] = { - HSPHY_INIT_CFG(0x80, 0x44, 0), - HSPHY_INIT_CFG(0x81, 0x38, 0), - HSPHY_INIT_CFG(0x82, 0x24, 0), - HSPHY_INIT_CFG(0x83, 0x13, 0), -}; - static const struct hsphy_data hsphy_data_femtophy = { .init_seq = init_seq_femtophy, .init_seq_num = ARRAY_SIZE(init_seq_femtophy), }; -static const struct hsphy_data hsphy_data_mdm9607 = { - .init_seq = init_seq_mdm9607, - .init_seq_num = ARRAY_SIZE(init_seq_mdm9607), -}; - static const struct of_device_id qcom_snps_hsphy_match[] = { { .compatible = "qcom,usb-hs-28nm-femtophy", .data = &hsphy_data_femtophy, }, - { .compatible = "qcom,usb-hs-28nm-mdm9607", .data = &hsphy_data_mdm9607, }, { }, }; MODULE_DEVICE_TABLE(of, qcom_snps_hsphy_match);