From patchwork Tue Aug 29 20:59:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 718347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0870C6FA8F for ; Tue, 29 Aug 2023 21:00:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232260AbjH2U7f (ORCPT ); Tue, 29 Aug 2023 16:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240576AbjH2U72 (ORCPT ); Tue, 29 Aug 2023 16:59:28 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5CD51BF for ; Tue, 29 Aug 2023 13:59:23 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-500bdef7167so288501e87.0 for ; Tue, 29 Aug 2023 13:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693342762; x=1693947562; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ZClpEK+uUKPaycwTgXOUijkUQvmjkQmrL5FK82P2oPE=; b=QmQ1/FAUwtRhTgOE6gN1o+0iNj9yIxTbUXewz9xArIDUpbWkngaYp8juo6QojZm3iT lGv0c103ZUzUGgWQGfiIMxiibm7ulHyxa3e5UjhdwIBIuUK/p8hZvDypQCz8LxS0UD6m rt0/QlE+E9gaWZ4uFUc/q50jTDdUALmP7ck4yezrtI08Abage+tILTz+S36etLnY5l2Y 1vhLMHwXqFhc6xx3CR/ULoRfrTn/SmPNqEyehMsAr4/vZf395CjvBf/JB2jxsHzr7dk5 KNDgQQD9Tbl9nV0M+1GMU/G2KSVLr2z6vbFG6DtXuoG9mgFSF11GukfgioIbM6hBv4I/ G60Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693342762; x=1693947562; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZClpEK+uUKPaycwTgXOUijkUQvmjkQmrL5FK82P2oPE=; b=BRL57s/9vWSbXaQgdSy0ccWusC4P61uiLtDWaO4EKrMndB2IsHciH+YOeTTrQWP2la QydCPnsBczW1o1B4W/SWm+HD3NPzI9aRXf7S3gR2JmryI7+lWTeVTt0gcsNm+VU1n5GO 3ReNwPFXXEga7+h6EGWyE3dLilqWyXJhFeVAFttVzEaF37o48Sb3bwuNzQnYc7SVuiVK bPtIIFAihNWKDZKB9zHy41E7wyC47T+hr8cw3MxSFW92TiyugDnjjxfcJ7Od2wS0zrqp BPcO02XFPFsJMA03xTe9Fj/n7KUy+oXchfogZkOobJqG+Vdnp+mMcR93rp/rr6E/IacD TisQ== X-Gm-Message-State: AOJu0Yx2S+dnBj+F7GixIITZbv3E0k8fwQ0uPeiaMc98gFre+83QhLJt 1pv9Q0WdlKRpSWgAk8K9MIsDrA== X-Google-Smtp-Source: AGHT+IHTFrDD4halxuYrCPsR6VcW7GvdIxOAeOcebEyn3hhz73/cfFfBtt9lRL4iZLg5leo05uOYsQ== X-Received: by 2002:ac2:4e82:0:b0:4fd:c8fb:eb71 with SMTP id o2-20020ac24e82000000b004fdc8fbeb71mr105147lfr.11.1693342762069; Tue, 29 Aug 2023 13:59:22 -0700 (PDT) Received: from [192.168.1.101] (abyl195.neoplus.adsl.tpnet.pl. [83.9.31.195]) by smtp.gmail.com with ESMTPSA id q30-20020ac2515e000000b004fbad09317csm2074025lfd.189.2023.08.29.13.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 13:59:21 -0700 (PDT) From: Konrad Dybcio Date: Tue, 29 Aug 2023 22:59:04 +0200 Subject: [PATCH 1/2] phy: qcom-qmp-combo: Square out 8550 POWER_STATE_CONFIG1 MIME-Version: 1.0 Message-Id: <20230829-topic-8550_usbphy-v1-1-599ddbfa094a@linaro.org> References: <20230829-topic-8550_usbphy-v1-0-599ddbfa094a@linaro.org> In-Reply-To: <20230829-topic-8550_usbphy-v1-0-599ddbfa094a@linaro.org> To: Andy Gross , Bjorn Andersson , Vinod Koul , Kishon Vijay Abraham I , Abel Vesa , Johan Hovold , Dmitry Baryshkov Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1693342759; l=2561; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=ucbwZ1OoJJzdpql8jU/xLWDQeE1n/wAFfObCw093aVc=; b=Id79l4NM+X3WzTvMQFjDt69iOjhEsZOo/dEqkbR9V5S7/Ef7XnsbMxjOG/tqfQMc65u3RAREF mc8pZrjwhDkDOi16N+lcYkm62PG3/NgaDGK+OdNM3bdKYZEmdMHDqb9 X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org There are two instances of the POWER_STATE_CONFIG1 register: one in the PCS space and another one in PCS_USB. The downstream init sequence pokes the latter one while we've been poking the former one (and misnamed it as the latter one, impostor!). Fix that up to avoid UB. Fixes: 49742e9edab3 ("phy: qcom-qmp-combo: Add support for SM8550") Signed-off-by: Konrad Dybcio Reviewed-by: Dmitry Baryshkov Reviewed-by: Abel Vesa --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 2 +- drivers/phy/qualcomm/phy-qcom-qmp-pcs-usb-v6.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index cbb28afce135..843099d314bf 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -859,10 +859,10 @@ static const struct qmp_phy_init_tbl sm8550_usb3_pcs_tbl[] = { QMP_PHY_INIT_CFG(QPHY_USB_V6_PCS_PCS_TX_RX_CONFIG, 0x0c), QMP_PHY_INIT_CFG(QPHY_USB_V6_PCS_EQ_CONFIG1, 0x4b), QMP_PHY_INIT_CFG(QPHY_USB_V6_PCS_EQ_CONFIG5, 0x10), - QMP_PHY_INIT_CFG(QPHY_USB_V6_PCS_USB3_POWER_STATE_CONFIG1, 0x68), }; static const struct qmp_phy_init_tbl sm8550_usb3_pcs_usb_tbl[] = { + QMP_PHY_INIT_CFG(QPHY_USB_Q6_PCS_USB3_POWER_STATE_CONFIG1, 0x68), QMP_PHY_INIT_CFG(QPHY_USB_V6_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8), QMP_PHY_INIT_CFG(QPHY_USB_V6_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07), QMP_PHY_INIT_CFG(QPHY_USB_V6_PCS_USB3_RCVR_DTCT_DLY_U3_L, 0x40), diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcs-usb-v6.h b/drivers/phy/qualcomm/phy-qcom-qmp-pcs-usb-v6.h index 9510e63ba9d8..b9060c242fd2 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcs-usb-v6.h +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcs-usb-v6.h @@ -12,7 +12,7 @@ #define QPHY_USB_V6_PCS_LOCK_DETECT_CONFIG3 0xcc #define QPHY_USB_V6_PCS_LOCK_DETECT_CONFIG6 0xd8 #define QPHY_USB_V6_PCS_REFGEN_REQ_CONFIG1 0xdc -#define QPHY_USB_V6_PCS_USB3_POWER_STATE_CONFIG1 0x90 +#define QPHY_USB_V6_PCS_POWER_STATE_CONFIG1 0x90 #define QPHY_USB_V6_PCS_RX_SIGDET_LVL 0x188 #define QPHY_USB_V6_PCS_RCVR_DTCT_DLY_P1U2_L 0x190 #define QPHY_USB_V6_PCS_RCVR_DTCT_DLY_P1U2_H 0x194 @@ -23,6 +23,7 @@ #define QPHY_USB_V6_PCS_EQ_CONFIG1 0x1dc #define QPHY_USB_V6_PCS_EQ_CONFIG5 0x1ec +#define QPHY_USB_Q6_PCS_USB3_POWER_STATE_CONFIG1 0x00 #define QPHY_USB_V6_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL 0x18 #define QPHY_USB_V6_PCS_USB3_RXEQTRAINING_DFE_TIME_S2 0x3c #define QPHY_USB_V6_PCS_USB3_RCVR_DTCT_DLY_U3_L 0x40 From patchwork Tue Aug 29 20:59:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 719139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35340C83F19 for ; Tue, 29 Aug 2023 21:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239972AbjH2U7g (ORCPT ); Tue, 29 Aug 2023 16:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240581AbjH2U7b (ORCPT ); Tue, 29 Aug 2023 16:59:31 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC0C7CC4 for ; Tue, 29 Aug 2023 13:59:24 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-500c7796d8eso1076337e87.1 for ; Tue, 29 Aug 2023 13:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693342763; x=1693947563; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yDiDlbXY5yzxtV/UMHY8DDSwA1Y2sSArumeXUmrmXZw=; b=c8o1+BNYPTNZVhHl+goLHv+xrTxunRhO89wvU+igpZ81AGcFG3DJGezxlWnPyHGiKM HgSWKwppdMvxYlWHkm2CAdcFth0WbKyI2XXvwAY/NLpENu7QZqrinM8+0c9MQpYCo1Cu nGd+0q6Mt4fRmLMSOTS3Zumav2H4ouNbvnySxxdJJHvnxZdI2q+6TMLVKULCyfU1gbdn Rg/nsyAlwDSaBJkqPR+Ut8ZilX/fmxGP+Anh8ZS4+gvleuya/fbBl+DT3qvU0IGHHszn vXOdd8Juxxta+oCZqQer74Ii4pX4TCFIVsrc5nhcu3VBpsLO6tyNgFh7jyybyVSLp9Tb TbfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693342763; x=1693947563; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yDiDlbXY5yzxtV/UMHY8DDSwA1Y2sSArumeXUmrmXZw=; b=ZH/88nLyH2NgKSdBsFcqRF8n9yjtxcuuUUhO4NIm3QrKtcPBzyaqBQS6A4O7hzARU5 M2Qb/fhbrZTBCFbOLsS/PFBGpWw+gbY1V5sCOhZRDKr0Cz+vUxvsbRhV2WV2Gn+g0xgy WYw5XUbojjKlYCI9025i8XEoW1kNAtujG0YjngygU4uao26g3Ma9u1kuj12b/34ZfZlB w6IUNAnFQSlejff/TyA1aQVh+CYeu8EeMIs+jeaAFHzIMmozsx2KHL9avw+GcJSh+T8y RjJ4Ki9zLmHfjEDBbQo129g4Wi6A/INLYN8tHeZ5a6Lgf8AySUe19wSw+TjawO89CtyD LpGw== X-Gm-Message-State: AOJu0Yx0rEyQAVVTF9jboE4facVT7nm9bv5j6WmBUN3jEBX/ul+7KMLq bZkUZ/96pwVm+VYLYaYWJFGMEQ== X-Google-Smtp-Source: AGHT+IFBt6mCKFv8FjhhTBDDAyZfTvDLM3LO49D3cQx1lhHL5aFnzKrfjknbW6j9TLPvdXrQfK39tw== X-Received: by 2002:a19:5e1a:0:b0:4fa:21d4:b3ca with SMTP id s26-20020a195e1a000000b004fa21d4b3camr56225lfb.2.1693342763210; Tue, 29 Aug 2023 13:59:23 -0700 (PDT) Received: from [192.168.1.101] (abyl195.neoplus.adsl.tpnet.pl. [83.9.31.195]) by smtp.gmail.com with ESMTPSA id q30-20020ac2515e000000b004fbad09317csm2074025lfd.189.2023.08.29.13.59.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 13:59:22 -0700 (PDT) From: Konrad Dybcio Date: Tue, 29 Aug 2023 22:59:05 +0200 Subject: [PATCH 2/2] phy: qcom-qmp-combo: initialize PCS_USB registers MIME-Version: 1.0 Message-Id: <20230829-topic-8550_usbphy-v1-2-599ddbfa094a@linaro.org> References: <20230829-topic-8550_usbphy-v1-0-599ddbfa094a@linaro.org> In-Reply-To: <20230829-topic-8550_usbphy-v1-0-599ddbfa094a@linaro.org> To: Andy Gross , Bjorn Andersson , Vinod Koul , Kishon Vijay Abraham I , Abel Vesa , Johan Hovold , Dmitry Baryshkov Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Adrien Thierry X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1693342759; l=1235; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=adVmBzdoCGTsemFqAoQk/FkwFdzWdPC36JGX5NvhpUo=; b=aDox5HcEB7BiDj/xATHHbGSkGblXnbMQljwSM6u6KT9zqxT2CPkjQKRfdRFMeyrXHUXoEa/jb cTlHVJoE3TxA9rPwoIfEsLI77n93TCXC9YiFRSKD/Ji8qAq6PuntL5b X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Currently, PCS_USB registers that have their initialization data in a pcs_usb_tbl table are never initialized. Fix that. Fixes: fc64623637da ("phy: qcom-qmp-combo,usb: add support for separate PCS_USB region") Reported-by: Adrien Thierry Signed-off-by: Konrad Dybcio --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index 843099d314bf..1922b05403ac 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -2555,6 +2555,7 @@ static int qmp_combo_usb_power_on(struct phy *phy) void __iomem *tx2 = qmp->tx2; void __iomem *rx2 = qmp->rx2; void __iomem *pcs = qmp->pcs; + void __iomem *pcs_usb = qmp->pcs_usb; void __iomem *status; unsigned int val; int ret; @@ -2576,6 +2577,9 @@ static int qmp_combo_usb_power_on(struct phy *phy) qmp_combo_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); + if (pcs_usb) + qmp_combo_configure(pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num); + if (cfg->has_pwrdn_delay) usleep_range(10, 20);