From patchwork Mon Jan 13 12:26:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 857336 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 6719122AE49; Mon, 13 Jan 2025 12:26:59 +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=1736771221; cv=none; b=Z50e7DJWwIP9BfRIjBnRO+4dXYfH1E+bmWhYf7FfgGFrGgoKtdwhzaoX9Hc7taMqujAjxvVWoZ26Q5kI/a4i8T5fRd7ipXiGReS8ins+/E+br4stFROUiC3OQ3yDSRzZnuuxagIG7EO1Ke+oFtYa7zcCMMmvJ0zO9zM35P53T+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771221; c=relaxed/simple; bh=4pAohm9PgiohpzQ+nzLusuwNomgnJTKczSn8upU0tFw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ROEhhiQNfrIDTT2bsb/5YR4GMjh0oj9OdyZa9uZWMjpaQtcKJKcVBMp5eDtgJqnVo/2vIjoBW0VFBXA6/JVtDXOFHy1YDmSf5s/rxd9GBX4vFdi7UNpQ/ZL9s/zQXnSSBY6AsI0qFvjTRIvNWzdy6CgV/NIwlkqT51bpaOznwFs= 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=FBI9DACe; 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="FBI9DACe" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-385de59c1a0so2015103f8f.2; Mon, 13 Jan 2025 04:26:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771218; x=1737376018; 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=6CQU+DVYlAO+oIq3UJzRqfbMr0HitdK160Letc85i8Q=; b=FBI9DACejVceFcC0ClTTVHujkvx+3bYJJzeDXW3KIKpiNYES4mwCbUlmL9GvcXIRsz 8mp4OQvDgtH3D1KsN4M47BxJijNAVUciCmlGHXLJ4ikl3GNqKwIc+J56D+in1K8yKDTa fLXfUzMu7iWal+NcQAs5gLrrT8+o5exaGEa2/UaGbQFTwhGAwWocWR8rsJ7bnXQuV/FY wf5U3EOUI8vajQrC5j3or1IftP989uRlg+CmyyTrlG1LThAG3g27AmwMmPKxAQG02Hh/ +ivrLg8O4BG0mfYdeX2AGkaPl1ukVa+mLb79voac3Y8Tk00SCZ7w+uzioE04BRTWvRjb 1fZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771218; x=1737376018; 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=6CQU+DVYlAO+oIq3UJzRqfbMr0HitdK160Letc85i8Q=; b=GNejgqWwnGPe0MncDuqpLX2XPqpAxEXoN2kX40No0HHKjttv0YJyov/VY8WoxYDUEV vQj4TUwEq+09WMVLqYilFiHxjgwfIKIngY1lP49h6uI/YALjOr3bnmaeRJZXwwcv+YJE JmL6aCSenX6qfrVQROhNwgXuIxlUX4cP/jEXh9zUemXQIfIQeSd1VPO0ZYnitSwDw6L7 gJZJCSzHjyx/5bINfllj93hVu2LN82gNUiBbV+ZPEkAWwHDRYlscJ1T7KK0b6DoYcUyg 9wmtH7ULBDJ1nEtuPjTzYuoBCzO8fPaz3q8cFHqeHAu/S98cyymh221wTIGafE5z8Whl ISwg== X-Forwarded-Encrypted: i=1; AJvYcCU2+z+89Y0yzvHIKnWxGyRPgZ8WwVQnO6IHJZh2lN+VsEV7LS42yLvvT0hpXYnEbAbBuQ0DeCFMITM=@vger.kernel.org, AJvYcCWL5XgkdAaSQlfgssZTaDACqHIpKYAT1BMedgvwP2R6Fz0DsJ5B7+rGuSAIjW5XN3UQF6dDyMoFZfzEJh5i@vger.kernel.org X-Gm-Message-State: AOJu0Yz7U3Y2nKddsXtP2bNfNlL//wPSeNsRpQTMuloQzJy8a0bNJY7d 3+ceRxg/ajnZEmTmBnFgWFG+juRl0Wio01kP5tPAH3uUDsqMfvP0 X-Gm-Gg: ASbGncsIPigo8DuO4BMXIyIh9kHHGtBMCUGcADbGyCgQqUyaxKjuUH2YAVHueuy4iTW qU3WzGDOKyxgj3u1rMT5QW12PMp3A9QlWqQr2KnjSR8F4t6kM7h5n+1NzYijKPrzNPblyWmGzXM nyqBWvCG/HDvQo++tjQYFwndouWDMitDaJzQ1BkVhlghe/tk+EXnAWAr4WPRL9k7odhphcSLsaP xEZQQmOCUe2kZyL/i+zaURUq12AgBybQLFxkFpH+5b35Fl3aKsL1iCAcHdoK2/qBpWEyMzTVcJB k5DbogFdHQ== X-Google-Smtp-Source: AGHT+IGC9DFGOG62gGkAFLoAPAC0GixW8o1Xy5xI6YUgpzDHJiXwzZYTQrub0EvnDhbOYWrR9yNROQ== X-Received: by 2002:a05:6000:470d:b0:385:df2c:91b5 with SMTP id ffacd0b85a97d-38a87085becmr18908243f8f.0.1736771217635; Mon, 13 Jan 2025 04:26:57 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:26:57 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , Andy Shevchenko , Philipp Zabel Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar , Claudiu Beznea Subject: [PATCH v6 03/10] i2c: riic: Use local `dev` pointer in `dev_err_probe()` Date: Mon, 13 Jan 2025 12:26:36 +0000 Message-ID: <20250113122643.819379-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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`. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea --- v4->v6 - No change v3->v4 - No change v2->v3 - Moved replacing dev_err -> dev_err_probe into patch#1 - Dropped fixes tags - Updated commit message - Collected RB and tested tags 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 4e2add343c9e..c555b6220e66 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); From patchwork Mon Jan 13 12:26:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 857335 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 C740E22F16E; Mon, 13 Jan 2025 12:27:00 +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=1736771222; cv=none; b=C56aVv6JrRK0vog7dDc4kaUbPBdyzCfgt3GZP1ThC6IQ674T6jkzA86ISASN/iwFMFCVNbwsSgkz7gBqXpKVHC0mXxq1scXAZKIaLp5rSXiTBDBAJ9No7ftiNg2eN1cZTGViEqQs6hYIpUCxlQe1D6CT2AwH5bVIJNyKy5umlj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771222; c=relaxed/simple; bh=kD/BB26IlDjp+BdXvMhyWMQzfTjuj11XTsCTUTRtnqU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CxoNAqfohZkkLt5VO+1/CbIwMt3v4IP3oJMolroR6QozaFpnZFYlJEtS3DIJ07Jmt25zTZWtQCDKzKtxFAqOfU3/LBkOTE0SEdwvjPv6nj//zYBCJBJNGd+CptN/x4Vp1j0cqOcWAL8r4+qDO98geZSM9rsxrt+Zw4OfbDVm45Y= 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=E8uFQGiR; 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="E8uFQGiR" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-436202dd7f6so48634405e9.0; Mon, 13 Jan 2025 04:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771219; x=1737376019; 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=oLFxeHsbZaMLi7y4U70NTqyWNjRRV0RJYoNkPRe1z3c=; b=E8uFQGiR23PjDvOc7p9ji3lzxHocelzezvga91HUT5eVlHDbCSyeXjOZwCoT8U70dA fC/fClvhlEiferVWWJUvqNCmjBMeGCJmyUmEDtHLdCvsMmfOMD4RCuGtIEpV3VlfYGPD qFksiTYg2GRAKmJuWlc00XY/nkOZV6TeAkPFJeUkYY/U56iHq+UDD0mdJrgIcmWAiAlx jGQkuVPOq8mCmqv7fEqHtrLDj7pkblavGdcZWF+eaF0JZ047YtIsq2VNigRiwZ/x/YLa 3ql42rQTiCRX3HEGTQV3Qa/wGRoclcKidNNs6Lj/ypur3RJbbrab8RIooRW3gCN+/TEj bhFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771219; x=1737376019; 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=oLFxeHsbZaMLi7y4U70NTqyWNjRRV0RJYoNkPRe1z3c=; b=QbjTq5JAcEFC05SCs02i8J+KXIJ5nfaIM9BFFV6XUwuPNcC3gorXEbVxe6d9jxxXAf 1aoWK1Ttoxx4gTTrYhvhTSWBWt6PWbGuVMqX4CcsjDYy59o1Rsx9mMaT/3S+TM32CPgS sl8X1wofU5UNktvTbZ3Y3aqhHxkUpGV7pRcy3lnR3xioCgHiAbs+d+HAhwYDsaMK8Hpj wSKL+bbvmKf53+LkbqPA3R0R4PHKYTnDaXtt9pHr8PEnP5lk+VjavI/HfpzCnIPPaUJQ PJD2SOuvYUeBDTv9eDQQpLZO3vyjIx6eGHr9tLaNTwtSNEU7GNDi8/2q43CQeUFor5Q/ IkTg== X-Forwarded-Encrypted: i=1; AJvYcCVSw/StTvBhCX+6joKzQxg3p+XR/tBwQ3eoS9SMm/piNkfLhJZk671E/7DDDO+OVFU/k0fQZ778M/A=@vger.kernel.org, AJvYcCXVk9Vn6NxZ11nv9P+Qd4I9lZcEWLjgdrB9zna1Gzrv/Gn/14/GtV56Vv4iL2oOhGccezRVN+iAhwkc0Kal@vger.kernel.org X-Gm-Message-State: AOJu0YzMSPtJKXhqDenBxkZ5cBrvtNOTkRZwsZf9KfWTjNl7bRtcp1IA kZGYpWrRjEcwjpBx+7ks439FcGJG2yv1WMxazjz6kUxY9YATIOXa X-Gm-Gg: ASbGncuXmKLGp65VMG3PsZeJ3aJjRK0pk4uvLRo4ynwRE4aDMdgyZTnc7/Bmi1Wxzgi T98NHklUWmxeB9fQNbuF1W+I9xH6TAijplBVh+bBkLVSFEDHuRBlzTeOuGy/jlpxKi44luOm7vG 4r0GDp0G4h0Y+RLa2EphcWf7UfglbPctBHsKk8wO9km6nMCxSFJ56IydsjBAgO5Ctn+GFgN21WZ 2Kg32DQ4M5NgfYh2OhBGtG53tPyX42n4BcIYqiyE4blK2gJX3JKHB4f2FYhWLWHRXtCunfcclyP n8tNyikOWw== X-Google-Smtp-Source: AGHT+IEJdT1V5ztbSQit1l4JUUiyXQNX5YIla9xZdjNckE55C9SpnMwefkT1tGr3ozOfyOqyW8KNCQ== X-Received: by 2002:a05:600c:4f03:b0:434:f396:525e with SMTP id 5b1f17b1804b1-436e269c2e6mr184653945e9.9.1736771218578; Mon, 13 Jan 2025 04:26:58 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.26.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:26:58 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , Andy Shevchenko , Philipp Zabel Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar , Claudiu Beznea Subject: [PATCH v6 04/10] i2c: riic: Use BIT macro consistently Date: Mon, 13 Jan 2025 12:26:37 +0000 Message-ID: <20250113122643.819379-5-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea --- v4->v6 - Used linux/bits.h - Since the changes were small, I've kept the RB/TB tags. v3->v4 - Included bits.h - Since the changes were small, I've kept the RB/TB tags. v2->v3 - Collected RB and tested tags v1->v2 - Collected RB tag from Geert --- drivers/i2c/busses/i2c-riic.c | 37 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index c555b6220e66..370cb83bf5ac 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -34,6 +34,7 @@ * Also check the comments in the interrupt routines for some gory details. */ +#include #include #include #include @@ -46,32 +47,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 Mon Jan 13 12:26:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 857334 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 8A4D2235BED; Mon, 13 Jan 2025 12:27:03 +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=1736771225; cv=none; b=q3EPWn673Qho7J3R7hazd3H3JTszjjnAnUBGvOz0Lk5GG77dQpeFRQ6PBgnqpoUw50gohA3tJKEB9I7Rifs0k4Rh0oPsq0ENgaeMYqWMOEquQmwcIQmEET/C5wDFw+Mdcs2eMT5Nji8P/OotBdPdRfbSCNPk3hQ6cMRWXBp69yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771225; c=relaxed/simple; bh=J9hyRBKSuXe8hqhiAoUA3WRKFV5ZyRq8cJJ8EI+szls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QfYjUIbmmuQhfV1irrk1v0Eb/5tVqR0hnMi4bMxlYAR08cmiPZxtZwiD6EywPfevTucT+lhX8zyZ9KWds0FsyskfClHieLJOUDZbznfMMgoGg+nUwdGo5//rXRXsm8jFHvu/UJMXiP74THOzRUTmckVDrkjmQ57s9W1z2pEMGDc= 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=k7156tSE; 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="k7156tSE" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-385ef8b64b3so3656713f8f.0; Mon, 13 Jan 2025 04:27:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771222; x=1737376022; 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=JwlrU1/L4OoVV250darEN+AvnT2p06BYtepXz4Se2OE=; b=k7156tSEtY8eE1t/IVqJltlcubA8LnyEp/DGob24HZgZM0qrbmRBHSkvyoIAE5/HYy rDm3XsuW0UQBnmp2LaIWzvj+wplCFXlyHwHHnpIit5Q5mg6zZFBTX8I5lK496JNPSyJG wtNLyTn4x26haQjBeWUtD2TZkwT+E+ahyr2ql8UX/YJoneNiMGJs/y3FkxrnnBHSvovD y3l6Cx2tXhDZSNt6TrpaeEXB4kcJapIbs5yMLP5xcuQGnqzJUSJgdDXdNBeCnqRniov/ c1JvAl/8POsiq5RrKmOfB/pnh0CReAF0ktPLNq3xv6P+ig8uAteHNg0uhsBTf26KaFZ5 ikpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771222; x=1737376022; 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=JwlrU1/L4OoVV250darEN+AvnT2p06BYtepXz4Se2OE=; b=fAv7uvhteunOX2F6E9k6pjApIgTYAzsBsuHWblO5py+K6ubQ5CyIbU7KXFlseLOTtj 0M412Pol3x3EFMz8JpKFniNJApdxNse5A26bg0/WlTUM9ZE8f6og6IhtGEMWcFsohDWU TcM1FB6LpUXG/CXafvh5/VM4DtJ5vtDVXkeFGPW6B7q5MScRqBKcRlNkuW0RWViAJspC yO+g09kTaPYeKnvRQPX/sjOQLvTnPpndT/lPXRvC660mM7XQdlM3P3BChGWwNjRKfZYT JPrn4By2FNV1/nsOt/c2YCoI3wBza+9WANLDAyPsrcthfObtdOE4dG6MD0rDyZ6s8pDM J9rw== X-Forwarded-Encrypted: i=1; AJvYcCWXLt2PtiDhXfz4uSWMjyf/f3eiXLML4E4yPxhgadMSeUfVYAggKriAu3cprjlgb8KuHPomDNWGi4w=@vger.kernel.org, AJvYcCWl9wnPu+xdj4Vi2LekXhlHknSc+qk8ci+hAM5Qg8SOqVAyKhvTfgIp05YkGKOqjBV+eeJ51eSA6lmRBJcN@vger.kernel.org X-Gm-Message-State: AOJu0YwojPtCGdg41Jtz585AOA7MMJLDkd21DKbtbHtNAxO8nVzQvff/ arN61y/KZBG3IIiVC2fw1ml1zw7vSsw8E6w1ASeAzjoGySvrcgdxz6uXCc4HwiA= X-Gm-Gg: ASbGncvau0QO+esxn2HU52McaJ/6WpMYbGdH/0U7bvtKNORmmh83i4M90KJbpSGfQjH T9weJx1SKcU7cLsYYG88y1LRXG0jXI+Am7398IJx20U+8RQGPHeETyDIAaqhatwKdQHqhs+YAap 72YJEGAFd1grCuiW3XWpqArGo8seKiw5jTG/Y1D2UNDptYT7Tml01H49D12j0s7gLs2M9VpTK9e sPrXYBRl2Xf/ehECLxESJ6WN2Im2+F67yR6M0lDuqjcNbHnhfMyZZ/eimasBFoj/0UPkwC14Izs tLhWM33RmA== X-Google-Smtp-Source: AGHT+IFFobk5AQ2m4K7uPD7TeaYAsYgBxs8uq8w+kSbuaKt94jIejAPw3myughySRCs1PqIrI6LI7Q== X-Received: by 2002:a05:6000:4711:b0:386:2d40:a192 with SMTP id ffacd0b85a97d-38a872f51ffmr18082388f8f.34.1736771221625; Mon, 13 Jan 2025 04:27:01 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:27:01 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , Andy Shevchenko , Philipp Zabel Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar , Claudiu Beznea Subject: [PATCH v6 07/10] i2c: riic: Mark riic_irqs array as const Date: Mon, 13 Jan 2025 12:26:40 +0000 Message-ID: <20250113122643.819379-8-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 Tested-by: Wolfram Sang Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea Reviewed-by: Wolfram Sang --- v4->v6 - Included RB tag from Wolfram v3->v4 - No change v2->v3 - Collected RB and tested tags 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 577be1fb941e..d1768b38b12d 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -415,7 +415,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 Mon Jan 13 12:26:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 857333 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 98A26239799; Mon, 13 Jan 2025 12:27:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771226; cv=none; b=gOq+XZ1aBcCpCBBhNAVbRKbAFSezO+ejFVMdWzoYDSvRK59qfFysPPrEyq8Wfrq6+MJEawXjiyLdQ5KpqMiGvrtdu1YvMybYEbevicFF4lB3jKlTzTTzV1yHdLlkRR77WfBL9drPxRISO2DEZnQjlcAEQG0oXTfim+cBhmhMa94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771226; c=relaxed/simple; bh=kxkVdWLNWABkMrhQXDHs8153xINcmHXb/kPLxxUgWhc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QOsTAyQP7OIZ5wk/pPzi1dEdM8VvR4iM9ymSMFrj+oEy2g9H9zO/jrr7+y9vI9N1NVxlixdA9JZvtcokxOnPNFpusIlzYj4L9z2fS3xsdUuV8u1ZQ2fk10vRh3/Bm7AwBXjgERrjQc2Pqme5I2eN8Ll0LsA2+PVoc1glDtQmX5g= 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=diG434a+; arc=none smtp.client-ip=209.85.128.46 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="diG434a+" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-436202dd730so29766455e9.2; Mon, 13 Jan 2025 04:27:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771223; x=1737376023; 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=Ep0KfFAO2kailNpwGXc9iLyPxYa9AKLwF9zXOgKPL94=; b=diG434a+9zVeYf4ZIwXWFqBIi2NptFA8Tnoa/zHPqVmmX51rTqFXGcQ+OOmnKWr7/N bcBT8Oopj7abQ+vkoEYQ2g2IR8KLCDjbdf6fBvCvx+szTZs1Oz8QylbWuaGUwCtGQJ6f YL8xur3QSTkCXK0dxqyJLwN1lH0eiWIYsv1NNe7V+yI9meP8WeTqTQflNRcDEl1810dA aMhVlDOyciMHFnR2tbilw8R7/yOVo5SXQRgJcuDC5PFQeVEpBw0f2/1fY5ZYoTKQKheb zHgbw31fUA05ioPScrWWHxB5GvCQSgbyx6KNdBgfLfx33w0lKe8yFZmVBQ+0zMvg8lNL zcZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771223; x=1737376023; 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=Ep0KfFAO2kailNpwGXc9iLyPxYa9AKLwF9zXOgKPL94=; b=MnlEBc+GUdBP4F+pL0l9I3GONyM8v2RthqMwuvdSpFltToPH99rEnNqW2pjNilcrIh 6dniBGAIcTTJsAg+Ia44DqMuw7nwsdMRO5RukM1jd657JrcUUhrVGHxp03SoyhKAZdgh Fjy4DU8phz7udyJrohKsQOLiccU53gyE0618zG4s9WWrqeDseBrUCFZ/58PQg2X61jEf XxbRxuYBC/ahECPvvm9R81eYgiGoi8zfO1i/EoYMkra2AQ4+Nb+MKMYkFT42ZyzhqU9g 4i9nDL/H2hQ12I48OyPAceksGScrywaEpXbnfzmzcogDSYmBEgkL4NGfVRCl7wcRgoSY lJJA== X-Forwarded-Encrypted: i=1; AJvYcCURzyYlztPZ83OdkYW9kdr7lnRFozKQmRJ2MUpSJ7p+Z9X6FCzUAqaFEKfTmNi4e2IluJIEvxQEKOeIDO3+@vger.kernel.org, AJvYcCUxGZ7TZtinU4RdZwPY9yaGPR+TtW8YzU/y+WqGirfyKC+aTtrx7X2r3aRVuh+8lqdND+q457ny+9c=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/IDtG7O6iQrkfjLRI7kYVAVnPgjuzTepfHt+RXCw5ksQk8utO orJXetdAhptJl5Cc0JMq9+x6+faQeQAzHbs8rMHCSRpS3ENhlnlLxc1ece3lDrM= X-Gm-Gg: ASbGncvETNYpeJpeB+cmrzzUR+no4qfrCAX9Y1z8+W2ecwbypJSoDpUHkDkCv8xS1sE x/eQil4LvYvoSpQsNL/fursOVb/7XcUQx4TfP04SWzfg7WwvK6uqWKYeG60KcqvNyLugPsTbt1/ mMcsjaIxOdH+rIqoqbp7ufez74mPKj0Z8SfD/gn/UyAqZBg9+gy3cr2EeUumDOtDIX0npxbLZXU XdYcALZSqUdSnnp1GTk0FUeyST72H+ZGR5vTqPVw5zSblMV4Z8+WjNEn/k4kvTagkvzoI61Ef7X BGMGqF2jRQ== X-Google-Smtp-Source: AGHT+IFsgLgEBrMB7TTIJ/qjyTgtk19I+bBa9GftLkpjygWN6k7hLa5OVQFYWM3xH/JzRmnhoP+0xA== X-Received: by 2002:adf:9787:0:b0:386:3e48:f732 with SMTP id ffacd0b85a97d-38a87303f5dmr15132911f8f.16.1736771222734; Mon, 13 Jan 2025 04:27:02 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:27:02 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , Andy Shevchenko , Philipp Zabel 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 v6 08/10] i2c: riic: Use predefined macro and simplify clock tick calculation Date: Mon, 13 Jan 2025 12:26:41 +0000 Message-ID: <20250113122643.819379-9-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 `NSEC_PER_SEC` macro for clarity. Simplify the code by introducing a `ns_per_tick` variable to store `NSEC_PER_SEC / rate`, reducing redundancy and improving readability. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven Tested-by: Wolfram Sang --- v4->v6 - Included `linux/time.h` - Included RB/TB tested from Geert and Wolfram v3->v4 - Switched to use NSEC_PER_SEC instead of NANO - Updated the commit message - Dropped the RB/TB tags v2->v3 - Collected RB and tested tags 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 d1768b38b12d..aa3e4f430b11 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -46,6 +46,7 @@ #include #include #include +#include #define ICCR1_ICE BIT(7) #define ICCR1_IICRST BIT(6) @@ -313,6 +314,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; @@ -376,8 +378,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 = NSEC_PER_SEC / 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) @@ -387,8 +390,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 Mon Jan 13 12:26:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 857332 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 C972222F16E; Mon, 13 Jan 2025 12:27:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771228; cv=none; b=M12au43CXtYqUfLv3wTAlRnItfnYwvaGjckuf22y88HdXwt4lxFKuY0DvTsxPdnk8mTMO9McW/ZOXNHYN+Bf5y/R6te195mQYlSR0PL/JzHupgHpSRXEjfnwMYcykHCzP16cT478BuvL9JwiWvkrnkX/YowqyrYbbriroN//zm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736771228; c=relaxed/simple; bh=/Lyj8zeajSffVRPgPE60R+/Zg9mopkTcD9qHBwfxMGM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gp7BesPHSLJbVzSj+U+a2cXE5H7rTarkdnMYzm44s5J+2NBPUarmzm+WvD49yQq6S0LnJXobC3zcn7KuzhArFV6GryROVEMX46cEytMeHGODMD1EIFuFO3NgFFFUVCA6rtI9reFEFQIMu+olMi++FK8R2RPcqeEyAZc9JA7Qm4w= 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=W4eUjoPV; arc=none smtp.client-ip=209.85.221.49 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="W4eUjoPV" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-38a88ba968aso3513668f8f.3; Mon, 13 Jan 2025 04:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736771225; x=1737376025; 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=Eu4ESOBvVBzaEzRYnyWj2Jpuu4zqLWmBIIf9AvIQNX0=; b=W4eUjoPVVW/ht/uvZr1oIoqrQa3WioYv4+lpXQSId448/WwtAphAjGEOo6k3z8DkjX DkaoHdWlIIOIJ2GNK8WWeO+6sJrLeWzZ6nQZTFEnebCDYPy8BsLy2Ixrs1x4SaaXx+l6 krRn7htY4t/i7QDckLEUW4/nfg9PiQl03X69Ck/kZ8XDT+3H+sYR9O+QUGqN6JJ6QWcI JDiE5iO0SDVVQprF3AjqpcrQvOJfM0VNI+/flTokkJx3MZ+k9SekxXnCnkK3PLtdz7iI DkchcudbwB3nCtDWVYFebLx2fX1/Ik2ZDrruwgpJBQ3S5AkVpe31wxyg+XhIvhrtyl5k Dywg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736771225; x=1737376025; 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=Eu4ESOBvVBzaEzRYnyWj2Jpuu4zqLWmBIIf9AvIQNX0=; b=Cuc9h4zG6Ux1ZWAHAk+XHEwQfqa4he2BQUxE08Amd5o/g7w439fcxFuW5lrmXi+9Ma d0JTWy1+irthq1x4goq4+aPckJUc8RjwR7ySa+QNzsQS/nH3SckSoaABpJJwdMtc2BXx BANjlKeUVuDUW2LRBXS+fImIgVVU8PExDvdueyIbY4UNlgisQBdZjCnxTiBm3ULEtWZB HiCZTcXKYYRwRpn1+VtgVTQUB0SksY1vRrBTxNsWuQ2QPpUtAMFnpzDzrJ7XNBbnKvXj NnGbuVCTRoLAbP055nBPVtBppIK3L9LbEg2QYQPFFK9lfGNx5Ypzk44jX1ndq1TZtXER 3pqQ== X-Forwarded-Encrypted: i=1; AJvYcCUrOXTGridfJk0Qge8IZ1mGcMyICyyGCgVUeN9oue6gc4WXSNzT8mwzTu9MmJvh+zGkvRCJMzBBjtGcvNCh@vger.kernel.org, AJvYcCVTzTyY8de1DbQoRQOZh3LoNO06CiGN0RRrOZe+DYHcVUey6FyRNZxg0/oVJmWMDSpNQDM6RKWh2g4=@vger.kernel.org X-Gm-Message-State: AOJu0YzfxSc7BolhmMb106U8+3d/iJkmOo9c4DblphWv972JctWALfRC Q0Q0efLhW3RkjOeywr1F3PPRU+S00j1rIypgcwKZ+PNqomSM9iKt X-Gm-Gg: ASbGnctgWQds71r0WhcmyK/duKJh77XwuTkESL4GxBT+279oaqG2uttqe6Q5VNAHpBP HEuEpiDfcsqnMzIH8zvTHBnhH2uNLn99Usa7Fu+hb/9BFDscnOVcSGygPJ9nT3gMzvKGb+Hg0xs 5LN8uiRASA2gUM3QJ4yzc9xJzcAyEDDZg8Al7Z/t/baUBgYMyyQXk1L4W3Amp7rP5azeCSUNveD W0+MU5VzvM6ZYI1lVgtMSMzn2wE44yqBrgkf1Sn9cYy+c0MthmB0sYD6Xmke0+y4mqC3LJ8ZpUG /FzKl8TA8w== X-Google-Smtp-Source: AGHT+IH++7Mt7kMI0ZNxMuFx6bJy0gxGzyTry5sGR7HsNR9hj6Q2VncFV4yRvdodzlJLS5SawD8f4g== X-Received: by 2002:a5d:5f51:0:b0:38a:8e2e:9fe3 with SMTP id ffacd0b85a97d-38a8e2ea20cmr13470048f8f.24.1736771225041; Mon, 13 Jan 2025 04:27:05 -0800 (PST) Received: from prasmi.Home ([2a06:5906:61b:2d00:acc9:404c:3a6c:d1aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4c23dcsm11812720f8f.101.2025.01.13.04.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 04:27:04 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Chris Brandt , Andi Shyti , Geert Uytterhoeven , Wolfram Sang , Andy Shevchenko , Philipp Zabel Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar , Claudiu Beznea Subject: [PATCH v6 10/10] i2c: riic: Implement bus recovery Date: Mon, 13 Jan 2025 12:26:43 +0000 Message-ID: <20250113122643.819379-11-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113122643.819379-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20250113122643.819379-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 Tested-by: Claudiu Beznea Reviewed-by: Claudiu Beznea --- Hi Wolfram, I have inlcuded bus recovery patch as part of v6 as I am seeing issues while using generic I2C algorithm for bus recovery as mentioned in the below thread. [0] https://lore.kernel.org/all/CA+V-a8s4-g9vxyfYMgnKMK=Oej9kDBwWsWehWLYTkxw-06w-2g@mail.gmail.com/ Cheers, Prabhakar v2->v6 - Included RB and TB from Claudiu. 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 d7dddd6c296a..888825423d94 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -51,6 +51,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) @@ -69,6 +70,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) @@ -82,6 +84,8 @@ #define RIIC_INIT_MSG -1 +#define RIIC_RECOVERY_CLK_CNT 9 + enum riic_reg_list { RIIC_ICCR1 = 0, RIIC_ICCR2, @@ -151,13 +155,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 ret; + 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 ret; + + /* 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; @@ -493,6 +572,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; @@ -505,7 +585,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; @@ -613,7 +693,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