From nobody Tue Dec 2 02:43:40 2025 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 97E112FC862; Tue, 18 Nov 2025 09:30:16 +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=1763458218; cv=none; b=dh4nrX2FCHXrX4cdTCvL/ETR1itahv2dxNfp6p+jLE8KIIZL+2z1P4z8VwkQwmdWNDmpKB/0Oex54orfykgEBUkcEDLk96M6MDlThegU4GtE5I3MR+RNGbDMzqwgqE3TLRttR/hH8+6nAkAFz4wlag/OZ74AIrssU/D6BRZ4lts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763458218; c=relaxed/simple; bh=o/ioPXXZYh/dgl1Zd0IL9GbLfli276QgGGru0OCthHw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y5qcat2EmJqBNPBHpv1nQM9IIXgRSsxiyWl3VrjRWv81SBrfkGLaYa+0WlyrwabcVTKi/HY87a6EYOAmvFKcGkbJZDD7kRsYlcabIjiLmrf9xwYsa1v0luS/3/HvPFXyyWQcCDaT6ckXsXGJ7DMyY0/tmZv0DlrjKXWSV6P17Jg= 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=kKTuKmxc 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="kKTuKmxc" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4d9fHq5vp8z1DQqY; Tue, 18 Nov 2025 10:21: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 4d9fHq3fw3z1DDqw; Tue, 18 Nov 2025 10:21:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1763457687; bh=/e4X68xG1gU6FLZnmngS77rn9PhpDpT87XyNVAA8OuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kKTuKmxc2dfYbaIgbHEwzd+xYMHf2X5cDd4nU9B/iwUQvqqe3VeX1ffkrkuOVl1em kM7bcbYTbe/J609JgJ6NJ9jMVL+w/uT6b5VjwX95beQqESxwl5Rl1axrAiTdKX4Jod pm28QW8kGIRTe6u1BWH9CInS6n3KUNNaLx3C69Yum+j1gmT2mM0yxkLUA7vWY5JUUC Iq0rnkQ4WF3FOG5skYHjI66qIZmQb4KdwQjVnNJ4W+7K8T9/Bw8HapK5oAZ27fqh1l LHs6fM2/JnJ/RppL5Tdr87EhzfFNJxMFrmwwDPQfemwqcuapIRKqn3EBGtUoWkjOg5 j+ZRe4pmURcwA== 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 Subject: [PATCH 01/10] dt-bindings: Add vendor prefix for Frontgrade Gaisler AB Date: Tue, 18 Nov 2025 10:21:06 +0100 Message-ID: <20251118092115.3455-2-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118092115.3455-1-arun.muthusamy@gaisler.com> References: <20251118092115.3455-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 --- 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 Tue Dec 2 02:43:40 2025 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 F3A6B262FC0; Tue, 18 Nov 2025 09:21:31 +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=1763457696; cv=none; b=aOvvXt0ee3N0Ir+KKqD7TjdtkKxr7xRlrR6/8WRZCq8dMsT7NkClgbtTel/L685ZDlxXE7VZdiOSeKx3/rcKQjePSCbKHKBsKn9+AZXvJeyGkV6kx0j69lFqDYp9htvT8zBDaxfkxCwRYA5FtdQCZnW+rT3HydIIEMzSAdNAPyo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763457696; c=relaxed/simple; bh=qsq70m9aoOeIKPhV+zDdYMShngSTVeO/RN0J0OIkiZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t9+ubQ44oFhO5F6GlFNee71+PN/mLULuKyv8iUt2zKG73XjvQg7bTRvodnXSeyogfqK2oxVYEHOmT3rDgKtTU6v+uyoxKI4wjIsHh4fPfA0C7bAAeI56sJciZiBEK+cv7zi2zOaZXsW1xtIb3UmUrP6Fli0jZy+puwKAhWlmbEU= 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=CSfDiocX 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="CSfDiocX" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4d9fHs747bz1DDXm; Tue, 18 Nov 2025 10:21: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 4d9fHs4gx7z1DHYP; Tue, 18 Nov 2025 10:21:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1763457689; bh=QIto6meMbgfhU+k/5Zes9dtjfsi03cPshAM6CMpt0ic=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CSfDiocXNSrBkQFgGLnL1lUUe7KMmmXYMQRWZlLGL01di4/IC6WMi11Nmwdx74mPV Cn+DZzAmvaJP3q01YXtf5gH88ycMFvSHZOYQ+jfFBI/vES6TbVDxfRdcOuxxdqO1gG sxemoadA9KpasLJ6bZqDO9grhXT+Axig1LsowhxUedRzWb/I1/NKSVFGHh1yQHt7Bf jeXAVApTydeItUR4gjYZKc92GeMqaXrnQLbGQxhPRUWK9v9JJ3exi2eIO6wWm+mcla rD9Qcdx/yn/WCb3NexniyBge6SObZVApbKUMCQ3sd1wqBgdk7lyqOdiUGusalGKJ25 YWT89CG9URrYw== 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 02/10] dt-bindings: net: can: grcan: Convert GRCAN CAN controllers binding from txt to YAML Date: Tue, 18 Nov 2025 10:21:07 +0100 Message-ID: <20251118092115.3455-3-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118092115.3455-1-arun.muthusamy@gaisler.com> References: <20251118092115.3455-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. - Add properties such as `compatible`, `reg`, `interrupts` and `clocks` for the CAN controllers. - Removal of the old `grcan.txt` file as its contents have been fully migrated to the YAML file. - YAML file includes examples of device tree bindings for the CAN controllers Signed-off-by: Arun Muthusamy --- .../bindings/net/can/gaisler,grcan.yaml | 85 +++++++++++++++++++ .../devicetree/bindings/net/can/grcan.txt | 28 ------ 2 files changed, 85 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..521bdd89f130 --- /dev/null +++ b/Documentation/devicetree/bindings/net/can/gaisler,grcan.yaml @@ -0,0 +1,85 @@ +# 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 co= re + 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 + name: + description: | + Fallback on node name matching for systems that don't provide compat= ible. + enum: + - GAISLER_GRCAN + - 01_03d + - GAISLER_GRHCAN + - "01_034" + + 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 that utilize the common clock + framework is not supported. + +unevaluatedProperties: false + +required: + - reg + - interrupts + +examples: + - | + #include + can@ff400000 { + compatible =3D "gaisler,grcanfd"; + clocks =3D <&sysclock>; + reg =3D <0xff400000 0x400>; + interrupt-parent =3D <&plic0>; + interrupts =3D <6>; + }; + - | + #include + can@ff400000 { + compatible =3D "gaisler,grcan"; + clocks =3D <&sysclock>; + reg =3D <0xff400000 0x400>; + interrupt-parent =3D <&plic0>; + interrupts =3D <6>; + }; + - | + GAISLER_GRCAN@ff840000 { + reg =3D <0xff840000 0x400>; + freq =3D <50000000>; + interrupts =3D <16>; + }; 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 Tue Dec 2 02:43:40 2025 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 2D0473002D0; Tue, 18 Nov 2025 09:21: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=1763457696; cv=none; b=JED3SHFKEoaApIJ9C7CHo3gtBMIhX87ncjXOPPqfI6xIkRHDQkGi3vsHORWT0GFfYIu+6KkImoQPZw27mqmpoNgBU+qerL61Tu2K99R5fmljx2LCxXgj65Yg90ndxe5rHIQpNTbU8+3ELfKdH2vJwG1NWoodnTqjOJPrw7YN7kQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763457696; c=relaxed/simple; bh=TZyWk9jjqqbVyfqG7U5NY8aXjAHEJzA4VTnk5rwHIAE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=duYqREBvw5Bb5qPvldiwt9Lm9jgioL+RFoM17D6dv8BN3xRHw75wPB6zQzYQMXAVpQphpyLTNB7xWo3+Tg4a/9DwstgLiSs09rdV929YXyc9mEPS5XKILYl97USmOHttHN08eYCi3NI6D0dLAOGOkgD29U01kK/Qgk840mWpF3A= 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=m9OBLTvM 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="m9OBLTvM" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4d9fHv2GCLz1DQqn; Tue, 18 Nov 2025 10:21: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 4d9fHt60PGz1DDTS; Tue, 18 Nov 2025 10:21:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1763457691; bh=dGU5JS1NOmLxMLxAUqMZLV4VSvB6qlG6yu1QcrvUIFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=m9OBLTvM+netJc6jGiWfOMAuR4w09GOH12apDtOWfBI/v0IE+JP5Aob3XHeXB1t6i o5Y2xldHiQpjd5pD4xf8cnV8ij4Zx0yZUAPf4filXZmi3lrRB0fCJdRG+0kuY5Pjx5 ekurOBi0zYI/9vJoclMTfQ2DgymUCAhp1GWETMVU0KG/AYr8oD7VqH77CYYKHUSlk0 OZe+NEzDE8q/995CfXGjgUdtqiMv2mgfVwFmLbeUi2Xp92RVLUOgmg4DaigvO9ZJb1 mU/zMpN8W0Ubkzz3kIVHNWQ46t82zfTTXw2fU7NmFjrs4Ps+XRtYeDXEL3MLsGvRpF D+Az1iwFJ03sQ== 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 03/10] MAINTAINERS: Add entry for GRCAN CAN network driver Date: Tue, 18 Nov 2025 10:21:08 +0100 Message-ID: <20251118092115.3455-4-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118092115.3455-1-arun.muthusamy@gaisler.com> References: <20251118092115.3455-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. 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/ +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 -- 2.51.0 From nobody Tue Dec 2 02:43:40 2025 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 3FDCC3101DD; Tue, 18 Nov 2025 09:21: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=1763457697; cv=none; b=inUkeMQVXWWEY2vy619Pzxn3606rNqt6HynT5E6sdAVoMZCnWb0TMk2vhGMt1nIJ3ev84dFZMTUb8+BtniUOIIH8XmKvKwgthioeIkkjU7FShCGcTes7EHBzQeihZAg3gVNSFR3kpKEGkW1+illygeaOfMSeUBllQ5xzCuRhu6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763457697; c=relaxed/simple; bh=m88D8lBJm4UALW3eQ1CFTCXSUl6mxjcAsqAkW2JLgt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hzD0omku0eJ1rJA95FN04QiyUh8AaNhDF/7v+prsCvzTmkVQjQ43SGEmbNd+LkaTIG02FVrTgzOOHsAgW4VRSlbEipdumm395JRhS1CUp0Eq/fDPNjZKc7sycd0FmoqTLY4n632N1AZkQ7ajbYx22rPFWZLe+YC3SITULKjR49I= 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=Stqx8TAO 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="Stqx8TAO" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4d9fHw25Q1z1DHbg; Tue, 18 Nov 2025 10:21: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 4d9fHv73djz1DQr4; Tue, 18 Nov 2025 10:21:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1763457692; bh=isp+XXy2t/sAgvrNrWukSWnOnRGpWab6nIVj+in0B7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Stqx8TAOfYCM3FB74gB8rF5pmY1WlqeNJjVdSpWU3ZBH5L3YFrjyx259Te94gKG/G lzw0mTsI53SCWH0SF5Gas1eax/4hgTBsmM10geLDL/H3V595YvXQvDAjao0fbpIQyk 8oHsr49N+n6yiqFmp6qVZrz3kBIph7ZCR6zd6Je3WgsLW7Jkqs32S/1qQs117BHr7f 04PHWV2wmf+8/5vYlHHD3hbGEY4yBUB52IsnAE7I7sijMTamjwAsrWau2An5LLSzMQ aDaN14Q7IaBcJjzYJ0Fu9t679BM0ZiQRhRNV0qn9wlwo5X+DVp2qvTzNDEVUpUEu+c tE7eV8C/9Peag== 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 04/10] can: grcan: Add clock handling Date: Tue, 18 Nov 2025 10:21:09 +0100 Message-ID: <20251118092115.3455-5-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118092115.3455-1-arun.muthusamy@gaisler.com> References: <20251118092115.3455-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: Arun Muthusamy Signed-off-by: Daniel Hellstrom --- 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 Tue Dec 2 02:43:40 2025 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 E80E3313554; Tue, 18 Nov 2025 09:21: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=1763457698; cv=none; b=SYSKFOhmBRjgpxCwuXKzQSh9tYnnivXhGMdg7RWWf1ZoY1vGmjLWzr5KdvllPE225+b4QXHl8kkZ6rYzcF8tLRovX7s7p62F+DNxaZeLFDke6TVB8hfz59Btcv0BUUiiqbNwoc3yYOvk0uKvL2tVY14HfRYrkDgjVnGOT4YIDEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763457698; c=relaxed/simple; bh=9yknJCGmDa/gqo7+F7dWEtolQI/BzuopsblUp3mm10k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JrXVqhi/nHTGe5MSAdJHPsU/hCyY9m8OT+wuAveQrBEe15MRTV+znS2GOLEpcVgm2RtoqpjPBM9VllAbCd9vPfhPd8cq0KjkZTwml5sa/9sYFnWwBNbo0bv+B4BUUa6Z7WsHkem0BCAomgHcd+U44KdUdIzCbmSncx4WEkG5Y3A= 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=PZ2XFL/R 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="PZ2XFL/R" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4d9fHx2DGVz1DDXL; Tue, 18 Nov 2025 10:21:33 +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 4d9fHw6v9Fz1DHc4; Tue, 18 Nov 2025 10:21:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1763457693; bh=AHCagI2CG98CSLtLVHmtrL6P3BHrqiUzhqquz9U5GsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PZ2XFL/RrdH/NKMAfAvER2xgsazC/luwpdxwxQs+BTtcLNBI9eMhgz/7akIQ9bIFn imwSL4rMUNfPwi8MBaC1ffeswGWXpMsN8u231zS7sS3J7FnrNx+1IpUAY6s8Yx9PLU w1lfY0QfB7YypBMnK74pZCp2x+BkRrgyv50YqQiojEpRLXRdQNqjmKu7Yzk0p6TmWy yBY5PYfVaiCzNfqXM3ERs6qE5a7w1XNSB0JT9cvasuUsefk0T+bobAkUI5419PCt7E mQUhOtXivuMTZaGUKlFvaSYraoN71q6K6vbkz9L91JTxsKnzMIPunT024PL6Day08Q 8Usosb4tUHdaA== 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 05/10] can: grcan: add FD capability detection and nominal bit-timing Date: Tue, 18 Nov 2025 10:21:10 +0100 Message-ID: <20251118092115.3455-6-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118092115.3455-1-arun.muthusamy@gaisler.com> References: <20251118092115.3455-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 capability for the driver to detect CAN FD support and adjust accordingly. Introduce structures and functions for setting nominal bit-timing for standard CAN and 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 | 189 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 176 insertions(+), 19 deletions(-) diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index d43d56694667..816b6e71a990 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, GRCANFD 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 538a9b4f82ab..b9b0dd7d53f6 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -50,7 +51,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 */ @@ -212,6 +217,67 @@ struct grcan_registers { #error "Invalid default buffer size" #endif +#define GRCANFD_NOMCONF_SJW_MIN 1 +#define GRCANFD_NOMCONF_SJW_MAX 16 +#define GRCANFD_NOMCONF_PS1_MIN 2 +#define GRCANFD_NOMCONF_PS1_MAX 63 +#define GRCANFD_NOMCONF_PS2_MIN 2 +#define GRCANFD_NOMCONF_PS2_MAX 16 +#define GRCANFD_NOMCONF_SCALER_MIN 0 +#define GRCANFD_NOMCONF_SCALER_MAX 255 +#define GRCANFD_NOMCONF_SCALER_INC 1 + +#define GRCANFD_NBTR_SCALER 0x00ff0000 +#define GRCANFD_NBTR_PS1 0x0000fc00 +#define GRCANFD_NBTR_PS2 0x000003e0 +#define GRCANFD_NBTR_SJW 0x0000001f +#define GRCANFD_NBTR_TIMING \ + (GRCANFD_NBTR_SCALER | GRCANFD_NBTR_PS1 | GRCANFD_NBTR_PS2 | \ + GRCANFD_NBTR_SJW) + +#define GRCANFD_NBTR_SCALER_BIT 16 +#define GRCANFD_NBTR_PS1_BIT 10 +#define GRCANFD_NBTR_PS2_BIT 5 +#define GRCANFD_NBTR_SJW_BIT 0 + +#define GRCANFD_FDCONF_SJW_MIN 1 +#define GRCANFD_FDCONF_SJW_MAX 8 +#define GRCANFD_FDCONF_PS1_MIN 1 +#define GRCANFD_FDCONF_PS1_MAX 15 +#define GRCANFD_FDCONF_PS2_MIN 2 +#define GRCANFD_FDCONF_PS2_MAX 8 +#define GRCANFD_FDCONF_SCALER_MIN 0 +#define GRCANFD_FDCONF_SCALER_MAX 255 +#define GRCANFD_FDCONF_SCALER_INC 1 + +#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. + */ + bool fd; + bool txbug_possible; + const struct can_bittiming_const *bt_const; + int (*set_bittiming)(struct net_device *dev); +}; + +static const struct grcan_hwcap grcan_hwcap; +static const struct of_device_id grcan_match[]; + struct grcan_dma_buffer { size_t size; void *buf; @@ -304,6 +370,8 @@ struct grcan_priv { */ bool resetting; bool closing; + + const struct grcan_hwcap *hwcap; }; /* Wait time for a short wait for ongoing to clear */ @@ -402,6 +470,19 @@ static const struct can_bittiming_const grcan_bittimin= g_const =3D { .brp_inc =3D GRCAN_CONF_SCALER_INC, }; +/* GRCANFD nominal boundaries for baud-rate parameters */ +static const struct can_bittiming_const grcanfd_bittiming_const =3D { + .name =3D DRV_NAME, + .tseg1_min =3D GRCANFD_NOMCONF_PS1_MIN, + .tseg1_max =3D GRCANFD_NOMCONF_PS1_MAX, + .tseg2_min =3D GRCANFD_NOMCONF_PS2_MIN, + .tseg2_max =3D GRCANFD_NOMCONF_PS2_MAX, + .sjw_max =3D GRCANFD_NOMCONF_SJW_MAX, + .brp_min =3D GRCANFD_NOMCONF_SCALER_MIN + 1, + .brp_max =3D GRCANFD_NOMCONF_SCALER_MAX + 1, + .brp_inc =3D GRCANFD_NOMCONF_SCALER_INC, +}; + static int grcan_set_bittiming(struct net_device *dev) { struct grcan_priv *priv =3D netdev_priv(dev); @@ -439,12 +520,55 @@ static int grcan_set_bittiming(struct net_device *dev) 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); + netdev_dbg(dev, "setting timing=3D0x%x\n", timing); grcan_write_bits(®s->conf, timing, GRCAN_CONF_TIMING); return 0; } +static int grcanfd_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; + const char *msg; + u32 timing =3D 0; + int sjw, ps1, ps2, scaler; + + /* Should never happen - function will not be called when + * device is up + */ + if (grcan_read_bits(®s->ctrl, GRCAN_CTRL_ENABLE)) + return -EBUSY; + + sjw =3D bt->sjw; + ps1 =3D (bt->prop_seg + bt->phase_seg1); /* tseg1 */ + ps2 =3D bt->phase_seg2; + scaler =3D (bt->brp - 1); + netdev_dbg(dev, "Request for SJW=3D%d, PS1=3D%d, PS2=3D%d, SCALER=3D%d", + sjw, ps1, ps2, scaler); + if (sjw > min(ps1, ps2)) { + msg =3D "SJW <=3D MIN(PS1,PS2) must hold: PS1=3D%d, PS2=3D%d, SJW=3D%d\n= "; + netdev_err(dev, msg, ps1, ps2, sjw); + return -EINVAL; + } + if (ps2 < sjw) { + netdev_err(dev, "PS2 >=3D SJW must hold: PS2=3D%d, SJW=3D%d\n", + ps2, sjw); + return -EINVAL; + } + + timing |=3D (sjw << GRCANFD_NBTR_SJW_BIT) & GRCANFD_NBTR_SJW; + timing |=3D (ps1 << GRCANFD_NBTR_PS1_BIT) & GRCANFD_NBTR_PS1; + timing |=3D (ps2 << GRCANFD_NBTR_PS2_BIT) & GRCANFD_NBTR_PS2; + timing |=3D (scaler << GRCANFD_NBTR_SCALER_BIT) & + GRCANFD_NBTR_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) { @@ -1569,7 +1693,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; @@ -1592,14 +1717,15 @@ 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_bittiming =3D hwcap->set_bittiming; 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; @@ -1644,22 +1770,32 @@ 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 of_device_id *of_id; + const struct grcan_hwcap *hwcap =3D &grcan_hwcap; struct clk *clk; u32 sysid, ambafreq; int irq, err; void __iomem *base; bool txbug =3D true; + of_id =3D of_match_device(grcan_match, &ofdev->dev); + if (of_id && of_id->data) + hwcap =3D (struct grcan_hwcap *)of_id->data; + /* 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); @@ -1695,7 +1831,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; @@ -1722,11 +1858,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 Tue Dec 2 02:43:40 2025 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 0B0DA314B6B; Tue, 18 Nov 2025 09:21: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=1763457698; cv=none; b=BEmsZD/yrFoCTsh7mouPtHDd+ZyHn4rASqM1d3Cjmqw/4RN+SDeckzXbWJu5S+y8jWO48LgQZCh0F0AgM2LmXWoZt8GlxpT7i3EoNqLFeVsG4L/+/DNmFacXbfU0IF80HXsepui7NXyszLKD6vvKOKCKq5tu13tG4jI1cwkJ6Gc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763457698; c=relaxed/simple; bh=b7Zq0GOWaEmdeMJ9RtteCRyHH7sDdecofUJoMlLfKN0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GuD3KJHxgp8tnt71aUJvH9DA4Kej8u0fIsxaGrM3JHMxcD2aLOBP191ooOQmcWyVxEqaSfAD0TVaHmQx3cNVARNF+j5Wr8biYurliu1GfT9/t5/VZGUWBPwtIw60VyIDt6nAKuTaueEHB16kWYebJ2KhRC3JX1oOVB5ecg9RKrg= 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=GiNlf4TR 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="GiNlf4TR" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4d9fHy32Blz1DDSP; Tue, 18 Nov 2025 10:21:34 +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 4d9fHx6qYsz1DHc4; Tue, 18 Nov 2025 10:21:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1763457694; bh=hK2CbkQEFxq+gefU1nAN+6Xp4sCe8yQEfMXpw3izA78=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GiNlf4TRRQv7sWPgRm/OjrvptcCRAY5HRBIFAc+Brga+lp64+bIA2hc7/PeUtyyv+ 2spqiRHVes0qEGn4vkm7oZ0K2BY0Fzag2/HZj3WF39BgjVPkNn/rmlcjwiNE+BiQAa MlXM0JRzx4Rxvtu7HAcVKmZYG9InP4dXijgmAc9XC5n+Nl+e++QKxXlavJCKxp/nTk Lvd8WpnT4tu5ZD/6lSrYhrJuRTCFdxdNtVTK6HaX8GME7g49p3ZgzbSIeHzBlaySg4 o7K4F+a0nuqL3Hz4XErqZxkQaoRibRA9zNTBn4gJW/WGCuCyeHNdemFxRdrOyCHnJ4 eQ7tchYyqB9TA== 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 06/10] can: grcan: optimize DMA by 32-bit accesses Date: Tue, 18 Nov 2025 10:21:11 +0100 Message-ID: <20251118092115.3455-7-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118092115.3455-1-arun.muthusamy@gaisler.com> References: <20251118092115.3455-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: Arun Muthusamy Signed-off-by: Daniel Hellstrom --- drivers/net/can/grcan.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index b9b0dd7d53f6..e367581faa57 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -1287,7 +1287,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); @@ -1323,10 +1323,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) { + *(u32 *)(cf->data) =3D slot[2]; + if (cf->can_dlc > 4) + *(u32 *)(cf->data + 4) =3D slot[3]; } stats->rx_bytes +=3D cf->len; @@ -1466,8 +1466,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; @@ -1520,10 +1519,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) { + slot[2] =3D *(u32 *)(cf->data); /* data aligned 64-bit */ + if (dlc > 4) + slot[3] =3D *(u32 *)(cf->data + 4); } /* Checking that channel has not been disabled. These cases -- 2.51.0 From nobody Tue Dec 2 02:43:40 2025 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 0085C31A7E6; Tue, 18 Nov 2025 09:21:37 +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=1763457700; cv=none; b=mx2GmCiAZQejFWntJt5KAVqCiq4El+v/2SBMMAzr+N5ZS/myN2uUAz3Z+zjzlixwexeg+qZk5suNLG7oaHiQL8jRI8y0YE/2BQHoCiP8H5RdDL4gTz8svDdAYA0e9Ju6RhTagslNsc+jGGDua1lgQe2adbc2afvC8nKNuhXQLpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763457700; c=relaxed/simple; bh=lZdwI/r+jFdYNMBHCoNFfYnxlV9yVg8rteHV9kgTw3A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uj6oESthWzT9Ep+8owW7UWqRouJX9UwFCAENrSoCh2lfPMK1sl0Gp+/XVIyJ0gXiN9/BFvf+KyBQzOwXF6TDN62w3rsdqB3TfrvCMFEHWMshulenUzXw7mUVN75UMlaXyBwHr5OCGNkXleuU/0GL9hyfuocLlt7L3XxbxSDxWtY= 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=HwiiElPM 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="HwiiElPM" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4d9fJ01RGJz1DHc4; Tue, 18 Nov 2025 10:21:36 +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 4d9fHz0HZRz1DQrn; Tue, 18 Nov 2025 10:21:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1763457696; bh=6tkl5nHID9oP8tfKbnGzaF98n5Rgglr41s9KC7FnAGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HwiiElPMW122zNa1zcr880l1YdRd3B3I/171eNMWu8nXdrq6SuZYGV3tn5C4/VnEB uINwq18fWnAwimI65Ekhks5TpxMSxi9F2sjwjUhKl5s6hFwkG2SA5k/1huD+cRP950 kFYXFvQ+dT8qBJtGBf0JeKBAuoJsrZcjFlOXOVFwAv0Ihg0LEjDDX3gnE+bzDAY0mC 3kaSDC27IZGYefLrKRgfSHvoNmuPfw3SL9IIeLJK/qHGX243Vd8g04r4kTWbke07sf USDoqfd00F1iCs+qGP6mI8NKuzjNfHshKTLtR9InM+S74sajv8dvFkTCINgrXCw6R1 x7y+5/vqgD2CA== 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 07/10] can: grcan: set DMA mask for GRCAN and GRCANFD to 32-bit Date: Tue, 18 Nov 2025 10:21:12 +0100 Message-ID: <20251118092115.3455-8-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118092115.3455-1-arun.muthusamy@gaisler.com> References: <20251118092115.3455-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: Arun Muthusamy Signed-off-by: Daniel Hellstrom --- drivers/net/can/grcan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index e367581faa57..51a10fae2faf 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -1074,6 +1074,12 @@ static int grcan_allocate_dma_buffers(struct net_dev= ice *dev, /* Extra GRCAN_BUFFER_ALIGNMENT to allow for alignment */ dma->base_size =3D lsize + ssize + GRCAN_BUFFER_ALIGNMENT; + + /* On 64-bit systems.. GRCAN and GRCANFD can only address 32-bit */ + if (dma_set_mask_and_coherent(priv->ofdev_dev, DMA_BIT_MASK(32))) { + netdev_warn(dev, "No suitable DMA available\n"); + return -ENOMEM; + } dma->base_buf =3D dma_alloc_coherent(priv->ofdev_dev, dma->base_size, &dma->base_handle, -- 2.51.0 From nobody Tue Dec 2 02:43:40 2025 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 E90BA320CB6; Tue, 18 Nov 2025 09:21:38 +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=1763457701; cv=none; b=cehDh05Pu005TyTJSnBHbeMzdDCObFus+Pb67dvDwhuLbFNB4zPB/+mI8DzvCxdChUW3SvRoHNKSMnTXpA1tOoRv1nHz2ktNGj0QmH0HbkSgTgaqg6jZH64V3p8lwjzoZd+BaAO304dpVrL8rP4agpJCvi9CxqHVv+iNjai3+UQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763457701; c=relaxed/simple; bh=LVS6eRyUPiqzjSOcNIID21CJbnwYaMkpo/BaNL/MUK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mCW6VXenJy7+Hb2b6n/ESmMQZR3M13lp6QpYXez7jfpRf0NPYAvf4lIuM6xJunNtmwwuAd/LGHuq1EH/R6b3Z17WZbBn++iKvS7FyJreMaiqGAlGFmHJ3Dwkzg1E8CU/klizVcNY0ZWtbZosiklaD5VaMcwzYVmCGl9RGFO4krg= 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=bsOUKvUa 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="bsOUKvUa" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4d9fJ1205sz1DHbS; Tue, 18 Nov 2025 10:21:37 +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 4d9fJ06h3Hz1DDMt; Tue, 18 Nov 2025 10:21:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1763457697; bh=i26IscNrG/yGOdmDusxDjybIBfuxBgNEq0EZpswnJek=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bsOUKvUaxz1e867e0JANCawlYLJJinJVUGBUGujdJLis3W6mNLPHqfUbyxkoDgNnu QWIcSK9Guaz0Xi6Cmoknl4mLxuEjQ4g2s9ZoTIRl9on+KUMmd7gTt8Bi6InTW0+AYz uF/3luCg5PX7tg4uRoAvckXHXAhB8Zef23TDXtC45Lk9AO9pkK67RsiZzALf8cu0h5 tH00dB15AIf7DvsjO+QGdoyZOrqsmYpsESevkYWF/Z1HQR1rak3nR+8mGYurhqO6Q8 Hhg8rLYxE2ZfDjQTpDDAi6dTKqmxN3dSgP8ZpZcwINP/xL2b2Dow4TMyih8ogDGZpc cYEWXWuiucVOA== 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 08/10] can: grcan: Add saving and restoring of CAN FD baud-rate registers Date: Tue, 18 Nov 2025 10:21:13 +0100 Message-ID: <20251118092115.3455-9-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118092115.3455-1-arun.muthusamy@gaisler.com> References: <20251118092115.3455-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: Arun Muthusamy Signed-off-by: Daniel Hellstrom --- drivers/net/can/grcan.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 51a10fae2faf..b0e2367fb163 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -589,9 +589,19 @@ 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); + } 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); + } priv->eskbp =3D grcan_read_reg(®s->txrd); priv->can.state =3D CAN_STATE_STOPPED; -- 2.51.0 From nobody Tue Dec 2 02:43:40 2025 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 B57CC327219; Tue, 18 Nov 2025 09:21:40 +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=1763457702; cv=none; b=C5QJLqtr5bo1GHTmMaOXIi+LM9QiJ0xBChkSsP3oszJyQ8JlzPk5S1+6IXlVBdhzttOFHBXN0b6krpWY2AaJtyMRnRMTp/QP5TE8YTEQZxL4baFMetd8VKJXxfT2BLrLIYZKiwmwUA6nd4NuNeSOMVIv2qJ5X+htDzG5G7Z6JRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763457702; c=relaxed/simple; bh=ug/Om85tbIBh3JYtv6HolFoHDU30KjEcwo6+XqPwbPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fRXHf25ylJ5snkjuc1EAQ1KTUpnmHZHenEzUgFae5msFUvFKJUDRg8MRKnYbpexVpN1g80UOqIzGY0wR7/8/JuLaPm1eeXCfTu05ojttSNrVTrLO36n4E197NCxBMO8C7hIoCmn1MHQ11LmO3R+lbKs3NVocFgcFdwIjzUniFLk= 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=a9m8DajD 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="a9m8DajD" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4d9fJ318nQz1DQsp; Tue, 18 Nov 2025 10:21:39 +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 4d9fJ214cNz1DDTS; Tue, 18 Nov 2025 10:21:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1763457699; bh=DB+/tMqLlPkDZnPEDnw4du5Ox/vJip09odqNd4Jpj68=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a9m8DajD/yUrXtHDnt0RAsddXnnPJigvXbMyyajH9SMM5kmPvCWNaZftG33NYIL+q UdTuBi1yBbPh3ND8F1Z3+aVckWGYepwVxOkQsaalMH7y2Au47gmOmRgCGzDsM1OadY FeEclIPKZMSxC1a7HJwN8S3YIVw/mZd3mX7h/WmDV1DDV03e2fnfcpPtDSvIjmwtNb TNaMtoOTryiZ/g+U79M1I+FtDC8jgSWSWmOavLP8i7U8+tC6XhLuZMfL5OsTWe0vdX jNP59Se+qbY+std+LStmAHXxeoxJxor7T+0o+cs5eHTVCBkhmuYByAIu5Ib+sX9kPo xS56bVcc3eZeA== 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 09/10] can: grcan: Reserve space between cap and next register to align with address layout Date: Tue, 18 Nov 2025 10:21:14 +0100 Message-ID: <20251118092115.3455-10-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118092115.3455-1-arun.muthusamy@gaisler.com> References: <20251118092115.3455-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: Arun Muthusamy Signed-off-by: Daniel Hellstrom --- 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 b0e2367fb163..8753bff4f917 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -48,7 +48,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 Tue Dec 2 02:43:40 2025 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 1DADA3002D0; Tue, 18 Nov 2025 09:21:41 +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=1763457704; cv=none; b=OpacY4ltQHldToS59wRAYREPKb5Cf/GFbY3+p+DN3n4EU2Gpx9+RzyqJf5CjfL+UACffUxratlqsJwv1fRY59hFo/ENrJ9lxeodQumn/qU+sViib6TR+NttOWnvXAsWQU0BfMfdY1wDqW+PPpCXnFHbtH1YDxLDM3ucMJ0J6aEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763457704; c=relaxed/simple; bh=eYJDVvzMxd54Z6ewy3W7588Nnt5sWQmA67ybVJy6Miw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rn//xuVYQ9w/VYAH+akARL2dfghA7wwnxHS8/oXBnMwPSJL5eJWsHScX7CpOzgpGeUZSZH3tt8TqEjRJxp38bi4ELLh0cIuWaqSIAHuIdLNzYw5ojcrXvF1CQo/CF4CWOjgnrJyIIODJM+Hy1faC9LMpJT17palznigua6TdQRQ= 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=fZ6PWCz6 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="fZ6PWCz6" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4d9fJ43nynz1DQs2; Tue, 18 Nov 2025 10:21:40 +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 4d9fJ36qpDz1DHWH; Tue, 18 Nov 2025 10:21:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=simplycom2; t=1763457700; bh=onHjwDINwmfoLhPqJh9wE9PG6GD3/mlPECyMzfMSbN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fZ6PWCz6nmJGjdeNS4QuH/Uc4yjAVyiviYnXTPoXamtkcX1KuRg9UGw7z5nQs7Drb cq34IScgqYn9hwVtfMalsuzD8KCG+43zFsg8nEc1YWAK5jqmBHYfUYbhknV087xena Py9akGuYeLGERX+dXBNArp0y8kh7LzmtHqJS1e/FstCKyixCn2vuI0hDFDQpRAl1js pA1kdWxkOv0gYB/llIaeCxBswuoGEL4hPHjWYvLW6UUI+uFLJ9cUKdRC13v3o5q7ul H3dNySGAC3tsQpXndNOUGD+hpLFsIeVQ4Ta9K+1H3SfOum7JJM2ncetCs1oyzFOWfG 8ElOyCtW8ptrA== 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 10/10] can: grcan: Add CANFD support alongside legacy CAN Date: Tue, 18 Nov 2025 10:21:15 +0100 Message-ID: <20251118092115.3455-11-arun.muthusamy@gaisler.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118092115.3455-1-arun.muthusamy@gaisler.com> References: <20251118092115.3455-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 support with the legacy CAN support, enabling support for extended data payloads up to 64 bytes, higher bit rates, handle canecho frames. Signed-off-by: Arun Muthusamy --- drivers/net/can/grcan.c | 240 ++++++++++++++++++++++++++++------------ 1 file changed, 167 insertions(+), 73 deletions(-) diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 8753bff4f917..ff7ab979d2c9 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c @@ -44,6 +44,8 @@ #define GRCAN_RESERVE_SIZE(slot1, slot2) (((slot2) - (slot1)) / 4 - 1) +#define CHECK_SLOT_FDF(slot) ((slot) & GRCAN_RX_FDF) + struct grcan_registers { u32 conf; /* 0x00 */ u32 stat; /* 0x04 */ @@ -181,8 +183,11 @@ struct grcan_registers { | GRCAN_IRQ_TXAHBERR | GRCAN_IRQ_RXAHBERR \ | GRCAN_IRQ_TXLOSS) #define GRCAN_IRQ_DEFAULT (GRCAN_IRQ_RX | GRCAN_IRQ_TX | GRCAN_IRQ_ERRORS) +#define GRCAN_CTRL_MODES (CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_ONE_SHOT) +#define GRCAN_CTRL_MODES_FD (CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_ONE_SH= OT | CAN_CTRLMODE_FD) #define GRCAN_MSG_SIZE 16 +#define GRCAN_CLASSIC_DATA_SIZE 8 #define GRCAN_MSG_IDE 0x80000000 #define GRCAN_MSG_RTR 0x40000000 @@ -264,6 +269,12 @@ 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) + +#define GRCAN_RX_BRS BIT(25) +#define GRCAN_RX_FDF BIT(26) + /* Hardware capabilities */ struct grcan_hwcap { /* CAN-FD capable, indicates GRCANFD IP. @@ -326,6 +337,13 @@ 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. + * It's important for ensuring that we correctly manage the echo skb. + */ + u32 echo_skb_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. @@ -637,7 +655,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 @@ -648,19 +666,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; } @@ -1174,6 +1195,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->echo_skb_idx =3D 0; spin_unlock_irqrestore(&priv->lock, flags); return err; } @@ -1223,7 +1245,6 @@ static int grcan_open(struct net_device *dev) netif_start_queue(dev); priv->resetting =3D false; priv->closing =3D false; - spin_unlock_irqrestore(&priv->lock, flags); return 0; @@ -1294,20 +1315,29 @@ static void grcan_transmit_catch_up(struct net_devi= ce *dev) spin_unlock_irqrestore(&priv->lock, flags); } +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); struct grcan_registers __iomem *regs =3D priv->regs; struct grcan_dma *dma =3D &priv->dma; struct net_device_stats *stats =3D &dev->stats; - struct can_frame *cf; + struct canfd_frame *cf; struct sk_buff *skb; - u32 wr, rd, startrd; + u32 wr, rd, dlc, startrd; u32 *slot; u32 rtr, eff; - int work_done =3D 0; + u8 *data; + int i, bds, payload_offset, copy_len, work_done =3D 0; 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 */ @@ -1315,44 +1345,70 @@ 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 (CHECK_SLOT_FDF(slot[1])) + 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); - } - 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) { - *(u32 *)(cf->data) =3D slot[2]; - if (cf->can_dlc > 4) - *(u32 *)(cf->data + 4) =3D slot[3]; + dlc =3D (slot[1] & GRCAN_MSG_DLC) >> GRCAN_MSG_DLC_BIT; + if (CHECK_SLOT_FDF(slot[1])) + 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 ((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); + } + if (rtr) + cf->can_id |=3D CAN_RTR_FLAG; + + dlc =3D (slot[1] & GRCAN_MSG_DLC) >> GRCAN_MSG_DLC_BIT; + if (CHECK_SLOT_FDF(slot[1])) + 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; } - - stats->rx_bytes +=3D cf->len; + rd +=3D GRCAN_MSG_SIZE; + if (rd >=3D dma->tx.size) + rd -=3D dma->tx.size; } - stats->rx_packets++; + /* 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 @@ -1479,12 +1535,15 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff = *skb, struct grcan_priv *priv =3D netdev_priv(dev); struct grcan_registers __iomem *regs =3D priv->regs; struct grcan_dma *dma =3D &priv->dma; - struct can_frame *cf =3D (struct can_frame *)skb->data; - u32 id, txwr, txrd, space, txctrl; - int slotindex; - u32 *slot; - u32 rtr, eff, dlc, tmp, err; + struct can_frame *cf; + struct canfd_frame *cfd; + int i, bds, copy_len, payload_offset; unsigned long flags; + u8 *payload; + u8 len; + u32 *slot; + u32 eff, rtr, dlc, tmp, err, can_id; + u32 id, txwr, txrd, space, txctrl; u32 oneshotmode =3D priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT; if (can_dev_dropped_skb(dev, skb)) @@ -1496,6 +1555,20 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *= skb, if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) return NETDEV_TX_BUSY; + if (can_is_canfd_skb(skb)) { + cfd =3D (struct canfd_frame *)skb->data; + len =3D cfd->len; + dlc =3D can_fd_len2dlc(cfd->len); + can_id =3D cfd->can_id; + payload =3D cfd->data; + } else { + cf =3D (struct can_frame *)skb->data; + len =3D cf->len; + dlc =3D can_get_cc_dlc(cf, priv->can.ctrlmode); + can_id =3D cf->can_id; + payload =3D cf->data; + } + /* 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. @@ -1504,9 +1577,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); @@ -1522,24 +1593,38 @@ 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; - - slot[1] =3D ((dlc << GRCAN_MSG_DLC_BIT) & GRCAN_MSG_DLC); - slot[2] =3D 0; - slot[3] =3D 0; - if (dlc > 0) { - slot[2] =3D *(u32 *)(cf->data); /* data aligned 64-bit */ - if (dlc > 4) - slot[3] =3D *(u32 *)(cf->data + 4); + 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 (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; + slot[1] =3D ((dlc << GRCAN_MSG_DLC_BIT) & GRCAN_MSG_DLC); + if (can_is_canfd_skb(skb)) { + slot[1] |=3D GRCAN_TX_FDF; + if (cfd->flags & CANFD_BRS) + slot[1] |=3D GRCAN_TX_BRS; + } + + 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 @@ -1574,7 +1659,14 @@ 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); + + can_put_echo_skb(skb, dev, priv->echo_skb_idx, 0); + + /* Move to the next index in the echo skb buffer */ + priv->echo_skb_idx =3D (priv->echo_skb_idx + 1) % priv->can.echo_skb_max; + + if (priv->can.echo_skb[priv->echo_skb_idx]) + netif_stop_queue(dev); /* Make sure everything is written before allowing hardware to * read from the memory @@ -1582,8 +1674,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; } @@ -1734,12 +1825,15 @@ 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_bittiming =3D hwcap->set_bittiming; 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 GRCAN_CTRL_MODES_FD; + else + priv->can.ctrlmode_supported =3D GRCAN_CTRL_MODES; priv->need_txbug_workaround =3D txbug; priv->hwcap =3D hwcap; -- 2.51.0