Enable CAN support on RK3588
Heiko Stuebner
maintainercover Enable CAN support on RK3588
The RK3588 uses basically the same CAN controller as the RK3588, except the documentation stopped claiming for it to support CAN-FD.
So add a compatible to the binding, the basic driver support and the errata I could test for so far + enable CAN on the Tiger-Haikou board.
I'm not sure if more errata apply, so I've added Elaine Zhang in Cc to maybe add more information.
Heiko Stuebner (6):
dt-bindings: can: rockchip_canfd: add compatible for the RK3588
variant
can: rockchip-canfd: add support for the RK3588 variant
can: rockchip-canfd: enable erratum 6 on RK3588
can: rockchip-canfd: enable erratum 5 on RK3588
arm64: dts: rockchip: Add RK3588 CAN controller nodes
arm64: dts: rockchip: Enable CAN controller on RK3588-Tiger-Haikou
.../net/can/rockchip,rk3568v2-canfd.yaml | 1 + arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 39 +++++++++++++++++++ .../boot/dts/rockchip/rk3588-tiger-haikou.dts | 6 +++ .../net/can/rockchip/rockchip_canfd-core.c | 12 ++++++ drivers/net/can/rockchip/rockchip_canfd.h | 1 + 5 files changed, 59 insertions(+)
Signature · 1 line
2.47.3
Heiko Stuebner
maintainerPATCH 1/6 dt-bindings: can: rockchip_canfd: add compatible for the RK3588 variant
From: Heiko Stuebner <[email protected]>
The RK3588 uses a variant of the CAN(-FD) controller introduced at first with the RK3568 SoC.
--- .../devicetree/bindings/net/can/rockchip,rk3568v2-canfd.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/can/rockchip,rk3568v2-canfd.yaml +1 -0
@@ -20,6 +20,7 @@ properties: - items: - const: rockchip,rk3568v3-canfd - const: rockchip,rk3568v2-canfd + - const: rockchip,rk3588-canfd reg: maxItems: 1
Signature · 1 line
2.47.3
Re: [PATCH 1/6] dt-bindings: can: rockchip_canfd: add compatible for the RK3588 variant
Quoted 15 lines · Heiko Stuebner
From: Heiko Stuebner <[email protected]>
The RK3588 uses a variant of the CAN(-FD) controller introduced at first with the RK3568 SoC.
Signed-off-by Heiko Stuebner <[email protected]>--- .../devicetree/bindings/net/can/rockchip,rk3568v2-canfd.yaml | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/net/can/rockchip,rk3568v2-canfd.yaml +0
-0
Documentation/devicetree/bindings/net/can/rockchip,rk3568v2-canfd.yaml properties: · line 23
Quoted 4 lines
Documentation/devicetree/bindings/net/can/rockchip,rk3568v2-canfd.yaml +1
-0@@ -20,6 +20,7 @@ properties: - items: - const: rockchip,rk3568v3-canfd - const: rockchip,rk3568v2-canfd + - const: rockchip,rk3588-canfd
So this is just an enum with the first entry.
Best regards,
Krzysztof
Heiko Stuebner
maintainerPATCH 2/6 can: rockchip-canfd: add support for the RK3588 variant
In reply to Heiko StuebnerFrom: Heiko Stuebner <[email protected]>
The RK3588 SoC uses a variant of this controller.
From the start it does not claim to support can-fd in any part of the documentation, so it seems that is still broken.
Further errata will be enabled in subsequent patches, with more in-depth explanation.
--- drivers/net/can/rockchip/rockchip_canfd-core.c | 11 +++++++++++ drivers/net/can/rockchip/rockchip_canfd.h | 1 + 2 files changed, 12 insertions(+)
drivers/net/can/rockchip/rockchip_canfd-core.c +11 -0
@@ -50,6 +50,12 @@ static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3568v3 = { RKCANFD_QUIRK_CANFD_BROKEN, }; +static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3588 = { + .model =RKCANFD_MODEL_RK3588 , + .quirks =/* Possibly more errata */ +RKCANFD_QUIRK_CANFD_BROKEN , +}; +static const char *__rkcanfd_get_model_str (enum rkcanfd_model model) {switch (model) {
@@ -57,6 +63,8 @@ static const char *__rkcanfd_get_model_str(enum rkcanfd_model model)return "rk3568v2" ;case RKCANFD_MODEL_RK3568V3 :return "rk3568v3" ; +case RKCANFD_MODEL_RK3588 : +return "rk3588" ; }return "<unknown>" ;
@@ -846,6 +854,9 @@ static const struct of_device_id rkcanfd_of_match[] = { }, { .compatible = "rockchip,rk3568v3-canfd", .data = &rkcanfd_devtype_data_rk3568v3, + }, { + .compatible = "rockchip,rk3588-canfd", + .data = &rkcanfd_devtype_data_rk3588, }, { /* sentinel */ },
drivers/net/can/rockchip/rockchip_canfd.h +1 -0
@@ -434,6 +434,7 @@enum rkcanfd_model {RKCANFD_MODEL_RK3568V2 =0x35682 ,RKCANFD_MODEL_RK3568V3 =0x35683 , +RKCANFD_MODEL_RK3588 =0x3588 , };struct rkcanfd_devtype_data {
Signature · 1 line
2.47.3
Heiko Stuebner
maintainerPATCH 3/6 can: rockchip-canfd: enable erratum 6 on RK3588
In reply to Heiko StuebnerFrom: Heiko Stuebner <[email protected]>
Sending extended CAN frames from the RK3588's CAN controller, sometimes sends standard frames, as explained in the erratum's description:
can0 00001234 [4] DE AD BE EF can0 00000001 [4] DE AD BE EF can0 000007FF [4] DE AD BE EF can0 00000800 [4] DE AD BE EF can0 1FFFFFFF [4] DE AD BE EF can0 12345678 [4] DE AD BE EF can0 234 [4] DE AD BE EF can0 00000001 [4] DE AD BE EF
Enabling the erratum, introduces the correct behaviour in re-sending the frame:
can0 1FFFFFFF [4] DE AD BE EF can0 12345678 [4] DE AD BE EF can0 234 [4] DE AD BE EF can0 00001234 [4] DE AD BE EF can0 00000001 [4] DE AD BE EF
--- drivers/net/can/rockchip/rockchip_canfd-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/rockchip/rockchip_canfd-core.c +1 -0
@@ -53,6 +53,7 @@ static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3568v3 = {static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3588 = { .model =RKCANFD_MODEL_RK3588 , .quirks =/* Possible more Errata */ +RKCANFD_QUIRK_RK3568_ERRATUM_6 ,RKCANFD_QUIRK_CANFD_BROKEN , };
Signature · 1 line
2.47.3
Heiko Stuebner
maintainerPATCH 4/6 can: rockchip-canfd: enable erratum 5 on RK3588
In reply to Heiko StuebnerFrom: Heiko Stuebner <[email protected]>
Lowering the clock-frequency as described in the erratum, also leads to empty RX-fifos immediately, indicating that the erratum is also present on the RK3588 variant.
--- drivers/net/can/rockchip/rockchip_canfd-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/rockchip/rockchip_canfd-core.c +1 -1
@@ -53,7 +53,7 @@ static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3568v3 = {static const struct rkcanfd_devtype_data rkcanfd_devtype_data_rk3588 = { .model =RKCANFD_MODEL_RK3588 , .quirks =/* Possible more Errata */ -RKCANFD_QUIRK_RK3568_ERRATUM_6 , +RKCANFD_QUIRK_RK3568_ERRATUM_5 |RKCANFD_QUIRK_RK3568_ERRATUM_6 ,RKCANFD_QUIRK_CANFD_BROKEN , };
Signature · 1 line
2.47.3
Heiko Stuebner
maintainerPATCH 5/6 arm64: dts: rockchip: Add RK3588 CAN controller nodes
In reply to Heiko StuebnerFrom: Heiko Stuebner <[email protected]>
The RK3588 has 3 CAN controllers, so add the core nodes for them.
--- arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi +39 -0
@@ -2648,6 +2648,45 @@ dmac1: dma-controller@fea30000 { #dma-cells = <1>; }; + can0: can@fea50000 { + compatible = "rockchip,rk3588-canfd"; + reg = <0x0 0xfea50000 0x0 0x1000>; + interrupts = <GIC_SPI 341 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&cru CLK_CAN0>, <&cru PCLK_CAN0>; + clock-names = "baud", "pclk"; + pinctrl-names = "default"; + pinctrl-0 = <&can0m0_pins>; + resets = <&cru SRST_CAN0>, <&cru SRST_P_CAN0>; + reset-names = "can", "apb"; + status = "disabled"; + }; + + can1: can@fea60000 { + compatible = "rockchip,rk3588-canfd"; + reg = <0x0 0xfea60000 0x0 0x1000>; + interrupts = <GIC_SPI 342 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&cru CLK_CAN1>, <&cru PCLK_CAN1>; + clock-names = "baud", "pclk"; + pinctrl-names = "default"; + pinctrl-0 = <&can1m0_pins>; + resets = <&cru SRST_CAN1>, <&cru SRST_P_CAN1>; + reset-names = "can", "apb"; + status = "disabled"; + }; + + can2: can@fea70000 { + compatible = "rockchip,rk3588-canfd"; + reg = <0x0 0xfea70000 0x0 0x1000>; + interrupts = <GIC_SPI 343 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&cru CLK_CAN2>, <&cru PCLK_CAN2>; + clock-names = "baud", "pclk"; + pinctrl-names = "default"; + pinctrl-0 = <&can2m0_pins>; + resets = <&cru SRST_CAN2>, <&cru SRST_P_CAN2>; + reset-names = "can", "apb"; + status = "disabled"; + }; + i2c1: i2c@fea90000 { compatible = "rockchip,rk3588-i2c", "rockchip,rk3399-i2c"; reg = <0x0 0xfea90000 0x0 0x1000>;
Signature · 1 line
2.47.3
Heiko Stuebner
maintainerPATCH 6/6 arm64: dts: rockchip: Enable CAN controller on RK3588-Tiger-Haikou
In reply to Heiko StuebnerFrom: Heiko Stuebner <[email protected]>
CAN0 is piped through the Q7-connector to the CAN-Header on the Haikou base-board, so enable support for it there.
At least on RK3588-Tiger, the CAN clocks default to 99MHz, limiting usable CAN bitrates without skew. Errata documentation mentions 300MHz as the default frequency on RK3568, so replicate this here to allow more bitrates.
--- arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/rockchip/rk3588-tiger-haikou.dts +6 -0
@@ -155,6 +155,12 @@ vddd_audio_1v6: regulator-vddd-audio-1v6 { }; }; +&can0 { + assigned-clocks = <&cru CLK_CAN0>; + assigned-clock-rates = <300000000>; + status = "okay"; +}; + &combphy2_psu { status = "okay"; };
Signature · 1 line
2.47.3