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 203B32192EC; Mon, 23 Jun 2025 22:24:18 +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=1750717458; cv=none; b=Nqup+MeeiwxBSK82dTeJw4O3j7T/aqFyh5Rj6STnM4tpLndEZfhRw4xr+D/WIfpJai99gtsXHqk+gizU7XeqBVRwH56opNuhZk41SrunYE6r597/NsNz75n2WS83U4PdfVy5gIoFykF2ImD4lNPe3kKB36dyPbGuVW7Sz7tUt3I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750717458; c=relaxed/simple; bh=eXyCLuWJo6ITotZYHEZihRxduPcwhUdV83NG/Blju5E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XWsEHOUc1TSZ5iyGpPrn0KSfcRQ7/WT6tgB+E8gpGdnfvDF/BLtdSSmG1sCi46BpB4VPtdElGAezX5KEGfbsTJ76s6qm0lwEIClsCFuEnnjSsE/rziu8AV/rYHAS6X5+nX5XZBMPWcxi2v207E4e/CRkdYb8PqxyWfYX2MS2tgw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=G2Oaii6w; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="G2Oaii6w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAC8AC4CEEA; Mon, 23 Jun 2025 22:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750717458; bh=eXyCLuWJo6ITotZYHEZihRxduPcwhUdV83NG/Blju5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G2Oaii6wtn2NUuo3tQiXwxVc4fgjSwOzOHQh7MQnQyIiMNy30pJ258tZ3lm55nwbX RshBApsVN8YNU12E94HlzY9yQd1bxzJ6DZ4Trpyh8PB84b9A5UfcSrrrMG/nRXRLc8 3Y8lBEqe0VNFri9flY21PysB+SsGq+aP1dd5yrLc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tali Perry , Mohammed Elbadry , Mukesh Kumar Savaliya , Andi Shyti , Sasha Levin Subject: [PATCH 6.1 398/508] i2c: npcm: Add clock toggle recovery Date: Mon, 23 Jun 2025 15:07:23 +0200 Message-ID: <20250623130655.049185106@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130645.255320792@linuxfoundation.org> References: <20250623130645.255320792@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tali Perry [ Upstream commit 38010591a0fc3203f1cee45b01ab358b72dd9ab2 ] During init of the bus, the module checks that the bus is idle. If one of the lines are stuck try to recover them first before failing. Sometimes SDA and SCL are low if improper reset occurs (e.g., reboot). Signed-off-by: Tali Perry Signed-off-by: Mohammed Elbadry Reviewed-by: Mukesh Kumar Savaliya Link: https://lore.kernel.org/r/20250328193252.1570811-1-mohammed.0.elbadry@gmail.com Signed-off-by: Andi Shyti Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 0947e3d155c56..828234d1ee477 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -1973,10 +1973,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode, /* Check HW is OK: SDA and SCL should be high at this point. */ if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) { - dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num); - dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap), - npcm_i2c_get_SCL(&bus->adap)); - return -ENXIO; + dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempting to recover\n", bus->num, + npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap)); + if (npcm_i2c_recovery_tgclk(&bus->adap)) { + dev_err(bus->dev, "I2C%d init fail: SDA=%d SCL=%d\n", + bus->num, npcm_i2c_get_SDA(&bus->adap), + npcm_i2c_get_SCL(&bus->adap)); + return -ENXIO; + } } npcm_i2c_int_enable(bus, true); -- 2.39.5