From patchwork Thu Aug 31 18:17:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 719634 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51433C83F2F for ; Thu, 31 Aug 2023 18:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244692AbjHaSSM (ORCPT ); Thu, 31 Aug 2023 14:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242148AbjHaSSM (ORCPT ); Thu, 31 Aug 2023 14:18:12 -0400 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 825E8E5F for ; Thu, 31 Aug 2023 11:18:09 -0700 (PDT) Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 293E480702; Thu, 31 Aug 2023 20:18:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1693505888; bh=SSyy5p6GBLWM4WJD7NXGqgc/zib0LYrCgS3OTnqMioU=; h=From:To:Cc:Subject:Date:From; b=CPXh4FbxZ0i/RKRclYd94/I8Y8icAJKBpLeOGnjhQFMraWtWdoR/OIfVInJi5rix+ R0jYcY4Z/6QvRRP8dLX3+oMiUjGsJJvtdYlHvW7b2rb9wyO2lvSC+mfYEecbp9YtDU kIxs69wwvspBDaxJblvJbloNY0R+DJqMdpJQMlv2geFvEYGU/1jDPWTgCz4ItrzMfh UjHMy4D7nxCMWued6MGi1/E5uPuUejBg5F7nZRrEsjDYUJxNpxd3chobvIPcl3WF9x cRN61z00ipY7X72MNaxibiz6F2nhfPEIVCgt/2l5wSXV90cXM0ounNI0s3tGqQaCF1 Xtu5PT+kY3Qnw== From: Marek Vasut To: linux-i2c@vger.kernel.org Cc: Marek Vasut , Peter Rosin , Wolfram Sang Subject: [PATCH 1/2] i2c: mux: pca954x: Make sure the mux remains configured the same as before resume Date: Thu, 31 Aug 2023 20:17:52 +0200 Message-Id: <20230831181753.154787-1-marex@denx.de> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The current implementation of pca954x_init() rewrites content of data->last_chan which is then populated into the mux select register. Skip this part, so that the mux is populated with content of data->last_chan as it was set before suspend. This way, the mux state is retained across suspend/resume cycle. Fixes: e65e228eb096 ("i2c: mux: pca954x: support property idle-state") Signed-off-by: Marek Vasut --- Cc: Peter Rosin Cc: Wolfram Sang Cc: linux-i2c@vger.kernel.org --- drivers/i2c/muxes/i2c-mux-pca954x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 2219062104fbc..97cf475dde0f4 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -620,9 +620,9 @@ static int pca954x_resume(struct device *dev) struct pca954x *data = i2c_mux_priv(muxc); int ret; - ret = pca954x_init(client, data); + ret = i2c_smbus_write_byte(client, data->last_chan); if (ret < 0) - dev_err(&client->dev, "failed to verify mux presence\n"); + dev_err(&client->dev, "failed to restore mux state\n"); return ret; } From patchwork Thu Aug 31 18:17:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 719294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96E00C83F39 for ; Thu, 31 Aug 2023 18:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242148AbjHaSSN (ORCPT ); Thu, 31 Aug 2023 14:18:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244232AbjHaSSM (ORCPT ); Thu, 31 Aug 2023 14:18:12 -0400 Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8616E63 for ; Thu, 31 Aug 2023 11:18:09 -0700 (PDT) Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 727468657F; Thu, 31 Aug 2023 20:18:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1693505888; bh=P/1f2J/c+3Ic9WT9oy6mwXSQDEz17yKxQnoArGuUDQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJLRqbhCc5RZ92voDs4jlnGueOoQYCZvmatm8FNkRr2hHMY2LSZ04GnHREMObjLaQ LCCWdEVMWhVrTQZ3NyXMB6nLRmTzqDHIBDVQJYcHlfQVcFQGXRa4pjI6Hb111514wn Zk1qKZP434EpD6YYa6YfG4tFnc5x+rGlW7A8ZsUfKeYd+zd/Edl2+wtKO8AAS/Y6kc xvV3iMxtjMbInoKgx8ELXY+Pm4Lsx8KIkQ7YJJUJCdsbKX7mp2Gqn83uc/bmZNLKrk UgbdIwBDCXuhMPN7pPL/U0YOyiWHrQ+PjF8zmJ95zI4GGjM1KOv+LMUz6IElsuTeXY TeObbd9rpTZqg== From: Marek Vasut To: linux-i2c@vger.kernel.org Cc: Marek Vasut , Peter Rosin , Wolfram Sang Subject: [PATCH 2/2] i2c: mux: pca954x: Resume the mux early Date: Thu, 31 Aug 2023 20:17:53 +0200 Message-Id: <20230831181753.154787-2-marex@denx.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230831181753.154787-1-marex@denx.de> References: <20230831181753.154787-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The mux resumes alongside its subdevices, which means the subdevices may resume while the mux is not yet fully configured and those subdevices may fail to access I2C registers through the mux. Use resume_early to resume the mux before any of the other i2c devices. Signed-off-by: Marek Vasut --- NOTE: This might be wrong approach --- Cc: Peter Rosin Cc: Wolfram Sang Cc: linux-i2c@vger.kernel.org --- drivers/i2c/muxes/i2c-mux-pca954x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 97cf475dde0f4..87fd8d3ba56b2 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -627,12 +627,14 @@ static int pca954x_resume(struct device *dev) return ret; } -static DEFINE_SIMPLE_DEV_PM_OPS(pca954x_pm, NULL, pca954x_resume); +static const struct dev_pm_ops pca954x_pm = { + .resume_early = pca954x_resume, +}; static struct i2c_driver pca954x_driver = { .driver = { .name = "pca954x", - .pm = pm_sleep_ptr(&pca954x_pm), + .pm = &pca954x_pm, .of_match_table = pca954x_of_match, }, .probe = pca954x_probe,