From patchwork Thu Mar 6 12:42:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14004435 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 1DB4C190051; Thu, 6 Mar 2025 12:43:24 +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=1741265006; cv=none; b=G18WFGvC4IgcKb4CFsLrQRY9Oqa68VKfz6a03p+RtEzX9qvD44cvT6JS7PkQ5zvWNEZI1u04pzmxiexJI8o/sF9BvAi4aw+GymYc1cS3Xk1EkJyinZw3V3WwQOH+1uKLaTKpUDbPNLh0nr/SCNX6IOAibFyv6eLGePjDW9VsCPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741265006; c=relaxed/simple; bh=rCOWjDTHH7R8LnSELQundOl5VWXN+RHp1dk/qqkecZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uB4icQ2BdVjoEUpCuAosLOecwBKiQPyFFoecGDutar7tMjUxRotZ/w4fpk5Puapgj+PA9CcCzO/sptRM//u12QgZrcCZKmbGxo6lgF4XRW5IQAQymkI5/JvWRl+lr7noqSeZF3y+lJsQ6DfGbexxP7oujkmdFuXrHsVHWwy7OKc= 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: NYHLih1ZSKmVJig35Fl+Gg== X-CSE-MsgGUID: bFHgLdHORoGI/m40/6FsOA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 06 Mar 2025 21:43:24 +0900 Received: from localhost.localdomain (unknown [10.226.92.10]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id F17C34281B03; Thu, 6 Mar 2025 21:43:21 +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 v4 05/11] can: rcar_canfd: Add shared_can_regs variable to struct rcar_canfd_hw_info Date: Thu, 6 Mar 2025 12:42:44 +0000 Message-ID: <20250306124256.93033-6-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250306124256.93033-1-biju.das.jz@bp.renesas.com> References: <20250306124256.93033-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 R-Car Gen4 has shared regs for both CAN-FD and Classical CAN operations. Add shared_can_regs variable to struct rcar_canfd_hw_info to handle this difference. Signed-off-by: Biju Das --- v3->v4: * No change. v3: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index e21041fe432c..f71725da57ce 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -517,6 +517,7 @@ struct rcar_canfd_hw_info { unsigned shared_global_irqs:1; /* Has shared global irqs */ unsigned multi_channel_irqs:1; /* Has multiple channel irqs */ unsigned ch_interface_mode:1; /* Has channel interface mode */ + unsigned shared_can_reg:1; /* Has shared classical can registers */ }; /* Channel priv data */ @@ -598,6 +599,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .postdiv = 2, .shared_global_irqs = 1, .ch_interface_mode = 1, + .shared_can_reg = 1, }; static const struct rcar_canfd_hw_info rzg2l_hw_info = { @@ -813,7 +815,7 @@ static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv, /* Write number of rules for channel */ rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLCFG(ch), RCANFD_GAFLCFG_SETRNC(gpriv, ch, num_rules)); - if (is_gen4(gpriv)) + if (gpriv->info->shared_can_reg) offset = RCANFD_GEN4_GAFL_OFFSET; else if (gpriv->fdmode) offset = RCANFD_F_GAFL_OFFSET; @@ -1349,7 +1351,7 @@ static void rcar_canfd_set_bittiming(struct net_device *dev) brp, sjw, tseg1, tseg2); } else { /* Classical CAN only mode */ - if (is_gen4(gpriv)) { + if (gpriv->info->shared_can_reg) { cfg = (RCANFD_NCFG_NTSEG1(gpriv, tseg1) | RCANFD_NCFG_NBRP(brp) | RCANFD_NCFG_NSJW(gpriv, sjw) | @@ -1514,7 +1516,7 @@ static netdev_tx_t rcar_canfd_start_xmit(struct sk_buff *skb, dlc = RCANFD_CFPTR_CFDLC(can_fd_len2dlc(cf->len)); - if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) || is_gen4(gpriv)) { + if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) || gpriv->info->shared_can_reg) { rcar_canfd_write(priv->base, RCANFD_F_CFID(gpriv, ch, RCANFD_CFFIFO_IDX), id); rcar_canfd_write(priv->base, @@ -1573,7 +1575,7 @@ static void rcar_canfd_rx_pkt(struct rcar_canfd_channel *priv) u32 ch = priv->channel; u32 ridx = ch + RCANFD_RFFIFO_IDX; - if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) || is_gen4(gpriv)) { + if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) || gpriv->info->shared_can_reg) { id = rcar_canfd_read(priv->base, RCANFD_F_RFID(gpriv, ridx)); dlc = rcar_canfd_read(priv->base, RCANFD_F_RFPTR(gpriv, ridx)); @@ -1624,7 +1626,7 @@ static void rcar_canfd_rx_pkt(struct rcar_canfd_channel *priv) cf->len = can_cc_dlc2len(RCANFD_RFPTR_RFDLC(dlc)); if (id & RCANFD_RFID_RFRTR) cf->can_id |= CAN_RTR_FLAG; - else if (is_gen4(gpriv)) + else if (gpriv->info->shared_can_reg) rcar_canfd_get_data(priv, cf, RCANFD_F_RFDF(gpriv, ridx, 0)); else rcar_canfd_get_data(priv, cf, RCANFD_C_RFDF(ridx, 0));