From patchwork Wed Apr 2 10:21:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035750 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 D525023496B; Wed, 2 Apr 2025 10:22:38 +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=1743589360; cv=none; b=QcsFbHosGmLYZ5o2LGkzivwbZ8uoCxz7B2HkdaHDBFF9Cefn7WKyZoEd5UC8Xb4jUygrUno7LyduLaDOzBpZjCyv9aZUoRqL9FicnRZW4IOFilGNjp80xQvJyqjo32/RRmQq0aWG2bZ+QwfB4l83ZYpyDbJd0/cTsOQKpOtLCBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589360; c=relaxed/simple; bh=5wtNBVVkxEfypneA46AZuGKvxc8VE8UUQN+plr+f0gI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OvkH+7wdPSwXKcjSFQHgsHBorFlrerRxGYxngtYgmwsnuGZPVwrwyHmAEFiqNw1EUTvAxHfvGjv1RLrMRFHCzoluPKmK0Y0l+cLihIjZ4vMvRsmrsDvIzlnO7SuCY8Yi8wSuzP/5Zg1fxAzhhFYKTWWs62qmqqOVh+2bOUM8DGs= 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: 532p3sIISgGGiJGNA59MKA== X-CSE-MsgGUID: 7x98D9vzT/SU3GetWGSvBA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:22:38 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id DB1974222E78; Wed, 2 Apr 2025 19:22:33 +0900 (JST) From: Biju Das To: Marc Kleine-Budde , Vincent Mailhol , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , Fabrizio Castro , Simon Horman , Duy Nguyen , linux-can@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das , Conor Dooley Subject: [PATCH v8 01/19] dt-bindings: can: renesas,rcar-canfd: Simplify the conditional schema Date: Wed, 2 Apr 2025 11:21:53 +0100 Message-ID: <20250402102226.28032-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 RZ/G3E SoC has 20 interrupts, 2 resets and 6 channels that need more branching with conditional schema. Simplify the conditional schema with if statements rather than the complex if-else statements to prepare for supporting RZ/G3E SoC. Acked-by: Conor Dooley Reviewed-by: Geert Uytterhoeven Signed-off-by: Biju Das --- v7->v8: * No change. v6->v7: * No change. v5->v6: * No change. v4->v5: * The rules for R-Car Gen3/4 could be kept together, reducing the number of lines. Done the similar change for rzg2l-canfd. * Retained the tags as it is trivial change. v3->v4: * No change. v2->v3: * Collected tags. v1->v2: * No change --- .../bindings/net/can/renesas,rcar-canfd.yaml | 99 +++++++++++-------- 1 file changed, 60 insertions(+), 39 deletions(-) diff --git a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml index f6884f6e59e7..4a83498b2a8b 100644 --- a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml +++ b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml @@ -45,7 +45,35 @@ properties: reg: maxItems: 1 - interrupts: true + interrupts: + oneOf: + - items: + - description: Channel interrupt + - description: Global interrupt + - items: + - description: CAN global error interrupt + - description: CAN receive FIFO interrupt + - description: CAN0 error interrupt + - description: CAN0 transmit interrupt + - description: CAN0 transmit/receive FIFO receive completion interrupt + - description: CAN1 error interrupt + - description: CAN1 transmit interrupt + - description: CAN1 transmit/receive FIFO receive completion interrupt + + interrupt-names: + oneOf: + - items: + - const: ch_int + - const: g_int + - items: + - const: g_err + - const: g_recc + - const: ch0_err + - const: ch0_rec + - const: ch0_trx + - const: ch1_err + - const: ch1_rec + - const: ch1_trx clocks: maxItems: 3 @@ -117,52 +145,55 @@ allOf: then: properties: interrupts: - items: - - description: CAN global error interrupt - - description: CAN receive FIFO interrupt - - description: CAN0 error interrupt - - description: CAN0 transmit interrupt - - description: CAN0 transmit/receive FIFO receive completion interrupt - - description: CAN1 error interrupt - - description: CAN1 transmit interrupt - - description: CAN1 transmit/receive FIFO receive completion interrupt + minItems: 8 + maxItems: 8 interrupt-names: - items: - - const: g_err - - const: g_recc - - const: ch0_err - - const: ch0_rec - - const: ch0_trx - - const: ch1_err - - const: ch1_rec - - const: ch1_trx + minItems: 8 + maxItems: 8 resets: + minItems: 2 maxItems: 2 reset-names: - items: - - const: rstp_n - - const: rstc_n + minItems: 2 + maxItems: 2 required: - reset-names - else: + + - if: + properties: + compatible: + contains: + enum: + - renesas,rcar-gen3-canfd + - renesas,rcar-gen4-canfd + then: properties: interrupts: - items: - - description: Channel interrupt - - description: Global interrupt + minItems: 2 + maxItems: 2 interrupt-names: - items: - - const: ch_int - - const: g_int + minItems: 2 + maxItems: 2 resets: maxItems: 1 + - if: + properties: + compatible: + contains: + enum: + - renesas,rcar-gen3-canfd + - renesas,rzg2l-canfd + then: + patternProperties: + "^channel[2-7]$": false + - if: properties: compatible: @@ -171,16 +202,6 @@ allOf: then: patternProperties: "^channel[4-7]$": false - else: - if: - not: - properties: - compatible: - contains: - const: renesas,rcar-gen4-canfd - then: - patternProperties: - "^channel[2-7]$": false unevaluatedProperties: false From patchwork Wed Apr 2 10:21:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035751 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31164235BE8; Wed, 2 Apr 2025 10:22:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589366; cv=none; b=eMD76pM/K42b7NB+qMOMiLXaw83gcjW3y1a1ROixPjwraPuygMeIpoCOaJmafz4fBLCu6gzm0Rf36EPPrU8YroFgdtJkMv0YZWzwWlvrs2y+YLtSZS6BLDFztFozaGkZDqtECurjFdNxNauq7+TSZUVqEYV1srzAH4WZB0luVTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589366; c=relaxed/simple; bh=+K8K9u6y5Z8sCK3//Pf0EXDMz5wTG60LRO9scUYcGGA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QieUEvVNTiP1zG0NMBDc/JPym4af9XjirF2Zg/CU2bo0vAemqpaEkMmmQTVDRD6m59SZGB/Muv7C0a5W603YecLEYigkipIeBETztfvTnDPYYzETKnlm+4RQrLxuvD30xRC/rAp1M6rJSazb61NT2FNznwmTXcs2HhXFy6URM+Y= 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.172 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: P/FpafFwToaw+nKQJhjwAg== X-CSE-MsgGUID: D72IuE5nT2a7kk3DIAnRCA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:22:43 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 29A134222E70; Wed, 2 Apr 2025 19:22:38 +0900 (JST) From: Biju Das To: Marc Kleine-Budde , Vincent Mailhol , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , Fabrizio Castro , Simon Horman , Duy Nguyen , linux-can@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das Subject: [PATCH v8 02/19] dt-bindings: can: renesas,rcar-canfd: Document RZ/G3E support Date: Wed, 2 Apr 2025 11:21:54 +0100 Message-ID: <20250402102226.28032-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Document support for the CAN-FD Interface on the RZ/G3E (R9A09G047) SoC, which supports up to six channels. The CAN-FD module on RZ/G3E is very similar to the one on both R-Car V4H and RZ/G2L, but differs in some hardware parameters: * No external clock, but instead has ram clock. * Support up to 6 channels. * 20 interrupts. Reviewed-by: Rob Herring (Arm) Reviewed-by: Geert Uytterhoeven Signed-off-by: Biju Das --- v7->v8: * No change. v6->v7: * No change. v5->v6: * No change. v4->v5: * Keeping interrupts and resets together allows to keep a clear separation between RZ/G2L and RZ/G3E, at the expense of only a single line. * Retained the tags as it is trivial change. v3->v4: * Added Rb tag from Rob. v2->v3: * Replaced maxItems->minItems: 20 for RZ/G3E interrupt,s as the list has 20 elements and for existing platforms dropped minItems and keep maxItems: 8. v1->v2: * No change. --- .../bindings/net/can/renesas,rcar-canfd.yaml | 76 +++++++++++++++++-- 1 file changed, 70 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml index 4a83498b2a8b..f4ac21c68427 100644 --- a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml +++ b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml @@ -42,6 +42,8 @@ properties: - renesas,r9a07g054-canfd # RZ/V2L - const: renesas,rzg2l-canfd # RZ/G2L family + - const: renesas,r9a09g047-canfd # RZ/G3E + reg: maxItems: 1 @@ -59,6 +61,19 @@ properties: - description: CAN1 error interrupt - description: CAN1 transmit interrupt - description: CAN1 transmit/receive FIFO receive completion interrupt + - description: CAN2 error interrupt + - description: CAN2 transmit interrupt + - description: CAN2 transmit/receive FIFO receive completion interrupt + - description: CAN3 error interrupt + - description: CAN3 transmit interrupt + - description: CAN3 transmit/receive FIFO receive completion interrupt + - description: CAN4 error interrupt + - description: CAN4 transmit interrupt + - description: CAN4 transmit/receive FIFO receive completion interrupt + - description: CAN5 error interrupt + - description: CAN5 transmit interrupt + - description: CAN5 transmit/receive FIFO receive completion interrupt + minItems: 8 interrupt-names: oneOf: @@ -74,15 +89,33 @@ properties: - const: ch1_err - const: ch1_rec - const: ch1_trx + - const: ch2_err + - const: ch2_rec + - const: ch2_trx + - const: ch3_err + - const: ch3_rec + - const: ch3_trx + - const: ch4_err + - const: ch4_rec + - const: ch4_trx + - const: ch5_err + - const: ch5_rec + - const: ch5_trx + minItems: 8 clocks: maxItems: 3 clock-names: - items: - - const: fck - - const: canfd - - const: can_clk + oneOf: + - items: + - const: fck + - const: canfd + - const: can_clk + - items: + - const: fck + - const: ram_clk + - const: can_clk power-domains: maxItems: 1 @@ -145,11 +178,9 @@ allOf: then: properties: interrupts: - minItems: 8 maxItems: 8 interrupt-names: - minItems: 8 maxItems: 8 resets: @@ -183,6 +214,30 @@ allOf: resets: maxItems: 1 + - if: + properties: + compatible: + contains: + const: renesas,r9a09g047-canfd + then: + properties: + interrupts: + minItems: 20 + + interrupt-names: + minItems: 20 + + resets: + minItems: 2 + maxItems: 2 + + reset-names: + minItems: 2 + maxItems: 2 + + required: + - reset-names + - if: properties: compatible: @@ -203,6 +258,15 @@ allOf: patternProperties: "^channel[4-7]$": false + - if: + properties: + compatible: + contains: + const: renesas,r9a09g047-canfd + then: + patternProperties: + "^channel[6-7]$": false + unevaluatedProperties: false examples: From patchwork Wed Apr 2 10:21:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035752 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2E7253BE; Wed, 2 Apr 2025 10:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589369; cv=none; b=kH0ZLOlAmrncCFJKKiX2TJ/UTLS0XbANsUv/cKaEeCpn8R4LRWQDaKaBLtVjMKoofuBfWmCEVnu1UIDMuA+2iwTVtaP6mp1PvafocqmzEujW4jLPt+34gbaBic3ePZCGWLv8BWE352tEb6OeDGFO3Ef0yID/8JCP2KlThcTV6zM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589369; c=relaxed/simple; bh=UCfydqd9zT+xvD4YM8nH6iXme/emAuct9ppKIZ7ze/Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KRxmME9qLS3D1OgafbMtDoi/qnGOyxPidjsVn63auPQjtWHMSbYlPpR8z40B62ECjlK1ST3XqkFlrrUQ38cZDkkOyVrHFn+byw4e0+O4mNFgCk229zcwod6ey1AJa9bSsnWKVHtJ/49FVAWhtbRwcQXZF5dJsYQV0NTbWv5ZLIc= 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.172 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: FyxOSCR6SICwaf+st//4sg== X-CSE-MsgGUID: rwAwC4NnQ16lG4z4LQY6Mw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:22:47 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 2AA6E4222E78; Wed, 2 Apr 2025 19:22:43 +0900 (JST) From: Biju Das To: Marc Kleine-Budde , Vincent Mailhol Cc: Biju Das , Geert Uytterhoeven , Wolfram Sang , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Rob Herring , Ulrich Hecht , linux-can@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH v8 03/19] can: rcar_canfd: Use of_get_available_child_by_name() Date: Wed, 2 Apr 2025 11:21:55 +0100 Message-ID: <20250402102226.28032-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Simplify rcar_canfd_probe() using of_get_available_child_by_name(). While at it, move of_node_put(child) inside the if block to avoid additional check if of_child is NULL. Reviewed-by: Vincent Mailhol Reviewed-by: Geert Uytterhoeven Signed-off-by: Biju Das --- v7->v8: * No change. v6->v7: * No change. v5->v6: * No change. v4->v5: * No change. v3->v4: * No change. v2->v3: * Added Rb tag from Geert. v2: * Added to this series as dependency patch hit on can-next. * Added Rb tag from Vincent Mailhol * Dropped redundant comment from commit description. --- drivers/net/can/rcar/rcar_canfd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index aa3df0d05b85..2d9569fd0e0b 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -1855,13 +1855,13 @@ static int rcar_canfd_probe(struct platform_device *pdev) for (i = 0; i < info->max_channels; ++i) { name[7] = '0' + i; - of_child = of_get_child_by_name(dev->of_node, name); - if (of_child && of_device_is_available(of_child)) { + of_child = of_get_available_child_by_name(dev->of_node, name); + if (of_child) { channels_mask |= BIT(i); transceivers[i] = devm_of_phy_optional_get(dev, of_child, NULL); + of_node_put(of_child); } - of_node_put(of_child); if (IS_ERR(transceivers[i])) return PTR_ERR(transceivers[i]); } From patchwork Wed Apr 2 10:21:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035753 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 5A78D53BE; Wed, 2 Apr 2025 10:22:51 +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=1743589374; cv=none; b=ig4w5z15YlZrOKgwMBedCDdt7GvBdCNpw0qhhy4nTpRTTHQveA6aAxhQI7VVivitXNbac+zjdxq1bLu+wMdRhnBFBEWJPLQBoRj4RoK5M6uARvoXyr1FSsNuqBZqEL1T8/tTpsltUTJT+tozWlV48rRmF6HHCYv+sDOYIQLv1mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589374; c=relaxed/simple; bh=jEH+/LY2v3Y2Gs6bIr6D97+DiiJDQe+aJAPPPZqWSyg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T0mh4bhjzog+XQEg0yQQpNpU47d0LEMP27Y6srvo0Ezb441fGnT5oonyCWXglGeQ0qODh5ZASXfK8zxiMvUX9bXp7y+sD4m/4FIqpjZasz2obdHUxnJaKQeoeNe49w4IBk6Q/x4GAZ+UOQaBFyM0HOWAc7eUF4eIFbFy8mAiBVU= 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: lsjjsOzyToqabhWwjfQWcQ== X-CSE-MsgGUID: MERVr5xnQl23ERM7QJfyOw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:22:51 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 196B04222E78; Wed, 2 Apr 2025 19:22:47 +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 04/19] can: rcar_canfd: Drop RCANFD_GAFLCFG_GETRNC macro Date: Wed, 2 Apr 2025 11:21:56 +0100 Message-ID: <20250402102226.28032-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Drop the unused macro RCANFD_GAFLCFG_GETRNC. Reviewed-by: Geert Uytterhoeven Reviewed-by: Vincent Mailhol Signed-off-by: Biju Das --- v7->v8: * Collected tag. v6->v7: * No change. v5->v6: * Collected tag. v5: * New patch --- drivers/net/can/rcar/rcar_canfd.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 2d9569fd0e0b..565a91c2ca83 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -94,10 +94,6 @@ (((x) & reg_gen4(gpriv, 0x1ff, 0xff)) << \ (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8))) -#define RCANFD_GAFLCFG_GETRNC(gpriv, n, x) \ - (((x) >> (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8))) & \ - reg_gen4(gpriv, 0x1ff, 0xff)) - /* RSCFDnCFDGAFLECTR / RSCFDnGAFLECTR */ #define RCANFD_GAFLECTR_AFLDAE BIT(8) #define RCANFD_GAFLECTR_AFLPN(gpriv, x) ((x) & reg_gen4(gpriv, 0x7f, 0x1f)) From patchwork Wed Apr 2 10:21:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035754 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B41E7236A6D; Wed, 2 Apr 2025 10:22:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589377; cv=none; b=ktBZya/benPmyysSQ8K29n537yq+7jxUifwePKQwZ8gwuGWos8PdtxImOpZAEIITqPhtznlx8cZYbkufvM9e9zQrr9MYxIGERe4SiOdF/sj7VBMObwQEd0hff3MErbrJMV/y0jIE7lbWN6hvE66ddTK/VGXzEQEMgpvwx8a1wMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589377; c=relaxed/simple; bh=yIBwMbzqJ6zOnHdUv2lIo8hse+8X/W1xeHcs+N9gr2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gmuHIRc354ErypAFKTlY5KVPgzl112V37OjI/7M0gs6s2GUbqsMtUknlAILpgS1N51N/SPXe7kNNVOb9An2A+457m9pQQIW0/HRBJj6bbUdRTGQFycXPUTfQ90t/q5lnGIrc2RDQY3HdGLK4qHT34DGqRUMubkvle1AythlLjcs= 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.172 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: oVpfX/v4Tl+wiWHhRDlm1Q== X-CSE-MsgGUID: N0wFbfd1ToSUur9w+BMjYg== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:22:54 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id A202342241E7; Wed, 2 Apr 2025 19:22:51 +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 05/19] can: rcar_canfd: Update RCANFD_GERFL_ERR macro Date: Wed, 2 Apr 2025 11:21:57 +0100 Message-ID: <20250402102226.28032-6-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Replace the macro RCANFD_GERFL_EEF0_7->RCANFD_GERFL_EEF. The macros RCANFD_GERFL_EEF* in RCANFD_GERFL_ERR can be replaced by FIELD_PREP() and drop the redundant macro RCANFD_GERFL_EEF(ch). Signed-off-by: Biju Das --- v7->v8: * Updated commit description. * Replaced the macro RCANFD_GERFL_EEF0_7->RCANFD_GERFL_EEF. * Dropped the redundant macro RCANFD_GERFL_EEF(ch). * Dropped the tag. v6->v7: * No change. v5->v6: * Collected tag. v5: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 565a91c2ca83..34b918e8ec1c 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -74,18 +74,18 @@ #define RCANFD_GSTS_GNOPM (BIT(0) | BIT(1) | BIT(2) | BIT(3)) /* RSCFDnCFDGERFL / RSCFDnGERFL */ -#define RCANFD_GERFL_EEF0_7 GENMASK(23, 16) -#define RCANFD_GERFL_EEF(ch) BIT(16 + (ch)) +#define RCANFD_GERFL_EEF GENMASK(23, 16) #define RCANFD_GERFL_CMPOF BIT(3) /* CAN FD only */ #define RCANFD_GERFL_THLES BIT(2) #define RCANFD_GERFL_MES BIT(1) #define RCANFD_GERFL_DEF BIT(0) #define RCANFD_GERFL_ERR(gpriv, x) \ - ((x) & (reg_gen4(gpriv, RCANFD_GERFL_EEF0_7, \ - RCANFD_GERFL_EEF(0) | RCANFD_GERFL_EEF(1)) | \ - RCANFD_GERFL_MES | \ - ((gpriv)->fdmode ? RCANFD_GERFL_CMPOF : 0))) +({\ + typeof(gpriv) (_gpriv) = (gpriv); \ + ((x) & ((FIELD_PREP(RCANFD_GERFL_EEF, (_gpriv)->channels_mask)) | \ + RCANFD_GERFL_MES | ((_gpriv)->fdmode ? RCANFD_GERFL_CMPOF : 0))); \ +}) /* AFL Rx rules registers */ @@ -938,7 +938,7 @@ static void rcar_canfd_global_error(struct net_device *ndev) u32 ridx = ch + RCANFD_RFFIFO_IDX; gerfl = rcar_canfd_read(priv->base, RCANFD_GERFL); - if (gerfl & RCANFD_GERFL_EEF(ch)) { + if (gerfl & FIELD_PREP(RCANFD_GERFL_EEF, ch)) { netdev_dbg(ndev, "Ch%u: ECC Error flag\n", ch); stats->tx_dropped++; } From patchwork Wed Apr 2 10:21:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035763 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61583235BF0; Wed, 2 Apr 2025 10:22:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589380; cv=none; b=ODduZWZQRKbVUJ7bLZZ+0P0gjFTjXY52BiGynCvl4n5Lxg0nhRj0nIEC9uNZQl5kOEAP2o99iHCC7UV7xuNRkj5Qci9o5ccIlgEs88ROgp7q6WZNwyEJyJKu7tfjXfOnF22xs0J/0qmT1pot7vKnQPX5dp4xH+YVnXNFX359O/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589380; c=relaxed/simple; bh=squ4J4KXqQBUlULcmYlzGzCJxkIWghsxDRs1Te4RYrk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aw9YF1m8clFs8czFVlejkXh4kszvfRrjLsNJF0hYceyPEuud1A6r4dy7h4noCFg6fRxQnaDnirwkQebmE/610MueXynHvzx3nT5WoOWlckZvwO+FIGvaxFEKNFS7aINu1CfqQn2z3wMGkPgP5LEIozBFohJamM3D3Cimp8oUayg= 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.172 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: 8DhZlcFmRD+SX+ZVORO7JQ== X-CSE-MsgGUID: 2NZbHlx2RQSYRmPQWsIsTQ== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:22:58 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 498184222E70; Wed, 2 Apr 2025 19:22:55 +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 06/19] can: rcar_canfd: Drop the mask operation in RCANFD_GAFLCFG_SETRNC macro Date: Wed, 2 Apr 2025 11:21:58 +0100 Message-ID: <20250402102226.28032-7-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Drop the mask operation in RCANFD_GAFLCFG_SETRNC macro as the num_rules can never be larger than number of supported rules. Signed-off-by: Biju Das --- v8: * New patch --- drivers/net/can/rcar/rcar_canfd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 34b918e8ec1c..8205e4ada12e 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -91,8 +91,7 @@ /* RSCFDnCFDGAFLCFG0 / RSCFDnGAFLCFG0 */ #define RCANFD_GAFLCFG_SETRNC(gpriv, n, x) \ - (((x) & reg_gen4(gpriv, 0x1ff, 0xff)) << \ - (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8))) + ((x) << (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8))) /* RSCFDnCFDGAFLECTR / RSCFDnGAFLECTR */ #define RCANFD_GAFLECTR_AFLDAE BIT(8) From patchwork Wed Apr 2 10:21:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035764 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 9000F235BE4; Wed, 2 Apr 2025 10:23:02 +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=1743589384; cv=none; b=gkLXxojRhpmsv12SegJXlnKe1Tn0FO2UHgGA72BtyWotieopojc2N1kN/Qm1VJ9DYn8+BGzwO2sCerMYQiN9daBnmnLbUd8WjHyPj6mCCvAS1kd73euLAGRtBBdMxj5TokjWrNnzautQNHsQDTrL/RMlSavTT0GMMEubzfWL4sc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589384; c=relaxed/simple; bh=0kq1G3DHhA9ffXoYE2ZCDUdX+emnmO/4xdi1UFZmiq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SCAllzYEk6kjN6+9VvPADMAIeMaNzs0sj7SOidy2BljqYxt6SJYmoHwzbjdK4e8MK8DGupq3kIkP011RGjBJ2uk2r65LCQgoEQcUTPxbAt2UyrqYFWG4ZoNKFWWPMrkUa8t4yL5cSXfhzo8j21aN6wfDojYWl/u4pcUpcEclmVs= 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: rJo7DCmARL6vP5+h3iUYIQ== X-CSE-MsgGUID: RoF8yThlQO6+T3Go0hiWhw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:01 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id AEEF442241F9; Wed, 2 Apr 2025 19:22:58 +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 07/19] can: rcar_canfd: Add rcar_canfd_setrnc() Date: Wed, 2 Apr 2025 11:21:59 +0100 Message-ID: <20250402102226.28032-8-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Add rcar_canfd_setrnc() to replace the macro RCANFD_GAFLCFG_SETRNC. While at it, replace int->unsigned int for local variables offset, page and num_rules in rcar_canfd_configure_afl_rules(). Signed-off-by: Biju Das --- v8: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 8205e4ada12e..98532f4031b1 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -89,10 +89,6 @@ /* AFL Rx rules registers */ -/* RSCFDnCFDGAFLCFG0 / RSCFDnGAFLCFG0 */ -#define RCANFD_GAFLCFG_SETRNC(gpriv, n, x) \ - ((x) << (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8))) - /* RSCFDnCFDGAFLECTR / RSCFDnGAFLECTR */ #define RCANFD_GAFLECTR_AFLDAE BIT(8) #define RCANFD_GAFLECTR_AFLPN(gpriv, x) ((x) & reg_gen4(gpriv, 0x7f, 0x1f)) @@ -676,6 +672,15 @@ static void rcar_canfd_tx_failure_cleanup(struct net_device *ndev) can_free_echo_skb(ndev, i, NULL); } +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); + u32 rnc = num_rules << shift; + + rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLCFG(ch), rnc); +} + static void rcar_canfd_set_mode(struct rcar_canfd_global *gpriv) { if (is_gen4(gpriv)) { @@ -784,7 +789,7 @@ static void rcar_canfd_configure_controller(struct rcar_canfd_global *gpriv) static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv, u32 ch, u32 rule_entry) { - int offset, page, num_rules = RCANFD_CHANNEL_NUMRULES; + unsigned int offset, page, num_rules = RCANFD_CHANNEL_NUMRULES; u32 rule_entry_index = rule_entry % 16; u32 ridx = ch + RCANFD_RFFIFO_IDX; @@ -795,8 +800,7 @@ static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv, RCANFD_GAFLECTR_AFLDAE)); /* Write number of rules for channel */ - rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLCFG(ch), - RCANFD_GAFLCFG_SETRNC(gpriv, ch, num_rules)); + rcar_canfd_setrnc(gpriv, ch, num_rules); if (is_gen4(gpriv)) offset = RCANFD_GEN4_GAFL_OFFSET; else if (gpriv->fdmode) From patchwork Wed Apr 2 10:22:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035765 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 43D1E53BE; Wed, 2 Apr 2025 10:23:05 +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=1743589386; cv=none; b=nHHVag7s8K9MX6qcDconDX3NsCNYu/GiUrv9yTDufdv38YdLDA8JBVJYB0EdPC436kxzvG5m/o1MzuVPZOPVYmxzYsRHsmB5aCakRr8T5sGBpM6ONQ5xBHuC1xp2YT7iJ+UeZfbYXH4O9IGUjas1BWT4QbkcLLY043hHZxVudeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589386; c=relaxed/simple; bh=+UZlOw47u+6+638D99dC1yO5TdFlW+yeBCc0XEkiBdc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YZKCIrtdM9mtOI3uFf9m4IVdaSazaarUUqTPvxfKfsrCDcFXP2Wx5UITvQOTCpmgVns7jXF+YaW4v8MlCeNU5KwFPMXirWmJaiDUN5Ew6Fa0fnRM1V91MHrRdS0r1hkjgB15Qkc/CPV7u+g2Cx5blxpkMVimSLlZ9eBKiqNHjlU= 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: WTWlbQ8iRrW8j4w3MJWYJw== X-CSE-MsgGUID: 4B0IyejqQeC8hUCn6yT2qg== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:05 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 2EAEF4224218; Wed, 2 Apr 2025 19:23:01 +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 08/19] can: rcar_canfd: Update RCANFD_GAFLCFG macro Date: Wed, 2 Apr 2025 11:22:00 +0100 Message-ID: <20250402102226.28032-9-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Update RCANFD_GAFLCFG macro by replacing the parameter ch->w, where w is the GAFLCFG index used in the hardware manual. Signed-off-by: Biju Das --- v8: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 98532f4031b1..b2b87291dcf1 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -289,7 +289,7 @@ /* RSCFDnCFDGAFLECTR / RSCFDnGAFLECTR */ #define RCANFD_GAFLECTR (0x0098) /* RSCFDnCFDGAFLCFG / RSCFDnGAFLCFG */ -#define RCANFD_GAFLCFG(ch) (0x009c + (0x04 * ((ch) / 2))) +#define RCANFD_GAFLCFG(w) (0x009c + (0x04 * (w))) /* RSCFDnCFDRMNB / RSCFDnRMNB */ #define RCANFD_RMNB (0x00a4) /* RSCFDnCFDRMND / RSCFDnRMND */ @@ -677,8 +677,9 @@ static void rcar_canfd_setrnc(struct rcar_canfd_global *gpriv, unsigned int ch, { unsigned int shift = reg_gen4(gpriv, 16, 24) - (ch & 1) * reg_gen4(gpriv, 16, 8); u32 rnc = num_rules << shift; + unsigned int w = ch / 2; - rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLCFG(ch), rnc); + rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLCFG(w), rnc); } static void rcar_canfd_set_mode(struct rcar_canfd_global *gpriv) From patchwork Wed Apr 2 10:22:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035766 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77C35235BE8; Wed, 2 Apr 2025 10:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589391; cv=none; b=UGY6x/1DCOWgd9Ymv9DRIyyzlwEaTFLd4WLWeckocxKLcGsynv++btLWTzh8wtokSCR+38s/pf8l0BcTRwYmSh6gzWvwcMufdBqxyNw1U8DFZH1qWHGsByWmyR32LM33isN3UflxTEgqk7amuym8htEz9or2tIXUz/KmMRbC8VQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589391; c=relaxed/simple; bh=jtKsdUUKlIcdKd2BpXwIhgD6VAFFUTq0Rrd+HKolDM4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KZilqi9CumvVrxRJCbjd2bpoIknLAU1ITXPR8RdrUzGMwhJTuUTSDdKfB8SgVicOMfkN23blUHfHCFqVpphlBkeNtTsyEhhUhusrE1RNEKpmtH7z2Co8E033g6Tq0OZWOHqx8FJq51AJDSIivFmHBB6i3s/BoaDnueONbesfLRs= 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.172 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: CY9UB0rwTu28wRfGrB4XfA== X-CSE-MsgGUID: 6binXyi5QPGMbY+vsjnOjg== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:08 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 955C64222E70; Wed, 2 Apr 2025 19:23:05 +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:22:01 +0100 Message-ID: <20250402102226.28032-10-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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); } From patchwork Wed Apr 2 10:22:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035767 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2720D235BE8; Wed, 2 Apr 2025 10:23:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589393; cv=none; b=u5VSxGsBvbEZ9xN88Vy1QpaFqrd3fN3Dnr7l9Wct2Fe7Dkbax/ncNhdjNZ7UJdA1eIVMdfQhxdLnx+VaMOSIZRIAPVN8cbSqbp+7GOk77SOT6lT/0WpSHvA1OEZTFXAu+/fri9D35orbXNunbfq7KfnqEVXcq/TdA8ekX0q9fH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589393; c=relaxed/simple; bh=cf4kiArMQCApr4Cyso0vLIzfhTH1oSuq69f+roQcTAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cqBYAihpES19WN6Bl2j0E6CzEqAAtIv6SA351Q2Lyt9kTuq9gSqrhLkrKsxw5/QTj9mxpFCaJxny45J4DF+NpPs61oqJy5aou2Ked2PA7c6eko7LSlY68v+lekyLarmltXR5ywXqsBq0ughgUYZtZ+r4cs2Zs9hMdLfUwYyjlig= 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.172 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: Xc2VTveXR0eIXe+u38ak1Q== X-CSE-MsgGUID: cnAqgh+0T5a56KBjnLrVFQ== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:11 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 056914224201; Wed, 2 Apr 2025 19:23:08 +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 10/19] can: rcar_canfd: Add max_aflpn variable to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:22:02 +0100 Message-ID: <20250402102226.28032-11-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Gen3 has maximum acceptance filter list page number of 31 whereas on R-Car Gen4 it is 127. Add max_aflpn variable to struct rcar_canfd_hw_info in order to support RZ/G3E that has max AFLPN of 63. While at it, rename the parameter x->page_num in RCANFD_GAFLECTR_AFLPN macro to make it clear. Reviewed-by: Geert Uytterhoeven Reviewed-by: Vincent Mailhol Signed-off-by: Biju Das --- v7->v8: * Renamed the parameter x->page_num in RCANFD_GAFLECTR_AFLPN macro to make it clear. * Collected tag. v6->v7: * Collected tag. v6: * 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 ee4d24646b2d..16fbe4be6782 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -91,7 +91,7 @@ /* RSCFDnCFDGAFLECTR / RSCFDnGAFLECTR */ #define RCANFD_GAFLECTR_AFLDAE BIT(8) -#define RCANFD_GAFLECTR_AFLPN(gpriv, x) ((x) & reg_gen4(gpriv, 0x7f, 0x1f)) +#define RCANFD_GAFLECTR_AFLPN(gpriv, page_num) ((page_num) & (gpriv)->info->max_aflpn) /* RSCFDnCFDGAFLIDj / RSCFDnGAFLIDj */ #define RCANFD_GAFLID_GAFLLB BIT(29) @@ -503,6 +503,7 @@ struct rcar_canfd_global; struct rcar_canfd_hw_info { u8 rnc_field_width; + u8 max_aflpn; u8 max_channels; u8 postdiv; /* hardware features */ @@ -580,6 +581,7 @@ 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_aflpn = 31, .max_channels = 2, .postdiv = 2, .shared_global_irqs = 1, @@ -587,6 +589,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .rnc_field_width = 16, + .max_aflpn = 127, .max_channels = 8, .postdiv = 2, .shared_global_irqs = 1, @@ -594,6 +597,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { static const struct rcar_canfd_hw_info rzg2l_hw_info = { .rnc_field_width = 8, + .max_aflpn = 31, .max_channels = 2, .postdiv = 1, .multi_channel_irqs = 1, From patchwork Wed Apr 2 10:22:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035768 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 8ED2F53BE; Wed, 2 Apr 2025 10:23:16 +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=1743589398; cv=none; b=XKoySl/lkCDN0ezInplGOxLmSEKcpc6x9bhsaajRxZdi7Z1p8LzA0bT/Guvq7Fc5cUKXH1OCobIMUbonDRhD6iJoOZdSa3E8TL5L2vWSGOzEWhbKdXbDyoBl+jeMbNeKxjAhYYeZ9F8NLVAgRwQH5TZtQxYAKL/oMQdaxiyyYmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589398; c=relaxed/simple; bh=p6DtY5MTZkDcvhqyxDKHFC5yXF2yHt4uN9GBknrU2x8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iGTrAXyiY+xvK9SRBaVYm+wENHwc6/z1gxzXVR7KstaiO8aJfmskD6uKl8Td17PklBdUXNGiGuOof210WCLp3yCuolib1IOGPgIyQOjdin7l9TNube+Eyj3Gvyo8rmTu37RTBNiArmxZj4PRTcVC+mAnH29nzROGUPcwjzN+ISs= 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: rPGawsxdSf+SxBPtzqVOTQ== X-CSE-MsgGUID: WpVqteABT5SVEGDE2VkEjg== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:15 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 707FF4224218; Wed, 2 Apr 2025 19:23:12 +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 11/19] can: rcar_canfd: Add max_cftml variable to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:22:03 +0100 Message-ID: <20250402102226.28032-12-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Gen3 has CFTML max positional value is 15 whereas on R-Car Gen4 it is 31. Add a max_cftml variable to struct rcar_canfd_hw_info to handle this difference. While at it, rename the parameter x->cftml in RCANFD_CFCC_CFTML macro to make it clear. Reviewed-by: Geert Uytterhoeven Reviewed-by: Vincent Mailhol Signed-off-by: Biju Das --- v7->v8: * Renamed the parameter x->cftml in RCANFD_CFCC_CFTML macro to make it clear. * Collected tag. v6->v7: * Collected tag. v6: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 16fbe4be6782..569ee5925b55 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -224,8 +224,11 @@ /* Common FIFO bits */ /* RSCFDnCFDCFCCk */ -#define RCANFD_CFCC_CFTML(gpriv, x) \ - (((x) & reg_gen4(gpriv, 0x1f, 0xf)) << reg_gen4(gpriv, 16, 20)) +#define RCANFD_CFCC_CFTML(gpriv, cftml) \ +({\ + typeof(gpriv) (_gpriv) = (gpriv); \ + (((cftml) & (_gpriv)->info->max_cftml) << reg_gen4(_gpriv, 16, 20)); \ +}) #define RCANFD_CFCC_CFM(gpriv, x) (((x) & 0x3) << reg_gen4(gpriv, 8, 16)) #define RCANFD_CFCC_CFIM BIT(12) #define RCANFD_CFCC_CFDC(gpriv, x) (((x) & 0x7) << reg_gen4(gpriv, 21, 8)) @@ -504,6 +507,7 @@ struct rcar_canfd_global; struct rcar_canfd_hw_info { u8 rnc_field_width; u8 max_aflpn; + u8 max_cftml; u8 max_channels; u8 postdiv; /* hardware features */ @@ -582,6 +586,7 @@ 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_aflpn = 31, + .max_cftml = 15, .max_channels = 2, .postdiv = 2, .shared_global_irqs = 1, @@ -590,6 +595,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .rnc_field_width = 16, .max_aflpn = 127, + .max_cftml = 31, .max_channels = 8, .postdiv = 2, .shared_global_irqs = 1, @@ -598,6 +604,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { static const struct rcar_canfd_hw_info rzg2l_hw_info = { .rnc_field_width = 8, .max_aflpn = 31, + .max_cftml = 15, .max_channels = 2, .postdiv = 1, .multi_channel_irqs = 1, From patchwork Wed Apr 2 10:22:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035769 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0232753BE; Wed, 2 Apr 2025 10:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589400; cv=none; b=ugkHOGdAEyHeIM2YtCeioafUk25wdzCN2jx3vc9lmkEtElV/haBmy89OcBTbLiilSCEGsV/kE0m7SDL9lPo2kc1whgfzPQNgDorYzYMsYKj4fWlXs7TVQEcPoeLx7aCLWmydCOuvnjqE5Jzf+Kj4qXQM470YiH8LIJ7xPJwCf6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589400; c=relaxed/simple; bh=/BTEzCRMsUsE1DaQKGHr3o1zxvul3eWYD3Y/LKWc/00=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xl5YOlyMU87HyimP71gDV/az1rQ+EBzWA5NQQEH1PJ9gikTKyOjCb1vDFoKaJc829we/oL3zkVFmMj0L8b7uJhp7xQTg2Lx6obzg2rRMJVDfQyV+MvjCIPT0xSjayZMSs+I9OiYCrF1Kf+3o+V7GBRKSv92Q1Kohciyi59etEIU= 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.172 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: xakrF7kQS1e9sEsFdUIYLg== X-CSE-MsgGUID: xBLgSmwZRNyj2uxPqF3SPg== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:18 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id DA52D4224218; Wed, 2 Apr 2025 19:23:15 +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 12/19] can: rcar_canfd: Add {nom,data}_bittiming variables to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:22:04 +0100 Message-ID: <20250402102226.28032-13-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Both R-Car Gen4 and R-Car Gen3 have different bit timing parameters Add {nom,data}_bittiming variables to struct rcar_canfd_hw_info to handle this difference. Since the mask used in the macros are max value - 1, replace that as well. Reviewed-by: Geert Uytterhoeven Reviewed-by: Vincent Mailhol Signed-off-by: Biju Das --- v7->v8: * Collected tag. v6->v7: * Collected tag. * Updated 'aswell'->'as well' in commit description. v6: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 53 ++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 569ee5925b55..54f5b8842cb2 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -109,13 +109,13 @@ /* RSCFDnCFDCmNCFG - CAN FD only */ #define RCANFD_NCFG_NTSEG2(gpriv, x) \ - (((x) & reg_gen4(gpriv, 0x7f, 0x1f)) << reg_gen4(gpriv, 25, 24)) + (((x) & ((gpriv)->info->nom_bittiming->tseg2_max - 1)) << reg_gen4(gpriv, 25, 24)) #define RCANFD_NCFG_NTSEG1(gpriv, x) \ - (((x) & reg_gen4(gpriv, 0xff, 0x7f)) << reg_gen4(gpriv, 17, 16)) + (((x) & ((gpriv)->info->nom_bittiming->tseg1_max - 1)) << reg_gen4(gpriv, 17, 16)) #define RCANFD_NCFG_NSJW(gpriv, x) \ - (((x) & reg_gen4(gpriv, 0x7f, 0x1f)) << reg_gen4(gpriv, 10, 11)) + (((x) & ((gpriv)->info->nom_bittiming->sjw_max - 1)) << reg_gen4(gpriv, 10, 11)) #define RCANFD_NCFG_NBRP(x) (((x) & 0x3ff) << 0) @@ -177,13 +177,13 @@ #define RCANFD_CERFL_ERR(x) ((x) & (0x7fff)) /* above bits 14:0 */ /* RSCFDnCFDCmDCFG */ -#define RCANFD_DCFG_DSJW(gpriv, x) (((x) & reg_gen4(gpriv, 0xf, 0x7)) << 24) +#define RCANFD_DCFG_DSJW(gpriv, x) (((x) & ((gpriv)->info->data_bittiming->sjw_max - 1)) << 24) #define RCANFD_DCFG_DTSEG2(gpriv, x) \ - (((x) & reg_gen4(gpriv, 0x0f, 0x7)) << reg_gen4(gpriv, 16, 20)) + (((x) & ((gpriv)->info->data_bittiming->tseg2_max - 1)) << reg_gen4(gpriv, 16, 20)) #define RCANFD_DCFG_DTSEG1(gpriv, x) \ - (((x) & reg_gen4(gpriv, 0x1f, 0xf)) << reg_gen4(gpriv, 8, 16)) + (((x) & ((gpriv)->info->data_bittiming->tseg1_max - 1)) << reg_gen4(gpriv, 8, 16)) #define RCANFD_DCFG_DBRP(x) (((x) & 0xff) << 0) @@ -505,6 +505,8 @@ struct rcar_canfd_global; struct rcar_canfd_hw_info { + const struct can_bittiming_const *nom_bittiming; + const struct can_bittiming_const *data_bittiming; u8 rnc_field_width; u8 max_aflpn; u8 max_cftml; @@ -545,7 +547,7 @@ struct rcar_canfd_global { }; /* CAN FD mode nominal rate constants */ -static const struct can_bittiming_const rcar_canfd_nom_bittiming_const = { +static const struct can_bittiming_const rcar_canfd_gen3_nom_bittiming_const = { .name = RCANFD_DRV_NAME, .tseg1_min = 2, .tseg1_max = 128, @@ -557,8 +559,20 @@ static const struct can_bittiming_const rcar_canfd_nom_bittiming_const = { .brp_inc = 1, }; +static const struct can_bittiming_const rcar_canfd_gen4_nom_bittiming_const = { + .name = RCANFD_DRV_NAME, + .tseg1_min = 2, + .tseg1_max = 256, + .tseg2_min = 2, + .tseg2_max = 128, + .sjw_max = 128, + .brp_min = 1, + .brp_max = 1024, + .brp_inc = 1, +}; + /* CAN FD mode data rate constants */ -static const struct can_bittiming_const rcar_canfd_data_bittiming_const = { +static const struct can_bittiming_const rcar_canfd_gen3_data_bittiming_const = { .name = RCANFD_DRV_NAME, .tseg1_min = 2, .tseg1_max = 16, @@ -570,6 +584,18 @@ static const struct can_bittiming_const rcar_canfd_data_bittiming_const = { .brp_inc = 1, }; +static const struct can_bittiming_const rcar_canfd_gen4_data_bittiming_const = { + .name = RCANFD_DRV_NAME, + .tseg1_min = 2, + .tseg1_max = 32, + .tseg2_min = 2, + .tseg2_max = 16, + .sjw_max = 16, + .brp_min = 1, + .brp_max = 256, + .brp_inc = 1, +}; + /* Classical CAN mode bitrate constants */ static const struct can_bittiming_const rcar_canfd_bittiming_const = { .name = RCANFD_DRV_NAME, @@ -584,6 +610,8 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = { }; static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { + .nom_bittiming = &rcar_canfd_gen3_nom_bittiming_const, + .data_bittiming = &rcar_canfd_gen3_data_bittiming_const, .rnc_field_width = 8, .max_aflpn = 31, .max_cftml = 15, @@ -593,6 +621,8 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { }; static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { + .nom_bittiming = &rcar_canfd_gen4_nom_bittiming_const, + .data_bittiming = &rcar_canfd_gen4_data_bittiming_const, .rnc_field_width = 16, .max_aflpn = 127, .max_cftml = 31, @@ -602,6 +632,8 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { }; static const struct rcar_canfd_hw_info rzg2l_hw_info = { + .nom_bittiming = &rcar_canfd_gen3_nom_bittiming_const, + .data_bittiming = &rcar_canfd_gen3_data_bittiming_const, .rnc_field_width = 8, .max_aflpn = 31, .max_cftml = 15, @@ -1798,9 +1830,8 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch, } if (gpriv->fdmode) { - priv->can.bittiming_const = &rcar_canfd_nom_bittiming_const; - priv->can.data_bittiming_const = - &rcar_canfd_data_bittiming_const; + priv->can.bittiming_const = gpriv->info->nom_bittiming; + priv->can.data_bittiming_const = gpriv->info->data_bittiming; /* Controller starts in CAN FD only mode */ err = can_set_static_ctrlmode(ndev, CAN_CTRLMODE_FD); From patchwork Wed Apr 2 10:22:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035770 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7998D53BE; Wed, 2 Apr 2025 10:23:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589404; cv=none; b=fIj+zIV5+uObgKVu05bxoT9tc6u4TTZT4lf1mLnE32E4/0FWh1+t1puwojT9Hgn1dDt6eYa7bifWFgfZXNFwgsXiUQeSl1AtBW78JFc2U0BXHEl2llJjVdKnOY33xtLyCBho7nOJfRbw3V1yN2Mp0V+duloyu0kbHJtjEc5MtLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589404; c=relaxed/simple; bh=xM3YsvI4jkB659bhyGDR1H/gzwGdJrH7mW09Jm/6i+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EQpUTHxMlnymVRyHa1d/Sa92JV55ieCbUT1afPKzm62CdrsdhYzS4qvngRGgbY7SlcrgWekSM+hpeiBo0w0fbpQ5Qxjd2cbvG8JVf98ihmWjEuKnFyFTzc6AW0HfHDNoIP0kIfetkq9dMxb+VS10xOiZU5rsMPyhE1nXcywzM5M= 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.172 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: IxHSEnc8SeCKh+/fFfs70g== X-CSE-MsgGUID: qUxn7gBxQ3my6v+XFAV4bA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:22 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 5EB374224218; Wed, 2 Apr 2025 19:23:19 +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 13/19] can: rcar_canfd: Add ch_interface_mode variable to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:22:05 +0100 Message-ID: <20250402102226.28032-14-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 channel specific interface mode bit for setting CAN-FD or Classical CAN mode whereas on R-Car Gen3 it is global. Add a ch_interface_mode variable to struct rcar_canfd_hw_info to handle this difference. Reviewed-by: Geert Uytterhoeven Reviewed-by: Vincent Mailhol Signed-off-by: Biju Das --- v7->v8: * Updated {rzg2l,car_gen3_hw_info} with ch_interface_mode = 0. * Collected tag. v6->v7: * No change. v5->v6: * No change. v4->v5: * Collected tag. v3->v4: * No change. v3: * 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 54f5b8842cb2..bcdf6e4aafc4 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -515,6 +515,7 @@ struct rcar_canfd_hw_info { /* hardware features */ 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 */ }; /* Channel priv data */ @@ -618,6 +619,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { .max_channels = 2, .postdiv = 2, .shared_global_irqs = 1, + .ch_interface_mode = 0, }; static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { @@ -629,6 +631,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .max_channels = 8, .postdiv = 2, .shared_global_irqs = 1, + .ch_interface_mode = 1, }; static const struct rcar_canfd_hw_info rzg2l_hw_info = { @@ -640,6 +643,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = { .max_channels = 2, .postdiv = 1, .multi_channel_irqs = 1, + .ch_interface_mode = 0, }; /* Helper functions */ @@ -732,7 +736,7 @@ static void rcar_canfd_setrnc(struct rcar_canfd_global *gpriv, unsigned int ch, static void rcar_canfd_set_mode(struct rcar_canfd_global *gpriv) { - if (is_gen4(gpriv)) { + if (gpriv->info->ch_interface_mode) { u32 ch, val = gpriv->fdmode ? RCANFD_GEN4_FDCFG_FDOE : RCANFD_GEN4_FDCFG_CLOE; From patchwork Wed Apr 2 10:22:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035771 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF52523496B; Wed, 2 Apr 2025 10:23:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589408; cv=none; b=HACs9PiBJ4+6FtuqIX7AT0hzZsFsBtxlxr5hN7U/U1aRr5PhINlR0YBnX8idVUAvb7V9iKI8uCcYo7iacoq9bbQ4NYPdnC0yx/mPDiIQltmdhCGVPUReZJ1+BmolWRxYOSDr4hCax3quC3vuOOAZ6K8PYvM1c+tqS5/tUyVU82g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589408; c=relaxed/simple; bh=gST2ejQk2F0tWWHX4eQpcrDaICjzCTIwJNNiYH+d2T0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qLzwNdyuQzZDvw4esqK9AMUQH51JZdyj/pbyQW5vxI9artIzuVHMYvB19+Mgra4FcqeJKxFiSJs6t8DtpjN/Z00LK7a0+NIOLunamAPWriOJV/6d83+Am2becJoNaVJN5esbCHLUgS7funRX2U/Ti8ht+FSgk7l8hVQGR3DxvQQ= 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.172 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: inXeJ8UWQ8iRK73ZsyriHQ== X-CSE-MsgGUID: MaI/B+kPSbyIVGHXme+GMA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:25 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id C1BAE4224201; Wed, 2 Apr 2025 19:23:22 +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 14/19] can: rcar_canfd: Add shared_can_regs variable to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:22:06 +0100 Message-ID: <20250402102226.28032-15-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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. Reviewed-by: Geert Uytterhoeven Reviewed-by: Vincent Mailhol Signed-off-by: Biju Das --- v7->v8: * Updated {rzg2l,rcar_gen3}_hw_info with shared_can_regs = 0. * Collected tag. v6->v7: * No change. v5->v6: * No change. v4->v5: * Collected tag. * Replaced the variable name shared_can_reg->shared_can_regs. v3->v4: * No change. v3: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index bcdf6e4aafc4..6f398fd7ad5c 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -516,6 +516,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_regs:1; /* Has shared classical can registers */ }; /* Channel priv data */ @@ -620,6 +621,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { .postdiv = 2, .shared_global_irqs = 1, .ch_interface_mode = 0, + .shared_can_regs = 0, }; static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { @@ -632,6 +634,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .postdiv = 2, .shared_global_irqs = 1, .ch_interface_mode = 1, + .shared_can_regs = 1, }; static const struct rcar_canfd_hw_info rzg2l_hw_info = { @@ -644,6 +647,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = { .postdiv = 1, .multi_channel_irqs = 1, .ch_interface_mode = 0, + .shared_can_regs = 0, }; /* Helper functions */ @@ -854,7 +858,7 @@ static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv, /* Write number of rules for channel */ rcar_canfd_setrnc(gpriv, ch, num_rules); - if (is_gen4(gpriv)) + if (gpriv->info->shared_can_regs) offset = RCANFD_GEN4_GAFL_OFFSET; else if (gpriv->fdmode) offset = RCANFD_F_GAFL_OFFSET; @@ -1390,7 +1394,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_regs) { cfg = (RCANFD_NCFG_NTSEG1(gpriv, tseg1) | RCANFD_NCFG_NBRP(brp) | RCANFD_NCFG_NSJW(gpriv, sjw) | @@ -1555,7 +1559,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_regs) { rcar_canfd_write(priv->base, RCANFD_F_CFID(gpriv, ch, RCANFD_CFFIFO_IDX), id); rcar_canfd_write(priv->base, @@ -1614,7 +1618,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_regs) { id = rcar_canfd_read(priv->base, RCANFD_F_RFID(gpriv, ridx)); dlc = rcar_canfd_read(priv->base, RCANFD_F_RFPTR(gpriv, ridx)); @@ -1665,7 +1669,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_regs) rcar_canfd_get_data(priv, cf, RCANFD_F_RFDF(gpriv, ridx, 0)); else rcar_canfd_get_data(priv, cf, RCANFD_C_RFDF(ridx, 0)); From patchwork Wed Apr 2 10:22:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035772 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 18CB4236A6D; Wed, 2 Apr 2025 10:23:29 +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=1743589411; cv=none; b=kg8dCViiTiwgCAHIJMwszFWfnsth0TjjgV0C2LeOktloxYQbWksx/yT3GSq3co5CqMHsc0EMfXvgyl7iuvkudu5YsKaD7YonvRpxDoIZQq4NKYktu+tlkBStiauWSmFP0PFqjI/0jJ/ILCwMQ0s94MWUWUy0gUVrPZNOwTUAFA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589411; c=relaxed/simple; bh=RGAMyxirMppsOLp3mGnKvSdVS9ti9NCTGCeqHJZ2JFM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FOjbUQdtnwQAnMVZS/aGWJziPxTtoAyUhfqBWDOByl2oiaL6afw2ovX4mC/4uixlUylBY6KnwsF4GeKVy8L1Y/iZBvaDfS/v/kEg27LD6WB3SE4PgC4MsOSx8fY0FrY84b6wXM9Q1afCL8dR+SHjgjgmq9jI9t0RXAfVJYbXSNQ= 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: 5Y6L3VkoQ0ShJAuLZMCgkg== X-CSE-MsgGUID: adUmQjRYSk+4nMtS03HYOA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:29 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 452524222E70; Wed, 2 Apr 2025 19:23:26 +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 15/19] can: rcar_canfd: Add struct rcanfd_regs variable to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:22:07 +0100 Message-ID: <20250402102226.28032-16-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Gen3 and Gen4 have some differences in the register offsets. Add a struct rcanfd_regs variable regs to struct rcar_canfd_hw_info handle these differences. Signed-off-by: Biju Das --- v7->v8: * Started using struct rcanfd_regs instead of LUT. * Updated commit description. * Dropped tag v6->v7: * No change. v5->v6: * No change. v4->v5: * Improved commit description by replacing has->have. * Collected tag. v3->v4: * Added prefix RCANFD_* to enum rcar_canfd_reg_offset_id. v3: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 48 ++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 6f398fd7ad5c..c550bf89ae61 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -299,7 +299,7 @@ #define RCANFD_RMND(y) (0x00a8 + (0x04 * (y))) /* RSCFDnCFDRFCCx / RSCFDnRFCCx */ -#define RCANFD_RFCC(gpriv, x) (reg_gen4(gpriv, 0x00c0, 0x00b8) + (0x04 * (x))) +#define RCANFD_RFCC(gpriv, x) ((gpriv)->info->regs->rfcc + (0x04 * (x))) /* RSCFDnCFDRFSTSx / RSCFDnRFSTSx */ #define RCANFD_RFSTS(gpriv, x) (RCANFD_RFCC(gpriv, x) + 0x20) /* RSCFDnCFDRFPCTRx / RSCFDnRFPCTRx */ @@ -309,13 +309,13 @@ /* RSCFDnCFDCFCCx / RSCFDnCFCCx */ #define RCANFD_CFCC(gpriv, ch, idx) \ - (reg_gen4(gpriv, 0x0120, 0x0118) + (0x0c * (ch)) + (0x04 * (idx))) + ((gpriv)->info->regs->cfcc + (0x0c * (ch)) + (0x04 * (idx))) /* RSCFDnCFDCFSTSx / RSCFDnCFSTSx */ #define RCANFD_CFSTS(gpriv, ch, idx) \ - (reg_gen4(gpriv, 0x01e0, 0x0178) + (0x0c * (ch)) + (0x04 * (idx))) + ((gpriv)->info->regs->cfsts + (0x0c * (ch)) + (0x04 * (idx))) /* RSCFDnCFDCFPCTRx / RSCFDnCFPCTRx */ #define RCANFD_CFPCTR(gpriv, ch, idx) \ - (reg_gen4(gpriv, 0x0240, 0x01d8) + (0x0c * (ch)) + (0x04 * (idx))) + ((gpriv)->info->regs->cfpctr + (0x0c * (ch)) + (0x04 * (idx))) /* RSCFDnCFDFESTS / RSCFDnFESTS */ #define RCANFD_FESTS (0x0238) @@ -431,7 +431,7 @@ /* CAN FD mode specific register map */ /* RSCFDnCFDCmXXX -> RCANFD_F_XXX(m) */ -#define RCANFD_F_DCFG(gpriv, m) (reg_gen4(gpriv, 0x1400, 0x0500) + (0x20 * (m))) +#define RCANFD_F_DCFG(gpriv, m) ((gpriv)->info->regs->f_dcfg + (0x20 * (m))) #define RCANFD_F_CFDCFG(m) (0x0504 + (0x20 * (m))) #define RCANFD_F_CFDCTR(m) (0x0508 + (0x20 * (m))) #define RCANFD_F_CFDSTS(m) (0x050c + (0x20 * (m))) @@ -447,7 +447,7 @@ #define RCANFD_F_RMDF(q, b) (0x200c + (0x04 * (b)) + (0x20 * (q))) /* RSCFDnCFDRFXXx -> RCANFD_F_RFXX(x) */ -#define RCANFD_F_RFOFFSET(gpriv) reg_gen4(gpriv, 0x6000, 0x3000) +#define RCANFD_F_RFOFFSET(gpriv) ((gpriv)->info->regs->rfoffset) #define RCANFD_F_RFID(gpriv, x) (RCANFD_F_RFOFFSET(gpriv) + (0x80 * (x))) #define RCANFD_F_RFPTR(gpriv, x) (RCANFD_F_RFOFFSET(gpriv) + 0x04 + (0x80 * (x))) #define RCANFD_F_RFFDSTS(gpriv, x) (RCANFD_F_RFOFFSET(gpriv) + 0x08 + (0x80 * (x))) @@ -455,7 +455,7 @@ (RCANFD_F_RFOFFSET(gpriv) + 0x0c + (0x80 * (x)) + (0x04 * (df))) /* RSCFDnCFDCFXXk -> RCANFD_F_CFXX(ch, k) */ -#define RCANFD_F_CFOFFSET(gpriv) reg_gen4(gpriv, 0x6400, 0x3400) +#define RCANFD_F_CFOFFSET(gpriv) ((gpriv)->info->regs->cfoffset) #define RCANFD_F_CFID(gpriv, ch, idx) \ (RCANFD_F_CFOFFSET(gpriv) + (0x180 * (ch)) + (0x80 * (idx))) @@ -504,9 +504,20 @@ struct rcar_canfd_global; +struct rcar_canfd_regs { + u16 rfcc; /* RX FIFO Configuration/Control Register */ + u16 cfcc; /* Common FIFO Configuration/Control Register */ + u16 cfsts; /* Common FIFO Status Register */ + u16 cfpctr; /* Common FIFO Pointer Control Register */ + u16 f_dcfg; /* Global FD Configuration Register */ + u16 rfoffset; /* Receive FIFO buffer access ID register */ + u16 cfoffset; /* Transmit/receive FIFO buffer access ID register */ +}; + struct rcar_canfd_hw_info { const struct can_bittiming_const *nom_bittiming; const struct can_bittiming_const *data_bittiming; + const struct rcar_canfd_regs *regs; u8 rnc_field_width; u8 max_aflpn; u8 max_cftml; @@ -611,9 +622,30 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = { .brp_inc = 1, }; +static const struct rcar_canfd_regs rcar_gen3_regs = { + .rfcc = 0x00b8, + .cfcc = 0x0118, + .cfsts = 0x0178, + .cfpctr = 0x01d8, + .f_dcfg = 0x0500, + .rfoffset = 0x3000, + .cfoffset = 0x3400, +}; + +static const struct rcar_canfd_regs rcar_gen4_regs = { + .rfcc = 0x00c0, + .cfcc = 0x0120, + .cfsts = 0x01e0, + .cfpctr = 0x0240, + .f_dcfg = 0x1400, + .rfoffset = 0x6000, + .cfoffset = 0x6400, +}; + static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { .nom_bittiming = &rcar_canfd_gen3_nom_bittiming_const, .data_bittiming = &rcar_canfd_gen3_data_bittiming_const, + .regs = &rcar_gen3_regs, .rnc_field_width = 8, .max_aflpn = 31, .max_cftml = 15, @@ -627,6 +659,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .nom_bittiming = &rcar_canfd_gen4_nom_bittiming_const, .data_bittiming = &rcar_canfd_gen4_data_bittiming_const, + .regs = &rcar_gen4_regs, .rnc_field_width = 16, .max_aflpn = 127, .max_cftml = 31, @@ -640,6 +673,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { static const struct rcar_canfd_hw_info rzg2l_hw_info = { .nom_bittiming = &rcar_canfd_gen3_nom_bittiming_const, .data_bittiming = &rcar_canfd_gen3_data_bittiming_const, + .regs = &rcar_gen3_regs, .rnc_field_width = 8, .max_aflpn = 31, .max_cftml = 15, From patchwork Wed Apr 2 10:22:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035773 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 CED1B235BF0; Wed, 2 Apr 2025 10:23:32 +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=1743589414; cv=none; b=mewvYCcz1qVdgdrqH1mSD3UUZEyjNZAFMv570AhJYu3VkuzLDJPg6dhiovfqc//TlKbbKaLDguTuCZQ/+AfvLLmKNz1ZAAR0wLQOB/V+FdQ7m81pnyefpBENga+n6EH96c7fWmYNzoZX2lhDdOn1qGC2hdBOP4iOfYBZcv7jkR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589414; c=relaxed/simple; bh=Gm8+yUUJJfZ3gv/LFtroidgxbDwNK8vfS5jtMGeORGA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RAokAJuUvxuhAcZTXkHftc+gHLJktAFYsdkpxBslQjQWmv5FHhQ/Ru0ZKlcC+kj19pjflB95G49TZnnPn2XdTc5SIm5YihkIf7we5OYtai+nLbYNTANF5MzeJEnQj91kPvD/cVUp3FmIcGN0m6lI8QjVx/QGw2HTbIFM4GAiL0g= 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: a1BQQ7YnSFiQ5Li8CS/PEg== X-CSE-MsgGUID: CakMOMbbTeav1hhlKXVYyw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:32 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id B35924224201; Wed, 2 Apr 2025 19:23:29 +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 16/19] can: rcar_canfd: Add sh variable to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:22:08 +0100 Message-ID: <20250402102226.28032-17-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Gen3 and Gen4 have some differences in the shift bits. Introduce a struct rcar_canfd_shift_data to hold these values and add the struct rcar_canfd_shift_data variable sh to struct rcar_canfd_hw_info to handle these differences. After this, drop the unused functions reg_gen4() and is_gen4(). Signed-off-by: Biju Das --- v7->v8: * Updated commit description. * Started using struct rcar_canfd_shift_data instead of LUT. * Dropped the tag. v6->v7: * No change. v5->v6: * No change. v4->v5: * Collected tag. * Dropped RCANFD_FIRST_RNC_SH and RCANFD_SECOND_RNC_SH by using a formula (32 - (n % rnc_per_reg + 1) * rnc_field_width. v3->v4: * Added prefix RCANFD_* to enum rcar_canfd_shift_id. v3: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 64 ++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index c550bf89ae61..5c46bc0e352f 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -109,13 +109,13 @@ /* RSCFDnCFDCmNCFG - CAN FD only */ #define RCANFD_NCFG_NTSEG2(gpriv, x) \ - (((x) & ((gpriv)->info->nom_bittiming->tseg2_max - 1)) << reg_gen4(gpriv, 25, 24)) + (((x) & ((gpriv)->info->nom_bittiming->tseg2_max - 1)) << (gpriv)->info->sh->ntseg2) #define RCANFD_NCFG_NTSEG1(gpriv, x) \ - (((x) & ((gpriv)->info->nom_bittiming->tseg1_max - 1)) << reg_gen4(gpriv, 17, 16)) + (((x) & ((gpriv)->info->nom_bittiming->tseg1_max - 1)) << (gpriv)->info->sh->ntseg1) #define RCANFD_NCFG_NSJW(gpriv, x) \ - (((x) & ((gpriv)->info->nom_bittiming->sjw_max - 1)) << reg_gen4(gpriv, 10, 11)) + (((x) & ((gpriv)->info->nom_bittiming->sjw_max - 1)) << (gpriv)->info->sh->nsjw) #define RCANFD_NCFG_NBRP(x) (((x) & 0x3ff) << 0) @@ -180,10 +180,10 @@ #define RCANFD_DCFG_DSJW(gpriv, x) (((x) & ((gpriv)->info->data_bittiming->sjw_max - 1)) << 24) #define RCANFD_DCFG_DTSEG2(gpriv, x) \ - (((x) & ((gpriv)->info->data_bittiming->tseg2_max - 1)) << reg_gen4(gpriv, 16, 20)) + (((x) & ((gpriv)->info->data_bittiming->tseg2_max - 1)) << (gpriv)->info->sh->dtseg2) #define RCANFD_DCFG_DTSEG1(gpriv, x) \ - (((x) & ((gpriv)->info->data_bittiming->tseg1_max - 1)) << reg_gen4(gpriv, 8, 16)) + (((x) & ((gpriv)->info->data_bittiming->tseg1_max - 1)) << (gpriv)->info->sh->dtseg1) #define RCANFD_DCFG_DBRP(x) (((x) & 0xff) << 0) @@ -227,11 +227,11 @@ #define RCANFD_CFCC_CFTML(gpriv, cftml) \ ({\ typeof(gpriv) (_gpriv) = (gpriv); \ - (((cftml) & (_gpriv)->info->max_cftml) << reg_gen4(_gpriv, 16, 20)); \ + (((cftml) & (_gpriv)->info->max_cftml) << (_gpriv)->info->sh->cftml); \ }) -#define RCANFD_CFCC_CFM(gpriv, x) (((x) & 0x3) << reg_gen4(gpriv, 8, 16)) +#define RCANFD_CFCC_CFM(gpriv, x) (((x) & 0x3) << (gpriv)->info->sh->cfm) #define RCANFD_CFCC_CFIM BIT(12) -#define RCANFD_CFCC_CFDC(gpriv, x) (((x) & 0x7) << reg_gen4(gpriv, 21, 8)) +#define RCANFD_CFCC_CFDC(gpriv, x) (((x) & 0x7) << (gpriv)->info->sh->cfdc) #define RCANFD_CFCC_CFPLS(x) (((x) & 0x7) << 4) #define RCANFD_CFCC_CFTXIE BIT(2) #define RCANFD_CFCC_CFE BIT(0) @@ -514,10 +514,22 @@ struct rcar_canfd_regs { u16 cfoffset; /* Transmit/receive FIFO buffer access ID register */ }; +struct rcar_canfd_shift_data { + u8 ntseg2; /* Nominal Bit Rate Time Segment 2 Control */ + u8 ntseg1; /* Nominal Bit Rate Time Segment 1 Control */ + u8 nsjw; /* Nominal Bit Rate Resynchronization Jump Width Control */ + u8 dtseg2; /* Data Bit Rate Time Segment 2 Control */ + u8 dtseg1; /* Data Bit Rate Time Segment 1 Control */ + u8 cftml; /* Common FIFO TX Message Buffer Link */ + u8 cfm; /* Common FIFO Mode */ + u8 cfdc; /* Common FIFO Depth Configuration */ +}; + struct rcar_canfd_hw_info { const struct can_bittiming_const *nom_bittiming; const struct can_bittiming_const *data_bittiming; const struct rcar_canfd_regs *regs; + const struct rcar_canfd_shift_data *sh; u8 rnc_field_width; u8 max_aflpn; u8 max_cftml; @@ -642,10 +654,33 @@ static const struct rcar_canfd_regs rcar_gen4_regs = { .cfoffset = 0x6400, }; +static const struct rcar_canfd_shift_data rcar_gen3_shift_data = { + .ntseg2 = 24, + .ntseg1 = 16, + .nsjw = 11, + .dtseg2 = 20, + .dtseg1 = 16, + .cftml = 20, + .cfm = 16, + .cfdc = 8, +}; + +static const struct rcar_canfd_shift_data rcar_gen4_shift_data = { + .ntseg2 = 25, + .ntseg1 = 17, + .nsjw = 10, + .dtseg2 = 16, + .dtseg1 = 8, + .cftml = 16, + .cfm = 8, + .cfdc = 21, +}; + static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { .nom_bittiming = &rcar_canfd_gen3_nom_bittiming_const, .data_bittiming = &rcar_canfd_gen3_data_bittiming_const, .regs = &rcar_gen3_regs, + .sh = &rcar_gen3_shift_data, .rnc_field_width = 8, .max_aflpn = 31, .max_cftml = 15, @@ -660,6 +695,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .nom_bittiming = &rcar_canfd_gen4_nom_bittiming_const, .data_bittiming = &rcar_canfd_gen4_data_bittiming_const, .regs = &rcar_gen4_regs, + .sh = &rcar_gen4_shift_data, .rnc_field_width = 16, .max_aflpn = 127, .max_cftml = 31, @@ -674,6 +710,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = { .nom_bittiming = &rcar_canfd_gen3_nom_bittiming_const, .data_bittiming = &rcar_canfd_gen3_data_bittiming_const, .regs = &rcar_gen3_regs, + .sh = &rcar_gen3_shift_data, .rnc_field_width = 8, .max_aflpn = 31, .max_cftml = 15, @@ -685,17 +722,6 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = { }; /* Helper functions */ -static inline bool is_gen4(struct rcar_canfd_global *gpriv) -{ - return gpriv->info == &rcar_gen4_hw_info; -} - -static inline u32 reg_gen4(struct rcar_canfd_global *gpriv, - u32 gen4, u32 not_gen4) -{ - return is_gen4(gpriv) ? gen4 : not_gen4; -} - static inline void rcar_canfd_update(u32 mask, u32 val, u32 __iomem *reg) { u32 data = readl(reg); From patchwork Wed Apr 2 10:22:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035774 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 5108C236458; Wed, 2 Apr 2025 10:23:36 +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=1743589417; cv=none; b=OQ+BB4wXfT2GWgFwAlZR0xCrihuFnRdasYxr+0eY5qkz03dwkbREc5PoYRBZDOPJ++Ejgnqs8hPW6U2raNyQv+VruF+/SiAqsYrGoRQAr+nXBBZz4bgZRyUfEIb9d11dlOjXPonNFHHiwQSop1q/z5NdzA5g0nvvgkznRetiEOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589417; c=relaxed/simple; bh=7fIh0qAmuWaknqgBDZFudnSDW33VQKb/IMN9ZUEM8EQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bjdwt7ybE2QW8s7TpsTMpy8bO1BTCPEljNuYtGdfjz6cEO0pSp0CsVDv8iJA7jj9kx28PKYRY9T6b48V2z2H8hI9Oh38Tpv5wp6aHgc7UlHAITOuMqcaNxtdOG3VzWOcSNJBTq6V35lAXB4592B/DainaWrp+5k+eot6YdaWVyY= 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: tVklE34bS+O9c7IyKS3YKg== X-CSE-MsgGUID: UPiPBUzdSyC349w5xfu3OQ== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:35 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 2547C4224218; Wed, 2 Apr 2025 19:23:32 +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 17/19] can: rcar_canfd: Add external_clk variable to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:22:09 +0100 Message-ID: <20250402102226.28032-18-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 All existing SoCs support an external clock, but RZ/G3E has only internal clocks. Add external_clk variable to struct rcar_canfd_hw_info to handle this difference. Reviewed-by: Geert Uytterhoeven Reviewed-by: Vincent Mailhol Signed-off-by: Biju Das --- v7->v8: * Renamed only_internal_clks->external_clk to avoid negation. * Updated commit description. * Updated rcar_canfd_hw_info tables. * Collected tag. v6->v7: * No change. v5->v6: * No change. v4->v5: * Collected tag. * Improved commit description by "All SoCs supports extenal clock"-> "All existing SoCs support an external clock". v3->v4: * No change. v2->v3: * No change v1->v2: * No change. --- 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 5c46bc0e352f..11dd3730e98c 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -540,6 +540,7 @@ struct rcar_canfd_hw_info { unsigned multi_channel_irqs:1; /* Has multiple channel irqs */ unsigned ch_interface_mode:1; /* Has channel interface mode */ unsigned shared_can_regs:1; /* Has shared classical can registers */ + unsigned external_clk:1; /* Has external clock */ }; /* Channel priv data */ @@ -689,6 +690,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { .shared_global_irqs = 1, .ch_interface_mode = 0, .shared_can_regs = 0, + .external_clk = 1, }; static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { @@ -704,6 +706,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { .shared_global_irqs = 1, .ch_interface_mode = 1, .shared_can_regs = 1, + .external_clk = 1, }; static const struct rcar_canfd_hw_info rzg2l_hw_info = { @@ -719,6 +722,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = { .multi_channel_irqs = 1, .ch_interface_mode = 0, .shared_can_regs = 0, + .external_clk = 1, }; /* Helper functions */ @@ -2047,7 +2051,7 @@ static int rcar_canfd_probe(struct platform_device *pdev) fcan_freq = clk_get_rate(gpriv->can_clk) / info->postdiv; } else { fcan_freq = clk_get_rate(gpriv->can_clk); - gpriv->extclk = true; + gpriv->extclk = gpriv->info->external_clk; } addr = devm_platform_ioremap_resource(pdev, 0); From patchwork Wed Apr 2 10:22:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035775 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49BA9235BF0; Wed, 2 Apr 2025 10:23:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589421; cv=none; b=HhzVN7vYLoXGwMKb2QzFLwIzIEtO+rqq5u/wCMmvgGMRCelDioLkx148WfZIQs7EimMFkuma3a2iIXozfk8Xca5yJUUitENvc8duZmjQ1UUp3hjtKPeXNTuAAqtclNyekhOcHIk78BNoee1TXVsV3QEX0VHqcswN633RX83L0nA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589421; c=relaxed/simple; bh=eYj0DoRiDXafJXbvWxuK/tBh30UjNkeTeCw4glhAA04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TsWj3k9oQoaZ+n3Mne8DJdMGnwVi/BkVDmaL9zPXU/YK5q2XJilwmwXFan7ud7JJf2rdySBdc6pIBuWfrRMxdfzOSFp7AaCuwRElcS23utnL24fK/DkTgNn9wH1G6D8SV1urXCotlcu6HGuE452rz0yVDHKm1lJH199pLwqoH7c= 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.172 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: jaWyMNkrQtWIDsvbdLVnIQ== X-CSE-MsgGUID: pIJaTKyvRyysz0IcoiG9Aw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:39 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 8C06C4224218; Wed, 2 Apr 2025 19:23:36 +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 18/19] can: rcar_canfd: Enhance multi_channel_irqs handling Date: Wed, 2 Apr 2025 11:22:10 +0100 Message-ID: <20250402102226.28032-19-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 Currently multi_channel_irqs has only 2 channels. But RZ/G3E has six channels. Enhance multi_channel_irqs handling to support more than two channels. Reviewed-by: Geert Uytterhoeven Reviewed-by: Vincent Mailhol Signed-off-by: Biju Das --- v7->v8: * Replaced 10->sizeof(name) in scnprintf(). * Collected tag. v6->v7: * No change. v5->v6: * No change. v4->v5: * Collected tag. v3->v4: * No change. v2->v3: * No change. v1->v2: * No change. --- drivers/net/can/rcar/rcar_canfd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 11dd3730e98c..2631e88dbf47 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -1856,16 +1856,19 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch, if (info->multi_channel_irqs) { char *irq_name; + char name[10]; int err_irq; int tx_irq; - err_irq = platform_get_irq_byname(pdev, ch == 0 ? "ch0_err" : "ch1_err"); + scnprintf(name, sizeof(name), "ch%u_err", ch); + err_irq = platform_get_irq_byname(pdev, name); if (err_irq < 0) { err = err_irq; goto fail; } - tx_irq = platform_get_irq_byname(pdev, ch == 0 ? "ch0_trx" : "ch1_trx"); + scnprintf(name, sizeof(name), "ch%u_trx", ch); + tx_irq = platform_get_irq_byname(pdev, name); if (tx_irq < 0) { err = tx_irq; goto fail; From patchwork Wed Apr 2 10:22:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035776 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A29B23496B; Wed, 2 Apr 2025 10:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589424; cv=none; b=PFfY4vF4OtbTRhWAOyZqV/S7pGgTxnPa/48l+aI9saz9DAEflRmnQSSrMiUd0FhmkoKcPPqZuLomdZFPpXwaku6NDRe82j/hr2H/PS4lLSLmdeofSlj2dtVPx+qwIBxkw/6mJtTM73MwvjjhuedOFTZvQqM+DPvgU5DHS7No4Sk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589424; c=relaxed/simple; bh=LADb+nIQsZ+ME2W3uyv4Uj12jhNL+wRffWW7Ax95r5w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wn4CzDYvj1sV5uNpedPIt/UEXhUKnm+mx/eAiAygn5EhRR8O7YTzShZJVHNRccrNEhTpVWdgeDSXG8vl65B28xAAQ0WKKssozrWcN5uaDEGQKNobawqXpDBkr5lz1DOHPUPIfNcgbFwfp/AItzUv82kMwFTB/eqOnNppYBDpZSo= 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.172 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: VTQgmjakTza87i2rUbrTgg== X-CSE-MsgGUID: DDG64Ir5T3iRCCf7uYYIFA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:23:42 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 0104F4222E70; Wed, 2 Apr 2025 19:23: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 v8 19/19] can: rcar_canfd: Add RZ/G3E support Date: Wed, 2 Apr 2025 11:22:11 +0100 Message-ID: <20250402102226.28032-20-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102226.28032-1-biju.das.jz@bp.renesas.com> References: <20250402102226.28032-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 CAN-FD IP found on the RZ/G3E SoC is similar to R-Car Gen4, but it has no external clock instead it has clk_ram, it has 6 channels and supports 20 interrupts. Add support for RZ/G3E CAN-FD driver. Reviewed-by: Geert Uytterhoeven Reviewed-by: Vincent Mailhol Signed-off-by: Biju Das --- v7->v8: * Collected tag. v6->v7: * No change. v5->v6: * Collected tag. * Updated r9a09g047_hw_info table. v4->v5: * Updated error description as "cannot get enabled ram clock" * Updated r9a09g047_hw_info table. v3->v4: * No change. v2->v3: * Replaced gen4_type entry with mask_table, shift_table, regs, ch_interface_mode and shared_can_reg. v1->v2: * No change. --- drivers/net/can/rcar/rcar_canfd.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 2631e88dbf47..ecf68461a0e7 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -725,6 +725,22 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = { .external_clk = 1, }; +static const struct rcar_canfd_hw_info r9a09g047_hw_info = { + .nom_bittiming = &rcar_canfd_gen4_nom_bittiming_const, + .data_bittiming = &rcar_canfd_gen4_data_bittiming_const, + .regs = &rcar_gen4_regs, + .sh = &rcar_gen4_shift_data, + .rnc_field_width = 16, + .max_aflpn = 63, + .max_cftml = 31, + .max_channels = 6, + .postdiv = 1, + .multi_channel_irqs = 1, + .ch_interface_mode = 1, + .shared_can_regs = 1, + .external_clk = 0, +}; + /* Helper functions */ static inline void rcar_canfd_update(u32 mask, u32 val, u32 __iomem *reg) { @@ -1968,6 +1984,7 @@ static int rcar_canfd_probe(struct platform_device *pdev) u32 rule_entry = 0; bool fdmode = true; /* CAN FD only mode - default */ char name[9] = "channelX"; + struct clk *clk_ram; int i; info = of_device_get_match_data(dev); @@ -2057,6 +2074,11 @@ static int rcar_canfd_probe(struct platform_device *pdev) gpriv->extclk = gpriv->info->external_clk; } + clk_ram = devm_clk_get_optional_enabled(dev, "ram_clk"); + if (IS_ERR(clk_ram)) + return dev_err_probe(dev, PTR_ERR(clk_ram), + "cannot get enabled ram clock\n"); + addr = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(addr)) { err = PTR_ERR(addr); @@ -2219,6 +2241,7 @@ static SIMPLE_DEV_PM_OPS(rcar_canfd_pm_ops, rcar_canfd_suspend, static const __maybe_unused struct of_device_id rcar_canfd_of_table[] = { { .compatible = "renesas,r8a779a0-canfd", .data = &rcar_gen4_hw_info }, + { .compatible = "renesas,r9a09g047-canfd", .data = &r9a09g047_hw_info }, { .compatible = "renesas,rcar-gen3-canfd", .data = &rcar_gen3_hw_info }, { .compatible = "renesas,rcar-gen4-canfd", .data = &rcar_gen4_hw_info }, { .compatible = "renesas,rzg2l-canfd", .data = &rzg2l_hw_info },