From nobody Mon Feb 9 01:35:50 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 AE96D28C849; Wed, 28 Jan 2026 14:49:28 +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=1769611772; cv=none; b=bqcdyRwm8Uo4JLBcCiuSm+0yD2KYutLSy8Q8HvxibthA1an9+apItwHpH5ceSdMzAf4RdD4ueDvaHhTg5DVLaxlJSmnfz9w2i7YDGVUCpEZnfNR5LdNoH4gKVAcaZ99Uk8KWp44xJwa5JkblLT2cHCaKn4u8YUO9X1EXuZs75jA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611772; c=relaxed/simple; bh=clW+1YVLmkB8gfJe5CXe5vWkV6Gyr4z+up8cHS4TKMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lPPJPQfnq/L5FqOLYMR9UCTnNoBNGmJbLLlz5Lb83mgo+SMqY0IpQ81YUycBCnQl4c42faoeL+fr+PYdniGY07MXyWl7XUAdJ55aNeqiaXads7xAERkryqUK66TjHy0J4ZoaQuHdrCHkFDr87AF9w/vHbAzc4WmXL5rdYSqXPf0= 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=Tup0J71O 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="Tup0J71O" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCW1Ysgz1FDXn; Wed, 28 Jan 2026 15:49:27 +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 4f1QCV4l4hz1FDXX; Wed, 28 Jan 2026 15:49:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611767; bh=iX7VqUaWibeG9wCWEco8lmK+AEYcMSSoBfhahTDCOrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Tup0J71OEqijq8H85ABDAi14+5nlo+byaDZhqE0Q331l+Ch2O1YwQeR7GQThBAzmr xWBXLS7B15QyZFBb/joLeGCEMDIZIb6MwlQbAErH8oeHRxd8ZHq+1Q+z2VHzoRc83l fr+tdfqAiMcnjsiVwY1qJcWE/s8XaRqxTFZBUqGWyL0MJaQKTONZAqdleH4qXl5Ri1 2E+VxtvxUVSjzkQPHb/t7AJO+guK6UYb5mZGM2TSQKbV2OK3HA0iZqGlg/R+OtgLEr o0rNXJ1StySFS5n5fqU7JjWiawdZjpFK+ch4/UkDghDQuQEP4EoFXp3qzXv7Z7xqpf pWomeP2wOJpvg== 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 v4 01/15] dt-bindings: Add vendor prefix for Frontgrade Gaisler AB Date: Wed, 28 Jan 2026 15:49:07 +0100 Message-ID: <20260128144921.5458-2-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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: Arun Muthusamy Acked-by: Krzysztof Kozlowski Signed-off-by: Ludwig Rydberg --- 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,.*": -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 0A0FC29C351; Wed, 28 Jan 2026 14:49:28 +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=1769611772; cv=none; b=hzpX8OeZMK1R2W8eSadvQLL8bwMs4BmBqMr7TRk1+xTsrzsw619tIfLxLAYDF3DIP4MvxAo13YjGmdqRnL6/4W2u5HsUAhstEzEdEEQ3PTYMlV3C7TuAlJZiXV/LioNiVpxO13gafwuJ7SLx5lXGz9kpr1PsdG5adqJm/hg6zC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611772; c=relaxed/simple; bh=uH8Pe/J7AVvgFk9GqJLL0H34VTUppg+JpzhlnZrGObA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QdQw09SEbT/5vtEZBCEnQQbjaCKDTN7FWVzBbNJHGFkNyGsx4Dx+/wUYn+bbHXMJ1uxMFlaKFYWBquoJ217MQ5zt12D5uYWnOEgj9vbOXUzE/xS/18MlJot7/Ex3POQiOIR8eWcYzxBNtlZNtWUFUXRN19zmp6m7kvlhx58nOd8= 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=ZNd9ZPke 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="ZNd9ZPke" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCW3FCGz1FDY7; Wed, 28 Jan 2026 15:49:27 +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 4f1QCW1Hbcz1DR2b; Wed, 28 Jan 2026 15:49:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611767; bh=YB2t286nraRNB5mAmjhOvxJnKyocZr4eSz/qausgjto=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZNd9ZPkev3ttYRPfGxomxqvO/DD7VdiQjW3u/5FVU8PievEAU3tvPsX6j97LeBJDt R/80fkUGSFz9bxpTHrA0bOjN95a/i7Ko4x6EO1gJn2mDJtsWULNOp6VrVh1g9iuXcG hk8pAV10ZXYC2F5n8vwlbUgZKxxNUd1QeBNCrLZzK288TiWsWtAWpJzmULrGYVHrRe rn71B4T89V+iSzRnTa2T7C79J8crg+HwG9ngk4CjNtdvV58vq2+jbFsFS1jLmj8WrA p4VHkDK3ZPDqEpt15n6bMq2+5n9p02fiWt/R5O12AooU6oMo3GYi1xOCB0x2kVj2KN Vn75NtkcSfggA== 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 v4 02/15] net: can: Convert gaisler,grcan to DT schema Date: Wed, 28 Jan 2026 15:49:08 +0100 Message-ID: <20260128144921.5458-3-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 Reviewed-by: Rob Herring (Arm) Signed-off-by: Arun Muthusamy --- .../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 -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 57C8A2D7DD9; Wed, 28 Jan 2026 14:49:29 +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=1769611771; cv=none; b=PGmfTGklx+XjfhXejWscuY/fHJJDZNqG/2ag+axT89MZX6yfcAAjAuuNEtOBD2Rsjy+Net6RCOTzSSKN7ijOK2KvK0hCKzqf/jOlmz17dZemo4Do8rSxfe0c3JPv5/XXp6ZDOlPL8oWb14z/yywq8EFE3wTlz09BWQv4fI7Ekas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611771; c=relaxed/simple; bh=hG5KSuPtLiBtHjq424HSyAbeOdsq1PzCy6qL7NHd2UY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YcHaH/5bSO59QNG4VDbqPwHnezdLdHnI2o7lMFANDeJRDfz0ddFrnIlC1pNQUnArLvrtoJ0Dmk0qmQALIWOpPWx2wGF+/t4cS/bX1DgmX8Ox9Ur4PSyMASG1vQL3auRULQmBzzzlkQireuRIi8e0/dt3FU1OAFQ8HaMKuknIgU8= 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=ABOjyo7Q 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="ABOjyo7Q" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCW5Fs9z1FQVL; Wed, 28 Jan 2026 15:49:27 +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 4f1QCW2wNDz1FDXy; Wed, 28 Jan 2026 15:49:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611767; bh=lDfZgx61aSWUJ1n5uo3C1KLCGawncX5ACzgdlX+fljk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ABOjyo7QCcN2HGH0fm3FRdny/3vvaVZWTkqL4lqQhBzoCM+DhDuqRpDWeXIJqNp4+ UOhuoArUJRZqkZmAFSUG/2pE2c8JeapbHNeYDnBWH0ScylT6OHE+d0B0OicLywx4X/ Z4YbLblIGRV463eByBUoypSLPuO/ZceHOfpg4M/jZ5pt8rgPB3GN+2EOdnMNNoYjZT JtLY+frHPZSRfcbJZMAo9FI2r8MvUpZPFrccokFnxRL0fvnc7JOQ5w4kVzOgEvCgt9 pF7Vi0fS2s+Pmu5LzOR7RL8xaSPdc2Vz7u44vWO8SVJEwaIVJA6WryFdYsJJn1UYAw sT6Iht4IGvg+Q== 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 v4 03/15] MAINTAINERS: Add maintainers for GRCAN CAN network driver Date: Wed, 28 Jan 2026 15:49:09 +0100 Message-ID: <20260128144921.5458-4-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 01:35:50 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 57BCA2D7D30; Wed, 28 Jan 2026 14:49:29 +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=1769611771; cv=none; b=UoVK0j3okwnkUgwnWC+NskA5fdz/v6KQ7OeRAd3QKb8E1596NTzKZ2GpR9XJC78Nom44rjsXI8192FzzSOGoQwI/v8J37jhVxBmbTddGPmyoQ4TrUTSAom+py7cEVqC5Iv3Ppsc58dJiD7JEU/Ylenoab5BKdV/n8PPjD7QHWjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611771; c=relaxed/simple; bh=Aioox3rnLyBh3Qn7704KGfRcMdTIvPjXkFSn9oO5ek4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LECVE2Zjz4LqUeQGrJX8aXXM4DRU6nQ/xMnaRr/zG2zSLBlmRelbGWC2i8G5iw/Ay1NuZbrkk6i94D+zpEm6k2Caz4j9yl6l4GVlpu/r6tb7YSM/8qw87m2XWcfsgK8AN411Vbr1R01724IO8TkAY+hfXa1bPNP25i4Y2Nt5BzY= 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=Z5rxydNw 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="Z5rxydNw" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCX02QLz1FQVM; Wed, 28 Jan 2026 15:49:28 +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 4f1QCW51Tmz1FDY1; Wed, 28 Jan 2026 15:49:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611767; bh=IMU/wLjbU6RVE7LY0W7niv61k/USFwtxnDj46IVSkeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z5rxydNw4MmYE71yQiFrPFUnVE/Hjh0aAPQnQ5KHPdgRoiKihNJcv+tu5Hb5SY+Tg wEjTufmYYcZ0vG9ysPSM8MwLXee13F5O+RJKgpQHaFFVdImn/fryqbSNnj2jCTzLfe hGBpgJ5ehpNQJ0DVCIcm0GqSLlvgU0geA27r9fD9U2kO9UHrigUJDF6UrxvoZruhFb MD6vbop8Kis+2/BxG8LFfaKNN4yyOYRjaBRXJS/WaBnITEcLLYKrQbMpXUQ8BwEH7O FeCTSxo53ARNkyQXnUosACCoQBlsMaxyaSEbbWQG1YqKic32osF0qUu5xYZVKjHLpJ GyJmNpARAttLA== 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 v4 04/15] can: grcan: Add clock handling Date: Wed, 28 Jan 2026 15:49:10 +0100 Message-ID: <20260128144921.5458-5-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 3b1b09943436..f3821e224f4f 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -34,7 +34,7 @@ #include #include #include - +#include #include #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,19 @@ static int grcan_probe(struct platform_device *ofdev) 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; + } + + ambafreq =3D clk_get_rate(clk); + if (!ambafreq) { + dev_err(&ofdev->dev, "Invalid or Uninitialized clock\n"); + return -EINVAL; + } } base =3D devm_platform_ioremap_resource(ofdev, 0); -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 A434E364026; Wed, 28 Jan 2026 14:49:32 +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=1769611774; cv=none; b=CrI1AY1sXRQhFssm+X+MjxbNyKObvQhoVgy0NZLTnfWKBzuMAgmQfQkUTp0aN3Fxl35KGh+uuTHPfLtJRjqykC0Ki/fnSsh+5Z5YezM0du/TCuW5NPQG99Y62gQZYhamUwXsMK7CPCSjoqu0GDxHeXpXOoctlBdJoQKHOB53NDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611774; c=relaxed/simple; bh=L/rLTS5nZPe+MmfZKsbNjowyZgFPne1GMZzhSMt64rI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tp49kGCGFY6Ip/DgY0MzUYBv44djqBf+9soTYQwtlSJrmiSZBmm36K8Lc+IneTkoioAjAY2EcGXHoVx4qjHYka3EkUS8RoSrUjUCOeKSIvAYeqD+W2wrhlPo7NStGwG9crDtrsH5g/pXgQVksZbgRk4b/2QQur33w8MQdR1IWaw= 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=XIlJ/wpC 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="XIlJ/wpC" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCX1mwzz1FQVQ; Wed, 28 Jan 2026 15:49:28 +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 4f1QCW6tJkz1DQsp; Wed, 28 Jan 2026 15:49:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611768; bh=p+KzDx4M2gcKRYgJHx+u+LHbuSg09/20zOFN0HOSdwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XIlJ/wpCWWU20nwpPr5L4iMCDf6nSotuqGa4jncM+N/WzaVfGLVqhBWOAkGA1aYhk HuEykKjY3Qod8LyHZOS+LkPBqnwla4jM7ZJi63LQiKYKq2np7G2+Fc2d48YeF84bat kWz0zZEODRF9okEp2sZzi5qT/GiwKCprw5cJQ4PRZOabshh5PVFBfI3SEMTvnxVM7v 7LNkoNGRAO3QiE8TfhFzqxrvlUu885H86O24Bpa56XxJ5bt32swICKXW99R65HI9B3 wTZqMI2ArTROk1i71TV/zqLp7opvCmzMjdhvZ6w590t1niW7+2wKy2Y3iRN4iZUjgD GxDVZpO0Yo4iA== 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 v4 05/15] can: grcan: Replace bit timing macros with literal values Date: Wed, 28 Jan 2026 15:49:11 +0100 Message-ID: <20260128144921.5458-6-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 f3821e224f4f..12fd4911add2 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -36,6 +36,7 @@ #include #include #include +#include #define DRV_NAME "grcan" @@ -93,16 +94,6 @@ struct grcan_registers { (GRCAN_CONF_BPR | GRCAN_CONF_RSJ | GRCAN_CONF_PS1 \ | GRCAN_CONF_PS2 | GRCAN_CONF_SCALER) -#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 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, }; static int grcan_set_bittiming(struct net_device *dev) -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 A42C7364025; Wed, 28 Jan 2026 14:49:32 +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=1769611774; cv=none; b=XwnTvKLYMK5rqcSMOnY5a5keoYQ7HTLMaEk1euGiqiJPbWVrWiVB8MdmtPZl+ODQE87771ThBvaGPEs3O9h5Cn1YM4BxB/AGKg2+Go8fwZt3Bgkke7b7tDhKtt5pUXUIJ1oSTsPol6OyV+u+a2+lY9J5lnh44crd/jtVMOP0CJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611774; c=relaxed/simple; bh=b+0WcbYuxFTCDcRlD07zm6GzaI+wV68tk/uuy0A8rxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kF+DcOa42Lm+VdiQZNoK1sRWNBdJPs5aI/xGRLS38nyeDi/WDvWbP9GtNDtrK0EGJvhNm59qE/rcPkdFdWT1WJ7SeiEZsJV78QpFvYl5svGKElnEpC7GCI59PNthbET9CKv3Z+uU0chXJLmalMNVa6BHO6WzftkZAGk19F4zKn0= 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=fgDN4uDJ 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="fgDN4uDJ" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCX59NWz1FDXy; Wed, 28 Jan 2026 15:49:28 +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 4f1QCX1XXCz1FDY1; Wed, 28 Jan 2026 15:49:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611768; bh=/Cc4womNHfEVVi2feJ08kcyRKFNgj2xVLregWPcaY00=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fgDN4uDJMfSNMzGGpFsFmPpHdplSYnDJfNOBw0388q7PI0YdIZojNuaOCr9DL8ya9 klOiKvlL1c/1+0mMsGioAKA9f1bMOgoc4lQk+c3GF9emAg+rtZJFn3M+gCl9EcUeae 67qR/W/GFn4K2n4iyZXbmgpexILbEWr4aUg35nNoZ4fiU5G6ot89pAZEiWZL6Q2hRy R4NTdbPo1ei9pdVtuP/+KScjxX5XfKXeXMNWzXlao2PzR0q1lHF05rJzCvqXpC8rzH XGGJzdPQVSI1ZbxiGUNWMBFnLN22Awb7EQWX8YeTG8QfomudQIf0Tc+OlBUqjQMcY+ EKS5d6CkYP3+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 v4 06/15] can: grcan: Simplify timing configuration Date: Wed, 28 Jan 2026 15:49:12 +0100 Message-ID: <20260128144921.5458-7-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 12fd4911add2..4ed0fb1d70b7 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; - /* 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; 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); return 0; -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 A4789364037; Wed, 28 Jan 2026 14:49:32 +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=1769611776; cv=none; b=OyF5swy/WyYi6ttb6yJBiTz80r5tfTZCqJlClhDBq7D/k87fQLhA38aTZoJUyjhbJuZ8qLLrcnN3G9AJ0AGLaBIxEMyIM6pbprAA0Pi7GmgNB0eUO74TjrhZY/6vlMqrdEIOOUigDPP29trVHHXhQqN0vUIh2VMxJj4POV+TrjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611776; c=relaxed/simple; bh=RPIVoAMFk1h/d/PLuQxfQAEVIXrFvOzekbjN8qv8GIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RnObqCIdxG0rXiOw1Uz2n5BWhApt10tRyNZ7XfB3lRMOAUIw06Mn3ZYTUkfz7svlGYd4qWgjeXPVcSrr8xOzMnHR4/s4CSQeC/6THQDXhMOBvj0LAysyYnqbAYwrxTQ1xFpI/0zH9KT0+1ZR5aXKoCqLF3B9HBe4BEQtlv72V1E= 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=ZAFxrjeR 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="ZAFxrjeR" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCY1BbRz1FQVT; Wed, 28 Jan 2026 15:49:29 +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 4f1QCX4qYQz1DQsp; Wed, 28 Jan 2026 15:49:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611769; bh=YKraLCfX9sUKTKhBlpVkse1ctK5HfkR4tSodMZ5Riww=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZAFxrjeRg4sYST3Mt1pox64aOYlWH1zIU+vNxzVj4xJ+AtGvevLKGCtCuaAKOsayF kR8ll8zAXzHuHaGLnejVFB97f86JmLgWS3olivA5evmupvDdIin+w40cOkwWD5Axv9 RgS+05fTuS0jIat7Dq+LL334B1L7Aig4joD4FLmlKHrVaylUzhqdKbQJ06n0uGXb+6 qxpr91UbrPFs7YODtMeACrcmudY/3fCBimWQqCZzFw4Ylxkm+qVJOBSLVfBwy49AoA kuyRPkMBtiNhpao+KVR6yqhq2n2GiPrG1W7T9rGuyA0wGqJcBRi9nxRZJ7qFLIoUMN XKVUL/lMEStTA== 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 v4 07/15] can: grcan: add FD capability detection and nominal bit-timing Date: Wed, 28 Jan 2026 15:49:13 +0100 Message-ID: <20260128144921.5458-8-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 | 137 +++++++++++++++++++++++++++++++++++----- 2 files changed, 125 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. 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 4ed0fb1d70b7..a752aea51d96 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 +#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; struct grcan_registers __iomem *regs; /* ioremap'ed registers */ + const struct grcan_hwcap *hwcap; struct grcan_device_config config; struct grcan_dma dma; @@ -393,6 +432,19 @@ static const struct can_bittiming_const grcan_bittimin= g_const =3D { .brp_inc =3D 1, }; +/* 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 +473,32 @@ static int grcan_set_bittiming(struct net_device *dev) return 0; } +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_dbg(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 +1623,8 @@ static const struct ethtool_ops grcan_ethtool_ops =3D= { 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 +1647,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; /* Discover if triple sampling is supported by hardware */ regs =3D priv->regs; @@ -1620,22 +1699,29 @@ 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; + hwcap =3D device_get_match_data(&ofdev->dev); + /* 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); + } } err =3D of_property_read_u32(np, "freq", &ambafreq); @@ -1670,7 +1756,7 @@ static int grcan_probe(struct platform_device *ofdev) grcan_sanitize_module_config(ofdev); - 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; @@ -1697,11 +1783,30 @@ static void grcan_remove(struct platform_device *of= dev) free_candev(dev); } +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}, {}, }; -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 A43F336402C; Wed, 28 Jan 2026 14:49:32 +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=1769611774; cv=none; b=cnr1ZbGc7PuavuwG0WRYdbDCjidzDeKpyP/gsT2kkDo5pbzqHGkv7nxR3N6vLzuZjOZs4MXrvdkYPheX5+Cey7fX9DQqy6PcyU89SmNhLeLCMkioYnEeeLHhFXcNX1AI5yHAEr+xyc89oqB+44BtJhTfgR5JspntZ2hWtAz6c/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611774; c=relaxed/simple; bh=+Q2CBHQL6M1OJgngX5kKbP9z7TX9fOIWijblvbTL4iI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MJMfSoy6n8GbazFpZUHyJNPe+8/GVoLh5r0CmAdIA+q8caQ7nB9EKj3BgxKvW7XBZE4SWDN//HKbMdDOEoXCICAybu/1s0y4GFTUPqzkTQ2oc/UlpovPFQHG8OJ4rUXhUhuCrCAg3rLjn02rttal1fMEtbX6wx9TbD/p0OOKbeM= 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=Ik2if4DC 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="Ik2if4DC" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCY3QHTz1FDY1; Wed, 28 Jan 2026 15:49:29 +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 4f1QCY13Pxz1FDYD; Wed, 28 Jan 2026 15:49:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611769; bh=n1jitg9yLGLEHU7Ikk+MP1rDLSfLfCDwECBLI2mLq7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ik2if4DCJ34OkBIrnC7BXV8fhYc0uKYlLocx3ALHEJidbZJjzM2Ege8R7pjYHcAR7 HKZE77pfOP3F/946XUqKNQbc2wOm5OXWrbBjz+XfVfl2PB46QH9xFgwKZ28gTD0tPD ABMs9A8i6aaiieTr9oprpm3BXxS2DgZkLj3m/rNwuAR23FYTigTspJtlidjQ2xC51w qSF+h8l1JWG3Wrh26YNCmUp/ORp21CbNhNmvCv2daeLcrYYhn8h7nA29jTBbhQx1TF ep5MXPRX7sNfsmI5Ic3m5625nTCrD2Yo/+t3adNEiq40bSVrVqq8y+x2Cnr+9bmM0e 8Gabh/HJ7fd8A== 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 v4 08/15] can: grcan: optimize DMA by 32-bit accesses Date: Wed, 28 Jan 2026 15:49:14 +0100 Message-ID: <20260128144921.5458-9-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 a752aea51d96..29247e9860c9 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 -#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 @@ -1217,7 +1214,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; rd =3D grcan_read_reg(®s->rxrd); @@ -1253,11 +1250,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)); stats->rx_bytes +=3D cf->len; } @@ -1396,8 +1392,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; @@ -1450,11 +1445,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)); /* Checking that channel has not been disabled. These cases * should never happen -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 4C91B3644BB; Wed, 28 Jan 2026 14:49:33 +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=1769611774; cv=none; b=MCi5Y0IseKF61LFRQO9JmqF2VuxoPe9PH1Hs/uqZHjLFATGvvCzYwxGLmaUjY62qN/F+Z8yLrdME/qy0u+kaOBp/ID13YR8Ee5G424A78vu4+oanYf0Hc7rFWDevAPuEaR/MtXwFdmim9YRrUFK4BsMkfqgrXGZy0LwFIYmDCHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611774; c=relaxed/simple; bh=ypXQ3CGaxHltaC8+njiLV/XzkbBML+AAs9YiQAPtn+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SlCVj1sBsofuNZiMBiEJuqbyBxuiBn1M2b7zpnqqbgWn2l3P3vxPqySoH+ClGWMRmcS9h6vlNRp7gvoGAv4Mf4bt1ZjWKy0V2QeREEMCxCNv6Kj1TM8MOxgm8o76JqTIvUUEwrOyOMel59//QgPlOznqX1I/uiEFwDuOVguzDKs= 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=iiSuj/yj 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="iiSuj/yj" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCY5vB3z1FQVs; Wed, 28 Jan 2026 15:49:29 +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 4f1QCY33PTz1FDXm; Wed, 28 Jan 2026 15:49:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611769; bh=Xu+Tx4YbRAuYDk68YZmjQXkVSfoxhaU2CbP0o4HeWPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iiSuj/yjRjJNCL2surRCDlxr4IqLqU2wEaprcP58KxBPuNP6q9E9wx8v4CGnmhyG5 m+cRgTaJ/Z0KLYhkdl+IlnOM0J1luhgbxBv8K/Dk/ayGGWws45kZqJ7D519TTUZc5g KMyJqem3FuuxjXitZWv3+X3dptYeYcMp4UtMnsbvxU4YSisvAEmrAZKaWSlZ4MBpQ9 ZxHE8pXUjPA5njW8T8CxFMbWCBqzDE3Lvu6JlGPpIbxSnwrvj+WmNHXrFKQIwoH08x JgrX2d+AkniB7f0gclGragXmuLcqaGrMiT9eScBT2A2amWlSNMGO/+nEQkTjqr48yX VXwEoCWK53yUQ== 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 v4 09/15] can: grcan: set DMA mask for GRCAN and GRCANFD to 32-bit Date: Wed, 28 Jan 2026 15:49:15 +0100 Message-ID: <20260128144921.5458-10-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 29247e9860c9..13dc4989f067 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -1741,6 +1741,13 @@ static int grcan_probe(struct platform_device *ofdev) goto exit_error; } + /* 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"); -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 668683644C8; Wed, 28 Jan 2026 14:49:33 +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=1769611775; cv=none; b=rlYxtQ5ytBG7EGdWk8xsUCnBMPAh+1iXvzNGJjIpfxosS0Vu6yoL9Ty9OPPr4uTIq1NdNXxlzMKM8yjC8Re53ExAQuFqAmVQmtTHx1ySjq6xKxHfWoYdj8P2dQSA3htQd8934/xho7X5LvZ85YEaGA8cta1lkUwWfGFublMe4PI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611775; c=relaxed/simple; bh=TZvQ/BRxtMnWSrNnyUeBYv2Nd56zIvqbp1IMhNvOPzM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eMyKT0hHNMnFcMhALm/n4rvYF4ZmQ1hBFjFOTGNfqrvGs3t66MBP5d1D+aXNMHeOzIlSObM/8DwEAbcSnatPTk4cMweW1OOjKizK2by40zheFzgYKRINBL5zk96RQmwdPB0nbWYSyrWJd+tuQgguCgbtwNCN1ftU8HFf9dRhm0E= 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=HEeLseea 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="HEeLseea" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCZ3s01z1FDXX; Wed, 28 Jan 2026 15:49:30 +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 4f1QCY5ZLwz1FDXv; Wed, 28 Jan 2026 15:49:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611770; bh=jXQcjRcxsrRIpmX3uVmGRrYNnSd0R0YaXJGt3CFoZWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HEeLseeavOtZHZsHGnoAcFJ4R1JV5+D/ZMVk1SaqbQmJevxw01KmXIjrdPU57ZP1b EkYJNeikp56AsJNdiFhDD+E0LFQVhzsS4aWWEXD8LkNzAKOpRmO1bWC42eT5+KcGEr cPybGXNCH2WL7arO/E7uRbZ1zDgbyjqbN56qMxadAxENOJyr0s2fn5Evz+Gz+CXp57 R6LUmEB/QdYGNE1pm0+hHJT2jP0zNo35ALqrpRIOy4jJvwC+RNg+dqO1hEsSxWNG+o ODyzg1WWHoaHzarsjtNP97q2bMNk4Aaws0E16pDrybcf+41mpEaJ0bp7o+er5I8QGE icYyVBS78eyCQ== 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 v4 10/15] can: grcan: Add saving and restoring of CAN FD baud-rate registers Date: Wed, 28 Jan 2026 15:49:16 +0100 Message-ID: <20260128144921.5458-11-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 13dc4989f067..0ceda12335bc 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -525,6 +525,8 @@ static void grcan_reset(struct net_device *dev) /* Turn off hardware filtering - regs->rxcode set to 0 by reset */ grcan_write_reg(®s->rxmask, 0); + + priv->hwcap->set_bittiming(dev); } /* stop device without changing any configurations */ -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 B3457364E85; Wed, 28 Jan 2026 14:49:33 +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=1769611775; cv=none; b=p0z+LGiQMo8RzRM5rkIYdffE8erPRYHu2tw9p4L5euWI/qK4oA3K7m2VMiUjyawwhDrPldJJ5bSUejxZSV9YHtKi5OTpk2VGd4OoeOqQKL4vPNIQ2jUisVU2VzSt0pHVHMrokCf+B0rbw6kT7NU5rcPl487Jd81gqauYMo+Q71M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611775; c=relaxed/simple; bh=0JeFaaAsquUf7sT9m/pFX5d28x6116D6GvovNNfY5Bw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jY3CzmQngvgcdvrqNw8JpflqTeimxiUvRPVtviDQHh7xaTPjxTbTHbAkmSOvLHBp8xDxPoQabz/TuFEIiiDee9txWwLpSgZFeCIqsCulKPSVgdSJEqieKBx/T33nrSF6RcUpHI6qyPEKmkkmlsS+ntOG5QzGlgx5v2YpCjNtA50= 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=S6BN+x+B 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="S6BN+x+B" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCb10Byz1FDYD; Wed, 28 Jan 2026 15:49:31 +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 4f1QCZ3PJqz1DPkK; Wed, 28 Jan 2026 15:49:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611771; bh=XhDpIgFvLtKYCf6Xd2LNeTP2TSc4kdJLbKvmX5frO1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S6BN+x+BaszGKMeHN4TFnlevOSvHd/+UZGs0XI/gbTMogr8j+8faomr1WeJYaDCBM ooXE6cvcZcSHWGYBucBqWqDSjGV3bAt6LYoh6g/5y1xWUaApHnZuVJ5ca6DEUQn8eC iYVrRgkhODa2hnv2TxF+u/hgODiYAkVjubh9Qt02tICqRvZ8UVvZZAkoCd6TahwFqx gAfp9s+fzvyPTCAzJC8KXI+B2VbqsPlXEwfrCGMgxhMjE/QpKbDLVZhf5h3j2GpO9+ Jm/OF+bglGWvsItznBV/E8g4F5JujLKUkRMorS1hf1BPjEiwB8/pX2RAqfoGD+IEWT b4KcjZjy/8blA== 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 v4 11/15] can: grcan: Reserve space between cap and next register to align with address layout Date: Wed, 28 Jan 2026 15:49:17 +0100 Message-ID: <20260128144921.5458-12-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 0ceda12335bc..3104946071dd 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)]; -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 C8B7C30AD1C; Wed, 28 Jan 2026 14:49:33 +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=1769611775; cv=none; b=s6veOCUZmoeY87nnHeYvSwHxMQ7FwNLnAyj3UV9Tn35vDJduk5ujyvJseYBH7HPyVA5gIpcXtWYGH9Q+lFhG5Rsy7yDy47Mb/GRyLwKxB15Oa0kjGtJYL7TsImKwO3w6mVD99cC0fRyp8LbSX9MIqBiqp8CWf0T5cicsStrbgAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611775; c=relaxed/simple; bh=hH5mNenLFv2jFXESBsX15fa4OXtKrcjO/eZje/dQ4zU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DexSg3KtTfQTqZ/QktN8ebBHGu5vLU6XyoS/WqXIKScJ6ZSa2Ym3W1AnYeRWZmiMplnwucjrXKjLoPS/HaxGNnqZlY8z9KEjZZAi079G5cbadluRK0T1QYeFzy+hNV1bPw8sOA2PgYrKc/9Q4H/NsTxfLd/p7jrYrLlr7jC3bmk= 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=QFBAP+eC 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="QFBAP+eC" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCb2rwnz1FQVX; Wed, 28 Jan 2026 15:49:31 +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 4f1QCb0nVBz1FDXm; Wed, 28 Jan 2026 15:49:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611771; bh=euBnDk4LZvnk8pPGEi69v5bjXxDOkS3WahwCOi6NLIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QFBAP+eCO0cdU3T71ad4DLoaImpdd6M+fMQdq37tmiqgzd8/LZa0eY2b+G6YisQnK WudvlLXwIpP1zr/8OB4innlvzhOdU1yEb5E2ugPTGVrzxGwC37USzDEDLKN5LoNcS/ +uy94yqm+42n6dmp+dWIJwd4PVJq6e1f2itXx+4Vu5JXhzxarxuQ1dTvhYrtye+rvN 1FEtkM3A5glQM1UIJaaIyQjeI5jbhAKqWrhCQ9Stp/lcrb/TV3vg+h0FjBBRGhW1+B tlNPsyVaM84ed+ugU39IlDhEwJ5Rxloysfljk2VqWSNjPi7tS91/RDt18pPxKG0O+O QLdOjg6OgQShQ== 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 v4 12/15] can: grcan: Add CANFD TX support alongside legacy CAN Date: Wed, 28 Jan 2026 15:49:18 +0100 Message-ID: <20260128144921.5458-13-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 | 103 +++++++++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 28 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 3104946071dd..da0b5c129aae 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) #define GRCAN_MSG_SIZE 16 +#define GRCAN_CLASSIC_DATA_SIZE 8 #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 +#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 +#define GRCAN_TX_BRS BIT(25) +#define GRCAN_TX_FDF BIT(26) + /* Hardware capabilities */ struct grcan_hwcap { /* CAN-FD capable, indicates GRCANFD IP. @@ -1207,6 +1215,14 @@ static void grcan_transmit_catch_up(struct net_devic= e *dev) spin_unlock_irqrestore(&priv->lock, flags); } +static int grcan_numbds(int len) +{ + if (len <=3D GRCAN_CLASSIC_DATA_SIZE) + return 1; + + return 1 + DIV_ROUND_UP(len - GRCAN_CLASSIC_DATA_SIZE, GRCAN_MSG_SIZE); +} + static int grcan_receive(struct net_device *dev, int budget) { struct grcan_priv *priv =3D netdev_priv(dev); @@ -1389,15 +1405,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; if (can_dev_dropped_skb(dev, skb)) return NETDEV_TX_OK; @@ -1408,6 +1431,18 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *= skb, if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) return NETDEV_TX_BUSY; + 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. @@ -1416,9 +1451,7 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *s= kb, 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); if (unlikely(space =3D=3D 1)) netif_stop_queue(dev); @@ -1434,24 +1467,39 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff = *skb, return NETDEV_TX_BUSY; } - /* 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; + } - 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; + } /* Checking that channel has not been disabled. These cases * should never happen @@ -1493,8 +1541,7 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *s= kb, wmb(); /* 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); return NETDEV_TX_OK; } -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 5165D364EB7; Wed, 28 Jan 2026 14:49:34 +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=1769611777; cv=none; b=Yx7oADtnFq/kO2wOT19JX3QjcJwX+LAzt5v+KK2HBNSqyOX9t121H8Em50eosWTISZXyA87sVgGo3JYHY6/XOmoF5BtbpApLIWdOSx1Wk7uACJwge64WuH+BXZ7GGK0FYT88MGl2RrBpq66LfiRfC0YC+g+hYROSrW8BnA5XS34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611777; c=relaxed/simple; bh=F6mmkBeE4aOPMU0lOY0fasf1dzzHl5Jx4qKtzKvLMnI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KurAY+1FhL/llfcycGmgtEC+0TrKk1LU7/ryGxMVjz2R3l3MOQ5qzC8RcPxLifr3UZhzXPBHSKC/Tv2f2oeeq6+Bo36LteunSSZs5yu/PyT3Nv1ghCn2pCb4EcZH7l4rg2PRmFsIlEzHwPVSY2HWnsiK+T/7gIFjngJQp2kZTGg= 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=ShTdkZu7 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="ShTdkZu7" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCb4w20z1FDXm; Wed, 28 Jan 2026 15:49:31 +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 4f1QCb2V1Hz1FQVR; Wed, 28 Jan 2026 15:49:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611771; bh=5z1T/3tk6laeWF5sjShkZPMdQKbinFCwx3rclkgUEAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ShTdkZu752CuXsOk8RAdGchL4uO0WwUJxi47lzHrYkPYlXXZ4964sjELzjypIFK3B P2mYvzi+HnHOQwtT69e3z3Gvo6mDGxz9lXJmqx1pI8ox3nndF6VhtzI7MUURQpH6oS tGuEXLkLtWHUqADMdizeKlHI1BMnDk0TriWTbo75CVp4RRe/qG5wCW1xAa96LasSw5 lFGOKJVkOpo6HeO6YDID0HSoykNgwyeVXnxzA/dEto9X0Vb7yYkN9ihStIax1ozbRX X53DJ9/yD7gpceJi64dCD985KFRjD/usD46iuAb5p44XeHR9o89JWGZqoL5ndg3Pls J72nIj3x+lL2A== 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 v4 13/15] can: grcan: Add CANFD RX support alongside legacy CAN Date: Wed, 28 Jan 2026 15:49:19 +0100 Message-ID: <20260128144921.5458-14-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 da0b5c129aae..d838fb0698f4 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) +#define GRCAN_RX_BRS BIT(25) +#define GRCAN_RX_FDF BIT(26) + /* Hardware capabilities */ struct grcan_hwcap { /* CAN-FD capable, indicates GRCANFD IP. @@ -1225,18 +1228,22 @@ static int grcan_numbds(int len) 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; + 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 */ @@ -1244,43 +1251,68 @@ static int grcan_receive(struct net_device *dev, in= t budget) if (rd =3D=3D wr) break; - /* 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; } - 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)); - 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); } /* Make sure everything is read before allowing hardware to -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 49323364EB2; Wed, 28 Jan 2026 14:49:34 +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=1769611776; cv=none; b=lsgobcuGKdY2EY4rIiLAzqQvTddpFSkD17+0D83RCcmLmeTJEyVX6uaTOZgdCr8NMI1y+i1JS4Zmp9tEQZT53gpaZXRW8ejZs0/yctWc8zPhNRDCD1VurXcPqFU2oST44x6dKLkGNCvzCs2kOdTZWP3FIcErsvq/DToAhBCmeek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611776; c=relaxed/simple; bh=Nb9C6mcqFX76VfmPbSiKsIalpLxwEFJMYdlOpZfRw0g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k4WlOwU/SqBhMnWZ4EP50fp7+px8eD0raHvL+S6KbEd0KCGog9VDNxz/ey94GWbWUTghfgPliAVfqCrW2LnuHJ1uu2HJbH0zE8pAS6LCLE513PkV9vSq2cubqlLOd75z3/aRf2C630jdzPiCsrlES/Sf/rq5Pe82G4LjBu1Rg/k= 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=LrW0CCpE 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="LrW0CCpE" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCc0BXHz1DR2b; Wed, 28 Jan 2026 15:49:32 +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 4f1QCb50VWz1FQVr; Wed, 28 Jan 2026 15:49:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611771; bh=U7a/Lfd9ejcMVj7P5oPql/Qxige+KLxPk95VuUAYL5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LrW0CCpE8XBsr9L8qVx2z76vpqfOpBFgZskDOqjm7OeDts95RWrRZvuaj21iJZBuM kSCJ6RXGQBgl7ZQWZVP1P87qBL5bOcNaJmq8uS19ouQsskrzLZ1MnTshI8H6ga7jWH mDfQIV/k0/phDa4yv2JV6CLJZUuZ9669ULorSRmjBwUBJH0JM30SzcCUzNic4O8Psk F0XrG8TwY0EdwsS1doKGFppWLybSv6KY2U/TiMQ50ExJdhG7CkhW/9KSo+NmG+w1hI OM5cE+w0EzoAvnq875ZEmbr2vWzdq3TwSEyoM+Bv5uH9NpbAMJTOyHWp6dGOjbM+Vp lxhY+D7weMp/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 Subject: [PATCH v4 14/15] can: grcan: Update echo skb handling to match variable length CANFD frame Date: Wed, 28 Jan 2026 15:49:20 +0100 Message-ID: <20260128144921.5458-15-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 | 53 ++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index d838fb0698f4..e6f3cd36ea66 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -298,6 +298,15 @@ struct grcan_priv { struct sk_buff **echo_skb; /* We allocate this on our own */ + /* + * 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. @@ -567,7 +576,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; /* Updates to priv->eskbp and wake-ups of the queue needs to * be atomic towards the reads of priv->eskbp and shut-downs @@ -578,19 +587,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); - } 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; } @@ -1098,6 +1110,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; } @@ -1109,6 +1122,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; /* Allocate memory */ @@ -1119,13 +1133,15 @@ static int grcan_open(struct net_device *dev) return err; } - 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; /* Get can device up */ @@ -1485,8 +1501,11 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *= skb, space =3D grcan_txspace(dma->tx.size, txwr, priv->eskbp); bds =3D grcan_numbds(len); - if (unlikely(space =3D=3D 1)) + if (unlikely(space < bds || priv->can.echo_skb[priv->echo_skb_idx])) { netif_stop_queue(dev); + spin_unlock_irqrestore(&priv->lock, flags); + return NETDEV_TX_BUSY; + } spin_unlock_irqrestore(&priv->lock, flags); /* End of critical section*/ @@ -1565,7 +1584,13 @@ 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; /* Make sure everything is written before allowing hardware to * read from the memory -- 2.51.0 From nobody Mon Feb 9 01:35:50 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 2B6B7350A2C; Wed, 28 Jan 2026 14:49:35 +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=1769611777; cv=none; b=cAVD+z3brPRRgrpEpEQx5elpDI6sT7LdeH9HYYkAQXxPcJ5xsrTtjYLQ+JhgLYuUYundTObZ5XBTFKc1Wn2k+cjMi+RsYtOq2b0b4ZSsqUsT0PRfvTv1CnxDYGlsu+Dcbap67LpfchAlN8ewTO7ZwWW1CZJHVkF6+2yEMSaTA5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769611777; c=relaxed/simple; bh=2XI+kEnL0TlyTyqFkt/kZCVxZGcDhK23q6AphLO89ME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kI2jvhwgBIlYxHD6EQe1jS3us9xORhyBBhc0b0Vtz7VOU8orGmLqPXeaI3rI3Qotxia6tFT0w+514WsGDFZmnfSMBth1oQRmK//h8P1jQpUg8lH7O4dgRRXh15hEP3nqV7KoqrYn3/Sj1nFjKaylFcj98icB4NVVrkJosaF25UM= 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=Cg5ZeKQO 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="Cg5ZeKQO" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4f1QCc3LZcz1FDXb; Wed, 28 Jan 2026 15:49:32 +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 4f1QCb6gzGz1FQVl; Wed, 28 Jan 2026 15:49:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1769611772; bh=bWrGRAw1Ymt+kLMgEE+iCVDAba/QTAuev1cp5/ho8Jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Cg5ZeKQO8JfCKsw83clxCkxnu9n8jmENAfuLZ+LaTduQ8tIrIklq75G7GAhAQAyyk KJBVbU2yUDn8beBHnEWHA25qw6KlGHddnIBAPC9TqJ3rKTT00UakIjhkG6P+Vl/X1o Hu0bdTGD0gM2YjfF6sezo1QEIRb62RWCXDMJUNBzkOYKSXkyz5BdRihXerwQ78VvPI ZClOKpreh0T/jjk/7z/LUGlu+9YSOL+R2Ku2yolZKcU5eperG+n0Z40tJJhPNEyHeH o+oBB+uJYVbs/jFLtaN6gNzrIlYVlxTKcbavzelktFrQBlol00gMuTkP6uO7xVUhPK H5GhiFbKLrs0g== 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 v4 15/15] can: grcan: Advertise CANFD capability Date: Wed, 28 Jan 2026 15:49:21 +0100 Message-ID: <20260128144921.5458-16-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260128144921.5458-1-arun.muthusamy@gaisler.com> References: <20260128144921.5458-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 e6f3cd36ea66..120e722cc59e 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -1749,11 +1749,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; -- 2.51.0