From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Lee Jones <lee@kernel.org>, Daniel Thompson <danielt@kernel.org>,
Jingoo Han <jingoohan1@gmail.com>, Helge Deller <deller@gmx.de>,
Kiran Gunda <quic_kgunda@quicinc.com>,
Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Abel Vesa <abelvesa@kernel.org>,
Dmitry Baryshkov <lumag@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, mfd@lists.linux.dev
Subject: Re: [PATCH v2 4/8] regulator: add Qualcomm LCDB driver
Date: Mon, 19 Oct 2026 13:59:54 +0200 [thread overview]
Message-ID: <0829d45e-a55a-43f6-a9f3-f445337fa00f@oss.qualcomm.com> (raw)
In-Reply-To: <20261019-sm8150-display-card-v2-4-86c05068efc5@oss.qualcomm.com>
On 10/19/26 1:25 PM, Dmitry Baryshkov wrote:
> LCD panels on boards with PMI632, PM6150L or PM8150L take their bias
> rails from the LCDB block. Without a driver they only work as long as
> the bootloader has enabled it and nothing turns it off.
[...]
> +static bool qcom_lcdb_handle_sc(struct qcom_lcdb *lcdb)
> +{
> + guard(mutex)(&lcdb->lock);
> +
> + if (!lcdb->enabled_mask || lcdb->sc_disabled)
> + return false;
> +
> + qcom_lcdb_module_disable(lcdb);
> +
> + if (ktime_us_delta(ktime_get(), lcdb->sc_time) > LCDB_SC_RESET_CNT_DLY_US) {
> + lcdb->sc_count = 0;
> + } else if (lcdb->sc_count > LCDB_SC_CNT_MAX) {
> + dev_err(lcdb->dev, "persistent short circuit, keeping the outputs off\n");
> + lcdb->sc_disabled = true;
> + return true;
> + }
> +
> + lcdb->sc_count++;
> + lcdb->sc_time = ktime_get();
GPT:
The commit message says to restart up to ten times within one second,
but sc_time is updated on every fault.
Konrad
> +
> + if (qcom_lcdb_module_enable(lcdb)) {
> + dev_err(lcdb->dev, "failed to recover from a short circuit\n");
> + lcdb->sc_disabled = true;
> + return true;
> + }
> +
> + return false;
> +}
> +
> +static irqreturn_t qcom_lcdb_sc_irq(int irq, void *data)
> +{
> + struct qcom_lcdb *lcdb = data;
> + unsigned int val;
> + int ret, i;
> +
> + ret = regmap_read(lcdb->regmap, lcdb->base + LCDB_INT_RT_STS, &val);
> + if (ret || !(val & LCDB_SC_ERROR_RT_STS))
> + return IRQ_HANDLED;
> +
> + /* Blanking time, a real short circuit is still reported afterwards */
> + usleep_range(2000, 2100);
> +
> + ret = regmap_read(lcdb->regmap, lcdb->base + LCDB_INT_RT_STS, &val);
> + if (ret || !(val & LCDB_SC_ERROR_RT_STS))
> + return IRQ_HANDLED;
> +
> + if (qcom_lcdb_handle_sc(lcdb)) {
> + for (i = 0; i < LCDB_NUM_RAILS; i++)
> + regulator_notifier_call_chain(lcdb->rdev[i],
> + REGULATOR_EVENT_FAIL, NULL);
> + }
> +
> + return IRQ_HANDLED;
> +}
> +
> +static int qcom_lcdb_hw_init(struct qcom_lcdb *lcdb)
> +{
> + unsigned int val;
> + int ret, i;
> +
> + for (i = 0; i < LCDB_NUM_RAILS; i++) {
> + ret = regmap_read(lcdb->regmap, lcdb->base + qcom_lcdb_vreg[i], &val);
> + if (ret)
> + return ret;
> +
> + lcdb->uV[i] = qcom_lcdb_sel_to_uV(val & LCDB_OUTPUT_VOLTAGE_MASK);
> + }
> +
> + ret = regmap_read(lcdb->regmap, lcdb->base + LCDB_ENABLE_CTL1, &val);
> + if (ret)
> + return ret;
> +
> + if (val & LCDB_MODULE_EN) {
> + lcdb->enabled_mask = GENMASK(LCDB_NUM_RAILS - 1, 0);
> + return 0;
> + }
> +
> + return regmap_set_bits(lcdb->regmap, lcdb->base + LCDB_MODULE_RDY,
> + LCDB_MODULE_RDY_BIT);
> +}
> +
> +static int qcom_lcdb_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct regulator_config cfg = {};
> + struct qcom_lcdb *lcdb;
> + int irq, ret, i;
> +
> + lcdb = devm_kzalloc(dev, sizeof(*lcdb), GFP_KERNEL);
> + if (!lcdb)
> + return -ENOMEM;
> +
> + lcdb->dev = dev;
> +
> + lcdb->regmap = dev_get_regmap(dev->parent, NULL);
> + if (!lcdb->regmap)
> + return dev_err_probe(dev, -ENODEV, "failed to get the parent regmap\n");
> +
> + ret = device_property_read_u32(dev, "reg", &lcdb->base);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to get the base address\n");
> +
> + ret = devm_mutex_init(dev, &lcdb->lock);
> + if (ret)
> + return ret;
> +
> + ret = qcom_lcdb_hw_init(lcdb);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to read the initial state\n");
> +
> + cfg.dev = dev;
> + cfg.regmap = lcdb->regmap;
> + cfg.driver_data = lcdb;
> +
> + for (i = 0; i < LCDB_NUM_RAILS; i++) {
> + lcdb->rdev[i] = devm_regulator_register(dev, &qcom_lcdb_descs[i], &cfg);
> + if (IS_ERR(lcdb->rdev[i]))
> + return dev_err_probe(dev, PTR_ERR(lcdb->rdev[i]),
> + "failed to register %s\n",
> + qcom_lcdb_descs[i].name);
> + }
> +
> + irq = platform_get_irq(pdev, 0);
> + if (irq < 0)
> + return irq;
> +
> + return devm_request_threaded_irq(dev, irq, NULL, qcom_lcdb_sc_irq,
> + IRQF_ONESHOT, "lcdb-sc", lcdb);
> +}
> +
> +static const struct of_device_id qcom_lcdb_match[] = {
> + { .compatible = "qcom,pm8150l-lcdb" },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, qcom_lcdb_match);
> +
> +static struct platform_driver qcom_lcdb_driver = {
> + .driver = {
> + .name = "qcom-lcdb-regulator",
> + .of_match_table = qcom_lcdb_match,
> + },
> + .probe = qcom_lcdb_probe,
> +};
> +module_platform_driver(qcom_lcdb_driver);
> +
> +MODULE_DESCRIPTION("Qualcomm LCDB (LCD bias) regulator driver");
> +MODULE_LICENSE("GPL");
>
next prev parent reply other threads:[~2026-10-19 12:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 11:25 [PATCH v2 0/8] arm64: qcom: enable display card support on SM8150 HDK Dmitry Baryshkov
2026-10-19 11:25 ` [PATCH v2 1/8] backlight: qcom-wled: fix string detection brightness on WLED5 Dmitry Baryshkov
2026-10-19 11:25 ` [PATCH v2 2/8] regulator: dt-bindings: add Qualcomm LCDB regulator Dmitry Baryshkov
2026-10-19 11:25 ` [PATCH v2 3/8] dt-bindings: mfd: qcom,spmi-pmic: add LCDB Dmitry Baryshkov
2026-10-19 11:25 ` [PATCH v2 4/8] regulator: add Qualcomm LCDB driver Dmitry Baryshkov
2026-10-19 11:59 ` Konrad Dybcio [this message]
2026-10-19 11:25 ` [PATCH v2 5/8] arm64: dts: qcom: pm8150l: add LCDB regulators Dmitry Baryshkov
2026-10-19 11:47 ` Abel Vesa
2026-10-19 11:48 ` Konrad Dybcio
2026-10-19 11:25 ` [PATCH v2 6/8] arm64: dts: qcom: sm8150: add MDSS reset Dmitry Baryshkov
2026-10-19 11:46 ` Abel Vesa
2026-10-19 11:25 ` [PATCH v2 7/8] arm64: dts: qcom: sm8150-hdk: fix FSA4480 address Dmitry Baryshkov
2026-10-19 11:46 ` Abel Vesa
2026-10-19 11:25 ` [PATCH v2 8/8] arm64: dts: qcom: sm8150-hdk: add display card overlay Dmitry Baryshkov
2026-10-19 11:47 ` Konrad Dybcio
2026-10-19 11:47 ` Abel Vesa
2026-10-19 11:32 ` [PATCH v2 0/8] arm64: qcom: enable display card support on SM8150 HDK Konrad Dybcio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0829d45e-a55a-43f6-a9f3-f445337fa00f@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=danielt@kernel.org \
--cc=deller@gmx.de \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jingoohan1@gmail.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lumag@kernel.org \
--cc=mfd@lists.linux.dev \
--cc=quic_kgunda@quicinc.com \
--cc=quic_subbaram@quicinc.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox