From patchwork Wed Sep 13 09:53:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 138939 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1216370vqx; Wed, 13 Sep 2023 09:45:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG57yY0/fh3nz8Whl97TKPDGi3ttvv0b6soryQZewBSH9+8aRUJm8AaBPpbi7sulDBd+qS2 X-Received: by 2002:a05:6a21:2702:b0:14d:4126:b293 with SMTP id rm2-20020a056a21270200b0014d4126b293mr2028897pzb.56.1694623525361; Wed, 13 Sep 2023 09:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623525; cv=none; d=google.com; s=arc-20160816; b=o10M6Y44VhraqBB9kYMcjTEidCNN318JmQgh0hurMTItQbExYx9ENAB2ZreBkOZCnO E0Z7JxediQBMii9M+DFnW80RE4m0S8dr8N3peKpf15dxtAyeuSZux1omVkb7rVrLO2ji XTh+X4hS0eM1y5x+G9nnxl/zWDDKJ7TsmshjQapvK1QOYHHR+bj97h1MFhLxJT5m0BJv 0r5Vm2dtc6uCIhJPRkQjgQk+BcU8Dy3LRxygj6Hid4o1gWV1T6ZBVqJGbXqLIDW1HspD IdklaIVQwi53SPHHKnc9erO28oc3ARlbP8S39cot0EvhPn/wq6COy123y+hOKifs/MT4 N8sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=bGEWNaFOSGbgLmGphSZoYFcO8R5kpnOWxma4oPpmrkM=; fh=bjGNk7INdi7ghZ3YzwEfvVQ70abLcRJWXpQgSHZ4Du8=; b=TxyU1DzxitPCxSBc4Vm9u+polp2/FfyT769ctkp+aATYiewH0FxoCHjbqwKQvJrU/D OoEQcGz2Qcr8Fj2uoZdT/zh2RRckJJOuUrpW9XPBIe8MWKY7uF1QtA7Q3kYfdnMJWLzw HxLoBF+a64TSA1PHKGlKBiEgwM7EHVyGyIRmT9H8NtZk4tRgX6fgErbQKghkNE9qCbmq BJpiiLBmdiD+wiQsDlAsMhztMnzmvmBUxzBzQB868lS95W71uBrHW66iN7WM4t+6ugCy CnGzEEOLoGsUURVJehLW9jMA056CYfRG7c5Cd92o3hAXxLb5GrwQyJfkrOTlTpy1t4Mc ECbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y0rqKamB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id u17-20020a62ed11000000b0068be710ee94si3618664pfh.394.2023.09.13.09.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:45:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y0rqKamB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id DD41480F9BDC; Wed, 13 Sep 2023 02:54:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239510AbjIMJyM (ORCPT + 36 others); Wed, 13 Sep 2023 05:54:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239477AbjIMJyF (ORCPT ); Wed, 13 Sep 2023 05:54:05 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 530F61BEC for ; Wed, 13 Sep 2023 02:54:01 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2bf5bf33bcdso106330471fa.0 for ; Wed, 13 Sep 2023 02:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694598839; x=1695203639; 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=bGEWNaFOSGbgLmGphSZoYFcO8R5kpnOWxma4oPpmrkM=; b=Y0rqKamB+0p5b5AijOQbmrkJsDGgm731hDVScfGpt/C0RvnbsfPYKUTYqRpRiHxy5b G7fK5YG608PoM/o0q0J+nxOLYwN3Xo9d7na95hEw2y/G+p+aSFtQgyvn+PsCn98zrSaz OIuqX6+AQ44EZKsMggMDl5ZqgYILp8lj5ZX/biucnyK1h/LyU/p8HN9nnHqPWBz9ZWve A59yd6Q2K2W37/4ZRjKLD/dM2UZIcHiHYBOmNRGnntn6pnc79c/wLIYbNoKHCzVRZqMO XjtuB5yqyDTCLNs6fsA8CJfS8MS8Qi7acyVv/4hIEbeQ5oa7H+CZZt8El+HpdtpTzvmp ZcUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694598839; x=1695203639; 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=bGEWNaFOSGbgLmGphSZoYFcO8R5kpnOWxma4oPpmrkM=; b=EVEWCc2232lZsrtU6CYm8qP1SuXkIKNvgq9JIE8DYOsucRikSnV6T1r5NR9IOFhhzq 5GpDd181z6Oj5RSABR90OcXMec1aPXbZfVXK/KL+Ji0ARjzng4eKXwo1LJKtyMLRCtI3 k23S1srsw6yMrw/FZOxw9H6R0ih1lshR2jH0Dauh1F2R9esypF0N5K+sNd8yhtJyiSs6 WXQOlNsfjAeTL7+x/wxgSflFr0PJEfq//q9YMJ+gYpgVoqeEtT/BzFBhzGArFIt8lAFV wLNH2wQL3NkeaEl9pPVbt4A86ff/+k4awDJe/PO03pIg+ZMh69k0bN5EJlN6BxQ9SQnD LUmA== X-Gm-Message-State: AOJu0YwVcGQ5IPuNjAxm+5XFQuyKbgvcGshp4EijRjOiqHwyUN2GYD3R t2s+VwselrF6anOSvsVovtj/Tg== X-Received: by 2002:a2e:9806:0:b0:2b9:e6a0:5c3a with SMTP id a6-20020a2e9806000000b002b9e6a05c3amr1705981ljj.48.1694598839540; Wed, 13 Sep 2023 02:53:59 -0700 (PDT) Received: from [10.167.154.1] (178235177106.dynamic-4-waw-k-1-1-0.vectranet.pl. [178.235.177.106]) by smtp.gmail.com with ESMTPSA id l21-20020a170906939500b00985ed2f1584sm8092669ejx.187.2023.09.13.02.53.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 02:53:59 -0700 (PDT) From: Konrad Dybcio Date: Wed, 13 Sep 2023 11:53:23 +0200 Subject: [PATCH v2 1/4] dt-bindings: phy: qcom,snps-eusb2-repeater: Add magic tuning overrides MIME-Version: 1.0 Message-Id: <20230830-topic-eusb2_override-v2-1-7d8c893d93f6@linaro.org> References: <20230830-topic-eusb2_override-v2-0-7d8c893d93f6@linaro.org> In-Reply-To: <20230830-topic-eusb2_override-v2-0-7d8c893d93f6@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=1694598835; l=1475; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=+WkmKOaL4o5Pf6bG2lB645yeG0HwBKcy91tPmktunQA=; b=Ma2LEKDh/8hk+rsvOx7vD/eD/ZV5DGMbX+SL8VQxrsc3O3sKPGbAoG7NjjqSM31BPA4Bth27J GG9ZG6Qx8DuD2gA7zYTmHwQrUqRI6EMbl/lzO269iELzs75JLwQRn/9 X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:54:22 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941557734880497 X-GMAIL-MSGID: 1776941557734880497 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 Acked-by: Rob Herring --- .../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..24c733c10e0e 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-usb2-disc-thres: + $ref: /schemas/types.yaml#/definitions/uint8 + description: High-Speed disconnect threshold + minimum: 0 + maximum: 7 + default: 0 + + qcom,tune-usb2-amplitude: + $ref: /schemas/types.yaml#/definitions/uint8 + description: High-Speed trasmit amplitude + minimum: 0 + maximum: 15 + default: 8 + + qcom,tune-usb2-preem: + $ref: /schemas/types.yaml#/definitions/uint8 + description: High-Speed TX pre-emphasis tuning + minimum: 0 + maximum: 7 + default: 5 + required: - compatible - reg From patchwork Wed Sep 13 09:53:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 138859 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1125277vqx; Wed, 13 Sep 2023 07:27:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHD+LpWgZH8E0NUT+PwdnJDScY+bpk9VR8Ia9SamdtBnpTKoXfmaK9kQahZIFCqg3aldI1Z X-Received: by 2002:a05:6a00:24d4:b0:68e:351b:15b9 with SMTP id d20-20020a056a0024d400b0068e351b15b9mr3915004pfv.4.1694615252122; Wed, 13 Sep 2023 07:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694615252; cv=none; d=google.com; s=arc-20160816; b=G3nkm7D1WW64E47lCc0kw6UD199Iei3J0vKAAa6yHl3rhHiwj/vnLOi5HT35S/7zD8 pTuqn1uWgA/NWEai9nx60pZ8P/ER8/kYMKlzEmIdcj7h/slXz8oewjCMVr0BpYQSSt9q 5xCSrvq3hF2ISyZhcX7t0t+gqgxUTDebHRTFuAEVlhqMHYTAGBjFEY1Nkc6Qodwz59+e h4vxWjC6ay4xY7Xzwoe8dyiyYTyjKmLUXp8jPiaBFhX/cnLYuBf64xllpICLu9W7aRzn xv9ojEpYNwIH27ffWUdgcnAi5/zmQrlhdjH5g8euSGRgQzzNImJxU+8hZ08lF3pbu/4B 8Cfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=AqhtzcGyFHDluGDjY5bQjlFxQW1yi0cE3p4JZH8FKz0=; fh=bjGNk7INdi7ghZ3YzwEfvVQ70abLcRJWXpQgSHZ4Du8=; b=Yj3dp5aMhwEUyIKDBkVRIkokyNQYBmh7IT4vgJb7wuHkOby+gf9Uw1pxa/RHXz8Igt ckYe4AgObffELYgy/TWbR1E/qgx4Z6r3FAsCkXl63bnIdoAHkK8BestrkeLmtttLu2oM YyG1k3RodJ+4CT80psmWNXHvAR9WgrhbEytAkLCM9za46qb93f/YNiau/u/qtR43D3qu tfNVveVCG+XYWDlY66d5RA7oHH1zJxL07NI26M2chStqVVvxYgMGIzQR4Ys8C5ROt14w 9n8Tj8uf1X0PhBXqZb5orxhQNN5H7Z84qUfSt3m9vFfnUSW1gIlWUX9j40BevCHZVkGO laKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ssmIRhy1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id cr9-20020a056a000f0900b0068e390d86b4si10290602pfb.133.2023.09.13.07.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 07:27:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ssmIRhy1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B53BD8315C9B; Wed, 13 Sep 2023 02:54:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239488AbjIMJyP (ORCPT + 36 others); Wed, 13 Sep 2023 05:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239548AbjIMJyH (ORCPT ); Wed, 13 Sep 2023 05:54:07 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2B1B1FD3 for ; Wed, 13 Sep 2023 02:54:02 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5007abb15e9so11371182e87.0 for ; Wed, 13 Sep 2023 02:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694598841; x=1695203641; 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=AqhtzcGyFHDluGDjY5bQjlFxQW1yi0cE3p4JZH8FKz0=; b=ssmIRhy1mSisYkut48LhtZojZ1lknTHmP1p8aC87Iqc2BOscjRuCSUxZopuMljgUSt TuyVprXiaaZjL2OhIRwQfUmcRd//dNzpaqrHE2Dffu2p5EMGObH3ou2VATzYdbVeOjra sL0Z0OlfPE7Rh/EyqHo2wFIKMKhzXYauZLj4g4CZgObf8j6U/Xc5QewYm8IbdOhROmws 3fv46nWfbkkMov+RrAdVEGNwl1DyXR8f4JHRKVcq5z68EfHfquTiFaJYlXo2bMuC5wok dVLYAkFiOsZQLKd3N/ast2aPbE4PSKeooSDwZE3BxeOWTcVRBy7yGH11ugfya1yy628W TLqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694598841; x=1695203641; 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=I2TgJwLpx3J+LNzIaVmjtnu7EjmIF6oVx9IndwKp912k6Dt4QcCi4e5BV0+7HasisY CUBimhdKF+0Emnq3rLT7YT+bLP/ojAYw54Qm5Kz7Nz1cprAPyTB3AVQtJn726Mz9Ur/G cb2iBVX9+skWCqWnRSN2+6se0KcvppVl/zbEa6D0hEcXBotpb5NzRXic2Xsfo0YOpGKJ 6um7GSBa+mUoQE69bIbI8Rs3pbLl/aYiIgbgtDrnS1wJhk3omD5ie7btKu6+9b6HYj1l eE6SUq47B8XwVooXsIczuCfJg08omPu2JZAZgsU86W9duL9m6hhB/K0DCtAsu01UY9Wr lu6w== X-Gm-Message-State: AOJu0Yy19Tj2aIMoNNjx/vBSClFn0lKPUzjIJx6NFhuaXhrYDSdjB8bM cDSSedHCyhJmhQQ1vmTl04om7Q== X-Received: by 2002:a2e:9c95:0:b0:2bf:b106:6296 with SMTP id x21-20020a2e9c95000000b002bfb1066296mr1992334lji.4.1694598841134; Wed, 13 Sep 2023 02:54:01 -0700 (PDT) Received: from [10.167.154.1] (178235177106.dynamic-4-waw-k-1-1-0.vectranet.pl. [178.235.177.106]) by smtp.gmail.com with ESMTPSA id l21-20020a170906939500b00985ed2f1584sm8092669ejx.187.2023.09.13.02.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 02:54:00 -0700 (PDT) From: Konrad Dybcio Date: Wed, 13 Sep 2023 11:53:24 +0200 Subject: [PATCH v2 2/4] phy: qualcomm: phy-qcom-eusb2-repeater: Use regmap_fields MIME-Version: 1.0 Message-Id: <20230830-topic-eusb2_override-v2-2-7d8c893d93f6@linaro.org> References: <20230830-topic-eusb2_override-v2-0-7d8c893d93f6@linaro.org> In-Reply-To: <20230830-topic-eusb2_override-v2-0-7d8c893d93f6@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=1694598835; l=6150; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=LovaKfaqbkXiJ4az1PcPQZkH3FJdcJGz/pvW4OALguE=; b=XQp+5kTi6ild6Zxmlevo6fXNSvkR8Nv36RLh64N3zxki1otft+Now1GEIXUujMQqQ5DBWTfRS WxuRAaSJgqFCoVICxB3WM94ZbpcnKYskhI1gv+Va/0L5iwrtLU+/Orp X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:54:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776932882642526945 X-GMAIL-MSGID: 1776932882642526945 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 Sep 13 09:53:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 138884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1154257vqx; Wed, 13 Sep 2023 08:11:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1QDNfWRBZnaHAaJLW9xI1lFwELV210VWdq/ZmqdAyGvFgTWZrnV2WHDbNs0d3Z02rSp6Y X-Received: by 2002:a05:6870:708c:b0:1bf:1c49:7455 with SMTP id v12-20020a056870708c00b001bf1c497455mr3388554oae.6.1694617864036; Wed, 13 Sep 2023 08:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694617863; cv=none; d=google.com; s=arc-20160816; b=nJdA09ob3VwrTJCduRvF6iNN9Dwbr2j/XPvUDLBDqkM9kmU4AdAxs3CCjB3AGAbCWO p/eJY4dAvRTiqjgheqg3s3QQc5phtpU/oGRz5NOh+YKIRcDqOqjw3VupPUuPs9w/qHQm PRxKQzuBKjNuWtEdLWTrTgF+Nbo6slxsPhXosc8yMNG0kKip/eNBFjY+fZwTzBjg5HXM YpcLRKgRb319rcb/0ofkAblbnSQzzndRkpPu4sRZdQV8OVPKvUKt2U5V898ODnLzfw9H skHFGfw2hN740wq68EfGQ0J8dq0uqPW4uv/y73EmVDlZuI/LEW+gTp2yfWeGLoqfZcWU HsFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=AUYPXOt61j/CwnUtExvJrzeKAesEhBK7qFjfb3sogTc=; fh=bjGNk7INdi7ghZ3YzwEfvVQ70abLcRJWXpQgSHZ4Du8=; b=RQxu4XxEgjWoKCQ5DU0M2qV5x2Hgkxe0icGHC6PGEFo/V1q4p12WJ10EWrEuUu1I29 zL96xC1NRbqi7dg51yOvSmbe5e/snIRTdWpGjIEh91tvjk/WcVH8XL43JQkXLEMQLXR/ VChKKhLqDDHahynQBqkxAgOXhDm5pD6LE0VwV3xeNwptVrh2ngVR2bYavR0Pm00aV6SO KtSLd/umP9BUICqQyV+yYC6jdzVqfshQ+gW9weMGLfrjUMvNH4e5y+iVZWmbpvfVfT40 QnBxer2wVXbMOPkILl9IecUvCEdd976viRI2QAs6w07Fl8hGFLS3ihZwxgFe8CZx+MUS bEpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wit2tCGj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h70-20020a636c49000000b00570505c5267si9912872pgc.262.2023.09.13.08.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 08:11:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wit2tCGj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 08EC282C402A; Wed, 13 Sep 2023 02:54:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239593AbjIMJyS (ORCPT + 36 others); Wed, 13 Sep 2023 05:54:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239578AbjIMJyI (ORCPT ); Wed, 13 Sep 2023 05:54:08 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 305D81BC0 for ; Wed, 13 Sep 2023 02:54:04 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-99357737980so826476666b.2 for ; Wed, 13 Sep 2023 02:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694598842; x=1695203642; 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=AUYPXOt61j/CwnUtExvJrzeKAesEhBK7qFjfb3sogTc=; b=Wit2tCGj0BYcarxUZTqAWvNJdtutRX+Cn8DVhQR/qCPNFzLZCg+W01uoPowznu3S7w Fi3Hsc37AdjIa5yZhOtlezWDVg9/Ivj9Yb9hRMmqOjs7myae95r1Xv6469NNaE2ZLD+w 9WxaEPiNIqyD5SBInLIz+EGOXAw5zCLU0o2FqA8Cmm+xQ8unUMeCl3CLH49tf8eNfByV /LUfiD0NO1u8bGlgxVxuYakK10m8Oiw88qEf+jh6YaK+Mc44EqfHgsgL+EwC2UzpfnYG mFohxo4NkD0QbUPPTyUJEYP5QG5lTkPgfeXVX6BaVonY3F0taSf6E7KvReGauolGE/vV CqSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694598842; x=1695203642; 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=AUYPXOt61j/CwnUtExvJrzeKAesEhBK7qFjfb3sogTc=; b=PUPu0KeZfcXB7k8Ya2bfnhf8EhK9xfGaxuNYcgfrJUY82FlSpPvHLalGt8/pMXyVnV bnoUlCybM0/T/s1dbwssqsUT78DnoicsIZc98zPQZg8owj+J+c1g+XTu65x8Go2KaLv1 JK8q7QdPKnTut6oMlLsPKY+1wOVr9dGyyalUesnKdAIJL/f6gN6OJPuny97Zm5fK7j0k EdaKV6p5gf1mkv6artjnsQey+bjg64vOC5pnMGs0TS6DZSOiUjn5XxM+hgkeN4tRUR7N RFaneMoyU+nsnDUP7hqsjlzreShdE9/M3PavhG/FBiHlTcT+BWDHa00cLitYGveuIUdW DGQA== X-Gm-Message-State: AOJu0YxqbPpexntsO96/D2CXSp6GMCrP+gRqgLsxrSdmWgsh4f+6A+Yd t8M1mqb1cTtwGfAYLQSC4mCaBg== X-Received: by 2002:a17:906:518d:b0:9a1:eb67:c0ce with SMTP id y13-20020a170906518d00b009a1eb67c0cemr1832553ejk.50.1694598842583; Wed, 13 Sep 2023 02:54:02 -0700 (PDT) Received: from [10.167.154.1] (178235177106.dynamic-4-waw-k-1-1-0.vectranet.pl. [178.235.177.106]) by smtp.gmail.com with ESMTPSA id l21-20020a170906939500b00985ed2f1584sm8092669ejx.187.2023.09.13.02.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 02:54:02 -0700 (PDT) From: Konrad Dybcio Date: Wed, 13 Sep 2023 11:53:25 +0200 Subject: [PATCH v2 3/4] phy: qualcomm: phy-qcom-eusb2-repeater: Zero out untouched tuning regs MIME-Version: 1.0 Message-Id: <20230830-topic-eusb2_override-v2-3-7d8c893d93f6@linaro.org> References: <20230830-topic-eusb2_override-v2-0-7d8c893d93f6@linaro.org> In-Reply-To: <20230830-topic-eusb2_override-v2-0-7d8c893d93f6@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=1694598835; l=4717; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=tfXcOnK4MVXM/ELTMdiq7X69Wiw7KaRfq/u6evxvcmU=; b=UGw8FhPHnMGx6HcP17G3JFukIQzCmtAOIvW5d6j5oSc8nQNnuQvW3QQokYYi2FIlAOogWBmFl GoTcZmp6N5RATkgBJkozkgEqsVFqL3D9TEPi/tH1z96eTbgboVA9uP8 X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:54:46 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776935621224115664 X-GMAIL-MSGID: 1776935621224115664 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 | 58 +++++++++++++++++++------- 1 file changed, 44 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..d4fb85c20eb0 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 = { @@ -118,8 +140,9 @@ static int eusb2_repeater_init_vregs(struct eusb2_repeater *rptr) static int eusb2_repeater_init(struct phy *phy) { + struct reg_field *regfields = eusb2_repeater_tune_reg_fields; 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 +153,16 @@ 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++) { + if (init_tbl[i]) { + regmap_field_update_bits(rptr->regs[i], init_tbl[i], init_tbl[i]); + } else { + /* Write 0 if there's no value set */ + u32 mask = GENMASK(regfields[i].msb, regfields[i].lsb); + + regmap_field_update_bits(rptr->regs[i], mask, 0); + } + } ret = regmap_field_read_poll_timeout(rptr->regs[F_RPTR_STATUS], val, val & RPTR_OK, 10, 5); From patchwork Wed Sep 13 09:53:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 139340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp144998vqi; Wed, 13 Sep 2023 23:20:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9KOVmLBQ2lKZjFvMYPl7TSUBmWRh9fi8Ibc7WTFvU2OSNxD4JGsE/vwP4ClDQo8/nVomh X-Received: by 2002:a25:790b:0:b0:d77:e3e1:44cf with SMTP id u11-20020a25790b000000b00d77e3e144cfmr4619497ybc.38.1694672413116; Wed, 13 Sep 2023 23:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694672413; cv=none; d=google.com; s=arc-20160816; b=qHyf9KLw0txz5GVkSvVNs6IPmZQPExy1qYnvrvAZeZqSydvHaCHBD2/LnOJNvdsxDp adUow1VYCJGk9e5HIthfrqHe/BJn1kPL237hESWYp8DX6kQECzIWj63Twk+GImBLo9q/ 2P6fAE1KQrQ9Eo5x1R6HzwbhHHWEMtcjw/3iOEF1sZbESZsM9+IyLq6HpCJFA6UD1f9J k5RcsxAEmYYPepsuBOv7mHhXV/JE447gpReqjgK/1JEjc7EOEJLFE5dlzlZ/8GZVwXtG pTFp0fAHij1pc45d2pOE64vYepghzT/6WO4PM/qD7yrMolweOcLjAhQwT1/aAZVsGT1L gVFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=y61vDLY2d3z1XABw8fo4c9R1eNGV9j8r0ag87ujCd/s=; fh=bjGNk7INdi7ghZ3YzwEfvVQ70abLcRJWXpQgSHZ4Du8=; b=ofKIeUqIdGkgEiMh5iiB/0JXh9QTYylFBF9A2MqwB3hZ7QWRYNKMXZh9OxllZhkZbd 7bCvkd3l1B/KD+N4EvuXB6ID9kHlv+ckr0pGXbdacLNsPvQyzP78VDEIhqsgAoRMI2Vc 0XQaj/xFz6LPuZKw1UDEArTzLrDXuFDt2W6IP/ess3dywDtK/+zWl5mhbOiKBDrwtk5t H2GX++E3EuM6x8NnzRYPutLhQuH5GwWUYoMxBC6Xp5SBu5f93iU3siV/ykZ5++P/1A6i 7mQsw3fdvW23dAARvd/L4NWYP1CigEut9Pqdm+EpMSgyQLQcVtxNl6MJJ3Q8Dk6BmPuX V+bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vUYpN1T4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id m66-20020a633f45000000b00565f01b9403si811583pga.883.2023.09.13.23.20.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 23:20:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vUYpN1T4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C957481D476D; Wed, 13 Sep 2023 02:54:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239525AbjIMJyV (ORCPT + 36 others); Wed, 13 Sep 2023 05:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239538AbjIMJyK (ORCPT ); Wed, 13 Sep 2023 05:54:10 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8692A19B1 for ; Wed, 13 Sep 2023 02:54:05 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-99c3c8adb27so843485966b.1 for ; Wed, 13 Sep 2023 02:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694598844; x=1695203644; 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=y61vDLY2d3z1XABw8fo4c9R1eNGV9j8r0ag87ujCd/s=; b=vUYpN1T4xXsSYMKRj6j9d5nyc5Pg+8XJitpgAvy0deWkpspw6AxHOMGy+WQkPD5H7X 9q75xgHSA/W0rMTsSPTOJhW7n9dEZzqzZGqrYz87wAYfXgB2sEK597y0TmF2BhukEf67 q3Eh2RMVTN8K/Fk6BCJGOLTHCAAcwc1vs4yNkpMtWPMH6vxdCN9Yps8dIR8kTEf1qEH2 2DwqbanxuzpN6n/mTqrpwiSg1+PjUkTkb2Df4uHstyOY3TKbhjo3BNkj8+5osAMrO+zj aI/mNRvkjY3BQDhaStvYnbpy6XOxTIyncIy54ScOAinNf7nZcFw2z9MWMsu9dAqbio6J I9Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694598844; x=1695203644; 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=y61vDLY2d3z1XABw8fo4c9R1eNGV9j8r0ag87ujCd/s=; b=qFi0OR+IGWJw3+2mXo774jGyaWJtXwdzxqppGcxJnsYn8vtrSpSZhOuCrWkuaY1Xmz BM88dI9G1vBR5uUU9hnx223QyI4/0A2vQmetvrP+8edruxsGUEJ84YIkG/I9uCYLif+a UNL7PL8qmDHZO7zWWv1q1WKBdivWryvPISx6o56BBL598cAloaNqz/t2P4njcAfjDhA0 eTDZoTd+bcoR2pQI9TX5WYDiCh/nEN2uIXkEG51dCnG8LNdY9M+qMUBmKulx9wykJEJU aXN+TIZ43PMU5apIA617YGLe4IifcH7ENvgGttANlqFCMEsgLE3cDVvJQY6e1L3WmzGp 4p9Q== X-Gm-Message-State: AOJu0YxeMWedJWjX25aba468vqZuhQVNoUMMMs0TfGSyU8pZvVsi4EqK MkuSj17+AS58fGrbRJG/yjjjsg== X-Received: by 2002:a17:906:319a:b0:9a1:c00e:60c5 with SMTP id 26-20020a170906319a00b009a1c00e60c5mr1459575ejy.48.1694598844117; Wed, 13 Sep 2023 02:54:04 -0700 (PDT) Received: from [10.167.154.1] (178235177106.dynamic-4-waw-k-1-1-0.vectranet.pl. [178.235.177.106]) by smtp.gmail.com with ESMTPSA id l21-20020a170906939500b00985ed2f1584sm8092669ejx.187.2023.09.13.02.54.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 02:54:03 -0700 (PDT) From: Konrad Dybcio Date: Wed, 13 Sep 2023 11:53:26 +0200 Subject: [PATCH v2 4/4] phy: qualcomm: phy-qcom-eusb2-repeater: Add tuning overrides MIME-Version: 1.0 Message-Id: <20230830-topic-eusb2_override-v2-4-7d8c893d93f6@linaro.org> References: <20230830-topic-eusb2_override-v2-0-7d8c893d93f6@linaro.org> In-Reply-To: <20230830-topic-eusb2_override-v2-0-7d8c893d93f6@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=1694598835; l=1798; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=vlWt+/crcyxMQdUhFQmb4WOVKaBs0wbkNDm3+xQ+iBc=; b=rj7SzS4MbUgXjzqv55kbUGwKD8esrMRttXxGkS+rICUBd8qFKbouTxfru32W5y6X7a00cfv4x 32ZjJI8ZlwwBxD5Fbcx78qPt7e2le1FLdTFvkRx6e79+TsMPkhHqPYH X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:54:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776992819902318353 X-GMAIL-MSGID: 1776992819902318353 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 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c index d4fb85c20eb0..a623f092b11f 100644 --- a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c +++ b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c @@ -142,7 +142,9 @@ static int eusb2_repeater_init(struct phy *phy) { struct reg_field *regfields = eusb2_repeater_tune_reg_fields; 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; @@ -163,6 +165,19 @@ static int eusb2_repeater_init(struct phy *phy) regmap_field_update_bits(rptr->regs[i], mask, 0); } } + memcpy(init_tbl, rptr->cfg->init_tbl, sizeof(init_tbl)); + + if (!of_property_read_u8(np, "qcom,tune-usb2-amplitude", &override)) + init_tbl[F_TUNE_IUSB2] = override; + + if (!of_property_read_u8(np, "qcom,tune-usb2-disc-thres", &override)) + init_tbl[F_TUNE_HSDISC] = override; + + if (!of_property_read_u8(np, "qcom,tune-usb2-preem", &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]); ret = regmap_field_read_poll_timeout(rptr->regs[F_RPTR_STATUS], val, val & RPTR_OK, 10, 5);