From patchwork Wed Apr 2 10:20:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035739 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 97B5F23496B; Wed, 2 Apr 2025 10:21: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=1743589265; cv=none; b=oc+5PyMDd0+hcZvqVK6gAVjePAjYJefVEFJZwuCtzBpNkx1zgb94+E2WZWTy7SjtGQ0ogVtufRbgoKcYkVzs4tZkVGoU9dNSkjXou6hcq8Cg/o3wy3dtMrImfOh80U41BwqtuoEVmCXcPAQXtgQp7JjHLm63xPrx/+9wKdGcH6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589265; c=relaxed/simple; bh=5wtNBVVkxEfypneA46AZuGKvxc8VE8UUQN+plr+f0gI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U1H33x0j0OGwz6PSWWd62w4jm02ZUOiOIp0+rgJG3fXvnPGTEk92fd4nuWomIFlEhzwhkurkNQzK2Hivzf4iX95NWqr8dGaiojuo9uEkpbKIr8XgbSTs67m6GtAlPI2bjuiId4SYSNLl4+vI4pTEUNvrXwp5fzUnpMGL3mIN+Cc= 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: 5T6+DECLSEi/aPcVlDJMCA== X-CSE-MsgGUID: 2ne81RzrRGG3Px1JluBHzQ== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:01 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 84665401C75A; Wed, 2 Apr 2025 19:20:56 +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:20:21 +0100 Message-ID: <20250402102047.27943-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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:20:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035740 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 8AF5323496B; Wed, 2 Apr 2025 10:21:06 +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=1743589268; cv=none; b=NiGH5iHtEAbPj7mHy1DXjuLg6qb4XyHz6XAYXh+1mXUj+sd38+HUqQXqfNUcGLpBGzz1+Ttf92qUM01nhMP3wYM0VfhiI5NDUkyHvaWHgM/AAuErza1Yy/u/JtoyXexocYc5YsdFQcz3E5hD0C5cUprtvY+6brDiM1Q3t3rBnsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589268; c=relaxed/simple; bh=+K8K9u6y5Z8sCK3//Pf0EXDMz5wTG60LRO9scUYcGGA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IzGgSG/fWREN+cFtaXL5wRLvQ7W4xrO0v2r7plZE+Lw9GvhfsbNSHKfXBejA+NIjg7UkWiQ8WSkbzxjmqikjc2hxCavdtQ0nKU/hxTY7YB9cMXUa4UJu7J0X0bBFVLHl98q/Oe/fr2m9QtLCHfJDH/ywXILwAR21nN6z/Quc+Bo= 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: 4z4MzEAeTHGVps39gEtn+w== X-CSE-MsgGUID: X1QtceOXRvKTCoSjsY4lag== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:06 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id C93C6401C75B; Wed, 2 Apr 2025 19:21:01 +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:20:22 +0100 Message-ID: <20250402102047.27943-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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:20:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035741 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 C147B23496B; Wed, 2 Apr 2025 10:21:11 +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=1743589273; cv=none; b=t5obuM/DBwCyylsBILgSiUFyt1fy1Rvj612NSC8NF7fthHr1kJ4gTmkINvi/xKD1AJpeOW9YiJKR9Xo1TDx2bhmdMNQlTEJ1XgZvwqnpIowu9O6mn27ddRdVWsIFZoyt0bWAMR984uHFZkSwQ0g0bPVl6J/D9qWt7cYkLTfTyew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589273; c=relaxed/simple; bh=UCfydqd9zT+xvD4YM8nH6iXme/emAuct9ppKIZ7ze/Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fBGCMVBYdWHSK3GH95JhiGr5IMTsB0pUfH2zuDPL1159QgGchTRVj+SYAcl9I59xRcG6IUtg93a0t3E8fksOJpTCq2b5wa5U+zJuzw0GBSkuKcdAuIHht+zzxsNLMoByOSNZIBKAVyiaKG9a+xjtmo4IfnS1oDvBF0vJqXyEf8Q= 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: id+UAzvsQoizFgG6E3Vofg== X-CSE-MsgGUID: 18MzQI9VScWq0WJsgkxNww== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:10 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id D1FCE401C759; Wed, 2 Apr 2025 19:21:06 +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:20:23 +0100 Message-ID: <20250402102047.27943-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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:20:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035742 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 E55BD23496B; Wed, 2 Apr 2025 10:21:13 +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=1743589275; cv=none; b=mgvRnqWypJWqBjhD2r4vSXrZ7SSSvJguNj5g1ZyvCSZ94obYUO0aQXyIczA6bl+ekq+AZadkqLDoexeDm6OkVM8+6bUvrP15FBSwGWBvOJjcm+Gy2oMO8Atfq1TlOJd8ZkZ23xEijlmQdxYLWUq11GE8hOrXNgaziCFqXR30fTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589275; c=relaxed/simple; bh=jEH+/LY2v3Y2Gs6bIr6D97+DiiJDQe+aJAPPPZqWSyg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z9z2Pr/M4fG+Iz+Hc5jfmqiHg+dthc9eQZmbAGIn3AIWPhOv1/mzRd6YTe4yt8uJm+5sjbXDmauSYXi1vKB4OZcl3OVvM/JMogwSNlMBjC+9iBr99iN5WvqoHVCwMjJy2jo+5NjBUATLboFzKEVZK61sUm3hVcRyAFJSgbTSQzc= 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: 1nnSnnTHRiS8J01h8Z8V3Q== X-CSE-MsgGUID: 9V54P9dgStesnMQ2nKlr0A== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:13 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id C9B1E401C75A; Wed, 2 Apr 2025 19:21:10 +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:20:24 +0100 Message-ID: <20250402102047.27943-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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:20:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035743 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 62C72235BF0; Wed, 2 Apr 2025 10:21:17 +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=1743589279; cv=none; b=lBjxw2wg43Ic1MVLScMD0vCxW1hZeipWwNkbjHroWeTJtdrlY7bw6ZM/kIUQQ1uClaOUTyM5bOjRiU38U6ZfJ8kaF/BDYU0dlqErosWOd61uxJIt5cz6w7q91WMqEcB6cvar0HoMoAviemDbtJpB7zgR+41LK6G2n4h/raDGSc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589279; c=relaxed/simple; bh=yIBwMbzqJ6zOnHdUv2lIo8hse+8X/W1xeHcs+N9gr2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r2SvUfXYK2lgynWHTh83lhPhJvADDDKO0y10K8zKoV9l46rqGzuX1/htU0bZUKZLqGDOJhnnQVLuDHlYfaQIv/1K/gH1Z5xpGt1X7zVmVwJe7FsJtEMpJGGvI6k7viZqOtZeF//zTZn3EYKFJDIrtxRd9kX7meQeGSzuY/ahEkk= 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: +CjXSPdiSn216oNmOxzo5Q== X-CSE-MsgGUID: vsJUsfnpQlWtz8xeSRclFw== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:17 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 42E68401C759; Wed, 2 Apr 2025 19:21:14 +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:20:25 +0100 Message-ID: <20250402102047.27943-6-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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:20:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035744 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 D2EF123534D; Wed, 2 Apr 2025 10:21:20 +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=1743589282; cv=none; b=oFJpJiGplzZmWftJ88uVqeMItHhp1COln7MgGVs45ZRsYCqPefbsihxdLbPLhifKNV69QHoqbO2LVA49r+WbscN7UuGSHTnjF2I0O+0iKjwnOq1YvcwC4GxOsj8JT/VqDA9i+tOI6wZ+AURikujzLGek8g2TVy7YujvSi+8PwOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589282; c=relaxed/simple; bh=squ4J4KXqQBUlULcmYlzGzCJxkIWghsxDRs1Te4RYrk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kmFqx3QFjcX7N5OvNVm1PuvwN2hgbMl2iZSJRcgvVuVTk8qz3i+/J18B5QrjUeElZpiCVzesQTNeC1eMUerkCWaAMGj9wlY5Tj4JlySGeWzTcxb4nH8x5TIRhxFdMq1uhtDq4cz9HWgGOWeK9DAj5ZEBX//ppFY8vm1xFSLyuAQ= 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: eFAjH13lSZ2nlzUXW4rT2A== X-CSE-MsgGUID: +eaA0/hkQSyN0gdFBjx+jQ== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:20 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id B0624401C759; Wed, 2 Apr 2025 19:21:17 +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:20:26 +0100 Message-ID: <20250402102047.27943-7-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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:20:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035745 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 3B96C23496B; Wed, 2 Apr 2025 10:21:25 +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=1743589287; cv=none; b=d/yezWzeIW6lx7QXN7AofDZ+ab1jSEFlSQSWBK8+3ounBBj3CUz0gGaSEbfdpEuNZk9Kaq5tl+q8vG5cSV7YtFP94IVrBIGQ6ZWFkomRvv29go/Slg4qwiJb6FYouPsfQlhay2uB84x4ipYdqVcVu1PgEqByCZZk/fZwrGugFK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589287; c=relaxed/simple; bh=+UZlOw47u+6+638D99dC1yO5TdFlW+yeBCc0XEkiBdc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZGYD27JSZ0MUQx7gMvGBF01YLrEuctCSSse+wd/1oCt0ONFBYh3+YgHwsNul4CqGoQW+PDP74iG2q1oE/PyJh+S0Nlq8nTB/yeGTw6TRkqlBGyXccosrj4Ph1c9nDbFTnNYx6YoHAThJM36GCse1WFNAdvX4Accl2uHfwLL206c= 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: 2TmkaY3lRaGdTLNrff+XVg== X-CSE-MsgGUID: +EmOoeQSRG2uhwQNC4zIeQ== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:25 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 330C5401C759; Wed, 2 Apr 2025 19:21:21 +0900 (JST) From: Biju Das To: Marc Kleine-Budde , Vincent Mailhol Cc: Biju Das , Wolfram Sang , Geert Uytterhoeven , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , linux-can@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH v8 08/19] can: rcar_canfd: Update RCANFD_GAFLCFG macro Date: Wed, 2 Apr 2025 11:20:28 +0100 Message-ID: <20250402102047.27943-9-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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:20:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035746 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD75223642E; Wed, 2 Apr 2025 10:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589290; cv=none; b=nnJg0xLcFlBCfpY+BpIf4lisYOKMHYCXwmC+l6DQCbcv8d4A6e9iZfVI44gbmNvuh225mkRNTBSoysSZBOzw4ShHZnaUyYFLkQqVKXaEg4re9VfLWGoglDGSK3H+kHXbfNgQFn4hhv1+coERENYwvgrTU+RVcF+dmdG8cXEtc90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589290; c=relaxed/simple; bh=jtKsdUUKlIcdKd2BpXwIhgD6VAFFUTq0Rrd+HKolDM4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L2oiDqYjUlCCtQ1fjsAexe8YD5Q1UXRtSWWR46Hg4/kpVAjtbVAPL4vJsTUbaXPnVziP/koP3BmGynQLtU6+EWXhMkdOHvxd1XaK/Bev4DBRnF1EXEVEv03ZtMdP50EGb7Zp4F44ILt0CTTFlSjKv3BDkqS0G1vhgHP+qVZk53U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-CSE-ConnectionGUID: mrAPeXblT4GlGqVc168Mzg== X-CSE-MsgGUID: taUUyhY0S0qZpwnf1I8JQg== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:28 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id A6542401C759; Wed, 2 Apr 2025 19:21:25 +0900 (JST) From: Biju Das To: Marc Kleine-Budde , Vincent Mailhol Cc: Biju Das , Wolfram Sang , Geert Uytterhoeven , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , linux-can@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH v8 09/19] can: rcar_canfd: Add rnc_field_width variable to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:20:29 +0100 Message-ID: <20250402102047.27943-10-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The shift and w value in rcar_canfd_setrnc() are dictated by the field width: - R-Car Gen4 packs 2 values in a 32-bit word, using a field width of 16 bits, - R-Car Gen3 packs up to 4 values in a 32-bit word, using a field width of 8 bits. Add rnc_field_width variable to struct rcar_canfd_hw_info to handle this difference. The rnc_stride is 32 / rnc_field_width and the index parameter w is calculated by ch / rnc_stride. The shift value in rcar_canfd_setrnc() is computed by using (32 - (ch % rnc_stride + 1) * rnc_field_width). Reviewed-by: Geert Uytterhoeven Signed-off-by: Biju Das --- v7->v8: * Updated commit description. v6->v7: * Collected tag. v6: * New patch. --- drivers/net/can/rcar/rcar_canfd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index b2b87291dcf1..ee4d24646b2d 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -502,6 +502,7 @@ struct rcar_canfd_global; struct rcar_canfd_hw_info { + u8 rnc_field_width; u8 max_channels; u8 postdiv; /* hardware features */ @@ -578,18 +579,21 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = { }; static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { + .rnc_field_width = 8, .max_channels = 2, .postdiv = 2, .shared_global_irqs = 1, }; static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { + .rnc_field_width = 16, .max_channels = 8, .postdiv = 2, .shared_global_irqs = 1, }; static const struct rcar_canfd_hw_info rzg2l_hw_info = { + .rnc_field_width = 8, .max_channels = 2, .postdiv = 1, .multi_channel_irqs = 1, @@ -675,9 +679,10 @@ static void rcar_canfd_tx_failure_cleanup(struct net_device *ndev) static void rcar_canfd_setrnc(struct rcar_canfd_global *gpriv, unsigned int ch, unsigned int num_rules) { - unsigned int shift = reg_gen4(gpriv, 16, 24) - (ch & 1) * reg_gen4(gpriv, 16, 8); + unsigned int rnc_stride = 32 / gpriv->info->rnc_field_width; + unsigned int shift = 32 - (ch % rnc_stride + 1) * gpriv->info->rnc_field_width; + unsigned int w = ch / rnc_stride; u32 rnc = num_rules << shift; - unsigned int w = ch / 2; rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLCFG(w), rnc); } From patchwork Wed Apr 2 10:20:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035747 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 1CFA5235BE8; Wed, 2 Apr 2025 10:21:32 +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=1743589294; cv=none; b=MbhXE6+qCunmBZ8Pw0poW7o7pKzWfGJ7yPDcLmYYBJ3O2L7I9/43uZJ0iUUrrxCaniKf5GKOO3kl/HRc3zwz1sWvTixwoU50kK54zVhr65u1GKgBsY4I5//yE0tn9/jc/OY07WC6HqcpitMAE3/BCu73U+uikyNW3l9AZqvehUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589294; c=relaxed/simple; bh=cf4kiArMQCApr4Cyso0vLIzfhTH1oSuq69f+roQcTAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YJu5Dik7iulcPO5HpD7HJlWCaN2o6FC2Bi3/0YvJHSFwM8Rt/wOrqBP95+SI7y5gdrQXwY7nAmSXFcv2sPXN1YqbvABN6IqfxN92WWTw+Nd4cW3BR72A9TjlQf+lN8yFv7L/65XXarYB+q4TcHA3L3wXxpiGw5/2DiNlGQ6DHN4= 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: 4O0FVlmVTQ+OBuOF46IhRA== X-CSE-MsgGUID: SN7X21GESwGeOPyTBQEUnA== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:31 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 22727401C75A; Wed, 2 Apr 2025 19:21:28 +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:20:30 +0100 Message-ID: <20250402102047.27943-11-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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:20:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 14035748 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 A59F5235BE8; Wed, 2 Apr 2025 10:21:35 +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=1743589297; cv=none; b=abzZOnb3EH4zfszwknin0TbjeEHbXIx05t3BJwivkbJSpudHZKHku2J7uZjIKKHy1MqHJAGZPRLKE4FSmJKohFqE5tRtwK2tTrXyOeO6vMIUcqUAayUWPb2tbFNyBro8SgnnkChOgkHqbLZXv80Sn6IOfM8JgFgHqAhS5bSNZak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743589297; c=relaxed/simple; bh=p6DtY5MTZkDcvhqyxDKHFC5yXF2yHt4uN9GBknrU2x8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EPMDXbAf2Z8Y2djdTaioEBkN2B9PKAgmd1dEZsjNmWl2DJoNXEml2i36iDn7Es1oVS5Ay+Z1+rSEOiDg77dr3IXFVcEYdq4Faby7C9KcKOc/2OF9dZcL9IEjffhim/h/i6gh58htTg8fmtwY9e6DWmz4J3erMPHtZd15mYR3k+0= 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: /9ickgV3SnmUWHCgxMgy2Q== X-CSE-MsgGUID: S74RqZeWTx+IYuE6m4c2hA== Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 02 Apr 2025 19:21:35 +0900 Received: from localhost.localdomain (unknown [10.226.93.220]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 89645401C759; Wed, 2 Apr 2025 19:21: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 11/19] can: rcar_canfd: Add max_cftml variable to struct rcar_canfd_hw_info Date: Wed, 2 Apr 2025 11:20:31 +0100 Message-ID: <20250402102047.27943-12-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> References: <20250402102047.27943-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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,