From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E51A27C84B; Mon, 7 Apr 2025 18:18:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744049884; cv=none; b=rLkJGlhuVHTjKIep2/fzMC+FIlMT8X9k51kSEsv2XyVr3aoCgH05rIivYrWh2r4uIVNp8EqCpHxdKutEQagJ/gnpqDwLRncjI1lDOzhGqxVpMjhf4jbWcVT6zlBHl6++PJuOMkLWXb0XM+50vQUSn8itA9GxSxElT84FUKwRb/8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744049884; c=relaxed/simple; bh=BcrprjYx4NDsHAhlJTiL+KxgPwmFVz/6ErbVEKo/jAI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IWzr1sX19lVrjfhEsR4SNmR69K7IDe8bnqsIy0RsT7rKZILkorb8O9jjIov4eseoCraeIVEYpVee17Gu/brUdww6Pz0l1HowA8sYLFiUayIkgsGRozkrFvBdUzk7NvdIQYIyAvNAXsNrbSfIIhAZ7jMKzGDYuHl2uWWAy/8y5BQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LNgzrvxf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LNgzrvxf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF57EC4CEE7; Mon, 7 Apr 2025 18:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744049881; bh=BcrprjYx4NDsHAhlJTiL+KxgPwmFVz/6ErbVEKo/jAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LNgzrvxfmufJDZOQgoW+gBNF7oVUyIOjOyfVee5jNKZvu/4BOQ/7fE+V23ccpehcf jg9eXBO77tVixON2IedkX46dYRpIqqeCfN37DKdq0TPSt1fEFOx/n/z3DZ5pMTKKz5 sbc7TVrfugnZwNryY8NVNZXN+jutjn4GawLFb88EzVyp4C8oRFc8Cw7uy/eq8a5Ihg 0p9HvAwypXC8kyY0W34OO7LmWVa3B5K6pNTvVcty3rgpWKLgpLe1W6SpoHQXgw8krL VB8jWNzSOj4miHDEXdNv3l4gQ77KoKoJvi1xZey/weh0ILsCX8ctOWBKilbkHdN6Xs xJcU0lsEFRgxw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lukas Stockmann , Alexander Sverdlin , Alexandre Belloni , Sasha Levin , linux-rtc@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 5/5] rtc: pcf85063: do a SW reset if POR failed Date: Mon, 7 Apr 2025 14:17:48 -0400 Message-Id: <20250407181749.3184538-5-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250407181749.3184538-1-sashal@kernel.org> References: <20250407181749.3184538-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.133 Content-Transfer-Encoding: 8bit From: Lukas Stockmann [ Upstream commit 2b7cbd98495f6ee4cd6422fe77828a19e9edf87f ] Power-on Reset has a documented issue in PCF85063, refer to its datasheet, section "Software reset": "There is a low probability that some devices will have corruption of the registers after the automatic power-on reset if the device is powered up with a residual VDD level. It is required that the VDD starts at zero volts at power up or upon power cycling to ensure that there is no corruption of the registers. If this is not possible, a reset must be initiated after power-up (i.e. when power is stable) with the software reset command" Trigger SW reset if there is an indication that POR has failed. Link: https://www.nxp.com/docs/en/data-sheet/PCF85063A.pdf Signed-off-by: Lukas Stockmann Signed-off-by: Alexander Sverdlin Link: https://lore.kernel.org/r/20250120093451.30778-1-alexander.sverdlin@siemens.com Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/rtc/rtc-pcf85063.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c index 6ffdc10b32d32..4a29b44e75e6a 100644 --- a/drivers/rtc/rtc-pcf85063.c +++ b/drivers/rtc/rtc-pcf85063.c @@ -35,6 +35,7 @@ #define PCF85063_REG_CTRL1_CAP_SEL BIT(0) #define PCF85063_REG_CTRL1_STOP BIT(5) #define PCF85063_REG_CTRL1_EXT_TEST BIT(7) +#define PCF85063_REG_CTRL1_SWR 0x58 #define PCF85063_REG_CTRL2 0x01 #define PCF85063_CTRL2_AF BIT(6) @@ -606,7 +607,7 @@ static int pcf85063_probe(struct i2c_client *client) i2c_set_clientdata(client, pcf85063); - err = regmap_read(pcf85063->regmap, PCF85063_REG_CTRL1, &tmp); + err = regmap_read(pcf85063->regmap, PCF85063_REG_SC, &tmp); if (err) { dev_err(&client->dev, "RTC chip is not present\n"); return err; @@ -616,6 +617,22 @@ static int pcf85063_probe(struct i2c_client *client) if (IS_ERR(pcf85063->rtc)) return PTR_ERR(pcf85063->rtc); + /* + * If a Power loss is detected, SW reset the device. + * From PCF85063A datasheet: + * There is a low probability that some devices will have corruption + * of the registers after the automatic power-on reset... + */ + if (tmp & PCF85063_REG_SC_OS) { + dev_warn(&client->dev, + "POR issue detected, sending a SW reset\n"); + err = regmap_write(pcf85063->regmap, PCF85063_REG_CTRL1, + PCF85063_REG_CTRL1_SWR); + if (err < 0) + dev_warn(&client->dev, + "SW reset failed, trying to continue\n"); + } + err = pcf85063_load_capacitance(pcf85063, client->dev.of_node, config->force_cap_7000 ? 7000 : 0); if (err < 0) -- 2.39.5