All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: linux-media@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH 3/3] adv748x: Configure device when resuming from sleep
Date: Sun, 22 Nov 2020 17:36:37 +0100	[thread overview]
Message-ID: <20201122163637.3590465-4-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20201122163637.3590465-1-niklas.soderlund+renesas@ragnatech.se>

If the device is powered off for example during system suspend to ram
the devices loses its configuration, specially the slave i2c mappings
and other configuration set at probe time. This renders the device
unusable and only way to recover is to unbind and rebind the device to
the driver to run the probe setup again.

Add an early resume callback that reinitializes the device and setup the
slave i2c address mappings and other probe time configuration.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/media/i2c/adv748x/adv748x-core.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
index b578a01cfebe7217..4e54148147b9adec 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -565,6 +565,18 @@ static int adv748x_identify_chip(struct adv748x_state *state)
 	return 0;
 }
 
+/* -----------------------------------------------------------------------------
+ * Suspend / Resume
+ */
+
+static int __maybe_unused adv748x_resume_early(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adv748x_state *state = i2c_get_clientdata(client);
+
+	return adv748x_reset(state);
+}
+
 /* -----------------------------------------------------------------------------
  * i2c driver
  */
@@ -827,10 +839,15 @@ static const struct of_device_id adv748x_of_table[] = {
 };
 MODULE_DEVICE_TABLE(of, adv748x_of_table);
 
+static const struct dev_pm_ops adv748x_pm_ops = {
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(NULL, adv748x_resume_early)
+};
+
 static struct i2c_driver adv748x_driver = {
 	.driver = {
 		.name = "adv748x",
 		.of_match_table = adv748x_of_table,
+		.pm = &adv748x_pm_ops,
 	},
 	.probe_new = adv748x_probe,
 	.remove = adv748x_remove,
-- 
2.29.2


  parent reply	other threads:[~2020-11-22 16:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-22 16:36 [PATCH 0/3] adv748x: Add support for s2ram Niklas Söderlund
2020-11-22 16:36 ` [PATCH 1/3] adv748x: afe: Select input port when device is reset Niklas Söderlund
2020-11-23  8:00   ` Sergei Shtylyov
2020-11-25 12:10   ` Kieran Bingham
2020-11-25 13:16     ` Niklas Söderlund
2020-11-22 16:36 ` [PATCH 2/3] adv748x: csi2: Set virtual channel " Niklas Söderlund
2020-11-23  8:06   ` Sergei Shtylyov
2020-11-22 16:36 ` Niklas Söderlund [this message]
2020-11-23  8:09   ` [PATCH 3/3] adv748x: Configure device when resuming from sleep Sergei Shtylyov
2020-11-23  8:05 ` [PATCH 0/3] adv748x: Add support for s2ram Sergei Shtylyov
2020-11-25 13:09 ` Kieran Bingham
2020-11-25 13:39   ` Niklas Söderlund
2020-11-25 13:58     ` Geert Uytterhoeven

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=20201122163637.3590465-4-niklas.soderlund+renesas@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.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 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.