Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1128809lqm; Thu, 2 May 2024 06:15:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCViqQIKe9pVV09TW/3N1tfk8cynzrMmxIDbE1okQ7M0Z2bfx837ooa8wqk++I3BzT+l8nGVcUJ0iX0nl02Ui3XnuPvGkx3CvF9Dc13aBQ== X-Google-Smtp-Source: AGHT+IEjaoB4JaHhBUNGxUfOt1BKz/T+DLKD+rXv+TfQcGgNvbsi+6yWUoLtUJdwGl1ZIDXTUr1m X-Received: by 2002:a05:6a20:5657:b0:1af:654d:6e06 with SMTP id is23-20020a056a20565700b001af654d6e06mr2009133pzc.59.1714655727775; Thu, 02 May 2024 06:15:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714655727; cv=pass; d=google.com; s=arc-20160816; b=Qs/iD/eQGgAZ/iczBSU/Vm3G/UthSaF9u7Xk/n8Ih1eqs8Dc5cGwabkUaNUK4zuU7X AfXaYV2htHs0OCelCuLQ3IzEZETfbK0miIab49VMnFJt90PXp+XDMDvtWzkppQvHEYGE wnO9gPauSSTiCdlexLzCBc8+hyKEs2Q80S194aclw4+wu4ZJiLnGC7pEmxAf//la2XnB ccTosTO2AMF2c67VyWm1Jo2E65mlXVsPBtIa3bAFmbejy8c+iZhgBtoxhrQBE54LXTw0 38ubmXALoZAgmOskQQ0w85davWc22+D8p+ORVR4PxA4vYE+OiQj/VkyWe1LD18jdI7cR t7aA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=e9IfF2XRrC1/or05aEZt3Pgg1CS/l8eHWqh1tFVKZN4=; fh=8LlIB6EuVwfOQnOrouZDwyeHtChory3ieNcpoqr060E=; b=yK+2vNonH9oRwzG3/M9ovata3tEGrp2nobgFjuFZcRD23yVmyPGhag5vAGv5wIqJbb VAaX4a75MwzlU1LW9k2fQGkHbivyPVec6J8+Eoes4XFKf28tBN3KP+cqE0mx46fkebzA UO4tAQfrTH6kLDhj1afwbZCXQC5Fe0QAPHHeP1sJ/OJV8DD801/5qt9qhv0pmBYlIf7i OWcLc7svoMTiZE0XRkZ8giUiHoU/0syFZjDRJ0FoibphbXNKkbkBfag1Urlbn0d/g5+d LgYnzfWX9wbb2s+WvAn0+60micvNtQPJ93bdtr74g8JZKnfO29onK0bOtl1nrXg8bITT AgTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pq0FcFFd; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-166491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i74-20020a639d4d000000b0061236221242si938075pgd.359.2024.05.02.06.15.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 06:15:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pq0FcFFd; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-166491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B49ECB23C4C for ; Thu, 2 May 2024 13:12:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C59484A24; Thu, 2 May 2024 13:12:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pq0FcFFd" Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A4A643158 for ; Thu, 2 May 2024 13:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714655553; cv=none; b=ddtwLebziprOWeP4MljCo2HesfK6xy/jIe5ARtLUASyrAa5AMGFkK1WagAprl+ODdxHDPtZOBujV4u9WmQZPgSZHzA0AXmYYxiF/lDGatOFhBedyHbv4BzEIm155IYcdv34JGK5y2RzZm2NH41IaM2wA1IpO5BY322OnlOIedNs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714655553; c=relaxed/simple; bh=w36A9qNTkHew7BT2vRvvyNspByFD2CNRYwskOpKFMNY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=G5dTkK+KM6K3Hjb5AMj4ugmf0Rf8L0iocRDXOQ8KQtttOt1U+ZumGy4Jcksl7Wn7UIutzfWD3sz7/DrCNiKo+jx8PU1+uGkDE4Qv3CQp/M0LaIGQ5aRc7aAD8eRce9KKqMcYMkP1KB3AmHK/ezEtJY81NMbd853dLwe5sSwvK2Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=pq0FcFFd; arc=none smtp.client-ip=209.85.219.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-ddda842c399so8146524276.3 for ; Thu, 02 May 2024 06:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714655551; x=1715260351; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=e9IfF2XRrC1/or05aEZt3Pgg1CS/l8eHWqh1tFVKZN4=; b=pq0FcFFdFyslHFHmW4iDwTqhNMjI0Wh4AibrlCf4ipmtVjIjnYVOtFEx6iTp/NHEUT aDweGprtPI6uW1sFtvp9lL1iWFibsYbLvZF8d1rkGCTwF5UwpqB5EaUv6Z8K91HJdd6T WsNfJ8lZKuHcX1EVeYLgQsAxyltsXipHtgW3hFiBe2esvPEw39UbzopxfT+NAyfRt1Wf LKEQQyYtdCdrITo8RIreOGb1qzRE5ev4YZDz7TnodKFOFKz6luibL7eoEcNt9FUBF5oH qItPSV7p8nnPY6VM88twrhz3mDUB0+F80g+zqDnSZbEEcbvChgxhGdow+iwFeZAdQd9b 4+NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714655551; x=1715260351; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=e9IfF2XRrC1/or05aEZt3Pgg1CS/l8eHWqh1tFVKZN4=; b=TxJGUenC1rgeXSzKwPGG/BXp9trjbN+jXUG/3pxAyesztFp5U9wzluakQt70Py1paW dcLAEn23G3ARZAa27kB/TsHjqfOU5stdg4K/DYG+D1yE+8rg0B2W/HWEXRh5WSCXRQ7Y mIQsOA554s+9bvnUSyj3542z+dJH3QuSUXHqSuGtyHikw1TfeWcS727WI6qStAqEW8rS ovpjmeL8+K1cjCLPCaDGjy8cTvqLWkZ+Z/WVrvacFmcqVENUpsDRceYsdUSEfDIvdHtX E25L83IGZUZillosrpJ6vDzKZ4YIAQzmiWANRLMKw3Bj9xdInu48N+64LStlygvNahV1 UwEw== X-Forwarded-Encrypted: i=1; AJvYcCXb1OlGS8Wqefiica2mk494fVox5iQC6IxW24KUm9n+12I4MLiHt87BKeeoGBYafgPQgJjCbVQBa0u6joOk0iKFhDVok3wjfJ5Ei1p5 X-Gm-Message-State: AOJu0YzFs4H7++cbG803y7Xe3rgchx1k61nAPk0AbYTX7Oqt+36MUB1f OvRvWccq6HvTZIk7S2BAH+zOKWdBh2U0aBCAF1f4YzR5F97PbAzMzXIQg3w9Ojf8V/ZNAAlJaww K3TaYLnI+20cT4UG6BWBCUM1Kng91ORWaY9qwoA== X-Received: by 2002:a25:db8e:0:b0:dca:a3e8:a25a with SMTP id g136-20020a25db8e000000b00dcaa3e8a25amr2216795ybf.62.1714655551232; Thu, 02 May 2024 06:12:31 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240502123312.31083-1-quic_ugoswami@quicinc.com> In-Reply-To: <20240502123312.31083-1-quic_ugoswami@quicinc.com> From: Dmitry Baryshkov Date: Thu, 2 May 2024 16:12:20 +0300 Message-ID: Subject: Re: [PATCH] phy: qcom-snps-femto-v2: Add load and voltage setting for LDO's used To: Udipto Goswami Cc: Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Thu, 2 May 2024 at 15:33, Udipto Goswami wrote: > > The Femto phy depends on 0.88/ 1.8/ 3.3V regulators for its operation. > If one of the regulators is not voted to the required minimum voltage > for phy to operate, then High speed mode of operation will fail. > > On certain targets like (qcm6490_rb3gen2) where the minimum voltage > of the regulator is lower than the operating voltage of the phy. > If not voted properly, the phy supply would be limited to the min value > of the LDO thereby rendering the phy non-operational. > > The current implementation of the regulators in the Femto PHY is not > setting the load and voltage for each LDO. The appropriate voltages and > loads required for the PHY to operate should be set. Please move min/max voltages to the DTS. There is no need to set them from the driver. Also, is there any reason why you can't use `regulator-initial-mode = ;` like other boards do? > > Implement a bulk operation api to set load & voltages before doing bulk > enable. This will ensure that the PHY remains operational under all > conditions. > > Signed-off-by: Udipto Goswami > --- > drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c | 121 +++++++++++++++++- > 1 file changed, 114 insertions(+), 7 deletions(-) > > diff --git a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c > index eb0b0f61d98e..cbe9cdaa6849 100644 > --- a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c > +++ b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c > @@ -78,11 +78,39 @@ > > #define LS_FS_OUTPUT_IMPEDANCE_MASK GENMASK(3, 0) > > -static const char * const qcom_snps_hsphy_vreg_names[] = { > - "vdda-pll", "vdda33", "vdda18", > + > +struct qcom_snps_hsphy_regulator_data { > + const char *name; > + unsigned int enable_load; > + unsigned int min_voltage; > + unsigned int max_voltage; > +}; > + > +static const struct qcom_snps_hsphy_regulator_data hsphy_vreg_l[] = { > + { > + .name = "vdda-pll", > + .enable_load = 30000, > + .min_voltage = 825000, > + .max_voltage = 925000, > + }, > + > + { > + .name = "vdda18", > + .enable_load = 19000, > + .min_voltage = 1704000, > + .max_voltage = 1800000 > + }, > + > + { > + .name = "vdda33", > + .enable_load = 16000, > + .min_voltage = 3050000, > + .max_voltage = 3300000 > + }, > + > }; > > -#define SNPS_HS_NUM_VREGS ARRAY_SIZE(qcom_snps_hsphy_vreg_names) > +#define SNPS_HS_NUM_VREGS ARRAY_SIZE(hsphy_vreg_l) > > struct override_param { > s32 value; > @@ -132,12 +160,90 @@ struct qcom_snps_hsphy { > struct clk_bulk_data *clks; > struct reset_control *phy_reset; > struct regulator_bulk_data vregs[SNPS_HS_NUM_VREGS]; > + const struct qcom_snps_hsphy_regulator_data *vreg_list; > > bool phy_initialized; > enum phy_mode mode; > struct phy_override_seq update_seq_cfg[NUM_HSPHY_TUNING_PARAMS]; > }; > > +static int __vdda_phy_bulk_enable_disable(struct qcom_snps_hsphy *hsphy, bool on) Separate functions, please. > +{ > + int ret = 0; > + int i; > + > + if (!on) > + goto disable_vdd; > + > + for (i = 0; i < SNPS_HS_NUM_VREGS; i++) { > + > + ret = regulator_set_load(hsphy->vregs[i].consumer, > + hsphy->vreg_list[i].enable_load); > + > + if (ret < 0) { > + dev_err(hsphy->dev, "unable to set HPM of %s %d\n", > + hsphy->vregs[i].supply, ret); > + goto err_vdd; > + } > + } > + > + for (i = 0; i < SNPS_HS_NUM_VREGS; i++) { > + ret = regulator_set_voltage(hsphy->vregs[i].consumer, > + hsphy->vreg_list[i].min_voltage, > + hsphy->vreg_list[i].max_voltage); > + if (ret) { > + dev_err(hsphy->dev, > + "unable to set voltage of regulator %s %d\n", > + hsphy->vregs[i].supply, ret); > + goto put_vdd_lpm; > + } > + } > + > + ret = regulator_bulk_enable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs); > + if (ret) > + goto unconfig_vdd; > + > + return ret; > + > +disable_vdd: > + regulator_bulk_disable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs); > + > +unconfig_vdd: > + for (i = 0; i < SNPS_HS_NUM_VREGS; i++) { > + ret = regulator_set_voltage(hsphy->vregs[i].consumer, 0, > + hsphy->vreg_list[i].max_voltage); > + if (ret) { > + dev_err(hsphy->dev, > + "unable to set voltage of regulator %s %d\n", > + hsphy->vregs[i].supply, ret); > + } > + } > + > +put_vdd_lpm: > + for (i = 0; i < SNPS_HS_NUM_VREGS; i++) { > + ret = regulator_set_load(hsphy->vregs[i].consumer, 0); > + > + if (ret < 0) { > + dev_err(hsphy->dev, "unable to set LPM of %s %d\n", > + hsphy->vregs[i].supply, ret); > + } > + } > + > +err_vdd: > + return ret; > + > +} > + > +static int vdda_phy_bulk_enable(struct qcom_snps_hsphy *hsphy) > +{ > + return __vdda_phy_bulk_enable_disable(hsphy, true); > +} > + > +static int vdda_phy_bulk_disable(struct qcom_snps_hsphy *hsphy) > +{ > + return __vdda_phy_bulk_enable_disable(hsphy, false); > +} > + > static int qcom_snps_hsphy_clk_init(struct qcom_snps_hsphy *hsphy) > { > struct device *dev = hsphy->dev; > @@ -390,7 +496,7 @@ static int qcom_snps_hsphy_init(struct phy *phy) > > dev_vdbg(&phy->dev, "%s(): Initializing SNPS HS phy\n", __func__); > > - ret = regulator_bulk_enable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs); > + ret = vdda_phy_bulk_enable(hsphy); > if (ret) > return ret; > > @@ -471,7 +577,7 @@ static int qcom_snps_hsphy_init(struct phy *phy) > disable_clks: > clk_bulk_disable_unprepare(hsphy->num_clks, hsphy->clks); > poweroff_phy: > - regulator_bulk_disable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs); > + ret = vdda_phy_bulk_disable(hsphy); > > return ret; > } > @@ -482,7 +588,7 @@ static int qcom_snps_hsphy_exit(struct phy *phy) > > reset_control_assert(hsphy->phy_reset); > clk_bulk_disable_unprepare(hsphy->num_clks, hsphy->clks); > - regulator_bulk_disable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs); > + vdda_phy_bulk_disable(hsphy); > hsphy->phy_initialized = false; > > return 0; > @@ -592,8 +698,9 @@ static int qcom_snps_hsphy_probe(struct platform_device *pdev) > > num = ARRAY_SIZE(hsphy->vregs); > for (i = 0; i < num; i++) > - hsphy->vregs[i].supply = qcom_snps_hsphy_vreg_names[i]; > + hsphy->vregs[i].supply = hsphy_vreg_l[i].name; > > + hsphy->vreg_list = hsphy_vreg_l; > ret = devm_regulator_bulk_get(dev, num, hsphy->vregs); > if (ret) > return dev_err_probe(dev, ret, > -- > 2.17.1 > > -- With best wishes Dmitry