From: Abhash Kumar Jha <a-kumar2@ti.com>
To: <andrzej.hajda@intel.com>, <neil.armstrong@linaro.org>,
<rfoss@kernel.org>, <mripard@kernel.org>, <tzimmermann@suse.de>,
<airlied@gmail.com>, <simona@ffwll.ch>, <devarsht@ti.com>,
<u-kumar1@ti.com>, <sjakhade@cadence.com>
Cc: <linux-kernel@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
<Laurent.pinchart@ideasonboard.com>, <jonas@kwiboo.se>,
<jernej.skrabec@gmail.com>, <s-jain1@ti.com>, <y-d@ti.com>,
<tomi.valkeinen@ideasonboard.com>, <benjamin.robin@bootlin.com>
Subject: [PATCH v4] drm/bridge: cdns-mhdp8546: Add suspend resume support to the bridge driver
Date: Thu, 26 Nov 2026 11:35:32 +0530 [thread overview]
Message-ID: <20261126060532.2379444-1-a-kumar2@ti.com> (raw)
Add system suspend and resume hooks to the cdns-mhdp8546 bridge driver.
While resuming we either load the firmware or activate it. Firmware
is loaded only when resuming from a successful suspend-resume cycle.
If resuming due to an aborted suspend, loading the firmware is not
possible because the uCPU's IMEM is only accessible after a reset and the
bridge has not gone through a reset in this case. Hence, activate the
firmware that is already loaded.
Use the KEEP_ALIVE register to determine if there is a firmware already
running or not and load the FW accordingly.
Signed-off-by: Abhash Kumar Jha <a-kumar2@ti.com>
---
Hi,
Changes in v4:
- Use LATE_SYSTEM_SLEEP_PM_OPS for the pm_ops.
- Replace genpd_notifier callback with reading the KEEP_ALIVE register
to determine if FW is already running in the bridge
- Link to v3: https://lore.kernel.org/all/20260601095041.3042950-1-a-kumar2@ti.com/
Changes in v3:
- Register genpd_notifier callback only when genpd is available.
- Mark mhdp->powered_off = false after resume is successful.
- Use SIMPLE_DEV_PM_OPS instead of SET_SYSTEM_SLEEP_PM_OPS.
- Set mhdp->hw_state appropriately in error paths.
- Link to v2: https://lore.kernel.org/all/20260205085233.81678-1-a-kumar2@ti.com/
Changes in v2:
- Fixed defined but not used [-Wunused-function] warning for suspend and resume calls.
- Link to v1: https://lore.kernel.org/all/20260129112016.2448037-1-a-kumar2@ti.com/
Thanks and Regards,
Abhash
.../drm/bridge/cadence/cdns-mhdp8546-core.c | 121 +++++++++++++++++-
1 file changed, 120 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index cdee05380fd29..4b0f51b309505 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -12,7 +12,6 @@
*
* TODO:
* - Implement optimized mailbox communication using mailbox interrupts
- * - Add support for power management
* - Add support for features like audio, MST and fast link training
* - Implement request_fw_cancel to handle HW_STATE
* - Fix asynchronous loading of firmware implementation
@@ -2287,6 +2286,125 @@ static void cdns_mhdp_hpd_work(struct work_struct *work)
drm_bridge_hpd_notify(&mhdp->bridge, cdns_mhdp_detect(mhdp));
}
+static int cdns_mhdp_resume(struct device *dev)
+{
+ struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
+ unsigned int keep_alive, keep_alive_inc;
+ unsigned long rate;
+ int ret;
+
+ ret = clk_prepare_enable(mhdp->clk);
+ if (ret)
+ return ret;
+
+ rate = clk_get_rate(mhdp->clk);
+ writel(rate % 1000000, mhdp->regs + CDNS_SW_CLK_L);
+ writel(rate / 1000000, mhdp->regs + CDNS_SW_CLK_H);
+ writel(~0, mhdp->regs + CDNS_APB_INT_MASK);
+
+ ret = phy_init(mhdp->phy);
+ if (ret) {
+ dev_err(mhdp->dev, "Failed to initialize PHY: %d\n", ret);
+ goto disable_clk;
+ }
+ ret = phy_power_on(mhdp->phy);
+ if (ret < 0) {
+ dev_err(mhdp->dev, "Failed to power on PHY: %d\n", ret);
+ goto phy_exit;
+ }
+
+ /*
+ * The KEEP_ALIVE register is incremented at every scheduler loop of the
+ * firmware. If it changes between reads, the firmware is still running
+ * (e.g. the suspend was aborted) and only needs to be activated. If it
+ * does not change, the bridge lost power and the firmware must be loaded
+ * again.
+ */
+ keep_alive = readl(mhdp->regs + CDNS_KEEP_ALIVE) & CDNS_KEEP_ALIVE_MASK;
+ ret = readl_poll_timeout(mhdp->regs + CDNS_KEEP_ALIVE, keep_alive_inc,
+ (keep_alive_inc & CDNS_KEEP_ALIVE_MASK) != keep_alive,
+ 2000, 2 * CDNS_KEEP_ALIVE_TIMEOUT);
+ if (ret) {
+ ret = cdns_mhdp_load_firmware(mhdp);
+ if (ret)
+ goto phy_off;
+
+ ret = wait_event_timeout(mhdp->fw_load_wq,
+ mhdp->hw_state == MHDP_HW_READY,
+ msecs_to_jiffies(1000));
+ if (ret == 0) {
+ dev_err(mhdp->dev, "%s: Timeout waiting for fw loading\n",
+ __func__);
+ ret = -ETIMEDOUT;
+ goto phy_off;
+ }
+ } else {
+ ret = cdns_mhdp_set_firmware_active(mhdp, true);
+ if (ret) {
+ dev_err(mhdp->dev, "Failed to activate firmware (%pe)\n",
+ ERR_PTR(ret));
+ goto phy_off;
+ }
+
+ spin_lock(&mhdp->start_lock);
+ mhdp->hw_state = MHDP_HW_READY;
+ if (!mhdp->no_hpd)
+ cdns_mhdp_bridge_hpd_enable(&mhdp->bridge);
+ spin_unlock(&mhdp->start_lock);
+ }
+
+ return 0;
+
+phy_off:
+ phy_power_off(mhdp->phy);
+phy_exit:
+ phy_exit(mhdp->phy);
+disable_clk:
+ clk_disable_unprepare(mhdp->clk);
+
+ return ret;
+}
+
+static int cdns_mhdp_suspend(struct device *dev)
+{
+ struct cdns_mhdp_device *mhdp = dev_get_drvdata(dev);
+ unsigned long timeout = msecs_to_jiffies(100);
+ int ret;
+
+ cancel_work_sync(&mhdp->hpd_work);
+
+ ret = wait_event_timeout(mhdp->fw_load_wq,
+ mhdp->hw_state == MHDP_HW_READY,
+ timeout);
+ if (ret == 0) {
+ dev_err(mhdp->dev, "%s: Timeout waiting for fw loading\n", __func__);
+ return -ETIMEDOUT;
+ }
+
+ spin_lock(&mhdp->start_lock);
+ mhdp->hw_state = MHDP_HW_STOPPED;
+ spin_unlock(&mhdp->start_lock);
+
+ ret = cdns_mhdp_set_firmware_active(mhdp, false);
+ if (ret) {
+ dev_err(mhdp->dev, "Failed to stop firmware (%pe)\n", ERR_PTR(ret));
+ spin_lock(&mhdp->start_lock);
+ mhdp->hw_state = MHDP_HW_READY;
+ spin_unlock(&mhdp->start_lock);
+ return ret;
+ }
+
+ phy_power_off(mhdp->phy);
+ phy_exit(mhdp->phy);
+ clk_disable_unprepare(mhdp->clk);
+
+ return 0;
+}
+
+static const struct dev_pm_ops cdns_mhdp_pm_ops = {
+ LATE_SYSTEM_SLEEP_PM_OPS(cdns_mhdp_suspend, cdns_mhdp_resume)
+};
+
static int cdns_mhdp_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -2497,6 +2615,7 @@ static struct platform_driver mhdp_driver = {
.driver = {
.name = "cdns-mhdp8546",
.of_match_table = mhdp_ids,
+ .pm = pm_sleep_ptr(&cdns_mhdp_pm_ops),
},
.probe = cdns_mhdp_probe,
.remove = cdns_mhdp_remove,
--
2.34.1
next reply other threads:[~2026-11-26 6:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 6:05 Abhash Kumar Jha [this message]
2026-11-26 6:21 ` [PATCH v4] drm/bridge: cdns-mhdp8546: Add suspend resume support to the bridge driver sashiko-bot
2026-11-26 12:46 ` kernel test robot
2026-11-26 16:44 ` kernel test robot
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=20261126060532.2379444-1-a-kumar2@ti.com \
--to=a-kumar2@ti.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=benjamin.robin@bootlin.com \
--cc=devarsht@ti.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=s-jain1@ti.com \
--cc=simona@ffwll.ch \
--cc=sjakhade@cadence.com \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=tzimmermann@suse.de \
--cc=u-kumar1@ti.com \
--cc=y-d@ti.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.