From patchwork Fri Jan 5 10:16:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 13511904 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 50344C4707B for ; Fri, 5 Jan 2024 10:16:34 +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=2TsaAc4/wmaEcWmIax2+NQdgRFWfEHDPqpsfwnO5EmY=; b=OrgZ4Nip6CYJ++ vtJBHJ6KGsGUrUZeVAIniYDuFQovC7unG6sw3Gf+AKXv51LRJyiiNElddydPNWJnl7TPb24Phsarj E2e4RhZM6PJGmXseMtW4qh4BwFBAWhzh7pVqy+YoXhJ218+NRhAMxxkJq8hQJUzi6D6FAS5PD/QG/ g0IoA5iA319y4J4lC7E5XktwQl9qcSl+uk0KqtqoNEy6byU525fmIFfX/ZYqhgt+2zlZg6VqCebHe cyoMIFYtyGVJQlsH2R7xfE7N8QAKXdmpNQkwFX93/TMFiYph51gBSbl52bBH2tMimcsuhsZx59t06 liOQCUluWqAdbXjuzM7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rLhFi-00GVCh-0B; Fri, 05 Jan 2024 10:16:34 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rLhFe-00GVB2-2E for linux-phy@lists.infradead.org; Fri, 05 Jan 2024 10:16:32 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a28b2e1a13fso159251366b.3 for ; Fri, 05 Jan 2024 02:16:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704449789; x=1705054589; 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=M2SbbmAUvxuz+3O7vyQxuSBbpMgT1hRNIR0aHAh7TUs=; b=Cz+mRX9H3cxbY8nGdmgUSGDqP71GTBGj1TXBWiL9dbHA6USMAAKYd6OAVTTp/CpzSs QUxorinbikHMJxcBGKtVV7DUuzKhCkU+Xt833Wpy64/J7UVBVDNdZc2ntCyhlSIzKkI/ JoWuh3rmJGxNjlj9ASMZ8kAxn4PYdDO4fC2r5rr86z+4HZA081mox3XgL4oNRhrEQqiV wk7aTKn5qExCEXC+2viKHOXQMYhrdcR/v9y4e5QrNHdbiNKZBnRpVMywer+ZYx5do7rx pioqiYLNSRbyTnVUWHRu5pUdEzGmfGbFxXlHhpLTTyZBhpMXkhR8M21M1tiTZEpnQKvd lnuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704449789; x=1705054589; 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=M2SbbmAUvxuz+3O7vyQxuSBbpMgT1hRNIR0aHAh7TUs=; b=mP9UBzFOWXof7bYIj9LCT97xvV7/84yv4Avi01X9jVNnIBR27OcYDMZqJTSGHzedlb 07h7XTCnRAggGOrQbfXmU5wt+WIoaUXbb7Ds4ZV+2MnyYoku13pVzU2Dynpt5f8SJ/zM FpTTunHDjTBvCp9Ty0+QvqOpvK4Y/ZyfGJB/S055mCrYEeN2sLTWBGhTDRFeIWs2VAxd CG9Ql8D4tFksGHhzJiXT/A3MKoAuS4r/aTKxCK29jePEZkgclweziQGqn1Vj7t9xYCEW QM2EaK8LA02Q7rNFjVIpTJQgSi5Zgx3lbSg0CY4nMFpxGvCVo4sKGGn71XsfWTmFoaqb 2HYA== X-Gm-Message-State: AOJu0YwkZ546sjONV0CzcfrsZDPd8DjqPzBjJUbFCCyfblApgX25cdut WzajC1orCQjSkb5rh2BzVlFR3e0gUw9aLg== X-Google-Smtp-Source: AGHT+IGXz2g8H97RWKY+7sFScbllJc8+MA2CAHJyVkS1v+Mjo7+A0HD5O0yVEja/MabxVgS6haXrfg== X-Received: by 2002:a17:906:1d9:b0:a28:ad97:e214 with SMTP id 25-20020a17090601d900b00a28ad97e214mr1018779ejj.1.1704449789326; Fri, 05 Jan 2024 02:16:29 -0800 (PST) Received: from [127.0.1.1] ([79.115.23.25]) by smtp.gmail.com with ESMTPSA id o9-20020a170906358900b00a2824bff5b1sm713180ejb.216.2024.01.05.02.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 02:16:28 -0800 (PST) From: Abel Vesa Date: Fri, 05 Jan 2024 12:16:16 +0200 Subject: [PATCH v2 1/2] phy: qualcomm: eusb2-repeater: Fix the regfields for multiple instances MIME-Version: 1.0 Message-Id: <20240105-phy-qcom-eusb2-repeater-fixes-v2-1-775d98e7df05@linaro.org> References: <20240105-phy-qcom-eusb2-repeater-fixes-v2-0-775d98e7df05@linaro.org> In-Reply-To: <20240105-phy-qcom-eusb2-repeater-fixes-v2-0-775d98e7df05@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I Cc: Elliot Berman , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Abel Vesa X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2272; i=abel.vesa@linaro.org; h=from:subject:message-id; bh=vIbUfNQlZTi1v25Ve+Sd4HHhwYJTXbuLuFkWrD7aJiM=; b=owEBbQKS/ZANAwAKARtfRMkAlRVWAcsmYgBll9b412/e8NdvgMxOeqdne0SbNS5xvfDpT5ibA mNOTJNMutmJAjMEAAEKAB0WIQRO8+4RTnqPKsqn0bgbX0TJAJUVVgUCZZfW+AAKCRAbX0TJAJUV VvHvEACX+B/Dfb3IwGS3F1o+zp26fCXYgaMHeIrlqxwCWDSKYGcmjmCH8lBMHKOVzaPSKz+hExZ Q8sVmp0CuZkAAhuTs4YQSywX54L1BLD49ApRdASsfzvucIUXcqOf4aW4E8UvBTXX2YrD2xZG/+b Y9jus7yZF0GCbabI9hnxd4HYaDn+KBzSoWz5+iEzU3kLsYI+MyzkdmNxXJnZwm+khQ3YqjjbXgd FUe9CotAQlXu6OFqSBCC4PJ4uOWdPWT1XB9QK/3PqqH9C1d3A35KC8lG7dybHfsexHrBwxux/1s 1qMtc2xw/yLtQp1OZSyPiHU4OkoyRBiKYMYllWjutWCzxXAqD0FLax+k3AsCcXQLUECjKERivM2 5FMIdxS318g9etxPl/7BsnbOV10/yUoVazYudaCCnXiOlfv6b6gcWRm4zghRc9kt73QPKO35Bt0 JsTc/w1u0H8WwceWNV65T2AXOmMLX0b56orO7CGuXtXQJGhc1OaknOcgURit54n0LFtEt9BHh4m PLms9g4BJbcBgqkkkqxFD4Dg+h0zbMKRRHI+k/2Y9wNxX7U9OsYwTtJinUMgNyNHKIHDtIdVyo2 CUBQAeg9Ms+1f8fHsSSD6NiYiJbNIeDwBkQSjeg5WXg2Y05qbrEc/AxcY6tKQhoAmeGac8G8W1k pzX3kGTBm2uD7dA== X-Developer-Key: i=abel.vesa@linaro.org; a=openpgp; fpr=6AFF162D57F4223A8770EF5AF7BF214136F41FAE X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240105_021630_725719_57A64397 X-CRM114-Status: GOOD ( 14.02 ) 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 global regmap fields offsets currently get incremented with the base address of the repeater. This issue doesn't get noticed unless the probe defers or there are multiple repeaters on that platform. So instead of incrementing the global ones, copy them for each instance of the repeater. Fixes: 4ba2e52718c0 ("phy: qualcomm: phy-qcom-eusb2-repeater: Use regmap_fields") Reviewed-by: Konrad Dybcio Signed-off-by: Abel Vesa --- drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c index a623f092b11f..5f5862a68b73 100644 --- a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c +++ b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c @@ -101,6 +101,7 @@ struct eusb2_repeater { struct regmap_field *regs[F_NUM_FIELDS]; struct phy *phy; struct regulator_bulk_data *vregs; + struct reg_field *regfields; const struct eusb2_repeater_cfg *cfg; enum phy_mode mode; }; @@ -140,8 +141,8 @@ 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); + struct reg_field *regfields = rptr->regfields; struct device_node *np = rptr->dev->of_node; u32 init_tbl[F_NUM_TUNE_FIELDS] = { 0 }; u8 override; @@ -262,15 +263,21 @@ static int eusb2_repeater_probe(struct platform_device *pdev) if (!regmap) return -ENODEV; + rptr->regfields = devm_kmemdup(dev, eusb2_repeater_tune_reg_fields, + sizeof(eusb2_repeater_tune_reg_fields), + GFP_KERNEL); + if (!rptr->regfields) + return -ENOMEM; + ret = of_property_read_u32(np, "reg", &res); if (ret < 0) return ret; for (i = 0; i < F_NUM_FIELDS; i++) - eusb2_repeater_tune_reg_fields[i].reg += res; + rptr->regfields[i].reg += res; ret = devm_regmap_field_bulk_alloc(dev, regmap, rptr->regs, - eusb2_repeater_tune_reg_fields, + rptr->regfields, F_NUM_FIELDS); if (ret) return ret; From patchwork Fri Jan 5 10:16:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 13511906 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 94092C47079 for ; Fri, 5 Jan 2024 10:16:34 +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=C3ZoXTd8Z65iLqvZo8aoC5hYSbmE7sjFgfCHit57YXw=; b=GmRaPP8ift9U5K sVdOMgBM/YOj5oyg6UqC75pHz1j+UN08f/yEgcir5cPwjtNgYsIjm1mhWn/fh0J7zM5ZNapC8W3HH Ywod92ad0W2c3szH79oPEh4+LRBkl7Th1ld2clgn4rygiRfnxNDno2XjXENtUoSF4PBJLiydW1npR yk8N0/B0wTs90RBUgGhuhgeuXtZN7CmHSmUHHjyrjOxffrS1Anr61lyJgtpQxvHcUUwucYjEOiY2n f2Dd/RZTuNh/WVQRseX8lcqpHvmv8wO1wLz0YtA+s3U9pbgCCgj9lV3+fgy/9XWdDaQbLP5uGr9zs 1D/sx0z1Er+x5sPZxvuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rLhFi-00GVCs-15; Fri, 05 Jan 2024 10:16:34 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rLhFg-00GVBi-0B for linux-phy@lists.infradead.org; Fri, 05 Jan 2024 10:16:33 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2cca5d81826so20268131fa.2 for ; Fri, 05 Jan 2024 02:16:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704449790; x=1705054590; 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=/QKH2I8GrPdCeY4Xo3OxMu/ITqYHkEvyiTHRM/5TT/M=; b=cDdZy2h5xRPI3ITm7y23Tevy9sK7w6w7ktGzXUqJ/eBmXj2cvdtzU8LOnds553qD7J 8THcVlLK5IIpeZS420SiVHkk5AszRw0u9YrGAFiLnM83NkoKKbtTfjf/Y1cUCB1xlbA1 nVyIK3G5CdhxaipWiWCcs88lVfVgQqV3TYLfyV8+l6grQH0RTb8KWxselo9Z7L5CItUL Ysvl/CA+QwZIA+4cFCZFgmEF2OC+Y/AiQiSMk7+7eSF4CwFnf+eQYRnN4g3So9P4gi2K JPI8ulXIyWAna8FJip3kvTYlgAkQ9vVYE4lQAhM83+0CdKfmmh1FLB9w3FxmlAgNnMu1 goWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704449790; x=1705054590; 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=/QKH2I8GrPdCeY4Xo3OxMu/ITqYHkEvyiTHRM/5TT/M=; b=MBNLMSyLRm19bHkbGClu4+IoftMouNZb3dbUpxuFPf6MKkAIoRnY35nj5vY3MRn7tQ y0PurZiSzJRCW5JxwQtKjl/yvG74oH3UbWLgAxB/IqzfkHczTBS6wT+o0Y4BuuNmA2r/ 5DHQAFApdozmggbRRwoEP13VQkAPTgRZDDXvjr1X/MJKXP8NxJjvzD6Lf+WYyoV/nt4i gY2607crzefrHjV0vzwa5g8FgmYoEVgy8QIhGQ1uzkSRz+7S59M/OA4uODT9gG8qua32 k4/XO+F0cCXO1UYzTMZJfnANuEGphb3LXDOsDWZUk/VY5y0BirJqvQ80CF3MTuoNrUS/ V0LQ== X-Gm-Message-State: AOJu0Yx2JjLE9hhmXQxnoOBbxctlKg0s2eP8x+2uJtFvmH3yml3TxR68 NJ54VlGJf9TWpxadn2eKz7HCEgR6CWoM4g== X-Google-Smtp-Source: AGHT+IH1RawZ6OGwh/tmYi2y5tlVMSy5TK/O7WKXvjLqh8pSSTkg0pe17sX5VEnwrzib+wteIRYU1Q== X-Received: by 2002:a05:6512:398f:b0:50e:a8c7:b2df with SMTP id j15-20020a056512398f00b0050ea8c7b2dfmr1238858lfu.36.1704449790463; Fri, 05 Jan 2024 02:16:30 -0800 (PST) Received: from [127.0.1.1] ([79.115.23.25]) by smtp.gmail.com with ESMTPSA id o9-20020a170906358900b00a2824bff5b1sm713180ejb.216.2024.01.05.02.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 02:16:30 -0800 (PST) From: Abel Vesa Date: Fri, 05 Jan 2024 12:16:17 +0200 Subject: [PATCH v2 2/2] phy: qualcomm: eusb2-repeater: Rework init to drop redundant zero-out loop MIME-Version: 1.0 Message-Id: <20240105-phy-qcom-eusb2-repeater-fixes-v2-2-775d98e7df05@linaro.org> References: <20240105-phy-qcom-eusb2-repeater-fixes-v2-0-775d98e7df05@linaro.org> In-Reply-To: <20240105-phy-qcom-eusb2-repeater-fixes-v2-0-775d98e7df05@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I Cc: Elliot Berman , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Abel Vesa X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=4690; i=abel.vesa@linaro.org; h=from:subject:message-id; bh=qz6RxnBEtexpOzrPteLkLotdoWP7JKERv8XNG5Nn5QM=; b=owEBbQKS/ZANAwAKARtfRMkAlRVWAcsmYgBll9b6oEoplC1rUxzC5CX0PPap9ab4rMbCpOvnF gB3skAbdMWJAjMEAAEKAB0WIQRO8+4RTnqPKsqn0bgbX0TJAJUVVgUCZZfW+gAKCRAbX0TJAJUV VkmMEAC24tkNwCFDgvtyg4UdCNkqDoMI7rhoRoHjl8iutENftVniejltVji8R6WcslGJhr3uzyx sO1FM+8DgxKVuiIM7PLO97LbHwqDk1J1q3qN/7ViKmIYKJsU1KuXSOmh894Z5JmYfNi1hnBlqBQ /j9EddFvW/SbATHdL/7T/xHrnqj4AYAywauwTKhcDZEz9lbuvjxqq/v+Rbx+0gBb/rDgwJ9zgsO NblEYyt1QRAp+dC4wyuBjAa1JlO1MluMSlNrq86xOWz/sg8owH+h15Tude7ZZPHyW9sMP7u0YsF ee+9JAc4whznsIvVjLC5OyZcgG2SMJz0HlsR1isCNkoCbIqq2WtQH2OqNCxL4elNChKSveeEiJT sBWYvfpv7AO/Mm9k/oz2i74sOwmtDyZMwho1YoDaM1WkvY5lX2T65AVYugRnaT7gaei2j3WSb+b OYpDm7AGhVBhytb31Qv7MdYxiznkv/q+MtkFWvGZ+GTC/+W6GjuhY+s5RYo9sWnHktoQicrfmbN h+u8ntPOjhA8P0suRSayTxEVEpV87R6+2uSFiA++IbnBjiI/ixsqOnUL4/I0AQ922CoJcfrGUU5 i6BB4xmoa0m0d5whGV2svtrt6zxndROwCWFzI8KikcS9VCuvlbJUL9ugMpDtugwaukV4dKMFYHG Bvdgr57kzmJHYUg== X-Developer-Key: i=abel.vesa@linaro.org; a=openpgp; fpr=6AFF162D57F4223A8770EF5AF7BF214136F41FAE X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240105_021632_094484_187ADA1D X-CRM114-Status: GOOD ( 16.49 ) 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 device match config init table already has zero values, so rework the container struct to hold a copy of the init table that can be override be the DT specified values. By doing this, only the number of vregs remain in the device match config that will be later needed, so instead of holding the cfg after probe, store the number of vregs in the container struct. Fixes: 99a517a582fc ("phy: qualcomm: phy-qcom-eusb2-repeater: Zero out untouched tuning regs") Signed-off-by: Abel Vesa --- drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c | 42 ++++++++++++-------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c index 5f5862a68b73..d28106e71ce3 100644 --- a/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c +++ b/drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c @@ -102,7 +102,8 @@ struct eusb2_repeater { struct phy *phy; struct regulator_bulk_data *vregs; struct reg_field *regfields; - const struct eusb2_repeater_cfg *cfg; + u32 *init_tbl; + int num_vregs; enum phy_mode mode; }; @@ -123,9 +124,10 @@ static const struct eusb2_repeater_cfg pm8550b_eusb2_cfg = { .num_vregs = ARRAY_SIZE(pm8550b_vreg_l), }; -static int eusb2_repeater_init_vregs(struct eusb2_repeater *rptr) +static int eusb2_repeater_init_vregs(struct eusb2_repeater *rptr, + const struct eusb2_repeater_cfg *cfg) { - int num = rptr->cfg->num_vregs; + int num = cfg->num_vregs; struct device *dev = rptr->dev; int i; @@ -134,7 +136,7 @@ static int eusb2_repeater_init_vregs(struct eusb2_repeater *rptr) return -ENOMEM; for (i = 0; i < num; i++) - rptr->vregs[i].supply = rptr->cfg->vreg_list[i]; + rptr->vregs[i].supply = cfg->vreg_list[i]; return devm_regulator_bulk_get(dev, num, rptr->vregs); } @@ -142,32 +144,19 @@ 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); - struct reg_field *regfields = rptr->regfields; struct device_node *np = rptr->dev->of_node; - u32 init_tbl[F_NUM_TUNE_FIELDS] = { 0 }; + u32 *init_tbl = rptr->init_tbl; u8 override; u32 val; int ret; int i; - ret = regulator_bulk_enable(rptr->cfg->num_vregs, rptr->vregs); + ret = regulator_bulk_enable(rptr->num_vregs, rptr->vregs); if (ret) return ret; regmap_field_update_bits(rptr->regs[F_EN_CTL1], EUSB2_RPTR_EN, EUSB2_RPTR_EN); - 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); - } - } - 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; @@ -228,7 +217,7 @@ static int eusb2_repeater_exit(struct phy *phy) { struct eusb2_repeater *rptr = phy_get_drvdata(phy); - return regulator_bulk_disable(rptr->cfg->num_vregs, rptr->vregs); + return regulator_bulk_disable(rptr->num_vregs, rptr->vregs); } static const struct phy_ops eusb2_repeater_ops = { @@ -240,6 +229,7 @@ static const struct phy_ops eusb2_repeater_ops = { static int eusb2_repeater_probe(struct platform_device *pdev) { + const struct eusb2_repeater_cfg *cfg; struct eusb2_repeater *rptr; struct device *dev = &pdev->dev; struct phy_provider *phy_provider; @@ -255,8 +245,8 @@ static int eusb2_repeater_probe(struct platform_device *pdev) rptr->dev = dev; dev_set_drvdata(dev, rptr); - rptr->cfg = of_device_get_match_data(dev); - if (!rptr->cfg) + cfg = of_device_get_match_data(dev); + if (!cfg) return -EINVAL; regmap = dev_get_regmap(dev->parent, NULL); @@ -269,6 +259,12 @@ static int eusb2_repeater_probe(struct platform_device *pdev) if (!rptr->regfields) return -ENOMEM; + rptr->init_tbl = devm_kmemdup(dev, cfg->init_tbl, + sizeof(cfg->init_tbl), + GFP_KERNEL); + if (!rptr->init_tbl) + return -ENOMEM; + ret = of_property_read_u32(np, "reg", &res); if (ret < 0) return ret; @@ -282,7 +278,7 @@ static int eusb2_repeater_probe(struct platform_device *pdev) if (ret) return ret; - ret = eusb2_repeater_init_vregs(rptr); + ret = eusb2_repeater_init_vregs(rptr, cfg); if (ret < 0) { dev_err(dev, "unable to get supplies\n"); return ret;