rockchip: add NanoPi R2C support
authorTianling Shen <cnsztl@immortalwrt.org>
Sat, 13 May 2023 05:54:38 +0000 (13:54 +0800)
committerHauke Mehrtens <hauke@hauke-m.de>
Thu, 18 May 2023 15:42:53 +0000 (17:42 +0200)
The NanoPi R2C is a minor variant of NanoPi R2S with the on-board NIC
chip changed from rtl8211e to yt8521s, and otherwise identical to R2S.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
target/linux/rockchip/armv8/base-files/etc/board.d/01_leds
target/linux/rockchip/armv8/base-files/etc/board.d/02_network
target/linux/rockchip/armv8/base-files/etc/hotplug.d/net/40-net-smp-affinity
target/linux/rockchip/image/armv8.mk
target/linux/rockchip/patches-5.15/006-v6.4-arm64-dts-rockchip-Add-FriendlyARM-NanoPi-R2C.patch [new file with mode: 0644]
target/linux/rockchip/patches-5.15/100-rockchip-use-system-LED-for-OpenWrt.patch

index b10c43ba6052ec6a6fc2dcf095f93cd6e237c274..2c9206b03ed85e6d78584c6c1a825ebeb1b58397 100644 (file)
@@ -8,10 +8,8 @@ boardname="${board##*,}"
 board_config_update
 
 case $board in
-friendlyarm,nanopi-r2s)
-       ucidef_set_led_netdev "wan" "WAN" "$boardname:green:wan" "eth0"
-       ucidef_set_led_netdev "lan" "LAN" "$boardname:green:lan" "eth1"
-       ;;
+friendlyarm,nanopi-r2c|\
+friendlyarm,nanopi-r2s|\
 friendlyarm,nanopi-r4s)
        ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth0"
        ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth1"
index 816045a480318b0bf81966fde37159eeb18dccfd..16ba01b7e313c8085b010037fa0a8cc97dbaf74d 100644 (file)
@@ -46,6 +46,7 @@ rockchip_setup_macs()
        local label_mac=""
 
        case "$board" in
+       friendlyarm,nanopi-r2c|\
        friendlyarm,nanopi-r2s)
                wan_mac=$(macaddr_generate_from_mmc_cid mmcblk0)
                lan_mac=$(macaddr_add "$wan_mac" 1)
index c76e62a23a347b9832f224788a82d50b11a1f31e..3d1d99128ecfdc36482c84631b00ec49b4d1e890 100644 (file)
@@ -29,6 +29,7 @@ set_interface_core() {
 }
 
 case "$(board_name)" in
+friendlyarm,nanopi-r2c|\
 friendlyarm,nanopi-r2s)
        set_interface_core 2 "eth0"
        set_interface_core 4 "eth1" "xhci-hcd:usb3"
index 72e5832f06c1bbf4ead92abe8dbdf8009e4fa958..601ddcbdd6b9aac91735ccb7a43c64c710064038 100644 (file)
@@ -15,6 +15,15 @@ define Device/firefly_roc-rk3328-cc
 endef
 TARGET_DEVICES += firefly_roc-rk3328-cc
 
+define Device/friendlyarm_nanopi-r2c
+  DEVICE_VENDOR := FriendlyARM
+  DEVICE_MODEL := NanoPi R2C
+  SOC := rk3328
+  IMAGE/sysupgrade.img.gz := boot-common | boot-script | pine64-img | gzip | append-metadata
+  DEVICE_PACKAGES := kmod-usb-net-rtl8152
+endef
+TARGET_DEVICES += friendlyarm_nanopi-r2c
+
 define Device/friendlyarm_nanopi-r2s
   DEVICE_VENDOR := FriendlyARM
   DEVICE_MODEL := NanoPi R2S
