Skip to contentSkip to conversation

can: amlogic: add support for Amlogic A9 CAN-FD controller

PATCH In review zelong dong 3 participants 9 messages Nov 20 – Dec 1

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover can: amlogic: add support for Amlogic A9 CAN-FD controller

From: Zelong Dong <[email protected]>

This series adds support for the CAN-FD controller found on the Amlogic A9 SoC family.

The controller supports classic CAN and CAN-FD. The driver uses the generic RX offload infrastructure with hardware timestamps, reports bus errors through the CAN berr counter, and implements suspend/resume support.

Zelong Dong (3):
dt-bindings: net: can: add Amlogic A9 CAN controller
can: amlogic: add driver for Amlogic A9 CAN-FD controller
arm64: dts: amlogic: a9: add CAN controller node

 .../bindings/net/can/amlogic,a9-can.yaml      |  65 ++
 .../dts/amlogic/amlogic-a9-a311y3-by401.dts   |   7 +
 arch/arm64/boot/dts/amlogic/amlogic-a9.dtsi   |  25 +
 drivers/net/can/Kconfig                       |   1 +
 drivers/net/can/Makefile                      |   1 +
 drivers/net/can/amlogic/Kconfig               |   9 +
 drivers/net/can/amlogic/Makefile              |   3 +
 drivers/net/can/amlogic/amlogic_can.c         | 864 ++++++++++++++++++
 drivers/net/can/amlogic/amlogic_can.h         | 367 ++++++++
 9 files changed, 1342 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/can/amlogic,a9-can.yaml
 create mode 100644 drivers/net/can/amlogic/Kconfig
 create mode 100644 drivers/net/can/amlogic/Makefile
 create mode 100644 drivers/net/can/amlogic/amlogic_can.c
 create mode 100644 drivers/net/can/amlogic/amlogic_can.h
Signature · 1 line
2.47.1
#1 lore raw

PATCH 1/3 dt-bindings: net: can: add Amlogic A9 CAN controller

From: Zelong Dong <[email protected]>

Add device tree bindings for the CAN-FD controller found on the Amlogic A9 SoC family.

---
 .../bindings/net/can/amlogic,a9-can.yaml      | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/can/amlogic,a9-can.yaml
Documentation/devicetree/bindings/net/can/amlogic,a9-can.yaml new file +65 -0
new file mode 100644
index 000000000000..dd4ad6147f2e
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# # Copyright (C) 2026 Amlogic, Inc. All rights reserved
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/can/amlogic,a9-can.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic A9 SoC CANBus Controller
+
+maintainers:
+  - Zelong Dong <[email protected]>
+
+properties:
+  compatible:
+    const: amlogic,a9-can
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: CAN protocol engine clock
+      - description: CAN filter clock
+
+  clock-names:
+    items:
+      - const: can_pe
+      - const: can_filter
+
+  power-domains:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+allOf:
+  - $ref: can-controller.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    bus {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        can@3a8000 {
+            compatible = "amlogic,a9-can";
+            reg = <0x0 0x3a8000 0x0 0x383c>;
+            interrupts = <GIC_SPI 82 IRQ_TYPE_EDGE_RISING>;
+            clocks = <&clkc_periphs 0>,
+                     <&clkc_periphs 1>;
+            clock-names = "can_pe", "can_filter";
+            power-domains = <&pwrc 2>;
+        };
+    };
Signature · 1 line
2.47.1
maintainer
#2 lore raw

Re: [PATCH 1/3] dt-bindings: net: can: add Amlogic A9 CAN controller

Quoted 38 lines · zelong dong

From: Zelong Dong <[email protected]>

Add device tree bindings for the CAN-FD controller found on the Amlogic A9 SoC family.

---
 .../bindings/net/can/amlogic,a9-can.yaml      | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/can/amlogic,a9-can.yaml
Documentation/devicetree/bindings/net/can/amlogic,a9-can.yaml new file +21 -0
new file mode 100644
index 000000000000..dd4ad6147f2e
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# # Copyright (C) 2026 Amlogic, Inc. All rights reserved
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/can/amlogic,a9-can.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Amlogic A9 SoC CANBus Controller
+
+maintainers:
+  - Zelong Dong <[email protected]>
+
+properties:
+  compatible:
+    const: amlogic,a9-can
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1

Documentation/devicetree/bindings/net/can/amlogic,a9-can.yaml line 31

Quoted 10 lines
Documentation/devicetree/bindings/net/can/amlogic,a9-can.yaml new file +10 -0
+
+  clocks:
+    items:
+      - description: CAN protocol engine clock
+      - description: CAN filter clock
+
+  clock-names:
+    items:
+      - const: can_pe
+      - const: can_filter

Drop 'can_'. It's redundant.

Quoted 37 lines
Documentation/devicetree/bindings/net/can/amlogic,a9-can.yaml new file +34 -0
+
+  power-domains:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+allOf:
+  - $ref: can-controller.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    bus {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        can@3a8000 {
+            compatible = "amlogic,a9-can";
+            reg = <0x0 0x3a8000 0x0 0x383c>;
+            interrupts = <GIC_SPI 82 IRQ_TYPE_EDGE_RISING>;
+            clocks = <&clkc_periphs 0>,
+                     <&clkc_periphs 1>;
+            clock-names = "can_pe", "can_filter";
+            power-domains = <&pwrc 2>;
+        };
+    };
Signature · 1 line
2.47.1
#3 lore raw

