From patchwork Thu Mar 20 09:10:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14023561 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 15B171A238C; Thu, 20 Mar 2025 09:11:42 +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=1742461905; cv=none; b=avL2wh1Xr68j83y7mo1sEq8vwdZlFPpp8QYkixWCRabzAe5Ez4MHmJzWVJkY1jHcLsre9GoVbbY6jzOv273ogZcPSMpM8TCdnrjRqQhrw9T8y3XAw93XYyjD/nJmb0r4T8NJVWtWwe3iUhwkX9zPYyI3vIk+CmCg1y4uecIaj/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742461905; c=relaxed/simple; bh=foeK/uilJbELSNekStGS+N16ALqK3nEQFCrHtU1YuAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t0GpP/z9H6S+7K1GwI6VprFvoHj7m5uTdu4kCCzfc5VsI6LGII382Jr5XXRv/1Q0IlKnGCplWIZZElO3dsx/rn8Rvqi2sYiR13Mm2dk3ZhS4UXaFG5psAi64agmeHV5koITPM7sKkZ/SOc/pvXfGhiikl4pvHNxvBxv1899rQlQ= 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: vhwt71U9SHSY1u+6WIbgvQ== X-CSE-MsgGUID: 0zewnTUhQpOsgo+NkUSilw== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 20 Mar 2025 18:11:42 +0900 Received: from localhost.localdomain (unknown [10.226.93.24]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id E84BF4001DAF; Thu, 20 Mar 2025 18:11:39 +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 v6 08/18] can: rcar_canfd: Simplify RCANFD_GAFLCFG_SETRNC macro Date: Thu, 20 Mar 2025 09:10:39 +0000 Message-ID: <20250320091101.33637-9-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250320091101.33637-1-biju.das.jz@bp.renesas.com> References: <20250320091101.33637-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 values in RCANFD_GAFLCFG_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 and simplify the shift value in RCANFD_GAFLCFG_SETRNC macro by using a formula (32 - (n % rnc_stride + 1) * rnc_field_width). Signed-off-by: Biju Das Reviewed-by: Geert Uytterhoeven --- v5->6: * Replaced RCANFD_RNC_PER_REG macro with rnc_stride variable. * Updated commit description * Dropped the Rb tag. v5: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 0001c8043c25..62cde1efa0c0 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -89,7 +89,7 @@ /* RSCFDnCFDGAFLCFG0 / RSCFDnGAFLCFG0 */ #define RCANFD_GAFLCFG_SETRNC(gpriv, n, x) \ (((x) & ((gpriv)->info->num_supported_rules - 1)) << \ - (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8))) + (32 - (((n) % (gpriv)->info->rnc_stride + 1) * (gpriv)->info->rnc_field_width))) /* RSCFDnCFDGAFLECTR / RSCFDnGAFLECTR */ #define RCANFD_GAFLECTR_AFLDAE BIT(8) @@ -506,6 +506,7 @@ struct rcar_canfd_global; struct rcar_canfd_hw_info { u16 num_supported_rules; u8 rnc_stride; + u8 rnc_field_width; u8 max_channels; u8 postdiv; /* hardware features */ @@ -584,6 +585,7 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = { static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { .num_supported_rules = 256, .rnc_stride = 4, + .rnc_field_width = 8, .max_channels = 2, .postdiv = 2, .shared_global_irqs = 1, @@ -592,6 +594,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .num_supported_rules = 512, .rnc_stride = 2, + .rnc_field_width = 16, .max_channels = 8, .postdiv = 2, .shared_global_irqs = 1, @@ -600,6 +603,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { static const struct rcar_canfd_hw_info rzg2l_hw_info = { .num_supported_rules = 256, .rnc_stride = 4, + .rnc_field_width = 8, .max_channels = 2, .postdiv = 1, .multi_channel_irqs = 1,