From nobody Tue Nov 26 13:20:42 2024 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 2D3E918CBF1 for ; Fri, 18 Oct 2024 12:49:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729255786; cv=none; b=JthCI3DvkLmLugsD/Gffm5eR8dfo9lOUkex8Y3Z2rrx3q4kPaAi2N6IPIXoehrjRCo0AT3SmFvg7HT6UISDEwjO6gQN7nCqEZgzb7Dryuf7OGq4gwhlLHdo6iprvuiR1QUNs7JTCd2KYaH7B8IDZQDz9GzhD4mqcFRNGbDPohTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729255786; c=relaxed/simple; bh=hjSlU2gxSWCop+hBvftwzPuKHq8KM6fyKWuyNw14hJ4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Yrq5YMnCgOpjQhBZEscsw7S8P3F3bIof7ZfZbEWytlNXqhh6e5i/0Up9bsqGMJJc/OYQlLFgNeUx8EfrP9ImcTEY56jRPZWGxKiAKr4ia96yc5aAQTQfX+w7Lcy+i3r23ShIHET8CW1sDFgiDvwiENKGGjjiubnp2jDJmZaBFdM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=ml+tP7aD; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="ml+tP7aD" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4314c4cb752so21001015e9.2 for ; Fri, 18 Oct 2024 05:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1729255780; x=1729860580; 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=sPRs0w0MxEGgnxDO7g24yPQwpAr5gvzr/mzcIR+fDQg=; b=ml+tP7aD5KA4obM4sOjmiz0qjNwVYxs1h224sElAXTVlrMc+fjfawXnkl8Uc5wzhap FyDSOkQkjcVzkkICWLD8Lw0C1MUATtEMevbNE4nXiyQ+gg4aqWX6ItSP7AML3dqdsNBM U0UoZD4JPxGPhTN9uWWJMa6ukOCo+JpQVt4vmbrob5NwY+/AQiSKrvmELf0FlE+xCHD+ p6Dg6WPDKXMmnecS3zLZEx4hGfaAqpqeGZPMOYHOvJmFV5aeuOb3eE2tNiqB5NoLoNE7 6f+yvKoOjJZbXjVxdT2UECnBTLlZJBMpFeNo76lKlvUKsJvyeuq8NlXw9/gpshexi0IO Y63A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729255780; x=1729860580; 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=sPRs0w0MxEGgnxDO7g24yPQwpAr5gvzr/mzcIR+fDQg=; b=qeFMXiT63Mld9iObFl5hEYAwQ60+VsbVCPrAgZoUtAJ430HjQ3Nd0l9AabXH7AjDKs sqN9aTXwTvFD3eJqYmqGYhmhS+6H8IL/6yvVJmT9OVp0F0IYD/l6/LuB89YAkpPGmvuH FVf1vkMRg77f/JQQ6qx4gCusHg2dDC9BX1SAt6UvK37DAFUoHjGrEbw/TQ32CjGqy4LE 65p4eUVQ/qSRynz4yr68jCY1gcAf3Y+OKaIpLsNnWwhT5wV0nqW1nYiBADc48UXGhYWs N7SeHWklcR+3LvKcYIwCO6Y8ezqSAahhfIFYgCT78voeXQolEjBcAkYREUnUWTvndBiX q92w== X-Forwarded-Encrypted: i=1; AJvYcCW/NU7rGTGI0m2ZO8Mg3n2sQIsEQ9ANPS/eO6erp/TbLlYhX59q0MPiZf33ghH4Pv4N+duSPZ0urOGnOAE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxpc25besN9aNivq9Vb+71SolTkxiwvJSz88fe77mOnyTPy3GYB Egu5jMuSCwELTj4ILpgl3uMsqQsbGC6S7/HEdSAig+4il7xjvN8q54pgAG9XjTI= X-Google-Smtp-Source: AGHT+IEIqw8kUmJihhMwDgPJitdV2JACtgTL4TNLOBjhAV3udeTjvvchkzKbUkVpGd6jNrhJYTpzbg== X-Received: by 2002:a05:600c:46c6:b0:42c:b220:4778 with SMTP id 5b1f17b1804b1-4316169127dmr18151415e9.33.1729255780398; Fri, 18 Oct 2024 05:49:40 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:45a3:93e:5196:d8ce]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43160695d8fsm26640835e9.27.2024.10.18.05.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 05:49:39 -0700 (PDT) From: Bartosz Golaszewski Date: Fri, 18 Oct 2024 14:49:12 +0200 Subject: [PATCH v6 2/6] power: sequencing: qcom-wcn: improve support for wcn6855 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241018-sc8280xp-pwrseq-v6-2-8da8310d9564@linaro.org> References: <20241018-sc8280xp-pwrseq-v6-0-8da8310d9564@linaro.org> In-Reply-To: <20241018-sc8280xp-pwrseq-v6-0-8da8310d9564@linaro.org> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bartosz Golaszewski , Bjorn Andersson , Konrad Dybcio , Johan Hovold , Kalle Valo , Dmitry Baryshkov , Abel Vesa , Manivannan Sadhasivam Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6994; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=wVgH0vy0LFJruCxGn7HHmD4PkWROab2fVJIQAlt3CXs=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnEllfsBsZmyRrH2pE5TQOodqN6VXrIyUAgK/g/ 9eUResIs22JAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZxJZXwAKCRARpy6gFHHX csEbD/9s1CuSb8y7vzkO3hEQvtki5RwrD/clMXivveK+FJM0HtjKoBFKACCorQwUOgO8Q1XwRfq lNAnxYdBCxwWxjvD0YpRTrxd3iTR02vO+iAPoTAa8L79c+/Ee1H+4aeu9CjzlxQSiLbeH1eFi0o bk2lRh4fbRXs74wV2OaMgHVtJMPFWJvD87nVihzua17MO15cF9JeCUMw1zUhsZu6nJs5STyp2pE kWdUd9BE0XCqEg6WiqZcwyHL5XamvFCH7m6eY2tyOTMpCQ4vWGV18X605S8BAWRNP4G5JloMbvV vf6Dwg2Ug7dTApd1ciVgsNbrJt0aYFr8ogTdtzKCFAwB7d87BsjKJfisUwIzBoZUmMUNKev2vZY g9DjkZ3iMTcYQbBgs8TK7I5H9zORYh9mMeK3rcco+dml6hzhYvZuPhbi+CmFhe/ApOzSXia+h0l TR5YuL0tqU8XYNmxM930Vdz5myAWFx7os8d4D/V3QbsQz1ovn64umdCdsE2U64LejuGES8f3g5u ZaTKpOyj/Zlg0D51DjYVUvKLMdzgQHTvhyVbX1ndFTNXpn+njABx6iDAEuh+/jyF2nN5khs8k2h R8Eb6knpNu+REUIqtXRWaxKeQgd2W1nCqBMviwjD2moNcqySo3nc2vN4Q/dn9x9tkI7qFfQvT7w qi0ba9tYsZPBmdA== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski WCN6855 (also known as QCA6490) is similar to the already supported QCA6390 but takes in two more supplies so add a new vregs list for it. On sm8450-hdk it also requires a short assert of the xo-clk pin so add handling for it in a dedicated unit. As we now have a separate set of targets for this variant, store the pointer to the targets struct associated with a model in the device match data. Signed-off-by: Bartosz Golaszewski Reviewed-by: Dmitry Baryshkov --- drivers/power/sequencing/pwrseq-qcom-wcn.c | 101 +++++++++++++++++++++++++= +++- 1 file changed, 98 insertions(+), 3 deletions(-) diff --git a/drivers/power/sequencing/pwrseq-qcom-wcn.c b/drivers/power/seq= uencing/pwrseq-qcom-wcn.c index 4fa129877d7e..682a9beac69e 100644 --- a/drivers/power/sequencing/pwrseq-qcom-wcn.c +++ b/drivers/power/sequencing/pwrseq-qcom-wcn.c @@ -22,6 +22,7 @@ struct pwrseq_qcom_wcn_pdata { size_t num_vregs; unsigned int pwup_delay_ms; unsigned int gpio_enable_delay_ms; + const struct pwrseq_target_data **targets; }; =20 struct pwrseq_qcom_wcn_ctx { @@ -31,6 +32,7 @@ struct pwrseq_qcom_wcn_ctx { struct regulator_bulk_data *regs; struct gpio_desc *bt_gpio; struct gpio_desc *wlan_gpio; + struct gpio_desc *xo_clk_gpio; struct clk *clk; unsigned long last_gpio_enable_jf; }; @@ -98,6 +100,33 @@ static const struct pwrseq_unit_data *pwrseq_qcom_wcn_u= nit_deps[] =3D { NULL }; =20 +static int pwrseq_qcom_wcn6855_clk_assert(struct pwrseq_device *pwrseq) +{ + struct pwrseq_qcom_wcn_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); + + if (!ctx->xo_clk_gpio) + return 0; + + msleep(1); + + gpiod_set_value_cansleep(ctx->xo_clk_gpio, 1); + usleep_range(100, 200); + + return 0; +} + +static const struct pwrseq_unit_data pwrseq_qcom_wcn6855_xo_clk_assert =3D= { + .name =3D "xo-clk-assert", + .enable =3D pwrseq_qcom_wcn6855_clk_assert, +}; + +static const struct pwrseq_unit_data *pwrseq_qcom_wcn6855_unit_deps[] =3D { + &pwrseq_qcom_wcn_vregs_unit_data, + &pwrseq_qcom_wcn_clk_unit_data, + &pwrseq_qcom_wcn6855_xo_clk_assert, + NULL +}; + static int pwrseq_qcom_wcn_bt_enable(struct pwrseq_device *pwrseq) { struct pwrseq_qcom_wcn_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); @@ -125,6 +154,13 @@ static const struct pwrseq_unit_data pwrseq_qcom_wcn_b= t_unit_data =3D { .disable =3D pwrseq_qcom_wcn_bt_disable, }; =20 +static const struct pwrseq_unit_data pwrseq_qcom_wcn6855_bt_unit_data =3D { + .name =3D "wlan-enable", + .deps =3D pwrseq_qcom_wcn6855_unit_deps, + .enable =3D pwrseq_qcom_wcn_bt_enable, + .disable =3D pwrseq_qcom_wcn_bt_disable, +}; + static int pwrseq_qcom_wcn_wlan_enable(struct pwrseq_device *pwrseq) { struct pwrseq_qcom_wcn_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); @@ -152,6 +188,13 @@ static const struct pwrseq_unit_data pwrseq_qcom_wcn_w= lan_unit_data =3D { .disable =3D pwrseq_qcom_wcn_wlan_disable, }; =20 +static const struct pwrseq_unit_data pwrseq_qcom_wcn6855_wlan_unit_data = =3D { + .name =3D "wlan-enable", + .deps =3D pwrseq_qcom_wcn6855_unit_deps, + .enable =3D pwrseq_qcom_wcn_wlan_enable, + .disable =3D pwrseq_qcom_wcn_wlan_disable, +}; + static int pwrseq_qcom_wcn_pwup_delay(struct pwrseq_device *pwrseq) { struct pwrseq_qcom_wcn_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); @@ -162,6 +205,18 @@ static int pwrseq_qcom_wcn_pwup_delay(struct pwrseq_de= vice *pwrseq) return 0; } =20 +static int pwrseq_qcom_wcn6855_xo_clk_deassert(struct pwrseq_device *pwrse= q) +{ + struct pwrseq_qcom_wcn_ctx *ctx =3D pwrseq_device_get_drvdata(pwrseq); + + if (ctx->xo_clk_gpio) { + usleep_range(2000, 5000); + gpiod_set_value_cansleep(ctx->xo_clk_gpio, 0); + } + + return pwrseq_qcom_wcn_pwup_delay(pwrseq); +} + static const struct pwrseq_target_data pwrseq_qcom_wcn_bt_target_data =3D { .name =3D "bluetooth", .unit =3D &pwrseq_qcom_wcn_bt_unit_data, @@ -174,12 +229,30 @@ static const struct pwrseq_target_data pwrseq_qcom_wc= n_wlan_target_data =3D { .post_enable =3D pwrseq_qcom_wcn_pwup_delay, }; =20 +static const struct pwrseq_target_data pwrseq_qcom_wcn6855_bt_target_data = =3D { + .name =3D "bluetooth", + .unit =3D &pwrseq_qcom_wcn6855_bt_unit_data, + .post_enable =3D pwrseq_qcom_wcn6855_xo_clk_deassert, +}; + +static const struct pwrseq_target_data pwrseq_qcom_wcn6855_wlan_target_dat= a =3D { + .name =3D "wlan", + .unit =3D &pwrseq_qcom_wcn6855_wlan_unit_data, + .post_enable =3D pwrseq_qcom_wcn6855_xo_clk_deassert, +}; + static const struct pwrseq_target_data *pwrseq_qcom_wcn_targets[] =3D { &pwrseq_qcom_wcn_bt_target_data, &pwrseq_qcom_wcn_wlan_target_data, NULL }; =20 +static const struct pwrseq_target_data *pwrseq_qcom_wcn6855_targets[] =3D { + &pwrseq_qcom_wcn6855_bt_target_data, + &pwrseq_qcom_wcn6855_wlan_target_data, + NULL +}; + static const char *const pwrseq_qca6390_vregs[] =3D { "vddio", "vddaon", @@ -196,13 +269,28 @@ static const struct pwrseq_qcom_wcn_pdata pwrseq_qca6= 390_of_data =3D { .num_vregs =3D ARRAY_SIZE(pwrseq_qca6390_vregs), .pwup_delay_ms =3D 60, .gpio_enable_delay_ms =3D 100, + .targets =3D pwrseq_qcom_wcn_targets, +}; + +static const char *const pwrseq_wcn6855_vregs[] =3D { + "vddio", + "vddaon", + "vddpmu", + "vddpmumx", + "vddpmucx", + "vddrfa0p95", + "vddrfa1p3", + "vddrfa1p9", + "vddpcie1p3", + "vddpcie1p9", }; =20 static const struct pwrseq_qcom_wcn_pdata pwrseq_wcn6855_of_data =3D { - .vregs =3D pwrseq_qca6390_vregs, - .num_vregs =3D ARRAY_SIZE(pwrseq_qca6390_vregs), + .vregs =3D pwrseq_wcn6855_vregs, + .num_vregs =3D ARRAY_SIZE(pwrseq_wcn6855_vregs), .pwup_delay_ms =3D 50, .gpio_enable_delay_ms =3D 5, + .targets =3D pwrseq_qcom_wcn6855_targets, }; =20 static const char *const pwrseq_wcn7850_vregs[] =3D { @@ -219,6 +307,7 @@ static const struct pwrseq_qcom_wcn_pdata pwrseq_wcn785= 0_of_data =3D { .vregs =3D pwrseq_wcn7850_vregs, .num_vregs =3D ARRAY_SIZE(pwrseq_wcn7850_vregs), .pwup_delay_ms =3D 50, + .targets =3D pwrseq_qcom_wcn_targets, }; =20 static int pwrseq_qcom_wcn_match(struct pwrseq_device *pwrseq, @@ -295,6 +384,12 @@ static int pwrseq_qcom_wcn_probe(struct platform_devic= e *pdev) return dev_err_probe(dev, PTR_ERR(ctx->wlan_gpio), "Failed to get the WLAN enable GPIO\n"); =20 + ctx->xo_clk_gpio =3D devm_gpiod_get_optional(dev, "xo-clk", + GPIOD_OUT_LOW); + if (IS_ERR(ctx->xo_clk_gpio)) + return dev_err_probe(dev, PTR_ERR(ctx->xo_clk_gpio), + "Failed to get the XO_CLK GPIO\n"); + /* * Set direction to output but keep the current value in order to not * disable the WLAN module accidentally if it's already powered on. @@ -313,7 +408,7 @@ static int pwrseq_qcom_wcn_probe(struct platform_device= *pdev) config.owner =3D THIS_MODULE; config.drvdata =3D ctx; config.match =3D pwrseq_qcom_wcn_match; - config.targets =3D pwrseq_qcom_wcn_targets; + config.targets =3D ctx->pdata->targets; =20 ctx->pwrseq =3D devm_pwrseq_device_register(dev, &config); if (IS_ERR(ctx->pwrseq)) --=20 2.43.0