PATCH 2/3 can: amlogic: add driver for Amlogic A9 CAN-FD controller

In reply to zelong dong

From: Zelong Dong <[email protected]>

Add a driver for the CAN-FD controller found on the Amlogic A9 SoC family. The controller supports both classic CAN and CAN-FD.

The driver uses the generic RX offload infrastructure with hardware timestamps, reports bus errors through the CAN berr counter, and implements suspend/resume support.

---
 drivers/net/can/Kconfig               |   1 +
 drivers/net/can/Makefile              |   1 +
 drivers/net/can/amlogic/Kconfig       |   9 +
 drivers/net/can/amlogic/Makefile      |   3 +
 drivers/net/can/amlogic/amlogic_can.c | 864 ++++++++++++++++++++++++++
 drivers/net/can/amlogic/amlogic_can.h | 367 +++++++++++
 6 files changed, 1245 insertions(+)
 create mode 100644 drivers/net/can/amlogic/Kconfig
 create mode 100644 drivers/net/can/amlogic/Makefile
 create mode 100644 drivers/net/can/amlogic/amlogic_can.c
 create mode 100644 drivers/net/can/amlogic/amlogic_can.h
drivers/net/can/Kconfig +1 -0
index a8fad6fe5302..fbd7523f38a4 100644
@@ -257,6 +257,7 @@ source "drivers/net/can/sja1000/Kconfig"
 source "drivers/net/can/softing/Kconfig"
 source "drivers/net/can/spi/Kconfig"
 source "drivers/net/can/usb/Kconfig"
+source "drivers/net/can/amlogic/Kconfig"
 
 endif #CAN_NETLINK
 
drivers/net/can/Makefile +1 -0
index 4010d17f8583..a5cec506bab4 100644
@@ -35,5 +35,6 @@ obj-$(CONFIG_CAN_SUN4I)		+= sun4i_can.o
 obj-$(CONFIG_CAN_TI_HECC)	+= ti_hecc.o
 obj-$(CONFIG_CAN_VIRTIO_CAN)	+= virtio_can.o
 obj-$(CONFIG_CAN_XILINXCAN)	+= xilinx_can.o
+obj-$(CONFIG_CAN_AMLOGIC)	+= amlogic/
 
 subdir-ccflags-$(CONFIG_CAN_DEBUG_DEVICES) += -DDEBUG
drivers/net/can/amlogic/Kconfig new file +9 -0
new file mode 100644
index 000000000000..52e5298061f1
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR MIT)
+
+config CAN_AMLOGIC
+        tristate "Amlogic CANBUS Controller"
+	select CAN_RX_OFFLOAD
+	default n
+        help
+          Say Y here if you want to use Amlogic CANBUS Controller.
+
drivers/net/can/amlogic/Makefile new file +3 -0
new file mode 100644
index 000000000000..20a0b33b3098
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR MIT)
+
+obj-$(CONFIG_CAN_AMLOGIC) += amlogic_can.o
drivers/net/can/amlogic/amlogic_can.c new file +864 -0

864 lines not on this page · raw message

drivers/net/can/amlogic/amlogic_can.h new file +367 -0

367 lines not on this page · raw message

Signature · 1 line
2.47.1
#4 lore raw

PATCH 3/3 arm64: dts: amlogic: a9: add CAN controller node

In reply to zelong dong

From: Zelong Dong <[email protected]>

Add the CAN controller node and its pinmux states to the Amlogic A9 SoC device tree. Enable the controller on the A311Y3 BY401 board.

---
 .../dts/amlogic/amlogic-a9-a311y3-by401.dts   |  7 ++++++
 arch/arm64/boot/dts/amlogic/amlogic-a9.dtsi   | 25 +++++++++++++++++++
 2 files changed, 32 insertions(+)
arch/arm64/boot/dts/amlogic/amlogic-a9-a311y3-by401.dts +7 -0
index 503e38a29ce6..dffcdd4c35d0 100644
@@ -136,3 +136,10 @@ &spisg_e {
 	pinctrl-names = "default";
 	pinctrl-0 = <&spisg_e_pins_z>;
 };
+
+&canbus {
+	pinctrl-0 = <&can0_pins>;
+	pinctrl-1 = <&can0_pins_sleep>;
+	pinctrl-names = "default", "sleep";
+	status = "okay";
+};
arch/arm64/boot/dts/amlogic/amlogic-a9.dtsi +25 -0
index 509dd1c37a5d..7c3734c4d23f 100644
@@ -605,6 +605,20 @@ spisg_e_pins_z: group-spisg-e-pins {
 						drive-strength-microamp = <3000>;
 					};
 				};
