From patchwork Wed Apr 2 10:20:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035746 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD75223642E; Wed, 2 Apr 2025 10:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589290; cv=none; b=nnJg0xLcFlBCfpY+BpIf4lisYOKMHYCXwmC+l6DQCbcv8d4A6e9iZfVI44gbmNvuh225mkRNTBSoysSZBOzw4ShHZnaUyYFLkQqVKXaEg4re9VfLWGoglDGSK3H+kHXbfNgQFn4hhv1+coERENYwvgrTU+RVcF+dmdG8cXEtc90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589290; c=relaxed/simple; bh=jtKsdUUKlIcdKd2BpXwIhgD6VAFFUTq0Rrd+HKolDM4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L2oiDqYjUlCCtQ1fjsAexe8YD5Q1UXRtSWWR46Hg4/kpVAjtbVAPL4vJsTUbaXPnVziP/koP3BmGynQLtU6+EWXhMkdOHvxd1XaK/Bev4DBRnF1EXEVEv03ZtMdP50EGb7Zp4F44ILt0CTTFlSjKv3BDkqS0G1vhgHP+qVZk53U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-CSE-ConnectionGUID: mrAPeXblT4GlGqVc168Mzg== X-CSE-MsgGUID: taUUyhY0S0qZpwnf1I8JQg== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:28 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id A6542401C759; Wed, 2 Apr 2025 19:21:25 +0900 (JST) From: Biju Das To: Marc Kleine-Budde , Vincent Mailhol Cc: Biju Das , Wolfram Sang , Geert Uytterhoeven , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , linux-can@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH v8 09/19] can: rcar_canfd: Add rnc_field_width variable to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:20:29 +0100 Message-ID: <20250402102047.27943-10-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The shift and w value in rcar_canfd_setrnc() are dictated by the field width: - R-Car Gen4 packs 2 values in a 32-bit word, using a field width of 16 bits, - R-Car Gen3 packs up to 4 values in a 32-bit word, using a field width of 8 bits. Add rnc_field_width variable to struct rcar_canfd_hw_info to handle this difference. The rnc_stride is 32 / rnc_field_width and the index parameter w is calculated by ch / rnc_stride. The shift value in rcar_canfd_setrnc() is computed by using (32 - (ch % rnc_stride + 1) * rnc_field_width). Reviewed-by: Geert Uytterhoeven Signed-off-by: Biju Das --- v7->v8: * Updated commit description. v6->v7: * Collected tag. v6: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index b2b87291dcf1..ee4d24646b2d 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -502,6 +502,7 @@ struct rcar_canfd_global; struct rcar_canfd_hw_info { + u8 rnc_field_width; u8 max_channels; u8 postdiv; /* hardware features */ @@ -578,18 +579,21 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = { }; static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { + .rnc_field_width = 8, .max_channels = 2, .postdiv = 2, .shared_global_irqs = 1, }; static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { + .rnc_field_width = 16, .max_channels = 8, .postdiv = 2, .shared_global_irqs = 1, }; static const struct rcar_canfd_hw_info rzg2l_hw_info = { + .rnc_field_width = 8, .max_channels = 2, .postdiv = 1, .multi_channel_irqs = 1, @@ -675,9 +679,10 @@ static void rcar_canfd_tx_failure_cleanup(struct net_device *ndev) static void rcar_canfd_setrnc(struct rcar_canfd_global *gpriv, unsigned int ch, unsigned int num_rules) { - unsigned int shift = reg_gen4(gpriv, 16, 24) - (ch & 1) * reg_gen4(gpriv, 16, 8); + unsigned int rnc_stride = 32 / gpriv->info->rnc_field_width; + unsigned int shift = 32 - (ch % rnc_stride + 1) * gpriv->info->rnc_field_width; + unsigned int w = ch / rnc_stride; u32 rnc = num_rules << shift; - unsigned int w = ch / 2; rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLCFG(w), rnc); }