From patchwork Fri Mar 28 19:32:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mohammed.0.elbadry@gmail.com X-Patchwork-Id: 876821 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11D5C35972; Fri, 28 Mar 2025 19:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743190385; cv=none; b=J5n3sK3yatePf3n/fW5V84Q5PB+qX3XmU4e0/nCD5suD0xFMkYE8IgKLx/OAciRMQyP/ngnDuFcndb1kStlZK17x3pNfD/LEox+wIFtJiCbxSbZohgU+6KAuGJ5mVmcC1/hoQhhqn7f1JY0hULKLKdiK2De/v1VXUc9dDOoPBvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743190385; c=relaxed/simple; bh=sezMGADMbesTGuGXfIbnNncPeM4zIsAZQfZWIjOPu6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C9LbNqE82rd0IBKw8BbusgVd73+d+MMwuZMBX15p1gePjNBzivny6RGTo5+EE8eN6wC2qtV+G4gTOvj/x3tMKibgdHxqGsx9ifwUu6pOkEmEtFCKUl1rTFdzSi1YekcYBmGG4Bu6mGo/jTLhtKZysXt8QmuZ6fOHbF/3uDaiusI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=byxXT6+Z; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="byxXT6+Z" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2279915e06eso57734075ad.1; Fri, 28 Mar 2025 12:33:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743190383; x=1743795183; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wmzzK5wrB1TwLnmdvaDnS9IoMKPVneQIzyzg2Urwedk=; b=byxXT6+ZJzGrpaRZeM2lOKvL+2IMlNJ+FwvKeGw9l+R+ruvZqD7uxDw5lYmWEsmVhn pvdEY7yOauyUlNc7SBQzIgeWhWL4iXYw8lyZnymsIsnKLjvS1uQYDAL9/TdXV6JF16a6 eycV1/RokmCKO4t5w67qZeFGgoufvsRWVlMyL6AjNuyXDpCwCoKl9uxrLmmU3lNI4lib 5CEc/xC8Qhf9mGNTTO236e3mUrHQUDDslBVWVRJnDvr/4dMV9JXCQNb21ukI4gUyPX/I r+WqxgIAk6lciiItCuF8la1pPwpBR99ksYcIqcwVqz0zw61pukkbmrZ41S+Q5lnvfoCV 8gvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743190383; x=1743795183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wmzzK5wrB1TwLnmdvaDnS9IoMKPVneQIzyzg2Urwedk=; b=XzZ09Ei7hBEDkeQzpI9J3xdVHnJwhRnti0T4hDOZo7GbjUaByn0WJX0iUu2pk8z9ar +Y4FlCQslYApbwKfx7NfJuXfIX/VQtvhWRbZHncRFc90QSxj9yS0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Ndley9Q== X-Received: by 2002:a05:6a00:18aa:b0:736:3c77:31fd with SMTP id d2e1a72fcca58-73980473887mr498675b3a.23.1743190383020; Fri, 28 Mar 2025 12:33:03 -0700 (PDT) Received: from elbadrym.c.googlers.com.com (34.125.168.34.bc.googleusercontent.com. [34.168.125.34]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-739710da6b9sm2258882b3a.174.2025.03.28.12.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Mar 2025 12:33:02 -0700 (PDT) From: mohammed.0.elbadry@gmail.com To: Cc: Tali Perry , Mohammed Elbadry , Avi Fishman , Tomer Maimon , Patrick Venture , Nancy Yuen , Benjamin Fair , Andi Shyti , openbmc@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] i2c: npcm: Add clock toggle recovery Date: Fri, 28 Mar 2025 19:32:50 +0000 Message-ID: <20250328193252.1570811-1-mohammed.0.elbadry@gmail.com> X-Mailer: git-send-email 2.49.0.472.ge94155a9ec-goog In-Reply-To: <20250327193816.670658-1-mohammed.0.elbadry@gmail.com> References: <20250327193816.670658-1-mohammed.0.elbadry@gmail.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tali Perry 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 --- 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 2fe68615942e..caf9aa1e6319 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -1967,10 +1967,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);