+
+				func-can0 {
+					can0_pins: group-can0-pins {
+						pinmux = <AML_PINMUX(AMLOGIC_GPIO_A, 18, 3)>,
+							 <AML_PINMUX(AMLOGIC_GPIO_A, 19, 3)>;
+						bias-disable;
+					};
+
+					can0_pins_sleep: group-can0-pins-sleep {
+						pinmux = <AML_PINMUX(AMLOGIC_GPIO_A, 18, 0)>,
+							 <AML_PINMUX(AMLOGIC_GPIO_A, 19, 0)>;
+						input-enable;
+					};
+				};
 			};
 
 			spisg_e: spi@50100 {
@@ -677,6 +691,17 @@ i2c8: i2c@3a4800 {
 				clocks = <&clkc_periphs CLKID_SYS_I2C_M_I>;
 				status = "disabled";
 			};
+
+			canbus: can@3a8000 {
+				compatible = "amlogic,a9-can";
+				reg = <0x0 0x3a8000 0x0 0x383c>;
+				interrupts = <GIC_SPI 82 IRQ_TYPE_EDGE_RISING>;
+				clocks = <&clkc_periphs CLKID_CAN0_PE>,
+					 <&clkc_periphs CLKID_CAN0_FILTER>;
+				clock-names = "can_pe", "can_filter";
+				power-domains = <&pwrc PWRC_A9_CAN0_ID>;
+				status = "disabled";
+			};
 		};
 
 		gic: interrupt-controller@ff800000 {
Signature · 1 line
2.47.1
#5 lore raw
In reply to zelong dong
Quoted 9 lines · zelong dong

From: Zelong Dong <[email protected]>

This series adds support for the CAN-FD controller found on the Amlogic A9 SoC family.

The controller supports classic CAN and CAN-FD. The driver uses the generic RX offload infrastructure with hardware timestamps, reports bus errors through the CAN berr counter, and implements suspend/resume support.

Have you had a look at the flexcan driver? The register layout of the IP core (and parts of your driver) looks like they were heavily inspired by it.

Can you summarize why you require a separate driver?

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
#6 lore raw

Yes, A9 CAN Bus Controller is base on FlexCAN, but some registers are appended, and not for NXP chip,

#define CAN_VERSION          0x3800
#define CAN_TOP_CTRL                            0x3804 #define CAN_DMA_CFG                             0x3808 #define CAN_TMTIK_CFG                           0x380C #define CAN_TWRAP_INT_CLR                       0x3810
                                                /* 0x3814 - 0x3818 */
#define CAN_TIMESTAMP                           0x381C #define CAN_WARN_INT_STS                        0x3820 #define CAN_MB_INT_STS0                         0x3824 #define CAN_MB_INT_STS1                         0x3828 #define CAN_MB_INT_STS2                         0x382C #define CAN_MB_INT_STS3                         0x3830 #define CAN_STS_REG                             0x3834 #define CAN_ECC_ERR_ADDR                        0x3838

In my opinion, FlexCAN driver is only for NXP chip.
Do you think I should  update FlexCAN driver rather than a new driver?

Quoted 19 lines · Marc Kleine-Budde
Quoted 9 lines · zelong dong

From: Zelong Dong <[email protected]>

This series adds support for the CAN-FD controller found on the Amlogic A9 SoC family.

The controller supports classic CAN and CAN-FD. The driver uses the generic RX offload infrastructure with hardware timestamps, reports bus errors through the CAN berr counter, and implements suspend/resume support.

Have you had a look at the flexcan driver? The register layout of the IP core (and parts of your driver) looks like they were heavily inspired by it.

Can you summarize why you require a separate driver?

regards,
Marc

#7 lore raw
Quoted 2 lines · Zelong Dong

Yes, A9 CAN Bus Controller is base on FlexCAN, but some registers are appended, and not for NXP chip,

Was this done by amlogic or is this a newer FlexCAN core?

Quoted 15 lines

#define CAN_VERSION 0x3800

#define CAN_TOP_CTRL                            0x3804
#define CAN_DMA_CFG                             0x3808
#define CAN_TMTIK_CFG                           0x380C
#define CAN_TWRAP_INT_CLR                       0x3810
                                                 /* 0x3814 - 0x3818 */
#define CAN_TIMESTAMP                           0x381C
#define CAN_WARN_INT_STS                        0x3820
#define CAN_MB_INT_STS0                         0x3824
#define CAN_MB_INT_STS1                         0x3828
#define CAN_MB_INT_STS2                         0x382C
#define CAN_MB_INT_STS3                         0x3830
#define CAN_STS_REG                             0x3834
#define CAN_ECC_ERR_ADDR                        0x3838
Quoted 1 line

In my opinion, FlexCAN driver is only for NXP chip.

No - spacemit K1 support is currently added.

Quoted 1 line

Do you think I should update FlexCAN driver rather than a new driver?

Yes, please go ahead.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |
#8 lore raw
In reply to zelong dong
Quoted 9 lines · zelong dong

From: Zelong Dong <[email protected]>

This series adds support for the CAN-FD controller found on the Amlogic A9 SoC family.

The controller supports classic CAN and CAN-FD. The driver uses the generic RX offload infrastructure with hardware timestamps, reports bus errors through the CAN berr counter, and implements suspend/resume support.

Please base your driver on current net-next/main.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |