From patchwork Wed Aug 30 02:40:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13369907 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BAB09C71153 for ; Wed, 30 Aug 2023 02:40:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wojIy7yBeVx+TW5yNFmStvmrJVafwff6hePRsoV9t5g=; b=Hlc+COs4Ks0Msz tgKcv70AlTFZYjC03ExJ2T3/3FceNfjwTZuoWAuHfJ4Q7sCentL57KYJEIt3t2/hFQVlaM+XmlJ86 fMyNWo8e1Z+8+gXQgNIHY6lulQqQmYYZPGEw/Wr4dfKZMtmmM/sGu9jaaVdTBP+E1a/Szjnh7G0o7 +V+phgY8lNKr4PljQdIMic/4qKXN9j54jOYNsHSNgrQmFcMhmx77hUlZ4FKZup/D1W67YuWunFBpP jHsHNduI9lmD7S63RSMHOFzpRoXewe5SzExCO0evcxgvJsIfmuqSuafouBBQAzxWPat3Gwqlsx26f glqin4kPireO92yc+xgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qbB85-00Cgv4-0n; Wed, 30 Aug 2023 02:40:25 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qbB82-00CgqK-1x for linux-phy@lists.infradead.org; Wed, 30 Aug 2023 02:40:23 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4ff8f2630e3so7974097e87.1 for ; Tue, 29 Aug 2023 19:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693363219; x=1693968019; darn=lists.infradead.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=eftHGQRECzJuXi1OVtNB5hDXhj+Beyk7gIuR4DJasbs=; b=IiM6gMjgBVUv3+fMafd5jdXwd5uZQnw9RiqmGSXWHnonrCWfV5ns8258NJ6MObf/LB z2pUYMIuvAShWcj3zu4PQUpbfRFNx6jKdm+T4Kgo0e22b9jQeAZsXn76d2mvq0VNk7MR s+DmFCRbv0Q/91pSyEC6WMyXCMNALxtCv7SK+d0GJlNpkRS3nmA4GeBBl5Z2944dSioM 4y9O3D7hnTz7nWOkOLF3SJKtgUaMXt4Sde3fZ9RqMEKKkRMmkS8yHK2JMSaa8MUVhp10 vnVz5CjjJmMTfL1x7GPk2DPPLD3mEpga3VSoouyMTFFfr0V7/N+RFAA/4OdAQAUCn4Tb z+9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693363219; x=1693968019; 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=eftHGQRECzJuXi1OVtNB5hDXhj+Beyk7gIuR4DJasbs=; b=Qk7ROCSxydV9sPKCSIoWH/aGLOPRaW9Ns0Fp7UDJDKtWnV8QtriYXwgXuvNFEIlNfj U+BdgSFtP5kZqi2t9ntfGv5QluUrQsgk6dNfPKPJWJ3F9zi13nWQZLi5q7LQk/uNU4lO lS8m0OdYWVkQ0GT84/F8YNub9b0/eyELlVgtlvYn9kfEZXeEysBxdg+fhUoiKUMAdc83 YOGjwO6GW0tqx65OOcGZwNgsc0SEnHglbI9buKazl6p1/fzvjsnPzpHuz2PEiAZKPPY6 AvPv64J9WIEDnHvoH8jzXD4cyls1oPyIef6m7RljhleWd5mo5lnSqE47WB0rEq5g5rz/ prWA== X-Gm-Message-State: AOJu0YzmIzgknD5cPuPRdUIYhHFDSwIPCjuXoBFYSTGQl/mmknyFk80r YJb1E0Bo6YzWIXB1oXrxiKPr3i4i/Oi0Oj5vtUHAOQ== X-Google-Smtp-Source: AGHT+IFHf9gBoE1ACeP5RVIgyVWnmxwTQm1ACDYzoey0sp3f/Y6uJkIWgpkT86PBWwx0PT6aRJeXxQ== X-Received: by 2002:a05:6512:368f:b0:500:bf44:b2b6 with SMTP id d15-20020a056512368f00b00500bf44b2b6mr406324lfs.45.1693363218120; Tue, 29 Aug 2023 19:40:18 -0700 (PDT) Received: from [192.168.1.101] (abyl195.neoplus.adsl.tpnet.pl. [83.9.31.195]) by smtp.gmail.com with ESMTPSA id w7-20020ac254a7000000b004fb99da37e3sm2183878lfk.220.2023.08.29.19.40.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 19:40:17 -0700 (PDT) From: Konrad Dybcio Date: Wed, 30 Aug 2023 04:40:15 +0200 Subject: [PATCH 1/4] dt-bindings: phy: qcom,snps-eusb2-repeater: Add magic tuning overrides MIME-Version: 1.0 Message-Id: <20230830-topic-eusb2_override-v1-1-ab23825385a8@linaro.org> References: <20230830-topic-eusb2_override-v1-0-ab23825385a8@linaro.org> In-Reply-To: <20230830-topic-eusb2_override-v1-0-ab23825385a8@linaro.org> To: Andy Gross , Bjorn Andersson , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Abel Vesa Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1693363215; l=1464; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=gOCoteo3eQFlsbrCmDlbDQsd6KpyGXjafi9HiIGRkBg=; b=I1ZTgaIC2oul/Cky4mzGoprgT3MxHSMek90ddaxpeFmCCCti1/S1gJ/cYPlRgCg7X23/Efw9k oZB5EyI87n3CD7c8+a1pi5LAwKjFZirypeO0ii1ML28JEmvoAHi1ABk X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230829_194022_646459_8BD52B48 X-CRM114-Status: UNSURE ( 8.53 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org The EUSB2 repeater requires some alterations to its init sequence, depending on board design. Add support for making the necessary changes to that sequence to make USB functional on SM8550-based Xperia 1 V. They all have lackluster description due to lack of information. Signed-off-by: Konrad Dybcio --- .../bindings/phy/qcom,snps-eusb2-repeater.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/phy/qcom,snps-eusb2-repeater.yaml b/Documentation/devicetree/bindings/phy/qcom,snps-eusb2-repeater.yaml index 029569d5fcf3..83fd6f936bf9 100644 --- a/Documentation/devicetree/bindings/phy/qcom,snps-eusb2-repeater.yaml +++ b/Documentation/devicetree/bindings/phy/qcom,snps-eusb2-repeater.yaml @@ -32,6 +32,27 @@ properties: vdd3-supply: true + qcom,tune-hsdisc-value: + $ref: /schemas/types.yaml#/definitions/uint8 + description: High-Speed disconnect threshold + minimum: 0 + maximum: 7 + default: 0 + + qcom,tune-iusb2-value: + $ref: /schemas/types.yaml#/definitions/uint8 + description: High-Speed trasmit amplitude + minimum: 0 + maximum: 15 + default: 8 + + qcom,tune-usb2-preem-value: + $ref: /schemas/types.yaml#/definitions/uint8 + description: TX pre-emphasis tuning + minimum: 0 + maximum: 7 + default: 5 + required: - compatible - reg From patchwork Wed Aug 30 02:40:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13369909 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E056EC83F18 for ; Wed, 30 Aug 2023 02:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QKharc35FAk+sSNb96+mJiBf171RYI2GPijVIzEUvJQ=; b=Ft/MpelN0oXP4K rhA57qnXFsTPbnQoY1UeWC+IRaETT6LIxcr6d4NsbfH/RXCGA/BURJKWy1FvoBnGZ/hSiZp/CbbnU SMlOF4BNkq2g9KUf1QrYK8SooT3xzcvi64R/jQLDMhYLFCE97Oai5AFZDYs5tBHUllyXKj54rad+T eAMxPv1hzNNdkTfUSQ6HTcWlEas503P5fF0brCdq8ovfgXelIqubtj/+vouDVOK9lf0nuvM/nY4Mg E+zRPjwFL7bJTqMQKHN9cS7Auu8MULhvXgyj87Mk+BYNrX8CdMjuNM6W9W73LYb1h2+vFG2B6POoL ZyRyJ02vKREqRnA5QyVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qbB87-00CgwL-21; Wed, 30 Aug 2023 02:40:27 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qbB83-00CgqN-0i for linux-phy@lists.infradead.org; Wed, 30 Aug 2023 02:40:24 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2bcb0b973a5so77510151fa.3 for ; Tue, 29 Aug 2023 19:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693363219; x=1693968019; darn=lists.infradead.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=AqhtzcGyFHDluGDjY5bQjlFxQW1yi0cE3p4JZH8FKz0=; b=fJe/i5r1N8pKXCtny7Seq9QETcjDxv+PmPojSTOYSvymq4/WyUjmK5x0F2aLJGuNg+ dVxScNw/27TsNj+K/xo1AIX5mtw78rmkOkz4bMr8q1z69o4hnirop4nqeJ6aDxHtOjN5 0Otsy0PQ6sORrCvtfXDP/ZoO1o6yfUMCoXvo1fKH26OeVSPLB2DoYY60hWUp3QWLRUEf MRAP6/JhHaRi9NL6hrV1lWKibzqXQ2hrrqlGaSdLSInUSsOorUD/9ygLNk84kzfrEQGk tmmou+6XQUICizPo/uEmRuVilLuLUjJP79yPSQkdfo9xAhnaZZIWO+Tniu2fkiQLZeOT Hziw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693363219; x=1693968019; 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=AqhtzcGyFHDluGDjY5bQjlFxQW1yi0cE3p4JZH8FKz0=; b=hNZ892L0dtcCAHQux5cmG+ZD+9TgBOtgkcAwzW4lwhG985pI63ecRSEXGspJMhRgiO /J31GKwOvOsBPb6GeQxYtQims0bhWV5gqr7hCdWFJg2g9Z2MxHFXb3GRWvOmj44T3qJ1 DPBls9IdKIlzu65eBk5D4vwRLEMD2eA+HRUgSwdrjveV9gUDwHR0PExtCtRXXECRQD6X 4WvQsU9ptUt+iidelmadf5PQrrJpFqur7qr6emFwbxuvwA8fzgUigzTtQJ4SsAjeU6vB VcE/oqtBdJVFOdPLJmYNwMvIvy1T6BnojkfGEpRm+shYFVP52vNNHMpqTmnZAWMJ/Bim /Q3w== X-Gm-Message-State: AOJu0YwCfmkswrqAIa1mk9sfTkSuDLa6UuLC7JdcD9GI8Whr8A3S8CgE X2lhOds/uGsNi5gQigNVMk4Liw== X-Google-Smtp-Source: AGHT+IFpBDe1bzQ/cK5vCouexaMPmERPp/g75Tb3Qz47U7S6slLNMI13E0TDLktmOPGAUr6ny71NYg== X-Received: by 2002:a19:2d57:0:b0:4fb:7675:1c16 with SMTP id t23-20020a192d57000000b004fb76751c16mr428572lft.49.1693363219478; Tue, 29 Aug 2023 19:40:19 -0700 (PDT) Received: from [192.168.1.101] (abyl195.neoplus.adsl.tpnet.pl. [83.9.31.195]) by smtp.gmail.com with ESMTPSA id w7-20020ac254a7000000b004fb99da37e3sm2183878lfk.220.2023.08.29.19.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 19:40:19 -0700 (PDT) From: Konrad Dybcio Date: Wed, 30 Aug 2023 04:40:16 +0200 Subject: [PATCH 2/4] phy: qualcomm: phy-qcom-eusb2-repeater: Use regmap_fields MIME-Version: 1.0 Message-Id: <20230830-topic-eusb2_override-v1-2-ab23825385a8@linaro.org> References: <20230830-topic-eusb2_override-v1-0-ab23825385a8@linaro.org> In-Reply-To: <20230830-topic-eusb2_override-v1-0-ab23825385a8@linaro.org> To: Andy Gross , Bjorn Andersson , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Abel Vesa Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1693363215; l=6150; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=LovaKfaqbkXiJ4az1PcPQZkH3FJdcJGz/pvW4OALguE=; b=a1geA4S8J2PTY4afb36vvk6SABGZSBl3BzJ58jL28SAunNSUJTSIThBvWtY/k3frdhxgqX9Er 6Pzctxcx9efBmMgVVRoGbJildXxxJjFaq9yznlfbyMmi1UDDIbYyDdr X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230829_194023_264333_BC1EC073 X-CRM114-Status: GOOD ( 18.45 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Switch to regmap_fields, so that the values written into registers are sanitized by their explicit sizes and the different registers are structured in an iterable object to make external changes to the init sequence simpler. Signed-off-by: Konrad Dybcio --- drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c | 91 +++++++++++++++++--------- 1 file changed, 61 insertions(+), 30 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c index 52c275fbb2a1..7561da01e633 100644 --- a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c +++ b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c @@ -28,14 +28,42 @@ #define EUSB2_TUNE_SQUELCH_U 0x54 #define EUSB2_TUNE_USB2_PREEM 0x57 -#define QCOM_EUSB2_REPEATER_INIT_CFG(o, v) \ +#define QCOM_EUSB2_REPEATER_INIT_CFG(r, v) \ { \ - .offset = o, \ + .reg = r, \ .val = v, \ } +enum reg_fields { + F_TUNE_USB2_PREEM, + F_TUNE_SQUELCH_U, + F_TUNE_IUSB2, + F_NUM_TUNE_FIELDS, + + F_FORCE_VAL_5 = F_NUM_TUNE_FIELDS, + F_FORCE_EN_5, + + F_EN_CTL1, + + F_RPTR_STATUS, + F_NUM_FIELDS, +}; + +static struct reg_field eusb2_repeater_tune_reg_fields[F_NUM_FIELDS] = { + [F_TUNE_USB2_PREEM] = REG_FIELD(EUSB2_TUNE_USB2_PREEM, 0, 2), + [F_TUNE_SQUELCH_U] = REG_FIELD(EUSB2_TUNE_SQUELCH_U, 0, 2), + [F_TUNE_IUSB2] = REG_FIELD(EUSB2_TUNE_IUSB2, 0, 3), + + [F_FORCE_VAL_5] = REG_FIELD(EUSB2_FORCE_VAL_5, 0, 7), + [F_FORCE_EN_5] = REG_FIELD(EUSB2_FORCE_EN_5, 0, 7), + + [F_EN_CTL1] = REG_FIELD(EUSB2_EN_CTL1, 0, 7), + + [F_RPTR_STATUS] = REG_FIELD(EUSB2_RPTR_STATUS, 0, 7), +}; + struct eusb2_repeater_init_tbl { - unsigned int offset; + unsigned int reg; unsigned int val; }; @@ -48,11 +76,10 @@ struct eusb2_repeater_cfg { struct eusb2_repeater { struct device *dev; - struct regmap *regmap; + struct regmap_field *regs[F_NUM_FIELDS]; struct phy *phy; struct regulator_bulk_data *vregs; const struct eusb2_repeater_cfg *cfg; - u16 base; enum phy_mode mode; }; @@ -61,9 +88,9 @@ static const char * const pm8550b_vreg_l[] = { }; static const struct eusb2_repeater_init_tbl pm8550b_init_tbl[] = { - QCOM_EUSB2_REPEATER_INIT_CFG(EUSB2_TUNE_IUSB2, 0x8), - QCOM_EUSB2_REPEATER_INIT_CFG(EUSB2_TUNE_SQUELCH_U, 0x3), - QCOM_EUSB2_REPEATER_INIT_CFG(EUSB2_TUNE_USB2_PREEM, 0x5), + QCOM_EUSB2_REPEATER_INIT_CFG(F_TUNE_IUSB2, 0x8), + QCOM_EUSB2_REPEATER_INIT_CFG(F_TUNE_SQUELCH_U, 0x3), + QCOM_EUSB2_REPEATER_INIT_CFG(F_TUNE_USB2_PREEM, 0x5), }; static const struct eusb2_repeater_cfg pm8550b_eusb2_cfg = { @@ -93,7 +120,6 @@ static int eusb2_repeater_init(struct phy *phy) { struct eusb2_repeater *rptr = phy_get_drvdata(phy); const struct eusb2_repeater_init_tbl *init_tbl = rptr->cfg->init_tbl; - int num = rptr->cfg->init_tbl_num; u32 val; int ret; int i; @@ -102,17 +128,14 @@ static int eusb2_repeater_init(struct phy *phy) if (ret) return ret; - regmap_update_bits(rptr->regmap, rptr->base + EUSB2_EN_CTL1, - EUSB2_RPTR_EN, EUSB2_RPTR_EN); + regmap_field_update_bits(rptr->regs[F_EN_CTL1], EUSB2_RPTR_EN, EUSB2_RPTR_EN); - for (i = 0; i < num; i++) - regmap_update_bits(rptr->regmap, - rptr->base + init_tbl[i].offset, - init_tbl[i].val, init_tbl[i].val); + for (i = 0; i < rptr->cfg->init_tbl_num; i++) + regmap_field_update_bits(rptr->regs[init_tbl[i].reg], + init_tbl[i].val, init_tbl[i].val); - ret = regmap_read_poll_timeout(rptr->regmap, - rptr->base + EUSB2_RPTR_STATUS, val, - val & RPTR_OK, 10, 5); + ret = regmap_field_read_poll_timeout(rptr->regs[F_RPTR_STATUS], + val, val & RPTR_OK, 10, 5); if (ret) dev_err(rptr->dev, "initialization timed-out\n"); @@ -131,10 +154,10 @@ static int eusb2_repeater_set_mode(struct phy *phy, * per eUSB 1.2 Spec. Below implement software workaround until * PHY and controller is fixing seen observation. */ - regmap_update_bits(rptr->regmap, rptr->base + EUSB2_FORCE_EN_5, - F_CLK_19P2M_EN, F_CLK_19P2M_EN); - regmap_update_bits(rptr->regmap, rptr->base + EUSB2_FORCE_VAL_5, - V_CLK_19P2M_EN, V_CLK_19P2M_EN); + regmap_field_update_bits(rptr->regs[F_FORCE_EN_5], + F_CLK_19P2M_EN, F_CLK_19P2M_EN); + regmap_field_update_bits(rptr->regs[F_FORCE_VAL_5], + V_CLK_19P2M_EN, V_CLK_19P2M_EN); break; case PHY_MODE_USB_DEVICE: /* @@ -143,10 +166,10 @@ static int eusb2_repeater_set_mode(struct phy *phy, * repeater doesn't clear previous value due to shared * regulators (say host <-> device mode switch). */ - regmap_update_bits(rptr->regmap, rptr->base + EUSB2_FORCE_EN_5, - F_CLK_19P2M_EN, 0); - regmap_update_bits(rptr->regmap, rptr->base + EUSB2_FORCE_VAL_5, - V_CLK_19P2M_EN, 0); + regmap_field_update_bits(rptr->regs[F_FORCE_EN_5], + F_CLK_19P2M_EN, 0); + regmap_field_update_bits(rptr->regs[F_FORCE_VAL_5], + V_CLK_19P2M_EN, 0); break; default: return -EINVAL; @@ -175,8 +198,9 @@ static int eusb2_repeater_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct phy_provider *phy_provider; struct device_node *np = dev->of_node; + struct regmap *regmap; + int i, ret; u32 res; - int ret; rptr = devm_kzalloc(dev, sizeof(*rptr), GFP_KERNEL); if (!rptr) @@ -189,15 +213,22 @@ static int eusb2_repeater_probe(struct platform_device *pdev) if (!rptr->cfg) return -EINVAL; - rptr->regmap = dev_get_regmap(dev->parent, NULL); - if (!rptr->regmap) + regmap = dev_get_regmap(dev->parent, NULL); + if (!regmap) return -ENODEV; ret = of_property_read_u32(np, "reg", &res); if (ret < 0) return ret; - rptr->base = res; + for (i = 0; i < F_NUM_FIELDS; i++) + eusb2_repeater_tune_reg_fields[i].reg += res; + + ret = devm_regmap_field_bulk_alloc(dev, regmap, rptr->regs, + eusb2_repeater_tune_reg_fields, + F_NUM_FIELDS); + if (ret) + return ret; ret = eusb2_repeater_init_vregs(rptr); if (ret < 0) { From patchwork Wed Aug 30 02:40:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13369910 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77360C6FA8F for ; Wed, 30 Aug 2023 02:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=66gWPJNoH4F6KWrwvjATBgTPFJ2/IpvfqIiFpI/KTT0=; b=SG804nVciGQi7E e1TJmZ1F5M6CjK03+RduFamu6phHJLrXngeXTi9qeRsabffToeGQnD/7z6VOmIpbFYfoaw6lUhOkw d70ylemSCw+/zub6sjBhwPWDBHaxotBzZ8OZ5Jok9sCLM4WTgF9m/ZHl4iYedK9NGlgWPoboRreJJ evC058dWoSf7fxvirjOKGYMS8DxJX3f/PRuaRMudUFnwEgo2kKYMkwIACq+L4UZbLTTFh6nUBfC4t yPDpo0per3mW9mPThd08uNyZnjxyzbXohJsWnKPsm263RVfDYyCZW/NQDTTCU3YJxDT02TDhXWNrW UbljFwAJHE9aUaW9F66Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qbB88-00Cgx5-0e; Wed, 30 Aug 2023 02:40:28 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qbB84-00Cgri-1T for linux-phy@lists.infradead.org; Wed, 30 Aug 2023 02:40:26 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4ffa248263cso7943363e87.2 for ; Tue, 29 Aug 2023 19:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693363220; x=1693968020; darn=lists.infradead.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=C4cHSwUyFzEktn3DghWL2c38zb9i5jrhA53otXSIPl0=; b=XFNGoYSZAKQxb6ZqfbNoMkulWYmnwmER3rGHCyK2RbLuHHnb/N/TQknvEBmy8DUKAi 8ksDhXSGD/zNKinEFiAzyiFfHEEIMyPwlp035bTmmkkxWJfmu8dY7O9gm53l3jltp2ad zapiRHMscrpNKIV9UVYQaJ4tHdIZk1W+j0P3HQfDVJwDzdWmij0YTH26Qw1mOh5Zc6sl K6t3hrBWEz+xS4OQVj0oPj2Qb62Y6Pe2B6Qt6Fr5HgJAxG6m6cBuV+nBOAMBm81YjdoM B1iPugLHde8uZDMXGASLWnWaTNkTxNBiPXSkRUZp6/0T7ZX+zpi36opdVfy4vUKV1rsg FwqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693363220; x=1693968020; 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=C4cHSwUyFzEktn3DghWL2c38zb9i5jrhA53otXSIPl0=; b=PezF/yyhQvqOI4k+NHfJ+dojKq2FCiHnBnhbATLMnDB4VpeZlD/7EcPkIqMTp9M9UY js0n+lopO3OMt4325H5PYn/aLod9TRiOCdWp+qCiU3sFJonQSd9Z9qpVfQL0Jtfhn6xW C1p9YRExCZMSgHPlyBixuhV4wD0X2b5T17CZa11I70iBm+jAq2/xe+t907aFhJ4I4hgO A8uqdcSvpIEz52/Ni6R2ClAriYUoeWP6uFXILxWxRasw8IJOqL1PJTSp43wAQiySS/2I l/hn/xWHYOmqAux9u+9ORVvBN0wQ9KQw4DKsAuLTP2viH8mXONXhWToYGrhQ+zgEGVFu L2ow== X-Gm-Message-State: AOJu0YxR54fmGKldzDarBmUbN4cdA3AUIDNVbONiJ5xUguXmr8RwPY5m YChUl36JhZ9xuAS8pjIrD5WNhYFDPtUPVDmDlDw7NA== X-Google-Smtp-Source: AGHT+IHBkg4b6ijOZVk1MC+rXi+R32uS7DM4uSAUqboM9an2pgttvClkrCz3fzYKhKRMPaEc7qH+jw== X-Received: by 2002:a19:4f45:0:b0:4fe:a2c:24b0 with SMTP id a5-20020a194f45000000b004fe0a2c24b0mr406115lfk.26.1693363220722; Tue, 29 Aug 2023 19:40:20 -0700 (PDT) Received: from [192.168.1.101] (abyl195.neoplus.adsl.tpnet.pl. [83.9.31.195]) by smtp.gmail.com with ESMTPSA id w7-20020ac254a7000000b004fb99da37e3sm2183878lfk.220.2023.08.29.19.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 19:40:20 -0700 (PDT) From: Konrad Dybcio Date: Wed, 30 Aug 2023 04:40:17 +0200 Subject: [PATCH 3/4] phy: qualcomm: phy-qcom-eusb2-repeater: Zero out untouched tuning regs MIME-Version: 1.0 Message-Id: <20230830-topic-eusb2_override-v1-3-ab23825385a8@linaro.org> References: <20230830-topic-eusb2_override-v1-0-ab23825385a8@linaro.org> In-Reply-To: <20230830-topic-eusb2_override-v1-0-ab23825385a8@linaro.org> To: Andy Gross , Bjorn Andersson , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Abel Vesa Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1693363215; l=4436; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=clg99SRrpP7Rr9sq765kCJ32qSeqb/MC63Wr0fr+Fsk=; b=lkPO+s4HhubGVZzqV8mpoo0iahoW2A7Wd+geW/BccLi+Ts93n5LWCzvlqOlLa5f7MJhXNb937 6hFpHSz+XXeArI0DUBNJ6BlIp+w1vKdKDVcz8SlKnJP+eXu0iAmwkau X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230829_194024_492577_0B10480C X-CRM114-Status: GOOD ( 13.51 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org The vendor kernel zeroes out all tuning data outside the init sequence as part of initialization. Follow suit to avoid UB. Signed-off-by: Konrad Dybcio --- drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c | 49 ++++++++++++++++++-------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c index 7561da01e633..645f0e95703a 100644 --- a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c +++ b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c @@ -24,9 +24,18 @@ #define EUSB2_FORCE_VAL_5 0xeD #define V_CLK_19P2M_EN BIT(6) +#define EUSB2_TUNE_USB2_CROSSOVER 0x50 #define EUSB2_TUNE_IUSB2 0x51 +#define EUSB2_TUNE_RES_FSDIF 0x52 +#define EUSB2_TUNE_HSDISC 0x53 #define EUSB2_TUNE_SQUELCH_U 0x54 +#define EUSB2_TUNE_USB2_SLEW 0x55 +#define EUSB2_TUNE_USB2_EQU 0x56 #define EUSB2_TUNE_USB2_PREEM 0x57 +#define EUSB2_TUNE_USB2_HS_COMP_CUR 0x58 +#define EUSB2_TUNE_EUSB_SLEW 0x59 +#define EUSB2_TUNE_EUSB_EQU 0x5A +#define EUSB2_TUNE_EUSB_HS_COMP_CUR 0x5B #define QCOM_EUSB2_REPEATER_INIT_CFG(r, v) \ { \ @@ -35,9 +44,18 @@ } enum reg_fields { + F_TUNE_EUSB_HS_COMP_CUR, + F_TUNE_EUSB_EQU, + F_TUNE_EUSB_SLEW, + F_TUNE_USB2_HS_COMP_CUR, F_TUNE_USB2_PREEM, + F_TUNE_USB2_EQU, + F_TUNE_USB2_SLEW, F_TUNE_SQUELCH_U, + F_TUNE_HSDISC, + F_TUNE_RES_FSDIF, F_TUNE_IUSB2, + F_TUNE_USB2_CROSSOVER, F_NUM_TUNE_FIELDS, F_FORCE_VAL_5 = F_NUM_TUNE_FIELDS, @@ -50,9 +68,18 @@ enum reg_fields { }; static struct reg_field eusb2_repeater_tune_reg_fields[F_NUM_FIELDS] = { + [F_TUNE_EUSB_HS_COMP_CUR] = REG_FIELD(EUSB2_TUNE_EUSB_HS_COMP_CUR, 0, 1), + [F_TUNE_EUSB_EQU] = REG_FIELD(EUSB2_TUNE_EUSB_EQU, 0, 1), + [F_TUNE_EUSB_SLEW] = REG_FIELD(EUSB2_TUNE_EUSB_SLEW, 0, 1), + [F_TUNE_USB2_HS_COMP_CUR] = REG_FIELD(EUSB2_TUNE_USB2_HS_COMP_CUR, 0, 1), [F_TUNE_USB2_PREEM] = REG_FIELD(EUSB2_TUNE_USB2_PREEM, 0, 2), + [F_TUNE_USB2_EQU] = REG_FIELD(EUSB2_TUNE_USB2_EQU, 0, 1), + [F_TUNE_USB2_SLEW] = REG_FIELD(EUSB2_TUNE_USB2_SLEW, 0, 1), [F_TUNE_SQUELCH_U] = REG_FIELD(EUSB2_TUNE_SQUELCH_U, 0, 2), + [F_TUNE_HSDISC] = REG_FIELD(EUSB2_TUNE_HSDISC, 0, 2), + [F_TUNE_RES_FSDIF] = REG_FIELD(EUSB2_TUNE_RES_FSDIF, 0, 2), [F_TUNE_IUSB2] = REG_FIELD(EUSB2_TUNE_IUSB2, 0, 3), + [F_TUNE_USB2_CROSSOVER] = REG_FIELD(EUSB2_TUNE_USB2_CROSSOVER, 0, 2), [F_FORCE_VAL_5] = REG_FIELD(EUSB2_FORCE_VAL_5, 0, 7), [F_FORCE_EN_5] = REG_FIELD(EUSB2_FORCE_EN_5, 0, 7), @@ -62,13 +89,8 @@ static struct reg_field eusb2_repeater_tune_reg_fields[F_NUM_FIELDS] = { [F_RPTR_STATUS] = REG_FIELD(EUSB2_RPTR_STATUS, 0, 7), }; -struct eusb2_repeater_init_tbl { - unsigned int reg; - unsigned int val; -}; - struct eusb2_repeater_cfg { - const struct eusb2_repeater_init_tbl *init_tbl; + const u32 *init_tbl; int init_tbl_num; const char * const *vreg_list; int num_vregs; @@ -87,10 +109,10 @@ static const char * const pm8550b_vreg_l[] = { "vdd18", "vdd3", }; -static const struct eusb2_repeater_init_tbl pm8550b_init_tbl[] = { - QCOM_EUSB2_REPEATER_INIT_CFG(F_TUNE_IUSB2, 0x8), - QCOM_EUSB2_REPEATER_INIT_CFG(F_TUNE_SQUELCH_U, 0x3), - QCOM_EUSB2_REPEATER_INIT_CFG(F_TUNE_USB2_PREEM, 0x5), +static const u32 pm8550b_init_tbl[F_NUM_TUNE_FIELDS] = { + [F_TUNE_IUSB2] = 0x8, + [F_TUNE_SQUELCH_U] = 0x3, + [F_TUNE_USB2_PREEM] = 0x5, }; static const struct eusb2_repeater_cfg pm8550b_eusb2_cfg = { @@ -119,7 +141,7 @@ static int eusb2_repeater_init_vregs(struct eusb2_repeater *rptr) static int eusb2_repeater_init(struct phy *phy) { struct eusb2_repeater *rptr = phy_get_drvdata(phy); - const struct eusb2_repeater_init_tbl *init_tbl = rptr->cfg->init_tbl; + const u32 *init_tbl = rptr->cfg->init_tbl; u32 val; int ret; int i; @@ -130,9 +152,8 @@ static int eusb2_repeater_init(struct phy *phy) regmap_field_update_bits(rptr->regs[F_EN_CTL1], EUSB2_RPTR_EN, EUSB2_RPTR_EN); - for (i = 0; i < rptr->cfg->init_tbl_num; i++) - regmap_field_update_bits(rptr->regs[init_tbl[i].reg], - init_tbl[i].val, init_tbl[i].val); + for (i = 0; i < F_NUM_TUNE_FIELDS; i++) + regmap_field_update_bits(rptr->regs[i], init_tbl[i], init_tbl[i]); ret = regmap_field_read_poll_timeout(rptr->regs[F_RPTR_STATUS], val, val & RPTR_OK, 10, 5); From patchwork Wed Aug 30 02:40:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13369908 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3137CC83F16 for ; Wed, 30 Aug 2023 02:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KC85e9Nu6xr7vvYdFE7UwIOMP9ypYp7VUTsjTr8ECCw=; b=UDYrIpaJBGlzjp 45s3cf7u4ro+mOM64CubwqbBXC7eZA8LVdAWn9Eimb2/mPj8jUy43CduOsPK6Ja+oNekJ1NKW4jfG TFoMaKbhhDq/3iHBiH9ePUA4hacByPUYsCyygo+m6eshS9JjTgROGjdkAkrk3fuABWss+NecPc8sA vFU1BrvKYBUrRwuL6x77eIz+KWbrfywKZLNDBS3wQUAg/gcPVPz4FpSMQ+A6h/ykBQ6BKboliZuHo bZK86qowWurxIwo1qsHzTbceAiYNZaOi8eO4tV2JcpgsJJ5p8gRjV+tItp2Z1oSDeqs+VC+MR0aNS Je8Szj86TJ67JxyeQL6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qbB87-00Cgwg-2w; Wed, 30 Aug 2023 02:40:27 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qbB83-00CgsC-1M for linux-phy@lists.infradead.org; Wed, 30 Aug 2023 02:40:25 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-50078eba7afso8179098e87.0 for ; Tue, 29 Aug 2023 19:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693363222; x=1693968022; darn=lists.infradead.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=u79yO0iAhOgHSkdtiLEgJV1fUj3/h29d83dbFcGVhBU=; b=G7/c9VIK5MKG4EAxim+pAi1jl3s+7kv8+t6J9AJdGHmapl533t+t9pPp1M86yAjBil E884kiElteT4W6iUEV1YfNEewjq7hi8w3eXJx4rOkbtWHCWEuikiksbJbolWIdNy5qtK iHB+8z/eFiEUb+k7qAOUhYWA4LYxHLJJhD6tY8niYr5TXzpjWsWk7Z4+/CXwsmFfGRyO V03GQ8xykujN7cUVHd8FAGLR1en5v0pYBWTn1T3YWT+KfezRbybhmafbaxb49OJb1Db6 9FsPoXlvO0av7iNNp5WZStlBXmxpQ8gNw6AjDbdbEMhBbg3gdhvN0TBpnpQz/HbGaiS6 5w1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693363222; x=1693968022; 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=u79yO0iAhOgHSkdtiLEgJV1fUj3/h29d83dbFcGVhBU=; b=e+wHC5xEoDPPzgBHCe2SsGh6+lGfQa8dzyOg2eFSG6K+tM2COhmhN/W+d1YgrOwn8H A0987IvPVzA7WciydSto8rgf4n7oHZKqnHzFMrwVtcfnLuwA/Rjt5O1QMZJNqIjkTxe9 wBniRiljjUoOh7CwYBP5PgA81VgLqWqfE2lhRMilmtwSWETumSGg/D0hSOzDNQqTcim8 oIe/bfmfoCpk070GklWeWH0YFw9grG72vOuX73Q52yv64kUqhlBs3BDC9dV2/V5H1+AD wim1D1cKRiHOQnb7WFGKRXas7PREZ6TSBQPSlVzatyceabT0pDE103F/J+O0Mz8grMoZ PWsg== X-Gm-Message-State: AOJu0YzCMk2esz8YdiZsk/vorH5vqUudEDzDhVh24yZwF8PmpxqhAkYf f4cACjJm7TvQmzITd2wfA9jG0w== X-Google-Smtp-Source: AGHT+IEB+Pvy4SQ9xZVdKt+EmXsnpVvha1l5vFdek6iZ3eZULbMZNYOs++suiQW5lY4y3P0QFRWZaQ== X-Received: by 2002:a05:6512:312b:b0:500:a0a3:80ff with SMTP id p11-20020a056512312b00b00500a0a380ffmr445095lfd.58.1693363221890; Tue, 29 Aug 2023 19:40:21 -0700 (PDT) Received: from [192.168.1.101] (abyl195.neoplus.adsl.tpnet.pl. [83.9.31.195]) by smtp.gmail.com with ESMTPSA id w7-20020ac254a7000000b004fb99da37e3sm2183878lfk.220.2023.08.29.19.40.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 19:40:21 -0700 (PDT) From: Konrad Dybcio Date: Wed, 30 Aug 2023 04:40:18 +0200 Subject: [PATCH 4/4] phy: qualcomm: phy-qcom-eusb2-repeater: Add tuning overrides MIME-Version: 1.0 Message-Id: <20230830-topic-eusb2_override-v1-4-ab23825385a8@linaro.org> References: <20230830-topic-eusb2_override-v1-0-ab23825385a8@linaro.org> In-Reply-To: <20230830-topic-eusb2_override-v1-0-ab23825385a8@linaro.org> To: Andy Gross , Bjorn Andersson , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Abel Vesa Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1693363215; l=1714; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=NiPnqK52QKHkd/CcD5h/xTEyUsqIlLXa328usvhRCnU=; b=VOEa0hyyG8UbttF1hLRne2t5QpVGEd7PBgEJAs3wp6uAI0TP1KnT9BEe4A+kAXPL1NCFnQmTd /cC2j3wCQ5fA7z1vShBb/7d6X7rOXpxgi457n+zuW2LVAKcm2t95ufT X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230829_194023_459989_723F7289 X-CRM114-Status: GOOD ( 11.74 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org There are devices in the wild, like the Sony Xperia 1 V that *require* different tuning than the base design for USB to work. Add support for overriding the necessary tuning values. Signed-off-by: Konrad Dybcio --- drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c index 645f0e95703a..53e10feb16a1 100644 --- a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c +++ b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c @@ -141,7 +141,9 @@ static int eusb2_repeater_init_vregs(struct eusb2_repeater *rptr) static int eusb2_repeater_init(struct phy *phy) { struct eusb2_repeater *rptr = phy_get_drvdata(phy); - const u32 *init_tbl = rptr->cfg->init_tbl; + struct device_node *np = rptr->dev->of_node; + u32 init_tbl[F_NUM_TUNE_FIELDS] = { 0 }; + u8 override; u32 val; int ret; int i; @@ -152,6 +154,17 @@ static int eusb2_repeater_init(struct phy *phy) regmap_field_update_bits(rptr->regs[F_EN_CTL1], EUSB2_RPTR_EN, EUSB2_RPTR_EN); + memcpy(init_tbl, rptr->cfg->init_tbl, sizeof(init_tbl)); + + if (!of_property_read_u8(np, "qcom,tune-iusb2-value", &override)) + init_tbl[F_TUNE_IUSB2] = override; + + if (!of_property_read_u8(np, "qcom,tune-hsdisc-value", &override)) + init_tbl[F_TUNE_HSDISC] = override; + + if (!of_property_read_u8(np, "qcom,tune-usb2-preem-value", &override)) + init_tbl[F_TUNE_USB2_PREEM] = override; + for (i = 0; i < F_NUM_TUNE_FIELDS; i++) regmap_field_update_bits(rptr->regs[i], init_tbl[i], init_tbl[i]);