diff --git a/target/linux/rockchip/patches-5.15/006-v6.4-arm64-dts-rockchip-Add-FriendlyARM-NanoPi-R2C.patch b/target/linux/rockchip/patches-5.15/006-v6.4-arm64-dts-rockchip-Add-FriendlyARM-NanoPi-R2C.patch
new file mode 100644 (file)
index 0000000..f58463b
--- /dev/null
@@ -0,0 +1,70 @@
+From 004589ff9df5b75672a78b6c3c4cba93202b14c9 Mon Sep 17 00:00:00 2001
+From: Tianling Shen <cnsztl@gmail.com>
+Date: Sat, 25 Mar 2023 15:40:20 +0800
+Subject: [PATCH] arm64: dts: rockchip: Add FriendlyARM NanoPi R2C
+
+The NanoPi R2C is a minor variant of NanoPi R2S with the on-board NIC
+chip changed from rtl8211e to yt8521s, and otherwise identical to R2S.
+
+Signed-off-by: Tianling Shen <cnsztl@gmail.com>
+Link: https://lore.kernel.org/r/20230325074022.9818-3-cnsztl@gmail.com
+Signed-off-by: Heiko Stuebner <heiko@sntech.de>
+---
+ arch/arm64/boot/dts/rockchip/Makefile         |  1 +
+ .../boot/dts/rockchip/rk3328-nanopi-r2c.dts   | 40 +++++++++++++++++++
+ 2 files changed, 41 insertions(+)
+ create mode 100644 arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2c.dts
+
+--- a/arch/arm64/boot/dts/rockchip/Makefile
++++ b/arch/arm64/boot/dts/rockchip/Makefile
+@@ -9,6 +9,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3318-a9
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3326-odroid-go2.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3328-a1.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3328-evb.dtb
++dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3328-nanopi-r2c.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3328-nanopi-r2s.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3328-rock64.dtb
+ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3328-rock-pi-e.dtb
+--- /dev/null
++++ b/arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2c.dts
+@@ -0,0 +1,40 @@
++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
++/*
++ * Copyright (c) 2021 FriendlyElec Computer Tech. Co., Ltd.
++ * (http://www.friendlyarm.com)
++ *
++ * Copyright (c) 2021-2023 Tianling Shen <cnsztl@gmail.com>
++ */
++
++/dts-v1/;
++#include "rk3328-nanopi-r2s.dts"
++
++/ {
++      model = "FriendlyElec NanoPi R2C";
++      compatible = "friendlyarm,nanopi-r2c", "rockchip,rk3328";
++};
++
++&gmac2io {
++      phy-handle = <&yt8521s>;
++      tx_delay = <0x22>;
++      rx_delay = <0x12>;
++
++      mdio {
++              /delete-node/ ethernet-phy@1;
++
++              yt8521s: ethernet-phy@3 {
++                      compatible = "ethernet-phy-ieee802.3-c22";
++                      reg = <3>;
++
++                      motorcomm,clk-out-frequency-hz = <125000000>;
++                      motorcomm,keep-pll-enabled;
++                      motorcomm,auto-sleep-disabled;
++
++                      pinctrl-0 = <&eth_phy_reset_pin>;
++                      pinctrl-names = "default";
++                      reset-assert-us = <10000>;
++                      reset-deassert-us = <50000>;
++                      reset-gpios = <&gpio1 RK_PC2 GPIO_ACTIVE_LOW>;
++              };
++      };
++};
index 4b963f33483e157ed1b80f18ed73422c6533ce1b..01009c5eb8411b1374cd99f061ecc7fd7c2ce31a 100644 (file)
@@ -27,6 +27,28 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
        };
  
        chosen {
+@@ -49,18 +54,18 @@
+               lan_led: led-0 {
+                       gpios = <&gpio2 RK_PB7 GPIO_ACTIVE_HIGH>;
+-                      label = "nanopi-r2s:green:lan";
++                      label = "green:lan";
+               };
+               sys_led: led-1 {
+                       gpios = <&gpio0 RK_PA2 GPIO_ACTIVE_HIGH>;
+-                      label = "nanopi-r2s:red:sys";
++                      label = "red:sys";
+                       default-state = "on";
+               };
+               wan_led: led-2 {
+                       gpios = <&gpio2 RK_PC2 GPIO_ACTIVE_HIGH>;
+-                      label = "nanopi-r2s:green:wan";
++                      label = "green:wan";
+               };
+       };
 --- a/arch/arm64/boot/dts/rockchip/rk3328-roc-cc.dts
 +++ b/arch/arm64/boot/dts/rockchip/rk3328-roc-cc.dts
 @@ -13,6 +13,11 @@