From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 974F92D63F6; Thu, 22 Jan 2026 12:10:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083855; cv=none; b=sT8TxxrbggeX8KbzFIYJYVu9S10gAV+9iJ64ichlZSzKUCdPiDhQvNQKgnXjxDYFU8RLHMfpNBivwWwRCQmKsISpiIVtTH48IZ39E2efxcGzVI5xtOKhJT2hbr3t2ZynVjsSm/HP2pxfKOnT0v+zbz7oZzdNrhDzoWnwqw44frQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083855; c=relaxed/simple; bh=4ABjbAD5+98MZmYAf0gnMH/kj3xedfLBF+h1XtnXyYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bKt7CzGMcIbrDMb28yuLWMBjuDxDknGQsnlEVAo0YwxT11Ni4KHDDuGIKMaHGBixGHMC1mW2pQNoXe0MNXODy1UkOFtKAxq9nOx1a/rdsD7JmBNB1T2/YAhrldDZzV3gE8wL0DDHz9fZC/XMCZLLq+HbUYBBezX8pXQgXa/cI+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=StkKAlRb reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="StkKAlRb" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfz90LSNz1DR2r; Thu, 22 Jan 2026 13:10:45 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfz82Nlbz1DHbp; Thu, 22 Jan 2026 13:10:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083844; bh=5SH078nohE+9Gm+77QrxCwdEF5+Vk2JfRQSsr5Vqm0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=StkKAlRbbnCId/tMEIBl2XQgLAuoElIuesov3YclhRkNyd3ytDklqXoJ/7nUkObjn nwsAHMJG3SroZpazm82oqQ2bNdgP0X2CpgUL6WWXd11wqRVYILq04AUELYAbUCBxpO buiGklzGBA6jz1a5VhJdd8gwX1jnD/oJzRlYzt5yI1Sb3T2dvk1YvumqIXc8M16h8u ByHMoIKFosnSFL+jnROGFjDKoeVfDrRbQUvwi+0bHhyhC2XM+IRRIqletFYTQfNj/T zdicTUmgKQLdolb0ziiZ3WZWpizONANXA8KM0HkEvQ9VD7vkN1+lDrsCAIk0Tvg/Oy e6WvXfAKgi4vA== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Ludwig Rydberg , Arun Muthusamy , Krzysztof Kozlowski Subject: [PATCH v3 01/15] dt-bindings: Add vendor prefix for Frontgrade Gaisler AB Date: Thu, 22 Jan 2026 13:10:24 +0100 Message-ID: <20260122121038.7910-2-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ludwig Rydberg Frontgrade Gaisler AB provides IP cores and supporting development tools for embedded processors based on the SPARC and RISC-V architectures. Some essential products are the LEON and NOEL synthesizable processor models together with a complete development environment and a library of IP cores (GRLIB). The company specializes in digital hardware design (ASIC/FPGA) for both commercial and aerospace applications. Web site: https://www.gaisler.com/ Signed-off-by: Ludwig Rydberg Signed-off-by: Arun Muthusamy Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Docum= entation/devicetree/bindings/vendor-prefixes.yaml index 424aa7b911a7..4e1b4eeff9ff 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -594,6 +594,8 @@ patternProperties: description: Fujitsu Ltd. "^fxtec,.*": description: FX Technology Ltd. + "^gaisler,.*": + description: Frontgrade Gaisler AB "^galaxycore,.*": description: GalaxyCore Inc. "^gameforce,.*": --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21B00275AEB; Thu, 22 Jan 2026 12:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083857; cv=none; b=rNpvLbPKG2BSocipx8Q2Me8qg61ED7zFeGr9w2thTCKuOtfUsHu3Wrnr/rBdCwmIXCgO01SryfprMvUlZvLSLYeAXoDAR+F4QEcBiv+UgM+I0nh1MU2x/ev/cIJ9BTeQZ7rHkAT/YJoBFxVN1H1hBogTBt/tMeKEXbB/ZiJ26E0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083857; c=relaxed/simple; bh=7bo6kyU/CzwrHOMH+Wx8lk0yAjgsIohwhkTlnakohB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ukF89Nm0+VhL1Xkimd6tw2OLNDL7FKtKhxPxvjU1PjpNIQme4zYFJAzE5jjYxtgId/znkqjQZ0YiaC/1xEoOacTrcaVD4ukTn8zABqnKL4go6JgMm2GE1HEFVHMqqxp0qLWyHiogPDa5V2dJ1a+MkI7qP6fRxXLhthm2OuBn5Jw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=lpb9z6tz reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="lpb9z6tz" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfz96SwDz1Fgd3; Thu, 22 Jan 2026 13:10:45 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfz86wZkz1Fg8w; Thu, 22 Jan 2026 13:10:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083845; bh=y0ATh+tm6nzwgLjCC2ONffH5fxw1dolErS8ddM5gl/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lpb9z6tzhlfEOHl/deGNOPor0gRG7V7y6DIJv7tazsWU5/aw0VZhCYv8356CjQA/N rfo0ChcjV2A/b3wTFX55/DWTvh2WR6dmj+aPWtBdJi+BBMvHMxoZFhjOkz274ED7Ve 78DFTX8KKXxWsNwtx0Gd35Oqmo5ezw1Br7BfLceOlqxrmb6apKJdYotxbiLjjAI6rf L+EMRUC5s0T5xwR2mbACcaWhb5MkqaWfmDuFLi1vDu4aQnNhw9pzbBqCMvhsaevKnt ViIfx0ydeAZv+erd0yEJ4NlMr7RVL7SShjqDQn2BsKKKk3e291OLOtREolDlqvSfKA PI+StxjJIsMxg== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Arun Muthusamy Subject: [PATCH v3 02/15] net: can: Convert gaisler,grcan to DT schema Date: Thu, 22 Jan 2026 13:10:25 +0100 Message-ID: <20260122121038.7910-3-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Migrate device tree bindings for Gaisler GRCAN, GRHCAN and GRCANFD CAN controllers from a text format to YAML format. Additional changes: - Remove stale systemid property removed in commit 1e93ed26acf0 ("can: grcan: grcan_probe(): fix broken system id check for errata workaround needs") - Make freq optional - Add clocks - Add compatible - Add example Signed-off-by: Arun Muthusamy Reviewed-by: Rob Herring --- .../bindings/net/can/gaisler,grcan.yaml | 62 +++++++++++++++++++ .../devicetree/bindings/net/can/grcan.txt | 28 --------- 2 files changed, 62 insertions(+), 28 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/can/gaisler,grcan= .yaml delete mode 100644 Documentation/devicetree/bindings/net/can/grcan.txt diff --git a/Documentation/devicetree/bindings/net/can/gaisler,grcan.yaml b= /Documentation/devicetree/bindings/net/can/gaisler,grcan.yaml new file mode 100644 index 000000000000..8fea97c7319a --- /dev/null +++ b/Documentation/devicetree/bindings/net/can/gaisler,grcan.yaml @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/can/gaisler,grcan.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Aeroflex Gaisler GRCAN, GRHCAN and GRCANFD CAN controllers. + +description: | + GRCAN, GRCANFD, GRHCAN controllers are available in the GRLIB VHDL + IP core library. + For further information look in the documentation for the GRLIB IP libra= ry: + https://download.gaisler.com/products/GRLIB/doc/grip.pdf + +maintainers: + - Arun Muthusamy + - Andreas Larsson + +allOf: + - $ref: can-controller.yaml# + +properties: + compatible: + enum: + - gaisler,grcan + - gaisler,grcanfd + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + freq: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Frequency of the external oscillator clock in Hz (the frequency of t= he + AMBA bus in the ordinary case). + This property should be used by systems where the common clock + framework is not supported. + +required: + - compatible + - reg + - interrupts + +unevaluatedProperties: false + +examples: + - | + #include + + can@ff400000 { + compatible =3D "gaisler,grcanfd"; + clocks =3D <&sysclock>; + reg =3D <0xff400000 0x400>; + interrupt-parent =3D <&plic0>; + interrupts =3D <6>; + }; diff --git a/Documentation/devicetree/bindings/net/can/grcan.txt b/Document= ation/devicetree/bindings/net/can/grcan.txt deleted file mode 100644 index 34ef3498f887..000000000000 --- a/Documentation/devicetree/bindings/net/can/grcan.txt +++ /dev/null @@ -1,28 +0,0 @@ -Aeroflex Gaisler GRCAN and GRHCAN CAN controllers. - -The GRCAN and CRHCAN CAN controllers are available in the GRLIB VHDL IP co= re -library. - -Note: These properties are built from the AMBA plug&play in a Leon SPARC s= ystem -(the ordinary environment for GRCAN and GRHCAN). There are no dts files for -sparc. - -Required properties: - -- name : Should be "GAISLER_GRCAN", "01_03d", "GAISLER_GRHCAN" or "01_034" - -- reg : Address and length of the register set for the device - -- freq : Frequency of the external oscillator clock in Hz (the frequency of - the amba bus in the ordinary case) - -- interrupts : Interrupt number for this device - -Optional properties: - -- systemid : If not present or if the value of the least significant 16 bi= ts - of this 32-bit property is smaller than GRCAN_TXBUG_SAFE_GRLIB_VERSION - a bug workaround is activated. - -For further information look in the documentation for the GLIB IP core lib= rary: -http://www.gaisler.com/products/grlib/grip.pdf --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1BB13B530E; Thu, 22 Jan 2026 12:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083856; cv=none; b=IaqHQTFdODbnpcL6Ox3cgcjHijM5L759HW7GsJx6bkvc54o3xYqrndPSGqqP9GdrhC40IsmEm/UCf2LshMKUlkcs3k0mye277O1EWJMrEoNK1BSYi5kTQueMppL8YymYNsvlxTRCpdbGwLTtG7OjFRP5TFxFtGUk42kVOxSVzhY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083856; c=relaxed/simple; bh=hG5KSuPtLiBtHjq424HSyAbeOdsq1PzCy6qL7NHd2UY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XgffIjX27oLigRCkp7sMeiQ6O8YsOHwnu34dFZwel7ikqOmAf1FCGJskV49wc6zBc2FGS6YLd1IsHYkHwBe6CCkvBeBjIZdOm8ucwaRSUzP3CpD5APrhG/iP+2DBZD4DuNr4PuQiJbE551sxJhjZXlsAZssDv19WswtRb/4c3gk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=c7Yptj0l reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="c7Yptj0l" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzB31slz1Fgd0; Thu, 22 Jan 2026 13:10:46 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfz956CRz1Fgcp; Thu, 22 Jan 2026 13:10:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083846; bh=lDfZgx61aSWUJ1n5uo3C1KLCGawncX5ACzgdlX+fljk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=c7Yptj0l/vbaClo29pXsJ/WdqRR/uLT9oFIn3tV5b87uPiHYzi6yHGxGg+/uVJ/uD H24EwpR0K71MpjDjq0P/o8I5WTyX8Rw7XZMuwulpEdk4o6KRmx7iD85WFfxvNX7mzC l87QBiT9/xmypfP+SLb1jstuSRTBqkmJXLUyb7CvVkjuyaKT6Aqg2Ur42Byp9xu5IM TTBJLO3SDfMXS55NkbAi2QIquyWFANcsB0QAywfyKWupQqDHSRsK6nUiZQrbQ7TA5v rSoUSsF0DWi4KEiGWU2tZu6kP429nd8fh39K4dbVKCRaOsXEk49sNX2NdpmlFVRpOB I17SfFIsfS8iw== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Arun Muthusamy Subject: [PATCH v3 03/15] MAINTAINERS: Add maintainers for GRCAN CAN network driver Date: Thu, 22 Jan 2026 13:10:26 +0100 Message-ID: <20260122121038.7910-4-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add Arun Muthusamy and Andreas Larsson as maintainers for the GRCAN CAN network driver, This entry ensures clear communication channels for maintaining the Documentation and driver code associated with GRCAN. Signed-off-by: Arun Muthusamy --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 0dc4aa37d903..14ddd48e063f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10706,6 +10706,14 @@ F: drivers/gpio/gpiolib-cdev.c F: include/uapi/linux/gpio.h F: tools/gpio/ =20 +GRCAN CAN NETWORK DRIVER +M: Andreas Larsson +M: Arun Muthusamy +L: linux-can@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/net/can/gaisler,grcan.yaml +F: drivers/net/can/grcan.c + GRETH 10/100/1G Ethernet MAC device driver M: Andreas Larsson L: netdev@vger.kernel.org --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5DB535E529; Thu, 22 Jan 2026 12:10:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083857; cv=none; b=GLbnkn307GQNOVsjXb/VENZEc/L4L60CayBVPdA0Uk6dFy7WMs9CKErGcFeZu81XVxdGRAnGgTiUVHfM4sOsIwcM8IGpij8XQ6x2QsCm5/8IEBWCzsLz26m5I51EBwOVGTrGOzF98nYFCImle0FLAQUHshexxXdEMUAVaGOWp+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083857; c=relaxed/simple; bh=5nuYmtDIo1xkP7UImyOsAOk/6W2j04fEWx3lpFIWgw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CZwJwuznsswl0h3TViBC8wxMGCDI5E/n0DTcIjvROS5a3C59Fy42Y2Txa9riRM3bG+aySqY9Qd+w3oB6S5nR/duvL9H6Cpx6m2rKu9pfSKV35hVvh4JoQjhcGhjmr34rXCS6YMWtu1Zsus5/SXUryT3zfAUFQgyZTENMtbWwTmc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=PIy+4mnh reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="PIy+4mnh" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzB58L3z1FgdF; Thu, 22 Jan 2026 13:10:46 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzB2FWMz1Fgcl; Thu, 22 Jan 2026 13:10:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083846; bh=npkggg7tOGIOrWu8aBerGnxSfTPWt4Z7jdrnizYzqoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PIy+4mnhfDoUbHLJGdEV9KEyIdPc2qAfmoAjUK/W/6uFL4rrSRarHqHG35VUQbu+e gEiucPT3/M18SDzJ7WDGz2MOBloqgmPbJ+9PK6/pE5RFnouPCUW7VyZK6HQlAX/723 /ut09Gg6zIK3X4pxCrFhCXtuKqKJL8JHxOF89DDohSG7CH6bthniZuZ/7bzSwNNsG5 hPafuOLSyqZQz2e6czwMz79PennYkI0XDTHYuUKhhg4cqUjj3usbV75uaHffZsFv6j RAW40rAagg1zBNCjojRUU4/9mw8fzzPnOTdoaU7tLdhx3ygyu1x79mDxsAcs3GZiAI tlmvt9+oxKfWA== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Daniel Hellstrom , Arun Muthusamy Subject: [PATCH v3 04/15] can: grcan: Add clock handling Date: Thu, 22 Jan 2026 13:10:27 +0100 Message-ID: <20260122121038.7910-5-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Hellstrom Add clock handling and add error messages for missing 'freq' DT property. Signed-off-by: Daniel Hellstrom Signed-off-by: Arun Muthusamy --- drivers/net/can/grcan.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 3b1b09943436..538a9b4f82ab 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -34,7 +34,7 @@ #include #include #include - +#include #include =20 #define DRV_NAME "grcan" @@ -1644,6 +1644,7 @@ static int grcan_probe(struct platform_device *ofdev) { struct device_node *np =3D ofdev->dev.of_node; struct device_node *sysid_parent; + struct clk *clk; u32 sysid, ambafreq; int irq, err; void __iomem *base; @@ -1663,8 +1664,20 @@ static int grcan_probe(struct platform_device *ofdev) =20 err =3D of_property_read_u32(np, "freq", &ambafreq); if (err) { - dev_err(&ofdev->dev, "unable to fetch \"freq\" property\n"); - goto exit_error; + clk =3D devm_clk_get(&ofdev->dev, NULL); + if (IS_ERR(clk)) { + dev_err_probe(&ofdev->dev, PTR_ERR(clk), + "Failed both to get \"freq\" property and clock for fallback\n"); + err =3D PTR_ERR(clk); + goto exit_error; + } + if (clk) { + ambafreq =3D clk_get_rate(clk); + if (!ambafreq) { + dev_err(&ofdev->dev, "Invalid or Uninitialized clock\n"); + return -EINVAL; + } + } } =20 base =3D devm_platform_ioremap_resource(ofdev, 0); --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 158D217B418; Thu, 22 Jan 2026 12:10:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083858; cv=none; b=L/VYiJkNI4s+ZMwN+/HBmLFNC1OoSUaQfe/b/Dz1W9o7RXBoLiMEZU9dcWibc/hNO7KkuKtF0epTz/eA73iQkAYOfLCmnPqJv+LJDJpanzRuSopnaG/y9Ee7By2AxoH7ou+kyfrdIPSvaU60ReGdD7aGA0fLIySLtayAqzyU03A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083858; c=relaxed/simple; bh=FNNZIBsrSgLHj2js+iZmraPJB/UTYKawHLKl2DBMccw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NYU+6OK6cc+g/sVjS08yZd6cU3xcJ6QE/v+BsQL3qZg/aiIU4XXIWRFPC65fg0dEktIiALhjCZ1Ir7SyP6RUtIQIEDp1D9hQ2GlWsycrUhxjDz9fAEBhi1I6KCntPewTd/o/wN0OcF1g2Sl3AZecBpz3FpLISxjs4DE1RUqb4S0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=LBLqWyrc reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="LBLqWyrc" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzC0X7Cz1DHbk; Thu, 22 Jan 2026 13:10:47 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzB4jPwz1Fgd9; Thu, 22 Jan 2026 13:10:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083846; bh=nSjMvwsSVcamn5+lgzYFxW7/Q79hZjUMP4od70MbxlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LBLqWyrc8XgQsPUmfXNpqd3bm7mJM7u8mcO31dM7EJr9Aa+AA2cx1+OKLWSpnx6Od 1okXGnyijsaL2UDgjHp4BfFZb/luufiuM+zfFFIIJsGL8i2veI3XoVNeUgarVVujq0 XweEh5Lp5tzqTdZqfAWgx1NI4jLyeq3X7GGPGT4pivlsjSxn+Dyj6jRgwgZx0Nz9XK 4Tzc0gcygqvQwuLTYIxRZElX9sDxoXxUMUskhvBM72sVg9InwDOHarFSTivClvIZd3 H77kK9TXDsnmV1jtSn0OXRXBktk5PdiLYPRItY5+NFMLAU1pKcEkTXTQlhFHpRFiK8 pBA0dgBqGp1fQ== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Arun Muthusamy , Daniel Hellstrom Subject: [PATCH v3 05/15] can: grcan: Replace bit timing macros with literal values Date: Thu, 22 Jan 2026 13:10:28 +0100 Message-ID: <20260122121038.7910-6-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor the bit timing constants in grcan_bittiming_const by replacing macros with literal values. Signed-off-by: Arun Muthusamy Signed-off-by: Daniel Hellstrom --- drivers/net/can/grcan.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 538a9b4f82ab..f34ca558fa5d 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -36,6 +36,7 @@ #include #include #include +#include =20 #define DRV_NAME "grcan" =20 @@ -93,16 +94,6 @@ struct grcan_registers { (GRCAN_CONF_BPR | GRCAN_CONF_RSJ | GRCAN_CONF_PS1 \ | GRCAN_CONF_PS2 | GRCAN_CONF_SCALER) =20 -#define GRCAN_CONF_RSJ_MIN 1 -#define GRCAN_CONF_RSJ_MAX 4 -#define GRCAN_CONF_PS1_MIN 1 -#define GRCAN_CONF_PS1_MAX 15 -#define GRCAN_CONF_PS2_MIN 2 -#define GRCAN_CONF_PS2_MAX 8 -#define GRCAN_CONF_SCALER_MIN 0 -#define GRCAN_CONF_SCALER_MAX 255 -#define GRCAN_CONF_SCALER_INC 1 - #define GRCAN_CONF_BPR_BIT 8 #define GRCAN_CONF_RSJ_BIT 12 #define GRCAN_CONF_PS1_BIT 20 @@ -392,14 +383,14 @@ static struct grcan_device_config grcan_module_config= =3D =20 static const struct can_bittiming_const grcan_bittiming_const =3D { .name =3D DRV_NAME, - .tseg1_min =3D GRCAN_CONF_PS1_MIN + 1, - .tseg1_max =3D GRCAN_CONF_PS1_MAX + 1, - .tseg2_min =3D GRCAN_CONF_PS2_MIN, - .tseg2_max =3D GRCAN_CONF_PS2_MAX, - .sjw_max =3D GRCAN_CONF_RSJ_MAX, - .brp_min =3D GRCAN_CONF_SCALER_MIN + 1, - .brp_max =3D GRCAN_CONF_SCALER_MAX + 1, - .brp_inc =3D GRCAN_CONF_SCALER_INC, + .tseg1_min =3D 2, + .tseg1_max =3D 16, + .tseg2_min =3D 2, + .tseg2_max =3D 8, + .sjw_max =3D 4, + .brp_min =3D 1, + .brp_max =3D 256, + .brp_inc =3D 1, }; =20 static int grcan_set_bittiming(struct net_device *dev) --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45C4331AF1F; Thu, 22 Jan 2026 12:10:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083859; cv=none; b=B+Yv4mEP62Ph6QfpV4+TeOnaaFlb8Qy7qHMOeJCohOm78JVqqbnB4h3aDxCnZgaqqJTlLL96yUXfx9hrIOPIeIXSR8XhYJelELC2x8ImXDK+rwlp+J85JYq8WjFhEsOFDp29VuhBGo/rkyrQaUhRjGq+K+6ZQN5Mcs0mUgVNocM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083859; c=relaxed/simple; bh=0n307RI2osGkwAnwHOdE+jJLyTXApuRW/XscUPfHsXI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JlFnyCSvs+v2hZcAVTRJo6Y4IKq5/M8cZEgydTiKcBa5rdXO1JmsdhjCkmG3HkegZT6Iq7vodcIFiN8UTMH3bFvypz0AEKwJjtbE0OjaEeDnSVWEZsfWoddH9Gvc0O1iTENWKNSgVr7HDDVsTW1Gnt1iemeVkyqEoB4oDpttSyM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=JbeGnaqt reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="JbeGnaqt" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzC5YMdz1Fgcr; Thu, 22 Jan 2026 13:10:47 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzC06VJz1DDC3; Thu, 22 Jan 2026 13:10:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083847; bh=EMkpJcbf388KKgy3H9YvNKkEn9x2GMeSt2rV8zMvFWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JbeGnaqtxaAb/xcv6B06Sh2OBidUzm2VXi7PO13rhCLg7JADZ5um9XnEko9B1COzR KcbtEzksiVntGVIXhmcIfeUcf7uqElV/+V+Uw9KHFXRpTarm5AAGryAT/H1KewDJBf Ach4EGB+Pu1r2Zvmd0qcGEYsmSFrFpriVvHrA6hDFiag+5mtOwfZbdEk4nwWRY93w9 ytKJ6rKt5jWwjMtMuMIhLkRYqF0D64s8cwGF5613Cy+p3J4/bXK0k++fHmSLX7Vmjm GW+ahqYFRWOjJ6GY2jqa9RPzwQylDYyxCBLUMQiqzYEe6qaQ8stJ2ULw82O2w/LqCk 5i3/HW/I/nbgA== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Arun Muthusamy , Daniel Hellstrom Subject: [PATCH v3 06/15] can: grcan: Simplify timing configuration Date: Thu, 22 Jan 2026 13:10:29 +0100 Message-ID: <20260122121038.7910-7-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove redundant error checks and use FIELD_PREP for bit timing assignments to simplify the timing configuration Signed-off-by: Arun Muthusamy Signed-off-by: Daniel Hellstrom --- drivers/net/can/grcan.c | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index f34ca558fa5d..5a63d0a0365f 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -396,41 +396,26 @@ static const struct can_bittiming_const grcan_bittimi= ng_const =3D { static int grcan_set_bittiming(struct net_device *dev) { struct grcan_priv *priv =3D netdev_priv(dev); - struct grcan_registers __iomem *regs =3D priv->regs; - struct can_bittiming *bt =3D &priv->can.bittiming; - u32 timing =3D 0; + struct grcan_registers __iomem *regs; int bpr, rsj, ps1, ps2, scaler; + struct can_bittiming *bt; + u32 timing =3D 0; =20 - /* Should never happen - function will not be called when - * device is up - */ - if (grcan_read_bits(®s->ctrl, GRCAN_CTRL_ENABLE)) - return -EBUSY; + regs =3D priv->regs; + bt =3D &priv->can.bittiming; =20 bpr =3D 0; /* Note bpr and brp are different concepts */ rsj =3D bt->sjw; ps1 =3D (bt->prop_seg + bt->phase_seg1) - 1; /* tseg1 - 1 */ ps2 =3D bt->phase_seg2; - scaler =3D (bt->brp - 1); - netdev_dbg(dev, "Request for BPR=3D%d, RSJ=3D%d, PS1=3D%d, PS2=3D%d, SCAL= ER=3D%d", - bpr, rsj, ps1, ps2, scaler); - if (!(ps1 > ps2)) { - netdev_err(dev, "PS1 > PS2 must hold: PS1=3D%d, PS2=3D%d\n", - ps1, ps2); - return -EINVAL; - } - if (!(ps2 >=3D rsj)) { - netdev_err(dev, "PS2 >=3D RSJ must hold: PS2=3D%d, RSJ=3D%d\n", - ps2, rsj); - return -EINVAL; - } - - timing |=3D (bpr << GRCAN_CONF_BPR_BIT) & GRCAN_CONF_BPR; - timing |=3D (rsj << GRCAN_CONF_RSJ_BIT) & GRCAN_CONF_RSJ; - timing |=3D (ps1 << GRCAN_CONF_PS1_BIT) & GRCAN_CONF_PS1; - timing |=3D (ps2 << GRCAN_CONF_PS2_BIT) & GRCAN_CONF_PS2; - timing |=3D (scaler << GRCAN_CONF_SCALER_BIT) & GRCAN_CONF_SCALER; - netdev_info(dev, "setting timing=3D0x%x\n", timing); + scaler =3D bt->brp - 1; + + timing |=3D FIELD_PREP(GRCAN_CONF_BPR, bpr); + timing |=3D FIELD_PREP(GRCAN_CONF_RSJ, rsj); + timing |=3D FIELD_PREP(GRCAN_CONF_PS1, ps1); + timing |=3D FIELD_PREP(GRCAN_CONF_PS2, ps2); + timing |=3D FIELD_PREP(GRCAN_CONF_SCALER, scaler); + netdev_dbg(dev, "setting timing=3D0x%x\n", timing); grcan_write_bits(®s->conf, timing, GRCAN_CONF_TIMING); =20 return 0; --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 724BE43C058; Thu, 22 Jan 2026 12:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083861; cv=none; b=FkF1mcCfcpBT8Dv2cAA/tP7J6LpQFDDBChktrhM5P46+Q22zST/uaOM+D7sL+gtEIdkEYY1v2AJK6Gqx+sPXOdZ1vlqr8XSwRHiMyziPC312c2jLK7rISz8l+3bUhWH4K8RU+AptZeEBCsD3KOO/3GaHd2+GK7dgIPIurwGtmOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083861; c=relaxed/simple; bh=p0JoOqWpkoWwanFjzCbCyt/1JNrsXZJp560szytT5zg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ERkkoxksrdZrSqbYRbcfvzz1860iRph3n8VfFi2KSyMLmsVnGWnD6sSKFGh4jx/CiPTf37q2xVfQQQ51FF7b8ZeU4dNH5G1JZjXoHWifKiSO88DjVkJVlOFogANgkTsI2RbtP9BOM0v85EQDvSLfa761NOTX8rRWSdl+nyp0Gu4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=ZZuBoNQC reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="ZZuBoNQC" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzD068Hz1FgdK; Thu, 22 Jan 2026 13:10:48 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzC5KTCz1DHbf; Thu, 22 Jan 2026 13:10:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083847; bh=EIQvS76kVsIc+m7OYyfaMa4b11bYFvKU+IqFc+wtBsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZZuBoNQCFP309lZuvHc859gMGWkAFkxUXM3f5JR2Ihey/wHZhNTeDSNVCupfxQWwd 0HpUSY27WdflSqaIF5GWaE31XiFgY1AzOjLFJ1N91qAtoLbxe1BTF6Rr4E4O79njqj VwU9GsGbKbR0zmiy+f/A0R18GI3RY8ZbWOuAxlAu6yCXU40c3AXrmnqOSiscedNL/4 J2TBz8pesNg+11tnuYxl5BV7iQ9xBbQRAtTtbsPi7vuTg3idltpHyD6heYTtZkV8J8 gFiFbV9Eal8+kXMzYvpjR9zcBEz7VPoWTjeaPEYxS7EkYx1VnYCT2mQDg7l3cr8qFH Qv6uLCu/pCY/w== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Arun Muthusamy , Daniel Hellstrom Subject: [PATCH v3 07/15] can: grcan: add FD capability detection and nominal bit-timing Date: Thu, 22 Jan 2026 13:10:30 +0100 Message-ID: <20260122121038.7910-8-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add capability for the driver to detect CAN FD support and adjust accordingly. Introduce structures and functions for setting nominal bit-timing for standard CAN FD. The `grcan_hwcap` structure defines hardware capabilities like CAN FD support and baud-rate options. Additionally, improved device tree compatibility by updating the `of_device_id` table for better matching of GRCAN and GRCANFD devices. Also update Kconfig to mention GRCANFD support. Signed-off-by: Arun Muthusamy Signed-off-by: Daniel Hellstrom --- drivers/net/can/Kconfig | 6 +- drivers/net/can/grcan.c | 142 +++++++++++++++++++++++++++++++++++----- 2 files changed, 130 insertions(+), 18 deletions(-) diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index d43d56694667..96f61b40a898 100644 --- a/drivers/net/can/Kconfig +++ b/drivers/net/can/Kconfig @@ -133,10 +133,12 @@ config CAN_FLEXCAN Say Y here if you want to support for Freescale FlexCAN. =20 config CAN_GRCAN - tristate "Aeroflex Gaisler GRCAN and GRHCAN CAN devices" + tristate "Aeroflex Gaisler GRCAN(FD) and GRHCAN CAN devices" depends on OF && HAS_DMA && HAS_IOMEM help - Say Y here if you want to use Aeroflex Gaisler GRCAN or GRHCAN. + Say Y here if you want to use Aeroflex Gaisler GRCAN or GRCANFD + or GRHCAN. + Note that the driver supports little endian, even though little endian syntheses of the cores would need some modifications on the hardware level to work. diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 5a63d0a0365f..5d09f61a153c 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,11 @@ struct grcan_registers { u32 __reserved1[GRCAN_RESERVE_SIZE(0x08, 0x18)]; u32 smask; /* 0x18 - CanMASK */ u32 scode; /* 0x1c - CanCODE */ - u32 __reserved2[GRCAN_RESERVE_SIZE(0x1c, 0x100)]; + u32 __reserved2[GRCAN_RESERVE_SIZE(0x1c, 0x40)]; + u32 nbtr; /* 0x40 */ + u32 fdbtr; /* 0x44 */ + u32 tdelay; /* 0x48 */ + u32 __reserved2_[GRCAN_RESERVE_SIZE(0x48, 0x100)]; u32 pimsr; /* 0x100 */ u32 pimr; /* 0x104 */ u32 pisr; /* 0x108 */ @@ -203,6 +208,39 @@ struct grcan_registers { #error "Invalid default buffer size" #endif =20 +#define GRCANFD_NBTR_SCALER GENMASK(23, 16) +#define GRCANFD_NBTR_PS1 GENMASK(17, 10) +#define GRCANFD_NBTR_PS2 GENMASK(9, 5) +#define GRCANFD_NBTR_SJW GENMASK(4, 0) +#define GRCANFD_NBTR_TIMING \ + (GRCANFD_NBTR_SCALER | GRCANFD_NBTR_PS1 | GRCANFD_NBTR_PS2 | \ + GRCANFD_NBTR_SJW) + +#define GRCANFD_FDBTR_SCALER 0x00ff0000 +#define GRCANFD_FDBTR_PS1 0x00003c00 +#define GRCANFD_FDBTR_PS2 0x000001e0 +#define GRCANFD_FDBTR_SJW 0x0000000f +#define GRCANFD_FDBTR_TIMING \ + (GRCANFD_FDBTR_SCALER | GRCANFD_FDBTR_PS1 | GRCANFD_FDBTR_PS2 | \ + GRCANFD_FDBTR_SJW) + +#define GRCANFD_FDBTR_SCALER_BIT 16 +#define GRCANFD_FDBTR_PS1_BIT 10 +#define GRCANFD_FDBTR_PS2_BIT 5 +#define GRCANFD_FDBTR_SJW_BIT 0 + +/* Hardware capabilities */ +struct grcan_hwcap { + /* CAN-FD capable, indicates GRCANFD IP. + * The GRCANFD has different baud-rate registers and extended DMA + * format to also describe FD-frames. + */ + const struct can_bittiming_const *bt_const; + int (*set_bittiming)(struct net_device *dev); + bool txbug_possible; + bool fd; +}; + struct grcan_dma_buffer { size_t size; void *buf; @@ -245,6 +283,7 @@ struct grcan_priv { struct napi_struct napi; =20 struct grcan_registers __iomem *regs; /* ioremap'ed registers */ + const struct grcan_hwcap *hwcap; struct grcan_device_config config; struct grcan_dma dma; =20 @@ -295,6 +334,7 @@ struct grcan_priv { */ bool resetting; bool closing; + }; =20 /* Wait time for a short wait for ongoing to clear */ @@ -393,6 +433,19 @@ static const struct can_bittiming_const grcan_bittimin= g_const =3D { .brp_inc =3D 1, }; =20 +/* GRCANFD nominal boundaries for baud-rate parameters */ +static const struct can_bittiming_const grcanfd_bittiming_const =3D { + .name =3D DRV_NAME, + .tseg1_min =3D 2, + .tseg1_max =3D 63, + .tseg2_min =3D 2, + .tseg2_max =3D 16, + .sjw_max =3D 16, + .brp_min =3D 1, + .brp_max =3D 256, + .brp_inc =3D 1, +}; + static int grcan_set_bittiming(struct net_device *dev) { struct grcan_priv *priv =3D netdev_priv(dev); @@ -421,6 +474,32 @@ static int grcan_set_bittiming(struct net_device *dev) return 0; } =20 +static int grcanfd_set_bittiming(struct net_device *dev) +{ + struct grcan_priv *priv =3D netdev_priv(dev); + struct grcan_registers __iomem *regs; + int sjw, ps1, ps2, scaler; + struct can_bittiming *bt; + u32 timing =3D 0; + + regs =3D priv->regs; + bt =3D &priv->can.bittiming; + + sjw =3D bt->sjw; + ps1 =3D (bt->prop_seg + bt->phase_seg1); + ps2 =3D bt->phase_seg2; + scaler =3D bt->brp - 1; + + timing |=3D FIELD_PREP(GRCANFD_NBTR_SJW, sjw); + timing |=3D FIELD_PREP(GRCANFD_NBTR_PS1, ps1); + timing |=3D FIELD_PREP(GRCANFD_NBTR_PS2, ps2); + timing |=3D FIELD_PREP(GRCANFD_NBTR_SCALER, scaler); + netdev_info(dev, "setting timing=3D0x%x\n", timing); + grcan_write_bits(®s->nbtr, timing, GRCANFD_NBTR_TIMING); + + return 0; +} + static int grcan_get_berr_counter(const struct net_device *dev, struct can_berr_counter *bec) { @@ -1545,7 +1624,8 @@ static const struct ethtool_ops grcan_ethtool_ops =3D= { =20 static int grcan_setup_netdev(struct platform_device *ofdev, void __iomem *base, - int irq, u32 ambafreq, bool txbug) + int irq, u32 ambafreq, bool txbug, + const struct grcan_hwcap *hwcap) { struct net_device *dev; struct grcan_priv *priv; @@ -1568,14 +1648,14 @@ static int grcan_setup_netdev(struct platform_devic= e *ofdev, priv->dev =3D dev; priv->ofdev_dev =3D &ofdev->dev; priv->regs =3D base; - priv->can.bittiming_const =3D &grcan_bittiming_const; - priv->can.do_set_bittiming =3D grcan_set_bittiming; + priv->can.bittiming_const =3D hwcap->bt_const; priv->can.do_set_mode =3D grcan_set_mode; priv->can.do_get_berr_counter =3D grcan_get_berr_counter; priv->can.clock.freq =3D ambafreq; priv->can.ctrlmode_supported =3D CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_ONE_SHOT; priv->need_txbug_workaround =3D txbug; + priv->hwcap =3D hwcap; =20 /* Discover if triple sampling is supported by hardware */ regs =3D priv->regs; @@ -1620,22 +1700,33 @@ static int grcan_probe(struct platform_device *ofde= v) { struct device_node *np =3D ofdev->dev.of_node; struct device_node *sysid_parent; + const struct grcan_hwcap *hwcap; struct clk *clk; u32 sysid, ambafreq; int irq, err; void __iomem *base; bool txbug =3D true; =20 + hwcap =3D device_get_match_data(&ofdev->dev); + if (!hwcap) { + dev_err(&ofdev->dev, "Platform data not provided!\n"); + return -ENODEV; + } + /* Compare GRLIB version number with the first that does not * have the tx bug (see start_xmit) */ - sysid_parent =3D of_find_node_by_path("/ambapp0"); - if (sysid_parent) { - err =3D of_property_read_u32(sysid_parent, "systemid", &sysid); - if (!err && ((sysid & GRLIB_VERSION_MASK) >=3D - GRCAN_TXBUG_SAFE_GRLIB_VERSION)) - txbug =3D false; - of_node_put(sysid_parent); + if (!hwcap->txbug_possible) { + txbug =3D false; + } else { + sysid_parent =3D of_find_node_by_path("/ambapp0"); + if (sysid_parent) { + err =3D of_property_read_u32(sysid_parent, "systemid", &sysid); + if (!err && ((sysid & GRLIB_VERSION_MASK) >=3D + GRCAN_TXBUG_SAFE_GRLIB_VERSION)) + txbug =3D false; + of_node_put(sysid_parent); + } } =20 err =3D of_property_read_u32(np, "freq", &ambafreq); @@ -1671,7 +1762,7 @@ static int grcan_probe(struct platform_device *ofdev) =20 grcan_sanitize_module_config(ofdev); =20 - err =3D grcan_setup_netdev(ofdev, base, irq, ambafreq, txbug); + err =3D grcan_setup_netdev(ofdev, base, irq, ambafreq, txbug, hwcap); if (err) goto exit_dispose_irq; =20 @@ -1698,11 +1789,30 @@ static void grcan_remove(struct platform_device *of= dev) free_candev(dev); } =20 +static const struct grcan_hwcap grcan_hwcap =3D { + .fd =3D false, + .txbug_possible =3D true, + .bt_const =3D &grcan_bittiming_const, + .set_bittiming =3D grcan_set_bittiming, +}; + +static const struct grcan_hwcap grcanfd_hwcap =3D { + .fd =3D true, + .txbug_possible =3D false, + .bt_const =3D &grcanfd_bittiming_const, + .set_bittiming =3D grcanfd_set_bittiming, +}; + static const struct of_device_id grcan_match[] =3D { - {.name =3D "GAISLER_GRCAN"}, - {.name =3D "01_03d"}, - {.name =3D "GAISLER_GRHCAN"}, - {.name =3D "01_034"}, + {.name =3D "GAISLER_GRCAN", .data =3D &grcan_hwcap}, + {.name =3D "01_03d", .data =3D &grcan_hwcap}, + {.name =3D "GAISLER_GRHCAN", .data =3D &grcan_hwcap}, + {.name =3D "01_034", .data =3D &grcan_hwcap}, + {.compatible =3D "gaisler,grcan", .data =3D &grcan_hwcap}, + /* GRCANFD */ + {.compatible =3D "gaisler,grcanfd", .data =3D &grcanfd_hwcap}, + {.name =3D "GAISLER_GRCANFD", .data =3D &grcanfd_hwcap}, + {.name =3D "01_0b5", .data =3D &grcanfd_hwcap}, {}, }; =20 --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEC9E426EB4; Thu, 22 Jan 2026 12:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083861; cv=none; b=Vq9bt1Y6Ajjk2kRAcXw2jDwhqNOe8pBWtL2NqNH4ma0PTJ+aHVwDnEHflCdbrLsIoS9bm6E/6lldWh2MMTTdPD/W/ZQPzl1k1B3eS1XUjQaSRU+8W93wSvi0aRuUYsx7I4BC56xIDmPEshLNWoxmjNejKRS30ujoI9UbCPUHU/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083861; c=relaxed/simple; bh=r7bUfIsAYLSfpdmydyK3ggHQ+jGjEjFE1oj7Od7EfV8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vc0Tj7Q5JQFzgPZRaMz4PnAp/wjlc7z9HUdrXuZKYc9y8oaj9Tg1Dg18TlRInf+98piOh3eA2O9iXaGhceuNkNqHDz2jh6sP2C/bCDqKjrS+3kDeodyXJxopD8NMH11Ua+jiQqU0kxnLTKEhwpFipknxuqM1i/DN8/VLthrkEDE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=d3OSD8Tq reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="d3OSD8Tq" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzD43b2z1FlXt; Thu, 22 Jan 2026 13:10:48 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzC6yrmz1FgdJ; Thu, 22 Jan 2026 13:10:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083848; bh=WNL2SDl32TrWWln0AQnf0KAmAYNyqjJmTlfmTjZRvt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d3OSD8TqbuBaVlW2uMrcFidr1T6O2ddGNKOyTro/EExYvbsKSK7ijV/PAFe3UTweH KrlYCt/nHAVCdQswRoR5tDt6HS1XdzQMaMzNiz1mVz4KGksAhn1Ic8ha861PXvyGNf hjJIEHE62BCBcvvXsWlMgzLgSKEsmTdr81qOYepIOZdBQ4zrqFytq0qwl+yb3Eg4ik R2M7azaDrTwNkre/A5a36R0hZ+TtFvWNU/fbhxqp8AucNYNK2qOecZ3wsQp99huoLq U6W6r1s62/1PjSP9TtXEJ09ySIb+Ar/4lDlxS9LuxX4hyHc0yA2ymBoH4PGRxYzoqn ajV9B3c0sSF3A== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Daniel Hellstrom , Arun Muthusamy Subject: [PATCH v3 08/15] can: grcan: optimize DMA by 32-bit accesses Date: Thu, 22 Jan 2026 13:10:31 +0100 Message-ID: <20260122121038.7910-9-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Hellstrom Optimizes DMA transfers in the GRCAN driver by reorganizing data handling to use 32-bit accesses instead of individual byte accesses. Signed-off-by: Daniel Hellstrom Signed-off-by: Arun Muthusamy --- drivers/net/can/grcan.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 5d09f61a153c..e2415529db45 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -194,9 +194,6 @@ struct grcan_registers { #define GRCAN_MSG_OFF 0x00000002 #define GRCAN_MSG_PASS 0x00000001 =20 -#define GRCAN_MSG_DATA_SLOT_INDEX(i) (2 + (i) / 4) -#define GRCAN_MSG_DATA_SHIFT(i) ((3 - (i) % 4) * 8) - #define GRCAN_BUFFER_ALIGNMENT 1024 #define GRCAN_DEFAULT_BUFFER_SIZE 1024 #define GRCAN_VALID_TR_SIZE_MASK 0x001fffc0 @@ -1218,7 +1215,7 @@ static int grcan_receive(struct net_device *dev, int = budget) struct sk_buff *skb; u32 wr, rd, startrd; u32 *slot; - u32 i, rtr, eff, j, shift; + u32 rtr, eff; int work_done =3D 0; =20 rd =3D grcan_read_reg(®s->rxrd); @@ -1254,11 +1251,10 @@ static int grcan_receive(struct net_device *dev, in= t budget) if (rtr) { cf->can_id |=3D CAN_RTR_FLAG; } else { - for (i =3D 0; i < cf->len; i++) { - j =3D GRCAN_MSG_DATA_SLOT_INDEX(i); - shift =3D GRCAN_MSG_DATA_SHIFT(i); - cf->data[i] =3D (u8)(slot[j] >> shift); - } + if (cf->can_dlc > 0) + memcpy(cf->data, &slot[2], sizeof(u32)); + if (cf->can_dlc > 4) + memcpy(cf->data + 4, &slot[3], sizeof(u32)); =20 stats->rx_bytes +=3D cf->len; } @@ -1397,8 +1393,7 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *s= kb, u32 id, txwr, txrd, space, txctrl; int slotindex; u32 *slot; - u32 i, rtr, eff, dlc, tmp, err; - int j, shift; + u32 rtr, eff, dlc, tmp, err; unsigned long flags; u32 oneshotmode =3D priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT; =20 @@ -1451,11 +1446,10 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff = *skb, slot[1] =3D ((dlc << GRCAN_MSG_DLC_BIT) & GRCAN_MSG_DLC); slot[2] =3D 0; slot[3] =3D 0; - for (i =3D 0; i < dlc; i++) { - j =3D GRCAN_MSG_DATA_SLOT_INDEX(i); - shift =3D GRCAN_MSG_DATA_SHIFT(i); - slot[j] |=3D cf->data[i] << shift; - } + if (dlc > 0) + memcpy(&slot[2], cf->data, sizeof(u32)); + if (dlc > 4) + memcpy(&slot[3], cf->data + 4, sizeof(u32)); =20 /* Checking that channel has not been disabled. These cases * should never happen --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AC4343DA55; Thu, 22 Jan 2026 12:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083862; cv=none; b=hpWWxocE9s0e3a2UYIGN87nyhcAW9PyLTDgT+b3TmGOET1FcNVUkmAInAr1vWoYiQsQpetVv7M/BxKJGS+RVHWCAIBnAkfU1ZxVjGUtHb59qjJM0p3X8SWA8Drq4VfN29tuSQGiqraYJktmI0gxsKjYxPHdZRGU263mwmnPyG0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083862; c=relaxed/simple; bh=vd7GadClo/RlrvKYnks9oUL4JQToH3YvUgrlmb9pj/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MP+Y1/wR++YAo9Zktlo+H77L9G85xD1eGCr2ah544SWCNbO7ZiUXO5T/YXICxJ3iftxlZtrW8zlgbYpO1Cxu6mFS4fjIAVVK8K2sy9lE7Fwrm4bbX9VyHQnR61GkG80x11Q0//NfQ+sKKBbC0iCp93MonttSB94huwr5PScPyVY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=OHP+mcX/ reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="OHP+mcX/" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzD6Mp9z1FlXw; Thu, 22 Jan 2026 13:10:48 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzD3pm5z1Fgcl; Thu, 22 Jan 2026 13:10:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083848; bh=LvNXlj/JjGmCmxw9Wh5XNyDZed3gle08v8TWEGLebtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OHP+mcX/8wsU7uZfHoJY6br9vYqjHV5yKd7fKHb4EFcYD7funhlWy6coRB8gqQ/6z IE2Z78+maYnHksTCcs/Syy7zb1sD/XeC+NmKwx7P9tIZgB+k38kMBPEE3zdrtmpDWa slG+8freLPdYTxGVnGclp/xNbpXE0+FMc3hMvEyMrPcaKi05U2NpoRTb3Jjxj0TqBH F9SOo5cPo+9pBZ5T6+ZK4Dpt39vxb0rQK1vh5DeSS1xwBM+Z9xyOqLBcQa+z1hO8ZE pce/C0TwpGEsBDfqcf2FQKo62m0GFfTEcTOpqEGytShpf6rqfpRILqsjky4oPTUKZd gxqWqp8gjuWOQ== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Daniel Hellstrom , Arun Muthusamy Subject: [PATCH v3 09/15] can: grcan: set DMA mask for GRCAN and GRCANFD to 32-bit Date: Thu, 22 Jan 2026 13:10:32 +0100 Message-ID: <20260122121038.7910-10-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Hellstrom Sets the DMA mask for GRCAN and GRCANFD devices to 32-bit. Setting the DMA mask and coherent DMA mask to 32-bit ensures proper memory addressing during DMA operations Signed-off-by: Daniel Hellstrom Signed-off-by: Arun Muthusamy --- drivers/net/can/grcan.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index e2415529db45..a2a5a5c868ff 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -1747,6 +1747,13 @@ static int grcan_probe(struct platform_device *ofdev) goto exit_error; } =20 + /* On 64-bit systems.. GRCAN and GRCANFD can only address 32-bit */ + err =3D dma_set_mask_and_coherent(&ofdev->dev, DMA_BIT_MASK(32)); + if (err) { + dev_err_probe(&ofdev->dev, err, "No usable DMA configuration.\n"); + goto exit_error; + } + irq =3D irq_of_parse_and_map(np, GRCAN_IRQIX_IRQ); if (!irq) { dev_err(&ofdev->dev, "no irq found\n"); --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2D4D429801; Thu, 22 Jan 2026 12:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083862; cv=none; b=l522pIvRRvjGYXPAiWrPuHuzr8yJfWXNOQtO8+AvTdPScjokLav4qBmVoFQWRIehv2vTtcJKRdWz/Q32ztj4ocCJ12/HikYODt20j0F3u9ZfBxwXc7NhiOWMoWzBByjT6tb8Z7lKozsYC0neG5LrIoLLXX6lOHcyNIV3Fc8xO1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083862; c=relaxed/simple; bh=D9L9i8M12EsxiljRdseF7D25+qQuEpcvENTCB6hcrCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lP2ywf6v1kc3l0MNFNoKkf9S+oWtB7gUOB71bKLKKHLwAwur4Lttu7TvGKq5vp9kqqCck/exwJTuc2p4TakSXFMEYVhKyqS/LHuhhzSpTbuwOT1YLSA7VR8vu3jYWnUk6NeLmUMBsD19qmFZwYVq7qziJgk6nNA5clBdksmvUqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=dOg6EIOL reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="dOg6EIOL" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzF1TBfz1FlXs; Thu, 22 Jan 2026 13:10:49 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzD68MFz1FgdH; Thu, 22 Jan 2026 13:10:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083849; bh=Z9BHb1vgH1ymUiLA9YViZTEhdIFyi4WNzllEYLrgUw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dOg6EIOL/dPTNklUDqTEcMdaC6cEeeSyciQSGdEbQt4ggTKLKR8xbhzUalJZrHnyD ms3vMbmoMZIJYUKzaI/szijIz5Zm4m0SuvFOGOBQS4NmF4zYk8QSySZ9RlWAlsHHYl GA9fjk2zreBhesnr2Das0TSe6KNBOH4nrNi8CPj2SvCEmInCMwwX78q6N0ivc1aZ4z 6Z563iXQzuOVByvZQ7SKNaRTXHApgV5LtzAnS7z6/YchfUwR1E+rGO3LjoORvK67Wd lXm1+0gDi76c9Wp0q3jIMmx4qxIv0A1hSJ1MSSB0rm8Nc0uO/TYMOH1ma0simYDGsA L93Yes7DC4pDw== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Daniel Hellstrom , Arun Muthusamy Subject: [PATCH v3 10/15] can: grcan: Add saving and restoring of CAN FD baud-rate registers Date: Thu, 22 Jan 2026 13:10:33 +0100 Message-ID: <20260122121038.7910-11-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Hellstrom While reset the GRCAN baud-rates are preserved, since GRCANFD has the baud-rate in different registers we need to add saving of those registers too. Signed-off-by: Daniel Hellstrom Signed-off-by: Arun Muthusamy --- drivers/net/can/grcan.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index a2a5a5c868ff..0ee6e9bfbe7f 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -517,15 +517,27 @@ static void grcan_reset(struct net_device *dev) struct grcan_priv *priv =3D netdev_priv(dev); struct grcan_registers __iomem *regs =3D priv->regs; u32 config =3D grcan_read_reg(®s->conf); + u32 nbtr, fdbtr; + + if (priv->hwcap->fd) { + nbtr =3D grcan_read_reg(®s->nbtr); + fdbtr =3D grcan_read_reg(®s->fdbtr); + } =20 grcan_set_bits(®s->ctrl, GRCAN_CTRL_RESET); grcan_write_reg(®s->conf, config); + if (priv->hwcap->fd) { + grcan_write_reg(®s->nbtr, nbtr); + grcan_write_reg(®s->fdbtr, fdbtr); + } =20 priv->eskbp =3D grcan_read_reg(®s->txrd); priv->can.state =3D CAN_STATE_STOPPED; =20 /* Turn off hardware filtering - regs->rxcode set to 0 by reset */ grcan_write_reg(®s->rxmask, 0); + + priv->hwcap->set_bittiming(dev); } =20 /* stop device without changing any configurations */ --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BE8F43E48B; Thu, 22 Jan 2026 12:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083862; cv=none; b=YTMTBHQzzxIVru3bPcV6LUv2plpQZ4FbCPwO8ZIgMYNuEWB4mwBjUeausJEzM8XZyWvrzi2ut0YrodAde50q3vamAY74CErDDayul4XTl+Hyn5on27Eu15qmWc4qEXGzEgC+wWjv86kzKkAgM5g1Ken+Yp0BfwrgTtRLGQUJUa8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083862; c=relaxed/simple; bh=ntLjzCp65tIxL92OBrl6hc1EQJAsMAfVCAnEiXcT5zM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ij9St2q1CvOXKPWbjR9nxvaqCrTnf16WDeWtazSBcf8x6QWfMu696HExUD6Vcx0ScNd9fGBJRVtub/6I4IiSaGMGY9gf57qUoEXa7rmSS6/QbsueY3d0j2WJRQ7zUrQMeLA4i0yEQTGmBggRC5QKFsR8NGMxGTQYMGoMwOt/CH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=N0es4UrF reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="N0es4UrF" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzF5n9Qz1FgdH; Thu, 22 Jan 2026 13:10:49 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzF1GQyz1DDC3; Thu, 22 Jan 2026 13:10:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083849; bh=nupmb7DwN5GSSfjG2VlctIMK0Bsqy3N15mv4BCL+2aY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N0es4UrFjCHccec7Br0nj90q1NRZiQTOeG9CCQQq/ZT684PY5euIer2O90yjHaDZ/ fNcL2GbHP4NNxkKbuBqMcaF0Km/Ro7mk9ORg81gK4XT9Sg0BXt2tdM5+xGTwXoi8in dthvu4TKHin9HgOk/smUUzX1XoiOpLS+J/LOVRidMdwoBF+DBV7h5RW4ntWrH5gtOH IKUttCYYyMkycihydfdTM9sv9Z4TKdF7PlOwNZtnNKu83qC0DlZ62CPVz8BM1tyaNG SVn/N/C60vKHLMenNx+4cHayApLitE/mXx3C67ThFgKkfHfnzdZFwNz8KhELRx/zE8 YjtisUYR9dBZw== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Daniel Hellstrom , Arun Muthusamy Subject: [PATCH v3 11/15] can: grcan: Reserve space between cap and next register to align with address layout Date: Thu, 22 Jan 2026 13:10:34 +0100 Message-ID: <20260122121038.7910-12-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Hellstrom Reserves space between the capability register and the next register within the GRCAN driver to align with the hardware address layout. Signed-off-by: Daniel Hellstrom Signed-off-by: Arun Muthusamy --- drivers/net/can/grcan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 0ee6e9bfbe7f..e99a8c2bffc6 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -49,7 +49,8 @@ struct grcan_registers { u32 conf; /* 0x00 */ u32 stat; /* 0x04 */ u32 ctrl; /* 0x08 */ - u32 __reserved1[GRCAN_RESERVE_SIZE(0x08, 0x18)]; + u32 cap; /* 0x0c */ + u32 __reserved1[GRCAN_RESERVE_SIZE(0x0c, 0x18)]; u32 smask; /* 0x18 - CanMASK */ u32 scode; /* 0x1c - CanCODE */ u32 __reserved2[GRCAN_RESERVE_SIZE(0x1c, 0x40)]; --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BD7443DA59; Thu, 22 Jan 2026 12:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083862; cv=none; b=GDeYB+pSRQpwhAOwpMv6Pkmv/fEaneO9v3sKvzVx601oRpF3GKAwjfn4Cfqa6NlCZ/i2vQ9HCfq1Ym4K1lX7KhfBr18HNGnYGBYwUii33SXShYTtywzchdguexUm1oDNhoq/KgOA7BP4YRVtN55nUlnvcVd1n75cKk23PdUrPcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083862; c=relaxed/simple; bh=vA7Bn/T3MRsg5KZ3x1qZfVZ2mW8VIC/LyFcEFlwEwvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CpoM+FUkWzuw3SNm9GXeMpWLNBMXB1Lig5e+AygwSDtfp8Gdy+M2gHNbA2TUIwYDtU4lxg3YhvOvWJwulhBsxid1xCVNz+BYjzOmOjqSV7Yw3qvxCVEQznl3pXO0SW0UE2cCnESV1C+xTroyqMFlnRihMDYUni+9d1oA4M8pS3I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=APk/YhVs reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="APk/YhVs" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzG1Ck6z1FlXv; Thu, 22 Jan 2026 13:10:50 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzF5ZxWz1FDXb; Thu, 22 Jan 2026 13:10:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083850; bh=pEzKnxcYuoOsnjOFZzfSF3b1bjVYx5kW8HBT6p9Mnqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=APk/YhVsH8MD6neQqao1VBk08TH1qmTT7PFXxwv9WR7LI/XndpYVMnAIMK2RHJci1 C1VQpfqbe+wQC6KetoTxy8uNfK1BoN9jlpUpSgOpPWSFgUeUy6/wleu4OCpUwNEuQm KmR7BamKQKbtdsE8aMQlzsqxGsiFDJVc5t9MJMeqvXqEIREErgD1ReUkoA/p/4IjUP ADgZWBVrvGQ5FYr3LD0l4dt9jEFggPf2byXJ+EbLK0k1HfzJkV3Utml53kJSP95mwo Os3+V3AO7GhZ9Dt9I6lbyE871OgX2hqb++SzFoq8HuZGZf36dOkouSj8bXCggxIvaR CLvM0ZBdMuoig== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Arun Muthusamy Subject: [PATCH v3 12/15] can: grcan: Advertise CANFD capability Date: Thu, 22 Jan 2026 13:10:35 +0100 Message-ID: <20260122121038.7910-13-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Advertise CANFD capability for GRCANFD hardware by enabling CAN_CTRLMODE_FD flag and providing CANFD timing operations. Signed-off-by: Arun Muthusamy --- drivers/net/can/grcan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index e99a8c2bffc6..9fc18064fab1 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -1656,11 +1656,14 @@ static int grcan_setup_netdev(struct platform_devic= e *ofdev, priv->ofdev_dev =3D &ofdev->dev; priv->regs =3D base; priv->can.bittiming_const =3D hwcap->bt_const; + priv->can.fd.data_bittiming_const =3D hwcap->bt_const; priv->can.do_set_mode =3D grcan_set_mode; priv->can.do_get_berr_counter =3D grcan_get_berr_counter; priv->can.clock.freq =3D ambafreq; priv->can.ctrlmode_supported =3D CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_ONE_SHOT; + if (hwcap->fd) + priv->can.ctrlmode_supported |=3D CAN_CTRLMODE_FD; priv->need_txbug_workaround =3D txbug; priv->hwcap =3D hwcap; =20 --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9333943634A; Thu, 22 Jan 2026 12:10:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083863; cv=none; b=NZU3n4Kj9gqNMtggKXZry7nxPctShVSdBmYoXlAOXqrsG/+w1xS6HG0k+84a6y2PSHuKADdNXdQ0E93GnZ+/K3mq8e9Ti8r3CWZGyK2yBsNmSW7o/xzSYxkZDyb+gKzZobogdwjcLM1Sj6Ekkl53USsv+B3PmJY51Oe9it2OC8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083863; c=relaxed/simple; bh=XhfqXG/GA5qfp1zS4RrMnh9Rpl6PePJ2REwVKnmb4Xo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s0JPTDr1oWSc8Vyhw91GYRUPdltpmvfPKHhhCl3FILWBZpatcpQ1+nUCW3ezX7rOF+5v1hz9kkmTdwrIyIRHd2+YnBsNZGzXWv5d1WsKMUOb1oSJAMX5zp0e3eg0oZSZKoAMbdsjDXVyXkVtMThIAUR4qxVBn1nSuMqGo6N5Kks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=ovn6rWOr reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="ovn6rWOr" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzG2ty2z1FDXl; Thu, 22 Jan 2026 13:10:50 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzG0kCXz1DHbf; Thu, 22 Jan 2026 13:10:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083850; bh=eUp2qOvFQCwqoiY/xIcrHbhbjUDJgP1zcgG5WtjOJIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ovn6rWOrCI0S+/MUkCxLbgGIc1v8g6r6UCa5cbJf7LZIms7pqtFx379v3sj5Dl1gQ qcQrxe3k4i1FSEagU5ytJp1zeS5V6VxKiktp5+M4b42cmBW0p+ffN5r3jl5HPl0AMc FNYpX6car+ekQp+fbVnp6+Ax8YSRBdA7bOl4CsbMgv8Ti4YlDOUMVuN12xGfw6L0Va x8OJkHwNpA3kNM0/Dq9VYMmndGSb5S95Fz5t114Gkc6VsfBwwinmcjFqfOFyJOEm4a cU2wsIr0GdsVaWBlOBrgZrHz+aTY9da5DElntif2WPyoAMt9gfh9g/bhOzEWlzkI+H SlHcpiZ1lXAWw== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Arun Muthusamy Subject: [PATCH v3 13/15] can: grcan: Add CANFD TX support alongside legacy CAN Date: Thu, 22 Jan 2026 13:10:36 +0100 Message-ID: <20260122121038.7910-14-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Include CANFD TX support with the legacy CAN support, enabling support for extended data payloads to provide higher bit rates. Signed-off-by: Arun Muthusamy --- drivers/net/can/grcan.c | 102 +++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 28 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 9fc18064fab1..508ad5320cff 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -174,6 +174,7 @@ struct grcan_registers { #define GRCAN_IRQ_DEFAULT (GRCAN_IRQ_RX | GRCAN_IRQ_TX | GRCAN_IRQ_ERRORS) =20 #define GRCAN_MSG_SIZE 16 +#define GRCAN_CLASSIC_DATA_SIZE 8 =20 #define GRCAN_MSG_IDE 0x80000000 #define GRCAN_MSG_RTR 0x40000000 @@ -195,6 +196,10 @@ struct grcan_registers { #define GRCAN_MSG_OFF 0x00000002 #define GRCAN_MSG_PASS 0x00000001 =20 +#define GRCAN_MSG_EID_MASK GENMASK(28, 0) +#define GRCAN_MSG_BID_MASK GENMASK(28, 18) +#define GRCAN_MSG_DLC_MASK GENMASK(31, 28) + #define GRCAN_BUFFER_ALIGNMENT 1024 #define GRCAN_DEFAULT_BUFFER_SIZE 1024 #define GRCAN_VALID_TR_SIZE_MASK 0x001fffc0 @@ -227,6 +232,9 @@ struct grcan_registers { #define GRCANFD_FDBTR_PS2_BIT 5 #define GRCANFD_FDBTR_SJW_BIT 0 =20 +#define GRCAN_TX_BRS BIT(25) +#define GRCAN_TX_FDF BIT(26) + /* Hardware capabilities */ struct grcan_hwcap { /* CAN-FD capable, indicates GRCANFD IP. @@ -1218,6 +1226,13 @@ static void grcan_transmit_catch_up(struct net_devic= e *dev) spin_unlock_irqrestore(&priv->lock, flags); } =20 +static int grcan_numbds(int len) +{ + if (len <=3D GRCAN_CLASSIC_DATA_SIZE) + return 1; + return 1 + ((len - GRCAN_CLASSIC_DATA_SIZE + GRCAN_MSG_SIZE) / GRCAN_MSG_= SIZE); +} + static int grcan_receive(struct net_device *dev, int budget) { struct grcan_priv *priv =3D netdev_priv(dev); @@ -1400,15 +1415,22 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff = *skb, struct net_device *dev) { struct grcan_priv *priv =3D netdev_priv(dev); - struct grcan_registers __iomem *regs =3D priv->regs; + struct grcan_registers __iomem *regs; + u32 eff, rtr, dlc, tmp, err, can_id; struct grcan_dma *dma =3D &priv->dma; - struct can_frame *cf =3D (struct can_frame *)skb->data; + u32 bds, copy_len, payload_offset; u32 id, txwr, txrd, space, txctrl; - int slotindex; - u32 *slot; - u32 rtr, eff, dlc, tmp, err; + struct canfd_frame *cfd; + struct can_frame *cf; unsigned long flags; - u32 oneshotmode =3D priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT; + u32 oneshotmode; + u8 *payload; + u32 *slot; + u8 len; + int i; + + regs =3D priv->regs; + oneshotmode =3D priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT; =20 if (can_dev_dropped_skb(dev, skb)) return NETDEV_TX_OK; @@ -1419,6 +1441,18 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *= skb, if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) return NETDEV_TX_BUSY; =20 + cfd =3D (struct canfd_frame *)skb->data; + len =3D cfd->len; + can_id =3D cfd->can_id; + payload =3D cfd->data; + + if (can_is_canfd_skb(skb)) { + dlc =3D can_fd_len2dlc(len); + } else { + cf =3D (struct can_frame *)skb->data; + dlc =3D can_get_cc_dlc(cf, priv->can.ctrlmode); + } + /* Reads of priv->eskbp and shut-downs of the queue needs to * be atomic towards the updates to priv->eskbp and wake-ups * of the queue in the interrupt handler. @@ -1427,9 +1461,7 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *s= kb, =20 txwr =3D grcan_read_reg(®s->txwr); space =3D grcan_txspace(dma->tx.size, txwr, priv->eskbp); - - slotindex =3D txwr / GRCAN_MSG_SIZE; - slot =3D dma->tx.buf + txwr; + bds =3D grcan_numbds(len); =20 if (unlikely(space =3D=3D 1)) netif_stop_queue(dev); @@ -1445,24 +1477,39 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff = *skb, return NETDEV_TX_BUSY; } =20 - /* Convert and write CAN message to DMA buffer */ - eff =3D cf->can_id & CAN_EFF_FLAG; - rtr =3D cf->can_id & CAN_RTR_FLAG; - id =3D cf->can_id & (eff ? CAN_EFF_MASK : CAN_SFF_MASK); - dlc =3D cf->len; - if (eff) - tmp =3D (id << GRCAN_MSG_EID_BIT) & GRCAN_MSG_EID; - else - tmp =3D (id << GRCAN_MSG_BID_BIT) & GRCAN_MSG_BID; - slot[0] =3D (eff ? GRCAN_MSG_IDE : 0) | (rtr ? GRCAN_MSG_RTR : 0) | tmp; + payload_offset =3D 0; + for (i =3D 0; i < bds; i++) { + slot =3D dma->tx.buf + txwr; + memset(slot, 0, GRCAN_MSG_SIZE); + + if (i =3D=3D 0) { + eff =3D can_id & CAN_EFF_FLAG; + rtr =3D can_id & CAN_RTR_FLAG; + id =3D can_id & (eff ? CAN_EFF_MASK : CAN_SFF_MASK); + if (eff) + tmp =3D FIELD_PREP(GRCAN_MSG_EID_MASK, id); + else + tmp =3D FIELD_PREP(GRCAN_MSG_BID_MASK, id); + slot[0] =3D (eff ? GRCAN_MSG_IDE : 0) | (rtr ? GRCAN_MSG_RTR : 0) | tmp; + slot[1] =3D FIELD_PREP(GRCAN_MSG_DLC_MASK, dlc); + if (can_is_canfd_skb(skb)) { + slot[1] |=3D GRCAN_TX_FDF; + if (cfd->flags & CANFD_BRS) + slot[1] |=3D GRCAN_TX_BRS; + } =20 - slot[1] =3D ((dlc << GRCAN_MSG_DLC_BIT) & GRCAN_MSG_DLC); - slot[2] =3D 0; - slot[3] =3D 0; - if (dlc > 0) - memcpy(&slot[2], cf->data, sizeof(u32)); - if (dlc > 4) - memcpy(&slot[3], cf->data + 4, sizeof(u32)); + copy_len =3D min(len, 8); + memcpy(&slot[2], payload, copy_len); + payload_offset +=3D copy_len; + } else { + copy_len =3D min(len - payload_offset, GRCAN_MSG_SIZE); + memcpy(slot, payload + payload_offset, copy_len); + payload_offset +=3D copy_len; + } + txwr +=3D GRCAN_MSG_SIZE; + if (txwr >=3D dma->tx.size) + txwr -=3D dma->tx.size; + } =20 /* Checking that channel has not been disabled. These cases * should never happen @@ -1504,8 +1551,7 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *s= kb, wmb(); =20 /* Update write pointer to start transmission */ - grcan_write_reg(®s->txwr, - grcan_ring_add(txwr, GRCAN_MSG_SIZE, dma->tx.size)); + grcan_write_reg(®s->txwr, txwr); =20 return NETDEV_TX_OK; } --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47B5D42980B; Thu, 22 Jan 2026 12:10:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083863; cv=none; b=imKunIrSH6ml5zmpCnYgvwnV+cfhOOkwz/qtVDtxYqPPXdiSRKSDoKy2qj/fIjmTvUWonjDrkzRwaAGNNrkG6OkfcamI62Ij8OlZS7vwP/UCXm15gPjOGh1SLxsyfTR8U3KjB8WBy0DNCzvQI8tyZvUqE6o6eCNus2XlAC/Kh8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083863; c=relaxed/simple; bh=PPk0WF5n99PlZvu7ZVeG5vXsJf7I/nzmRYtNPqeY/+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gUa4P5H7jj3TYJ/VU7n3F6sQmOzhM8lSY3mR6R3P5xVVTWksv0vhSyawFOZtNB7kXfS4EzZBzRo5Of7if4CpLkl5HCT5z0n0yM5irEr7zjRLTvTbzVEuOVDJwTGf6yf/uN35Y1x7iO8lteExbKm5B8o/a0+CUrX+Ok5wKgRWWnc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=N9pQKyt7 reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="N9pQKyt7" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzG50J3z1Fgd9; Thu, 22 Jan 2026 13:10:50 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzG2XpPz1DDC3; Thu, 22 Jan 2026 13:10:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083850; bh=cQecUzHZA3Ag9x7xgx5LRp21VuGFauFPBsaAtimBgwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N9pQKyt7wLTqxqges2RLYWUnpR2+5BG6NICOmjaBUjnKqatz+VMuj0REeDafSJJ5h xPcqQapUPjmNtrHrmoSznjVBBhCTCpn8KtkYuHC2x8yDvUAqZwQ+eiBwQEazj9yuiO 5YqY1QS6GoyVnxInF0QolPQU0k7mewZs0pF7wXBhsStsD5VeseuOdm/kYcpoET/op8 qwfx8vq5xuKdSy7axBM0UO208hwnmGMTCmKh3ZKo2oauJrDnTxjfjGTNuDlzlmoZqs T1Y4qva7jrs2IY+THg2W9dbUoHWQRf6SEDtTKruaNwVQQj7Xe7HAtxwjcWMS6dZK5j BuDAvN3P+5K4w== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Arun Muthusamy Subject: [PATCH v3 14/15] can: grcan: Add CANFD RX support alongside legacy CAN Date: Thu, 22 Jan 2026 13:10:37 +0100 Message-ID: <20260122121038.7910-15-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Include CANFD RX support with the legacy CAN support, enabling support for extended data payloads to provide higher bit rates. Signed-off-by: Arun Muthusamy --- drivers/net/can/grcan.c | 98 +++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 33 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 508ad5320cff..39afb12c50d0 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -235,6 +235,9 @@ struct grcan_registers { #define GRCAN_TX_BRS BIT(25) #define GRCAN_TX_FDF BIT(26) =20 +#define GRCAN_RX_BRS BIT(25) +#define GRCAN_RX_FDF BIT(26) + /* Hardware capabilities */ struct grcan_hwcap { /* CAN-FD capable, indicates GRCANFD IP. @@ -1235,18 +1238,22 @@ static int grcan_numbds(int len) =20 static int grcan_receive(struct net_device *dev, int budget) { + struct net_device_stats *stats =3D &dev->stats; struct grcan_priv *priv =3D netdev_priv(dev); - struct grcan_registers __iomem *regs =3D priv->regs; + struct grcan_registers __iomem *regs; struct grcan_dma *dma =3D &priv->dma; - struct net_device_stats *stats =3D &dev->stats; - struct can_frame *cf; + u32 bds, copy_len, payload_offset; + u32 wr, rd, dlc, startrd; + struct canfd_frame *cf; + int i, work_done =3D 0; struct sk_buff *skb; - u32 wr, rd, startrd; - u32 *slot; u32 rtr, eff; - int work_done =3D 0; + u32 *slot; + u8 *data; =20 + regs =3D priv->regs; rd =3D grcan_read_reg(®s->rxrd); + startrd =3D rd; for (work_done =3D 0; work_done < budget; work_done++) { /* Check for packet to receive */ @@ -1254,43 +1261,68 @@ static int grcan_receive(struct net_device *dev, in= t budget) if (rd =3D=3D wr) break; =20 - /* Take care of packet */ - skb =3D alloc_can_skb(dev, &cf); - if (skb =3D=3D NULL) { + slot =3D dma->rx.buf + rd; + + if (slot[1] & GRCAN_RX_FDF) + skb =3D alloc_canfd_skb(dev, &cf); + else + skb =3D alloc_can_skb(priv->dev, (struct can_frame **)&cf); + + if (unlikely(!skb)) { netdev_err(dev, "dropping frame: skb allocation failed\n"); stats->rx_dropped++; continue; } =20 - slot =3D dma->rx.buf + rd; - eff =3D slot[0] & GRCAN_MSG_IDE; - rtr =3D slot[0] & GRCAN_MSG_RTR; - if (eff) { - cf->can_id =3D ((slot[0] & GRCAN_MSG_EID) - >> GRCAN_MSG_EID_BIT); - cf->can_id |=3D CAN_EFF_FLAG; - } else { - cf->can_id =3D ((slot[0] & GRCAN_MSG_BID) - >> GRCAN_MSG_BID_BIT); + dlc =3D FIELD_GET(GRCAN_MSG_DLC_MASK, slot[1]); + if (slot[1] & GRCAN_RX_FDF) + cf->len =3D can_fd_dlc2len(dlc); + else + cf->len =3D can_cc_dlc2len(dlc); + + bds =3D grcan_numbds(cf->len); + payload_offset =3D 0; + data =3D cf->data; + + for (i =3D 0; i < bds; i++) { + slot =3D dma->rx.buf + rd; + + if (i =3D=3D 0) { + eff =3D slot[0] & GRCAN_MSG_IDE; + rtr =3D slot[0] & GRCAN_MSG_RTR; + if (eff) { + cf->can_id =3D FIELD_GET(GRCAN_MSG_EID_MASK, slot[0]); + cf->can_id |=3D CAN_EFF_FLAG; + } else { + cf->can_id =3D FIELD_GET(GRCAN_MSG_BID_MASK, slot[0]); + } + if (rtr) + cf->can_id |=3D CAN_RTR_FLAG; + + dlc =3D FIELD_GET(GRCAN_MSG_DLC_MASK, slot[1]); + if (slot[1] & GRCAN_RX_FDF) + cf->len =3D can_fd_dlc2len(dlc); + else + cf->len =3D can_cc_dlc2len(dlc); + + copy_len =3D min(cf->len, GRCAN_CLASSIC_DATA_SIZE); + memcpy(data, &slot[2], copy_len); + payload_offset +=3D copy_len; + } else { + copy_len =3D min(cf->len - payload_offset, GRCAN_MSG_SIZE); + memcpy(data + payload_offset, slot, copy_len); + payload_offset +=3D copy_len; + } + rd +=3D GRCAN_MSG_SIZE; + if (rd >=3D dma->rx.size) + rd -=3D dma->rx.size; } - cf->len =3D can_cc_dlc2len((slot[1] & GRCAN_MSG_DLC) - >> GRCAN_MSG_DLC_BIT); - if (rtr) { - cf->can_id |=3D CAN_RTR_FLAG; - } else { - if (cf->can_dlc > 0) - memcpy(cf->data, &slot[2], sizeof(u32)); - if (cf->can_dlc > 4) - memcpy(cf->data + 4, &slot[3], sizeof(u32)); =20 - stats->rx_bytes +=3D cf->len; - } + /* Update statistics and read pointer */ stats->rx_packets++; - + stats->rx_bytes +=3D cf->len; netif_receive_skb(skb); - - rd =3D grcan_ring_add(rd, GRCAN_MSG_SIZE, dma->rx.size); } =20 /* Make sure everything is read before allowing hardware to --=20 2.51.0 From nobody Mon Feb 9 03:16:31 2026 Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7130449ECA; Thu, 22 Jan 2026 12:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083865; cv=none; b=Id4p3i+zzPcdVAeS0pmU6Z6ttIe5InmnyaCF1j9Xe3EgBwLfnNth9Dwqp3yGKaERjMBzcWNxIMwpIdu74Yvrlr8TXLcsKw70MVO6jG8cIDagbTo4srK+iUpzObMDQ6C/tsYUkE3hPMPcb9rOovwazBRdYysr4YdTaPz4bkwCaFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769083865; c=relaxed/simple; bh=yzu11Z57nTas90/09+nK6ANfPzkmv2++yiMJl9jG0KU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CEYbaWxaOYWdpISLSIegXjsFnlPWip7NVqTHcym31Aoy8jDFbTlhDfN1y6qm2ajmQUNUQlrWUtYbylBxMBVYPPpxNXhaZbr1aNyhHarI1okyJcaV9B9v3upbC5w/eKibt7E+teFV78PGrvA8ic5mW/uRFxXbYRwwYBxzdLLSESI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=fail (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=oHwIpGZT reason="key not found in DNS"; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="oHwIpGZT" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4dxfzG6Y8Rz1FlY3; Thu, 22 Jan 2026 13:10:50 +0100 (CET) Received: from d-5xj5g74.got.gaisler.com.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4dxfzG4WSlz1FlY1; Thu, 22 Jan 2026 13:10:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769083850; bh=Ifj/YMFPcPFEro+213ka+sB+HgXHGlvN61oSA9++Mfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oHwIpGZTpG3v42jznLEsQ3TJ0pb5TXdBS4XK0RU35PzoPMSblXHduooaz6fPhK5w3 oLTUkxdRQA2eMehvMnk0JFUpjjsKy/WEyOJvOWwRSBDle3FsSbu2EJxEGor6WJYeuk 6FRVv49B4dMGvMnv6ne38k05XSaZ3bJk+dN1D9NuSO67CD2uPAqYUPWYnCnV8TYqO3 c56M8UUmEibv1x0mZcMLvrfQsFvbBtS+Fdu9NtuHj3DVXzYc5fSEm5oY9SR7XYDtn/ zRNJ1mkZnjo6lOGxVPZRuepQNaUTD3bY/V2s6Ktrj7k+9I/HXac1JF7yF0c4EfNnh7 C9Ov8n0LjTsKQ== From: Arun Muthusamy To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, mkl@pengutronix.de, mailhol@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-can@vger.kernel.org, Arun Muthusamy Subject: [PATCH v3 15/15] can: grcan: Update echo skb handling to match variable length CANFD frame Date: Thu, 22 Jan 2026 13:10:38 +0100 Message-ID: <20260122121038.7910-16-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260122121038.7910-1-arun.muthusamy@gaisler.com> References: <20260122121038.7910-1-arun.muthusamy@gaisler.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor echo socket buffer management by introducing dedicated indices for current and next echo slots. - Introduce "echo_skb_idx" to keep track of the current packet index in the echo buffer, and "next_echo_idx" for the next available slot. - Adjust memory allocation for echo skb to calculate the number of slots based on slot size. - Enhance logic in catch_up_echo_skb() to correctly process and free echo skbs. - Initialize "next_echo_idx" in grcan_set_mode() to ensure proper starting conditions when the device enters proper modes. - Improve memory and index handling in grcan_start_xmit() and added a check to stop the network queue when necessary. Signed-off-by: Arun Muthusamy --- drivers/net/can/grcan.c | 51 ++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 39afb12c50d0..22c86e5d7002 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -298,6 +298,15 @@ struct grcan_priv { =20 struct sk_buff **echo_skb; /* We allocate this on our own */ =20 + /* + * Since the CAN FD frame has a variable length, this variable is used + * to keep track of the index of the CAN echo skb (socket buffer) frame. + */ + u32 echo_skb_idx; + + /* Next echo skb free slot index */ + u32 next_echo_idx; + /* The echo skb pointer, pointing into echo_skb and indicating which * frames can be echoed back. See the "Notes on the tx cyclic buffer * handling"-comment for grcan_start_xmit for more details. @@ -578,7 +587,7 @@ static int catch_up_echo_skb(struct net_device *dev, in= t budget, bool echo) struct grcan_registers __iomem *regs =3D priv->regs; struct grcan_dma *dma =3D &priv->dma; struct net_device_stats *stats =3D &dev->stats; - int i, work_done; + int work_done; =20 /* Updates to priv->eskbp and wake-ups of the queue needs to * be atomic towards the reads of priv->eskbp and shut-downs @@ -589,19 +598,22 @@ static int catch_up_echo_skb(struct net_device *dev, = int budget, bool echo) for (work_done =3D 0; work_done < budget || budget < 0; work_done++) { if (priv->eskbp =3D=3D txrd) break; - i =3D priv->eskbp / GRCAN_MSG_SIZE; - if (echo) { - /* Normal echo of messages */ - stats->tx_packets++; - stats->tx_bytes +=3D can_get_echo_skb(dev, i, NULL); - } else { - /* For cleanup of untransmitted messages */ - can_free_echo_skb(dev, i, NULL); - } =20 priv->eskbp =3D grcan_ring_add(priv->eskbp, GRCAN_MSG_SIZE, dma->tx.size); txrd =3D grcan_read_reg(®s->txrd); + + /* Grab the packet once the packet is send or free untransmitted packet= */ + if (priv->eskbp =3D=3D txrd) { + if (echo) { + /* Normal echo of messages */ + stats->tx_packets++; + stats->tx_bytes +=3D can_get_echo_skb(dev, priv->echo_skb_idx, NULL); + } else { + /* For cleanup of untransmitted messages */ + can_free_echo_skb(dev, priv->echo_skb_idx, NULL); + } + } } return work_done; } @@ -1109,6 +1121,7 @@ static int grcan_set_mode(struct net_device *dev, enu= m can_mode mode) if (!(priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)) netif_wake_queue(dev); } + priv->next_echo_idx =3D 0; spin_unlock_irqrestore(&priv->lock, flags); return err; } @@ -1120,6 +1133,7 @@ static int grcan_open(struct net_device *dev) struct grcan_priv *priv =3D netdev_priv(dev); struct grcan_dma *dma =3D &priv->dma; unsigned long flags; + u32 nr_echo_slots; int err; =20 /* Allocate memory */ @@ -1130,13 +1144,15 @@ static int grcan_open(struct net_device *dev) return err; } =20 - priv->echo_skb =3D kcalloc(dma->tx.size, sizeof(*priv->echo_skb), + nr_echo_slots =3D dma->tx.size / GRCAN_MSG_SIZE; + + priv->echo_skb =3D kcalloc(nr_echo_slots, sizeof(*priv->echo_skb), GFP_KERNEL); if (!priv->echo_skb) { err =3D -ENOMEM; goto exit_free_dma_buffers; } - priv->can.echo_skb_max =3D dma->tx.size; + priv->can.echo_skb_max =3D nr_echo_slots; priv->can.echo_skb =3D priv->echo_skb; =20 /* Get can device up */ @@ -1575,7 +1591,16 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *= skb, * can_put_echo_skb would be an error unless other measures are * taken. */ - can_put_echo_skb(skb, dev, slotindex, 0); + + priv->echo_skb_idx =3D priv->next_echo_idx; + + can_put_echo_skb(skb, dev, priv->next_echo_idx, 0); + + /* Move to the next index in the echo skb buffer */ + priv->next_echo_idx =3D (priv->next_echo_idx + 1) % priv->can.echo_skb_ma= x; + + if (priv->can.echo_skb[priv->echo_skb_idx]) + netif_stop_queue(dev); =20 /* Make sure everything is written before allowing hardware to * read from the memory --=20 2.51.0