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 96F731EE7C6; Mon, 23 Jun 2025 21:36:25 +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=1750714585; cv=none; b=LvP4bDvl0gJC1W5y1Ul0FTs6C+fsDWYUZNQ0wdrbXSsWYFER1/kuKE+c1OXzd8Q90i5jsxygTQrf2tqGNQFnsmCh/qSooVbM3moCG2jFJWbVJMUFh9eE3wqMcF/Q4vD87DUv8z7ju5W9yMjn2u1/CNGyTWNRfIVuzvnVMctmZL8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750714585; c=relaxed/simple; bh=npwDM0Us4E1t9HpCNKFJw3/+z/v0wp5KrDVs6OFnzg4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BlP0Xze99G23ZfOSFO83M9lPLcwkEDcV/Ax/DxKOUXB3zVljEwjliHY1CIxldG1izbGxw4P51tS9Q7SO/6FuFSF6wvOwRb3f7HblZTllS+yYZZ22hx5wPSZ7P7EbM2FSGzJOMX20ld4B4Jku6tFze5lf7V8wJUGKKye+LF4dNVQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=r8QddA00; 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="r8QddA00" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C9B7C4CEEA; Mon, 23 Jun 2025 21:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750714585; bh=npwDM0Us4E1t9HpCNKFJw3/+z/v0wp5KrDVs6OFnzg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r8QddA00ZistD8hCPoyF+mP8qK7I0P0oKhUZmmHtlcIG6rv5kJH08qsKYEruXvb+n 7LZ9HKKL0jpXufFP0/290byPOJYOqPfj+rUe5H3AkROQdmqN/KcQjf7KkgPFnmJYKC 3bWBwrrrH92LQSpCLb5cUoeuR6J0PBClzqbzxlkU= 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.6 146/290] i2c: npcm: Add clock toggle recovery Date: Mon, 23 Jun 2025 15:06:47 +0200 Message-ID: <20250623130631.287701513@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130626.910356556@linuxfoundation.org> References: <20250623130626.910356556@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.6-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 91f508d50e7ab..5b3987460976e 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -1971,10 +1971,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