From patchwork Fri Dec 13 17:58:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 850567 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 9FF7C1E3775; Fri, 13 Dec 2024 17:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112717; cv=none; b=o7n3N7RcLiIXjFTEGBBxXypa9g3jZwpvhFvT4o54lRD1azbwkrbS2+Exh7quHT3q6u9vNqPb3Z8msNDiye67vQEEkXnTDRAeyZyHswQJp3QFL8wCwcb2svI5J9I8R7YeYKGLJRaqdeOjD5IvUV41c1gBO6SjEP+D6Gvf1qbHjz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112717; c=relaxed/simple; bh=W8oNQSeOIQ27iGni2+2i4bYsGd5Lo8gwn0kk254jE38=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X40jzpLyEGCS1V6BIKXLfXgOHavRyQRUYMZKTzDu7nfNVdSd4qCKa1pNqrbN6wJDLczgeX4KI3UUZyRybjmiYwdpdf5pB8noJ+l7XwlYA1sdomzhE0qECCmh4HsUmGK0xIgWQYFuj0cFNX+fFPoH48OwtO8cYrhRU3MEr1Rc99o= 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=moC8fTrj; arc=none smtp.client-ip=209.85.128.45 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="moC8fTrj" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-43618283dedso19382565e9.3; Fri, 13 Dec 2024 09:58:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734112714; x=1734717514; 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=m22X8YrMWCLSXkLU9BQ9UULdRQ3y6T7GHGyJIqVQpsA=; b=moC8fTrj3yh8i6GPJfM25umKI2407HXM637fVQhEl+TCgza1ZhTw4VoddbShZ5XUBx rmxV0MTnq4Xrgax+UHFOmGc4rHxFNxDLynJE5brXQbELmaQDVz4MoqmBPT/YE8WJbJwg 7/NsMsWqLq2i16UtDd8wWKfZ2Ig2LXTraRQox5/GpmbOxyYQXEEWr4GTZHRzoHWniDM5 CQUfPaa6fomy+6LU2tF+DqVHjTb6QKhxUHvjhKA3Wi48X5kmvLSlMjDoJoFjqQQ2c1zl McBn+AiJeweQCn19GMjRkb01tTM9eoQcQsgKOXav7rk5vnaKDzh2Z5eEUclwfLtYHQjN Dj9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734112714; x=1734717514; 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=m22X8YrMWCLSXkLU9BQ9UULdRQ3y6T7GHGyJIqVQpsA=; b=J43h4qsjOZXe1Mjf0+8gXU+mEP5lIi+ToUfd+RD+TtTU5KMfml77Fh0kUGqh/uGhpQ qQwpTotIaM23lMbTiDncWkUpXAFmqpfFPdDunI4MzyBOdlqff/lgoQH8Zr4C+/9/AVel tkxK8cgJy2Pi7xwvycn1IA1L1BClyCjPvC3/DhgHaIDemkMJF6N57PrjkgsxGxnRfShh PZgsfo9j+tn2UszEXg7sFZew3G5Q5YVli6cdAIEk3EZUfJhe096+GKFmnlIkrHdXVTk+ GoYmwiOvEoyM2cxL3ZJUAC1BYe8jugvWw1Sw7J5nVv3PhC4JdiZxREzICr4s0A2Z8taP ds6Q== X-Forwarded-Encrypted: i=1; AJvYcCWNS7HGCcUyew4Qoeo76/pDoeMTKKmfV/ovqmLJ8RzlLK8wLZ61pzNF1EZSXe+x8oFx0yLWUP6vklg=@vger.kernel.org, AJvYcCWlfSdR3VdcAKNEGTqtedaOUnpWizlSNPKZWVv6RsxP8MTRrpjvJZKwPp8Q6BvZbNElHZnDNZpaopqCuTmy@vger.kernel.org X-Gm-Message-State: AOJu0YzKRQw8kL9cNHwzewk809ohSWPCBl4htjE+vV9z7L4CWGUqjZzG k/3wZdYCIet8//KpCE7YnYPO9P3vks1L4kdjeH0J2Qqc809twiqsXq0BjQ== X-Gm-Gg: ASbGncu+wp7U1a42q8lErBbSn1iHtPtOVk5bf9695nqFcBDQf9z5knd8ieut4dzJnrZ vYhYPOGmLbp2xOKoPQljyDZGeLhEH2Ixt8e3wnDunT6Q84mLsWFoOPkcvZ3h41A06qJPZwcBWfN WINhA3OPCqZP8++Wn02ciNm/Qms+5mQdUVx7xjTEprmiGNE1R/NJRCBI5mSNfU9cwj72wBZnFdz TA7w5JHjWcxGNZ9qmM+Mh5kxFKH+O1RKbiDkJyI2hAfw1oRb7hdjJqWAKiHm07k084oi8NqMn7g T2mi/fFhKg== X-Google-Smtp-Source: AGHT+IFO96Lc8qDkLcXuP0pFBLM9GcL6S1MVl8Atv1Y7dbdV+Yk4b4sn9KSn0FCe2DhGRAXehYI7Pg== X-Received: by 2002:a05:6000:2a6:b0:385:f527:be6d with SMTP id ffacd0b85a97d-3888e0f4763mr2697926f8f.36.1734112713561; Fri, 13 Dec 2024 09:58:33 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:4eec:e99c:89a6:d7a6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c804d573sm119088f8f.64.2024.12.13.09.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:58:32 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Philipp Zabel , Wolfram Sang , Geert Uytterhoeven Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 1/9] i2c: riic: Replace dev_err with dev_err_probe in probe function Date: Fri, 13 Dec 2024 17:58:20 +0000 Message-ID: <20241213175828.909987-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Refactor error handling in the riic_i2c_probe() function by replacing multiple dev_err() calls with dev_err_probe(). Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-riic.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index c218f73c3650..7ab32aeead4b 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -445,10 +445,9 @@ static int riic_i2c_probe(struct platform_device *pdev) return PTR_ERR(riic->base); riic->clk = devm_clk_get(dev, NULL); - if (IS_ERR(riic->clk)) { - dev_err(dev, "missing controller clock"); - return PTR_ERR(riic->clk); - } + if (IS_ERR(riic->clk)) + return dev_err_probe(dev, PTR_ERR(riic->clk), + "missing controller clock"); riic->rstc = devm_reset_control_get_optional_exclusive(dev, NULL); if (IS_ERR(riic->rstc)) @@ -470,10 +469,9 @@ static int riic_i2c_probe(struct platform_device *pdev) ret = devm_request_irq(dev, ret, riic_irqs[i].isr, 0, riic_irqs[i].name, riic); - if (ret) { - dev_err(dev, "failed to request irq %s\n", riic_irqs[i].name); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to request irq %s\n", + riic_irqs[i].name); } riic->info = of_device_get_match_data(dev); From patchwork Fri Dec 13 17:58:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 851143 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 0ED001E7678; Fri, 13 Dec 2024 17:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112718; cv=none; b=QmuTZVDEIILEDGdO68SCiaJhEj+YNsoyICTSrBQkQrYVO0d1oOTo8vpzsOmHGFcdRk3b3Kc9GLADuc07Z0CBF2PocVTcPO4B7vVO2MTvbCua9gBGKdQQqQVlTd/NFG6BVfIlyns6DoeIHfZ9lVtzPr/f2a2VLk+P86/UT6mn9kI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112718; c=relaxed/simple; bh=owd0zn1P5YfeNkYMC+oUSuFlHqUQWKes+FGyKpfhQiY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t4Qssf6R612kieiu71c4CQgkbDSrjK6WuEBZoKO9Fp53gZX/7X3x8Dd8zAgW9Y5beb+QsJfzI6e0+IauhuXS505EQ5ldCPUKtwyCh4y0G2oE4VpCpk0a4G17/hvZMHyNNWKmHR9uMwLV1t5xyttcLvHf1h5QrqvmgagUUtFWY98= 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=SoQHTe4M; arc=none smtp.client-ip=209.85.221.41 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="SoQHTe4M" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-385df53e559so1623667f8f.3; Fri, 13 Dec 2024 09:58:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734112715; x=1734717515; 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=vaLlRj3ObamRETdZi3/ztjW/T2zRB+N3Lr9QOtAkYD0=; b=SoQHTe4MyI3oCh1N9dJDjCGa7nLyAvbc2ypJYLT0Jnpz17dpe7lZxRETaahj6v/EQN aLH7NuwyhYpFhngBcK/ZlI0le1kXyyfC+GOKELWP5WbLMaoAzn1kCUUbuDQ3t7DaJw0H kzZa6aYrc8cOExic4ftrdpSOd3vObS7Xj95LInVfbsEuNCVspKogAvvemvXfhKQmpzJZ U+mc45Z+1KcvgDncl4xFa8A1YdSoSFQcXS9VZxHdAUrSEEPCQyI8gJSb5YHyNCwnqNpm vCJzIWdCmGUpKW/5Q0e7FMg2/5SJ7TwqkwMQBo+ubIsGJiuIWcJal1zUIR8l6kitcQ9T YTaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734112715; x=1734717515; 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=vaLlRj3ObamRETdZi3/ztjW/T2zRB+N3Lr9QOtAkYD0=; b=gtRH2MLsRGVoWO80autOCuO9N4cMcWsCRWa1FUT54dtWZ2dCxygIM4raKV1F3q0q2Q Hz+3hhXvzQV8HC47Ag+BAwiT4pFBhhYDv3lDquIWo8uf2KsFv3171lcJad7vOQciEp42 +xyoZ4XrB0bC8GGcra0+ZTWyhREz30PtlQbg/QPVclqO99G5gEi9d070wHpTyhnhEtQS OtcMkZCqkg+Ivwe+AbfdzAZrJFkBSr8oGrCR+/cMMrfXBO+pHljAHgITKC6QGc0d7WeU A20hfUEBkXdUz71aU3pYKzKTMzidZ2KhKM3Y/PUKcYpu+RixC2htE0zaix3x8o4Be3cu sFNQ== X-Forwarded-Encrypted: i=1; AJvYcCUnQh8P4ImyrW5ytmKdOHdCm1TB0lbFMmCghnjNOhjSShfwYeyF79Kr9AdaSX4+f0l1+p1MnQ2GiyU=@vger.kernel.org, AJvYcCVdTx7cdcw2C+JFtJPhnNTF6tM7yJTgMmF4BUuf+DNJbqlJaeyyi+AP8y0V8P1kmgOqqmhIhUffmN0Vfkls@vger.kernel.org X-Gm-Message-State: AOJu0Yz0A6uPZna2cLGbHZOwBN7l9POjTN0ZyCZDEigGyfcxAapNrnUJ h4Yn2U76ewY50shxo5TVSGq89q1LjQm/MoHp8Yyx1Mc0jUsD2Zf275rn9g== X-Gm-Gg: ASbGncvRmxG9l+8yciHLNVnQQVXhHPlX5UiH9UbmspmYkgop7ETtHxGrXuCUqgtzA98 F3ANt6z67MVF1BlXqmtFxHofo+11I9VVs6M4gXE5VIgh6OqOnjv5YbflnQgfEvg18FHvsJdDcZV 5KXToAXzvhc57Weyza/7bWXhnwT0uTXSYwM4/5Jsn3ioOdfLWTYet6Wcp4lMNT8EUd4yd0YYjIw nuioBMC4Egk7uMywFR92iIG8ZUUC80L2ek4ZhlollAVHAGYmVLRqEzO7ubi3ikcRWrecKAXhQes mFUXk/i3Iw== X-Google-Smtp-Source: AGHT+IGM2iCVKSaOg2DupxSNUtFLUFBnepSblvZs1s4dgrr1Uu7AOUZYvAO9rnQwyUgNWxIvzWbb1w== X-Received: by 2002:a05:6000:188f:b0:386:3e87:2cd6 with SMTP id ffacd0b85a97d-3888e0f4779mr2647388f8f.38.1734112715063; Fri, 13 Dec 2024 09:58:35 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:4eec:e99c:89a6:d7a6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c804d573sm119088f8f.64.2024.12.13.09.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:58:34 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Philipp Zabel , Wolfram Sang , Geert Uytterhoeven Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 2/9] i2c: riic: Use local `dev` pointer in `dev_err_probe()` Date: Fri, 13 Dec 2024 17:58:21 +0000 Message-ID: <20241213175828.909987-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Update the `riic_init_hw()` function to use the local `dev` pointer in calls to `dev_err_probe()`. Previously, `riic_init_hw()` used `riic->adapter.dev` in error reporting. Since this function is invoked during the probe phase, the I2C adapter is not yet initialized, leading to `(null) ...` being printed in error messages. This patch fixes the issue by consistently using the local `dev` pointer, which points to `riic->adapter.dev.parent`. Additionally, replace `dev_err()` with `dev_err_probe()` throughout `riic_init_hw()` for consistency. Fixes: d982d66514192 ("i2c: riic: remove clock and frequency restrictions") Fixes: 71dacb2565ed (i2c: riic: Simplify unsupported bus speed handling") Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-riic.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 7ab32aeead4b..d01bb52d86ed 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -320,7 +320,7 @@ static int riic_init_hw(struct riic_dev *riic) : I2C_MAX_FAST_MODE_FREQ; if (t->bus_freq_hz > max_freq) - return dev_err_probe(&riic->adapter.dev, -EINVAL, + return dev_err_probe(dev, -EINVAL, "unsupported bus speed %uHz (%u max)\n", t->bus_freq_hz, max_freq); @@ -356,11 +356,9 @@ static int riic_init_hw(struct riic_dev *riic) rate /= 2; } - if (brl > (0x1F + 3)) { - dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n", - (unsigned long)t->bus_freq_hz); - return -EINVAL; - } + if (brl > (0x1F + 3)) + return dev_err_probe(dev, -EINVAL, "invalid speed (%lu). Too slow.\n", + (unsigned long)t->bus_freq_hz); brh = total_ticks - brl; From patchwork Fri Dec 13 17:58:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 850566 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 8AF891EB9F8; Fri, 13 Dec 2024 17:58:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112720; cv=none; b=az2lMiarq/m+00a5PN85/lAuFNG4BdtDSWc/AeNGwH9OcZ/3o/UwN7m48at7zzRIDFl4xa0liObX8QUN32wNIpZ+XFS3EpgWNtR5c7XnuxU3JiRWitUakioc3sPa4Lz5fEnHKB+s0gAN7wJvS3RcongQr3OlTe2HGDknD6fSFXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112720; c=relaxed/simple; bh=v6gRovSpSw1Dpn6da67WqnL5HJw9i7Rb0ebquq57WdI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WVBiK/5bQM6pTdS0erpkoI8Y3wEFRRUxn9yKICeeb7TT3HGic/W85afe9d4Sf83wgzp4FthYd4AXzhzWmKvDP4N8oKldtk9wRXOKlVxPG8+p6xUy2HK1WSaoAf/TNdH+eWbPYoHflihSxhJ5akt23C+/C/5QVm0MEECsmHPrcBE= 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=j8YmuUyr; arc=none smtp.client-ip=209.85.221.42 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="j8YmuUyr" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-385e0e224cbso1091033f8f.2; Fri, 13 Dec 2024 09:58:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734112717; x=1734717517; 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=isddyxmmGgOgjcayZ6HGdvTWBUz67VDzdtOROZt8tn8=; b=j8YmuUyr8pyMNrM0oslmtFKxM6Sw+9M6VukKPvalU21a0hPB8OkhGyllurkLddWx0b XPvPxakM7RHrf+BeS/NTPQvY1Km240LEAWfeAWHR8m1oz+gHh1oMOHq+m+ymis30kzSE BUqjRiHmxZQZ3YM1u8nFuM0qiQtfS7YZFstkyMWBBaRh79LepZ6wQzZHb76Cw5GBs9kj udDu2Eg4CfgSSU/MsciSu57tu0+//rrpC+CCzJJPTj7pIO+55ogz8GIfA+QJqLLGdjEt E8OL0OwDCZ+S627eHq6yswmYu1wKnVMKhqD7Nbktqy1m+lYbCxp82APsUv2hRp1oVv6P 1pfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734112717; x=1734717517; 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=isddyxmmGgOgjcayZ6HGdvTWBUz67VDzdtOROZt8tn8=; b=vK+ys3N17vRh2fBEiuBME5qREZsn+yO31js5uLOGI3yctYI7qgcocFaniTGbToQC8h w1+QBAJ19+EiCEIO+k2krTisTTpWkKUvjtxJnK2nHa3T1ppIrzLZwZ+ff7bHXQZyBZ5I N8dxqc6EkwVz6sgdnDe/eviHxJE9WFTCFehUSJDXjoZoT0XMWkKJsdZCZVpf+koraRk/ C9md7/7HadkdtLy0gCgjRK0NA9APbpCRP1iixMzbmdUqrsWHhwqIOoJm9i1FD7Tlullb ieBWKEuS48CwLUKFUS/MKO6tPk2/n6x84eU0hu7//pnWsC3Osev8zr0WP1/4XMoVCGcg OMhg== X-Forwarded-Encrypted: i=1; AJvYcCXnXlANCt8k6Wfc2iNp0Q2tguiLoqLdYn25khImLo4AMwV2kTwQqMOFEl2fJ9QYdzP4wQbt0unWW8GotsC4@vger.kernel.org, AJvYcCXzNCLIktU67zZGjZe9E9ie2EAO0ZfxixzmIUEvG0MEbSfdvK1mLkTI33Hana/OZGPgMX+q6vxRk5k=@vger.kernel.org X-Gm-Message-State: AOJu0YwLhhABFef8nUB7wxVD6+Symp+lV9B0cLOuqXxyklYKkI0gXFz3 PALEfQqzh/VAm85zV5Kg5eQg9te0yog5hfAO7ZTEjigyhQnLTJwg X-Gm-Gg: ASbGnctkFzs0NmwziOvRnpmE4mNAtX6OVgx40x1hPSy7SkNQGSBE1AGZcYBOeyqP70y Zm/jEJRsRE6GAOMX2zaqtgHHfEgoleaeRDKdr/niwFoslqEs/9Nf3rcPUrAmx3Hc9Ln9UBdKhPL xHFZORNIsz8EErjVkKq/put4vzA9I4P4d5dBG96ShcghSsXcdAkoGaB3Msohky1mKnZIJOAkbeW dUEsCcxq1/62B6lMbWXAvTuiD61t4evWi3w4oNvU9c1JxT42H7xbXxpE8FvOeSqXk+tJWxBscTw 4LDLCSou6Q== X-Google-Smtp-Source: AGHT+IEs95uhShUZYTyFBw4pkogT1ks9Ew7DEhDpTBgmZAupQO/qiQ/VEnupl7xMhJi0k4cOFusukQ== X-Received: by 2002:a05:6000:144f:b0:385:fae4:424e with SMTP id ffacd0b85a97d-3888e0c07b9mr2452260f8f.52.1734112716578; Fri, 13 Dec 2024 09:58:36 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:4eec:e99c:89a6:d7a6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c804d573sm119088f8f.64.2024.12.13.09.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:58:35 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Philipp Zabel , Wolfram Sang , Geert Uytterhoeven Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 3/9] i2c: riic: Use BIT macro consistently Date: Fri, 13 Dec 2024 17:58:22 +0000 Message-ID: <20241213175828.909987-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Easier to read and ensures proper types. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-riic.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index d01bb52d86ed..659b0702293a 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -46,32 +46,32 @@ #include #include -#define ICCR1_ICE 0x80 -#define ICCR1_IICRST 0x40 -#define ICCR1_SOWP 0x10 +#define ICCR1_ICE BIT(7) +#define ICCR1_IICRST BIT(6) +#define ICCR1_SOWP BIT(4) -#define ICCR2_BBSY 0x80 -#define ICCR2_SP 0x08 -#define ICCR2_RS 0x04 -#define ICCR2_ST 0x02 +#define ICCR2_BBSY BIT(7) +#define ICCR2_SP BIT(3) +#define ICCR2_RS BIT(2) +#define ICCR2_ST BIT(1) #define ICMR1_CKS_MASK 0x70 -#define ICMR1_BCWP 0x08 +#define ICMR1_BCWP BIT(3) #define ICMR1_CKS(_x) ((((_x) << 4) & ICMR1_CKS_MASK) | ICMR1_BCWP) -#define ICMR3_RDRFS 0x20 -#define ICMR3_ACKWP 0x10 -#define ICMR3_ACKBT 0x08 +#define ICMR3_RDRFS BIT(5) +#define ICMR3_ACKWP BIT(4) +#define ICMR3_ACKBT BIT(3) -#define ICFER_FMPE 0x80 +#define ICFER_FMPE BIT(7) -#define ICIER_TIE 0x80 -#define ICIER_TEIE 0x40 -#define ICIER_RIE 0x20 -#define ICIER_NAKIE 0x10 -#define ICIER_SPIE 0x08 +#define ICIER_TIE BIT(7) +#define ICIER_TEIE BIT(6) +#define ICIER_RIE BIT(5) +#define ICIER_NAKIE BIT(4) +#define ICIER_SPIE BIT(3) -#define ICSR2_NACKF 0x10 +#define ICSR2_NACKF BIT(4) #define ICBR_RESERVED 0xe0 /* Should be 1 on writes */ From patchwork Fri Dec 13 17:58:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 851142 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 DA8731EBFFD; Fri, 13 Dec 2024 17:58:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112721; cv=none; b=nCYfm1h/THQuTv91oNebPpAhaa2W2049a/R7mdJSxsP8XWDD4xmzIlD151xz2nkUCjGOCJJFwpovyHrgRxxZBzdlG2MIb3EYDG9vhUtww12snioz8S57RoD/ka2yGjV3zPU0ijyI+/3LjG4SkZsIod8iK9RIgCxHScWsqMN2Ey0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112721; c=relaxed/simple; bh=VTDFUkxwn4kqGox0RWUxsUygIOXtAgoK5fkkB8ExnlE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SBXx2yjL+ktFSHMqcun7R4MbBF73llLSrIgDPBbJG7I18L9RJJkUGfpra5bBNYKOWhpUF+B0SRA2SVSce23S7I4PEPB+tgl3KqJnZgEQxUSnVXbLHFheXCZJpNAxDDVxoMt82Xr400WkLtxnwlOMA/nUKWyZM0/U04fYoRbPU5Y= 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=WYujAjVh; arc=none smtp.client-ip=209.85.221.44 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="WYujAjVh" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-385e3621518so991496f8f.1; Fri, 13 Dec 2024 09:58:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734112718; x=1734717518; 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=lPNf7uIBjeieW0BTq46/mfPY9Pj6if/ReihPK1Mbj2k=; b=WYujAjVhl3aC1KZOBYGEFTxoF8KsLyRb4hmM8aPVVWGoK9CwW15GiB9BJdNcOO9cPs RjTC7H1aVahNUPamT0i80L1tqI3yzVl1Xh86d5/j1prXTKH8o39ATYKxCrv4A7gKkV0O E/cUmQQ/j10s/2XplRqPTopObkJLp4Z41pYItyCg/3umOoWwMLiZ016Vq/xVyxSd4OCY LYn5ByLHnptCzFIBl97oYa0tiGiFKXozITtZTbvjTpExpmSQkyiT4JAN2MF8r2GlDg7u s3rdj76OTeOgC+PnRoRhC7uIXLA1dWitmyZzoMGRVOZyqlsz2nhGx/bW1xThXvmSg6fy CgRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734112718; x=1734717518; 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=lPNf7uIBjeieW0BTq46/mfPY9Pj6if/ReihPK1Mbj2k=; b=Ab/pNdGJbR1WpKfRnIUgnKS6n60Ed3hb/OV+QCUsxiJgMZs34bRKqWU5LZWw+Ks74S gjP6vVYOD6Li+IigRbaLJq4d/EMsM/m2Z8xyYRox080n0G5iNEQyLFb7jpdYmAhAg9ea GYQyZtgJe8+ZFxJAThsW/fhr8MHqE2UkFFt1fwiEAFLJvENoNUrDL4vIbf96qo6bQYl3 /R3LnscQZk9BSZQBdwA863CevecGB9m4/ktnURGG6t5uBNbg2D+b35RNfH3FL75ggIIC MQoXacvqklf5PCOsX3s9C2hIwXZ/vG3UoFv1bGXcLcjcjradgHAZjOcXRdeVO8hh++Ib bdhw== X-Forwarded-Encrypted: i=1; AJvYcCVu3zPqusmDSyP1NSObPqNP9kj/KJyONbrhB340GEbg1KFJdWIXaOE7lQaaeJyBxVPSa2sY/bfmi5iXrxGK@vger.kernel.org, AJvYcCXLopjyhEgpJpe4cSwTMuir+Djyy2iiLMczryaHTBqhlwk9I5cuxoXg14HRiPUnzryVla33a33kpWA=@vger.kernel.org X-Gm-Message-State: AOJu0YzKE44X4HrZRhjI1wcWUQSPbvxf3G8EN0NJ4nMZX82jQiFvYEHm gSiiMXwv0oKt61iMpvwUPPMTitvGLIXKoDqfuUOT9QP+OZFAQDft X-Gm-Gg: ASbGncvCoT7W/quhcW6Ps2lXsYpqClq0WuLgDX1iUiyFHxT9/FAgDUU0RpGA+nj9lC7 EKsSJjv9QCgRQfh7Uyu7gt2ivMvaZSaTLwGe2d7m04RIX0SWEGZShvs5Ziul0yRZD+qDiBLL7Kd NrKviMeERt06z+XqI+PacR1w0yFhEtj75Szge+OJuY+j8hoPeVXZ1vrkFVhq9iGlJEytj0U2kst QUANO3Z4+cjXpbF8rfNHbNKFvx6nVTyq8hXDgpuPwC9DRR8r8akr6SgcYiy5QEkOf1D83o74RUD R4dccWQ3Tw== X-Google-Smtp-Source: AGHT+IG7mFRd97FR6mYhVVvYhtoBaFRLBuOIfm8PF3a9P3XL2Bf0khZUZ97iR4gF4s2kVDoMz5aKNA== X-Received: by 2002:a05:6000:2a3:b0:385:f1f2:13ee with SMTP id ffacd0b85a97d-3888e0b8b9fmr2813398f8f.46.1734112718112; Fri, 13 Dec 2024 09:58:38 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:4eec:e99c:89a6:d7a6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c804d573sm119088f8f.64.2024.12.13.09.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:58:37 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Philipp Zabel , Wolfram Sang , Geert Uytterhoeven Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 4/9] i2c: riic: Use GENMASK() macro for bitmask definitions Date: Fri, 13 Dec 2024 17:58:23 +0000 Message-ID: <20241213175828.909987-5-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Replace raw bitmask values with the `GENMASK()` macro in the `i2c-riic` driver to improve readability and maintain consistency. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-riic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 659b0702293a..487fa26264b0 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -55,7 +55,7 @@ #define ICCR2_RS BIT(2) #define ICCR2_ST BIT(1) -#define ICMR1_CKS_MASK 0x70 +#define ICMR1_CKS_MASK GENMASK(6, 4) #define ICMR1_BCWP BIT(3) #define ICMR1_CKS(_x) ((((_x) << 4) & ICMR1_CKS_MASK) | ICMR1_BCWP) @@ -73,7 +73,7 @@ #define ICSR2_NACKF BIT(4) -#define ICBR_RESERVED 0xe0 /* Should be 1 on writes */ +#define ICBR_RESERVED GENMASK(7, 5) /* Should be 1 on writes */ #define RIIC_INIT_MSG -1 From patchwork Fri Dec 13 17:58:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 850565 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 689201EE006; Fri, 13 Dec 2024 17:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112723; cv=none; b=fKJFqC4b/EpL1XVOI3iGiMRgTWyA1+0SS+Df7Ye9uGTXCQlUlmv9+hq+y9STm/q8clGDafiiP0Vewbzi3ujiVisUE09RPHjUSwdP0I825OgQmGyNPg36zZ08uIGgu7k7Boy4zC5Op7Pg7TeGFJIrKqnhFIA++cn2UnBOq4d8ttY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112723; c=relaxed/simple; bh=AhbwkG5EX1Hcj27wbvdujXUKwhLkJuv+2Gb2iyjaGg0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zd8Qgspss6Ata5TLC9oVc8BiraR5BckWRfoCk2+jRYbKFw2SODreuYS5lGTMIbRB78y+X93SDJc1/abBMV5uAzUgtfnt3GfpF1B5HNnlCrVZuz+6Q9Ot6S5eHJHi9brv/8f6yZd1Kr3S8ug514/QFG9UqlocLbbdjs9qlAdb2as= 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=DgbyM5lZ; arc=none smtp.client-ip=209.85.128.41 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="DgbyM5lZ" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4361f796586so24560535e9.3; Fri, 13 Dec 2024 09:58:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734112720; x=1734717520; 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=ZMWKkTzdj8DKVIv1nP3k0aiD5Wz9gMpH8BYSjw4iCUE=; b=DgbyM5lZFDu9k/W3XsNy1YR4w2yvCYLAQz15nkFMmMwVAA4wZyvvRPFnTgZgcwmMYF Msk4e3jEQu3wgQpDb1sx7t16RBo+Qcf7v8UaSb44lxu2feIwi897yD4am5/HFgAikgdl PttiIJ5toRa2QDdaAJFPfCdgW0IisXrT3e2sFunwREDGgNOrZtfOLjGK8lFfj7Z7Bm7A cgt+dTE8ejC77q6AZILiLR42EXzDHqn+PvehCNjq2FOOwbWePEdqxg27R79EzKLVlo3K cKtURHK8hPHTxM3NS3hHt1PeqDCcX49vMDQhQPzs+EDEEe9TYQNGXupv3VQXQyK8lRuM +XEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734112720; x=1734717520; 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=ZMWKkTzdj8DKVIv1nP3k0aiD5Wz9gMpH8BYSjw4iCUE=; b=QwseuB6mo46BIACMVsQVwenGvesyOAoUaxsEvW4M9rlVYSwfEnLiZNEitVb/Po/58s 2DMNdso0H4TcX81ZMdvWt75W/3k41CGlPFtXUtQ/GlpTNntWiidT2xOY0ugLIFvScGSw Z9SpKYIX1CmTTDk0WwWAjYuUgnBobhEGNvYKANuXVB98L6sxrjl16zJp/1E5z0FlCXpK V2wj0H5DvIgi0wzkNtVwiS1LTVSuwZudMyAT95FBMwXBNgq61MNHldD6jwp4QH+pHqnh 4o6YdSOZfng04tlNDpm6VYmJohrJbF4ZgU1KK8/bAJ0f4WTiVB52klYhDSw6CUAHtRoy qr+w== X-Forwarded-Encrypted: i=1; AJvYcCV+H6pwXW9gSVK/FtlL1cwQ50zHcWPfX/oIEYPVojnj1c5h/lIxYnKUG6xlpL1OPEJZB2E9UrKLuMk=@vger.kernel.org, AJvYcCXjyx/CVVJbPPjLbG66TwehGpSnaqJ8mGxAujBZKRVVvE08ZkJhjkfxM7PxAQYZC74spJomBXGP3LdEBFix@vger.kernel.org X-Gm-Message-State: AOJu0YwSQgy1OUgFKrZ5Zw+4ginVTGX2Ql8/tI8vJg/qMNIOjgpgPFXy EZBHn8u3SDgBBipGxt50xTwm4nXVUSrIvxqeWmZP8qgc6V+BWpoa X-Gm-Gg: ASbGncs3zFcVJVXNHPodpXfjYrB01tCFJXXZ85s4vnX666KaqSQLTL5oPMRm58uBbG4 okD08Ki8TlqKjlyz5C+QYDXjqeasFtVS4PLiaqcn+r6oY33/D/OAC1PF/twzlibLirrpW5JzFhB GYZMD2fxSu4J/B4eYLGVn6HIz36AhRxKdLtkDKr2kmbfcoKq2FcuuUiqEYr6rasuC3eTjZJ1xK7 sykDdjweeGbMX+W+A5fjy64cBlydRBe9+pu15NK7O4wUQehEXsX+UrYKqcfWYD834603sARLxwI ai/gVcvGBw== X-Google-Smtp-Source: AGHT+IFFvzvo+BgYEIPYdv9QhG0mMtRndQ0E4BmMrB01WgpcQo+o6kij8Qugk5H0PSio32gzXM2Srw== X-Received: by 2002:a05:600c:524c:b0:436:2238:97f6 with SMTP id 5b1f17b1804b1-4362aa1af5emr31723585e9.1.1734112719414; Fri, 13 Dec 2024 09:58:39 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:4eec:e99c:89a6:d7a6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c804d573sm119088f8f.64.2024.12.13.09.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:58:38 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Philipp Zabel , Wolfram Sang , Geert Uytterhoeven Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 5/9] i2c: riic: Make use of devres helper to request deasserted reset line Date: Fri, 13 Dec 2024 17:58:24 +0000 Message-ID: <20241213175828.909987-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Simplify the `riic_i2c_probe()` function by using the `devm_reset_control_get_optional_exclusive_deasserted()` API to request a deasserted reset line. This eliminates the need to manually deassert the reset control and the additional cleanup. Signed-off-by: Lad Prabhakar --- drivers/i2c/busses/i2c-riic.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 487fa26264b0..032cf0b1368e 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -422,11 +422,6 @@ static struct riic_irq_desc riic_irqs[] = { { .res_num = 5, .isr = riic_tend_isr, .name = "riic-nack" }, }; -static void riic_reset_control_assert(void *data) -{ - reset_control_assert(data); -} - static int riic_i2c_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -447,18 +442,10 @@ static int riic_i2c_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(riic->clk), "missing controller clock"); - riic->rstc = devm_reset_control_get_optional_exclusive(dev, NULL); + riic->rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL); if (IS_ERR(riic->rstc)) return dev_err_probe(dev, PTR_ERR(riic->rstc), - "Error: missing reset ctrl\n"); - - ret = reset_control_deassert(riic->rstc); - if (ret) - return ret; - - ret = devm_add_action_or_reset(dev, riic_reset_control_assert, riic->rstc); - if (ret) - return ret; + "Failed to acquire deasserted reset control\n"); for (i = 0; i < ARRAY_SIZE(riic_irqs); i++) { ret = platform_get_irq(pdev, riic_irqs[i].res_num); From patchwork Fri Dec 13 17:58:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 851141 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 CECAA1EE7A5; Fri, 13 Dec 2024 17:58:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112724; cv=none; b=PkECeAkvtDq9mR+bva60Ebqvh0M2LijCulw66mlAv05LtX8o0Gy5PIIUGAJk751Zz+d3twWPqdxwNxMTJqZ5tjSUV9ad5mYH0//K5ptVJERp0qNHf06WDx0XhMdfppADuB7AVbPbXKGbXuANgBWRNfU8MoatHaTaPiC7NFqAn7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112724; c=relaxed/simple; bh=ds8NCw46ssQGEQqUUOIbn2Ea79pBKLnCoyHVaH9R6+8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=anvJA1iEKB+uBPDN+NSsUhhOE1B5cLSCHaKs/Zl722DWxGdLJqrzCxZig3J1sI2DDKhhPC19yvB2dVkn5XOU7qpsZ/jhcU+qOtb5SdjevFzWPNpqhGqVw9bKuyYzhhPC4Hjeo4re29tdYqF6GweoCPWtOV1J2ywGVbYvYkPeMqY= 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=mlQXQEgJ; arc=none smtp.client-ip=209.85.221.52 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="mlQXQEgJ" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-38789e5b6a7so1061447f8f.1; Fri, 13 Dec 2024 09:58:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734112721; x=1734717521; 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=TiNH0sKIYgt1PPiF5X1cBcEENcf83pWJytTWM8aI9Ck=; b=mlQXQEgJ3jf3dNczZa0rUXE3J4ZuNmrwkimkFKYF3kurTm6yPKMmaDd5Qj7BFhCJLp fZyxSz22Upl6olDKhEPKFZfmqRWD43cxiRJRu4XTHo2MefUfOMHyUsa2uWqI9zOa9d+5 wBahb4fPlPIzBKTpANYMje2BkS7ah4Rm09y9PXiK7Tc3c/PKOLeeRggsChZkhEwwZqQH bi5wMrFmzQukhI/4ZsqLdMqmCPMY7MG4ffuwYLjxFAhku6M5A/6kLNx4nEtb3AhGRHfv Y1BHErQISUrb0rsBP/vLGYiSZ4p6VYWNewU5PEYI5AZiSnDPY5S5G1uj3QHJm7mGfRV+ 3i6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734112721; x=1734717521; 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=TiNH0sKIYgt1PPiF5X1cBcEENcf83pWJytTWM8aI9Ck=; b=VF2GYh7fdAjOm9Mg5TFlP9scWT+1D9zbRwQTHdvOjryEc1QYBzQWmMqOEk4dg8qgVs 1uftMmtLAc4gffYgs1L+JaTvOymt1lkjZrz7Ae/oadmMwmBg2TFJIN09O0wn7yQA7wrh zgoLDze6YRUGh/nrvUicqiekJIAJ1w2yuMyf99St78CH2dyegngZsmfOeeBPIMpnVYLq 715lZRZk0RSLRIO4z2nNpNp/q/QRe532vzNTDX7rvUgeIrbTu7MVBoUxAz2LWwFae9O+ 8WGvot8eKcfqpDO0ZnnuMFUi3U8t196WuKPQQSPqLDZT05VZwOpejK5vJdM+2F8itxhL ogzA== X-Forwarded-Encrypted: i=1; AJvYcCUGUJA8TRtFT5HdptA11AROGccyp1fI2RWTh7tNoQJp+SdmZ0tmXK6y/JA1Xv4ZCXblK608TUW2+qo=@vger.kernel.org, AJvYcCXBOEbiKZ6xU8brcxst1hjMg3Ur56EoxG4FsI+wTeqG61OFydVC4VBNgzUYiWYe48lo/xPmZ2aFNMK9qrEV@vger.kernel.org X-Gm-Message-State: AOJu0Yyqu45jPhjPwVM7N8pRLwcSZY+arRvEeMkb46VEnkNzQmQ9Afoo QQWP48glaqeeF1D7+6IvZP7CAay/JXInYFgCx1ZwJ2oAUMVqjLjz X-Gm-Gg: ASbGncuows0bgvWgV2ir8aIcittab/6Nsm4SPfVNnO0d1wNbf54PuEZ87TL7f1/i9uj RNDxfbHzfHjwi6enKB7jutz0L/8Mdgr4hWNKxjce+3iXh19QPXSRiHdYW1KmT34jdMMsBi522PZ BAuxdJKnSToZ1fNdIzdeGMixkPCA3zs2e8OgAYo4kg2UBBChe69tfA82UpQunlSEO1Vst8otu/o 1DXkB32AFhe3pCiOXt704xK81BZlQWwsCZNC+ZJpoM9EeK7OKoZMYx1TpBceDZr3FLMRkcyg1iF /JP1zRkcVA== X-Google-Smtp-Source: AGHT+IHVBCJt+7+MsngrIntVfZGLihZBqVCT0I+Sk3D782RivAOgWvy/pP1gVjqqVG9bQFQoFA4m8g== X-Received: by 2002:a5d:598e:0:b0:385:e1a8:e2a1 with SMTP id ffacd0b85a97d-38880af153bmr3219292f8f.3.1734112721109; Fri, 13 Dec 2024 09:58:41 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:4eec:e99c:89a6:d7a6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c804d573sm119088f8f.64.2024.12.13.09.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:58:39 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Philipp Zabel , Wolfram Sang , Geert Uytterhoeven Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 6/9] i2c: riic: Mark riic_irqs array as const Date: Fri, 13 Dec 2024 17:58:25 +0000 Message-ID: <20241213175828.909987-7-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar The riic_irqs array describes the supported IRQs by the RIIC driver and does not change at runtime. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-riic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 032cf0b1368e..e51bf911da0c 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -414,7 +414,7 @@ static int riic_init_hw(struct riic_dev *riic) return 0; } -static struct riic_irq_desc riic_irqs[] = { +static const struct riic_irq_desc riic_irqs[] = { { .res_num = 0, .isr = riic_tend_isr, .name = "riic-tend" }, { .res_num = 1, .isr = riic_rdrf_isr, .name = "riic-rdrf" }, { .res_num = 2, .isr = riic_tdre_isr, .name = "riic-tdre" }, From patchwork Fri Dec 13 17:58:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 850564 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 5B1801EF0B1; Fri, 13 Dec 2024 17:58:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112726; cv=none; b=IAYVA8K/DjLlMlfA4bVskGMBPIBIpnPNTJCnCKX2K+8Qg0MUx2a64d83Zlxy03uRQ2WONIy/diKwfggSp6VHIHqkWo4YVgIPF0dI0tjPFnH6smWygibCskTKcAjbQP5rpHBbgagMb+z3/3+CgQ6UIGq3pIyTLYchYaU6qbUqDhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112726; c=relaxed/simple; bh=A+D4b3BQmPK+Wger8wye87FzQJiq5IArXnw1p0rbQTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZYCIcm04Bp+uNlqRSjyvGCFn3VJYhw8iTlGTeL9xDycyZAANzBQZZX7GzVUTVIyEzPu33O2DCY2SsRjxLzRuPeTYDWGKQTiemPpvIT9VKWDBsoIxkcKC2B4wgZwF8EMbzio+jm+eQcLjx3GgpeVtsz1RPv5hjUhzMXg9x27azaE= 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=QTCbwpSA; arc=none smtp.client-ip=209.85.128.51 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="QTCbwpSA" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4362f61757fso8221635e9.2; Fri, 13 Dec 2024 09:58:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734112722; x=1734717522; 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=OAbrDsxEvILPM2FjpklK/XIsRBEt8VddEL8z2eQpt7U=; b=QTCbwpSAR2to7awKHQYXVTUfmfhUTEV1gpctyPd8sEupWoX6d9Cctl5Y/EhPVAC0vS RUI3nBxPP35KUUOkMPntULhRGesnIbfN1cW+Qi4djupWejCENnsd1rRJZumhVqFIt/ia bKQ4ra+3cYPyY4Mw4004sTIdszDZuGW5qm47xb5blFEtyVfvO9eNaScxxDawP3Xz8fkC Kgj0DCkYw3nksIjcCotv8JJHo36Y9m7RJCLXCnwFtrSfq26kLjL0eO8s6xuV21OEfp4S RYpwnpE+H2nwympJvzH+SCt16MT+zywIMEnDG14Z/v/qMx3wJp3fMTuS7F+6b/+3MvkU M9nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734112722; x=1734717522; 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=OAbrDsxEvILPM2FjpklK/XIsRBEt8VddEL8z2eQpt7U=; b=tWhjdHqu+u3+jeM133NW2IPQJHaKoriOSxCvJ6+d1NooY9yzmrnB9Z/Lu6/jj/Qt0o 7dzssOIvmfxsh2s8FfKD0+AQrJYLLNRm30xD1gZ/ARf1nm0Mi/ZpU0sHbXyQe2hvsy9Y /5dZrQSI2J+3yU4AK2SQ5YZwrPlrh3N9FNTym6zJYrxIPYLejyQD8juDyovOfja3njgC bj//9Ev8VMEP+RU1O2G8TzY+IOK+N8d0tGAHyaAxIQYSUZWTZyNp21MQFY3lE48ykvh8 KF5oFuk+rwT5hl4XZbmxkw4IKIUvwcMBnP8gk3NNO7V29TYo91SPlAqX1CqRr3lH101O Y6Fg== X-Forwarded-Encrypted: i=1; AJvYcCUqgFRA74G1huCMOsB16wnM+k+o8LpwWFbtLRSeSbotpuhFgyPHNE0pf22JuYykPLhjZWcEEAX3/y9p78/9@vger.kernel.org, AJvYcCWpTu26kW1lbKjj0kODHxUDu/oPMvz2F0d2YTBsiXkZKQyFg1rzNT+ghQ4pdt8eNIzkivz/yYXURmI=@vger.kernel.org X-Gm-Message-State: AOJu0YxZ+zYY+7nxGdO3+4PUj55jC3DA6NAeayDXdW4Wm6LJktbSwh1K fOfxwHp1KWsTifCyiJDtjgKqV/yfCyAhoS+ccLXYBp/UKmo7EQoQ X-Gm-Gg: ASbGnctqg8YDFsxEdNSl29liiXXI6kjW7NS7j+9CjMeYLXcMetG9WYFAH/lLiWtd3hs TUtyxZXKdHt0vz04HE0P4knN9J11WZDZ70UJN5IWqKeLgBK5o3GY5ZZLnHMEkKq7IGrFjze9zhO 0bPHkQFR3+ioUT+nbH8/VjRQqSsnTfMBCRdxs1YGjF/YeNrtemzzMXBMmMlJvp7VLYQFgeaGWpU ku6DOFHb2xGAGXn482edDtMJT1mowRhIuKf/2uacr32ncgeNGmZhrjxgnkeTJfI2/bt8osykz12 42jFqClywQ== X-Google-Smtp-Source: AGHT+IExtUcM7v+BXqiojll9F4g7AwEvhZz4YEHTKyRS6TOwpMVgvxozMVyz1/IHnc3IsPiBBD9xqQ== X-Received: by 2002:a05:6000:184f:b0:382:3efc:c6d8 with SMTP id ffacd0b85a97d-38880af13bdmr2651725f8f.12.1734112722356; Fri, 13 Dec 2024 09:58:42 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:4eec:e99c:89a6:d7a6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c804d573sm119088f8f.64.2024.12.13.09.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:58:41 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Philipp Zabel , Wolfram Sang , Geert Uytterhoeven Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 7/9] i2c: riic: Use predefined macro and simplify clock tick calculation Date: Fri, 13 Dec 2024 17:58:26 +0000 Message-ID: <20241213175828.909987-8-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Replace the hardcoded `1000000000` with the predefined `NANO` macro for clarity. Simplify the code by introducing a `ns_per_tick` variable to store `NANO / rate`, reducing redundancy and improving readability. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-riic.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index e51bf911da0c..48812e7d9cef 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -45,6 +45,7 @@ #include #include #include +#include #define ICCR1_ICE BIT(7) #define ICCR1_IICRST BIT(6) @@ -312,6 +313,7 @@ static int riic_init_hw(struct riic_dev *riic) { int ret; unsigned long rate; + unsigned long ns_per_tick; int total_ticks, cks, brl, brh; struct i2c_timings *t = &riic->i2c_t; struct device *dev = riic->adapter.dev.parent; @@ -375,8 +377,9 @@ static int riic_init_hw(struct riic_dev *riic) * Remove clock ticks for rise and fall times. Convert ns to clock * ticks. */ - brl -= t->scl_fall_ns / (1000000000 / rate); - brh -= t->scl_rise_ns / (1000000000 / rate); + ns_per_tick = NANO / rate; + brl -= t->scl_fall_ns / ns_per_tick; + brh -= t->scl_rise_ns / ns_per_tick; /* Adjust for min register values for when SCLE=1 and NFE=1 */ if (brl < 1) @@ -386,8 +389,7 @@ static int riic_init_hw(struct riic_dev *riic) pr_debug("i2c-riic: freq=%lu, duty=%d, fall=%lu, rise=%lu, cks=%d, brl=%d, brh=%d\n", rate / total_ticks, ((brl + 3) * 100) / (brl + brh + 6), - t->scl_fall_ns / (1000000000 / rate), - t->scl_rise_ns / (1000000000 / rate), cks, brl, brh); + t->scl_fall_ns / ns_per_tick, t->scl_rise_ns / ns_per_tick, cks, brl, brh); ret = pm_runtime_resume_and_get(dev); if (ret) From patchwork Fri Dec 13 17:58:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 851140 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 809B01F03CE; Fri, 13 Dec 2024 17:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112727; cv=none; b=n33bQ6G1HmPVelyLz7bF9jLS6i87CKeIDCS1W9ufECvNI8Uv6TBC7Qh0gBfaedtpyqdH0KiRv8mNyGTolkbmsjxpsoBcfxcnM1vPP/dDm1PHhDv/nVqYy8s5tLEGhD+SNE67mFR+YMdDWPvYW9hCzH5mnJJzFcBRb8A7M+SqlvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112727; c=relaxed/simple; bh=DpIe8jgrItvnhSA7SbrN6HdkN/siT0OgekjPRdjzvzI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oA3hk2qjKpayh46P77P06dda080VJguHJgs4tA7KuKUtdEZn1OKDCCY4eXOBqFXEowcV1ah7XHDurC7CSrB+hgSzLkLj6SBoKyGxkNZ+Xhz9ylJBmVEKkgBu/KKR+oHF2on2J7aUtuKyZUZYQ3RMDZK0MTtESVYWfOXH3HFp7SE= 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=hGMKp0Kd; arc=none smtp.client-ip=209.85.128.43 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="hGMKp0Kd" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-43621d27adeso14612915e9.2; Fri, 13 Dec 2024 09:58:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734112724; x=1734717524; 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=fmWil1cxIYx3s+bMSXeGjJtO1HSZn1VjUtrO9+QRfPU=; b=hGMKp0Kd/vf57E+jM/Flc/rye4lO6qHvjCL2aK7S4KbHQeKPNATWm3+CiOLuV9k4gq 3HY0kLk4GGoGoq3xZ8pJFlqxRnptt9qW6MKO5Xd5M1Gjm8H093VFxFwXlrcSmeuumdd6 ggUJHsbXwmeZ8WfDDhWnYq7gQvVtKSJyVqgTBz9Ak4LFRGerrhRyltj0oM2XyGZpr3W3 XLBmXeBAlG6Jz7cSJdk9Sl8+bUp++0TdsGxZiZ7LDSJ9Sr+gymI1vuDaWrhZFqs3GbqB w/DKRXaoABlWzlGyQv2BlON1jvs3tH62h40GCAdBn/haEPKlHfwxcL1BD9zgpQNYzh8/ qTuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734112724; x=1734717524; 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=fmWil1cxIYx3s+bMSXeGjJtO1HSZn1VjUtrO9+QRfPU=; b=XGq6FOQf4mwwhIakIlc4bEqE0HD0krQkwFWSIarmRg74fph8dE0mwhwR4zjsdd1qDB oUglYHjLvnrQ/B/Qdfa3WS7kS9nPB/P2B5ktrjKCTEXWCo/OExsmY9l1taZXZiMUhbxD OPchS8HP5Xo9KZLvIA0QIbSFrEytJ4QRGu7iWD2hRhGG8Q3nTaQB1yG11fIscFJdtu3D 2SBWe1lBDzrSvYf9LzbvSlzY262eiVelK4fnhVtVZX2Bdl1OtP19aA+NWEs3vowxAygk e9CaZlBNiATgREDelKOhtHlt3pU18qu7/5uUKyr9EbGhqNJcKWbryMki7IgZeuKAo71Z WM6Q== X-Forwarded-Encrypted: i=1; AJvYcCUHcrQ9r4BoooiPnOTrpMBDZ3DVsYHdWtl4NGtdV1o/unvNfYOuYMhx/6eF+KyyyOp6RpAZXdZLef1dHtJ1@vger.kernel.org, AJvYcCUxGat/wKYalq9KBKAVTbuUL1Ap/OKL9mhlbOGGn7n5SM4efoRgcftCnOPIk/GjZtzZRfQOGWQjCHE=@vger.kernel.org X-Gm-Message-State: AOJu0Yza6ie80mpYWcxYRIHKZ4x2r4V4uJvxXpQkfV9sMtfbw06bkjOs Rn497LIrv4iYBYy/6rcdqVqqSUUuP3cBXqLnaO6fS6ARPniOgwBd X-Gm-Gg: ASbGncvH+jS12yQ+hXqLQ47ejdWmGnS3OoX9i+dyTNimR/o/oOnZBGjRNJKXEyTs5qk Iod82I0K11daexiNoOPP1KWGH+GDJWXBklXsTab/0+oS5Q/QoWGQJD7vTc43F2ZnEOaacC0ZmEY VJg0H4igOYcWvRqsPVzt6Hkozh40UJykcWm6A9stb/bBUGy46aHfkVW6GMVIDQvbAuEicpYf4u0 mqvcDl9+jg2mvGzukjawYFDtjzUbajPxlwC+PovtsaREaWiURDy3pF8Qh9woTdJPQdHKPT4xu7k x9tWCyPMTA== X-Google-Smtp-Source: AGHT+IEDHANdD0OtyAiI+EfqRMxcoPqhmLiqQ33TANc7Xqyva6QVsG50d/sXV3IKiC+zIFMXPK+inw== X-Received: by 2002:a05:600c:1c82:b0:435:9ed3:5688 with SMTP id 5b1f17b1804b1-4362aa6f39emr33644775e9.18.1734112723656; Fri, 13 Dec 2024 09:58:43 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:4eec:e99c:89a6:d7a6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c804d573sm119088f8f.64.2024.12.13.09.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:58:42 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Philipp Zabel , Wolfram Sang , Geert Uytterhoeven Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 8/9] i2c: riic: Add `riic_bus_barrier()` to check bus availability Date: Fri, 13 Dec 2024 17:58:27 +0000 Message-ID: <20241213175828.909987-9-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Introduce a new `riic_bus_barrier()` function to verify bus availability before initiating an I2C transfer. This function enhances the bus arbitration check by ensuring that the SDA and SCL lines are not held low, in addition to checking the BBSY flag using `readb_poll_timeout()`. Previously, only the BBSY flag was checked to determine bus availability. However, it is possible for the SDA line to remain low even when BBSY = 0. This new implementation performs an additional check on the SDA and SCL lines to avoid potential bus contention issues. Signed-off-by: Lad Prabhakar --- drivers/i2c/busses/i2c-riic.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 48812e7d9cef..919da1bdcce5 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,8 @@ #define ICCR1_ICE BIT(7) #define ICCR1_IICRST BIT(6) #define ICCR1_SOWP BIT(4) +#define ICCR1_SCLI BIT(1) +#define ICCR1_SDAI BIT(0) #define ICCR2_BBSY BIT(7) #define ICCR2_SP BIT(3) @@ -135,6 +138,27 @@ static inline void riic_clear_set_bit(struct riic_dev *riic, u8 clear, u8 set, u riic_writeb(riic, (riic_readb(riic, reg) & ~clear) | set, reg); } +static int riic_bus_barrier(struct riic_dev *riic) +{ + int ret; + u8 val; + + /* + * The SDA line can still be low even when BBSY = 0. Therefore, after checking + * the BBSY flag, also verify that the SDA and SCL lines are not being held low. + */ + ret = readb_poll_timeout(riic->base + riic->info->regs[RIIC_ICCR2], val, + !(val & ICCR2_BBSY), 10, riic->adapter.timeout); + if (ret) + return -EBUSY; + + if (!(riic_readb(riic, RIIC_ICCR1) & ICCR1_SDAI) || + !(riic_readb(riic, RIIC_ICCR1) & ICCR1_SCLI)) + return -EBUSY; + + return 0; +} + static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) { struct riic_dev *riic = i2c_get_adapdata(adap); @@ -147,10 +171,9 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) if (ret) return ret; - if (riic_readb(riic, RIIC_ICCR2) & ICCR2_BBSY) { - riic->err = -EBUSY; + riic->err = riic_bus_barrier(riic); + if (riic->err) goto out; - } reinit_completion(&riic->msg_done); riic->err = 0; From patchwork Fri Dec 13 17:58:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 850563 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 C9DBF1F03FB; Fri, 13 Dec 2024 17:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112728; cv=none; b=g7ayr46N5jSew43kw8uFzV5mlglp0joaz3clXrfQS7DpLoPMZQFN/I3+UzvpNkuxw8TlwAnPS51UgnKzi5HBj4+w5qsG68JLQ0WcFdn27wpkrMdMItIaBlMi5zCDe/6uC/PxjSYwSktdqBrTHqLFW7PwOWJffMtjfE8LoXQxYWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734112728; c=relaxed/simple; bh=lriouYN7gltsmvsMjKZ43H1+bGtuTffBvCHZIZdPPTM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cgRGeaYIYL463uT8nVgxu4BRlJeGYxnxEJCBnP6H1dO0GpaiTzaFYfdCoMchhmsolGmsyTM0FavlE4etSTRaZ0Z3JFPI1isO3LFriAzsi/WsNVfuOrfHVKMvKIAGVmzHvWMdh8pG+SfCZmTIGAI5wBVtLU6TtY7itmLnEytDRJs= 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=kNQ2Z8Oo; arc=none smtp.client-ip=209.85.221.42 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="kNQ2Z8Oo" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-385de9f789cso1562396f8f.2; Fri, 13 Dec 2024 09:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734112725; x=1734717525; 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=z2uJf1DDqCWGIBEcHQR60EdB4n+QJNrWV4tvY6UExko=; b=kNQ2Z8Oo8kOFJ68hdbRRIdqBZai34guxV2Ol8eWI7zvHmgiPyf0FCvXssgxM/8hJFl HACVlerdmS7yiU+BvORragKznf6UibZSO4Wwi+W6Ub3fRcHeNsB2elzW7fO91Ta6ZH0l gXitNohC7JWACjZJEEewzQIBcrnkHgtHUaMW6jpQ59C/KaGqspFevj4r7E8CK7NKZePj 3dcs7UqiywVLAA4kvnLMxPtOrjl0vbaIWp36hH2cOshZNXDQQ8RAVL96dzJ6pMEd0O+d txi/w/tkZqp/RuunHxyTKUXfRBk+QzZy3eksBZPpcpfQGSbmG9eelMmpghwuOxmLidFo BY9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734112725; x=1734717525; 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=z2uJf1DDqCWGIBEcHQR60EdB4n+QJNrWV4tvY6UExko=; b=wraiAaTM8FIErwrYvuwmKWHUOidJ3FQw+vD3SdsNICiRqxa51ja5D+5+m48GV1GLtQ gY6cTICVwNgaWKf3dAinv1YV+8Fg+Q5yzR3DnBDn+rtgpQwFwHSrVBHWd/9GnvuZ6bex eNsNSvVysK9xs6YgnkqRCtrSY9rcCryrs5TIrPqlnOVsIuSM3Q4vLPodx1ov+u0i2ivf Zb358bLOFn+yMhSvKzmDEtSK+pWq1Nx95hKb9eha8dD9wdcGCD6AL35g8Dep0Ue57Fmh W1IMq5fmFDoIRzpjEvltxEO7yksLgQNb/72g0yo7dNlbprgZmZEc2PYFfrkKAkG9NR3x s4PQ== X-Forwarded-Encrypted: i=1; AJvYcCW0CfcHNGaUb5H4N5N7TqFc+8h6P9kmNFm2oFXJNgCQzTL0Bo9yYWNp2pMnhRaPcslELnzmp+72EmE=@vger.kernel.org, AJvYcCWT1QWq7SJoIwGYDaDpUJKD13msoSLNuGeyihkPAxLNOMNNSMyc5pYIQrh3DIl5swnjnXHmhI+Yl5FNkdr8@vger.kernel.org X-Gm-Message-State: AOJu0YyRQlJaMptmjH6bozP7BEXq3aSWLDtpDmYgz6bWbN9qc+IMko7E owUN/1jQy/eja53yoNzTrovSiFfwsz5WkzclBZcJId24vZuqZeMP X-Gm-Gg: ASbGncvFmxm0KUKKWOCpgoNyJwfG3wl0jFHwQsPMyaoxd23IUwmFIAGFqtkP3KI7aO1 hZylSKZfpuZWUMCPFjz03C6xydvaNrJes6dmffG9OgoR6NvBrUhJGT8KWGt/19tusPIAAHRDDoN V9mvxzmBTPD4kPNpTGaCyVbt+Whk+Jap2eLTkzT+fpao8bBqbLpd/MHnzUNjeD8KwNCxXBMV+2Z 87teVqkRkyd0xhDAkZdHoZlls+HJ/Y7WrW3Vs3jryRy8LTs8AJ36WI/KKXvi+ugQhB0JfrCxpV7 wVWx/TrjoQ== X-Google-Smtp-Source: AGHT+IEHsqN73p8/xBHRcyjY2csNfBRQd3dXrr5hc7WC3ejmqCtWnK1A5/5hAs6MXLMpxEy5ii3hkw== X-Received: by 2002:a05:6000:2a6:b0:385:f527:be6d with SMTP id ffacd0b85a97d-3888e0f4763mr2698209f8f.36.1734112725051; Fri, 13 Dec 2024 09:58:45 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:4eec:e99c:89a6:d7a6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-388c804d573sm119088f8f.64.2024.12.13.09.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 09:58:44 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Philipp Zabel , Wolfram Sang , Geert Uytterhoeven Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar Subject: [PATCH 9/9] i2c: riic: Implement bus recovery Date: Fri, 13 Dec 2024 17:58:28 +0000 Message-ID: <20241213175828.909987-10-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241213175828.909987-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Implement bus recovery by reinitializing the hardware to reset the bus state and generating 9 clock cycles (and a stop condition) to release the SDA line. Signed-off-by: Lad Prabhakar --- drivers/i2c/busses/i2c-riic.c | 100 ++++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 919da1bdcce5..cfb57e1de01b 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -50,6 +50,7 @@ #define ICCR1_ICE BIT(7) #define ICCR1_IICRST BIT(6) +#define ICCR1_CLO BIT(5) #define ICCR1_SOWP BIT(4) #define ICCR1_SCLI BIT(1) #define ICCR1_SDAI BIT(0) @@ -68,6 +69,7 @@ #define ICMR3_ACKBT BIT(3) #define ICFER_FMPE BIT(7) +#define ICFER_MALE BIT(1) #define ICIER_TIE BIT(7) #define ICIER_TEIE BIT(6) @@ -81,6 +83,8 @@ #define RIIC_INIT_MSG -1 +#define RIIC_RECOVERY_CLK_CNT 9 + enum riic_reg_list { RIIC_ICCR1 = 0, RIIC_ICCR2, @@ -150,13 +154,16 @@ static int riic_bus_barrier(struct riic_dev *riic) ret = readb_poll_timeout(riic->base + riic->info->regs[RIIC_ICCR2], val, !(val & ICCR2_BBSY), 10, riic->adapter.timeout); if (ret) - return -EBUSY; + goto i2c_recover; if (!(riic_readb(riic, RIIC_ICCR1) & ICCR1_SDAI) || !(riic_readb(riic, RIIC_ICCR1) & ICCR1_SCLI)) - return -EBUSY; + goto i2c_recover; return 0; + +i2c_recover: + return i2c_recover_bus(&riic->adapter); } static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) @@ -332,7 +339,7 @@ static const struct i2c_algorithm riic_algo = { .functionality = riic_func, }; -static int riic_init_hw(struct riic_dev *riic) +static int riic_init_hw(struct riic_dev *riic, bool recover) { int ret; unsigned long rate; @@ -414,9 +421,11 @@ static int riic_init_hw(struct riic_dev *riic) rate / total_ticks, ((brl + 3) * 100) / (brl + brh + 6), t->scl_fall_ns / ns_per_tick, t->scl_rise_ns / ns_per_tick, cks, brl, brh); - ret = pm_runtime_resume_and_get(dev); - if (ret) - return ret; + if (!recover) { + ret = pm_runtime_resume_and_get(dev); + if (ret) + return ret; + } /* Changing the order of accessing IICRST and ICE may break things! */ riic_writeb(riic, ICCR1_IICRST | ICCR1_SOWP, RIIC_ICCR1); @@ -434,8 +443,74 @@ static int riic_init_hw(struct riic_dev *riic) riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1); - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); + if (!recover) { + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + } + return 0; +} + +static int riic_recover_bus(struct i2c_adapter *adap) +{ + struct riic_dev *riic = i2c_get_adapdata(adap); + struct device *dev = riic->adapter.dev.parent; + int ret; + u8 val; + + ret = riic_init_hw(riic, true); + if (ret) + return -EINVAL; + + /* output extra SCL clock cycles with master arbitration-lost detection disabled */ + riic_clear_set_bit(riic, ICFER_MALE, 0, RIIC_ICFER); + + for (unsigned int i = 0; i < RIIC_RECOVERY_CLK_CNT; i++) { + riic_clear_set_bit(riic, 0, ICCR1_CLO, RIIC_ICCR1); + ret = readb_poll_timeout(riic->base + riic->info->regs[RIIC_ICCR1], val, + !(val & ICCR1_CLO), 0, 100); + if (ret) { + dev_err(dev, "SCL clock cycle timeout\n"); + return ret; + } + } + + /* + * The last clock cycle may have driven the SDA line high, so add a + * short delay to allow the line to stabilize before checking the status. + */ + udelay(5); + + /* + * If an incomplete byte write occurs, the SDA line may remain low + * even after 9 clock pulses, indicating the bus is not released. + * To resolve this, send an additional clock pulse to simulate a STOP + * condition and ensure proper bus release. + */ + if (!(riic_readb(riic, RIIC_ICCR1) & ICCR1_SDAI) && + (riic_readb(riic, RIIC_ICCR1) & ICCR1_SCLI)) { + riic_clear_set_bit(riic, 0, ICCR1_CLO, RIIC_ICCR1); + ret = readb_poll_timeout(riic->base + riic->info->regs[RIIC_ICCR1], val, + !(val & ICCR1_CLO), 0, 100); + if (ret) { + dev_err(dev, "SCL clock cycle timeout occurred while issuing the STOP condition\n"); + return ret; + } + /* delay to make sure SDA line goes back HIGH again */ + udelay(5); + } + + /* clear any flags set */ + riic_writeb(riic, 0, RIIC_ICSR2); + /* read back register to confirm writes */ + riic_readb(riic, RIIC_ICSR2); + + /* restore back ICFER_MALE */ + riic_clear_set_bit(riic, 0, ICFER_MALE, RIIC_ICFER); + + if (!(riic_readb(riic, RIIC_ICCR1) & ICCR1_SDAI) || + !(riic_readb(riic, RIIC_ICCR1) & ICCR1_SCLI)) + return -EINVAL; + return 0; } @@ -447,6 +522,10 @@ static const struct riic_irq_desc riic_irqs[] = { { .res_num = 5, .isr = riic_tend_isr, .name = "riic-nack" }, }; +static struct i2c_bus_recovery_info riic_bri = { + .recover_bus = riic_recover_bus, +}; + static int riic_i2c_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -491,6 +570,7 @@ static int riic_i2c_probe(struct platform_device *pdev) strscpy(adap->name, "Renesas RIIC adapter", sizeof(adap->name)); adap->owner = THIS_MODULE; adap->algo = &riic_algo; + adap->bus_recovery_info = &riic_bri; adap->dev.parent = dev; adap->dev.of_node = dev->of_node; @@ -503,7 +583,7 @@ static int riic_i2c_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(dev); pm_runtime_enable(dev); - ret = riic_init_hw(riic); + ret = riic_init_hw(riic, false); if (ret) goto out; @@ -611,7 +691,7 @@ static int riic_i2c_resume(struct device *dev) if (ret) return ret; - ret = riic_init_hw(riic); + ret = riic_init_hw(riic, false); if (ret) { /* * In case this happens there is no way to recover from this