From patchwork Wed Dec 18 00:16:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13912741 X-Patchwork-Delegate: geert@linux-m68k.org 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 40E061BC4E; Wed, 18 Dec 2024 00:16:31 +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=1734480994; cv=none; b=LMPDvm1XptlD+xoRZhkU8FmxsJqee2rdFT+cUwg/H3RSVz5UTzFp0TamCb8LtwG3Rcnt/Dfh9BISGlBJ1W6ZXO8ZZ1GFJagbhXOW22+3s7R5fojynXJg5pvFTUIZPxGmE3DmAVb1uo9DAIz1Y5JRzvz0RPLFRM6IwZ5JuR8Mkh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734480994; c=relaxed/simple; bh=9UUTeXz/RmiSiTM0WHtuMQr6xXxy7ucGYpUuKtc3/d4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NPe+kungXo85+5LvoA/ROZntfbV423RG7Jt1D6/+uyegRqojIdKTxMYnSYu7zDED29tmDvZ4kQ2xMCDeeEdGt2zU9uApVEjkBSAwXiGWUGPBSWBfh9Qs383Byz6OjE7mywRfjX4X79+Ymxo1AGbBc4IKtYGDdqJr80WvS+v/bv8= 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=Yq2feY9y; 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="Yq2feY9y" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-435f8f29f8aso42779855e9.2; Tue, 17 Dec 2024 16:16:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734480989; x=1735085789; 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=jkc1OJpwev5kmjBDTJJp++J5Vm9mWdZNE430qDxhZ30=; b=Yq2feY9yH0fLM0TD1v0x4l5q6cv0TyLZ+VzWS2prOJz7FFAePqls0viGN9omv6Go5g UN/VFVIo3TTr/OhmmP4CI3cGjL7ZHQYH9NhN3UTP1GbxvzY3N7yuZRc0V5V3JeRMu0A1 ia/P4/k/DdfHePJQE4klu+Df6U+NxxT0cKwk4Hj8zVFIOAwAe8uUnAq76j9mbLfv0Hpc HsXuBkVlG/r4fBQ9+83cnryIbC4BJl39V6uUKToQIt88hIw6ohmcxAeDFWkU4CHMrrMh 4l3Gv8ju8hUjyHlOGYsMKT7TpZDAI0SDRby0cR8Ugskn4SM/t0btZE6sGt3n+8eaeem+ OfVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734480989; x=1735085789; 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=jkc1OJpwev5kmjBDTJJp++J5Vm9mWdZNE430qDxhZ30=; b=nWW2NsMeD+whAFp6M0dm30HgJivAlhQHVci2FWnNZRijVopf1nDTiu8n2hSva7K22/ TXthcYM3gwLK0ldNVuXeIpPYwKYtD7OYM8dpOGU8qbtaUJZ605imSTit+EgGrUxKzMms L5xBy+20vah0Bw/zsQtQO53eWD3E2mpYOZWM5JSapclEPomElHQgUdHw/KlLkSN7K09Q x7lhIb5l46XlbCipKNflf0wOtvlS80ZZlZ86q/unJMnqgV/EkTmAe28hxn/1nh1pRvCW S9plH8kwfsXE/xioQIEx4YgMsRwue7NpVgz/gZZYlyvvn2Jpr0a7DrV3zUqNeCu41wm9 pOXg== X-Forwarded-Encrypted: i=1; AJvYcCXGkvTNOYJTcKOVC09v8zQfIJmKq/aP3O2eH4t7kLIkooflDzQkp+zILWJMibYqU1pphSCsTdQtve2iMWwx@vger.kernel.org, AJvYcCXQajKjfEi4VuB4BNUcLdVWlM8b3nEi7SyUkErqgMH8ZZUqio6sHV5dtHdj5rQ2W15/IXfYVb7oYz8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw25wR1WXTv8t50Z/Oc8NdEKJfC06/WerjQawVubAXyFlnn6TSu uBulpuGU/Rw2+GALYh69AeyTcNdpYgIb4cPLW6UvJSbyAOUTqgOw X-Gm-Gg: ASbGncvyfY+H6ba2K7RPOww1Lg5NiSxx8rUEfwSOQwkIc8/ojsoV8RilbwxoW6bX9Oi BsRX3uedrenQ455PoxJWG5rYbmkB2sqL52yUOqhi0axNSq61TI8mH8Rou9XmcOnkD1tU8meeWes In8jXGCp1eEHfHU9CwqqcA0duri0aBte3nPO/qIZSMNBHhAkadFJUA2/vI+gdIQAksu+PCKnnMK pc/udgXrTUPC1HOOB6cNiUsNWEl33oGy674FLXaf4Ii97QxYejdttqSes2S9bhOWkMqqrtfLUx4 KllJUTns9g== X-Google-Smtp-Source: AGHT+IEpWdpeUxKa3hgntdssG+zj9KJrUSSomOvQiuiUfgGJfzeECG2boqvJKxhRp5CGAsEdo0qZdA== X-Received: by 2002:a05:600c:3548:b0:434:a1d3:a30f with SMTP id 5b1f17b1804b1-43655345212mr4792605e9.6.1734480989251; Tue, 17 Dec 2024 16:16:29 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:ca61:1d3a:8af0:1c5a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b1f638sm2135495e9.37.2024.12.17.16.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 16:16:28 -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 v2 1/9] i2c: riic: Replace dev_err with dev_err_probe in probe function Date: Wed, 18 Dec 2024 00:16:10 +0000 Message-ID: <20241218001618.488946-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Wolfram Sang --- v1->v2 - Collected RB tag from Geert --- 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 9264adc97ca9..bfaa2d728a76 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 Wed Dec 18 00:16:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13912742 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 D92931DFEF; Wed, 18 Dec 2024 00:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734480996; cv=none; b=mQysAaxdwmOJIW0QR+9ONcTZm66NWZhwL25v2/UXZCOaTiQ6D7B4a5VP+xNubhZDlUdQ/gYpvtgglHLasf6JUQckVs2C0cBNrr2tJKvW79+qAM06heZQSnAMwgaLgS7HfotSWkneiraPREaGeiiWpx7GbXWHaJXrtQxXoPR7Dpc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734480996; c=relaxed/simple; bh=9Zgdf8GcOmbG5Lek1iph43k0r5RM2tt/ze3lY3aEvCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eBaqDecdYGCNj78t/mripnMmn8Pee478rxx8UJuGZv2+NTdBgnqlH2dQaHryUF7q97UM4H+m2RGl6/2iyL0N1vgV6HPI76AmayW7rBF+z4SzrP9J+rYyZkMIs0hafUC60xVGkl8KGgpkAg4EQsMcJjqoHVr7mFUc+GFgthSQrJ8= 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=C1zZgCyP; arc=none smtp.client-ip=209.85.128.47 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="C1zZgCyP" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-43622267b2eso61993155e9.0; Tue, 17 Dec 2024 16:16:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734480991; x=1735085791; 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=Jdk+v5oA7a+91eT3zlymmBbh68yix47J5FdaOJ1BhfQ=; b=C1zZgCyPoIaw6msoRq0O4eNCrGzaF7tB5jWvHpb2IgTMzAOT1g5deOYafQSzl5R3sn a2nV5pFL/T7Ml9Kv0WhKwqbrk1qmNA47GBAIHgkcgUwfvNKOVLy+quRtPOc5GnBES1MP 3i84qEn948CfOV+3tSb7SbSezojNXZmnvBGAlef5vEI+/wam5A6/yaJgNebRBarQ8Zwe YSnruydOmInx/W5iuWbYk/WWl7ifxbmcle92xPmKdh9p5rOKxONl3NKVaSJ16w6Z/KTV wRvE1NaxSntxuIfZw08KvGI4WINhnh80D2kKfehehG16+IZNBYiAZJCqkRjgR9OGbt/P nmzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734480991; x=1735085791; 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=Jdk+v5oA7a+91eT3zlymmBbh68yix47J5FdaOJ1BhfQ=; b=kZ9xXEmUdjDGLKSMDkeF8o8PW/k3yV/ZgMoaJZdDY5SnUidtaF1iA0Hh2l3z5l0pzG 2N7AHkG13YfCpatJScDsvHvEoCOFVlIhFCOlA5dB0F3RvcaIFGkQRIYEA1cJRjga3WeT 5eQgUwtDrevuvXFibPT9w++yM0t9RIuOjxBh4MgqkRXJ7AzUdMADiRh+Axd863uunB5w JzzsgMpX/w/fF865kYrWPUWTjU9fqj9w3IGm+74lR5b7aEWEaVsCckoPiYBGEiN7hzYe i5jxATEA2HZiVnDRtbpRG8SoVUjfCHfKlKjcXW8RgjiYqOvFikYrjIW6KMjVYnxaQchb +YBg== X-Forwarded-Encrypted: i=1; AJvYcCUOHq5/aYx5YyjVUEEyQv8yDnf4Yh3hfX0ANgnHfzAYGWPCYA3KqGZg81AIOsh7ywrypTiJb7ZZXaM=@vger.kernel.org, AJvYcCVaDQOT8lxmSHUqwj3wEK11BBmbxVzPIbiuoV67DNnlVIqsMarQtQ56yWJZvNB4DFFevlnHB6ttyGOLDgKS@vger.kernel.org X-Gm-Message-State: AOJu0YyQhP3wtfsyZyf9MDhROd8UgtWcTfAXP3tfqvwbrs6Xs2JJ+1Ff iKmqpVlmqlxiPi9pxsSOJPKN72wrV3BzvQqArtmz9FK1W+CAp3mG X-Gm-Gg: ASbGncvCXEmYpHhW4WTOELKW2qjwYcoz6l8ydMavkTEXvPu4wUZXU5TH1uaSD4tzqi7 Vq/PHz6EsiLfZl6wo2ZncHWiZouS3MlLbqVOlpqNVhadoxjz7ZhyU38KE+fm0w/aO3R+ApdGmaN 3UzgYa62O7BgkIn80fSVn9XTme5hXTlASL8xceoG7xN099WwyDYipL9Z79Ee0OY+ASzkjmOb5rM VAuyqXxfEfbj3pbVQI+7miWsf+a1Na6XyTN3VV9yad6eXk7gPBCfTZe+EQKwm42srHRom8VY848 g+aMWKA3Xg== X-Google-Smtp-Source: AGHT+IHs7nUpX9A8X7hKdIh/sm8IPJuB9OW+GNAAhaFZws+HFi2VUo+MYJe2v3HA0oleVxSgTOtWiw== X-Received: by 2002:a05:600c:4586:b0:434:a1d3:a306 with SMTP id 5b1f17b1804b1-4365534535bmr4514145e9.5.1734480990861; Tue, 17 Dec 2024 16:16:30 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:ca61:1d3a:8af0:1c5a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b1f638sm2135495e9.37.2024.12.17.16.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 16:16:30 -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 v2 2/9] i2c: riic: Use local `dev` pointer in `dev_err_probe()` Date: Wed, 18 Dec 2024 00:16:11 +0000 Message-ID: <20241218001618.488946-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Wolfram Sang --- v1->v2 - Collected RB tag from Geert --- 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 bfaa2d728a76..01195ffd4c07 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 Wed Dec 18 00:16:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13912744 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.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 844F519BBC; Wed, 18 Dec 2024 00:16:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734480997; cv=none; b=kSUju4vaIBHt1UzYjlLlYN1sLPCf/HDMhi/3lTsJspB0G9xCMoD+rcuGbjZLbT4o2dF1s2tkOEC0cDr555pS0psb/NzDoORaZIKKLBwG4J3NQjuidCDs2SCSUsACDU0t65Q+jXJXwWpnfi2QLv2bHItVmOdsM+//1ZOFaqqZd0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734480997; c=relaxed/simple; bh=DlHusKjm5MYxKJgaJjDb8vAXc89QRVe1imEnLwqhHgg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XHU/ynNeHOUeI971uXXev1nVBQ2vC0JTf9pwMiPnjcjWHtgVWXOHWCwcHlq54qNThy0Q++yRXI91Zmvf4mjArgmFHZXzt3qwS9wOpm7w8U5coR7ohzp7wcmtGWhpFeoHO92h+mSHrmLP4iuM3m2wqV2COE3x/fXa4dTkT+ocXp0= 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=JOr0Bicz; arc=none smtp.client-ip=209.85.128.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="JOr0Bicz" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-43626213fffso1267325e9.1; Tue, 17 Dec 2024 16:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734480993; x=1735085793; 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=yNw6LJnURoiyf5a/UCknyuAtawx0cwOabKiECwUUDWs=; b=JOr0Bicz0ZZ8/rWy9ult4f+to66gkQKofEo6DwYub6Pn7NpFpr3jOlQLB/EmH4f2uN 9HGTJZWs0Db7029i8ts78ske18TRX1IvTa3ez0/MO4rL6pJ+4K7KfiUEjTBsH6rhbzL3 U0D8TBqmaqx0Os17e2f4wAnR9CNCYKUuzXLQ/PptkW/AmJCyJD8dJLBCzFjXwsSTz7ki 5ky/xvi2IhyUXugQndBPBeRhl/TW7bYDsdWYwZVEMimzMnuZAWacllH3ZugPa9jtCtH1 jO7WGstC2OtMbxQsywCoO1kNkDJeqL6B/knZUjrRLVPX20Y5Tqt/UYOucj+q90lfzShn 3VQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734480993; x=1735085793; 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=yNw6LJnURoiyf5a/UCknyuAtawx0cwOabKiECwUUDWs=; b=D0oAuu9q3n97kfn4o9cCQtD91h41FgSA+toZqQ+tnaL4k9J4+X3FL8ZMzYLLH/OexQ k0djAT1M8zzy3EaSgsan7+scojGUZA81PmHhZlW3KaPinsgML2vogr1zQES28gASiB3c XWXPmGO8zwKH3GJ/eNlWpMm5qV4NSUmVnafchsYd/9vDRWU9x5/wKi7x9Gi+szpkpHhd GalhFKQRXfE6KjetqgleBTwgOZ6mkxYCFuKP6Q1zMnrNqZNmGO+YD/OuEYXhDnHz7c1R Td+u50qDCLKMFEVDjmhTLghtFQvoEboF1I58zV6nVC1sgbwORYylgv9p5E905TtOsYL6 jo9w== X-Forwarded-Encrypted: i=1; AJvYcCWL/BEFyABQnMigkd3YxBSTFjTxDn9CgdlAMPw8nIKnsK9gdcmNk0Fws7iwQV9zJTF+6naBqIRAESOuWFNa@vger.kernel.org, AJvYcCWvgY7TvXTt5khlEOdDbo3hTJE/83+vYJo0E69pN01MjFwO4Z0AfSdKhgXd8fJzfbMxKOFAt+/9PwA=@vger.kernel.org X-Gm-Message-State: AOJu0Ywy4T76MPNDo61eWYwdWmUcb860H6AZB/9MB7CobXuZEEZaXm8u lGRbOnErhvhzGXJF1sQHM8HHwjHDE7abTBEx0IiFyKEFbXrLiq9I X-Gm-Gg: ASbGncteJ2zRPsLmpBwJo7YBIp6IXEIj2LE7sbumPwxLYlUvBhzAUqnPR6Mk6G7eoD4 x8suTTLxCyeRTHsesD9Pf7qSv2zcLbEXyhUo5LORXirmodbcbthrw4KIyTq3qkoJIK/vwZD3mlM sM/s00tSa6iCFIjGU1FBrpqtB075Tkr/+6DpQxunvdkB03dd7B1R1ZZlRnyd5fH+nrlhd+X0old +o/cjCr06RRDgfBEEt0b/D2ds7FwGifVTVHnJvyj8GRz4AhAreC4ygosqNkOxa042axyz4xv89L VOadWlvkvQ== X-Google-Smtp-Source: AGHT+IEgMHKKICwiWXw4q352qa42ek2pm3QiKHPT7PQNLvpbYvEoxzbU9PgzdrV5qsScJdYOMCyGDw== X-Received: by 2002:a05:600c:3516:b0:436:1b77:b5aa with SMTP id 5b1f17b1804b1-4364815c7d6mr49268975e9.8.1734480992542; Tue, 17 Dec 2024 16:16:32 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:ca61:1d3a:8af0:1c5a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b1f638sm2135495e9.37.2024.12.17.16.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 16:16:31 -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 v2 3/9] i2c: riic: Use BIT macro consistently Date: Wed, 18 Dec 2024 00:16:12 +0000 Message-ID: <20241218001618.488946-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Wolfram Sang --- v1->v2 - Collected RB tag from Geert --- 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 01195ffd4c07..954e066d61a8 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 Wed Dec 18 00:16:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13912743 X-Patchwork-Delegate: geert@linux-m68k.org 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 DBC5D35952; Wed, 18 Dec 2024 00:16:35 +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=1734480997; cv=none; b=j0/1jOwssBgbDIOD39l9chvJxJdSPOCCgHU4sR3LkbAd7KBBEN4Jnx6C0XF8NNodR3B0/tzyi+cXln3tj9P5gAR0+Go9ZyuGzisiZ79mg2gvjxn8Ny/cR7bahN3rZoMICDrKT2fc1IX3Mjvuc6nAa44wN3l/yD96VOF2SvxHFxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734480997; c=relaxed/simple; bh=aKv/SnjD32JL/k+ADGSCQVQI0Gudg9gQc25t3nYAy4c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f3Xixfti7RvdXEfc7XecoVe5keUbyTSt4BsafBWijruT1imK2ZUIn96KPAzCgCUxP3wy+g6n9JdDB9WEEsAzIj/R8eWnmxx9DFbaCC5OjwxhmDG2IMv1SYp2VWDspLTZCaq1Wbe1crPTFePfw90jklwO+N/ELehC6XQu2bVLK2E= 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=Hs9pl3/Y; 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="Hs9pl3/Y" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-43635796b48so1442315e9.0; Tue, 17 Dec 2024 16:16:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734480994; x=1735085794; 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=pzo6pnZ8nQQ+9j1S4YV7Ap9BOpc4Nyt6rMblsqFBVt4=; b=Hs9pl3/YpwjCxw4omUZsrxEMU/1o8CgthbpTIrn5wgSbKfn8qhM77SgsgB9hX2WFLH bQutyfw02x9SwAXUN3tEzauvJlWSahgTSil++ZAyJ31x7K6B5jDnjwVLlpYCaMXnKHSm 3ovn7zxYUt9fqGW729gkkfNCyBU94qtar/2kq2W4zrmNf/fGx8y2dX9Y93Vk7E0NRUyj DsGkwtzeJBqomQ0g56JcJiuIyimGnzHevFobxzsc+aW+zOvyCW0K1/bkcjG8ah/KwNBP lnd2NtUVzfo13/kazQA+gXL3UrnLxN1m8VXRpfwURAhL0xSWAxRLbqlYyV3Vp2xlnFOr kklg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734480994; x=1735085794; 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=pzo6pnZ8nQQ+9j1S4YV7Ap9BOpc4Nyt6rMblsqFBVt4=; b=netPhzCe3Ggy2+AnvYtc+PRxz95/ZgvueCRXvYar39S0qSAs+KpqvQndFpUvFFKn9g 7e5IYogiNeK4aQpURA0HzKRno0AfPEnqBYtJ3ieUAdnjV4+VtuSapuyhwOjSY7py0gDz /sVqTICcu0PcqjPnqeULbEiCyNYS0lJvori7HVmNjbDAUo3PfM+Ckf53x8oYLiaVGou8 fbI3OInz8eWDJi4u/fQokHeuA8gpq9LzGpVoTbTe5LhPJkhSH5SRyY5h+Qz45k24/2Yv ZCH7756El1XcC9dAHP8Fxl5tIKfQV9AMbXDO9qp2SmWFGfCvKqK06a7QKv4jEAUV2PWI Gi7w== X-Forwarded-Encrypted: i=1; AJvYcCVLQ5+bwqckyI7ZtnC2WUvJCFAY4iaRV1TdoeZ4tDJmoemWk9MeF56yN+9Idtd9B0VDO4Rzzx6XzB4=@vger.kernel.org, AJvYcCVcrc54SaXi/WXovGJOgqqsv9iK42KEtVPz6izDeeAc9PMlHjIorC06q5tpfCTvtiQy/RA3pUh3rCdVoTTR@vger.kernel.org X-Gm-Message-State: AOJu0YzpqdYge5sVWDsaif/ibx15GI1NMEN5+dEosp5N6x2r+TOjBRIB Eq6oYrFm+z3gIKx/SkBvthbbcEcOkjN7+KQzPjAPr4mYHAD3VspM X-Gm-Gg: ASbGncvepsrthl4ihnalLEcU4RcEtuZFfcf5auiwXe5XAmTWkEOmbJUlcWfcNu0b3I3 IPVzCBDH4YaX8mhd0rLeHXBrXLhgcnJKLOfwaJlzxwWwhwrVsouUPKcG5ScQs3s7SBa6tyA3DAH iPBEjjOrzTu4HVYwmkft82geq39i+ppqbDlw6o83hOZ1JMONa0+RBKXX72d2tNubaMEYFCFmuN3 Nk+uL0BPh3F40a6zrLCohpE338m3JTzzro69xsfU+owoi6P82eljHygkJDyMBeHEqRKIszDOeAn xBgL15Yzzg== X-Google-Smtp-Source: AGHT+IFltRpUzSozDoA87m1TZYC7pxqBMTSIWpKZiQtJf4EL6iU4SamKsm8UvtQf1qY7MgprIN04/w== X-Received: by 2002:a05:600c:1808:b0:436:17a6:32ee with SMTP id 5b1f17b1804b1-436481b9110mr44086365e9.10.1734480994104; Tue, 17 Dec 2024 16:16:34 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:ca61:1d3a:8af0:1c5a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b1f638sm2135495e9.37.2024.12.17.16.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 16:16:33 -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 v2 4/9] i2c: riic: Use GENMASK() macro for bitmask definitions Date: Wed, 18 Dec 2024 00:16:13 +0000 Message-ID: <20241218001618.488946-5-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Wolfram Sang Reviewed-by: Wolfram Sang --- v1->v2 - Collected RB tag from Geert --- 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 954e066d61a8..ddae4b74a86b 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 Wed Dec 18 00:16:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13912745 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 1CA9B3597E; Wed, 18 Dec 2024 00:16:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734480999; cv=none; b=PAyczZxxj1Lm0IPhbZ+mhfnjrQnHN/WyaWq3morF8gkhXv1HOrSL08G9OS3Nv77UtfaaoRrpMcd1hTOctwaV5cY0DfM/jS8io7S/FbfBLN7v5ucPjWew5Uj0+XnsnMFyeHq2dEFODj0Zk/E8s0HjZGGuIQMe8PECEX5VPWbo52M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734480999; c=relaxed/simple; bh=I+lgjWblbzkc1ig97IwoLEh2egL2X+/F4HqtKjUg5bc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bXG6914Yv3umCdSo72DPmP2ORmSkbeMASUxI4MRH3DK7f4e+72GzjZ+FbLQ2gCKTKaj/LiFP7ww+0relDpcK5wtv1W7LPtp0bPnyH1LDpjQf1FxuyxfMeW52/X2zvWz1p5+/jxqbNN6RgM223n5UMhwYll1mBXva677wVYAZ2rE= 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=iT7aW0sJ; arc=none smtp.client-ip=209.85.128.53 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="iT7aW0sJ" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-43623f0c574so41536665e9.2; Tue, 17 Dec 2024 16:16:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734480996; x=1735085796; 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=WDPkBWjxoGBevYa/wanarFSpMlhYS8wLWm9t+ADkfqI=; b=iT7aW0sJMe046SiT83W2dZYgGGlmeWpKf5KclYDxI/XuS4Jz40p9OsQvuJLk/lFwDf iOsG/su7hz4k46jGUQXkLf87ujFnSIqgMJ/uAixhPvrnIQlWip8kpPdmREaG9TkctUE0 H7j+YBjflP5A0WIEFaN1OYZ2QCv3zVpdyMyF+bLxreWVvR5HEgj5TjAt9NdP7sxvK3S3 QDbQm5iHuh1/ablRJ7Q3mMmYuXIn3n1xib/Ip0qfoUR3MqF2BouZ3H0mloQ/l9uH3qq8 0BtDkrvAiO0BUm+P/xcLVDPnSId59UFqhjh+MjYVM+2R980nosmKwlXUL9b2IdmStyY5 7zFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734480996; x=1735085796; 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=WDPkBWjxoGBevYa/wanarFSpMlhYS8wLWm9t+ADkfqI=; b=Hbr6TBpcCfvmnzKTi+x4l1z69wITIaXlpvLdcsO5F0p5rNf1GGHLa6jyiLgM6AfDTp hQkwwbivubvpbt0oTneXFabKzHTDJA+TKz7j1MJLXdTGyQsSoyQxN5VDxKquJwGdacpQ UAUOZCb5n14HrnwoiwkzFdV2ofu2oVGP9zzYC/6QLTfUOUfdRaeA+qzIbSdd/grKwxAH dggSOD0nArg4OlkTu1tSmsbolwKbJpMwRAwLyv+XxzdbPQguveF0km9sanFvHMwvbJpM sqazxYxv3XjOV25a2XV/F7QrfJ5i2P6r/uHQAL/nheaHz9QbGZASY9IcPlWRz9Tpj2os KXnA== X-Forwarded-Encrypted: i=1; AJvYcCV3mBn/ctZDsG3TCozFGrJIvD81Hy3KKVxxUK7w62gpmumbUvxvnsJVUmm6BJGq4tXNcwr2Av45Iqg=@vger.kernel.org, AJvYcCVfTVml0BoCUIBG8lqPkG9BbvkkrOUPONF+7GI+WC2PRxp1WwgzPXsJ8HqzifxOT3at8Ks23oY5Y1ddw7t1@vger.kernel.org X-Gm-Message-State: AOJu0Yx+Mi5tyR1G3ITb6ADJeDX/fjVuTyhnvdywwAWNBWOEaIfrHvF2 JxA4kYvrEtW3yVy3HkdiWwfAqIDIY4pUaGvs8dzNQ7V8BoneYkVd X-Gm-Gg: ASbGnctTEClEJVKcGOpbxku5sB/An5seBPlRrvsCS3blEb1uuqR8p7x0Jbik6QB0lKh Albh+3SAwpTqodkpkIf6cmTMP0HJCzfQ5SyFIovI6inYEAugV0Etuw59qxKG5K7O7Xx12izuYC7 lJrVL6+5+XFftkqw6u/7rdIPhWZkrH3Ex/mr266emB7J551/n5AbASE3xN+ovTLZzdspYfDNABu BLkYKdK2mObBVyh3mnVzzT1/AD002KW1T2gLuOiY/JeW4GjWH5HOqYoJARE1aCExjjWqbSP/670 yr9Idqwbcw== X-Google-Smtp-Source: AGHT+IH6FM2SgII9gWPoT+4RHw2XMcC9XTb0s51E93sZoOCM9Rfjm2XRQlFECQCqt1kvmCkAOGmPjw== X-Received: by 2002:a05:6000:4711:b0:385:f821:e97e with SMTP id ffacd0b85a97d-388e4d6c078mr558608f8f.9.1734480996372; Tue, 17 Dec 2024 16:16:36 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:ca61:1d3a:8af0:1c5a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b1f638sm2135495e9.37.2024.12.17.16.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 16:16: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 v2 5/9] i2c: riic: Make use of devres helper to request deasserted reset line Date: Wed, 18 Dec 2024 00:16:14 +0000 Message-ID: <20241218001618.488946-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Geert Uytterhoeven --- v1->v2 - Updated error message --- 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 ddae4b74a86b..edf2212e96ea 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\n"); for (i = 0; i < ARRAY_SIZE(riic_irqs); i++) { ret = platform_get_irq(pdev, riic_irqs[i].res_num); From patchwork Wed Dec 18 00:16:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13912746 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 6B5AE481B6; Wed, 18 Dec 2024 00:16:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734481001; cv=none; b=UoZX3PDLucQIHGDwHJsKT1UsrzzPDW/jOp6SJsNMpKbIJwBLzLRZWPRec8QWeesxuSH7Adt0P4AI/FPagjTykfaCesCwtr+p04QtSaUxfWaztpC4TfdOA5RByT+zkFdy3OhYrl0IEfDdGoN4b0vRq6XVSh0dwUvMiQDA4wksvmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734481001; c=relaxed/simple; bh=d7ouRJRAsjh+0R/ZF/yPJvwkwIA1GnjZ6lxInDFwtbw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p559g/lfXGN50MuEBTGeLgcZ+6vV7oN1bDqunexPKVv87fL3zC7jk3kOhArNa5B1Z7hhgEkfwz2kqsonMxDCnMB98NoWYMCQrZIuzXesrlC4fnTp4YHZ6sU30BF7zWlXQxgI2uKjPUXYXeZ4aKS3cScrtzVYpqHVRyDkmP2LgU8= 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=RkQceh80; arc=none smtp.client-ip=209.85.221.48 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="RkQceh80" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3863494591bso3176030f8f.1; Tue, 17 Dec 2024 16:16:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734480998; x=1735085798; 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=BEkYgx5IsCjOyNY4uIDVU82NRqAGn8PJfip+/UWwLso=; b=RkQceh8058Xra3zBjqi7hA8wQWzI1WCDbowWOtWqHmN3zFP+4YPjWgm0Ti/qYT+Ulr LYWTmB4od1yynJm/kjJhrnKcr8aHSTgq84yXGQpmbYPgcowRf7LNc3iUCaZW0uP4Kglm oQYamYCHGRmhvS0rmoLqbzhzqvW1usI3fKcC1LEDeEPqKm499z5I9mmAR3jewN0fDeUC p+KWBGUOH5jRiOS//GeTLYroiLMBVn0zYHIEVfxw1y2uc1Iq1vpVCwdXIFa9/2McwwIo eD2czDywZHYxmOonw/SmlgoFVnL2qP72hFZDPtWYMuj4Tjzeh8BgSKCJqZSxjoUzYJ2G FDxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734480998; x=1735085798; 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=BEkYgx5IsCjOyNY4uIDVU82NRqAGn8PJfip+/UWwLso=; b=Oml5SarNgFudFRhtmD4vHgOpAq7G/Oxt0ALuqdLXUJKLtACZlOM9orOQxsMgqrDc4Z Ev9GPGSp1aurWfolN6Q0riuDS+F5JpUXSN6ogIZ2levU1oKdeB7wC2Q+j66CC7/zOGeW FJmjkWJ23G2aLBf9vA59Ey0Snbh7XaZaG2d2mGYZhYvXHkMd8S4jhsvrgu+QFJ/Ttw2j tCHxa7gwmlg6j1unlvY/Z9fSo2PTglth5yb06E0Mr21b2VVbUg/gQEGAzXhmIWPrWtH2 /pqbH+MZgc1OAyjJ21isaEFOausxUUkT+R+R9qbno4nyqt2mWcdqNQ3niL7lAvIPEv42 Q9tw== X-Forwarded-Encrypted: i=1; AJvYcCUO3pAQcSKAxj9BzduunwWc5OX1jZKYmgc2hRU6UKwrN4S7du3alU9O/+IRYhu9MpsdWTDcWr6f7AJGl1FX@vger.kernel.org, AJvYcCWMCNIF1WTb33dT65W5rBV8+7QnXa6zHqrIw2PlgC0US1A4pYksbfOLBFMWCQTslcLm/FypV2nJMHg=@vger.kernel.org X-Gm-Message-State: AOJu0YyIrMkb++tex6uS92Z8vRk/diSip32pK92q8eqwAO+9a2CkDytW s5UvpJiWdO+ujHTFZ6dvZNBX0HxDhWoN5El+GAInBYolmWadIDUK X-Gm-Gg: ASbGncuXv3tHMAuUdyVFXciZtXbQcQlznYPAoG2YoroLfVr2rl0/RtQ0HcObic96mD4 Glrpp7OuubcTlWikEZyN6nEHlgUHIyXXODgEvmHhBzoGqA4+8LgZ+bm1T6I0i5EniNApixkEcK4 ILO2sHwOIP5e2TdzqbtbPu9pQ4toYhuPxh4MDccuF7bByI2iGdRdTEBAaBIBK8PGaLzYDjfvop1 1PLSFJ6azaQ1biYOCMa7bPTlpOJbfYfs2T8QbPgWRHYRZSf1hDFpDmMRjYhij7q4sIognwXahp5 ANcS6Df4Lw== X-Google-Smtp-Source: AGHT+IGHydQizdElKOLw0A4g1vC+AWWjPsJ1YntcTknj3PedLHU259LKN2aDhuwoN1Gikw0z2a3iIQ== X-Received: by 2002:a05:6000:389:b0:386:391e:bc75 with SMTP id ffacd0b85a97d-388e4d83582mr673088f8f.16.1734480997455; Tue, 17 Dec 2024 16:16:37 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:ca61:1d3a:8af0:1c5a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b1f638sm2135495e9.37.2024.12.17.16.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 16:16:36 -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 v2 6/9] i2c: riic: Mark riic_irqs array as const Date: Wed, 18 Dec 2024 00:16:15 +0000 Message-ID: <20241218001618.488946-7-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@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 --- v1->v2 - Collected RB tag from Geert --- 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 edf2212e96ea..378887b133a5 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 Wed Dec 18 00:16:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13912747 X-Patchwork-Delegate: geert@linux-m68k.org 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 756117080D; Wed, 18 Dec 2024 00:16:40 +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=1734481002; cv=none; b=kAaAisQa3QZCqK4K6o6slUXTcnVMMu2WSaohzJVo4AWk/ASSxM9CMm6ubQZYjtLCKyeAbfWaVPneOesmSJO1zIHrYBJ/jQmdnZHWocJGxUMLegf02t1zWN/4a1SNkaBHH+rz1DL8A8IEv12GpIYdIEJS0LeoAQyDkna96kQaOoQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734481002; c=relaxed/simple; bh=O1c21zXPV98doPxaxobc5HUNIhBfX4wNZNSJ9kJ9gb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S0Bx8fHAxSnCh8phDTArysB6RDciQ/N2P1ACK7KynECb1VGuqXgU1j54njdn8oQf5Xt1ca9xHgsctKxj06xRyiBQbkpIzBwnnBI8IEksnHrsjFcJYrBgNnmeG4Z+lfFSmtk5Idq7MI/f3UHIgE679AgyYxBsLnt2tGn5KhlSfNQ= 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=cB7zsohF; 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="cB7zsohF" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-43635796b48so1442545e9.0; Tue, 17 Dec 2024 16:16:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734480999; x=1735085799; 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=o9oPfnkJc0KP7YSiaXz3SeZPwKzD4vqchRwAXJW+KQs=; b=cB7zsohFPubXgfhN6yCwpIlnFINQKv115RKXgxJYp9F2oLP7bz3f6Zf3Rihd+no1GW 5nopIfV1KsuebmTkx6Obru/qQJpwLP04ynWkH7Gg6R9uzcfn9spP20j6VcYqPoFin6QY 4Y7sPT7GlV1aTNcIIySsbw/p4ARJT55L0IST39F5z7CVq944ea3lZ7z8rnsk/B6w63C6 D7/YkQojLMGhYviwCw2fIVbUEyhxQwuvhPsZ45EIZMQhA4iI58GtY437ZnGKKlO3QVCU xGqdEbQV9mWXZBeCrN3BRseB/GXjJ+RCwO7cumGQX9DkpPgdWfb4qBsVs+ojWO8LRQqc dRXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734480999; x=1735085799; 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=o9oPfnkJc0KP7YSiaXz3SeZPwKzD4vqchRwAXJW+KQs=; b=aGJQfWm6CAwpRlie6rQjQpwbCbrM6cHPaqnhs8Iae+cofhjTWtoS5RiWazwAQhauwI HPmBIUPHcW7G9i+no59op3In94ffIOc3upORbLMGTQLxQeSs68Zs2pfdPHMJ3nNpQueV soRs2Rd4vBqEBoqZvlU7u/JSuHa3b3ZJXyxdLBdFcJjRW9kX+9ur2j9x7lBgFBCq2DC0 2ckdIKT46y58IWvRaF5odrGg730jAewqJE0+dPkVo9hxuFAQEZ+izE5v8Rk4X3nAqx5P cA2ReOV7z9DAOxZ88r3W/L/hyFnudZTP7qrUcZc9pBG1e0Yen7bk0oH4c2cB2O9CS/jm UrMg== X-Forwarded-Encrypted: i=1; AJvYcCVz9szO4c0z/xNRBICMApUxC/qbciI1wKs0+JQxJSx6ttOr18wzv31gNLYY9A8UFHjl1p6M1W/Y2sDnBinq@vger.kernel.org, AJvYcCWf+PYa5O6uL8O7rnh1CbfF1QrmYh9CHLc7/qQLQ2toR1RJNsbEhzwhiujJKvL2m2BX/2Fk6GHuVqA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxmnb0dbu+wkRfj+a1MDT0ZvQAIj/VpHpqSET5MEfrq2orIE5L+ HLwr4hVf+9W3t48AT4uGf6IThInyT4VgAp7JAsH+krDG2aePzoHc X-Gm-Gg: ASbGncuu4Arf8R0Or/FxOhnDRx1hQjvuuaJAGw0LNI2NRgdZ2vXpBNJcqkhxPijLaL6 2M7i3a/FBIu5ZiAOe2JMOdnWRa6kTN2R72ah8n2plryCBV70LRnw2GByum3VEqoHmttR7rCQMgD YVfHd/mWSuvhdrsjzwRExL0RDyE0lvo2LWRhb0X+psvSBUVQjsGjut1q0moZuSC9KeHUYeytj21 ocQK5IJZqVy1/wE+ETO3UsJfB0Ogqt0+8aAxMZJSzNbM39wfyyn1ymMvAeNcWfIcll0aR476j+u F3jB8VE6nQ== X-Google-Smtp-Source: AGHT+IFIYx+5/25sqC0jeqDKLPbTtPIxvBxy4/NlXn1kqsUfczYDgo8/6SaWBRL/g173S3p+9grp/w== X-Received: by 2002:a05:600c:1ca5:b0:436:1b0b:2633 with SMTP id 5b1f17b1804b1-4365532c98dmr4564775e9.9.1734480998688; Tue, 17 Dec 2024 16:16:38 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:ca61:1d3a:8af0:1c5a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b1f638sm2135495e9.37.2024.12.17.16.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 16:16: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 v2 7/9] i2c: riic: Use predefined macro and simplify clock tick calculation Date: Wed, 18 Dec 2024 00:16:16 +0000 Message-ID: <20241218001618.488946-8-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Wolfram Sang --- v1->v2 - Collected RB tag from Geert --- 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 378887b133a5..a2d0cde5ac54 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 Wed Dec 18 00:16:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13912748 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 6F6BA132105; Wed, 18 Dec 2024 00:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734481004; cv=none; b=KG14K72jqmH9ciZBoU0bzLSFVCwJ1g3ppuj2Uq7wYFWPGUym6sGpE9ZAF6oA5bqXi3wMiKmOwwXXbQI5QiHJnyK3MKx6MXbGKFRtB4W3WcyCBruQTTitTESYvqYKT/jRE/NPoq4jW6TvG/8DMoIWMrCXmsOt8yIPVagwdN8bSAY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734481004; c=relaxed/simple; bh=dEhhjSkwOsvO0yfTViPopf8lOjINrFffHGS1mQAkTNQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E16UAdslNF4x+I98ic36aVDnOqFknecnTP1DDbb/CDOVqFP0+8Vmr6JsQCbTQPy4WaGQ3hD589eCN6lKbOrKsF1XnrUsm7Gm+vRniCx83SwAeKTBzT2rO7dk1jZKunLaDfCwgMnfhAX75Ue2gbrsgTvI8M88UBDQDJDmo11xCec= 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=bbZgf6RB; arc=none smtp.client-ip=209.85.128.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="bbZgf6RB" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-434a766b475so61935085e9.1; Tue, 17 Dec 2024 16:16:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734481000; x=1735085800; 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=Yvkm4UBpAer1MShQHJyBEWf6t2rql/v0gNJBjW4RLVI=; b=bbZgf6RBxLWHrMUjCyh8TqVmBTShF4aQunrHphEA4Jm6JHeT5iEhlPi6kA+3LDy7bQ X4zzkYVX5/W2wUmD0EzaGyCtxXM8raVtQiIJEH26iesr8785MlZT5YYQ5HW08TOyjpok Lap18IXCnHqZzU8Te1hWc46KAES1Ms7AWvhhg1z7cZfG425+9+1KVG0qdR1GHl9TqLE6 2AcuZgHDCSXvIHHgfxrr2C9DLoqyX101TbrLeMEmqpKeFtLAASh7bG6cR2OusmmFBXCd fvCp0eRCU0jsldN9dyxfmgMzZcA2eMOVmbDUG9N94QC5DwQnBSz8w0Lc+dX2A/K4DNZk 4b1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734481000; x=1735085800; 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=Yvkm4UBpAer1MShQHJyBEWf6t2rql/v0gNJBjW4RLVI=; b=KYIaBigufeEMexad8lWmbArS+IEx0sY2hrhvf2WVPRQPifhm4ZMWhE2VUk3xGyKLnw tvLZWIU5yon9EZsIytjzVfGLPjGyQK+zdcQ471xaCxkXnKes0qFgzJ4+ctaVwdzaRDdY uHAqUyn0TeteAOlpP7gRIlG9bo1fv6XQzn/7JQ55p+cVU7gpAI9zeouClBUz1K4DOcEp +yHXMREfhvFtKCZ3Sx04uG6KuB/oPnL6DEumnJgswgs9jdo+5IuNoOCaukiQL3WwCnWw 5RqWo3HRwp29eb02rPmGLqIkerxwFCA+6Gffw+z9NMpAh5JleTyJOFwpx/JotAyCDn/e YDrQ== X-Forwarded-Encrypted: i=1; AJvYcCUvw1UiOIIyULdoAdxKE6IWZBdR3UhmRtnVDOl6A0cqCQBAZpmpz+/ZM391SYGt1Xu8v9lbQvhtRZGuFFGi@vger.kernel.org, AJvYcCXU31ZCk9Ksa9bbtjoLxzGWORuCqY9wAX4/UIcnKQck2Bw6ODHvU1rKly4AATSBxjVLXiNKp4RT3oo=@vger.kernel.org X-Gm-Message-State: AOJu0YzbPwtd5QXHnTyj8ioN6DTpFyZNF+dieiXBIT/BrTntqopoPPjE hrKT+tlJmsdJPyTwzddc+n/P2QRGP7xw//4MNCdua2zpLUS5GDl/ X-Gm-Gg: ASbGncuL2UgSNtHeUrgnmgQT0XitiL7HFKws92akJEsUswK6QgGkoAG27k85KmiHfGB Ea/6YQOuIeJsbkjuUiEDa2Ll946wd5sbm/SRq+dvKAVdCsuVA/w5pAyyyxdLYLn33b/26hWfeul S8Rosunpq3SN+VKpzq1lcARXKQPg6N+im+QtHDDdFZT0uRoK6EwSmqdCX4ZnsaHF4ksTlYCjQpl e9nTeZKX35pFd2Z798Zd0vuVkLwzW/sNkM19/u8uFfcsu+W5JsWDFzYWyIQUW45JDyLMtk3pTC5 spU0I55cag== X-Google-Smtp-Source: AGHT+IHbChzHzVEJjYkpceGOI4V0se0kepaUxaf5o3D/fAdXBr90ot/F9Sx15BvHAQRJl9H+MThydw== X-Received: by 2002:a05:6000:178b:b0:386:3835:9fec with SMTP id ffacd0b85a97d-388e4d8fbc0mr592302f8f.44.1734480999844; Tue, 17 Dec 2024 16:16:39 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:ca61:1d3a:8af0:1c5a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b1f638sm2135495e9.37.2024.12.17.16.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 16:16: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 v2 8/9] i2c: riic: Add `riic_bus_barrier()` to check bus availability Date: Wed, 18 Dec 2024 00:16:17 +0000 Message-ID: <20241218001618.488946-9-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@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 Reviewed-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang --- v1->v2 - Used single register read to check SDA/SCL lines --- 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 a2d0cde5ac54..586092454bb2 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 | ICCR1_SCLI)) != + (ICCR1_SDAI | 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 Wed Dec 18 00:16:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 13912749 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.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 C8AD81BDC3; Wed, 18 Dec 2024 00:16:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734481004; cv=none; b=ZCWFM2aQFR5Yxu6aFE/9Vyj/mbeuIjrNRRRl3S8ANbLzYQw3U+q4APG5jkeR1FTVoFffbQlgUjV3Khl9dWhoEqN/o8m8aATbvAjC70glp9XA4K9PxWiE/q1D41mqvXicip9McZ+9uHmPzZFib1lC0jXCl57XpOmQyRl6hbE6cso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734481004; c=relaxed/simple; bh=DgiiOozTR2Ns2as9XxnYghQ5OWP1bjSFARR0iQ4+cOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lJJCrcwG342Ln+rjvlPKvtg4DE181zvfaoG9ppfwMDYSlmT+iRFK3D0gbsLqSRoiHUK1xAmV+ZQDJikxBun3R+PrvDys4lwhyu6bxxG/EkL0fm+cyoxh54HEaOl3RNRKxFx/f7sECogOzdIuTRFkYQCt1Zc/KFfv5hoErees0Qs= 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=Rnlayz0T; arc=none smtp.client-ip=209.85.221.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="Rnlayz0T" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-382610c7116so3041419f8f.0; Tue, 17 Dec 2024 16:16:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734481001; x=1735085801; 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=q5HWS+/1/yNx246kpN3OwCxUSSCvlzQsqFE+TbYgREo=; b=Rnlayz0T7JFnrQ2/lvw/uq4eR+Bn7FwqVn0/cp157Qj+cEwxi0T6GgaXQiTDOkGguK hVvsAZlXZGS2mMp0Y4j6GHf+JlJpnWqy4A5JD9lHV56tTmVMhhmwS3q39FtRWbayV+h9 UF+sxhPy/m+UQdcBehXcetYIowRNLyXGPxZE63TP0l86rMpamWDKpGAjY+5paAWRCH5C wT2dqBUo/OkAiVqoWcQe5o5Ih+iMEhga4TQsTvbUljAG71mrrWb+8CgE0ARC9DMRj3ci 4lKl03IjpdGaYTO+mLRj7HGEqeOc5+vW4JXiDO8Vzyi3xSkUQ46YsDl46Lqfg3OCyXvj E1Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734481001; x=1735085801; 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=q5HWS+/1/yNx246kpN3OwCxUSSCvlzQsqFE+TbYgREo=; b=NucE3kpGAFYovEc6dr09IapxHTv+VCpyRgvrbzTBPl9dzGvTUAIJaNzLp/8rjk3C4N /kN3h3gWgSRH8GvypfHnakiUjt/v7pFUOQXGyZTlbcMPAmzgUflXifbTGxeGQytgC0WN COYK1SqRGsuZ6CorsxQI67zA4IoN5CP6NeXDpP1MT2BjKLUdR3XZe6n+ZILYTHGbHiAz ogo93YA0goI+xMyBrwrWSj+PwZbv6l+NSQOMNr9D6AWeajzq5T9DzLo684c1fGkAO/up WHLYpZMNJ0Ttwo3OmhdT4IdscKIyGhQcHdejDoIimat87oWHCXNhF25zdT9ROsyFgw6V PWkw== X-Forwarded-Encrypted: i=1; AJvYcCU/rOmEPpvHurJzUkrrNo/5CNffFqs1naGwMHmeJaNRFV1fIlDqMrX+qVhzkB55q2FgPkmHxkaonS0=@vger.kernel.org, AJvYcCUoSqMf0INei+Arp7e2tGeZVp2+jwhEw+YkkwJrOEsgtc8UzP2xfaltayHT+ZvznDidNY36P9f93MPJR5E0@vger.kernel.org X-Gm-Message-State: AOJu0Yw0OEJ8H1i0l/w4fmpGFDasHsejzB+FD2lGYxNsZDcdLWZT0gCY IIfd5/zU9fnA6mJ+fj6TTiGtEGS33oFeDDcqNb3XcwNc1pwjYh+w4jlCGQ== X-Gm-Gg: ASbGncueo4ZwPSn81O0IOJ9UBKKo0GND4qedTEskuHl9FIbAQS1QjpYsMVgeAvTe4ua 16XXO20SQVO3DVU1Q8UNBlaccPR7OiwbczbqNWlZmFwk1dUiiFlez+jUkkX0W4WS9/mmUzFcs4g TStBF+TmPXTfBPTz+hTV5oQGK4Z+deqBJueRJOwkaPqTXq4GjqLJTe+jd80ZrN1hywwm0x6tsxG RNlDAnBFh9ODrelDPrsPNq6rBY/AxsaS6BVaOAxfjtdKAZj6HtfKq4PGHLkhxEMhv6YKS/g71o+ RvXXFsjBdA== X-Google-Smtp-Source: AGHT+IFXdoejpCqwZZa6wAHPN1wrhEv9r8FHGpbElFBnqM3y+UrdqwfDDeh57fW2hHAT+zLbFnnsUg== X-Received: by 2002:a05:6000:4a1a:b0:385:df2c:91aa with SMTP id ffacd0b85a97d-388e4d2dd31mr694592f8f.7.1734481000860; Tue, 17 Dec 2024 16:16:40 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:ca61:1d3a:8af0:1c5a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b1f638sm2135495e9.37.2024.12.17.16.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 16:16:40 -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 v2 9/9] i2c: riic: Implement bus recovery Date: Wed, 18 Dec 2024 00:16:18 +0000 Message-ID: <20241218001618.488946-10-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20241218001618.488946-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@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 --- v1->v2 - Used single register read to check SDA/SCL lines --- 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 586092454bb2..d93c371a22de 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 | ICCR1_SCLI)) != (ICCR1_SDAI | 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 | ICCR1_SCLI)) != + (ICCR1_SDAI | 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 | ICCR1_SCLI)) != + (ICCR1_SDAI | 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