From 3625a730463a8adc32790b7af3d7867a1136cbb1 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Tue, 13 Jul 2021 00:37:50 +0800 Subject: [PATCH] ramips: switch to kernel 5.10 --- package/lean/luci-app-turboacc/Makefile | 2 +- target/linux/ramips/Makefile | 3 +- .../dts/mt7620a_alfa-network_ac1200rm.dts | 4 - .../dts/mt7620a_alfa-network_r36m-e4g.dts | 4 - .../dts/mt7620a_alfa-network_tube-e4g.dts | 4 - .../linux/ramips/dts/mt7620a_asus_rp-n53.dts | 3 +- .../ramips/dts/mt7620a_buffalo_whr-1166d.dts | 4 - .../ramips/dts/mt7620a_buffalo_whr-300hp2.dts | 4 - .../ramips/dts/mt7620a_buffalo_whr-600d.dts | 4 - .../linux/ramips/dts/mt7620a_cameo_810.dtsi | 4 - .../ramips/dts/mt7620a_dlink_dch-m225.dts | 4 - .../ramips/dts/mt7620a_dlink_dir-510l.dts | 4 - .../ramips/dts/mt7620a_dlink_dwr-118-a1.dts | 3 +- .../ramips/dts/mt7620a_dlink_dwr-118-a2.dts | 4 +- .../ramips/dts/mt7620a_dovado_tiny-ac.dts | 3 +- .../dts/mt7620a_edimax_br-6478ac-v2.dts | 2 +- .../ramips/dts/mt7620a_edimax_ew-7478apc.dts | 2 +- .../ramips/dts/mt7620a_edimax_ew-747x.dtsi | 4 +- .../ramips/dts/mt7620a_engenius_esr600.dts | 7 +- .../linux/ramips/dts/mt7620a_fon_fon2601.dts | 3 +- .../dts/mt7620a_head-weblink_hdrm200.dts | 5 + .../ramips/dts/mt7620a_iodata_wn-ac1167gr.dts | 4 + .../ramips/dts/mt7620a_iptime_a1004ns.dts | 4 + .../ramips/dts/mt7620a_lava_lr-25g001.dts | 27 +- .../ramips/dts/mt7620a_lb-link_bl-w1200.dts | 4 + .../ramips/dts/mt7620a_lenovo_newifi-y1s.dts | 3 +- .../ramips/dts/mt7620a_linksys_e1700.dts | 2 +- .../linux/ramips/dts/mt7620a_netis_wf2770.dts | 4 + .../ramips/dts/mt7620a_ohyeah_oy-0001.dts | 4 - .../ramips/dts/mt7620a_planex_cs-qr10.dts | 4 - .../ramips/dts/mt7620a_planex_db-wrt01.dts | 4 - .../ramips/dts/mt7620a_planex_mzk-750dhp.dts | 4 - .../ramips/dts/mt7620a_ralink_mt7620a-evb.dts | 3 +- .../dts/mt7620a_ralink_mt7620a-mt7530-evb.dts | 2 +- .../mt7620a_ralink_mt7620a-mt7610e-evb.dts | 4 - .../dts/mt7620a_ralink_mt7620a-v22sg-evb.dts | 3 +- .../ramips/dts/mt7620a_sercomm_na930.dts | 3 +- .../dts/mt7620a_tplink_archer-c5-v4.dts | 204 -- .../dts/mt7620a_tplink_archer-mr200.dts | 4 - .../ramips/dts/mt7620a_tplink_archer.dtsi | 4 - .../ramips/dts/mt7620a_tplink_re210-v1.dts | 3 +- .../dts/mt7620a_wavlink_wl-wn530hg4.dts | 1 - .../ramips/dts/mt7620a_wavlink_wl-wn579x3.dts | 3 +- .../ramips/dts/mt7620a_xiaomi_miwifi-r3.dts | 169 -- .../linux/ramips/dts/mt7620a_youku_yk-l1.dtsi | 1 + .../linux/ramips/dts/mt7620a_yukai_bocco.dts | 4 - target/linux/ramips/dts/mt7620a_zte_q7.dts | 4 - .../dts/mt7620a_zyxel_keenetic-viva.dts | 3 +- target/linux/ramips/dts/mt7620n.dtsi | 15 - .../ramips/dts/mt7620n_dlink_dwr-921-c1.dts | 6 - .../ramips/dts/mt7620n_dlink_dwr-922-e2.dts | 6 - target/linux/ramips/dts/mt7621.dtsi | 26 - .../ramips/dts/mt7621_d-team_newifi-d2.dts | 37 +- .../ramips/dts/mt7621_dlink_dir-853-a3.dts | 204 ++ .../ramips/dts/mt7621_dlink_dir-853-r1.dts | 144 + .../ramips/dts/mt7621_dlink_dir-867-a1.dts | 3 +- .../ramips/dts/mt7621_dlink_dir-878-a1.dts | 3 +- .../ramips/dts/mt7621_dlink_dir-882-a1.dts | 20 +- .../ramips/dts/mt7621_dlink_dir-882-r1.dts | 20 +- .../ramips/dts/mt7621_dlink_dir-882-x1.dtsi | 17 - ...-8xx-x1.dtsi => mt7621_dlink_dir-8xx.dtsi} | 0 ...a1.dtsi => mt7621_dlink_flash-16m-a1.dtsi} | 11 +- ...r1.dtsi => mt7621_dlink_flash-16m-r1.dtsi} | 2 - .../dts/mt7621_elecom_wrc-2533ghbk-i.dts | 199 ++ .../ramips/dts/mt7621_gehua_ghl-r-001.dts | 35 +- target/linux/ramips/dts/mt7621_jcg_y2.dts | 40 +- .../ramips/dts/mt7621_jdcloud_re-sp-01b.dts | 162 -- .../ramips/dts/mt7621_linksys_ea7300-v2.dts | 8 + .../ramips/dts/mt7621_linksys_ea8100-v2.dts | 8 + .../ramips/dts/mt7621_motorola_mr2600.dts | 46 - .../dts/mt7621_netgear_sercomm_bzv.dtsi | 38 +- .../dts/mt7621_netgear_sercomm_chj.dtsi | 24 +- .../linux/ramips/dts/mt7621_phicomm_k2p.dts | 35 +- .../ramips/dts/mt7621_tenbay_t-mb5eu-v01.dts | 196 ++ ...t-wg108.dts => mt7621_totolink_x5000r.dts} | 74 +- .../ramips/dts/mt7621_ubnt_unifi-6-lite.dts | 84 + .../ramips/dts/mt7621_ubnt_unifi-nanohd.dts | 80 +- .../linux/ramips/dts/mt7621_ubnt_unifi.dtsi | 81 + ....dts => mt7621_xiaomi_mi-router-3-pro.dts} | 2 +- .../dts/mt7621_xiaomi_mi-router-3g-v2.dts | 8 + .../ramips/dts/mt7621_xiaomi_mi-router-3g.dts | 117 + .../ramips/dts/mt7621_xiaomi_mi-router-4.dts | 96 + ... => mt7621_xiaomi_mi-router-4a-3g-v2.dtsi} | 7 +- .../mt7621_xiaomi_mi-router-4a-gigabit.dts | 8 + .../dts/mt7621_xiaomi_mi-router-ac2100.dts | 2 +- .../dts/mt7621_xiaomi_mi-router-cr6606.dts | 2 +- .../linux/ramips/dts/mt7621_xiaomi_mir3g.dts | 220 -- ..._mir4.dts => mt7621_xiaomi_nand_128m.dtsi} | 87 +- .../dts/mt7621_xiaomi_redmi-router-ac2100.dts | 2 +- .../dts/mt7621_xiaomi_router-ac2100.dtsi | 117 +- .../linux/ramips/dts/mt7621_xiaoyu_xy-c5.dts | 38 +- target/linux/ramips/dts/mt7628an.dtsi | 8 +- .../ramips/dts/mt7628an_hilink_hlk-7628n.dts | 1 + .../ramips/dts/mt7628an_hiwifi_hc5661a.dts | 27 +- .../ramips/dts/mt7628an_hiwifi_hc5761a.dts | 27 +- .../linux/ramips/dts/mt7628an_minew_g1-c.dts | 142 + .../ramips/dts/mt7628an_ravpower_rp-wd009.dts | 4 - .../dts/mt7628an_tplink_tl-mr6400-v5.dts | 91 + ...m.dts => mt7628an_xiaomi_mi-router-4.dtsi} | 58 +- .../dts/mt7628an_xiaomi_mi-router-4a-100m.dts | 45 + .../dts/mt7628an_xiaomi_mi-router-4c.dts | 124 +- target/linux/ramips/dts/rt3050.dtsi | 4 +- target/linux/ramips/dts/rt3352.dtsi | 4 +- .../ramips/dts/rt3662_engenius_esr600h.dts | 171 ++ target/linux/ramips/dts/rt5350.dtsi | 8 +- .../files/drivers/net/ethernet/ralink/Kconfig | 16 +- .../drivers/net/ethernet/ralink/Makefile | 4 - .../drivers/net/ethernet/ralink/esw_rt3050.c | 192 +- .../drivers/net/ethernet/ralink/esw_rt3050.h | 3 + .../drivers/net/ethernet/ralink/gsw_mt7620.c | 211 +- .../drivers/net/ethernet/ralink/gsw_mt7620.h | 18 +- .../drivers/net/ethernet/ralink/gsw_mt7621.c | 297 -- .../files/drivers/net/ethernet/ralink/mdio.c | 16 +- .../drivers/net/ethernet/ralink/mt7530.c | 194 +- .../drivers/net/ethernet/ralink/mt7530.h | 44 - .../drivers/net/ethernet/ralink/mtk_debugfs.c | 115 - .../drivers/net/ethernet/ralink/mtk_eth_soc.c | 110 +- .../drivers/net/ethernet/ralink/mtk_eth_soc.h | 19 +- .../drivers/net/ethernet/ralink/mtk_offload.c | 540 ---- .../drivers/net/ethernet/ralink/mtk_offload.h | 260 -- .../drivers/net/ethernet/ralink/soc_mt7620.c | 53 +- .../drivers/net/ethernet/ralink/soc_mt7621.c | 186 -- .../drivers/net/ethernet/ralink/soc_rt2880.c | 8 - .../drivers/net/ethernet/ralink/soc_rt3050.c | 18 +- .../drivers/net/ethernet/ralink/soc_rt3883.c | 8 - .../files/drivers/pinctrl/pinctrl-aw9523.c | 1135 ++++++++ target/linux/ramips/image/Makefile | 6 +- target/linux/ramips/image/common-tp-link.mk | 10 +- target/linux/ramips/image/mt7620.mk | 43 +- target/linux/ramips/image/mt7621.mk | 371 ++- target/linux/ramips/image/mt76x8.mk | 33 +- target/linux/ramips/image/rt305x.mk | 10 +- target/linux/ramips/image/rt3883.mk | 16 +- target/linux/ramips/modules.mk | 3 +- .../mt7620/base-files/etc/board.d/01_leds | 6 - .../mt7620/base-files/etc/board.d/02_network | 19 +- .../base-files/etc/board.d/03_gpio_switches | 1 - .../etc/uci-defaults/05_fix-compat-version | 10 + .../mt7620/base-files/lib/upgrade/platform.sh | 4 - target/linux/ramips/mt7620/config-5.10 | 1 + target/linux/ramips/mt7620/config-5.4 | 25 +- target/linux/ramips/mt7620/target.mk | 4 +- .../mt7621/base-files/etc/board.d/01_leds | 40 +- .../mt7621/base-files/etc/board.d/02_network | 114 +- .../base-files/etc/board.d/03_gpio_switches | 1 - .../base-files/etc/board.d/05_compat-version | 18 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 15 +- .../mt7621/base-files/etc/init.d/bootcount | 4 +- .../uci-defaults/01_enable_packet_steering | 5 + .../lib/preinit/07_mt7621_bringup_dsa_master | 2 +- .../mt7621/base-files/lib/upgrade/platform.sh | 11 +- target/linux/ramips/mt7621/config-5.10 | 2 + target/linux/ramips/mt7621/config-5.4 | 29 +- target/linux/ramips/mt7621/target.mk | 2 +- .../mt76x8/base-files/etc/board.d/01_leds | 5 +- .../mt76x8/base-files/etc/board.d/02_network | 16 +- .../mt76x8/base-files/lib/upgrade/platform.sh | 4 +- target/linux/ramips/mt76x8/config-5.10 | 1 + target/linux/ramips/mt76x8/config-5.4 | 1 + target/linux/ramips/mt76x8/target.mk | 2 +- ...or-Add-support-for-BoHong-bh25q128as.patch | 75 + .../ramips/patches-5.10/710-at803x.patch | 2 +- .../patches-5.10/805-pinctrl-AW9523.patch | 72 + ...an-up-boot_command_line-initializati.patch | 192 ++ ...2-MIPS-Always-define-builtin_cmdline.patch | 44 + ...-MIPS-add-bootargs-override-property.patch | 63 + ...38-mtd-ralink-add-mt7620-nand-driver.patch | 2386 ----------------- ...or-Add-support-for-BoHong-bh25q128as.patch | 34 + .../patches-5.4/805-pinctrl-AW9523.patch | 72 + .../linux/ramips/patches-5.4/991-at803x.patch | 2 +- .../rt288x/base-files/etc/board.d/01_leds | 1 - .../rt288x/base-files/etc/board.d/02_network | 1 - target/linux/ramips/rt288x/config-5.10 | 1 + target/linux/ramips/rt288x/config-5.4 | 1 + .../rt305x/base-files/etc/board.d/01_leds | 1 - .../rt305x/base-files/etc/board.d/02_network | 1 - target/linux/ramips/rt305x/config-5.10 | 1 + target/linux/ramips/rt305x/config-5.4 | 1 + .../rt3883/base-files/etc/board.d/01_leds | 1 - .../rt3883/base-files/etc/board.d/02_network | 19 +- target/linux/ramips/rt3883/config-5.10 | 1 + target/linux/ramips/rt3883/config-5.4 | 1 + 182 files changed, 4486 insertions(+), 6367 deletions(-) delete mode 100644 target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts delete mode 100644 target/linux/ramips/dts/mt7620a_xiaomi_miwifi-r3.dts create mode 100644 target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts create mode 100644 target/linux/ramips/dts/mt7621_dlink_dir-853-r1.dts delete mode 100644 target/linux/ramips/dts/mt7621_dlink_dir-882-x1.dtsi rename target/linux/ramips/dts/{mt7621_dlink_dir-8xx-x1.dtsi => mt7621_dlink_dir-8xx.dtsi} (100%) rename target/linux/ramips/dts/{mt7621_dlink_dir-8xx-a1.dtsi => mt7621_dlink_flash-16m-a1.dtsi} (78%) rename target/linux/ramips/dts/{mt7621_dlink_dir-8xx-r1.dtsi => mt7621_dlink_flash-16m-r1.dtsi} (94%) create mode 100644 target/linux/ramips/dts/mt7621_elecom_wrc-2533ghbk-i.dts delete mode 100644 target/linux/ramips/dts/mt7621_jdcloud_re-sp-01b.dts create mode 100644 target/linux/ramips/dts/mt7621_linksys_ea7300-v2.dts create mode 100644 target/linux/ramips/dts/mt7621_linksys_ea8100-v2.dts delete mode 100644 target/linux/ramips/dts/mt7621_motorola_mr2600.dts create mode 100644 target/linux/ramips/dts/mt7621_tenbay_t-mb5eu-v01.dts rename target/linux/ramips/dts/{mt7621_zbtlink_zbt-wg108.dts => mt7621_totolink_x5000r.dts} (70%) create mode 100644 target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts create mode 100644 target/linux/ramips/dts/mt7621_ubnt_unifi.dtsi rename target/linux/ramips/dts/{mt7621_xiaomi_mir3p.dts => mt7621_xiaomi_mi-router-3-pro.dts} (98%) create mode 100644 target/linux/ramips/dts/mt7621_xiaomi_mi-router-3g-v2.dts create mode 100644 target/linux/ramips/dts/mt7621_xiaomi_mi-router-3g.dts create mode 100644 target/linux/ramips/dts/mt7621_xiaomi_mi-router-4.dts rename target/linux/ramips/dts/{mt7621_xiaomi_mir3g-v2.dts => mt7621_xiaomi_mi-router-4a-3g-v2.dtsi} (95%) create mode 100644 target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-gigabit.dts delete mode 100644 target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts rename target/linux/ramips/dts/{mt7621_xiaomi_mir4.dts => mt7621_xiaomi_nand_128m.dtsi} (59%) create mode 100644 target/linux/ramips/dts/mt7628an_minew_g1-c.dts create mode 100644 target/linux/ramips/dts/mt7628an_tplink_tl-mr6400-v5.dts rename target/linux/ramips/dts/{mt7628an_xiaomi_mir4a-100m.dts => mt7628an_xiaomi_mi-router-4.dtsi} (60%) create mode 100644 target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4a-100m.dts create mode 100644 target/linux/ramips/dts/rt3662_engenius_esr600h.dts delete mode 100644 target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7621.c delete mode 100644 target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_debugfs.c delete mode 100644 target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_offload.c delete mode 100644 target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_offload.h delete mode 100644 target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7621.c create mode 100644 target/linux/ramips/files/drivers/pinctrl/pinctrl-aw9523.c mode change 100755 => 100644 target/linux/ramips/mt7620/base-files/etc/board.d/01_leds mode change 100755 => 100644 target/linux/ramips/mt7620/base-files/etc/board.d/02_network mode change 100755 => 100644 target/linux/ramips/mt7620/base-files/etc/board.d/03_gpio_switches create mode 100644 target/linux/ramips/mt7620/base-files/etc/uci-defaults/05_fix-compat-version mode change 100755 => 100644 target/linux/ramips/mt7621/base-files/etc/board.d/01_leds mode change 100755 => 100644 target/linux/ramips/mt7621/base-files/etc/board.d/02_network mode change 100755 => 100644 target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches create mode 100644 target/linux/ramips/mt7621/base-files/etc/board.d/05_compat-version create mode 100644 target/linux/ramips/mt7621/base-files/etc/uci-defaults/01_enable_packet_steering mode change 100755 => 100644 target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds mode change 100755 => 100644 target/linux/ramips/mt76x8/base-files/etc/board.d/02_network create mode 100644 target/linux/ramips/patches-5.10/405-mtd-spi-nor-Add-support-for-BoHong-bh25q128as.patch create mode 100644 target/linux/ramips/patches-5.10/805-pinctrl-AW9523.patch create mode 100644 target/linux/ramips/patches-5.4/0001-MIPS-cmdline-Clean-up-boot_command_line-initializati.patch create mode 100644 target/linux/ramips/patches-5.4/0002-MIPS-Always-define-builtin_cmdline.patch create mode 100644 target/linux/ramips/patches-5.4/0010-MIPS-add-bootargs-override-property.patch delete mode 100644 target/linux/ramips/patches-5.4/0038-mtd-ralink-add-mt7620-nand-driver.patch create mode 100644 target/linux/ramips/patches-5.4/405-mtd-spi-nor-Add-support-for-BoHong-bh25q128as.patch create mode 100644 target/linux/ramips/patches-5.4/805-pinctrl-AW9523.patch mode change 100755 => 100644 target/linux/ramips/rt288x/base-files/etc/board.d/01_leds mode change 100755 => 100644 target/linux/ramips/rt288x/base-files/etc/board.d/02_network mode change 100755 => 100644 target/linux/ramips/rt305x/base-files/etc/board.d/01_leds mode change 100755 => 100644 target/linux/ramips/rt305x/base-files/etc/board.d/02_network mode change 100755 => 100644 target/linux/ramips/rt3883/base-files/etc/board.d/01_leds mode change 100755 => 100644 target/linux/ramips/rt3883/base-files/etc/board.d/02_network diff --git a/package/lean/luci-app-turboacc/Makefile b/package/lean/luci-app-turboacc/Makefile index fdcc6c296..7e848d68c 100644 --- a/package/lean/luci-app-turboacc/Makefile +++ b/package/lean/luci-app-turboacc/Makefile @@ -28,7 +28,7 @@ config PACKAGE_TURBOACC_INCLUDE_OFFLOADING config PACKAGE_TURBOACC_INCLUDE_SHORTCUT_FE bool "Include Shortcut-FE" - default y if !(TARGET_ipq806x||TARGET_ipq807x) + default y if !(TARGET_ipq806x||TARGET_ipq807x||TARGET_ramips) config PACKAGE_TURBOACC_INCLUDE_BBR_CCA bool "Include BBR CCA" diff --git a/target/linux/ramips/Makefile b/target/linux/ramips/Makefile index d0480bc10..ca358d6c6 100644 --- a/target/linux/ramips/Makefile +++ b/target/linux/ramips/Makefile @@ -9,9 +9,8 @@ BOARD:=ramips BOARDNAME:=MediaTek Ralink MIPS SUBTARGETS:=mt7620 mt7621 mt76x8 rt288x rt305x rt3883 FEATURES:=squashfs gpio -MAINTAINER:=John Crispin -KERNEL_PATCHVER:=5.4 +KERNEL_PATCHVER:=5.10 KERNEL_TESTING_PATCHVER:=5.10 define Target/Description diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_ac1200rm.dts b/target/linux/ramips/dts/mt7620a_alfa-network_ac1200rm.dts index 27b6896ce..752a940cd 100644 --- a/target/linux/ramips/dts/mt7620a_alfa-network_ac1200rm.dts +++ b/target/linux/ramips/dts/mt7620a_alfa-network_ac1200rm.dts @@ -72,10 +72,6 @@ status = "okay"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &ohci { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts b/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts index 58386a9ac..0991ae844 100644 --- a/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts +++ b/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts @@ -141,10 +141,6 @@ status = "okay"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &i2c { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts index 30a0201c3..ca58d780f 100644 --- a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts +++ b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts @@ -114,10 +114,6 @@ status = "okay"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &ohci { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_asus_rp-n53.dts b/target/linux/ramips/dts/mt7620a_asus_rp-n53.dts index 3cb9142c3..4c72c6427 100644 --- a/target/linux/ramips/dts/mt7620a_asus_rp-n53.dts +++ b/target/linux/ramips/dts/mt7620a_asus_rp-n53.dts @@ -153,8 +153,7 @@ }; }; -&gsw { - mediatek,port4 = "ephy"; +ðernet { pinctrl-names = "default"; pinctrl-0 = <&ephy_pins>; }; diff --git a/target/linux/ramips/dts/mt7620a_buffalo_whr-1166d.dts b/target/linux/ramips/dts/mt7620a_buffalo_whr-1166d.dts index 196bbde72..93a09f99c 100644 --- a/target/linux/ramips/dts/mt7620a_buffalo_whr-1166d.dts +++ b/target/linux/ramips/dts/mt7620a_buffalo_whr-1166d.dts @@ -157,10 +157,6 @@ }; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts b/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts index ed2e03d6c..95152bc41 100644 --- a/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts +++ b/target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts @@ -144,10 +144,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; pinctrl-names = "default"; diff --git a/target/linux/ramips/dts/mt7620a_buffalo_whr-600d.dts b/target/linux/ramips/dts/mt7620a_buffalo_whr-600d.dts index b799a98e5..226967763 100644 --- a/target/linux/ramips/dts/mt7620a_buffalo_whr-600d.dts +++ b/target/linux/ramips/dts/mt7620a_buffalo_whr-600d.dts @@ -144,10 +144,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_cameo_810.dtsi b/target/linux/ramips/dts/mt7620a_cameo_810.dtsi index c3f3267d3..70407449d 100644 --- a/target/linux/ramips/dts/mt7620a_cameo_810.dtsi +++ b/target/linux/ramips/dts/mt7620a_cameo_810.dtsi @@ -132,10 +132,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &gpio2 { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts b/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts index 63667da28..0c9f56875 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts @@ -171,10 +171,6 @@ mtd-mac-address = <&factory 0x4>; }; -&gsw { - ralink,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; pinctrl-names = "default"; diff --git a/target/linux/ramips/dts/mt7620a_dlink_dir-510l.dts b/target/linux/ramips/dts/mt7620a_dlink_dir-510l.dts index f4db67648..774d90c79 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dir-510l.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dir-510l.dts @@ -120,10 +120,6 @@ }; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &state_default { default { groups = "i2c", "uartf"; diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts index bacebee8e..b86ab1449 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts @@ -185,5 +185,6 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; diff --git a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts index 0b124e67d..b0dd31caf 100644 --- a/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts +++ b/target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts @@ -173,6 +173,6 @@ }; &gsw { - mediatek,port4 = "gmac"; - mediatek,ephy-base-address = /bits/ 16 < 2 >; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <2>; }; diff --git a/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts b/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts index 9450596f1..ba1a2becd 100644 --- a/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts +++ b/target/linux/ramips/dts/mt7620a_dovado_tiny-ac.dts @@ -135,7 +135,8 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &pcie { diff --git a/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts b/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts index e7af34aa8..03a4c96f6 100644 --- a/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts +++ b/target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts @@ -178,7 +178,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,ephy-base = /bits/ 8 <12>; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts b/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts index 77d214e88..986b047e4 100644 --- a/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts +++ b/target/linux/ramips/dts/mt7620a_edimax_ew-7478apc.dts @@ -170,7 +170,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,ephy-base = /bits/ 8 <12>; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi b/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi index d17cc090c..6060fd99a 100644 --- a/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi +++ b/target/linux/ramips/dts/mt7620a_edimax_ew-747x.dtsi @@ -155,8 +155,6 @@ mtd-mac-address = <&factory 0x4>; - mediatek,mdio-mode = <1>; - phy-reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>; phy-reset-duration = <30>; @@ -202,7 +200,7 @@ }; &gsw { - mediatek,port5 = "gmac"; + mediatek,ephy-base = /bits/ 8 <8>; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_engenius_esr600.dts b/target/linux/ramips/dts/mt7620a_engenius_esr600.dts index b8fe2f8cd..ea895ac6e 100644 --- a/target/linux/ramips/dts/mt7620a_engenius_esr600.dts +++ b/target/linux/ramips/dts/mt7620a_engenius_esr600.dts @@ -144,7 +144,6 @@ mdio-bus { status = "okay"; - mediatek,mdio-mode; ethernet-phy@0 { reg = <0>; @@ -155,11 +154,15 @@ 0x7c 0x0000007e /* PORT0 STATUS */ 0x0c 0x05600000 /* PORT6 PAD MODE CTRL */ 0x94 0x0000007e /* PORT6 STATUS */ - >; + >; }; }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <8>; +}; + &state_default { gpio { groups = "i2c", "uartf", "nd_sd", "wled"; diff --git a/target/linux/ramips/dts/mt7620a_fon_fon2601.dts b/target/linux/ramips/dts/mt7620a_fon_fon2601.dts index ee61c6e59..373205e72 100644 --- a/target/linux/ramips/dts/mt7620a_fon_fon2601.dts +++ b/target/linux/ramips/dts/mt7620a_fon_fon2601.dts @@ -136,7 +136,8 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts b/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts index a0ebe4fff..7d807bff4 100644 --- a/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts +++ b/target/linux/ramips/dts/mt7620a_head-weblink_hdrm200.dts @@ -149,6 +149,11 @@ }; }; +&gsw { + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; +}; + &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts b/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts index 7044a511b..d59b481a6 100644 --- a/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts +++ b/target/linux/ramips/dts/mt7620a_iodata_wn-ac1167gr.dts @@ -184,6 +184,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; + &state_default { gpio { groups = "i2c", "uartf"; diff --git a/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts b/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts index 20d055791..6270af3b1 100644 --- a/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts +++ b/target/linux/ramips/dts/mt7620a_iptime_a1004ns.dts @@ -101,3 +101,7 @@ }; }; }; + +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; diff --git a/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts b/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts index 962ef3371..41d69d009 100644 --- a/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts +++ b/target/linux/ramips/dts/mt7620a_lava_lr-25g001.dts @@ -115,9 +115,8 @@ mdio-bus { status = "okay"; - mediatek,mdio-mode = <1>; - phy0: ethernet-phy@0 { + ethernet-phy@0 { reg = <0>; phy-mode = "rgmii"; qca,ar8327-initvals = < @@ -127,29 +126,13 @@ 0x94 0x00000000 /* PORT6_STATUS */ >; }; - - phy1: ethernet-phy@1 { - reg = <1>; - phy-mode = "rgmii"; - }; - - phy2: ethernet-phy@2 { - reg = <2>; - phy-mode = "rgmii"; - }; - - phy3: ethernet-phy@3 { - reg = <3>; - phy-mode = "rgmii"; - }; - - phy4: ethernet-phy@4 { - reg = <4>; - phy-mode = "rgmii"; - }; }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <8>; +}; + &pcie { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts b/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts index bb1303d4f..9e0b81716 100644 --- a/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts +++ b/target/linux/ramips/dts/mt7620a_lb-link_bl-w1200.dts @@ -135,6 +135,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; + &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts b/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts index a07683ed4..0544550bf 100644 --- a/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts +++ b/target/linux/ramips/dts/mt7620a_lenovo_newifi-y1s.dts @@ -111,5 +111,6 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; diff --git a/target/linux/ramips/dts/mt7620a_linksys_e1700.dts b/target/linux/ramips/dts/mt7620a_linksys_e1700.dts index 2619a4653..c38ea8082 100644 --- a/target/linux/ramips/dts/mt7620a_linksys_e1700.dts +++ b/target/linux/ramips/dts/mt7620a_linksys_e1700.dts @@ -145,7 +145,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,ephy-base = /bits/ 8 <12>; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_netis_wf2770.dts b/target/linux/ramips/dts/mt7620a_netis_wf2770.dts index ab8c61b1d..f83904886 100644 --- a/target/linux/ramips/dts/mt7620a_netis_wf2770.dts +++ b/target/linux/ramips/dts/mt7620a_netis_wf2770.dts @@ -142,6 +142,10 @@ }; }; +&gsw { + mediatek,ephy-base = /bits/ 8 <12>; +}; + &pcie { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_ohyeah_oy-0001.dts b/target/linux/ramips/dts/mt7620a_ohyeah_oy-0001.dts index 07f606fce..7dabbed9b 100644 --- a/target/linux/ramips/dts/mt7620a_ohyeah_oy-0001.dts +++ b/target/linux/ramips/dts/mt7620a_ohyeah_oy-0001.dts @@ -103,10 +103,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_planex_cs-qr10.dts b/target/linux/ramips/dts/mt7620a_planex_cs-qr10.dts index aa7ddb0a2..3edc41ac0 100644 --- a/target/linux/ramips/dts/mt7620a_planex_cs-qr10.dts +++ b/target/linux/ramips/dts/mt7620a_planex_cs-qr10.dts @@ -122,10 +122,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - ralink,port4 = "ephy"; -}; - &sdhci { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_planex_db-wrt01.dts b/target/linux/ramips/dts/mt7620a_planex_db-wrt01.dts index eb373e9aa..8f8f173de 100644 --- a/target/linux/ramips/dts/mt7620a_planex_db-wrt01.dts +++ b/target/linux/ramips/dts/mt7620a_planex_db-wrt01.dts @@ -94,10 +94,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_planex_mzk-750dhp.dts b/target/linux/ramips/dts/mt7620a_planex_mzk-750dhp.dts index df9c9689c..e1c5568ed 100644 --- a/target/linux/ramips/dts/mt7620a_planex_mzk-750dhp.dts +++ b/target/linux/ramips/dts/mt7620a_planex_mzk-750dhp.dts @@ -114,10 +114,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts index 7743df06f..ae3594150 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-evb.dts @@ -105,7 +105,8 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &sdhci { diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts index 4a0975596..f7d8cae16 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7530-evb.dts @@ -100,7 +100,7 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,ephy-base = /bits/ 8 <12>; }; &pcie { diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7610e-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7610e-evb.dts index ae0d364d3..b7a71c3e2 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7610e-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-mt7610e-evb.dts @@ -71,10 +71,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &sdhci { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts index bee4ba7fd..0e963e1f0 100644 --- a/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts +++ b/target/linux/ramips/dts/mt7620a_ralink_mt7620a-v22sg-evb.dts @@ -99,7 +99,8 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &pcie { diff --git a/target/linux/ramips/dts/mt7620a_sercomm_na930.dts b/target/linux/ramips/dts/mt7620a_sercomm_na930.dts index 4a91c07ec..1ffc0a2bc 100644 --- a/target/linux/ramips/dts/mt7620a_sercomm_na930.dts +++ b/target/linux/ramips/dts/mt7620a_sercomm_na930.dts @@ -166,7 +166,8 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &ehci { diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts b/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts deleted file mode 100644 index c5bfe5bf5..000000000 --- a/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts +++ /dev/null @@ -1,204 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -#include "mt7620a.dtsi" - -#include -#include - -/ { - compatible = "tplink,archer-c5-v4", "ralink,mt7620a-soc"; - model = "TP-Link Archer C5 v4"; - - aliases { - led-boot = &led_power; - led-failsafe = &led_power; - led-running = &led_power; - led-upgrade = &led_power; - label-mac-device = ðernet; - }; - - chosen { - bootargs = "console=ttyS0,115200"; - }; - - leds { - compatible = "gpio-leds"; - - led_power: power { - label = "green:power"; - gpios = <&gpio2 2 GPIO_ACTIVE_LOW>; - }; - - wlan2g { - label = "green:wlan2g"; - gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; - }; - - wlan5g { - label = "green:wlan5g"; - gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; - linux,default-trigger = "phy0tpt"; - }; - - wan { - label = "green:wan"; - gpios = <&gpio0 10 GPIO_ACTIVE_LOW>; - }; - - wan_orange { - label = "orange:wan"; - gpios = <&gpio0 9 GPIO_ACTIVE_LOW>; - }; - - lan { - label = "green:lan"; - gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>; - }; - - usb { - label = "green:usb"; - gpios = <&gpio0 7 GPIO_ACTIVE_LOW>; - trigger-sources = <&ohci_port1>, <&ehci_port1>; - linux,default-trigger = "usbport"; - }; - - wps { - label = "green:wps"; - gpios = <&gpio0 1 GPIO_ACTIVE_LOW>; - }; - }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; - linux,code = ; - }; - - rfkill { - label = "rfkill"; - gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; - linux,code = ; - }; - }; - - rtl8367s { - compatible = "realtek,rtl8367b"; - cpu_port = <7>; - realtek,extif2 = <1 0 1 1 1 1 1 1 2>; - mii-bus = <&mdio0>; - phy_id = <29>; - }; -}; - -&gpio2 { - status = "okay"; -}; - -&spi0 { - status = "okay"; - - flash@0 { - compatible = "jedec,spi-nor"; - reg = <0>; - spi-max-frequency = <80000000>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "u-boot"; - reg = <0x0 0x20000>; - read-only; - }; - - partition@20000 { - compatible = "tplink,firmware"; - label = "firmware"; - reg = <0x20000 0x7a0000>; - }; - - partition@7c0000 { - label = "config"; - reg = <0x7c0000 0x10000>; - read-only; - }; - - rom: partition@7d0000 { - label = "rom"; - reg = <0x7d0000 0x10000>; - read-only; - }; - - partition@7e0000 { - label = "romfile"; - reg = <0x7e0000 0x10000>; - read-only; - }; - - radio: partition@7f0000 { - label = "radio"; - reg = <0x7f0000 0x10000>; - read-only; - }; - }; - }; -}; - -&pinctrl { - state_default: pinctrl0 { - gpio { - ralink,group = "i2c", "uartf", "ephy", "rgmii2"; - ralink,function = "gpio"; - }; - }; -}; - -ðernet { - pinctrl-names = "default"; - mtd-mac-address = <&rom 0xf100>; - pinctrl-0 = <&rgmii1_pins &mdio_pins>; - - port@5 { - status = "okay"; - mediatek,fixed-link = <1000 1 1 1>; - phy-mode = "rgmii"; - }; - - mdio0: mdio-bus { - status = "okay"; - reset-gpios = <&gpio2 20 GPIO_ACTIVE_LOW>; - reset-delay-us = <10000>; - }; -}; - -&ehci { - status = "okay"; -}; - -&ohci { - status = "okay"; -}; - -&wmac { - ralink,mtd-eeprom = <&radio 0>; - mtd-mac-address = <&rom 0xf100>; -}; - -&pcie { - status = "okay"; -}; - -&pcie0 { - wifi@0,0 { - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&radio 0x8000>; - ieee80211-freq-limit = <5000000 6000000>; - mtd-mac-address = <&rom 0xf100>; - mtd-mac-address-increment = <2>; - }; -}; diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer-mr200.dts b/target/linux/ramips/dts/mt7620a_tplink_archer-mr200.dts index ae92dc85e..4212a70dc 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_archer-mr200.dts +++ b/target/linux/ramips/dts/mt7620a_tplink_archer-mr200.dts @@ -178,10 +178,6 @@ status = "okay"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&radio 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi b/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi index 670bad615..d2fb89143 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi +++ b/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi @@ -105,10 +105,6 @@ status = "okay"; }; -&gsw { - mediatek,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&radio 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts b/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts index 41e56fbe3..57cd0ed53 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts +++ b/target/linux/ramips/dts/mt7620a_tplink_re210-v1.dts @@ -61,7 +61,8 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; ðernet { diff --git a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn530hg4.dts b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn530hg4.dts index d8ce40c8d..27fd2e245 100644 --- a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn530hg4.dts +++ b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn530hg4.dts @@ -14,7 +14,6 @@ led-failsafe = &led_status_blue; led-running = &led_status_blue; led-upgrade = &led_status_blue; - serial0 = &uartlite; }; leds { diff --git a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts index 679d9c215..bfec806c1 100644 --- a/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts +++ b/target/linux/ramips/dts/mt7620a_wavlink_wl-wn579x3.dts @@ -195,7 +195,8 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620a_xiaomi_miwifi-r3.dts b/target/linux/ramips/dts/mt7620a_xiaomi_miwifi-r3.dts deleted file mode 100644 index 0a236615d..000000000 --- a/target/linux/ramips/dts/mt7620a_xiaomi_miwifi-r3.dts +++ /dev/null @@ -1,169 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -#include "mt7620a.dtsi" - -#include -#include - -/ { - compatible = "xiaomi,miwifi-r3", "ralink,mt7620a-soc"; - model = "Xiaomi Mi Router R3"; - - aliases { - led-status = &led_status_blue; - }; - - chosen { - bootargs = "console=ttyS0,115200"; - }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>; - linux,code = ; - }; - }; - - leds { - compatible = "gpio-leds"; - - led_status_blue: blue { - label = "blue:status"; - gpios = <&gpio1 0 GPIO_ACTIVE_LOW>; - default-state = "on"; - }; - - yellow { - label = "yellow:status"; - gpios = <&gpio1 2 GPIO_ACTIVE_LOW>; - }; - - red { - label = "red:status"; - gpios = <&gpio1 5 GPIO_ACTIVE_LOW>; - }; - }; - - nand { - status = "okay"; - #address-cells = <1>; - #size-cells = <1>; - compatible = "mtk,mt7620-nand"; - - partition@0 { - label = "Bootloader"; - reg = <0x0 0x40000>; - read-only; - }; - - partition@40000 { - label = "Config"; - reg = <0x40000 0x40000>; - }; - - partition@80000 { - label = "Bdata"; - reg = <0x80000 0x40000>; - read-only; - }; - - factory: partition@0xc0000 { - label = "factory"; - reg = <0xc0000 0x40000>; - read-only; - }; - - partition@100000 { - label = "crash"; - reg = <0x100000 0x40000>; - read-only; - }; - - partition@140000 { - label = "crash_syslog"; - reg = <0x140000 0x40000>; - read-only; - }; - - partition@180000 { - label = "reserved0"; - reg = <0x180000 0x80000>; - read-only; - }; - - partition@200000 { - label = "kernel_stock"; - reg = <0x200000 0x400000>; - }; - - partition@600000 { - label = "kernel"; - reg = <0x600000 0x400000>; - }; - - /* ubi partition is the result of squashing - * next consequent stock partitions: - * - rootfs0 (rootfs partition for stock kernel0), - * - rootfs1 (rootfs partition for stock failsafe kernel1), - * - overlay (used as ubi overlay in stock fw) - * resulting 117,5MiB space for packages. - */ - partition@a00000 { - label = "ubi"; - reg = <0xa00000 0x7600000>; - }; - }; -}; - -&gpio1 { - status = "okay"; -}; - -&ehci { - status = "okay"; -}; - -&ohci { - status = "okay"; -}; - -ðernet { - pinctrl-names = "default"; - pinctrl-0 = <&ephy_pins>; - mtd-mac-address = <&factory 0x28>; - mediatek,portmap = "llllw"; -}; - -&wmac { - ralink,mtd-eeprom = <&factory 0>; -}; - -&pcie { - status = "okay"; -}; - -&pcie0 { - wifi@0,0 { - compatible = "pci14c3,7662"; - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x8000>; - ieee80211-freq-limit = <5000000 6000000>; - }; -}; - -&pinctrl { - state_default: pinctrl0 { - gpio { - groups = "rgmii1"; - function = "gpio"; - }; - - pa { - groups = "pa"; - function = "pa"; - }; - }; -}; diff --git a/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi index 61062a317..db9bacefe 100644 --- a/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi +++ b/target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi @@ -103,6 +103,7 @@ ðernet { pinctrl-names = "default"; + pinctrl-0 = <&ephy_pins>; mtd-mac-address = <&factory 0x28>; diff --git a/target/linux/ramips/dts/mt7620a_yukai_bocco.dts b/target/linux/ramips/dts/mt7620a_yukai_bocco.dts index 9c99a6582..347c246e2 100644 --- a/target/linux/ramips/dts/mt7620a_yukai_bocco.dts +++ b/target/linux/ramips/dts/mt7620a_yukai_bocco.dts @@ -141,10 +141,6 @@ mediatek,portmap = "llllw"; }; -&gsw { - ralink,port4 = "ephy"; -}; - &wmac { ralink,mtd-eeprom = <&factory 0x0>; }; diff --git a/target/linux/ramips/dts/mt7620a_zte_q7.dts b/target/linux/ramips/dts/mt7620a_zte_q7.dts index 1ec3ba2e3..550f750c5 100644 --- a/target/linux/ramips/dts/mt7620a_zte_q7.dts +++ b/target/linux/ramips/dts/mt7620a_zte_q7.dts @@ -111,7 +111,3 @@ &ohci { status = "okay"; }; - -&gsw { - mediatek,port4 = "ephy"; -}; diff --git a/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts b/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts index 8c07de484..1a5ff2d0d 100644 --- a/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts +++ b/target/linux/ramips/dts/mt7620a_zyxel_keenetic-viva.dts @@ -157,7 +157,8 @@ }; &gsw { - mediatek,port4 = "gmac"; + mediatek,port4-gmac; + mediatek,ephy-base = /bits/ 8 <8>; }; &wmac { diff --git a/target/linux/ramips/dts/mt7620n.dtsi b/target/linux/ramips/dts/mt7620n.dtsi index 2fac09189..276bc1373 100644 --- a/target/linux/ramips/dts/mt7620n.dtsi +++ b/target/linux/ramips/dts/mt7620n.dtsi @@ -322,20 +322,6 @@ reset-names = "fe", "esw"; mediatek,switch = <&gsw>; - - mdio-bus { - #address-cells = <1>; - #size-cells = <0>; - - status = "disabled"; - }; - - port@4 { - compatible = "mediatek,mt7620a-gsw-port", "mediatek,eth-port"; - reg = <4>; - - status = "disabled"; - }; }; gsw: gsw@10110000 { @@ -347,7 +333,6 @@ interrupt-parent = <&intc>; interrupts = <17>; - mediatek,port4 = "ephy"; }; ehci: ehci@101c0000 { diff --git a/target/linux/ramips/dts/mt7620n_dlink_dwr-921-c1.dts b/target/linux/ramips/dts/mt7620n_dlink_dwr-921-c1.dts index c784839c3..d37bdb401 100644 --- a/target/linux/ramips/dts/mt7620n_dlink_dwr-921-c1.dts +++ b/target/linux/ramips/dts/mt7620n_dlink_dwr-921-c1.dts @@ -133,12 +133,6 @@ status = "okay"; }; -ðernet { - port@4 { - status = "okay"; - }; -}; - &state_default { default { groups = "spi refclk", "i2c", "ephy", "wled"; diff --git a/target/linux/ramips/dts/mt7620n_dlink_dwr-922-e2.dts b/target/linux/ramips/dts/mt7620n_dlink_dwr-922-e2.dts index 9400394d8..d3ca0dd53 100644 --- a/target/linux/ramips/dts/mt7620n_dlink_dwr-922-e2.dts +++ b/target/linux/ramips/dts/mt7620n_dlink_dwr-922-e2.dts @@ -136,12 +136,6 @@ status = "okay"; }; -ðernet { - port@4 { - status = "okay"; - }; -}; - &state_default { default { groups = "spi refclk", "i2c", "ephy", "wled"; diff --git a/target/linux/ramips/dts/mt7621.dtsi b/target/linux/ramips/dts/mt7621.dtsi index d1ff4b696..53e13441e 100644 --- a/target/linux/ramips/dts/mt7621.dtsi +++ b/target/linux/ramips/dts/mt7621.dtsi @@ -37,21 +37,6 @@ compatible = "mti,cpu-interrupt-controller"; }; - reserved-memory { - #address-cells = <0x1>; - #size-cells = <0x1>; - ranges; - - ramoops@3f00000 { - compatible = "ramoops"; - reg = <0x3f00000 0x80000>; - - record-size = <0x10000>; - console-size = <0x10000>; - ftrace-size = <0x20000>; - }; - }; - chosen { bootargs = "console=ttyS0,57600"; }; @@ -453,14 +438,6 @@ clock-names = "nfi_clk"; }; - crypto@1e004000 { - compatible = "mediatek,mtk-eip93"; - reg = <0x1e004000 0x1000>; - - interrupt-parent = <&gic>; - interrupts = ; - }; - ethsys: syscon@1e000000 { compatible = "mediatek,mt7621-ethsys", "syscon"; @@ -486,9 +463,6 @@ mediatek,ethsys = <ðsys>; - pinctrl-names = "default"; - pinctrl-0 = <&rgmii1_pins &mdio_pins>; - gmac0: mac@0 { compatible = "mediatek,eth-mac"; reg = <0>; diff --git a/target/linux/ramips/dts/mt7621_d-team_newifi-d2.dts b/target/linux/ramips/dts/mt7621_d-team_newifi-d2.dts index d72d07ae6..5622855f4 100644 --- a/target/linux/ramips/dts/mt7621_d-team_newifi-d2.dts +++ b/target/linux/ramips/dts/mt7621_d-team_newifi-d2.dts @@ -12,7 +12,7 @@ led-failsafe = &led_power_blue; led-running = &led_power_blue; led-upgrade = &led_power_blue; - label-mac-device = ðernet; + label-mac-device = &gmac0; }; chosen { @@ -148,19 +148,38 @@ }; }; -ðernet { - compatible = "mediatek,ralink-mt7621-eth"; - mediatek,switch = <&gsw>; +&gmac0 { mtd-mac-address = <&factory 0xe000>; }; &switch0 { - /delete-property/ compatible; - phy-mode = "rgmii"; -}; + ports { + port@0 { + status = "okay"; + label = "lan4"; + }; -&gsw { - compatible = "mediatek,ralink-mt7621-gsw"; + port@1 { + status = "okay"; + label = "lan3"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan1"; + }; + + port@4 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0xe006>; + }; + }; }; &state_default { diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts b/target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts new file mode 100644 index 000000000..738bcdc7d --- /dev/null +++ b/target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts @@ -0,0 +1,204 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "dlink,dir-853-a3", "mediatek,mt7621-soc"; + model = "D-Link DIR-853 A3"; + + aliases { + label-mac-device = &gmac0; + led-boot = &led_power_orange; + led-failsafe = &led_power_blue; + led-running = &led_power_blue; + led-upgrade = &led_net_orange; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wifi { + label = "wifi"; + gpios = <&gpio 7 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power_orange: power_orange { + label = "orange:power"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + led_power_blue: power_blue { + label = "blue:power"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + led_net_orange: net_orange { + label = "orange:net"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + + net_blue { + label = "blue:net"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + }; + + usb_blue { + label = "blue:usb"; + gpios = <&gpio 10 GPIO_ACTIVE_LOW>; + trigger-sources = <&xhci_ehci_port1>; + linux,default-trigger = "usbport"; + }; + + wlan2g { + label = "blue:wlan2g"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0radio"; + }; + + wlan5g { + label = "blue:wlan5g"; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1radio"; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "config"; + reg = <0x80000 0x80000>; + read-only; + }; + + factory: partition@100000 { + label = "factory"; + reg = <0x100000 0x40000>; + read-only; + }; + + partition@140000 { + label = "config2"; + reg = <0x140000 0x40000>; + read-only; + }; + + partition@180000 { + label = "firmware"; + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,padding = <96>; + reg = <0x180000 0x2800000>; + }; + + partition@2980000 { + label = "private"; + reg = <0x2980000 0x2000000>; + read-only; + }; + + partition@4980000 { + label = "firmware2"; + reg = <0x4980000 0x2800000>; + }; + + partition@7180000 { + label = "mydlink"; + reg = <0x7180000 0x600000>; + read-only; + }; + + partition@7780000 { + label = "reserved"; + reg = <0x7780000 0x880000>; + read-only; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + /* 5 GHz (phy1) does not take the address from calibration data, + but setting it manually here works */ + mtd-mac-address = <&factory 0x4>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0xe000>; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan4"; + }; + + port@1 { + status = "okay"; + label = "lan3"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan1"; + }; + + port@4 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0xe006>; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "uart2", "uart3", "jtag", "wdt"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-853-r1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-853-r1.dts new file mode 100644 index 000000000..09e46b011 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_dlink_dir-853-r1.dts @@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include "mt7621_dlink_flash-16m-r1.dtsi" + +#include +#include + +/ { + compatible = "dlink,dir-853-r1", "mediatek,mt7621-soc"; + model = "D-Link DIR-853 R1"; + + aliases { + label-mac-device = &wan; + led-boot = &led_power_orange; + led-failsafe = &led_power_blue; + led-running = &led_power_blue; + led-upgrade = &led_net_orange; + }; + + leds { + compatible = "gpio-leds"; + + led_power_orange: power_orange { + label = "orange:power"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + led_power_blue: power_blue { + label = "blue:power"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + led_net_orange: net_orange { + label = "orange:net"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + + net_blue { + label = "blue:net"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + }; + + usb_blue { + label = "blue:usb"; + gpios = <&gpio 10 GPIO_ACTIVE_LOW>; + trigger-sources = <&xhci_ehci_port1>; + linux,default-trigger = "usbport"; + }; + + wlan2g { + label = "blue:wlan2g"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0radio"; + }; + + wlan5g { + label = "blue:wlan5g"; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1radio"; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wifi { + label = "wifi"; + gpios = <&gpio 7 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + /* 5 GHz (phy1) does not take the address from calibration data, + but setting it manually here works */ + mtd-mac-address = <&factory 0x4>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0x4>; + mtd-mac-address-increment = <(-1)>; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan4"; + }; + + port@1 { + status = "okay"; + label = "lan3"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan1"; + }; + + wan: port@4 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0x4>; + mtd-mac-address-increment = <(-2)>; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "uart3", "uart2", "jtag", "wdt"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-867-a1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-867-a1.dts index b2ba5ecaa..e02eb9eeb 100644 --- a/target/linux/ramips/dts/mt7621_dlink_dir-867-a1.dts +++ b/target/linux/ramips/dts/mt7621_dlink_dir-867-a1.dts @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "mt7621_dlink_dir-8xx-a1.dtsi" +#include "mt7621_dlink_dir-8xx.dtsi" +#include "mt7621_dlink_flash-16m-a1.dtsi" / { compatible = "dlink,dir-867-a1", "mediatek,mt7621-soc"; diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts index 4bfe5ca43..1f1d5824f 100644 --- a/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts +++ b/target/linux/ramips/dts/mt7621_dlink_dir-878-a1.dts @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "mt7621_dlink_dir-8xx-a1.dtsi" +#include "mt7621_dlink_dir-8xx.dtsi" +#include "mt7621_dlink_flash-16m-a1.dtsi" / { compatible = "dlink,dir-878-a1", "mediatek,mt7621-soc"; diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-882-a1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-882-a1.dts index cef070539..01739fc25 100644 --- a/target/linux/ramips/dts/mt7621_dlink_dir-882-a1.dts +++ b/target/linux/ramips/dts/mt7621_dlink_dir-882-a1.dts @@ -1,9 +1,25 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "mt7621_dlink_dir-8xx-a1.dtsi" -#include "mt7621_dlink_dir-882-x1.dtsi" +#include "mt7621_dlink_dir-8xx.dtsi" +#include "mt7621_dlink_flash-16m-a1.dtsi" / { compatible = "dlink,dir-882-a1", "mediatek,mt7621-soc"; model = "D-Link DIR-882 A1"; }; + +&leds { + usb2 { + label = "green:usb2"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + trigger-sources = <&ehci_port2>; + linux,default-trigger = "usbport"; + }; + + usb3 { + label = "green:usb3"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + trigger-sources = <&xhci_ehci_port1>; + linux,default-trigger = "usbport"; + }; +}; diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-882-r1.dts b/target/linux/ramips/dts/mt7621_dlink_dir-882-r1.dts index 26b6f3470..9b0cd8e7b 100644 --- a/target/linux/ramips/dts/mt7621_dlink_dir-882-r1.dts +++ b/target/linux/ramips/dts/mt7621_dlink_dir-882-r1.dts @@ -1,9 +1,25 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "mt7621_dlink_dir-8xx-r1.dtsi" -#include "mt7621_dlink_dir-882-x1.dtsi" +#include "mt7621_dlink_dir-8xx.dtsi" +#include "mt7621_dlink_flash-16m-r1.dtsi" / { compatible = "dlink,dir-882-r1", "mediatek,mt7621-soc"; model = "D-Link DIR-882 R1"; }; + +&leds { + usb2 { + label = "green:usb2"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + trigger-sources = <&ehci_port2>; + linux,default-trigger = "usbport"; + }; + + usb3 { + label = "green:usb3"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + trigger-sources = <&xhci_ehci_port1>; + linux,default-trigger = "usbport"; + }; +}; diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-882-x1.dtsi b/target/linux/ramips/dts/mt7621_dlink_dir-882-x1.dtsi deleted file mode 100644 index cafb1df96..000000000 --- a/target/linux/ramips/dts/mt7621_dlink_dir-882-x1.dtsi +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -&leds { - usb2 { - label = "green:usb2"; - gpios = <&gpio 13 GPIO_ACTIVE_LOW>; - trigger-sources = <&ehci_port2>; - linux,default-trigger = "usbport"; - }; - - usb3 { - label = "green:usb3"; - gpios = <&gpio 14 GPIO_ACTIVE_LOW>; - trigger-sources = <&xhci_ehci_port1>; - linux,default-trigger = "usbport"; - }; -}; diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-8xx-x1.dtsi b/target/linux/ramips/dts/mt7621_dlink_dir-8xx.dtsi similarity index 100% rename from target/linux/ramips/dts/mt7621_dlink_dir-8xx-x1.dtsi rename to target/linux/ramips/dts/mt7621_dlink_dir-8xx.dtsi diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-8xx-a1.dtsi b/target/linux/ramips/dts/mt7621_dlink_flash-16m-a1.dtsi similarity index 78% rename from target/linux/ramips/dts/mt7621_dlink_dir-8xx-a1.dtsi rename to target/linux/ramips/dts/mt7621_dlink_flash-16m-a1.dtsi index e93a06d9f..911de595d 100644 --- a/target/linux/ramips/dts/mt7621_dlink_dir-8xx-a1.dtsi +++ b/target/linux/ramips/dts/mt7621_dlink_flash-16m-a1.dtsi @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "mt7621_dlink_dir-8xx-x1.dtsi" - &spi0 { status = "okay"; @@ -29,14 +27,15 @@ factory: partition@40000 { label = "factory"; - reg = <0x40000 0x10000>; + reg = <0x40000 0x20000>; read-only; }; - partition@50000 { - compatible = "denx,uimage"; + partition@60000 { + compatible = "openwrt,uimage", "denx,uimage"; + openwrt,padding = <96>; label = "firmware"; - reg = <0x50000 0xfb0000>; + reg = <0x60000 0xfa0000>; }; }; }; diff --git a/target/linux/ramips/dts/mt7621_dlink_dir-8xx-r1.dtsi b/target/linux/ramips/dts/mt7621_dlink_flash-16m-r1.dtsi similarity index 94% rename from target/linux/ramips/dts/mt7621_dlink_dir-8xx-r1.dtsi rename to target/linux/ramips/dts/mt7621_dlink_flash-16m-r1.dtsi index e93a06d9f..3f71ab971 100644 --- a/target/linux/ramips/dts/mt7621_dlink_dir-8xx-r1.dtsi +++ b/target/linux/ramips/dts/mt7621_dlink_flash-16m-r1.dtsi @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "mt7621_dlink_dir-8xx-x1.dtsi" - &spi0 { status = "okay"; diff --git a/target/linux/ramips/dts/mt7621_elecom_wrc-2533ghbk-i.dts b/target/linux/ramips/dts/mt7621_elecom_wrc-2533ghbk-i.dts new file mode 100644 index 000000000..a5436d55d --- /dev/null +++ b/target/linux/ramips/dts/mt7621_elecom_wrc-2533ghbk-i.dts @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "elecom,wrc-2533ghbk-i", "mediatek,mt7621-soc"; + model = "ELECOM WRC-2533GHBK-I"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + leds { + compatible = "gpio-leds"; + + wps { + label = "red:wps"; + gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + }; + + led_power: power { + label = "white:power"; + gpios = <&gpio 12 GPIO_ACTIVE_HIGH>; + }; + + wlan2g { + label = "white:wlan2g"; + gpios = <&gpio 14 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0radio"; + }; + + wlan5g { + label = "white:wlan5g"; + gpios = <&gpio 15 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1radio"; + }; + }; + + keys { + compatible = "gpio-keys"; + + auto { + label = "auto"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + linux,code = ; + linux,input-type = ; + }; + + reset { + label = "reset"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <40000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0x9a0000>; + }; + + partition@9f0000 { + label = "TM_1"; + reg = <0x9f0000 0x200000>; + read-only; + }; + + partition@bf0000 { + label = "TM_2"; + reg = <0xbf0000 0x200000>; + read-only; + }; + + partition@df0000 { + label = "manufacture"; + reg = <0xdf0000 0x180000>; + read-only; + }; + + partition@f70000 { + label = "backup"; + reg = <0xf70000 0x10000>; + read-only; + }; + + partition@f80000 { + label = "storage"; + reg = <0xf80000 0x80000>; + read-only; + }; + }; + }; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "wan"; + }; + + port@1 { + status = "okay"; + label = "lan4"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@3 { + status = "okay"; + label = "lan2"; + }; + + port@4 { + status = "okay"; + label = "lan1"; + }; + }; +}; + +&state_default { + gpio { + groups = "uart2", "uart3", "jtag", "wdt"; + function = "gpio"; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&xhci { + status = "disabled"; +}; diff --git a/target/linux/ramips/dts/mt7621_gehua_ghl-r-001.dts b/target/linux/ramips/dts/mt7621_gehua_ghl-r-001.dts index ebefa5cc2..e7b19fa42 100644 --- a/target/linux/ramips/dts/mt7621_gehua_ghl-r-001.dts +++ b/target/linux/ramips/dts/mt7621_gehua_ghl-r-001.dts @@ -9,10 +9,6 @@ compatible = "gehua,ghl-r-001", "mediatek,mt7621-soc"; model = "GeHua GHL-R-001"; - aliases { - label-mac-device = ðernet; - }; - leds { compatible = "gpio-leds"; @@ -110,19 +106,34 @@ }; }; -ðernet { - compatible = "mediatek,ralink-mt7621-eth"; - mediatek,switch = <&gsw>; +&gmac0 { mtd-mac-address = <&factory 0xe000>; }; &switch0 { - /delete-property/ compatible; - phy-mode = "rgmii"; -}; + ports { + port@0 { + status = "okay"; + label = "lan1"; + }; -&gsw { - compatible = "mediatek,ralink-mt7621-gsw"; + port@1 { + status = "okay"; + label = "lan2"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@4 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0xe000>; + mtd-mac-address-increment = <1>; + }; + }; }; &state_default { diff --git a/target/linux/ramips/dts/mt7621_jcg_y2.dts b/target/linux/ramips/dts/mt7621_jcg_y2.dts index 86c1e5f4d..06d6579aa 100644 --- a/target/linux/ramips/dts/mt7621_jcg_y2.dts +++ b/target/linux/ramips/dts/mt7621_jcg_y2.dts @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -/dts-v1/; #include "mt7621.dtsi" @@ -16,10 +15,6 @@ led-upgrade = &led_internet; }; - chosen { - bootargs = "console=ttyS0,57600"; - }; - leds { compatible = "gpio-leds"; @@ -93,19 +88,38 @@ }; }; -ðernet { - compatible = "mediatek,ralink-mt7621-eth"; - mediatek,switch = <&gsw>; +&gmac0 { mtd-mac-address = <&factory 0xe000>; }; &switch0 { - /delete-property/ compatible; - phy-mode = "rgmii"; -}; + ports { + port@0 { + status = "okay"; + label = "lan4"; + }; -&gsw { - compatible = "mediatek,ralink-mt7621-gsw"; + port@1 { + status = "okay"; + label = "lan3"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan1"; + }; + + wan: port@4 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0xe006>; + }; + }; }; &state_default { diff --git a/target/linux/ramips/dts/mt7621_jdcloud_re-sp-01b.dts b/target/linux/ramips/dts/mt7621_jdcloud_re-sp-01b.dts deleted file mode 100644 index 3f51f28ed..000000000 --- a/target/linux/ramips/dts/mt7621_jdcloud_re-sp-01b.dts +++ /dev/null @@ -1,162 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -#include "mt7621.dtsi" - -#include -#include - -/ { - compatible = "jdcloud,re-sp-01b", "mediatek,mt7621-soc"; - model = "JDCloud RE-SP-01B"; - - aliases { - led-boot = &led_red; - led-failsafe = &led_red; - led-running = &led_green; - led-upgrade = &led_blue; - label-mac-device = &gmac0; - }; - - chosen { - bootargs = "console=ttyS0,115200"; - }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - gpios = <&gpio 18 GPIO_ACTIVE_LOW>; - linux,code = ; - }; - }; - - leds { - compatible = "gpio-leds"; - - led_red: red { - label = "red:sys"; - gpios = <&gpio 6 GPIO_ACTIVE_LOW>; - panic-indicator; - }; - - led_green: green { - label = "green:sys"; - gpios = <&gpio 8 GPIO_ACTIVE_LOW>; - }; - - led_blue: blue { - label = "blue:sys"; - gpios = <&gpio 12 GPIO_ACTIVE_LOW>; - }; - }; -}; - -&sdhci { - status = "okay"; -}; - -&spi0 { - status = "okay"; - - flash@0 { - compatible = "jedec,spi-nor"; - reg = <0>; - spi-max-frequency = <50000000>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "u-boot"; - reg = <0x0 0x30000>; - read-only; - }; - - config: partition@30000 { - label = "config"; - reg = <0x30000 0x10000>; - read-only; - }; - - factory: partition@40000 { - label = "factory"; - reg = <0x40000 0x10000>; - read-only; - }; - - partition@50000 { - compatible = "denx,uimage"; - label = "firmware"; - reg = <0x50000 0x1ab0000>; - }; - - partition@1b00000 { - label = "mini"; - reg = <0x1b00000 0x400000>; - read-only; - }; - - partition@1f00000 { - label = "oem"; - reg = <0x1f00000 0x100000>; - read-only; - }; - }; - }; -}; - -&gmac0 { - mtd-mac-address-ascii = <&config 0x4429>; -}; - -&switch0 { - ports { - port@0 { - status = "okay"; - label = "wan"; - }; - - port@1 { - status = "okay"; - label = "lan1"; - }; - - port@2 { - status = "okay"; - label = "lan2"; - }; - }; -}; - -&pcie { - status = "okay"; -}; - -&pcie0 { - wifi@0,0 { - reg = <0x0000 0 0 0 0>; - mtd-mac-address-ascii = <&config 0x4429>; - mediatek,mtd-eeprom = <&factory 0x0>; - }; -}; - -&pcie1 { - wifi@0,0 { - reg = <0x0000 0 0 0 0>; - mtd-mac-address-ascii = <&config 0x4429>; - mtd-mac-address-increment = <0x80>; - mtd-mac-address-increment-byte = <3>; - mediatek,mtd-eeprom = <&factory 0x8000>; - ieee80211-freq-limit = <5000000 6000000>; - }; -}; - -&state_default { - gpio { - groups = "uart2", "uart3", "wdt"; - function = "gpio"; - }; -}; diff --git a/target/linux/ramips/dts/mt7621_linksys_ea7300-v2.dts b/target/linux/ramips/dts/mt7621_linksys_ea7300-v2.dts new file mode 100644 index 000000000..4ee148828 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_linksys_ea7300-v2.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_linksys_ea7xxx.dtsi" + +/ { + compatible = "linksys,ea7300-v2", "mediatek,mt7621-soc"; + model = "Linksys EA7300 v2"; +}; diff --git a/target/linux/ramips/dts/mt7621_linksys_ea8100-v2.dts b/target/linux/ramips/dts/mt7621_linksys_ea8100-v2.dts new file mode 100644 index 000000000..db1429ea1 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_linksys_ea8100-v2.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_linksys_ea7xxx.dtsi" + +/ { + compatible = "linksys,ea8100-v2", "mediatek,mt7621-soc"; + model = "Linksys EA8100 v2"; +}; diff --git a/target/linux/ramips/dts/mt7621_motorola_mr2600.dts b/target/linux/ramips/dts/mt7621_motorola_mr2600.dts deleted file mode 100644 index 2543d03cf..000000000 --- a/target/linux/ramips/dts/mt7621_motorola_mr2600.dts +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT - -#include "mt7621_dlink_dir-8xx-a1.dtsi" - -/ { - compatible = "motorola,motorola-mr2600", "mediatek,mt7621-soc"; - model = "Motorola MR2600"; - - aliases { - led-boot = &led_power_orange; - led-failsafe = &led_power_green; - led-running = &led_power_green; - led-upgrade = &led_net_orange; - }; - - leds { - compatible = "gpio-leds"; - - led_power_orange: power_orange { - label = "orange:power"; - gpios = <&gpio 8 GPIO_ACTIVE_LOW>; - }; - - led_power_green: power_green { - label = "green:power"; - gpios = <&gpio 16 GPIO_ACTIVE_LOW>; - }; - - led_net_orange: net_orange { - label = "orange:net"; - gpios = <&gpio 4 GPIO_ACTIVE_LOW>; - }; - - net_green { - label = "green:net"; - gpios = <&gpio 3 GPIO_ACTIVE_LOW>; - }; - - usb { - label = "green:usb"; - gpios = <&gpio 14 GPIO_ACTIVE_LOW>; - trigger-sources = <&xhci_ehci_port1>, <&ehci_port2>; - linux,default-trigger = "usbport"; - }; - }; -}; diff --git a/target/linux/ramips/dts/mt7621_netgear_sercomm_bzv.dtsi b/target/linux/ramips/dts/mt7621_netgear_sercomm_bzv.dtsi index f67052fd7..71c95e75b 100644 --- a/target/linux/ramips/dts/mt7621_netgear_sercomm_bzv.dtsi +++ b/target/linux/ramips/dts/mt7621_netgear_sercomm_bzv.dtsi @@ -9,7 +9,7 @@ compatible = "mediatek,mt7621-soc"; aliases { - label-mac-device = ðernet; + label-mac-device = &gmac0; led-boot = &led_power_white; led-failsafe = &led_power_orange; led-running = &led_power_white; @@ -161,19 +161,39 @@ }; }; -ðernet { - compatible = "mediatek,ralink-mt7621-eth"; - mediatek,switch = <&gsw>; +&gmac0 { mtd-mac-address = <&factory 0x4>; }; &switch0 { - /delete-property/ compatible; - phy-mode = "rgmii"; -}; + ports { + port@0 { + status = "okay"; + label = "lan4"; + }; -&gsw { - compatible = "mediatek,ralink-mt7621-gsw"; + port@1 { + status = "okay"; + label = "lan3"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan1"; + }; + + port@4 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0x4>; + mtd-mac-address-increment = <2>; + }; + }; }; &i2c { diff --git a/target/linux/ramips/dts/mt7621_netgear_sercomm_chj.dtsi b/target/linux/ramips/dts/mt7621_netgear_sercomm_chj.dtsi index 79ac46c89..7a15cd1f6 100644 --- a/target/linux/ramips/dts/mt7621_netgear_sercomm_chj.dtsi +++ b/target/linux/ramips/dts/mt7621_netgear_sercomm_chj.dtsi @@ -151,23 +151,12 @@ read-only; }; - partition@1 { + partition@100000 { label = "SC PART_MAP"; reg = <0x100000 0x100000>; read-only; }; - partition@100000 { - label = "BootEnv"; - reg = <0x100000 0x80000>; - read-only; - }; - - partition@180000 { - label = "Factory"; - reg = <0x180000 0x80000>; - }; - partition@200000 { label = "kernel"; reg = <0x200000 0x400000>; @@ -178,11 +167,6 @@ reg = <0x600000 0x2800000>; }; - partition@2 { - label = "firmware"; - reg = <0x200000 0x2c00000>; - }; - partition@2e00000 { label = "reserved0"; reg = <0x2e00000 0x1800000>; @@ -195,12 +179,6 @@ read-only; }; - partition@3 { - label = "epprom"; - reg = <0x4600000 0x80000>; - read-only; - }; - partition@4800000 { label = "reserved1"; reg = <0x4800000 0x3800000>; diff --git a/target/linux/ramips/dts/mt7621_phicomm_k2p.dts b/target/linux/ramips/dts/mt7621_phicomm_k2p.dts index 8d9af948a..ec24c713e 100644 --- a/target/linux/ramips/dts/mt7621_phicomm_k2p.dts +++ b/target/linux/ramips/dts/mt7621_phicomm_k2p.dts @@ -102,19 +102,38 @@ }; }; -ðernet { - compatible = "mediatek,ralink-mt7621-eth"; - mediatek,switch = <&gsw>; +&gmac0 { mtd-mac-address = <&factory 0xe000>; }; &switch0 { - /delete-property/ compatible; - phy-mode = "rgmii"; -}; + ports { + port@0 { + status = "okay"; + label = "lan1"; + }; -&gsw { - compatible = "mediatek,ralink-mt7621-gsw"; + port@1 { + status = "okay"; + label = "lan2"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@3 { + status = "okay"; + label = "lan4"; + }; + + port@4 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0xe006>; + }; + }; }; &state_default { diff --git a/target/linux/ramips/dts/mt7621_tenbay_t-mb5eu-v01.dts b/target/linux/ramips/dts/mt7621_tenbay_t-mb5eu-v01.dts new file mode 100644 index 000000000..ef0d48b8c --- /dev/null +++ b/target/linux/ramips/dts/mt7621_tenbay_t-mb5eu-v01.dts @@ -0,0 +1,196 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "tenbay,t-mb5eu-v01", "mediatek,mt7621-soc"; + model = "Tenbay T-MB5EU-V01"; + + aliases { + led-boot = &led_green; + led-failsafe = &led_red; + led-running = &led_blue; + led-upgrade = &led_red; + label-mac-device = &wan_port; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + bootargs-override = "console=ttyS0,115200"; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-names = "default"; + pinctrl-0 = <&led_pins>; + + led_blue: blue { + label = "blue"; + gpios = <&aw9523 0 GPIO_ACTIVE_LOW>; + }; + + led_red: red { + label = "red"; + gpios = <&aw9523 1 GPIO_ACTIVE_LOW>; + }; + + led_green: green { + label = "green"; + gpios = <&aw9523 11 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys-polled"; + poll-interval = <50>; + pinctrl-names = "default"; + pinctrl-0 = <&button_pins>; + + reset { + label = "reset"; + gpios = <&aw9523 9 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&aw9523 8 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + i2c-gpio { + #address-cells = <1>; + #size-cells = <0>; + + compatible = "i2c-gpio"; + gpios = <&gpio 7 GPIO_ACTIVE_HIGH &gpio 8 GPIO_ACTIVE_HIGH>; + i2c-gpio,delay-us = <10>; + + aw9523: gpio-expander@5b { + compatible = "awinic,aw9523-pinctrl"; + reg = <0x5b>; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&aw9523 0 0 16>; + + reset-gpios = <&gpio 6 GPIO_ACTIVE_HIGH>; + + button_pins: button-pins { + pins = "gpio8", "gpio9"; + function = "gpio"; + bias-pull-up; + drive-open-drain; + input-enable; + }; + + led_pins: led-pins { + pins = "gpio0", "gpio1", "gpio11"; + function = "gpio"; + input-disable; + output-low; + }; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie1 { + wifi@0,0 { + reg = <0x0 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0x4>; +}; + +&switch0 { + ports { + wan_port: port@0 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0x28>; + }; + + port@1 { + status = "okay"; + label = "lan1"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan3"; + }; + + port@4 { + status = "okay"; + label = "lan4"; + }; + }; +}; + +&state_default { + gpio { + groups = "uart3"; + function = "gpio"; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + read-only; + }; + + partition@40000 { + label = "product"; + reg = <0x40000 0x10000>; + read-only; + }; + + factory: partition@50000 { + label = "factory"; + reg = <0x50000 0x40000>; + read-only; + }; + + partition@90000 { + compatible = "denx,fit"; + label = "firmware"; + reg = <0x90000 0xf70000>; + }; + }; + }; +}; diff --git a/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg108.dts b/target/linux/ramips/dts/mt7621_totolink_x5000r.dts similarity index 70% rename from target/linux/ramips/dts/mt7621_zbtlink_zbt-wg108.dts rename to target/linux/ramips/dts/mt7621_totolink_x5000r.dts index 5a670c87f..ef491087e 100644 --- a/target/linux/ramips/dts/mt7621_zbtlink_zbt-wg108.dts +++ b/target/linux/ramips/dts/mt7621_totolink_x5000r.dts @@ -1,4 +1,4 @@ -/dts-v1/; +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT #include "mt7621.dtsi" @@ -6,15 +6,29 @@ #include / { - compatible = "zbtlink,zbt-wg108", "mediatek,mt7621-soc"; - model = "Zbtlink ZBT-WG108"; + compatible = "totolink,x5000r", "mediatek,mt7621-soc"; + model = "TOTOLINK X5000R"; aliases { - label-mac-device = &wifi1; + led-boot = &led_sys; + led-failsafe = &led_sys; + led-running = &led_sys; + led-upgrade = &led_sys; + label-mac-device = &gmac0; }; chosen { - bootargs = "console=ttyS0,115200"; + stdout-path = "serial0:115200n8"; + bootargs = "console=ttyS0,115200n8"; + }; + + leds { + compatible = "gpio-leds"; + + led_sys: sys { + label = "blue:sys"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + }; }; keys { @@ -22,26 +36,21 @@ reset { label = "reset"; - gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; linux,code = ; }; }; }; -&state_default { - gpio { - groups = "wdt"; - function = "gpio"; - }; -}; - &spi0 { status = "okay"; flash@0 { compatible = "jedec,spi-nor"; reg = <0>; - spi-max-frequency = <10000000>; + spi-max-frequency = <50000000>; + m25p,fast-read; partitions { compatible = "fixed-partitions"; @@ -75,6 +84,18 @@ }; }; +&pcie { + status = "okay"; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + }; +}; + &gmac0 { mtd-mac-address = <&factory 0xe000>; }; @@ -109,26 +130,9 @@ }; }; -&pcie { - status = "okay"; -}; - -&pcie0 { - wifi0: mt76@0,0 { - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x8000>; - ieee80211-freq-limit = <5000000 6000000>; +&state_default { + gpio { + groups = "i2c", "wdt"; + function = "gpio"; }; }; - -&pcie1 { - wifi1: mt76@0,0 { - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x0000>; - ieee80211-freq-limit = <2400000 2500000>; - }; -}; - -&sdhci { - status = "okay"; -}; diff --git a/target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts b/target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts new file mode 100644 index 000000000..d374fd3dd --- /dev/null +++ b/target/linux/ramips/dts/mt7621_ubnt_unifi-6-lite.dts @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_ubnt_unifi.dtsi" + +/ { + compatible = "ubnt,unifi-6-lite", "mediatek,mt7621-soc"; + model = "Ubiquiti UniFi 6 Lite"; + + chosen { + bootargs-override = "console=ttyS0,115200"; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x60000>; + read-only; + }; + + partition@60000 { + label = "u-boot-env"; + reg = <0x60000 0x10000>; + read-only; + }; + + factory: partition@70000 { + label = "factory"; + reg = <0x70000 0x40000>; + read-only; + }; + + eeprom: partition@b0000 { + label = "eeprom"; + reg = <0xb0000 0x10000>; + read-only; + }; + + partition@c0000 { + label = "bs"; + reg = <0xc0000 0x10000>; + }; + + partition@d0000 { + label = "cfg"; + reg = <0xd0000 0x100000>; + read-only; + }; + + partition@1d0000 { + compatible = "denx,fit"; + label = "firmware"; + reg = <0x1d0000 0xf10000>; + }; + + partition@10e0000 { + label = "kernel1"; + reg = <0x10e0000 0xf10000>; + }; + }; + }; +}; + +&wlan_2g { + mtd-mac-address = <&eeprom 0x0>; +}; + +&wlan_5g { + mediatek,mtd-eeprom = <&factory 0x20000>; + mtd-mac-address = <&eeprom 0x6>; + ieee80211-freq-limit = <5000000 6000000>; +}; diff --git a/target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts b/target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts index 4604de531..7a36ecfa7 100644 --- a/target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts +++ b/target/linux/ramips/dts/mt7621_ubnt_unifi-nanohd.dts @@ -1,49 +1,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "mt7621.dtsi" - -#include -#include +#include "mt7621_ubnt_unifi.dtsi" / { compatible = "ubnt,unifi-nanohd", "mediatek,mt7621-soc"; model = "Ubiquiti UniFi nanoHD"; - - aliases { - led-boot = &led_white; - led-failsafe = &led_white; - led-running = &led_blue; - led-upgrade = &led_blue; - label-mac-device = &gmac0; - }; - - chosen { - bootargs = "console=ttyS0,115200"; - }; - - leds { - compatible = "gpio-leds"; - - led_blue: dome_blue { - label = "blue:dome"; - gpios = <&gpio 3 GPIO_ACTIVE_HIGH>; - }; - - led_white: dome_white { - label = "white:dome"; - gpios = <&gpio 4 GPIO_ACTIVE_HIGH>; - }; - }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - gpios = <&gpio 12 GPIO_ACTIVE_LOW>; - linux,code = ; - }; - }; }; &spi0 { @@ -53,7 +14,6 @@ compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <50000000>; - broken-flash-reset; partitions { compatible = "fixed-partitions"; @@ -110,40 +70,6 @@ }; }; -&pcie { - status = "okay"; -}; - -&pcie0 { - wifi@0,0 { - reg = <0x0 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x0000>; - }; -}; - -&pcie1 { - wifi@0,0 { - reg = <0x0 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x8000>; - }; -}; - -&gmac0 { - mtd-mac-address = <&eeprom 0x0>; -}; - -&switch0 { - ports { - port@0 { - status = "okay"; - label = "lan"; - }; - }; -}; - -&state_default { - gpio { - groups = "i2c", "uart2"; - function = "gpio"; - }; +&wlan_5g { + mediatek,mtd-eeprom = <&factory 0x8000>; }; diff --git a/target/linux/ramips/dts/mt7621_ubnt_unifi.dtsi b/target/linux/ramips/dts/mt7621_ubnt_unifi.dtsi new file mode 100644 index 000000000..e0625ba50 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_ubnt_unifi.dtsi @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + aliases { + led-boot = &led_white; + led-failsafe = &led_white; + led-running = &led_blue; + led-upgrade = &led_blue; + label-mac-device = &gmac0; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + leds { + compatible = "gpio-leds"; + + led_blue: dome_blue { + label = "blue:dome"; + gpios = <&gpio 3 GPIO_ACTIVE_HIGH>; + }; + + led_white: dome_white { + label = "white:dome"; + gpios = <&gpio 4 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wlan_2g: wifi@0,0 { + reg = <0x0 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + }; +}; + +&pcie1 { + wlan_5g: wifi@0,0 { + reg = <0x0 0 0 0 0>; + }; +}; + +&gmac0 { + mtd-mac-address = <&eeprom 0x0>; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan"; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "uart2"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-3-pro.dts similarity index 98% rename from target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts rename to target/linux/ramips/dts/mt7621_xiaomi_mi-router-3-pro.dts index b296f1fcb..e8f3a50db 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mir3p.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-3-pro.dts @@ -6,7 +6,7 @@ #include / { - compatible = "xiaomi,mir3p", "mediatek,mt7621-soc"; + compatible = "xiaomi,mi-router-3-pro", "mediatek,mt7621-soc"; model = "Xiaomi Mi Router 3 Pro"; aliases { diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-3g-v2.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-3g-v2.dts new file mode 100644 index 000000000..fe03ff1e6 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-3g-v2.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_xiaomi_mi-router-4a-3g-v2.dtsi" + +/ { + compatible = "xiaomi,mi-router-3g-v2", "mediatek,mt7621-soc"; + model = "Xiaomi Mi Router 3G v2"; +}; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-3g.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-3g.dts new file mode 100644 index 000000000..40ea6625d --- /dev/null +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-3g.dts @@ -0,0 +1,117 @@ +#include "mt7621_xiaomi_nand_128m.dtsi" + +/ { + compatible = "xiaomi,mi-router-3g", "mediatek,mt7621-soc"; + model = "Xiaomi Mi Router 3G"; + + aliases { + led-boot = &led_status_yellow; + led-failsafe = &led_status_red; + led-running = &led_status_blue; + led-upgrade = &led_status_yellow; + label-mac-device = &gmac0; + }; + + leds { + compatible = "gpio-leds"; + + led_status_red: status_red { + label = "red:status"; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + }; + + led_status_blue: status_blue { + label = "blue:status"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + }; + + led_status_yellow: status_yellow { + label = "yellow:status"; + gpios = <&gpio 10 GPIO_ACTIVE_LOW>; + }; + + wan_amber { + label = "amber:wan"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + linux,default-trigger = "dsa-0.0:01:1Gbps"; + }; + + lan1_amber { + label = "amber:lan1"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + linux,default-trigger = "dsa-0.0:03:1Gbps"; + }; + + lan2_amber { + label = "amber:lan2"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,default-trigger = "dsa-0.0:02:1Gbps"; + }; + }; + + reg_usb_vbus: regulator { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio 12 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; +}; + +&xhci { + vbus-supply = <®_usb_vbus>; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "pci14c3,7603"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "pci14c3,7662"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0xe006>; +}; + +&switch0 { + ports { + port@1 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0xe000>; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan1"; + }; + }; +}; + +&state_default { + gpio { + groups = "jtag", "uart2", "uart3", "wdt"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4.dts new file mode 100644 index 000000000..18cbe0c01 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4.dts @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_xiaomi_nand_128m.dtsi" + +/ { + compatible = "xiaomi,mi-router-4", "mediatek,mt7621-soc"; + model = "Xiaomi Mi Router 4"; + + aliases { + led-boot = &led_status_yellow; + led-failsafe = &led_status_red; + led-running = &led_status_blue; + led-upgrade = &led_status_yellow; + label-mac-device = &gmac0; + }; + + leds { + compatible = "gpio-leds"; + + led_status_red: status_red { + label = "red:status"; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + }; + + led_status_blue: status_blue { + label = "blue:status"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + }; + + led_status_yellow: status_yellow { + label = "yellow:status"; + gpios = <&gpio 10 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&keys { + minet { + label = "minet"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + linux,code = ; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "pci14c3,7603"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "pci14c3,7662"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0xe000>; +}; + +&switch0 { + ports { + port@1 { + status = "okay"; + label = "lan2"; + }; + + port@2 { + status = "okay"; + label = "lan1"; + }; + + port@4 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0xe006>; + }; + }; +}; + +&state_default { + gpio { + groups = "jtag", "uart2", "uart3", "wdt"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-3g-v2.dtsi similarity index 95% rename from target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts rename to target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-3g-v2.dtsi index 3df6931bd..cc5abf09b 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mir3g-v2.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-3g-v2.dtsi @@ -6,9 +6,6 @@ #include / { - compatible = "xiaomi,mir3g-v2", "mediatek,mt7621-soc"; - model = "Xiaomi Mi Router 3G v2"; - aliases { led-boot = &led_status_yellow; led-failsafe = &led_status_yellow; @@ -52,7 +49,8 @@ flash@0 { compatible = "jedec,spi-nor"; reg = <0>; - spi-max-frequency = <80000000>; + spi-max-frequency = <50000000>; + m25p,fast-read; partitions { compatible = "fixed-partitions"; @@ -147,6 +145,7 @@ status = "okay"; label = "lan1"; }; + wan: port@4 { status = "okay"; label = "wan"; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-gigabit.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-gigabit.dts new file mode 100644 index 000000000..4387d3b79 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-4a-gigabit.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_xiaomi_mi-router-4a-3g-v2.dtsi" + +/ { + compatible = "xiaomi,mi-router-4a-gigabit", "mediatek,mt7621-soc"; + model = "Xiaomi Mi Router 4A Gigabit Edition"; +}; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-ac2100.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-ac2100.dts index b4f5d00ce..6cca16a79 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-ac2100.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-ac2100.dts @@ -11,7 +11,7 @@ led-failsafe = &led_status_yellow; led-running = &led_status_blue; led-upgrade = &led_status_blue; - label-mac-device = ðernet; + label-mac-device = &gmac0; }; leds { diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr6606.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr6606.dts index 8fcaa3dbe..22c86dbd8 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr6606.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-cr6606.dts @@ -8,7 +8,7 @@ / { compatible = "xiaomi,mi-router-cr6606", "mediatek,mt7621-soc"; - model = "Xiaomi Mi Router CR6606"; + model = "Xiaomi Mi Router CR6606/CR6608/CR6609"; aliases { led-boot = &led_sys_yellow; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts b/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts deleted file mode 100644 index 51f484225..000000000 --- a/target/linux/ramips/dts/mt7621_xiaomi_mir3g.dts +++ /dev/null @@ -1,220 +0,0 @@ -#include "mt7621.dtsi" - -#include -#include - -/ { - compatible = "xiaomi,mir3g", "mediatek,mt7621-soc"; - model = "Xiaomi Mi Router 3G"; - - aliases { - led-boot = &led_status_yellow; - led-failsafe = &led_status_red; - led-running = &led_status_blue; - led-upgrade = &led_status_yellow; - label-mac-device = &gmac0; - }; - - chosen { - bootargs = "console=ttyS0,115200n8"; - }; - - leds { - compatible = "gpio-leds"; - - led_status_red: status_red { - label = "red:status"; - gpios = <&gpio 6 GPIO_ACTIVE_LOW>; - }; - - led_status_blue: status_blue { - label = "blue:status"; - gpios = <&gpio 8 GPIO_ACTIVE_LOW>; - }; - - led_status_yellow: status_yellow { - label = "yellow:status"; - gpios = <&gpio 10 GPIO_ACTIVE_LOW>; - }; - - wan_amber { - label = "amber:wan"; - gpios = <&gpio 13 GPIO_ACTIVE_LOW>; - linux,default-trigger = "dsa-0.0:01:1Gbps"; - }; - - lan1_amber { - label = "amber:lan1"; - gpios = <&gpio 14 GPIO_ACTIVE_LOW>; - linux,default-trigger = "dsa-0.0:03:1Gbps"; - }; - - lan2_amber { - label = "amber:lan2"; - gpios = <&gpio 16 GPIO_ACTIVE_LOW>; - linux,default-trigger = "dsa-0.0:02:1Gbps"; - }; - }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - gpios = <&gpio 18 GPIO_ACTIVE_LOW>; - linux,code = ; - }; - }; - - reg_usb_vbus: regulator { - compatible = "regulator-fixed"; - regulator-name = "usb_vbus"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - gpio = <&gpio 12 GPIO_ACTIVE_HIGH>; - enable-active-high; - }; -}; - -&xhci { - vbus-supply = <®_usb_vbus>; -}; - -&nand { - status = "okay"; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "Bootloader"; - reg = <0x0 0x80000>; - read-only; - }; - - partition@80000 { - label = "Config"; - reg = <0x80000 0x40000>; - }; - - partition@c0000 { - label = "Bdata"; - reg = <0xc0000 0x40000>; - read-only; - }; - - factory: partition@100000 { - label = "factory"; - reg = <0x100000 0x40000>; - read-only; - }; - - partition@140000 { - label = "crash"; - reg = <0x140000 0x40000>; - }; - - partition@180000 { - label = "crash_syslog"; - reg = <0x180000 0x40000>; - }; - - partition@1c0000 { - label = "reserved0"; - reg = <0x1c0000 0x40000>; - read-only; - }; - - /* uboot expects to find kernels at 0x200000 & 0x600000 - * referred to as system 1 & system 2 respectively. - * a kernel is considered suitable for handing control over - * if its linux magic number exists & uImage CRC are correct. - * If either of those conditions fail, a matching sys'n'_fail flag - * is set in uboot env & a restart performed in the hope that the - * alternate kernel is okay. - * if neither kernel checksums ok and both are marked failed, system 2 - * is booted anyway. - * - * Note uboot's tftp flash install writes the transferred - * image to both kernel partitions. - */ - - partition@200000 { - label = "kernel_stock"; - reg = <0x200000 0x400000>; - }; - - partition@600000 { - label = "kernel"; - reg = <0x600000 0x400000>; - }; - - /* ubi partition is the result of squashing - * next consecutive stock partitions: - * - rootfs0 (rootfs partition for stock kernel0), - * - rootfs1 (rootfs partition for stock failsafe kernel1), - * - overlay (used as ubi overlay in stock fw) - * resulting 117,5MiB space for packages. - */ - - partition@a00000 { - label = "ubi"; - reg = <0xa00000 0x7580000>; - }; - }; -}; - -&pcie { - status = "okay"; -}; - -&pcie0 { - wifi@0,0 { - compatible = "pci14c3,7603"; - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x0000>; - ieee80211-freq-limit = <2400000 2500000>; - }; -}; - -&pcie1 { - wifi@0,0 { - compatible = "pci14c3,7662"; - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x8000>; - ieee80211-freq-limit = <5000000 6000000>; - }; -}; - -&gmac0 { - mtd-mac-address = <&factory 0xe006>; -}; - -&switch0 { - ports { - port@1 { - status = "okay"; - label = "wan"; - mtd-mac-address = <&factory 0xe000>; - }; - - port@2 { - status = "okay"; - label = "lan2"; - }; - - port@3 { - status = "okay"; - label = "lan1"; - }; - }; -}; - -&state_default { - gpio { - groups = "jtag", "uart2", "uart3", "wdt"; - function = "gpio"; - }; -}; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mir4.dts b/target/linux/ramips/dts/mt7621_xiaomi_nand_128m.dtsi similarity index 59% rename from target/linux/ramips/dts/mt7621_xiaomi_mir4.dts rename to target/linux/ramips/dts/mt7621_xiaomi_nand_128m.dtsi index ffebbcfeb..12e6bccc2 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_mir4.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_nand_128m.dtsi @@ -6,41 +6,11 @@ #include / { - compatible = "xiaomi,mir4", "mediatek,mt7621-soc"; - model = "Xiaomi Mi Router 4"; - - aliases { - led-boot = &led_status_yellow; - led-failsafe = &led_status_red; - led-running = &led_status_blue; - led-upgrade = &led_status_yellow; - label-mac-device = ðernet; - }; - chosen { bootargs = "console=ttyS0,115200n8"; }; - leds { - compatible = "gpio-leds"; - - led_status_red: status_red { - label = "red:status"; - gpios = <&gpio 6 GPIO_ACTIVE_LOW>; - }; - - led_status_blue: status_blue { - label = "blue:status"; - gpios = <&gpio 8 GPIO_ACTIVE_LOW>; - }; - - led_status_yellow: status_yellow { - label = "yellow:status"; - gpios = <&gpio 10 GPIO_ACTIVE_LOW>; - }; - }; - - keys { + keys: keys { compatible = "gpio-keys"; reset { @@ -48,12 +18,6 @@ gpios = <&gpio 18 GPIO_ACTIVE_LOW>; linux,code = ; }; - - minet { - label = "minet"; - gpios = <&gpio 12 GPIO_ACTIVE_LOW>; - linux,code = ; - }; }; }; @@ -68,6 +32,7 @@ partition@0 { label = "Bootloader"; reg = <0x0 0x80000>; + read-only; }; partition@80000 { @@ -78,11 +43,13 @@ partition@c0000 { label = "Bdata"; reg = <0xc0000 0x40000>; + read-only; }; factory: partition@100000 { label = "factory"; reg = <0x100000 0x40000>; + read-only; }; partition@140000 { @@ -98,6 +65,7 @@ partition@1c0000 { label = "reserved0"; reg = <0x1c0000 0x40000>; + read-only; }; /* uboot expects to find kernels at 0x200000 & 0x600000 @@ -114,6 +82,7 @@ * image to both kernel partitions. */ + /* We keep stock xiaomi firmware (kernel0) here */ partition@200000 { label = "kernel_stock"; reg = <0x200000 0x400000>; @@ -138,47 +107,3 @@ }; }; }; - -&pcie { - status = "okay"; -}; - -&pcie0 { - wifi@0,0 { - compatible = "pci14c3,7603"; - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x0000>; - ieee80211-freq-limit = <2400000 2500000>; - }; -}; - -&pcie1 { - wifi@0,0 { - compatible = "pci14c3,7662"; - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x8000>; - ieee80211-freq-limit = <5000000 6000000>; - }; -}; - -ðernet { - compatible = "mediatek,ralink-mt7621-eth"; - mediatek,switch = <&gsw>; - mtd-mac-address = <&factory 0xe006>; -}; - -&switch0 { - /delete-property/ compatible; - phy-mode = "rgmii"; -}; - -&gsw { - compatible = "mediatek,ralink-mt7621-gsw"; -}; - -&state_default { - gpio { - groups = "jtag", "uart2", "uart3", "wdt"; - function = "gpio"; - }; -}; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_redmi-router-ac2100.dts b/target/linux/ramips/dts/mt7621_xiaomi_redmi-router-ac2100.dts index a18885d50..4299de318 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_redmi-router-ac2100.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_redmi-router-ac2100.dts @@ -11,7 +11,7 @@ led-failsafe = &led_status_amber; led-running = &led_status_white; led-upgrade = &led_status_white; - label-mac-device = ðernet; + label-mac-device = &gmac0; }; leds { diff --git a/target/linux/ramips/dts/mt7621_xiaomi_router-ac2100.dtsi b/target/linux/ramips/dts/mt7621_xiaomi_router-ac2100.dtsi index 932da173e..7e6b3afcd 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_router-ac2100.dtsi +++ b/target/linux/ramips/dts/mt7621_xiaomi_router-ac2100.dtsi @@ -1,89 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "mt7621.dtsi" - -#include -#include - -/ { - chosen { - bootargs = "console=ttyS0,115200n8"; - }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - gpios = <&gpio 18 GPIO_ACTIVE_LOW>; - linux,code = ; - }; - }; -}; - -&nand { - status = "okay"; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "Bootloader"; - reg = <0x0 0x80000>; - }; - - partition@80000 { - label = "Config"; - reg = <0x80000 0x40000>; - }; - - partition@c0000 { - label = "Bdata"; - reg = <0xc0000 0x40000>; - read-only; - }; - - factory: partition@100000 { - label = "factory"; - reg = <0x100000 0x40000>; - read-only; - }; - - partition@140000 { - label = "crash"; - reg = <0x140000 0x40000>; - }; - - partition@180000 { - label = "crash_syslog"; - reg = <0x180000 0x40000>; - }; - - partition@1c0000 { - label = "reserved0"; - reg = <0x1c0000 0x40000>; - read-only; - }; - - /* We keep stock xiaomi firmware (kernel0) here */ - partition@200000 { - label = "kernel_stock"; - reg = <0x200000 0x400000>; - }; - - partition@600000 { - label = "kernel"; - reg = <0x600000 0x400000>; - }; - - partition@a00000 { - label = "ubi"; - reg = <0xa00000 0x7580000>; - }; - }; -}; +#include "mt7621_xiaomi_nand_128m.dtsi" &pcie { status = "okay"; @@ -107,19 +24,33 @@ }; }; -ðernet { - compatible = "mediatek,ralink-mt7621-eth"; - mediatek,switch = <&gsw>; - mtd-mac-address = <&factory 0xe006>; +&gmac0 { + mtd-mac-address = <&factory 0xe000>; }; &switch0 { - /delete-property/ compatible; - phy-mode = "rgmii"; -}; + ports { + port@0 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0xe006>; + }; -&gsw { - compatible = "mediatek,ralink-mt7621-gsw"; + port@2 { + status = "okay"; + label = "lan1"; + }; + + port@3 { + status = "okay"; + label = "lan2"; + }; + + port@4 { + status = "okay"; + label = "lan3"; + }; + }; }; &state_default { diff --git a/target/linux/ramips/dts/mt7621_xiaoyu_xy-c5.dts b/target/linux/ramips/dts/mt7621_xiaoyu_xy-c5.dts index cfb9a7c10..b90ff92c7 100644 --- a/target/linux/ramips/dts/mt7621_xiaoyu_xy-c5.dts +++ b/target/linux/ramips/dts/mt7621_xiaoyu_xy-c5.dts @@ -12,7 +12,7 @@ led-failsafe = &led_sys; led-running = &led_sys; led-upgrade = &led_sys; - label-mac-device = ðernet; + label-mac-device = &gmac0; }; leds { @@ -84,19 +84,39 @@ status = "okay"; }; -ðernet { - compatible = "mediatek,ralink-mt7621-eth"; - mediatek,switch = <&gsw>; +&gmac0 { mtd-mac-address = <&factory 0x4>; }; &switch0 { - /delete-property/ compatible; - phy-mode = "rgmii"; -}; + ports { + port@0 { + status = "okay"; + label = "lan1"; + }; -&gsw { - compatible = "mediatek,ralink-mt7621-gsw"; + port@1 { + status = "okay"; + label = "lan2"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@3 { + status = "okay"; + label = "lan4"; + }; + + port@4 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0x4>; + mtd-mac-address-increment = <1>; + }; + }; }; &state_default { diff --git a/target/linux/ramips/dts/mt7628an.dtsi b/target/linux/ramips/dts/mt7628an.dtsi index d622aa907..0dafdc790 100644 --- a/target/linux/ramips/dts/mt7628an.dtsi +++ b/target/linux/ramips/dts/mt7628an.dtsi @@ -429,8 +429,8 @@ interrupt-parent = <&cpuintc>; interrupts = <5>; - resets = <&rstctrl 21 &rstctrl 23>; - reset-names = "fe", "esw"; + resets = <&rstctrl 21>; + reset-names = "fe"; mediatek,switch = <&esw>; }; @@ -439,8 +439,8 @@ compatible = "mediatek,mt7628-esw", "ralink,rt3050-esw"; reg = <0x10110000 0x8000>; - resets = <&rstctrl 23>; - reset-names = "esw"; + resets = <&rstctrl 23 &rstctrl 24>; + reset-names = "esw", "ephy"; interrupt-parent = <&intc>; interrupts = <17>; diff --git a/target/linux/ramips/dts/mt7628an_hilink_hlk-7628n.dts b/target/linux/ramips/dts/mt7628an_hilink_hlk-7628n.dts index f5106a508..87dff72c4 100644 --- a/target/linux/ramips/dts/mt7628an_hilink_hlk-7628n.dts +++ b/target/linux/ramips/dts/mt7628an_hilink_hlk-7628n.dts @@ -47,6 +47,7 @@ compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <10000000>; + broken-flash-reset; partitions { compatible = "fixed-partitions"; diff --git a/target/linux/ramips/dts/mt7628an_hiwifi_hc5661a.dts b/target/linux/ramips/dts/mt7628an_hiwifi_hc5661a.dts index debd5ecb0..9e4068ce8 100644 --- a/target/linux/ramips/dts/mt7628an_hiwifi_hc5661a.dts +++ b/target/linux/ramips/dts/mt7628an_hiwifi_hc5661a.dts @@ -25,30 +25,11 @@ }; }; -&pinctrl { - sdxc_router_pins: sdxc_router_mode { - gpio { - groups = "i2s", "sdmode", "uart1", "gpio"; - function= "gpio"; - }; - - esdmode { - groups = "esdmode"; - function= "sdxc"; - }; +&state_default { + gpio { + groups = "i2c", "refclk", "wdt", "wled_an"; + function = "gpio"; }; - - state_default: pinctrl0 { - gpio { - groups = "i2c", "refclk", "wdt", "wled_an"; - function= "gpio"; - }; - }; -}; - -&sdhci { - status = "okay"; - pinctrl-0 = <&sdxc_router_pins>; }; &ehci { diff --git a/target/linux/ramips/dts/mt7628an_hiwifi_hc5761a.dts b/target/linux/ramips/dts/mt7628an_hiwifi_hc5761a.dts index e403411e5..828e5b8b2 100644 --- a/target/linux/ramips/dts/mt7628an_hiwifi_hc5761a.dts +++ b/target/linux/ramips/dts/mt7628an_hiwifi_hc5761a.dts @@ -44,24 +44,10 @@ }; }; -&pinctrl { - sdxc_router_pins: sdxc_router_mode { - gpio { - groups = "i2s", "sdmode", "uart1", "gpio"; - function = "gpio"; - }; - - esdmode { - groups = "esdmode"; - function = "sdxc"; - }; - }; - - state_default: pinctrl0 { - gpio { - groups = "i2c", "refclk", "wdt", "p2led_an", "p3led_an", "wled_an"; - function = "gpio"; - }; +&state_default { + gpio { + groups = "i2c", "refclk", "wdt", "p2led_an", "p3led_an", "wled_an"; + function = "gpio"; }; }; @@ -76,8 +62,3 @@ ieee80211-freq-limit = <5000000 6000000>; }; }; - -&sdhci { - status = "okay"; - pinctrl-0 = <&sdxc_router_pins>; -}; diff --git a/target/linux/ramips/dts/mt7628an_minew_g1-c.dts b/target/linux/ramips/dts/mt7628an_minew_g1-c.dts new file mode 100644 index 000000000..12cf47f5a --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_minew_g1-c.dts @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7628an.dtsi" + +#include +#include + +/ { + model = "Minew G1-C"; + compatible = "minew,g1-c", "mediatek,mt7628an-soc"; + + aliases { + led-boot = &led_system; + led-failsafe = &led_system; + led-running = &led_system; + led-upgrade = &led_system; + }; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x8000000>; + }; + + keys { + compatible = "gpio-keys-polled"; + poll-interval = <20>; + + reset { + label = "reset"; + gpios = <&gpio 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system: system { + label = "red:system"; + gpios = <&gpio 43 GPIO_ACTIVE_HIGH>; + default-state = "on"; + }; + }; + + gpio-export { + compatible = "gpio-export"; + #size-cells = <0>; + + ws2812 { + gpio-export,name = "ws2812"; + gpio-export,output = <1>; + gpios = <&gpio 11 GPIO_ACTIVE_HIGH>; + }; + + nrf_power { + gpio-export,name = "nrf_power"; + gpio-export,output = <1>; + gpios = <&gpio 45 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&state_default { + gpio { + groups = "gpio"; + function = "gpio"; + }; + + p0led_an { + groups = "p0led_an"; + function = "gpio"; + }; + + uart1 { + groups = "uart1"; + function = "gpio"; + }; + + wdt { + groups = "wdt"; + function = "gpio"; + }; +}; + +&spi0 { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>; + + m25p80@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <40000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0xfb0000>; + }; + }; + }; +}; + +ðernet { + mtd-mac-address = <&factory 0x28>; +}; + +&esw { + mediatek,portmap = <0x3e>; +}; + +&wmac { + status = "okay"; +}; + +&sdhci { + status = "okay"; + mediatek,cd-high; +}; diff --git a/target/linux/ramips/dts/mt7628an_ravpower_rp-wd009.dts b/target/linux/ramips/dts/mt7628an_ravpower_rp-wd009.dts index 6962651e1..859568b1c 100644 --- a/target/linux/ramips/dts/mt7628an_ravpower_rp-wd009.dts +++ b/target/linux/ramips/dts/mt7628an_ravpower_rp-wd009.dts @@ -16,10 +16,6 @@ led-upgrade = &led_globe; }; - chosen { - bootargs = "console=ttyS0,57600"; - }; - leds { compatible = "gpio-leds"; diff --git a/target/linux/ramips/dts/mt7628an_tplink_tl-mr6400-v5.dts b/target/linux/ramips/dts/mt7628an_tplink_tl-mr6400-v5.dts new file mode 100644 index 000000000..7ab19632e --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_tplink_tl-mr6400-v5.dts @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7628an_tplink_8m.dtsi" + +/ { + compatible = "tplink,tl-mr6400-v5", "mediatek,mt7628an-soc"; + model = "TP-Link TL-MR6400 v5"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + rfkill { + label = "rfkill"; + gpios = <&gpio 46 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + wlan { + label = "white:wlan"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + lan { + label = "white:lan"; + gpios = <&gpio 5 GPIO_ACTIVE_LOW>; + }; + + led_power: power { + label = "white:power"; + gpios = <&gpio 39 GPIO_ACTIVE_LOW>; + }; + + wan { + label = "white:wan"; + gpios = <&gpio 40 GPIO_ACTIVE_LOW>; + }; + + signal1 { + label = "white:signal1"; + gpios = <&gpio 41 GPIO_ACTIVE_LOW>; + }; + + signal2 { + label = "white:signal2"; + gpios = <&gpio 42 GPIO_ACTIVE_LOW>; + }; + + signal3 { + label = "white:signal3"; + gpios = <&gpio 43 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "p0led_an", "p1led_an", "p2led_an", "p3led_an", "p4led_an", "uart1", "wdt"; + function = "gpio"; + }; +}; + +&esw { + mediatek,portmap = <0x37>; + mediatek,portdisable = <0x30>; +}; + +&wmac { + mtd-mac-address = <&factory 0x1f100>; +}; + +ðernet { + mtd-mac-address = <&factory 0x1f100>; +}; diff --git a/target/linux/ramips/dts/mt7628an_xiaomi_mir4a-100m.dts b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4.dtsi similarity index 60% rename from target/linux/ramips/dts/mt7628an_xiaomi_mir4a-100m.dts rename to target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4.dtsi index c4912048f..0f5897f5c 100644 --- a/target/linux/ramips/dts/mt7628an_xiaomi_mir4a-100m.dts +++ b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4.dtsi @@ -6,29 +6,26 @@ #include / { - compatible = "xiaomi,mir4a-100m", "mediatek,mt7628an-soc"; - model = "Xiaomi Mi Router 4A (100M Edition)"; + aliases { + led-boot = &led_power_yellow; + led-failsafe = &led_power_yellow; + led-running = &led_power_blue; + led-upgrade = &led_power_yellow; + }; chosen { bootargs = "console=ttyS0,115200"; }; - aliases { - led-boot = &power_yellow; - led-failsafe = &power_yellow; - led-running = &power_blue; - led-upgrade = &power_yellow; - }; - leds { compatible = "gpio-leds"; - power_blue: power_blue { + led_power_blue: power_blue { label = "blue:power"; gpios = <&gpio 11 GPIO_ACTIVE_LOW>; }; - power_yellow: power_yellow { + led_power_yellow: power_yellow { label = "yellow:power"; gpios = <&gpio 44 GPIO_ACTIVE_LOW>; }; @@ -48,12 +45,12 @@ &spi0 { status = "okay"; - flash@0 { + flash0: flash@0 { compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <10000000>; - partitions { + partitions: partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; @@ -88,34 +85,11 @@ read-only; }; - partition@60000 { - label = "overlay"; - reg = <0x60000 0x100000>; - read-only; - }; - - partition@160000 { - label = "firmware"; - reg = <0x160000 0xea0000>; - compatible = "denx,uimage"; - }; + /* additional partitions in DTS */ }; }; }; -&pcie { - status = "okay"; -}; - -&pcie0 { - wifi@0,0 { - compatible = "mediatek,mt76"; - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x8000>; - ieee80211-freq-limit = <5000000 6000000>; - }; -}; - &state_default { gpio { groups = "gpio", "wdt", "wled_an"; @@ -123,16 +97,6 @@ }; }; -ðernet { - mtd-mac-address = <&factory 0x4>; - mtd-mac-address-increment = <(-1)>; -}; - -&esw { - mediatek,portmap = <0x3e>; - mediatek,portdisable = <0x2a>; -}; - &wmac { status = "okay"; }; diff --git a/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4a-100m.dts b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4a-100m.dts new file mode 100644 index 000000000..37797fc36 --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4a-100m.dts @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7628an_xiaomi_mi-router-4.dtsi" + +/ { + compatible = "xiaomi,mi-router-4a-100m", "mediatek,mt7628an-soc"; + model = "Xiaomi Mi Router 4A (100M Edition)"; +}; + +&partitions { + partition@60000 { + label = "overlay"; + reg = <0x60000 0x100000>; + read-only; + }; + + partition@160000 { + label = "firmware"; + reg = <0x160000 0xea0000>; + compatible = "denx,uimage"; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +ðernet { + mtd-mac-address = <&factory 0x4>; + mtd-mac-address-increment = <(-1)>; +}; + +&esw { + mediatek,portmap = <0x3e>; + mediatek,portdisable = <0x2a>; +}; diff --git a/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts index f459ae035..4389a9daf 100644 --- a/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts +++ b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts @@ -1,55 +1,31 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT -#include "mt7628an.dtsi" - -#include -#include +#include "mt7628an_xiaomi_mi-router-4.dtsi" / { compatible = "xiaomi,mi-router-4c", "mediatek,mt7628an-soc"; model = "Xiaomi Mi Router 4C"; aliases { - led-boot = &led_power_yellow; - led-failsafe = &led_power_yellow; - led-running = &led_power_blue; - led-upgrade = &led_power_yellow; label-mac-device = ðernet; }; - - chosen { - bootargs = "console=ttyS0,115200"; - }; - - leds { - compatible = "gpio-leds"; - - led_power_blue: power_blue { - label = "blue:power"; - gpios = <&gpio 11 GPIO_ACTIVE_LOW>; - }; - - led_power_yellow: power_yellow { - label = "yellow:power"; - gpios = <&gpio 44 GPIO_ACTIVE_LOW>; - }; - }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - gpios = <&gpio 38 GPIO_ACTIVE_LOW>; - linux,code = ; - }; - }; }; -&state_default { - gpio { - groups = "gpio", "wdt", "wled_an"; - function = "gpio"; +&flash0 { + spi-max-frequency = <40000000>; +}; + +&partitions { + partition@60000 { + label = "overlay"; + reg = <0x60000 0x100000>; + read-only; + }; + + partition@160000 { + label = "firmware"; + reg = <0x160000 0xea0000>; + compatible = "denx,uimage"; }; }; @@ -61,73 +37,11 @@ status = "disabled"; }; -&esw { - mediatek,portmap = <0x3d>; - mediatek,portdisable = <0x29>; -}; - -&wmac { - status = "okay"; -}; - ðernet { mtd-mac-address = <&factory 0x28>; }; -&spi0 { - status = "okay"; - - flash@0 { - compatible = "jedec,spi-nor"; - reg = <0>; - spi-max-frequency = <40000000>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "bootloader"; - reg = <0x0 0x20000>; - read-only; - }; - - partition@20000 { - label = "config"; - reg = <0x20000 0x10000>; - read-only; - }; - - factory: partition@30000 { - label = "factory"; - reg = <0x30000 0x10000>; - read-only; - }; - - partition@40000 { - label = "crash"; - reg = <0x40000 0x10000>; - read-only; - }; - - partition@50000 { - label = "cfg_bak"; - reg = <0x50000 0x10000>; - read-only; - }; - - partition@60000 { - label = "overlay"; - reg = <0x60000 0x100000>; - read-only; - }; - - partition@160000 { - label = "firmware"; - reg = <0x160000 0xea0000>; - compatible = "denx,uimage"; - }; - }; - }; +&esw { + mediatek,portmap = <0x3d>; + mediatek,portdisable = <0x29>; }; diff --git a/target/linux/ramips/dts/rt3050.dtsi b/target/linux/ramips/dts/rt3050.dtsi index 0cecd5d8c..492474fdc 100644 --- a/target/linux/ramips/dts/rt3050.dtsi +++ b/target/linux/ramips/dts/rt3050.dtsi @@ -319,8 +319,8 @@ compatible = "ralink,rt3050-esw"; reg = <0x10110000 0x8000>; - resets = <&rstctrl 23>; - reset-names = "esw"; + resets = <&rstctrl 23 &rstctrl 24>; + reset-names = "esw", "ephy"; interrupt-parent = <&intc>; interrupts = <17>; diff --git a/target/linux/ramips/dts/rt3352.dtsi b/target/linux/ramips/dts/rt3352.dtsi index 84d6ed590..608222cb5 100644 --- a/target/linux/ramips/dts/rt3352.dtsi +++ b/target/linux/ramips/dts/rt3352.dtsi @@ -331,8 +331,8 @@ compatible = "ralink,rt3352-esw", "ralink,rt3050-esw"; reg = <0x10110000 0x8000>; - resets = <&rstctrl 23>; - reset-names = "esw"; + resets = <&rstctrl 23 &rstctrl 24>; + reset-names = "esw", "ephy"; interrupt-parent = <&intc>; interrupts = <17>; diff --git a/target/linux/ramips/dts/rt3662_engenius_esr600h.dts b/target/linux/ramips/dts/rt3662_engenius_esr600h.dts new file mode 100644 index 000000000..cce44ed4c --- /dev/null +++ b/target/linux/ramips/dts/rt3662_engenius_esr600h.dts @@ -0,0 +1,171 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "rt3883.dtsi" + +#include +#include + +/ { + compatible = "engenius,esr600h", "ralink,rt3662-soc", "ralink,rt3883-soc"; + model = "EnGenius ESR600H"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "blue:power"; + gpios = <&gpio0 1 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + wps { + label = "blue:wps"; + gpios = <&gpio0 0 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys-polled"; + poll-interval = <100>; + + reset-wps { + label = "reset-wps"; + gpios = <&gpio1 2 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + gpio_export { + compatible = "gpio-export"; + #size-cells = <0>; + + usb { + gpio-export,name = "usb"; + gpio-export,output = <1>; + gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&gpio1 { + status = "okay"; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <20000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x1000>; + }; + + partition@32000 { + label = "config"; + reg = <0x32000 0xe000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0x7b0000>; + }; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "jtag", "uartf"; + function = "gpio"; + }; +}; + +ðernet { + status = "okay"; + + port@0 { + phy-handle = <&phy0>; + phy-mode = "rgmii"; + }; + + mdio-bus { + status = "okay"; + + phy0: ethernet-phy@0 { + reg = <0>; + phy-mode = "rgmii"; + + qca,ar8327-initvals = < + 0x04 0x07600000 /* PORT0 PAD MODE CTRL */ + 0x0c 0x07600000 /* PORT6 PAD MODE CTRL */ + 0x10 0x40000000 /* Power-on Strapping: 176-pin interface configuration */ + 0x50 0xc437c437 /* LED Control Register 0 */ + 0x54 0xc337c337 /* LED Control Register 1 */ + 0x58 0x00000000 /* LED Control Register 2 */ + 0x5c 0x03ffff00 /* LED Control Register 3 */ + 0x7c 0x0000007e /* PORT0_STATUS */ + 0x94 0x0000007e /* PORT6 STATUS */ + >; + }; + }; +}; + +&pci { + status = "okay"; +}; + +&pci1 { + status = "okay"; + + wifi@0,1,0 { + compatible = "pci1814,3091"; + reg = <0x0 1 0 0 0>; + ralink,5ghz = <0>; + ralink,mtd-eeprom = <&factory 0x8000>; + }; +}; + +&wmac { + status = "okay"; + + ralink,2ghz = <0>; + ralink,mtd-eeprom = <&factory 0x0>; +}; + +&ehci { + status = "okay"; +}; + +&ohci { + status = "okay"; +}; diff --git a/target/linux/ramips/dts/rt5350.dtsi b/target/linux/ramips/dts/rt5350.dtsi index ac4c6d9db..090e75574 100644 --- a/target/linux/ramips/dts/rt5350.dtsi +++ b/target/linux/ramips/dts/rt5350.dtsi @@ -343,8 +343,8 @@ compatible = "ralink,rt5350-eth"; reg = <0x10100000 0x10000>; - resets = <&rstctrl 21 &rstctrl 23>; - reset-names = "fe", "esw"; + resets = <&rstctrl 21>; + reset-names = "fe"; interrupt-parent = <&cpuintc>; interrupts = <5>; @@ -356,8 +356,8 @@ compatible = "ralink,rt5350-esw", "ralink,rt3050-esw"; reg = <0x10110000 0x8000>; - resets = <&rstctrl 23>; - reset-names = "esw"; + resets = <&rstctrl 23 &rstctrl 24>; + reset-names = "esw", "ephy"; interrupt-parent = <&intc>; interrupts = <17>; diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/Kconfig b/target/linux/ramips/files/drivers/net/ethernet/ralink/Kconfig index 51cace533..26e5e6d73 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/Kconfig +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/Kconfig @@ -27,23 +27,15 @@ config NET_RALINK_MT7620 bool "MT7620" depends on MIPS && SOC_MT7620 -config NET_RALINK_MT7621 - bool "MT7621" - depends on MIPS && SOC_MT7621 - endchoice -config NET_RALINK_OFFLOAD - def_bool NET_RALINK_SOC - depends on NET_RALINK_MT7621 - config NET_RALINK_HW_QOS def_bool NET_RALINK_SOC depends on NET_RALINK_MT7623 config NET_RALINK_MDIO def_bool NET_RALINK_SOC - depends on (NET_RALINK_RT2880 || NET_RALINK_RT3883 || NET_RALINK_MT7620 || NET_RALINK_MT7621) + depends on (NET_RALINK_RT2880 || NET_RALINK_RT3883 || NET_RALINK_MT7620) select PHYLIB config NET_RALINK_MDIO_RT2880 @@ -53,7 +45,7 @@ config NET_RALINK_MDIO_RT2880 config NET_RALINK_MDIO_MT7620 def_bool NET_RALINK_SOC - depends on (NET_RALINK_MT7620 || NET_RALINK_MT7621) + depends on NET_RALINK_MT7620 select NET_RALINK_MDIO config NET_RALINK_ESW_RT3050 @@ -63,8 +55,4 @@ config NET_RALINK_ESW_RT3050 config NET_RALINK_GSW_MT7620 def_tristate NET_RALINK_SOC depends on NET_RALINK_MT7620 - -config NET_RALINK_GSW_MT7621 - def_tristate NET_RALINK_SOC - depends on NET_RALINK_MT7621 endif diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/Makefile b/target/linux/ramips/files/drivers/net/ethernet/ralink/Makefile index eba21643b..79d2dbfef 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/Makefile +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/Makefile @@ -8,15 +8,11 @@ ralink-eth-$(CONFIG_NET_RALINK_MDIO) += mdio.o ralink-eth-$(CONFIG_NET_RALINK_MDIO_RT2880) += mdio_rt2880.o ralink-eth-$(CONFIG_NET_RALINK_MDIO_MT7620) += mdio_mt7620.o -ralink-eth-$(CONFIG_NET_RALINK_OFFLOAD) += mtk_offload.o mtk_debugfs.o - ralink-eth-$(CONFIG_NET_RALINK_RT2880) += soc_rt2880.o ralink-eth-$(CONFIG_NET_RALINK_RT3050) += soc_rt3050.o ralink-eth-$(CONFIG_NET_RALINK_RT3883) += soc_rt3883.o ralink-eth-$(CONFIG_NET_RALINK_MT7620) += soc_mt7620.o -ralink-eth-$(CONFIG_NET_RALINK_MT7621) += soc_mt7621.o obj-$(CONFIG_NET_RALINK_ESW_RT3050) += esw_rt3050.o obj-$(CONFIG_NET_RALINK_GSW_MT7620) += gsw_mt7620.o mt7530.o -obj-$(CONFIG_NET_RALINK_GSW_MT7621) += gsw_mt7621.o mt7530.o obj-$(CONFIG_NET_RALINK_SOC) += ralink-eth.o diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3050.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3050.c index 292f11a17..75b6707be 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3050.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3050.c @@ -17,11 +17,14 @@ #include #include #include +#include #include #include +#include #include "mtk_eth_soc.h" +#include "esw_rt3050.h" /* HW limitations for this switch: * - No large frame support (PKT_MAX_LEN at most 1536) @@ -172,7 +175,6 @@ #define RT5350_ESW_REG_PXTPC(_x) (0x150 + (4 * _x)) #define RT5350_EWS_REG_LED_POLARITY 0x168 -#define RT5350_RESET_EPHY BIT(24) enum { /* Global attributes. */ @@ -215,6 +217,7 @@ struct rt305x_esw { struct device *dev; void __iomem *base; int irq; + struct fe_priv *priv; /* Protects against concurrent register r/w operations. */ spinlock_t reg_rw_lock; @@ -232,6 +235,8 @@ struct rt305x_esw { int led_frequency; struct esw_vlan vlans[RT305X_ESW_NUM_VLANS]; struct esw_port ports[RT305X_ESW_NUM_PORTS]; + struct reset_control *rst_esw; + struct reset_control *rst_ephy; }; @@ -254,6 +259,29 @@ static inline void esw_rmw_raw(struct rt305x_esw *esw, unsigned reg, __raw_writel(t | val, esw->base + reg); } +static void esw_reset(struct rt305x_esw *esw) +{ + if (!esw->rst_esw) + return; + + reset_control_assert(esw->rst_esw); + usleep_range(60, 120); + reset_control_deassert(esw->rst_esw); + /* the esw takes long to reset otherwise the board hang */ + msleep(10); +} + +static void esw_reset_ephy(struct rt305x_esw *esw) +{ + if (!esw->rst_ephy) + return; + + reset_control_assert(esw->rst_ephy); + usleep_range(60, 120); + reset_control_deassert(esw->rst_ephy); + usleep_range(60, 120); +} + static void esw_rmw(struct rt305x_esw *esw, unsigned reg, unsigned long mask, unsigned long val) { @@ -436,6 +464,8 @@ static void esw_hw_init(struct rt305x_esw *esw) u8 port_disable = 0; u8 port_map = RT305X_ESW_PMAP_LLLLLL; + esw_reset(esw); + /* vodoo from original driver */ esw_w32(esw, 0xC8A07850, RT305X_ESW_REG_FCT0); esw_w32(esw, 0x00000000, RT305X_ESW_REG_SGC2); @@ -505,8 +535,7 @@ static void esw_hw_init(struct rt305x_esw *esw) esw->ports[i].disable = (port_disable & (1 << i)) != 0; if (ralink_soc == RT305X_SOC_RT3352) { - /* reset EPHY */ - fe_reset(RT5350_RESET_EPHY); + esw_reset_ephy(esw); rt305x_mii_write(esw, 0, 31, 0x8000); for (i = 0; i < 5; i++) { @@ -556,8 +585,7 @@ static void esw_hw_init(struct rt305x_esw *esw) /* select local register */ rt305x_mii_write(esw, 0, 31, 0x8000); } else if (ralink_soc == RT305X_SOC_RT5350) { - /* reset EPHY */ - fe_reset(RT5350_RESET_EPHY); + esw_reset_ephy(esw); /* set the led polarity */ esw_w32(esw, esw->reg_led_polarity & 0x1F, @@ -614,8 +642,7 @@ static void esw_hw_init(struct rt305x_esw *esw) } else if (ralink_soc == MT762X_SOC_MT7628AN || ralink_soc == MT762X_SOC_MT7688) { int i; - /* reset EPHY */ - fe_reset(RT5350_RESET_EPHY); + esw_reset_ephy(esw); /* set the led polarity */ esw_w32(esw, esw->reg_led_polarity & 0x1F, @@ -711,19 +738,44 @@ static void esw_hw_init(struct rt305x_esw *esw) esw_w32(esw, ~RT305X_ESW_PORT_ST_CHG, RT305X_ESW_REG_IMR); } + +int rt3050_esw_has_carrier(struct fe_priv *priv) +{ + struct rt305x_esw *esw = priv->soc->swpriv; + u32 link; + int i; + bool cpuport; + + link = esw_r32(esw, RT305X_ESW_REG_POA); + link >>= RT305X_ESW_POA_LINK_SHIFT; + cpuport = link & BIT(RT305X_ESW_PORT6); + link &= RT305X_ESW_POA_LINK_MASK; + for (i = 0; i <= RT305X_ESW_PORT5; i++) { + if (priv->link[i] != (link & BIT(i))) + dev_info(esw->dev, "port %d link %s\n", i, link & BIT(i) ? "up" : "down"); + priv->link[i] = link & BIT(i); + } + + return !!link && cpuport; +} + static irqreturn_t esw_interrupt(int irq, void *_esw) { - struct rt305x_esw *esw = (struct rt305x_esw *)_esw; + struct rt305x_esw *esw = (struct rt305x_esw *) _esw; u32 status; + int i; status = esw_r32(esw, RT305X_ESW_REG_ISR); if (status & RT305X_ESW_PORT_ST_CHG) { - u32 link = esw_r32(esw, RT305X_ESW_REG_POA); - - link >>= RT305X_ESW_POA_LINK_SHIFT; - link &= RT305X_ESW_POA_LINK_MASK; - dev_info(esw->dev, "link changed 0x%02X\n", link); + if (!esw->priv) + goto out; + if (rt3050_esw_has_carrier(esw->priv)) + netif_carrier_on(esw->priv->netdev); + else + netif_carrier_off(esw->priv->netdev); } + +out: esw_w32(esw, status, RT305X_ESW_REG_ISR); return IRQ_HANDLED; @@ -1351,9 +1403,7 @@ static int esw_probe(struct platform_device *pdev) struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct device_node *np = pdev->dev.of_node; const __be32 *port_map, *port_disable, *reg_init; - struct switch_dev *swdev; struct rt305x_esw *esw; - int ret; esw = devm_kzalloc(&pdev->dev, sizeof(*esw), GFP_KERNEL); if (!esw) @@ -1385,48 +1435,17 @@ static int esw_probe(struct platform_device *pdev) if (reg_init) esw->reg_led_polarity = be32_to_cpu(*reg_init); - swdev = &esw->swdev; - swdev->of_node = pdev->dev.of_node; - swdev->name = "rt305x-esw"; - swdev->alias = "rt305x"; - swdev->cpu_port = RT305X_ESW_PORT6; - swdev->ports = RT305X_ESW_NUM_PORTS; - swdev->vlans = RT305X_ESW_NUM_VIDS; - swdev->ops = &esw_ops; - - ret = register_switch(swdev, NULL); - if (ret < 0) { - dev_err(&pdev->dev, "register_switch failed\n"); - return ret; - } - - platform_set_drvdata(pdev, esw); + esw->rst_esw = devm_reset_control_get(&pdev->dev, "esw"); + if (IS_ERR(esw->rst_esw)) + esw->rst_esw = NULL; + esw->rst_ephy = devm_reset_control_get(&pdev->dev, "ephy"); + if (IS_ERR(esw->rst_ephy)) + esw->rst_ephy = NULL; spin_lock_init(&esw->reg_rw_lock); + platform_set_drvdata(pdev, esw); - esw_hw_init(esw); - - reg_init = of_get_property(np, "ralink,rgmii", NULL); - if (reg_init && be32_to_cpu(*reg_init) == 1) { - /* - * External switch connected to RGMII interface. - * Unregister the switch device after initialization. - */ - dev_err(&pdev->dev, "RGMII mode, not exporting switch device.\n"); - unregister_switch(&esw->swdev); - platform_set_drvdata(pdev, NULL); - return -ENODEV; - } - - ret = devm_request_irq(&pdev->dev, esw->irq, esw_interrupt, 0, "esw", - esw); - - if (!ret) { - esw_w32(esw, RT305X_ESW_PORT_ST_CHG, RT305X_ESW_REG_ISR); - esw_w32(esw, ~RT305X_ESW_PORT_ST_CHG, RT305X_ESW_REG_IMR); - } - - return ret; + return 0; } static int esw_remove(struct platform_device *pdev) @@ -1447,6 +1466,71 @@ static const struct of_device_id ralink_esw_match[] = { }; MODULE_DEVICE_TABLE(of, ralink_esw_match); +/* called by the ethernet driver to bound with the switch driver */ +int rt3050_esw_init(struct fe_priv *priv) +{ + struct device_node *np = priv->switch_np; + struct platform_device *pdev = of_find_device_by_node(np); + struct switch_dev *swdev; + struct rt305x_esw *esw; + const __be32 *rgmii; + int ret; + + if (!pdev) + return -ENODEV; + + if (!of_device_is_compatible(np, ralink_esw_match->compatible)) + return -EINVAL; + + esw = platform_get_drvdata(pdev); + if (!esw) + return -EPROBE_DEFER; + + priv->soc->swpriv = esw; + esw->priv = priv; + + esw_hw_init(esw); + + rgmii = of_get_property(np, "ralink,rgmii", NULL); + if (rgmii && be32_to_cpu(*rgmii) == 1) { + /* + * External switch connected to RGMII interface. + * Unregister the switch device after initialization. + */ + dev_err(&pdev->dev, "RGMII mode, not exporting switch device.\n"); + unregister_switch(&esw->swdev); + platform_set_drvdata(pdev, NULL); + return -ENODEV; + } + + swdev = &esw->swdev; + swdev->of_node = pdev->dev.of_node; + swdev->name = "rt305x-esw"; + swdev->alias = "rt305x"; + swdev->cpu_port = RT305X_ESW_PORT6; + swdev->ports = RT305X_ESW_NUM_PORTS; + swdev->vlans = RT305X_ESW_NUM_VIDS; + swdev->ops = &esw_ops; + + ret = register_switch(swdev, NULL); + if (ret < 0) { + dev_err(&pdev->dev, "register_switch failed\n"); + return ret; + } + + ret = devm_request_irq(&pdev->dev, esw->irq, esw_interrupt, 0, "esw", + esw); + if (!ret) { + esw_w32(esw, RT305X_ESW_PORT_ST_CHG, RT305X_ESW_REG_ISR); + esw_w32(esw, ~RT305X_ESW_PORT_ST_CHG, RT305X_ESW_REG_IMR); + } + + dev_info(&pdev->dev, "mediatek esw at 0x%08lx, irq %d initialized\n", + esw->base, esw->irq); + + return 0; +} + static struct platform_driver esw_driver = { .probe = esw_probe, .remove = esw_remove, diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3050.h b/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3050.h index bbc8fbd52..c9650209c 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3050.h +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3050.h @@ -26,4 +26,7 @@ static inline int __init mtk_switch_init(void) { return 0; } static inline void mtk_switch_exit(void) { } #endif + +int rt3050_esw_init(struct fe_priv *priv); +int rt3050_esw_has_carrier(struct fe_priv *priv); #endif diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c index 0b09814cc..7c91e5840 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.c @@ -40,7 +40,7 @@ static irqreturn_t gsw_interrupt_mt7620(int irq, void *_priv) struct fe_priv *priv = (struct fe_priv *)_priv; struct mt7620_gsw *gsw = (struct mt7620_gsw *)priv->soc->swpriv; u32 status; - int i, max = (gsw->port4 == PORT4_EPHY) ? (4) : (3); + int i, max = (gsw->port4_ephy) ? (4) : (3); status = mtk_switch_r32(gsw, GSW_REG_ISR); if (status & PORT_IRQ_ST_CHG) @@ -61,119 +61,82 @@ static irqreturn_t gsw_interrupt_mt7620(int irq, void *_priv) return IRQ_HANDLED; } -static int mt7620_mdio_mode(struct device_node *eth_node) -{ - struct device_node *phy_node, *mdiobus_node; - const __be32 *id; - int ret = 0; - - mdiobus_node = of_get_child_by_name(eth_node, "mdio-bus"); - - if (mdiobus_node) { - if (of_property_read_bool(mdiobus_node, "mediatek,mdio-mode")) - ret = 1; - - for_each_child_of_node(mdiobus_node, phy_node) { - id = of_get_property(phy_node, "reg", NULL); - if (id && (be32_to_cpu(*id) == 0x1f)) - ret = 1; - } - - of_node_put(mdiobus_node); - } - - return ret; -} - -static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) +static void mt7620_hw_init(struct mt7620_gsw *gsw) { u32 i; u32 val; - u32 is_BGA = (rt_sysc_r32(0x0c) >> 16) & 1; + u32 is_BGA = (rt_sysc_r32(SYSC_REG_CHIP_REV_ID) >> 16) & 1; + + /* Internal ethernet requires PCIe RC mode */ + rt_sysc_w32(rt_sysc_r32(SYSC_REG_CFG1) | PCIE_RC_MODE, SYSC_REG_CFG1); - rt_sysc_w32(rt_sysc_r32(SYSC_REG_CFG1) | BIT(8), SYSC_REG_CFG1); mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_CKGCR) & ~(0x3 << 4), GSW_REG_CKGCR); /* Enable MIB stats */ mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_MIB_CNT_EN) | (1 << 1), GSW_REG_MIB_CNT_EN); - if (mdio_mode) { - u32 val; - - /* turn off ephy and set phy base addr to 12 */ + if (gsw->ephy_disable) { mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | - (0x1f << 24) | (0xc << 16), + (gsw->ephy_base << 16) | (0x1f << 24), GSW_REG_GPC1); - /* set MT7530 central align */ - val = mt7530_mdio_r32(gsw, 0x7830); - val &= ~BIT(0); - val |= BIT(1); - mt7530_mdio_w32(gsw, 0x7830, val); + pr_info("gsw: internal ephy disabled\n"); + } else if (gsw->ephy_base) { + mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | + (gsw->ephy_base << 16), + GSW_REG_GPC1); + fe_reset(MT7620A_RESET_EPHY); - val = mt7530_mdio_r32(gsw, 0x7a40); - val &= ~BIT(30); - mt7530_mdio_w32(gsw, 0x7a40, val); + pr_info("gsw: ephy base address: %d\n", gsw->ephy_base); + } - mt7530_mdio_w32(gsw, 0x7a78, 0x855); + /* global page 4 */ + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x4000); + + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0x7444); + if (is_BGA) + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 19, 0x0114); + else + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 19, 0x0117); + + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x10cf); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x6212); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0777); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 29, 0x4000); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 28, 0xc077); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0000); + + /* global page 3 */ + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x3000); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0x4838); + + /* global page 2 */ + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x2000); + if (is_BGA) { + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 21, 0x0515); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x0053); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 23, 0x00bf); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0aaf); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x0fad); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0fc1); } else { + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 21, 0x0517); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x0fd2); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 23, 0x00bf); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0aab); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x00ae); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0fff); + } + /* global page 1 */ + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x1000); + _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0xe7f8); - if (gsw->ephy_base) { - /* set phy base addr to ephy_base */ - mtk_switch_w32(gsw, mtk_switch_r32(gsw, GSW_REG_GPC1) | - (gsw->ephy_base << 16), - GSW_REG_GPC1); - fe_reset(BIT(24)); /* Resets the Ethernet PHY block. */ - } - - /* global page 4 */ - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x4000); - - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0x7444); - if (is_BGA) - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 19, 0x0114); - else - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 19, 0x0117); - - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x10cf); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x6212); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0777); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 29, 0x4000); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 28, 0xc077); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0000); - - /* global page 3 */ - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x3000); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0x4838); - - /* global page 2 */ - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x2000); - if (is_BGA) { - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 21, 0x0515); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x0053); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 23, 0x00bf); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0aaf); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x0fad); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0fc1); - } else { - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 21, 0x0517); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 22, 0x0fd2); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 23, 0x00bf); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 24, 0x0aab); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 25, 0x00ae); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 26, 0x0fff); - } - /* global page 1 */ - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 31, 0x1000); - _mt7620_mii_write(gsw, gsw->ephy_base + 1, 17, 0xe7f8); - - /* turn on all PHYs */ - for (i = 0; i <= 4; i++) { - val = _mt7620_mii_read(gsw, gsw->ephy_base + i, MII_BMCR); - val &= ~BMCR_PDOWN; - val |= BMCR_ANRESTART | BMCR_ANENABLE | BMCR_SPEED100; - _mt7620_mii_write(gsw, gsw->ephy_base + i, MII_BMCR, val); - } + /* turn on all PHYs */ + for (i = 0; i <= 4; i++) { + val = _mt7620_mii_read(gsw, gsw->ephy_base + i, MII_BMCR); + val &= ~BMCR_PDOWN; + val |= BMCR_ANRESTART | BMCR_ANENABLE | BMCR_SPEED100; + _mt7620_mii_write(gsw, gsw->ephy_base + i, MII_BMCR, val); } /* global page 0 */ @@ -202,8 +165,8 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) mtk_switch_w32(gsw, 0x7f7f7fe0, 0x0010); /* setup port 4 */ - if (gsw->port4 == PORT4_EPHY) { - u32 val = rt_sysc_r32(SYSC_REG_CFG1); + if (gsw->port4_ephy) { + val = rt_sysc_r32(SYSC_REG_CFG1); val |= 3 << 14; rt_sysc_w32(val, SYSC_REG_CFG1); @@ -211,12 +174,6 @@ static void mt7620_hw_init(struct mt7620_gsw *gsw, int mdio_mode) _mt7620_mii_write(gsw, gsw->ephy_base + 4, 4, 0x05e1); _mt7620_mii_write(gsw, gsw->ephy_base + 4, 16, 0x1313); pr_info("gsw: setting port4 to ephy mode\n"); - } else if (!mdio_mode) { - u32 val = rt_sysc_r32(SYSC_REG_CFG1); - - val &= ~(3 << 14); - rt_sysc_w32(val, SYSC_REG_CFG1); - pr_info("gsw: setting port4 to gmac mode\n"); } } @@ -228,9 +185,13 @@ MODULE_DEVICE_TABLE(of, mediatek_gsw_match); int mtk_gsw_init(struct fe_priv *priv) { + struct device_node *eth_node = priv->dev->of_node; + struct device_node *phy_node, *mdiobus_node; struct device_node *np = priv->switch_np; struct platform_device *pdev = of_find_device_by_node(np); struct mt7620_gsw *gsw; + const __be32 *id; + u8 val; if (!pdev) return -ENODEV; @@ -241,7 +202,27 @@ int mtk_gsw_init(struct fe_priv *priv) gsw = platform_get_drvdata(pdev); priv->soc->swpriv = gsw; - mt7620_hw_init(gsw, mt7620_mdio_mode(priv->dev->of_node)); + gsw->ephy_disable = of_property_read_bool(np, "mediatek,ephy-disable"); + + mdiobus_node = of_get_child_by_name(eth_node, "mdio-bus"); + if (mdiobus_node) { + for_each_child_of_node(mdiobus_node, phy_node) { + id = of_get_property(phy_node, "reg", NULL); + if (id && (be32_to_cpu(*id) == 0x1f)) + gsw->ephy_disable = true; + } + + of_node_put(mdiobus_node); + } + + gsw->port4_ephy = !of_property_read_bool(np, "mediatek,port4-gmac"); + + if (of_property_read_u8(np, "mediatek,ephy-base", &val) == 0) + gsw->ephy_base = val; + else + gsw->ephy_base = 0; + + mt7620_hw_init(gsw); if (gsw->irq) { request_irq(gsw->irq, gsw_interrupt_mt7620, 0, @@ -255,10 +236,7 @@ int mtk_gsw_init(struct fe_priv *priv) static int mt7620_gsw_probe(struct platform_device *pdev) { struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - const char *port4 = NULL; struct mt7620_gsw *gsw; - struct device_node *np = pdev->dev.of_node; - u16 val; gsw = devm_kzalloc(&pdev->dev, sizeof(struct mt7620_gsw), GFP_KERNEL); if (!gsw) @@ -270,19 +248,6 @@ static int mt7620_gsw_probe(struct platform_device *pdev) gsw->dev = &pdev->dev; - of_property_read_string(np, "mediatek,port4", &port4); - if (port4 && !strcmp(port4, "ephy")) - gsw->port4 = PORT4_EPHY; - else if (port4 && !strcmp(port4, "gmac")) - gsw->port4 = PORT4_EXT; - else - gsw->port4 = PORT4_EPHY; - - if (of_property_read_u16(np, "mediatek,ephy-base-address", &val) == 0) - gsw->ephy_base = val; - else - gsw->ephy_base = 0; - gsw->irq = platform_get_irq(pdev, 0); platform_set_drvdata(pdev, gsw); diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h index 03d030446..cb5d098e9 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7620.h @@ -17,11 +17,7 @@ #define GSW_REG_PHY_TIMEOUT (5 * HZ) -#ifdef CONFIG_SOC_MT7621 -#define MT7620A_GSW_REG_PIAC 0x0004 -#else #define MT7620A_GSW_REG_PIAC 0x7004 -#endif #define GSW_NUM_VLANS 16 #define GSW_NUM_VIDS 4096 @@ -59,17 +55,13 @@ #define SYSC_REG_CHIP_REV_ID 0x0c #define SYSC_REG_CFG1 0x14 -#define RST_CTRL_MCM BIT(2) +#define PCIE_RC_MODE BIT(8) #define SYSC_PAD_RGMII2_MDIO 0x58 #define SYSC_GPIO_MODE 0x60 #define PORT_IRQ_ST_CHG 0x7f -#ifdef CONFIG_SOC_MT7621 -#define ESW_PHY_POLLING 0x0000 -#else #define ESW_PHY_POLLING 0x7000 -#endif #define PMCR_IPG BIT(18) #define PMCR_MAC_MODE BIT(16) @@ -96,16 +88,12 @@ enum { GSW_ATTR_PORT_UNTAG, }; -enum { - PORT4_EPHY = 0, - PORT4_EXT, -}; - struct mt7620_gsw { struct device *dev; void __iomem *base; int irq; - int port4; + bool ephy_disable; + bool port4_ephy; unsigned long int autopoll; u16 ephy_base; }; diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7621.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7621.c deleted file mode 100644 index c2538ef99..000000000 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/gsw_mt7621.c +++ /dev/null @@ -1,297 +0,0 @@ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Copyright (C) 2009-2015 John Crispin - * Copyright (C) 2009-2015 Felix Fietkau - * Copyright (C) 2013-2015 Michael Lee - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "mtk_eth_soc.h" -#include "gsw_mt7620.h" - -void mtk_switch_w32(struct mt7620_gsw *gsw, u32 val, unsigned reg) -{ - iowrite32(val, gsw->base + reg); -} - -u32 mtk_switch_r32(struct mt7620_gsw *gsw, unsigned reg) -{ - return ioread32(gsw->base + reg); -} - -static irqreturn_t gsw_interrupt_mt7621(int irq, void *_priv) -{ - struct fe_priv *priv = (struct fe_priv *)_priv; - struct mt7620_gsw *gsw = (struct mt7620_gsw *)priv->soc->swpriv; - u32 reg, i; - - reg = mt7530_mdio_r32(gsw, 0x700c); - mt7530_mdio_w32(gsw, 0x700c, reg); - - for (i = 0; i < 5; i++) - if (reg & BIT(i)) { - unsigned int link; - - link = mt7530_mdio_r32(gsw, - 0x3008 + (i * 0x100)) & 0x1; - - if (link != priv->link[i]) { - priv->link[i] = link; - if (link) - netdev_info(priv->netdev, - "port %d link up\n", i); - else - netdev_info(priv->netdev, - "port %d link down\n", i); - } - } - - mt7620_handle_carrier(priv); - - return IRQ_HANDLED; -} - -static void mt7621_hw_init(struct mt7620_gsw *gsw, struct device_node *np) -{ - u32 i; - u32 val; - - /* wardware reset the switch */ - fe_reset(RST_CTRL_MCM); - mdelay(10); - - /* reduce RGMII2 PAD driving strength */ - rt_sysc_m32(3 << 4, 0, SYSC_PAD_RGMII2_MDIO); - - /* gpio mux - RGMII1=Normal mode */ - rt_sysc_m32(BIT(14), 0, SYSC_GPIO_MODE); - - /* set GMAC1 RGMII mode */ - rt_sysc_m32(3 << 12, 0, SYSC_REG_CFG1); - - /* enable MDIO to control MT7530 */ - rt_sysc_m32(3 << 12, 0, SYSC_GPIO_MODE); - - /* turn off all PHYs */ - for (i = 0; i <= 4; i++) { - val = _mt7620_mii_read(gsw, i, 0x0); - val |= BIT(11); - _mt7620_mii_write(gsw, i, 0x0, val); - } - - /* reset the switch */ - mt7530_mdio_w32(gsw, 0x7000, 0x3); - usleep_range(10, 20); - - if ((rt_sysc_r32(SYSC_REG_CHIP_REV_ID) & 0xFFFF) == 0x0101) { - /* (GE1, Force 1000M/FD, FC ON, MAX_RX_LENGTH 1536) */ - mtk_switch_w32(gsw, 0x2305e30b, GSW_REG_MAC_P0_MCR); - mt7530_mdio_w32(gsw, 0x3600, 0x5e30b); - } else { - /* (GE1, Force 1000M/FD, FC ON, MAX_RX_LENGTH 1536) */ - mtk_switch_w32(gsw, 0x2305e33b, GSW_REG_MAC_P0_MCR); - mt7530_mdio_w32(gsw, 0x3600, 0x5e33b); - } - - /* (GE2, Link down) */ - mtk_switch_w32(gsw, 0x8000, GSW_REG_MAC_P1_MCR); - - /* Set switch max RX frame length to 2k */ - mt7530_mdio_w32(gsw, GSW_REG_GMACCR, 0x3F0B); - - /* Enable Port 6, P5 as GMAC5, P5 disable */ - val = mt7530_mdio_r32(gsw, 0x7804); - val &= ~BIT(8); - val |= BIT(6) | BIT(13) | BIT(16); - mt7530_mdio_w32(gsw, 0x7804, val); - - val = rt_sysc_r32(0x10); - val = (val >> 6) & 0x7; - if (val >= 6) { - /* 25Mhz Xtal - do nothing */ - } else if (val >= 3) { - /* 40Mhz */ - - /* disable MT7530 core clock */ - _mt7620_mii_write(gsw, 0, 13, 0x1f); - _mt7620_mii_write(gsw, 0, 14, 0x410); - _mt7620_mii_write(gsw, 0, 13, 0x401f); - _mt7620_mii_write(gsw, 0, 14, 0x0); - - /* disable MT7530 PLL */ - _mt7620_mii_write(gsw, 0, 13, 0x1f); - _mt7620_mii_write(gsw, 0, 14, 0x40d); - _mt7620_mii_write(gsw, 0, 13, 0x401f); - _mt7620_mii_write(gsw, 0, 14, 0x2020); - - /* for MT7530 core clock = 500Mhz */ - _mt7620_mii_write(gsw, 0, 13, 0x1f); - _mt7620_mii_write(gsw, 0, 14, 0x40e); - _mt7620_mii_write(gsw, 0, 13, 0x401f); - _mt7620_mii_write(gsw, 0, 14, 0x119); - - /* enable MT7530 PLL */ - _mt7620_mii_write(gsw, 0, 13, 0x1f); - _mt7620_mii_write(gsw, 0, 14, 0x40d); - _mt7620_mii_write(gsw, 0, 13, 0x401f); - _mt7620_mii_write(gsw, 0, 14, 0x2820); - - usleep_range(20, 40); - - /* enable MT7530 core clock */ - _mt7620_mii_write(gsw, 0, 13, 0x1f); - _mt7620_mii_write(gsw, 0, 14, 0x410); - _mt7620_mii_write(gsw, 0, 13, 0x401f); - } else { - /* 20Mhz Xtal - TODO */ - } - - /* RGMII */ - _mt7620_mii_write(gsw, 0, 14, 0x1); - - /* set MT7530 central align */ - val = mt7530_mdio_r32(gsw, 0x7830); - val &= ~BIT(0); - val |= BIT(1); - mt7530_mdio_w32(gsw, 0x7830, val); - val = mt7530_mdio_r32(gsw, 0x7a40); - val &= ~BIT(30); - mt7530_mdio_w32(gsw, 0x7a40, val); - mt7530_mdio_w32(gsw, 0x7a78, 0x855); - - /* delay setting for 10/1000M */ - mt7530_mdio_w32(gsw, 0x7b00, 0x102); - mt7530_mdio_w32(gsw, 0x7b04, 0x14); - - /* lower Tx Driving*/ - mt7530_mdio_w32(gsw, 0x7a54, 0x44); - mt7530_mdio_w32(gsw, 0x7a5c, 0x44); - mt7530_mdio_w32(gsw, 0x7a64, 0x44); - mt7530_mdio_w32(gsw, 0x7a6c, 0x44); - mt7530_mdio_w32(gsw, 0x7a74, 0x44); - mt7530_mdio_w32(gsw, 0x7a7c, 0x44); - - /* Disable EEE */ - for (i = 0; i <= 4; i++) { - _mt7620_mii_write(gsw, i, 13, 0x7); - _mt7620_mii_write(gsw, i, 14, 0x3C); - _mt7620_mii_write(gsw, i, 13, 0x4007); - _mt7620_mii_write(gsw, i, 14, 0x0); - } - - /* Disable EEE 10Base-Te */ - for (i = 0; i <= 4; i++) { - _mt7620_mii_write(gsw, i, 13, 0x1f); - _mt7620_mii_write(gsw, i, 14, 0x027b); - _mt7620_mii_write(gsw, i, 13, 0x401f); - _mt7620_mii_write(gsw, i, 14, 0x1177); - } - - /* turn on all PHYs */ - for (i = 0; i <= 4; i++) { - val = _mt7620_mii_read(gsw, i, 0); - val &= ~BIT(11); - _mt7620_mii_write(gsw, i, 0, val); - } - - /* enable irq */ - mt7530_mdio_w32(gsw, 0x7008, 0x1f); - val = mt7530_mdio_r32(gsw, 0x7808); - val |= 3 << 16; - mt7530_mdio_w32(gsw, 0x7808, val); -} - -static const struct of_device_id mediatek_gsw_match[] = { - { .compatible = "mediatek,ralink-mt7621-gsw" }, - {}, -}; -MODULE_DEVICE_TABLE(of, mediatek_gsw_match); - -int mtk_gsw_init(struct fe_priv *priv) -{ - struct device_node *np = priv->switch_np; - struct platform_device *pdev = of_find_device_by_node(np); - struct mt7620_gsw *gsw; - - if (!pdev) - return -ENODEV; - - if (!of_device_is_compatible(np, mediatek_gsw_match->compatible)) - return -EINVAL; - - gsw = platform_get_drvdata(pdev); - priv->soc->swpriv = gsw; - - if (gsw->irq) { - request_irq(gsw->irq, gsw_interrupt_mt7621, 0, - "gsw", priv); - disable_irq(gsw->irq); - } - - mt7621_hw_init(gsw, np); - - if (gsw->irq) - enable_irq(gsw->irq); - - return 0; -} - -static int mt7621_gsw_probe(struct platform_device *pdev) -{ - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - struct mt7620_gsw *gsw; - - gsw = devm_kzalloc(&pdev->dev, sizeof(struct mt7620_gsw), GFP_KERNEL); - if (!gsw) - return -ENOMEM; - - gsw->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(gsw->base)) - return PTR_ERR(gsw->base); - - gsw->dev = &pdev->dev; - gsw->irq = platform_get_irq(pdev, 0); - - platform_set_drvdata(pdev, gsw); - - return 0; -} - -static int mt7621_gsw_remove(struct platform_device *pdev) -{ - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static struct platform_driver gsw_driver = { - .probe = mt7621_gsw_probe, - .remove = mt7621_gsw_remove, - .driver = { - .name = "ralink-mt7621-gsw", - .owner = THIS_MODULE, - .of_match_table = mediatek_gsw_match, - }, -}; - -module_platform_driver(gsw_driver); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("John Crispin "); -MODULE_DESCRIPTION("GBit switch driver for Mediatek MT7621 SoC"); -MODULE_VERSION(MTK_FE_DRV_VERSION); diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c index f3f7b4e9f..b923b02af 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c @@ -97,13 +97,8 @@ int fe_connect_phy_node(struct fe_priv *priv, struct device_node *phy_node, int return -ENODEV; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) - phydev->supported &= PHY_GBIT_FEATURES; - phydev->advertising = phydev->supported; -#else phy_set_max_speed(phydev, SPEED_1000); linkmode_copy(phydev->advertising, phydev->supported); -#endif phydev->no_auto_carrier_off = 1; dev_info(priv->dev, @@ -125,17 +120,11 @@ static void phy_init(struct fe_priv *priv, struct phy_device *phy) phy->speed = 0; phy->duplex = 0; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) - phy->supported &= IS_ENABLED(CONFIG_NET_RALINK_MDIO_MT7620) ? - PHY_GBIT_FEATURES : PHY_BASIC_FEATURES; - phy->advertising = phy->supported | ADVERTISED_Autoneg; -#else phy_set_max_speed(phy, IS_ENABLED(CONFIG_NET_RALINK_MDIO_MT7620) ? SPEED_1000 : SPEED_100); linkmode_copy(phy->advertising, phy->supported); linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phy->advertising); -#endif phy_start_aneg(phy); } @@ -243,7 +232,8 @@ int fe_mdio_init(struct fe_priv *priv) mii_np = of_get_child_by_name(priv->dev->of_node, "mdio-bus"); if (!mii_np) { dev_err(priv->dev, "no %s child node found", "mdio-bus"); - return -ENODEV; + err = 0; + goto err_no_bus; } if (!of_device_is_available(mii_np)) { @@ -275,6 +265,8 @@ err_free_bus: kfree(priv->mii_bus); err_put_node: of_node_put(mii_np); +err_no_bus: + dev_err(priv->dev, "%s disabled", "mdio-bus"); priv->mii_bus = NULL; return err; } diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c index 0d9e63541..b4632d399 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.c @@ -37,11 +37,7 @@ #define MT7530_CPU_PORT 6 #define MT7530_NUM_PORTS 8 -#ifdef CONFIG_SOC_MT7621 -#define MT7530_NUM_VLANS 4095 -#else #define MT7530_NUM_VLANS 16 -#endif #define MT7530_MAX_VID 4095 #define MT7530_MIN_VID 0 #define MT7530_NUM_ARL_RECORDS 2048 @@ -50,9 +46,6 @@ #define MT7530_PORT_MIB_TXB_ID 2 /* TxGOC */ #define MT7530_PORT_MIB_RXB_ID 6 /* RxGOC */ -#define MT7621_PORT_MIB_TXB_ID 18 /* TxByte */ -#define MT7621_PORT_MIB_RXB_ID 37 /* RxByte */ - /* registers */ #define REG_ESW_WT_MAC_MFC 0x10 @@ -159,50 +152,6 @@ static const struct mt7xxx_mib_desc mt7620_port_mibs[] = { MIB_DESC(1, MT7620_MIB_STATS_PORT_REPC2N, "RxEPC2") }; -static const struct mt7xxx_mib_desc mt7621_mibs[] = { - MIB_DESC(1, MT7621_STATS_TDPC, "TxDrop"), - MIB_DESC(1, MT7621_STATS_TCRC, "TxCRC"), - MIB_DESC(1, MT7621_STATS_TUPC, "TxUni"), - MIB_DESC(1, MT7621_STATS_TMPC, "TxMulti"), - MIB_DESC(1, MT7621_STATS_TBPC, "TxBroad"), - MIB_DESC(1, MT7621_STATS_TCEC, "TxCollision"), - MIB_DESC(1, MT7621_STATS_TSCEC, "TxSingleCol"), - MIB_DESC(1, MT7621_STATS_TMCEC, "TxMultiCol"), - MIB_DESC(1, MT7621_STATS_TDEC, "TxDefer"), - MIB_DESC(1, MT7621_STATS_TLCEC, "TxLateCol"), - MIB_DESC(1, MT7621_STATS_TXCEC, "TxExcCol"), - MIB_DESC(1, MT7621_STATS_TPPC, "TxPause"), - MIB_DESC(1, MT7621_STATS_TL64PC, "Tx64Byte"), - MIB_DESC(1, MT7621_STATS_TL65PC, "Tx65Byte"), - MIB_DESC(1, MT7621_STATS_TL128PC, "Tx128Byte"), - MIB_DESC(1, MT7621_STATS_TL256PC, "Tx256Byte"), - MIB_DESC(1, MT7621_STATS_TL512PC, "Tx512Byte"), - MIB_DESC(1, MT7621_STATS_TL1024PC, "Tx1024Byte"), - MIB_DESC(2, MT7621_STATS_TOC, "TxByte"), - MIB_DESC(1, MT7621_STATS_RDPC, "RxDrop"), - MIB_DESC(1, MT7621_STATS_RFPC, "RxFiltered"), - MIB_DESC(1, MT7621_STATS_RUPC, "RxUni"), - MIB_DESC(1, MT7621_STATS_RMPC, "RxMulti"), - MIB_DESC(1, MT7621_STATS_RBPC, "RxBroad"), - MIB_DESC(1, MT7621_STATS_RAEPC, "RxAlignErr"), - MIB_DESC(1, MT7621_STATS_RCEPC, "RxCRC"), - MIB_DESC(1, MT7621_STATS_RUSPC, "RxUnderSize"), - MIB_DESC(1, MT7621_STATS_RFEPC, "RxFragment"), - MIB_DESC(1, MT7621_STATS_ROSPC, "RxOverSize"), - MIB_DESC(1, MT7621_STATS_RJEPC, "RxJabber"), - MIB_DESC(1, MT7621_STATS_RPPC, "RxPause"), - MIB_DESC(1, MT7621_STATS_RL64PC, "Rx64Byte"), - MIB_DESC(1, MT7621_STATS_RL65PC, "Rx65Byte"), - MIB_DESC(1, MT7621_STATS_RL128PC, "Rx128Byte"), - MIB_DESC(1, MT7621_STATS_RL256PC, "Rx256Byte"), - MIB_DESC(1, MT7621_STATS_RL512PC, "Rx512Byte"), - MIB_DESC(1, MT7621_STATS_RL1024PC, "Rx1024Byte"), - MIB_DESC(2, MT7621_STATS_ROC, "RxByte"), - MIB_DESC(1, MT7621_STATS_RDPC_CTRL, "RxCtrlDrop"), - MIB_DESC(1, MT7621_STATS_RDPC_ING, "RxIngDrop"), - MIB_DESC(1, MT7621_STATS_RDPC_ARL, "RxARLDrop") -}; - enum { /* Global attributes. */ MT7530_ATTR_ENABLE_VLAN, @@ -514,14 +463,6 @@ mt7530_set_vid(struct switch_dev *dev, const struct switch_attr *attr, return 0; } -static int -mt7621_get_vid(struct switch_dev *dev, const struct switch_attr *attr, - struct switch_val *val) -{ - val->value.i = val->port_vlan; - return 0; -} - static int mt7530_get_vid(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val) @@ -614,7 +555,6 @@ mt7530_write_vlan_entry(struct mt7530_priv *priv, int vlan, u16 vid, int port; u32 val; -#ifndef CONFIG_SOC_MT7621 /* vid of vlan */ val = mt7530_r32(priv, REG_ESW_VLAN_VTIM(vlan)); if (vlan % 2 == 0) { @@ -625,7 +565,6 @@ mt7530_write_vlan_entry(struct mt7530_priv *priv, int vlan, u16 vid, val |= (vid << 12); } mt7530_w32(priv, REG_ESW_VLAN_VTIM(vlan), val); -#endif /* vlan port membership */ if (ports) @@ -646,11 +585,7 @@ mt7530_write_vlan_entry(struct mt7530_priv *priv, int vlan, u16 vid, mt7530_w32(priv, REG_ESW_VLAN_VAWD2, val); /* write to vlan table */ -#ifdef CONFIG_SOC_MT7621 - mt7530_vtcr(priv, 1, vid); -#else mt7530_vtcr(priv, 1, vlan); -#endif } static int @@ -803,53 +738,6 @@ mt7530_get_port_link(struct switch_dev *dev, int port, return 0; } -static u64 get_mib_counter(struct mt7530_priv *priv, int i, int port) -{ - unsigned int port_base; - u64 lo; - - port_base = MT7621_MIB_COUNTER_BASE + - MT7621_MIB_COUNTER_PORT_OFFSET * port; - - lo = mt7530_r32(priv, port_base + mt7621_mibs[i].offset); - if (mt7621_mibs[i].size == 2) { - u64 hi; - - hi = mt7530_r32(priv, port_base + mt7621_mibs[i].offset + 4); - lo |= hi << 32; - } - - return lo; -} - -static int mt7621_sw_get_port_mib(struct switch_dev *dev, - const struct switch_attr *attr, - struct switch_val *val) -{ - static char buf[4096]; - struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev); - int i, len = 0; - - if (val->port_vlan >= MT7530_NUM_PORTS) - return -EINVAL; - - len += snprintf(buf + len, sizeof(buf) - len, - "Port %d MIB counters\n", val->port_vlan); - - for (i = 0; i < ARRAY_SIZE(mt7621_mibs); ++i) { - u64 counter; - len += snprintf(buf + len, sizeof(buf) - len, - "%-11s: ", mt7621_mibs[i].name); - counter = get_mib_counter(priv, i, val->port_vlan); - len += snprintf(buf + len, sizeof(buf) - len, "%llu\n", - counter); - } - - val->value.s = buf; - val->len = len; - return 0; -} - static u64 get_mib_counter_7620(struct mt7530_priv *priv, int i) { return mt7530_r32(priv, MT7620_MIB_COUNTER_BASE + mt7620_mibs[i].offset); @@ -1023,20 +911,6 @@ static int mt7530_get_port_stats(struct switch_dev *dev, int port, return 0; } -static int mt7621_get_port_stats(struct switch_dev *dev, int port, - struct switch_port_stats *stats) -{ - struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, swdev); - - if (port < 0 || port >= MT7530_NUM_PORTS) - return -EINVAL; - - stats->tx_bytes = get_mib_counter(priv, MT7621_PORT_MIB_TXB_ID, port); - stats->rx_bytes = get_mib_counter(priv, MT7621_PORT_MIB_RXB_ID, port); - - return 0; -} - static const struct switch_attr mt7530_global[] = { { .type = SWITCH_TYPE_INT, @@ -1069,41 +943,6 @@ static const struct switch_attr mt7530_global[] = { }, }; -static const struct switch_attr mt7621_port[] = { - { - .type = SWITCH_TYPE_STRING, - .name = "mib", - .description = "Get MIB counters for port", - .get = mt7621_sw_get_port_mib, - .set = NULL, - }, { - .type = SWITCH_TYPE_INT, - .name = "enable_mirror_rx", - .description = "Enable mirroring of RX packets", - .set = mt7530_set_port_mirror_rx, - .get = mt7530_get_port_mirror_rx, - .max = 1, - }, { - .type = SWITCH_TYPE_INT, - .name = "enable_mirror_tx", - .description = "Enable mirroring of TX packets", - .set = mt7530_set_port_mirror_tx, - .get = mt7530_get_port_mirror_tx, - .max = 1, - }, -}; - -static const struct switch_attr mt7621_vlan[] = { - { - .type = SWITCH_TYPE_INT, - .name = "vid", - .description = "VLAN ID (0-4094)", - .set = mt7530_set_vid, - .get = mt7621_get_vid, - .max = 4094, - }, -}; - static const struct switch_attr mt7530_port[] = { { .type = SWITCH_TYPE_STRING, @@ -1139,29 +978,6 @@ static const struct switch_attr mt7530_vlan[] = { }, }; -static const struct switch_dev_ops mt7621_ops = { - .attr_global = { - .attr = mt7530_global, - .n_attr = ARRAY_SIZE(mt7530_global), - }, - .attr_port = { - .attr = mt7621_port, - .n_attr = ARRAY_SIZE(mt7621_port), - }, - .attr_vlan = { - .attr = mt7621_vlan, - .n_attr = ARRAY_SIZE(mt7621_vlan), - }, - .get_vlan_ports = mt7530_get_vlan_ports, - .set_vlan_ports = mt7530_set_vlan_ports, - .get_port_pvid = mt7530_get_port_pvid, - .set_port_pvid = mt7530_set_port_pvid, - .get_port_link = mt7530_get_port_link, - .get_port_stats = mt7621_get_port_stats, - .apply_config = mt7530_apply_config, - .reset_switch = mt7530_reset_switch, -}; - static const struct switch_dev_ops mt7530_ops = { .attr_global = { .attr = mt7530_global, @@ -1205,9 +1021,6 @@ mt7530_probe(struct device *dev, void __iomem *base, struct mii_bus *bus, int vl if (bus) { swdev->alias = "mt7530"; swdev->name = "mt7530"; - } else if (IS_ENABLED(CONFIG_SOC_MT7621)) { - swdev->alias = "mt7621"; - swdev->name = "mt7621"; } else { swdev->alias = "mt7620"; swdev->name = "mt7620"; @@ -1215,10 +1028,7 @@ mt7530_probe(struct device *dev, void __iomem *base, struct mii_bus *bus, int vl swdev->cpu_port = MT7530_CPU_PORT; swdev->ports = MT7530_NUM_PORTS; swdev->vlans = MT7530_NUM_VLANS; - if (IS_ENABLED(CONFIG_SOC_MT7621)) - swdev->ops = &mt7621_ops; - else - swdev->ops = &mt7530_ops; + swdev->ops = &mt7530_ops; ret = register_switch(swdev, NULL); if (ret) { @@ -1233,7 +1043,7 @@ mt7530_probe(struct device *dev, void __iomem *base, struct mii_bus *bus, int vl mt7530_apply_config(swdev); /* magic vodoo */ - if (!IS_ENABLED(CONFIG_SOC_MT7621) && bus && mt7530_r32(mt7530, REG_HWTRAP) != 0x1117edf) { + if (bus && mt7530_r32(mt7530, REG_HWTRAP) != 0x1117edf) { dev_info(dev, "fixing up MHWTRAP register - bootloader probably played with it\n"); mt7530_w32(mt7530, REG_HWTRAP, 0x1117edf); } diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.h b/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.h index cf725c2f2..53e1d2ce5 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.h +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mt7530.h @@ -137,50 +137,6 @@ /* Rx Event Packet Counter of Port n */ #define MT7620_MIB_STATS_PORT_REPC2N 0x30 -#define MT7621_MIB_COUNTER_BASE 0x4000 -#define MT7621_MIB_COUNTER_PORT_OFFSET 0x100 -#define MT7621_STATS_TDPC 0x00 -#define MT7621_STATS_TCRC 0x04 -#define MT7621_STATS_TUPC 0x08 -#define MT7621_STATS_TMPC 0x0C -#define MT7621_STATS_TBPC 0x10 -#define MT7621_STATS_TCEC 0x14 -#define MT7621_STATS_TSCEC 0x18 -#define MT7621_STATS_TMCEC 0x1C -#define MT7621_STATS_TDEC 0x20 -#define MT7621_STATS_TLCEC 0x24 -#define MT7621_STATS_TXCEC 0x28 -#define MT7621_STATS_TPPC 0x2C -#define MT7621_STATS_TL64PC 0x30 -#define MT7621_STATS_TL65PC 0x34 -#define MT7621_STATS_TL128PC 0x38 -#define MT7621_STATS_TL256PC 0x3C -#define MT7621_STATS_TL512PC 0x40 -#define MT7621_STATS_TL1024PC 0x44 -#define MT7621_STATS_TOC 0x48 -#define MT7621_STATS_RDPC 0x60 -#define MT7621_STATS_RFPC 0x64 -#define MT7621_STATS_RUPC 0x68 -#define MT7621_STATS_RMPC 0x6C -#define MT7621_STATS_RBPC 0x70 -#define MT7621_STATS_RAEPC 0x74 -#define MT7621_STATS_RCEPC 0x78 -#define MT7621_STATS_RUSPC 0x7C -#define MT7621_STATS_RFEPC 0x80 -#define MT7621_STATS_ROSPC 0x84 -#define MT7621_STATS_RJEPC 0x88 -#define MT7621_STATS_RPPC 0x8C -#define MT7621_STATS_RL64PC 0x90 -#define MT7621_STATS_RL65PC 0x94 -#define MT7621_STATS_RL128PC 0x98 -#define MT7621_STATS_RL256PC 0x9C -#define MT7621_STATS_RL512PC 0xA0 -#define MT7621_STATS_RL1024PC 0xA4 -#define MT7621_STATS_ROC 0xA8 -#define MT7621_STATS_RDPC_CTRL 0xB0 -#define MT7621_STATS_RDPC_ING 0xB4 -#define MT7621_STATS_RDPC_ARL 0xB8 - int mt7530_probe(struct device *dev, void __iomem *base, struct mii_bus *bus, int vlan); #endif diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_debugfs.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_debugfs.c deleted file mode 100644 index 44b2e9d43..000000000 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_debugfs.c +++ /dev/null @@ -1,115 +0,0 @@ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Copyright (C) 2014-2016 Sean Wang - * Copyright (C) 2016-2017 John Crispin - */ - -#include "mtk_offload.h" - -static const char *mtk_foe_entry_state_str[] = { - "INVALID", - "UNBIND", - "BIND", - "FIN" -}; - -static const char *mtk_foe_packet_type_str[] = { - "IPV4_HNAPT", - "IPV4_HNAT", - "IPV6_1T_ROUTE", - "IPV4_DSLITE", - "IPV6_3T_ROUTE", - "IPV6_5T_ROUTE", - "IPV6_6RD", -}; - -#define IPV4_HNAPT 0 -#define IPV4_HNAT 1 -#define IS_IPV4_HNAPT(x) (((x)->bfib1.pkt_type == IPV4_HNAPT) ? 1: 0) -static struct mtk_eth *_eth; -#define es(entry) (mtk_foe_entry_state_str[entry->bfib1.state]) -//#define ei(entry, end) (MTK_PPE_TBL_SZ - (int)(end - entry)) -#define ei(entry, end) (MTK_PPE_ENTRY_CNT - (int)(end - entry)) -#define pt(entry) (mtk_foe_packet_type_str[entry->ipv4_hnapt.bfib1.pkt_type]) - -static int mtk_ppe_debugfs_foe_show(struct seq_file *m, void *private) -{ - struct mtk_eth *eth = _eth; - struct mtk_foe_entry *entry, *end; - int i = 0; - - entry = eth->foe_table; - end = eth->foe_table + MTK_PPE_ENTRY_CNT; - - while (entry < end) { - if (IS_IPV4_HNAPT(entry)) { - __be32 saddr = htonl(entry->ipv4_hnapt.sip); - __be32 daddr = htonl(entry->ipv4_hnapt.dip); - __be32 nsaddr = htonl(entry->ipv4_hnapt.new_sip); - __be32 ndaddr = htonl(entry->ipv4_hnapt.new_dip); - unsigned char h_dest[ETH_ALEN]; - unsigned char h_source[ETH_ALEN]; - - *((u32*) h_source) = swab32(entry->ipv4_hnapt.smac_hi); - *((u16*) &h_source[4]) = swab16(entry->ipv4_hnapt.smac_lo); - *((u32*) h_dest) = swab32(entry->ipv4_hnapt.dmac_hi); - *((u16*) &h_dest[4]) = swab16(entry->ipv4_hnapt.dmac_lo); - seq_printf(m, - "(%x)0x%05x|state=%s|type=%s|" - "%pI4:%d->%pI4:%d=>%pI4:%d->%pI4:%d|%pM=>%pM|" - "etype=0x%04x|info1=0x%x|info2=0x%x|" - "vlan1=%d|vlan2=%d\n", - i, - ei(entry, end), es(entry), pt(entry), - &saddr, entry->ipv4_hnapt.sport, - &daddr, entry->ipv4_hnapt.dport, - &nsaddr, entry->ipv4_hnapt.new_sport, - &ndaddr, entry->ipv4_hnapt.new_dport, h_source, - h_dest, ntohs(entry->ipv4_hnapt.etype), - entry->ipv4_hnapt.info_blk1, - entry->ipv4_hnapt.info_blk2, - entry->ipv4_hnapt.vlan1, - entry->ipv4_hnapt.vlan2); - } else - seq_printf(m, "0x%05x state=%s\n", - ei(entry, end), es(entry)); - entry++; - i++; - } - - return 0; -} - -static int mtk_ppe_debugfs_foe_open(struct inode *inode, struct file *file) -{ - return single_open(file, mtk_ppe_debugfs_foe_show, file->private_data); -} - -static const struct file_operations mtk_ppe_debugfs_foe_fops = { - .open = mtk_ppe_debugfs_foe_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -int ra_ppe_debugfs_init(struct mtk_eth *eth) -{ - struct dentry *root; - - _eth = eth; - - root = debugfs_create_dir("mtk_ppe", NULL); - if (!root) - return -ENOMEM; - - debugfs_create_file("all_entry", S_IRUGO, root, eth, &mtk_ppe_debugfs_foe_fops); - - return 0; -} diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c index 5220f0bf6..cf6d4806e 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c @@ -141,6 +141,17 @@ void fe_reset(u32 reset_bits) usleep_range(10, 20); } +void fe_reset_fe(struct fe_priv *priv) +{ + if (!priv->rst_fe) + return; + + reset_control_assert(priv->rst_fe); + usleep_range(60, 120); + reset_control_deassert(priv->rst_fe); + usleep_range(60, 120); +} + static inline void fe_int_disable(u32 mask) { fe_reg_w32(fe_reg_r32(FE_REG_FE_INT_ENABLE) & ~mask, @@ -564,7 +575,7 @@ static inline u32 fe_empty_txd(struct fe_tx_ring *ring) barrier(); return (u32)(ring->tx_ring_size - ((ring->tx_next_idx - ring->tx_free_idx) & - (ring->tx_ring_size - 1)) - 1); + (ring->tx_ring_size - 1))); } struct fe_map_state { @@ -715,19 +726,11 @@ next_frag: /* TX SG offload */ nr_frags = skb_shinfo(skb)->nr_frags; for (i = 0; i < nr_frags; i++) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) - struct skb_frag_struct *frag; -#else skb_frag_t *frag; -#endif frag = &skb_shinfo(skb)->frags[i]; if (fe_tx_dma_map_page(ring, &st, skb_frag_page(frag), -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) - frag->page_offset, skb_frag_size(frag))) -#else skb_frag_off(frag), skb_frag_size(frag))) -#endif goto err_dma; } @@ -762,11 +765,7 @@ next_frag: netif_wake_queue(dev); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0) - if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || !head->xmit_more) -#else if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || !netdev_xmit_more()) -#endif fe_reg_w32(ring->tx_next_idx, FE_REG_TX_CTX_IDX0); return 0; @@ -825,22 +824,14 @@ static inline int fe_cal_txd_req(struct sk_buff *skb) { struct sk_buff *head = skb; int i, nfrags = 0; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) - struct skb_frag_struct *frag; -#else skb_frag_t *frag; -#endif next_frag: nfrags++; if (skb_is_gso(skb)) { for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { frag = &skb_shinfo(skb)->frags[i]; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) - nfrags += DIV_ROUND_UP(frag->size, TX_DMA_BUF_LEN); -#else nfrags += DIV_ROUND_UP(skb_frag_size(frag), TX_DMA_BUF_LEN); -#endif } } else { nfrags += skb_shinfo(skb)->nr_frags; @@ -898,8 +889,6 @@ static int fe_poll_rx(struct napi_struct *napi, int budget, struct fe_rx_dma *rxd, trxd; int done = 0, pad; - fe_reg_w32(rx_intr, FE_REG_FE_INT_STATUS); - if (netdev->features & NETIF_F_RXCSUM) checksum_bit = soc->checksum_bit; else @@ -962,18 +951,11 @@ static int fe_poll_rx(struct napi_struct *napi, int budget, __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), RX_DMA_VID(trxd.rxd3)); -#ifdef CONFIG_NET_RALINK_OFFLOAD - if (ra_offload_check_rx(priv, skb, trxd.rxd4) == 0) { -#endif - stats->rx_packets++; - stats->rx_bytes += pktlen; + stats->rx_packets++; + stats->rx_bytes += pktlen; + + napi_gro_receive(napi, skb); - napi_gro_receive(napi, skb); -#ifdef CONFIG_NET_RALINK_OFFLOAD - } else { - dev_kfree_skb(skb); - } -#endif ring->rx_data[idx] = new_data; rxd->rxd1 = (unsigned int)dma_addr; @@ -992,6 +974,9 @@ release_desc: done++; } + if (done < budget) + fe_reg_w32(rx_intr, FE_REG_FE_INT_STATUS); + return done; } @@ -1006,8 +991,6 @@ static int fe_poll_tx(struct fe_priv *priv, int budget, u32 tx_intr, u32 idx, hwidx; struct fe_tx_ring *ring = &priv->tx_ring; - fe_reg_w32(tx_intr, FE_REG_FE_INT_STATUS); - idx = ring->tx_free_idx; hwidx = fe_reg_r32(FE_REG_TX_DTX_IDX0); @@ -1031,7 +1014,9 @@ static int fe_poll_tx(struct fe_priv *priv, int budget, u32 tx_intr, if (idx == hwidx) { /* read hw index again make sure no new tx packet */ hwidx = fe_reg_r32(FE_REG_TX_DTX_IDX0); - if (idx != hwidx) + if (idx == hwidx) + fe_reg_w32(tx_intr, FE_REG_FE_INT_STATUS); + else *tx_again = 1; } else { *tx_again = 1; @@ -1311,9 +1296,6 @@ static int fe_open(struct net_device *dev) napi_enable(&priv->rx_napi); fe_int_enable(priv->soc->tx_int | priv->soc->rx_int); netif_start_queue(dev); -#ifdef CONFIG_NET_RALINK_OFFLOAD - ra_ppe_probe(priv); -#endif return 0; } @@ -1350,10 +1332,6 @@ static int fe_stop(struct net_device *dev) fe_free_dma(priv); -#ifdef CONFIG_NET_RALINK_OFFLOAD - ra_ppe_remove(priv); -#endif - return 0; } @@ -1393,13 +1371,21 @@ static int __init fe_init(struct net_device *dev) const char *mac_addr; int err; - priv->soc->reset_fe(); + if (priv->soc->reset_fe) + priv->soc->reset_fe(priv); + else + fe_reset_fe(priv); + + if (priv->soc->switch_init) { + err = priv->soc->switch_init(priv); + if (err) { + if (err == -EPROBE_DEFER) + return err; - if (priv->soc->switch_init) - if (priv->soc->switch_init(priv)) { netdev_err(dev, "failed to initialize switch core\n"); return -ENODEV; } + } fe_reset_phy(priv); @@ -1514,23 +1500,6 @@ static int fe_change_mtu(struct net_device *dev, int new_mtu) return fe_open(dev); } -#ifdef CONFIG_NET_RALINK_OFFLOAD -static int -fe_flow_offload(enum flow_offload_type type, struct flow_offload *flow, - struct flow_offload_hw_path *src, - struct flow_offload_hw_path *dest) -{ - struct fe_priv *priv; - - if (src->dev != dest->dev) - return -EINVAL; - - priv = netdev_priv(src->dev); - - return mtk_flow_offload(priv, type, flow, src, dest); -} -#endif - static const struct net_device_ops fe_netdev_ops = { .ndo_init = fe_init, .ndo_uninit = fe_uninit, @@ -1548,9 +1517,6 @@ static const struct net_device_ops fe_netdev_ops = { #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = fe_poll_controller, #endif -#ifdef CONFIG_NET_RALINK_OFFLOAD - .ndo_flow_offload = fe_flow_offload, -#endif }; static void fe_reset_pending(struct fe_priv *priv) @@ -1632,6 +1598,12 @@ static int fe_probe(struct platform_device *pdev) goto err_free_dev; } + priv = netdev_priv(netdev); + spin_lock_init(&priv->page_lock); + priv->rst_fe = devm_reset_control_get(&pdev->dev, "fe"); + if (IS_ERR(priv->rst_fe)) + priv->rst_fe = NULL; + if (soc->init_data) soc->init_data(soc, netdev); netdev->vlan_features = netdev->hw_features & @@ -1646,8 +1618,6 @@ static int fe_probe(struct platform_device *pdev) if (fe_reg_table[FE_REG_FE_DMA_VID_BASE]) netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; - priv = netdev_priv(netdev); - spin_lock_init(&priv->page_lock); if (fe_reg_table[FE_REG_FE_COUNTER_BASE]) { priv->hw_stats = kzalloc(sizeof(*priv->hw_stats), GFP_KERNEL); if (!priv->hw_stats) { @@ -1735,7 +1705,7 @@ static struct platform_driver fe_driver = { .probe = fe_probe, .remove = fe_remove, .driver = { - .name = "ralink_soc_eth", + .name = "mtk_soc_eth", .owner = THIS_MODULE, .of_match_table = of_fe_match, }, diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.h b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.h index eb5285fc4..968db366c 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.h +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.h @@ -49,7 +49,7 @@ enum fe_work_flag { FE_FLAG_MAX }; -#define MTK_FE_DRV_VERSION "0.1.2" +#define MTK_FE_DRV_VERSION "0.2" /* power of 2 to let NEXT_TX_DESP_IDX work */ #define NUM_DMA_DESC BIT(10) @@ -157,6 +157,10 @@ enum fe_work_flag { #define MT7620A_FE_GDMA1_MAC_ADRL (MT7620A_GDMA_OFFSET + 0x0C) #define MT7620A_FE_GDMA1_MAC_ADRH (MT7620A_GDMA_OFFSET + 0x10) +#define MT7620A_RESET_FE BIT(21) +#define MT7620A_RESET_ESW BIT(23) +#define MT7620A_RESET_EPHY BIT(24) + #define RT5350_TX_BASE_PTR0 (RT5350_PDMA_OFFSET + 0x00) #define RT5350_TX_MAX_CNT0 (RT5350_PDMA_OFFSET + 0x04) #define RT5350_TX_CTX_IDX0 (RT5350_PDMA_OFFSET + 0x08) @@ -378,7 +382,7 @@ struct fe_soc_data { const u16 *reg_table; void (*init_data)(struct fe_soc_data *data, struct net_device *netdev); - void (*reset_fe)(void); + void (*reset_fe)(struct fe_priv *priv); void (*set_mac)(struct fe_priv *priv, unsigned char *mac); int (*fwd_config)(struct fe_priv *priv); void (*tx_dma)(struct fe_tx_dma *txd); @@ -494,6 +498,7 @@ struct fe_priv { DECLARE_BITMAP(pending_flags, FE_FLAG_MAX); struct reset_control *rst_ppe; + struct reset_control *rst_fe; struct mtk_foe_entry *foe_table; dma_addr_t foe_table_phys; struct flow_offload __rcu **foe_flow_table; @@ -513,20 +518,12 @@ void fe_reg_w32(u32 val, enum fe_reg reg); u32 fe_reg_r32(enum fe_reg reg); void fe_reset(u32 reset_bits); +void fe_reset_fe(struct fe_priv *priv); static inline void *priv_netdev(struct fe_priv *priv) { return (char *)priv - ALIGN(sizeof(struct net_device), NETDEV_ALIGN); } -int ra_ppe_probe(struct fe_priv *eth); -void ra_ppe_remove(struct fe_priv *eth); -int mtk_flow_offload(struct fe_priv *eth, - enum flow_offload_type type, - struct flow_offload *flow, - struct flow_offload_hw_path *src, - struct flow_offload_hw_path *dest); -int ra_offload_check_rx(struct fe_priv *eth, struct sk_buff *skb, u32 rxd4); - #endif /* FE_ETH_H */ diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_offload.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_offload.c deleted file mode 100644 index 27b7977a3..000000000 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_offload.c +++ /dev/null @@ -1,540 +0,0 @@ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Copyright (C) 2018 John Crispin - */ - -#include "mtk_offload.h" - -#define INVALID 0 -#define UNBIND 1 -#define BIND 2 -#define FIN 3 - -#define IPV4_HNAPT 0 -#define IPV4_HNAT 1 - -static u32 -mtk_flow_hash_v4(struct flow_offload_tuple *tuple) -{ - u32 ports = ntohs(tuple->src_port) << 16 | ntohs(tuple->dst_port); - u32 src = ntohl(tuple->dst_v4.s_addr); - u32 dst = ntohl(tuple->src_v4.s_addr); - u32 hash = (ports & src) | ((~ports) & dst); - u32 hash_23_0 = hash & 0xffffff; - u32 hash_31_24 = hash & 0xff000000; - - hash = ports ^ src ^ dst ^ ((hash_23_0 << 8) | (hash_31_24 >> 24)); - hash = ((hash & 0xffff0000) >> 16 ) ^ (hash & 0xfffff); - hash &= 0x7ff; - hash *= 2;; - - return hash; -} - -static int -mtk_foe_prepare_v4(struct mtk_foe_entry *entry, - struct flow_offload_tuple *tuple, - struct flow_offload_tuple *dest_tuple, - struct flow_offload_hw_path *src, - struct flow_offload_hw_path *dest) -{ - int is_mcast = !!is_multicast_ether_addr(dest->eth_dest); - - if (tuple->l4proto == IPPROTO_UDP) - entry->ipv4_hnapt.bfib1.udp = 1; - - entry->ipv4_hnapt.etype = htons(ETH_P_IP); - entry->ipv4_hnapt.bfib1.pkt_type = IPV4_HNAPT; - entry->ipv4_hnapt.iblk2.fqos = 0; - entry->ipv4_hnapt.bfib1.ttl = 1; - entry->ipv4_hnapt.bfib1.cah = 1; - entry->ipv4_hnapt.bfib1.ka = 1; - entry->ipv4_hnapt.iblk2.mcast = is_mcast; - entry->ipv4_hnapt.iblk2.dscp = 0; - entry->ipv4_hnapt.iblk2.port_mg = 0x3f; - entry->ipv4_hnapt.iblk2.port_ag = 0x1f; -#ifdef CONFIG_NET_RALINK_HW_QOS - entry->ipv4_hnapt.iblk2.qid = 1; - entry->ipv4_hnapt.iblk2.fqos = 1; -#endif -#ifdef CONFIG_RALINK - entry->ipv4_hnapt.iblk2.dp = 1; - if ((dest->flags & FLOW_OFFLOAD_PATH_VLAN) && (dest->vlan_id > 1)) - entry->ipv4_hnapt.iblk2.qid += 8; -#else - entry->ipv4_hnapt.iblk2.dp = (dest->dev->name[3] - '0') + 1; -#endif - - entry->ipv4_hnapt.sip = ntohl(tuple->src_v4.s_addr); - entry->ipv4_hnapt.dip = ntohl(tuple->dst_v4.s_addr); - entry->ipv4_hnapt.sport = ntohs(tuple->src_port); - entry->ipv4_hnapt.dport = ntohs(tuple->dst_port); - - entry->ipv4_hnapt.new_sip = ntohl(dest_tuple->dst_v4.s_addr); - entry->ipv4_hnapt.new_dip = ntohl(dest_tuple->src_v4.s_addr); - entry->ipv4_hnapt.new_sport = ntohs(dest_tuple->dst_port); - entry->ipv4_hnapt.new_dport = ntohs(dest_tuple->src_port); - - entry->bfib1.state = BIND; - - if (dest->flags & FLOW_OFFLOAD_PATH_PPPOE) { - entry->bfib1.psn = 1; - entry->ipv4_hnapt.etype = htons(ETH_P_PPP_SES); - entry->ipv4_hnapt.pppoe_id = dest->pppoe_sid; - } - - if (dest->flags & FLOW_OFFLOAD_PATH_VLAN) { - entry->ipv4_hnapt.vlan1 = dest->vlan_id; - entry->bfib1.vlan_layer = 1; - - switch (dest->vlan_proto) { - case htons(ETH_P_8021Q): - entry->ipv4_hnapt.bfib1.vpm = 1; - break; - case htons(ETH_P_8021AD): - entry->ipv4_hnapt.bfib1.vpm = 2; - break; - default: - return -EINVAL; - } - } - - return 0; -} - -static void -mtk_foe_set_mac(struct mtk_foe_entry *entry, u8 *smac, u8 *dmac) -{ - entry->ipv4_hnapt.dmac_hi = swab32(*((u32*) dmac)); - entry->ipv4_hnapt.dmac_lo = swab16(*((u16*) &dmac[4])); - entry->ipv4_hnapt.smac_hi = swab32(*((u32*) smac)); - entry->ipv4_hnapt.smac_lo = swab16(*((u16*) &smac[4])); -} - -static int -mtk_check_entry_available(struct mtk_eth *eth, u32 hash) -{ - struct mtk_foe_entry entry = ((struct mtk_foe_entry *)eth->foe_table)[hash]; - - return (entry.bfib1.state == BIND)? 0:1; -} - -static void -mtk_foe_write(struct mtk_eth *eth, u32 hash, - struct mtk_foe_entry *entry) -{ - struct mtk_foe_entry *table = (struct mtk_foe_entry *)eth->foe_table; - - memcpy(&table[hash], entry, sizeof(*entry)); -} - -int mtk_flow_offload(struct mtk_eth *eth, - enum flow_offload_type type, - struct flow_offload *flow, - struct flow_offload_hw_path *src, - struct flow_offload_hw_path *dest) -{ - struct flow_offload_tuple *otuple = &flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple; - struct flow_offload_tuple *rtuple = &flow->tuplehash[FLOW_OFFLOAD_DIR_REPLY].tuple; - u32 time_stamp = mtk_r32(eth, 0x0010) & (0x7fff); - u32 ohash, rhash; - struct mtk_foe_entry orig = { - .bfib1.time_stamp = time_stamp, - .bfib1.psn = 0, - }; - struct mtk_foe_entry reply = { - .bfib1.time_stamp = time_stamp, - .bfib1.psn = 0, - }; - - if (otuple->l4proto != IPPROTO_TCP && otuple->l4proto != IPPROTO_UDP) - return -EINVAL; - - if (type == FLOW_OFFLOAD_DEL) { - flow = NULL; - synchronize_rcu(); - return 0; - } - - switch (otuple->l3proto) { - case AF_INET: - if (mtk_foe_prepare_v4(&orig, otuple, rtuple, src, dest) || - mtk_foe_prepare_v4(&reply, rtuple, otuple, dest, src)) - return -EINVAL; - - ohash = mtk_flow_hash_v4(otuple); - rhash = mtk_flow_hash_v4(rtuple); - break; - - case AF_INET6: - return -EINVAL; - - default: - return -EINVAL; - } - - /* Two-way hash: when hash collision occurs, the hash value will be shifted to the next position. */ - if (!mtk_check_entry_available(eth, ohash)){ - if (!mtk_check_entry_available(eth, ohash + 1)) - return -EINVAL; - ohash += 1; - } - if (!mtk_check_entry_available(eth, rhash)){ - if (!mtk_check_entry_available(eth, rhash + 1)) - return -EINVAL; - rhash += 1; - } - - mtk_foe_set_mac(&orig, dest->eth_src, dest->eth_dest); - mtk_foe_set_mac(&reply, src->eth_src, src->eth_dest); - mtk_foe_write(eth, ohash, &orig); - mtk_foe_write(eth, rhash, &reply); - rcu_assign_pointer(eth->foe_flow_table[ohash], flow); - rcu_assign_pointer(eth->foe_flow_table[rhash], flow); - - return 0; -} - -#ifdef CONFIG_NET_RALINK_HW_QOS - -#define QDMA_TX_SCH_TX 0x1a14 - -static void mtk_ppe_scheduler(struct mtk_eth *eth, int id, u32 rate) -{ - int exp = 0, shift = 0; - u32 reg = mtk_r32(eth, QDMA_TX_SCH_TX); - u32 val = 0; - - if (rate) - val = BIT(11); - - while (rate > 127) { - rate /= 10; - exp++; - } - - val |= (rate & 0x7f) << 4; - val |= exp & 0xf; - if (id) - shift = 16; - reg &= ~(0xffff << shift); - reg |= val << shift; - mtk_w32(eth, val, QDMA_TX_SCH_TX); -} - -#define QTX_CFG(x) (0x1800 + (x * 0x10)) -#define QTX_SCH(x) (0x1804 + (x * 0x10)) - -static void mtk_ppe_queue(struct mtk_eth *eth, int id, int sched, int weight, int resv, u32 min_rate, u32 max_rate) -{ - int max_exp = 0, min_exp = 0; - u32 reg; - - if (id >= 16) - return; - - reg = mtk_r32(eth, QTX_SCH(id)); - reg &= 0x70000000; - - if (sched) - reg |= BIT(31); - - if (min_rate) - reg |= BIT(27); - - if (max_rate) - reg |= BIT(11); - - while (max_rate > 127) { - max_rate /= 10; - max_exp++; - } - - while (min_rate > 127) { - min_rate /= 10; - min_exp++; - } - - reg |= (min_rate & 0x7f) << 20; - reg |= (min_exp & 0xf) << 16; - reg |= (weight & 0xf) << 12; - reg |= (max_rate & 0x7f) << 4; - reg |= max_exp & 0xf; - mtk_w32(eth, reg, QTX_SCH(id)); - - resv &= 0xff; - reg = mtk_r32(eth, QTX_CFG(id)); - reg &= 0xffff0000; - reg |= (resv << 8) | resv; - mtk_w32(eth, reg, QTX_CFG(id)); -} -#endif - -static int mtk_init_foe_table(struct mtk_eth *eth) -{ - if (eth->foe_table) - return 0; - - eth->foe_flow_table = devm_kcalloc(eth->dev, MTK_PPE_ENTRY_CNT, - sizeof(*eth->foe_flow_table), - GFP_KERNEL); - if (!eth->foe_flow_table) - return -EINVAL; - - /* map the FOE table */ - eth->foe_table = dmam_alloc_coherent(eth->dev, MTK_PPE_TBL_SZ, - ð->foe_table_phys, GFP_KERNEL); - if (!eth->foe_table) { - dev_err(eth->dev, "failed to allocate foe table\n"); - kfree(eth->foe_flow_table); - return -ENOMEM; - } - - - return 0; -} - -static int ra_ppe_start(struct mtk_eth *eth) -{ - int ret; - - ret = mtk_init_foe_table(eth); - if (ret) - return ret; - - /* tell the PPE about the tables base address */ - mtk_w32(eth, eth->foe_table_phys, MTK_REG_PPE_TB_BASE); - - /* flush the table */ - memset(eth->foe_table, 0, MTK_PPE_TBL_SZ); - - /* setup hashing */ - mtk_m32(eth, - MTK_PPE_TB_CFG_HASH_MODE_MASK | MTK_PPE_TB_CFG_TBL_SZ_MASK, - MTK_PPE_TB_CFG_HASH_MODE1 | MTK_PPE_TB_CFG_TBL_SZ_4K, - MTK_REG_PPE_TB_CFG); - - /* set the default hashing seed */ - mtk_w32(eth, MTK_PPE_HASH_SEED, MTK_REG_PPE_HASH_SEED); - - /* each foe entry is 64bytes and is setup by cpu forwarding*/ - mtk_m32(eth, MTK_PPE_CAH_CTRL_X_MODE | MTK_PPE_TB_CFG_ENTRY_SZ_MASK | - MTK_PPE_TB_CFG_SMA_MASK, - MTK_PPE_TB_CFG_ENTRY_SZ_64B | MTK_PPE_TB_CFG_SMA_FWD_CPU, - MTK_REG_PPE_TB_CFG); - - /* set ip proto */ - mtk_w32(eth, 0xFFFFFFFF, MTK_REG_PPE_IP_PROT_CHK); - - /* setup caching */ - mtk_m32(eth, 0, MTK_PPE_CAH_CTRL_X_MODE, MTK_REG_PPE_CAH_CTRL); - mtk_m32(eth, MTK_PPE_CAH_CTRL_X_MODE, MTK_PPE_CAH_CTRL_EN, - MTK_REG_PPE_CAH_CTRL); - - /* enable FOE */ - mtk_m32(eth, 0, MTK_PPE_FLOW_CFG_IPV4_NAT_FRAG_EN | - MTK_PPE_FLOW_CFG_IPV4_NAPT_EN | MTK_PPE_FLOW_CFG_IPV4_NAT_EN | - MTK_PPE_FLOW_CFG_IPV4_GREK_EN, - MTK_REG_PPE_FLOW_CFG); - - /* setup flow entry un/bind aging */ - mtk_m32(eth, 0, - MTK_PPE_TB_CFG_UNBD_AGE | MTK_PPE_TB_CFG_NTU_AGE | - MTK_PPE_TB_CFG_FIN_AGE | MTK_PPE_TB_CFG_UDP_AGE | - MTK_PPE_TB_CFG_TCP_AGE, - MTK_REG_PPE_TB_CFG); - - mtk_m32(eth, MTK_PPE_UNB_AGE_MNP_MASK | MTK_PPE_UNB_AGE_DLTA_MASK, - MTK_PPE_UNB_AGE_MNP | MTK_PPE_UNB_AGE_DLTA, - MTK_REG_PPE_UNB_AGE); - mtk_m32(eth, MTK_PPE_BND_AGE0_NTU_DLTA_MASK | - MTK_PPE_BND_AGE0_UDP_DLTA_MASK, - MTK_PPE_BND_AGE0_NTU_DLTA | MTK_PPE_BND_AGE0_UDP_DLTA, - MTK_REG_PPE_BND_AGE0); - mtk_m32(eth, MTK_PPE_BND_AGE1_FIN_DLTA_MASK | - MTK_PPE_BND_AGE1_TCP_DLTA_MASK, - MTK_PPE_BND_AGE1_FIN_DLTA | MTK_PPE_BND_AGE1_TCP_DLTA, - MTK_REG_PPE_BND_AGE1); - - /* setup flow entry keep alive */ - mtk_m32(eth, MTK_PPE_TB_CFG_KA_MASK, MTK_PPE_TB_CFG_KA, - MTK_REG_PPE_TB_CFG); - mtk_w32(eth, MTK_PPE_KA_UDP | MTK_PPE_KA_TCP | MTK_PPE_KA_T, MTK_REG_PPE_KA); - - /* setup flow entry rate limit */ - mtk_w32(eth, (0x3fff << 16) | 0x3fff, MTK_REG_PPE_BIND_LMT_0); - mtk_w32(eth, MTK_PPE_NTU_KA | 0x3fff, MTK_REG_PPE_BIND_LMT_1); - mtk_m32(eth, MTK_PPE_BNDR_RATE_MASK, 1, MTK_REG_PPE_BNDR); - - /* enable the PPE */ - mtk_m32(eth, 0, MTK_PPE_GLO_CFG_EN, MTK_REG_PPE_GLO_CFG); - -#ifdef CONFIG_RALINK - /* set the default forwarding port to QDMA */ - mtk_w32(eth, 0x0, MTK_REG_PPE_DFT_CPORT); -#else - /* set the default forwarding port to QDMA */ - mtk_w32(eth, 0x55555555, MTK_REG_PPE_DFT_CPORT); -#endif - - /* allow packets with TTL=0 */ - mtk_m32(eth, MTK_PPE_GLO_CFG_TTL0_DROP, 0, MTK_REG_PPE_GLO_CFG); - - /* send all traffic from gmac to the ppe */ - mtk_m32(eth, 0xffff, 0x4444, MTK_GDMA_FWD_CFG(0)); - mtk_m32(eth, 0xffff, 0x4444, MTK_GDMA_FWD_CFG(1)); - - dev_info(eth->dev, "PPE started\n"); - -#ifdef CONFIG_NET_RALINK_HW_QOS - mtk_ppe_scheduler(eth, 0, 500000); - mtk_ppe_scheduler(eth, 1, 500000); - mtk_ppe_queue(eth, 0, 0, 7, 32, 250000, 0); - mtk_ppe_queue(eth, 1, 0, 7, 32, 250000, 0); - mtk_ppe_queue(eth, 8, 1, 7, 32, 250000, 0); - mtk_ppe_queue(eth, 9, 1, 7, 32, 250000, 0); -#endif - - return 0; -} - -static int mtk_ppe_busy_wait(struct mtk_eth *eth) -{ - unsigned long t_start = jiffies; - u32 r = 0; - - while (1) { - r = mtk_r32(eth, MTK_REG_PPE_GLO_CFG); - if (!(r & MTK_PPE_GLO_CFG_BUSY)) - return 0; - if (time_after(jiffies, t_start + HZ)) - break; - usleep_range(10, 20); - } - - dev_err(eth->dev, "ppe: table busy timeout - resetting\n"); - reset_control_reset(eth->rst_ppe); - - return -ETIMEDOUT; -} - -static int ra_ppe_stop(struct mtk_eth *eth) -{ - u32 r1 = 0, r2 = 0; - int i; - - /* discard all traffic while we disable the PPE */ - mtk_m32(eth, 0xffff, 0x7777, MTK_GDMA_FWD_CFG(0)); - mtk_m32(eth, 0xffff, 0x7777, MTK_GDMA_FWD_CFG(1)); - - if (mtk_ppe_busy_wait(eth)) - return -ETIMEDOUT; - - /* invalidate all flow table entries */ - for (i = 0; i < MTK_PPE_ENTRY_CNT; i++) - eth->foe_table[i].bfib1.state = FOE_STATE_INVALID; - - /* disable caching */ - mtk_m32(eth, 0, MTK_PPE_CAH_CTRL_X_MODE, MTK_REG_PPE_CAH_CTRL); - mtk_m32(eth, MTK_PPE_CAH_CTRL_X_MODE | MTK_PPE_CAH_CTRL_EN, 0, - MTK_REG_PPE_CAH_CTRL); - - /* flush cache has to be ahead of hnat diable --*/ - mtk_m32(eth, MTK_PPE_GLO_CFG_EN, 0, MTK_REG_PPE_GLO_CFG); - - /* disable FOE */ - mtk_m32(eth, - MTK_PPE_FLOW_CFG_IPV4_NAT_FRAG_EN | - MTK_PPE_FLOW_CFG_IPV4_NAPT_EN | MTK_PPE_FLOW_CFG_IPV4_NAT_EN | - MTK_PPE_FLOW_CFG_FUC_FOE | MTK_PPE_FLOW_CFG_FMC_FOE, - 0, MTK_REG_PPE_FLOW_CFG); - - /* disable FOE aging */ - mtk_m32(eth, 0, - MTK_PPE_TB_CFG_FIN_AGE | MTK_PPE_TB_CFG_UDP_AGE | - MTK_PPE_TB_CFG_TCP_AGE | MTK_PPE_TB_CFG_UNBD_AGE | - MTK_PPE_TB_CFG_NTU_AGE, MTK_REG_PPE_TB_CFG); - - r1 = mtk_r32(eth, 0x100); - r2 = mtk_r32(eth, 0x10c); - - dev_info(eth->dev, "0x100 = 0x%x, 0x10c = 0x%x\n", r1, r2); - - if (((r1 & 0xff00) >> 0x8) >= (r1 & 0xff) || - ((r1 & 0xff00) >> 0x8) >= (r2 & 0xff)) { - dev_info(eth->dev, "reset pse\n"); - mtk_w32(eth, 0x1, 0x4); - } - - /* set the foe entry base address to 0 */ - mtk_w32(eth, 0, MTK_REG_PPE_TB_BASE); - - if (mtk_ppe_busy_wait(eth)) - return -ETIMEDOUT; - - /* send all traffic back to the DMA engine */ -#ifdef CONFIG_RALINK - mtk_m32(eth, 0xffff, 0x0, MTK_GDMA_FWD_CFG(0)); - mtk_m32(eth, 0xffff, 0x0, MTK_GDMA_FWD_CFG(1)); -#else - mtk_m32(eth, 0xffff, 0x5555, MTK_GDMA_FWD_CFG(0)); - mtk_m32(eth, 0xffff, 0x5555, MTK_GDMA_FWD_CFG(1)); -#endif - return 0; -} - -static void mtk_offload_keepalive(struct fe_priv *eth, unsigned int hash) -{ - struct flow_offload *flow; - - rcu_read_lock(); - flow = rcu_dereference(eth->foe_flow_table[hash]); - if (flow) - flow->timeout = jiffies + 30 * HZ; - rcu_read_unlock(); -} - -int ra_offload_check_rx(struct fe_priv *eth, struct sk_buff *skb, u32 rxd4) -{ - unsigned int hash; - - switch (FIELD_GET(MTK_RXD4_CPU_REASON, rxd4)) { - case MTK_CPU_REASON_KEEPALIVE_UC_OLD_HDR: - case MTK_CPU_REASON_KEEPALIVE_MC_NEW_HDR: - case MTK_CPU_REASON_KEEPALIVE_DUP_OLD_HDR: - hash = FIELD_GET(MTK_RXD4_FOE_ENTRY, rxd4); - mtk_offload_keepalive(eth, hash); - return -1; - case MTK_CPU_REASON_PACKET_SAMPLING: - return -1; - default: - return 0; - } -} - -int ra_ppe_probe(struct mtk_eth *eth) -{ - int err; - - err = ra_ppe_start(eth); - if (err) - return err; - - err = ra_ppe_debugfs_init(eth); - if (err) - return err; - - return 0; -} - -void ra_ppe_remove(struct mtk_eth *eth) -{ - ra_ppe_stop(eth); -} diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_offload.h b/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_offload.h deleted file mode 100644 index 47f82b98a..000000000 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_offload.h +++ /dev/null @@ -1,260 +0,0 @@ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Copyright (C) 2014-2016 Sean Wang - * Copyright (C) 2016-2017 John Crispin - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mtk_eth_soc.h" - -#ifdef CONFIG_RALINK -/* ramips compat */ -#define mtk_eth fe_priv -#define MTK_GDMA_FWD_CFG(x) (0x500 + (x * 0x1000)) -#define mtk_m32 fe_m32 - -static inline u32 -mtk_r32(struct mtk_eth *eth, u32 reg) -{ - return fe_r32(reg); -} - -static inline void -mtk_w32(struct mtk_eth *eth, u32 val, u32 reg) -{ - fe_w32(val, reg); -} -#endif - -#define MTK_REG_PPE_GLO_CFG 0xe00 -#define MTK_PPE_GLO_CFG_BUSY BIT(31) -#define MTK_PPE_GLO_CFG_TTL0_DROP BIT(4) -#define MTK_PPE_GLO_CFG_EN BIT(0) - -#define MTK_REG_PPE_FLOW_CFG 0xe04 -#define MTK_PPE_FLOW_CFG_IPV4_GREK_EN BIT(19) -#define MTK_PPE_FLOW_CFG_IPV4_NAT_FRAG_EN BIT(17) -#define MTK_PPE_FLOW_CFG_IPV4_NAPT_EN BIT(13) -#define MTK_PPE_FLOW_CFG_IPV4_NAT_EN BIT(12) -#define MTK_PPE_FLOW_CFG_FUC_FOE BIT(2) -#define MTK_PPE_FLOW_CFG_FMC_FOE BIT(1) - -#define MTK_REG_PPE_IP_PROT_CHK 0xe08 - -#define MTK_REG_PPE_TB_BASE 0xe20 - -#define MTK_REG_PPE_BNDR 0xe28 -#define MTK_PPE_BNDR_RATE_MASK 0xffff - -#define MTK_REG_PPE_BIND_LMT_0 0xe2C - -#define MTK_REG_PPE_BIND_LMT_1 0xe30 -#define MTK_PPE_NTU_KA BIT(16) - -#define MTK_REG_PPE_KA 0xe34 -#define MTK_PPE_KA_T BIT(0) -#define MTK_PPE_KA_TCP BIT(16) -#define MTK_PPE_KA_UDP BIT(24) - -#define MTK_REG_PPE_UNB_AGE 0xe38 -#define MTK_PPE_UNB_AGE_MNP_MASK (0xffff << 16) -#define MTK_PPE_UNB_AGE_MNP (1000 << 16) -#define MTK_PPE_UNB_AGE_DLTA_MASK 0xff -#define MTK_PPE_UNB_AGE_DLTA 3 - -#define MTK_REG_PPE_BND_AGE0 0xe3c -#define MTK_PPE_BND_AGE0_NTU_DLTA_MASK (0xffff << 16) -#define MTK_PPE_BND_AGE0_NTU_DLTA (5 << 16) -#define MTK_PPE_BND_AGE0_UDP_DLTA_MASK 0xffff -#define MTK_PPE_BND_AGE0_UDP_DLTA 5 - -#define MTK_REG_PPE_BND_AGE1 0xe40 -#define MTK_PPE_BND_AGE1_FIN_DLTA_MASK (0xffff << 16) -#define MTK_PPE_BND_AGE1_FIN_DLTA (5 << 16) -#define MTK_PPE_BND_AGE1_TCP_DLTA_MASK 0xffff -#define MTK_PPE_BND_AGE1_TCP_DLTA 5 - -#define MTK_REG_PPE_DFT_CPORT 0xe48 - -#define MTK_REG_PPE_TB_CFG 0xe1c -#define MTK_PPE_TB_CFG_X_MODE_MASK (3 << 18) -#define MTK_PPE_TB_CFG_HASH_MODE1 BIT(14) -#define MTK_PPE_TB_CFG_HASH_MODE_MASK (0x3 << 14) -#define MTK_PPE_TB_CFG_KA (3 << 12) -#define MTK_PPE_TB_CFG_KA_MASK (0x3 << 12) -#define MTK_PPE_TB_CFG_FIN_AGE BIT(11) -#define MTK_PPE_TB_CFG_UDP_AGE BIT(10) -#define MTK_PPE_TB_CFG_TCP_AGE BIT(9) -#define MTK_PPE_TB_CFG_UNBD_AGE BIT(8) -#define MTK_PPE_TB_CFG_NTU_AGE BIT(7) -#define MTK_PPE_TB_CFG_SMA_FWD_CPU (0x3 << 4) -#define MTK_PPE_TB_CFG_SMA_MASK (0x3 << 4) -#define MTK_PPE_TB_CFG_ENTRY_SZ_64B 0 -#define MTK_PPE_TB_CFG_ENTRY_SZ_MASK BIT(3) -#define MTK_PPE_TB_CFG_TBL_SZ_4K 2 -#define MTK_PPE_TB_CFG_TBL_SZ_MASK 0x7 - -#define MTK_REG_PPE_HASH_SEED 0xe44 -#define MTK_PPE_HASH_SEED 0x12345678 - - -#define MTK_REG_PPE_CAH_CTRL 0xf20 -#define MTK_PPE_CAH_CTRL_X_MODE BIT(9) -#define MTK_PPE_CAH_CTRL_EN BIT(0) - -struct mtk_foe_unbind_info_blk { - u32 time_stamp:8; - u32 pcnt:16; /* packet count */ - u32 preb:1; - u32 pkt_type:3; - u32 state:2; - u32 udp:1; - u32 sta:1; /* static entry */ -} __attribute__ ((packed)); - -struct mtk_foe_bind_info_blk { - u32 time_stamp:15; - u32 ka:1; /* keep alive */ - u32 vlan_layer:3; - u32 psn:1; /* egress packet has PPPoE session */ -#ifdef CONFIG_RALINK - u32 vpm:2; /* 0:ethertype remark, 1:0x8100(CR default) */ -#else - u32 vpm:1; /* 0:ethertype remark, 1:0x8100(CR default) */ - u32 ps:1; /* packet sampling */ -#endif - u32 cah:1; /* cacheable flag */ - u32 rmt:1; /* remove tunnel ip header (6rd/dslite only) */ - u32 ttl:1; - u32 pkt_type:3; - u32 state:2; - u32 udp:1; - u32 sta:1; /* static entry */ -} __attribute__ ((packed)); - -struct mtk_foe_info_blk2 { - u32 qid:4; /* QID in Qos Port */ - u32 fqos:1; /* force to PSE QoS port */ - u32 dp:3; /* force to PSE port x - 0:PSE,1:GSW, 2:GMAC,4:PPE,5:QDMA,7=DROP */ - u32 mcast:1; /* multicast this packet to CPU */ - u32 pcpl:1; /* OSBN */ - u32 mlen:1; /* 0:post 1:pre packet length in meter */ - u32 alen:1; /* 0:post 1:pre packet length in accounting */ - u32 port_mg:6; /* port meter group */ - u32 port_ag:6; /* port account group */ - u32 dscp:8; /* DSCP value */ -} __attribute__ ((packed)); - -struct mtk_foe_ipv4_hnapt { - union { - struct mtk_foe_bind_info_blk bfib1; - struct mtk_foe_unbind_info_blk udib1; - u32 info_blk1; - }; - u32 sip; - u32 dip; - u16 dport; - u16 sport; - union { - struct mtk_foe_info_blk2 iblk2; - u32 info_blk2; - }; - u32 new_sip; - u32 new_dip; - u16 new_dport; - u16 new_sport; - u32 resv1; - u32 resv2; - u32 resv3:26; - u32 act_dp:6; /* UDF */ - u16 vlan1; - u16 etype; - u32 dmac_hi; - u16 vlan2; - u16 dmac_lo; - u32 smac_hi; - u16 pppoe_id; - u16 smac_lo; -} __attribute__ ((packed)); - -struct mtk_foe_entry { - union { - struct mtk_foe_unbind_info_blk udib1; - struct mtk_foe_bind_info_blk bfib1; - struct mtk_foe_ipv4_hnapt ipv4_hnapt; - }; -}; - -enum mtk_foe_entry_state { - FOE_STATE_INVALID = 0, - FOE_STATE_UNBIND = 1, - FOE_STATE_BIND = 2, - FOE_STATE_FIN = 3 -}; - - -#define MTK_RXD4_FOE_ENTRY GENMASK(13, 0) -#define MTK_RXD4_CPU_REASON GENMASK(18, 14) -#define MTK_RXD4_SRC_PORT GENMASK(21, 19) -#define MTK_RXD4_ALG GENMASK(31, 22) - -enum mtk_foe_cpu_reason { - MTK_CPU_REASON_TTL_EXCEEDED = 0x02, - MTK_CPU_REASON_OPTION_HEADER = 0x03, - MTK_CPU_REASON_NO_FLOW = 0x07, - MTK_CPU_REASON_IPV4_FRAG = 0x08, - MTK_CPU_REASON_IPV4_DSLITE_FRAG = 0x09, - MTK_CPU_REASON_IPV4_DSLITE_NO_TCP_UDP = 0x0a, - MTK_CPU_REASON_IPV6_6RD_NO_TCP_UDP = 0x0b, - MTK_CPU_REASON_TCP_FIN_SYN_RST = 0x0c, - MTK_CPU_REASON_UN_HIT = 0x0d, - MTK_CPU_REASON_HIT_UNBIND = 0x0e, - MTK_CPU_REASON_HIT_UNBIND_RATE_REACHED = 0x0f, - MTK_CPU_REASON_HIT_BIND_TCP_FIN = 0x10, - MTK_CPU_REASON_HIT_TTL_1 = 0x11, - MTK_CPU_REASON_HIT_BIND_VLAN_VIOLATION = 0x12, - MTK_CPU_REASON_KEEPALIVE_UC_OLD_HDR = 0x13, - MTK_CPU_REASON_KEEPALIVE_MC_NEW_HDR = 0x14, - MTK_CPU_REASON_KEEPALIVE_DUP_OLD_HDR = 0x15, - MTK_CPU_REASON_HIT_BIND_FORCE_CPU = 0x16, - MTK_CPU_REASON_TUNNEL_OPTION_HEADER = 0x17, - MTK_CPU_REASON_MULTICAST_TO_CPU = 0x18, - MTK_CPU_REASON_MULTICAST_TO_GMAC1_CPU = 0x19, - MTK_CPU_REASON_HIT_PRE_BIND = 0x1a, - MTK_CPU_REASON_PACKET_SAMPLING = 0x1b, - MTK_CPU_REASON_EXCEED_MTU = 0x1c, - MTK_CPU_REASON_PPE_BYPASS = 0x1e, - MTK_CPU_REASON_INVALID = 0x1f, -}; - - -/* our table size is 4K */ -#define MTK_PPE_ENTRY_CNT 0x1000 -#define MTK_PPE_TBL_SZ \ - (MTK_PPE_ENTRY_CNT * sizeof(struct mtk_foe_entry)) - -int ra_ppe_debugfs_init(struct mtk_eth *eth); - - diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c index 5fdec3170..42685eebc 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7620.c @@ -27,16 +27,9 @@ #define MT7620A_CDMA_CSG_CFG 0x400 #define MT7620_DMA_VID (MT7620A_CDMA_CSG_CFG | 0x30) -#define MT7621_CDMP_IG_CTRL (MT7620A_CDMA_CSG_CFG + 0x00) -#define MT7621_CDMP_EG_CTRL (MT7620A_CDMA_CSG_CFG + 0x04) -#define MT7620A_RESET_FE BIT(21) -#define MT7621_RESET_FE BIT(6) -#define MT7620A_RESET_ESW BIT(23) #define MT7620_L4_VALID BIT(23) -#define MT7621_L4_VALID BIT(24) #define MT7620_TX_DMA_UDF BIT(15) -#define MT7621_TX_DMA_UDF BIT(19) #define TX_DMA_FP_BMAP ((0xff) << 19) #define CDMA_ICS_EN BIT(2) @@ -53,11 +46,6 @@ #define MT7620_GDM1_TX_GBCNT (MT7620_REG_MIB_OFFSET + 0x300) #define MT7620_GDM2_TX_GBCNT (MT7620_GDM1_TX_GBCNT + 0x40) -#define MT7621_REG_MIB_OFFSET 0x2000 -#define MT7621_PPE_AC_BCNT0 (MT7621_REG_MIB_OFFSET + 0x00) -#define MT7621_GDM1_TX_GBCNT (MT7621_REG_MIB_OFFSET + 0x400) -#define MT7621_GDM2_TX_GBCNT (MT7621_GDM1_TX_GBCNT + 0x40) - #define GSW_REG_GDMA1_MAC_ADRL 0x508 #define GSW_REG_GDMA1_MAC_ADRH 0x50C @@ -68,8 +56,6 @@ * but after test it should be BIT(13). */ #define MT7620_FE_GDM1_AF BIT(13) -#define MT7621_FE_GDM1_AF BIT(28) -#define MT7621_FE_GDM2_AF BIT(29) static const u16 mt7620_reg_table[FE_REG_COUNT] = { [FE_REG_PDMA_GLO_CFG] = RT5350_PDMA_GLO_CFG, @@ -94,11 +80,26 @@ static const u16 mt7620_reg_table[FE_REG_COUNT] = { static int mt7620_gsw_config(struct fe_priv *priv) { struct mt7620_gsw *gsw = (struct mt7620_gsw *) priv->soc->swpriv; + u32 val; /* is the mt7530 internal or external */ if (priv->mii_bus && mdiobus_get_phy(priv->mii_bus, 0x1f)) { mt7530_probe(priv->dev, gsw->base, NULL, 0); mt7530_probe(priv->dev, NULL, priv->mii_bus, 1); + + /* magic values from original SDK */ + val = mt7530_mdio_r32(gsw, 0x7830); + val &= ~BIT(0); + val |= BIT(1); + mt7530_mdio_w32(gsw, 0x7830, val); + + val = mt7530_mdio_r32(gsw, 0x7a40); + val &= ~BIT(30); + mt7530_mdio_w32(gsw, 0x7a40, val); + + mt7530_mdio_w32(gsw, 0x7a78, 0x855); + + pr_info("mt7530: mdio central align\n"); } else { mt7530_probe(priv->dev, gsw->base, NULL, 1); } @@ -153,7 +154,7 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) u32 val, mask = 0; u32 val_delay = 0; u32 mask_delay = GSW_REG_GPCx_TXDELAY | GSW_REG_GPCx_RXDELAY; - int min = (gsw->port4 == PORT4_EPHY) ? (5) : (4); + int min = (gsw->port4_ephy) ? (5) : (4); if (!_id || (be32_to_cpu(*_id) < min) || (be32_to_cpu(*_id) > 5)) { if (_id) @@ -175,7 +176,6 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) (size != (4 * sizeof(*priv->phy->phy_fixed[id])))) { pr_err("%s: invalid fixed link property\n", np->name); priv->phy->phy_fixed[id] = NULL; - return; } #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) @@ -203,7 +203,7 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) break; case PHY_INTERFACE_MODE_RGMII_TXID: mask = 0; - val_delay &= ~GSW_REG_GPCx_TXDELAY; + val_delay |= GSW_REG_GPCx_TXDELAY; val_delay |= GSW_REG_GPCx_RXDELAY; break; case PHY_INTERFACE_MODE_MII: @@ -217,10 +217,6 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) return; } - priv->phy->phy_node[id] = of_parse_phandle(np, "phy-handle", 0); - if (!priv->phy->phy_node[id] && !priv->phy->phy_fixed[id]) - return; - val = rt_sysc_r32(SYSC_REG_CFG1); val &= ~(3 << shift); val |= mask << shift; @@ -261,8 +257,8 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) val = 2; break; default: - dev_err(priv->dev, "invalid link speed: %d\n", - priv->phy->speed[id]); + dev_err(priv->dev, "port %d - invalid link speed: %d\n", + id, priv->phy->speed[id]); priv->phy->phy_fixed[id] = 0; return; } @@ -276,7 +272,13 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) if (priv->phy->duplex[id]) val |= PMCR_DUPLEX; mtk_switch_w32(gsw, val, GSW_REG_PORT_PMCR(id)); - dev_info(priv->dev, "using fixed link parameters\n"); + dev_info(priv->dev, "port %d - using fixed link parameters\n", id); + return; + } + + priv->phy->phy_node[id] = of_parse_phandle(np, "phy-handle", 0); + if (!priv->phy->phy_node[id]) { + dev_err(priv->dev, "port %d - missing phy handle\n", id); return; } @@ -289,11 +291,10 @@ static void mt7620_port_init(struct fe_priv *priv, struct device_node *np) fe_connect_phy_node(priv, priv->phy->phy_node[id], id); gsw->autopoll |= BIT(be32_to_cpup(phy_addr)); mt7620_auto_poll(gsw,id); - return; } } -static void mt7620_fe_reset(void) +static void mt7620_fe_reset(struct fe_priv *priv) { fe_reset(MT7620A_RESET_FE | MT7620A_RESET_ESW); } diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7621.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7621.c deleted file mode 100644 index 6c5cdd969..000000000 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_mt7621.c +++ /dev/null @@ -1,186 +0,0 @@ -/* This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Copyright (C) 2009-2015 John Crispin - * Copyright (C) 2009-2015 Felix Fietkau - * Copyright (C) 2013-2015 Michael Lee - */ - -#include -#include -#include -#include - -#include - -#include "mtk_eth_soc.h" -#include "gsw_mt7620.h" -#include "mt7530.h" -#include "mdio.h" - -#define MT7620A_CDMA_CSG_CFG 0x400 -#define MT7621_CDMP_IG_CTRL (MT7620A_CDMA_CSG_CFG + 0x00) -#define MT7621_CDMP_EG_CTRL (MT7620A_CDMA_CSG_CFG + 0x04) -#define MT7621_RESET_FE BIT(6) -#define MT7621_L4_VALID BIT(24) - -#define MT7621_TX_DMA_UDF BIT(19) -#define MT7621_TX_DMA_FPORT BIT(25) - -#define CDMA_ICS_EN BIT(2) -#define CDMA_UCS_EN BIT(1) -#define CDMA_TCS_EN BIT(0) - -#define GDMA_ICS_EN BIT(22) -#define GDMA_TCS_EN BIT(21) -#define GDMA_UCS_EN BIT(20) - -/* frame engine counters */ -#define MT7621_REG_MIB_OFFSET 0x2000 -#define MT7621_PPE_AC_BCNT0 (MT7621_REG_MIB_OFFSET + 0x00) -#define MT7621_GDM1_TX_GBCNT (MT7621_REG_MIB_OFFSET + 0x400) -#define MT7621_GDM2_TX_GBCNT (MT7621_GDM1_TX_GBCNT + 0x40) - -#define GSW_REG_GDMA1_MAC_ADRL 0x508 -#define GSW_REG_GDMA1_MAC_ADRH 0x50C - -#define MT7621_FE_RST_GL (FE_FE_OFFSET + 0x04) -#define MT7620_FE_INT_STATUS2 (FE_FE_OFFSET + 0x08) - -/* FE_INT_STATUS reg on mt7620 define CNT_GDM1_AF at BIT(29) - * but after test it should be BIT(13). - */ -#define MT7620_FE_GDM1_AF BIT(13) -#define MT7621_FE_GDM1_AF BIT(28) -#define MT7621_FE_GDM2_AF BIT(29) - -static const u16 mt7621_reg_table[FE_REG_COUNT] = { - [FE_REG_PDMA_GLO_CFG] = RT5350_PDMA_GLO_CFG, - [FE_REG_PDMA_RST_CFG] = RT5350_PDMA_RST_CFG, - [FE_REG_DLY_INT_CFG] = RT5350_DLY_INT_CFG, - [FE_REG_TX_BASE_PTR0] = RT5350_TX_BASE_PTR0, - [FE_REG_TX_MAX_CNT0] = RT5350_TX_MAX_CNT0, - [FE_REG_TX_CTX_IDX0] = RT5350_TX_CTX_IDX0, - [FE_REG_TX_DTX_IDX0] = RT5350_TX_DTX_IDX0, - [FE_REG_RX_BASE_PTR0] = RT5350_RX_BASE_PTR0, - [FE_REG_RX_MAX_CNT0] = RT5350_RX_MAX_CNT0, - [FE_REG_RX_CALC_IDX0] = RT5350_RX_CALC_IDX0, - [FE_REG_RX_DRX_IDX0] = RT5350_RX_DRX_IDX0, - [FE_REG_FE_INT_ENABLE] = RT5350_FE_INT_ENABLE, - [FE_REG_FE_INT_STATUS] = RT5350_FE_INT_STATUS, - [FE_REG_FE_DMA_VID_BASE] = 0, - [FE_REG_FE_COUNTER_BASE] = MT7621_GDM1_TX_GBCNT, - [FE_REG_FE_RST_GL] = MT7621_FE_RST_GL, - [FE_REG_FE_INT_STATUS2] = MT7620_FE_INT_STATUS2, -}; - -static int mt7621_gsw_config(struct fe_priv *priv) -{ - if (priv->mii_bus && mdiobus_get_phy(priv->mii_bus, 0x1f)) - mt7530_probe(priv->dev, NULL, priv->mii_bus, 1); - - return 0; -} - -static void mt7621_fe_reset(void) -{ - fe_reset(MT7621_RESET_FE); -} - -static void mt7621_rxcsum_config(bool enable) -{ - if (enable) - fe_w32(fe_r32(MT7620A_GDMA1_FWD_CFG) | (GDMA_ICS_EN | - GDMA_TCS_EN | GDMA_UCS_EN), - MT7620A_GDMA1_FWD_CFG); - else - fe_w32(fe_r32(MT7620A_GDMA1_FWD_CFG) & ~(GDMA_ICS_EN | - GDMA_TCS_EN | GDMA_UCS_EN), - MT7620A_GDMA1_FWD_CFG); -} - -static void mt7621_rxvlan_config(bool enable) -{ - if (enable) - fe_w32(1, MT7621_CDMP_EG_CTRL); - else - fe_w32(0, MT7621_CDMP_EG_CTRL); -} - -static int mt7621_fwd_config(struct fe_priv *priv) -{ - struct net_device *dev = priv_netdev(priv); - - fe_w32(fe_r32(MT7620A_GDMA1_FWD_CFG) & ~0xffff, - MT7620A_GDMA1_FWD_CFG); - - /* mt7621 doesn't have txcsum config */ - mt7621_rxcsum_config((dev->features & NETIF_F_RXCSUM)); - mt7621_rxvlan_config(dev->features & NETIF_F_HW_VLAN_CTAG_RX); - - return 0; -} - -static void mt7621_tx_dma(struct fe_tx_dma *txd) -{ - txd->txd4 = MT7621_TX_DMA_FPORT; -} - -static void mt7621_init_data(struct fe_soc_data *data, - struct net_device *netdev) -{ - struct fe_priv *priv = netdev_priv(netdev); - - priv->flags = FE_FLAG_PADDING_64B | FE_FLAG_RX_2B_OFFSET | - FE_FLAG_RX_SG_DMA | FE_FLAG_NAPI_WEIGHT | - FE_FLAG_HAS_SWITCH | FE_FLAG_JUMBO_FRAME; - - netdev->hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM | - NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_SG | NETIF_F_IPV6_CSUM | - NETIF_F_TSO_MANGLEID; -} - -static void mt7621_set_mac(struct fe_priv *priv, unsigned char *mac) -{ - unsigned long flags; - - spin_lock_irqsave(&priv->page_lock, flags); - fe_w32((mac[0] << 8) | mac[1], GSW_REG_GDMA1_MAC_ADRH); - fe_w32((mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5], - GSW_REG_GDMA1_MAC_ADRL); - spin_unlock_irqrestore(&priv->page_lock, flags); -} - -static struct fe_soc_data mt7621_data = { - .init_data = mt7621_init_data, - .reset_fe = mt7621_fe_reset, - .set_mac = mt7621_set_mac, - .fwd_config = mt7621_fwd_config, - .tx_dma = mt7621_tx_dma, - .switch_init = mtk_gsw_init, - .switch_config = mt7621_gsw_config, - .reg_table = mt7621_reg_table, - .pdma_glo_cfg = FE_PDMA_SIZE_16DWORDS, - .rx_int = RT5350_RX_DONE_INT, - .tx_int = RT5350_TX_DONE_INT, - .status_int = (MT7621_FE_GDM1_AF | MT7621_FE_GDM2_AF), - .checksum_bit = MT7621_L4_VALID, - .has_carrier = mt7620_has_carrier, - .mdio_read = mt7620_mdio_read, - .mdio_write = mt7620_mdio_write, - .mdio_adjust_link = mt7620_mdio_link_adjust, -}; - -const struct of_device_id of_fe_match[] = { - { .compatible = "mediatek,ralink-mt7621-eth", .data = &mt7621_data }, - {}, -}; - -MODULE_DEVICE_TABLE(of, of_fe_match); diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt2880.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt2880.c index 6c89c997d..f36904950 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt2880.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt2880.c @@ -19,8 +19,6 @@ #include "mtk_eth_soc.h" #include "mdio_rt2880.h" -#define RT2880_RESET_FE BIT(18) - static void rt2880_init_data(struct fe_soc_data *data, struct net_device *netdev) { @@ -33,11 +31,6 @@ static void rt2880_init_data(struct fe_soc_data *data, /* netdev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM; */ } -void rt2880_fe_reset(void) -{ - fe_reset(RT2880_RESET_FE); -} - static int rt2880_fwd_config(struct fe_priv *priv) { int ret; @@ -55,7 +48,6 @@ static int rt2880_fwd_config(struct fe_priv *priv) struct fe_soc_data rt2880_data = { .init_data = rt2880_init_data, - .reset_fe = rt2880_fe_reset, .fwd_config = rt2880_fwd_config, .pdma_glo_cfg = FE_PDMA_SIZE_8DWORDS, .checksum_bit = RX_DMA_L4VALID, diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt3050.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt3050.c index 914b81410..435f00747 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt3050.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt3050.c @@ -17,11 +17,9 @@ #include #include "mtk_eth_soc.h" +#include "esw_rt3050.h" #include "mdio_rt2880.h" -#define RT305X_RESET_FE BIT(21) -#define RT305X_RESET_ESW BIT(23) - static const u16 rt5350_reg_table[FE_REG_COUNT] = { [FE_REG_PDMA_GLO_CFG] = RT5350_PDMA_GLO_CFG, [FE_REG_PDMA_RST_CFG] = RT5350_PDMA_RST_CFG, @@ -69,11 +67,6 @@ static int rt3050_fwd_config(struct fe_priv *priv) return 0; } -static void rt305x_fe_reset(void) -{ - fe_reset(RT305X_RESET_FE); -} - static void rt5350_init_data(struct fe_soc_data *data, struct net_device *netdev) { @@ -120,15 +113,10 @@ static void rt5350_tx_dma(struct fe_tx_dma *txd) txd->txd4 = 0; } -static void rt5350_fe_reset(void) -{ - fe_reset(RT305X_RESET_FE | RT305X_RESET_ESW); -} - static struct fe_soc_data rt3050_data = { .init_data = rt305x_init_data, - .reset_fe = rt305x_fe_reset, .fwd_config = rt3050_fwd_config, + .switch_init = rt3050_esw_init, .pdma_glo_cfg = FE_PDMA_SIZE_8DWORDS, .checksum_bit = RX_DMA_L4VALID, .rx_int = FE_RX_DONE_INT, @@ -139,9 +127,9 @@ static struct fe_soc_data rt3050_data = { static struct fe_soc_data rt5350_data = { .init_data = rt5350_init_data, .reg_table = rt5350_reg_table, - .reset_fe = rt5350_fe_reset, .set_mac = rt5350_set_mac, .fwd_config = rt5350_fwd_config, + .switch_init = rt3050_esw_init, .tx_dma = rt5350_tx_dma, .pdma_glo_cfg = FE_PDMA_SIZE_8DWORDS, .checksum_bit = RX_DMA_L4VALID, diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt3883.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt3883.c index 4935b7fbd..7b61e9c40 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt3883.c +++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/soc_rt3883.c @@ -19,13 +19,6 @@ #include "mtk_eth_soc.h" #include "mdio_rt2880.h" -#define RT3883_RSTCTRL_FE BIT(21) - -static void rt3883_fe_reset(void) -{ - fe_reset(RT3883_RSTCTRL_FE); -} - static int rt3883_fwd_config(struct fe_priv *priv) { int ret; @@ -54,7 +47,6 @@ static void rt3883_init_data(struct fe_soc_data *data, static struct fe_soc_data rt3883_data = { .init_data = rt3883_init_data, - .reset_fe = rt3883_fe_reset, .fwd_config = rt3883_fwd_config, .pdma_glo_cfg = FE_PDMA_SIZE_8DWORDS, .rx_int = FE_RX_DONE_INT, diff --git a/target/linux/ramips/files/drivers/pinctrl/pinctrl-aw9523.c b/target/linux/ramips/files/drivers/pinctrl/pinctrl-aw9523.c new file mode 100644 index 000000000..182e11cdc --- /dev/null +++ b/target/linux/ramips/files/drivers/pinctrl/pinctrl-aw9523.c @@ -0,0 +1,1135 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Awinic AW9523B i2c pin controller driver + * Copyright (c) 2020, AngeloGioacchino Del Regno + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "core.h" +#include "pinconf.h" +#include "pinctrl-utils.h" + +#define AW9523_MAX_FUNCS 2 +#define AW9523_NUM_PORTS 2 +#define AW9523_PINS_PER_PORT 8 + +/* + * HW needs at least 20uS for reset and at least 1-2uS to recover from + * reset, but we have to account for eventual board quirks, if any: + * for this reason, keep reset asserted for 50uS and wait for 20uS + * to recover from the reset. + */ +#define AW9523_HW_RESET_US 50 +#define AW9523_HW_RESET_RECOVERY_US 20 + +/* Port 0: P0_0...P0_7 - Port 1: P1_0...P1_7 */ +#define AW9523_PIN_TO_PORT(pin) (pin >> 3) +#define AW9523_REG_IN_STATE(pin) (0x00 + AW9523_PIN_TO_PORT(pin)) +#define AW9523_REG_OUT_STATE(pin) (0x02 + AW9523_PIN_TO_PORT(pin)) +#define AW9523_REG_CONF_STATE(pin) (0x04 + AW9523_PIN_TO_PORT(pin)) +#define AW9523_REG_INTR_DIS(pin) (0x06 + AW9523_PIN_TO_PORT(pin)) +#define AW9523_REG_CHIPID 0x10 +#define AW9523_VAL_EXPECTED_CHIPID 0x23 + +#define AW9523_REG_GCR 0x11 +#define AW9523_GCR_ISEL_MASK GENMASK(0, 1) +#define AW9523_GCR_GPOMD_MASK BIT(4) + +#define AW9523_REG_PORT_MODE(pin) (0x12 + AW9523_PIN_TO_PORT(pin)) +#define AW9523_REG_SOFT_RESET 0x7f +#define AW9523_VAL_RESET 0x00 + +/* + * struct aw9523_irq - Interrupt controller structure + * @lock: mutex locking for the irq bus + * @irqchip: structure holding irqchip params + * @cached_gpio: stores the previous gpio status for bit comparison + */ +struct aw9523_irq { + struct mutex lock; + struct irq_chip *irqchip; + u16 cached_gpio; +}; + +/* + * struct aw9523_pinmux - Pin mux params + * @name: Name of the mux + * @grps: Groups of the mux + * @num_grps: Number of groups (sizeof array grps) + */ +struct aw9523_pinmux { + const char *name; + const char * const *grps; + const u8 num_grps; +}; + +/* + * struct aw9523 - Main driver structure + * @dev: device handle + * @regmap: regmap handle for current device + * @i2c_lock: Mutex lock for i2c operations + * @reset_gpio: Hardware reset (RSTN) signal GPIO + * @vio_vreg: VCC regulator (Optional) + * @pctl: pinctrl handle for current device + * @gpio: structure holding gpiochip params + * @irq: Interrupt controller structure + */ +struct aw9523 { + struct device *dev; + struct regmap *regmap; + struct mutex i2c_lock; + struct gpio_desc *reset_gpio; + struct regulator *vio_vreg; + struct pinctrl_dev *pctl; + struct gpio_chip gpio; + struct aw9523_irq *irq; +}; + +static const struct pinctrl_pin_desc aw9523_pins[] = { + /* Port 0 */ + PINCTRL_PIN(0, "gpio0"), + PINCTRL_PIN(1, "gpio1"), + PINCTRL_PIN(2, "gpio2"), + PINCTRL_PIN(3, "gpio3"), + PINCTRL_PIN(4, "gpio4"), + PINCTRL_PIN(5, "gpio5"), + PINCTRL_PIN(6, "gpio6"), + PINCTRL_PIN(7, "gpio7"), + + /* Port 1 */ + PINCTRL_PIN(8, "gpio8"), + PINCTRL_PIN(9, "gpio9"), + PINCTRL_PIN(10, "gpio10"), + PINCTRL_PIN(11, "gpio11"), + PINCTRL_PIN(12, "gpio12"), + PINCTRL_PIN(13, "gpio13"), + PINCTRL_PIN(14, "gpio14"), + PINCTRL_PIN(15, "gpio15"), +}; + +static int aw9523_pinctrl_get_groups_count(struct pinctrl_dev *pctldev) +{ + return ARRAY_SIZE(aw9523_pins); +} + +static const char *aw9523_pinctrl_get_group_name(struct pinctrl_dev *pctldev, + unsigned int selector) +{ + return aw9523_pins[selector].name; +} + +static int aw9523_pinctrl_get_group_pins(struct pinctrl_dev *pctldev, + unsigned int selector, + const unsigned int **pins, + unsigned int *num_pins) +{ + *pins = &aw9523_pins[selector].number; + *num_pins = 1; + return 0; +} + +static const struct pinctrl_ops aw9523_pinctrl_ops = { + .get_groups_count = aw9523_pinctrl_get_groups_count, + .get_group_pins = aw9523_pinctrl_get_group_pins, + .get_group_name = aw9523_pinctrl_get_group_name, + .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, + .dt_free_map = pinconf_generic_dt_free_map, +}; + +static const char * const gpio_pwm_groups[] = { + "gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", + "gpio6", "gpio7", "gpio8", "gpio9", "gpio10", "gpio11", + "gpio12", "gpio13", "gpio14", "gpio15" +}; + +/* Warning: Do NOT reorder this array */ +static const struct aw9523_pinmux aw9523_pmx[] = { + { + .name = "pwm", + .grps = gpio_pwm_groups, + .num_grps = ARRAY_SIZE(gpio_pwm_groups), + }, + { + .name = "gpio", + .grps = gpio_pwm_groups, + .num_grps = ARRAY_SIZE(gpio_pwm_groups), + }, +}; + +static int aw9523_pmx_get_funcs_count(struct pinctrl_dev *pctl) +{ + return ARRAY_SIZE(aw9523_pmx); +} + +static const char *aw9523_pmx_get_fname(struct pinctrl_dev *pctl, + unsigned int sel) +{ + return aw9523_pmx[sel].name; +} + +static int aw9523_pmx_get_groups(struct pinctrl_dev *pctl, unsigned int sel, + const char * const **groups, + unsigned int * const num_groups) +{ + *groups = aw9523_pmx[sel].grps; + *num_groups = aw9523_pmx[sel].num_grps; + return 0; +} + +static int aw9523_pmx_set_mux(struct pinctrl_dev *pctl, unsigned int fsel, + unsigned int grp) +{ + struct aw9523 *awi = pinctrl_dev_get_drvdata(pctl); + int ret, pin = aw9523_pins[grp].number % AW9523_PINS_PER_PORT; + + if (fsel >= ARRAY_SIZE(aw9523_pmx)) + return -EINVAL; + + /* + * This maps directly to the aw9523_pmx array: programming a + * high bit means "gpio" and a low bit means "pwm". + */ + mutex_lock(&awi->i2c_lock); + ret = regmap_update_bits(awi->regmap, AW9523_REG_PORT_MODE(pin), + BIT(pin), (fsel ? BIT(pin) : 0)); + mutex_unlock(&awi->i2c_lock); + return ret; +} + +static const struct pinmux_ops aw9523_pinmux_ops = { + .get_functions_count = aw9523_pmx_get_funcs_count, + .get_function_name = aw9523_pmx_get_fname, + .get_function_groups = aw9523_pmx_get_groups, + .set_mux = aw9523_pmx_set_mux, +}; + +static int aw9523_pcfg_param_to_reg(enum pin_config_param pcp, int pin, u8 *r) +{ + u8 reg; + + switch (pcp) { + case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: + case PIN_CONFIG_BIAS_PULL_DOWN: + case PIN_CONFIG_BIAS_PULL_UP: + reg = AW9523_REG_IN_STATE(pin); + break; + case PIN_CONFIG_DRIVE_OPEN_DRAIN: + case PIN_CONFIG_DRIVE_PUSH_PULL: + reg = AW9523_REG_GCR; + break; + case PIN_CONFIG_INPUT_ENABLE: + case PIN_CONFIG_OUTPUT_ENABLE: + reg = AW9523_REG_CONF_STATE(pin); + break; + case PIN_CONFIG_OUTPUT: + reg = AW9523_REG_OUT_STATE(pin); + break; + default: + return -ENOTSUPP; + } + *r = reg; + + return 0; +} + +static int aw9523_pconf_get(struct pinctrl_dev *pctldev, unsigned int pin, + unsigned long *config) +{ + struct aw9523 *awi = pinctrl_dev_get_drvdata(pctldev); + enum pin_config_param param = pinconf_to_config_param(*config); + int regbit = pin % AW9523_PINS_PER_PORT; + unsigned int val; + u8 reg; + int rc; + + rc = aw9523_pcfg_param_to_reg(param, pin, ®); + if (rc) + return rc; + + mutex_lock(&awi->i2c_lock); + rc = regmap_read(awi->regmap, reg, &val); + mutex_unlock(&awi->i2c_lock); + if (rc) + return rc; + + switch (param) { + case PIN_CONFIG_BIAS_PULL_UP: + case PIN_CONFIG_INPUT_ENABLE: + case PIN_CONFIG_OUTPUT: + val &= BIT(regbit); + break; + case PIN_CONFIG_BIAS_PULL_DOWN: + case PIN_CONFIG_OUTPUT_ENABLE: + val &= BIT(regbit); + val = !val; + break; + case PIN_CONFIG_DRIVE_OPEN_DRAIN: + if (pin >= AW9523_PINS_PER_PORT) + val = 0; + else + val = !FIELD_GET(AW9523_GCR_GPOMD_MASK, val); + break; + case PIN_CONFIG_DRIVE_PUSH_PULL: + if (pin >= AW9523_PINS_PER_PORT) + val = 1; + else + val = FIELD_GET(AW9523_GCR_GPOMD_MASK, val); + break; + default: + return -ENOTSUPP; + } + if (val < 1) + return -EINVAL; + + *config = pinconf_to_config_packed(param, !!val); + + return rc; +} + +static int aw9523_pconf_set(struct pinctrl_dev *pctldev, unsigned int pin, + unsigned long *configs, unsigned int num_configs) +{ + struct aw9523 *awi = pinctrl_dev_get_drvdata(pctldev); + enum pin_config_param param; + int regbit = pin % AW9523_PINS_PER_PORT; + u32 arg; + u8 reg; + unsigned int mask, val; + int i, rc; + + mutex_lock(&awi->i2c_lock); + for (i = 0; i < num_configs; i++) { + param = pinconf_to_config_param(configs[i]); + arg = pinconf_to_config_argument(configs[i]); + + rc = aw9523_pcfg_param_to_reg(param, pin, ®); + if (rc) + goto end; + + switch (param) { + case PIN_CONFIG_OUTPUT: + /* First, enable pin output */ + rc = regmap_update_bits(awi->regmap, + AW9523_REG_CONF_STATE(pin), + BIT(regbit), 0); + if (rc) + goto end; + + /* Then, fall through to config output level */ + fallthrough; + case PIN_CONFIG_OUTPUT_ENABLE: + arg = !arg; + fallthrough; + case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: + case PIN_CONFIG_BIAS_PULL_DOWN: + case PIN_CONFIG_BIAS_PULL_UP: + case PIN_CONFIG_INPUT_ENABLE: + mask = BIT(regbit); + val = arg ? BIT(regbit) : 0; + break; + case PIN_CONFIG_DRIVE_OPEN_DRAIN: + /* Open-Drain is supported only on port 0 */ + if (pin >= AW9523_PINS_PER_PORT) { + rc = -ENOTSUPP; + goto end; + } + mask = AW9523_GCR_GPOMD_MASK; + val = 0; + break; + case PIN_CONFIG_DRIVE_PUSH_PULL: + /* Port 1 is always Push-Pull */ + if (pin >= AW9523_PINS_PER_PORT) { + mask = 0; + val = 0; + continue; + } + mask = AW9523_GCR_GPOMD_MASK; + val = AW9523_GCR_GPOMD_MASK; + break; + default: + rc = -ENOTSUPP; + goto end; + } + + rc = regmap_update_bits(awi->regmap, reg, mask, val); + if (rc) + goto end; + } +end: + mutex_unlock(&awi->i2c_lock); + return rc; +} + +static const struct pinconf_ops aw9523_pinconf_ops = { + .pin_config_get = aw9523_pconf_get, + .pin_config_set = aw9523_pconf_set, + .is_generic = true, +}; + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 5, 0) +#define GPIO_LINE_DIRECTION_IN 1 +#define GPIO_LINE_DIRECTION_OUT 0 +#endif + +/* + * aw9523_get_pin_direction - Get pin direction + * @regmap: Regmap structure + * @pin: gpiolib pin number + * @n: pin index in port register + * + * Return: Pin direction for success or negative number for error + */ +static int aw9523_get_pin_direction(struct regmap *regmap, u8 pin, u8 n) +{ + int val, ret; + + ret = regmap_read(regmap, AW9523_REG_CONF_STATE(pin), &val); + if (ret < 0) + return ret; + + return (val & BIT(n)) == BIT(n); +} + +/* + * aw9523_get_port_state - Get input or output state for entire port + * @regmap: Regmap structure + * @pin: gpiolib pin number + * @regbit: hw pin index, used to retrieve port number + * @state: returned port state + * + * Return: Zero for success or negative number for error + */ +static int aw9523_get_port_state(struct regmap *regmap, u8 pin, + u8 regbit, unsigned int *state) +{ + u8 reg; + int dir; + + dir = aw9523_get_pin_direction(regmap, pin, regbit); + if (dir < 0) + return dir; + + if (dir == GPIO_LINE_DIRECTION_IN) + reg = AW9523_REG_IN_STATE(pin); + else + reg = AW9523_REG_OUT_STATE(pin); + + return regmap_read(regmap, reg, state); +} + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 5, 0) +#undef GPIO_LINE_DIRECTION_IN +#undef GPIO_LINE_DIRECTION_OUT +#endif + +static int aw9523_gpio_irq_type(struct irq_data *d, unsigned int type) +{ + switch (type) { + case IRQ_TYPE_NONE: + case IRQ_TYPE_EDGE_BOTH: + return 0; + default: + return -EINVAL; + }; +} + +/* + * aw9523_irq_mask - Mask interrupt + * @d: irq data + * + * Sets which interrupt to mask in the bitmap; + * The interrupt will be masked when unlocking the irq bus. + */ +static void aw9523_irq_mask(struct irq_data *d) +{ + struct aw9523 *awi = gpiochip_get_data(irq_data_get_irq_chip_data(d)); + unsigned int n = d->hwirq % AW9523_PINS_PER_PORT; + + regmap_update_bits(awi->regmap, + AW9523_REG_INTR_DIS(d->hwirq), + BIT(n), BIT(n)); +} + +/* + * aw9523_irq_unmask - Unmask interrupt + * @d: irq data + * + * Sets which interrupt to unmask in the bitmap; + * The interrupt will be masked when unlocking the irq bus. + */ +static void aw9523_irq_unmask(struct irq_data *d) +{ + struct aw9523 *awi = gpiochip_get_data(irq_data_get_irq_chip_data(d)); + unsigned int n = d->hwirq % AW9523_PINS_PER_PORT; + + regmap_update_bits(awi->regmap, + AW9523_REG_INTR_DIS(d->hwirq), + BIT(n), 0); +} + +static irqreturn_t aw9523_irq_thread_func(int irq, void *dev_id) +{ + struct aw9523 *awi = (struct aw9523 *)dev_id; + unsigned long n, val = 0; + unsigned long changed_gpio; + unsigned int tmp, port_pin, i, ret; + + for (i = 0; i < AW9523_NUM_PORTS; i++) { + port_pin = i * AW9523_PINS_PER_PORT; + ret = regmap_read(awi->regmap, + AW9523_REG_IN_STATE(port_pin), + &tmp); + if (ret) + return ret; + val |= (u8)tmp << (i * 8); + } + + /* Handle GPIO input release interrupt as well */ + changed_gpio = awi->irq->cached_gpio ^ val; + awi->irq->cached_gpio = val; + + /* + * To avoid up to four *slow* i2c reads from any driver hooked + * up to our interrupts, just check for the irq_find_mapping + * result: if the interrupt is not mapped, then we don't want + * to care about it. + */ + for_each_set_bit(n, &changed_gpio, awi->gpio.ngpio) { + tmp = irq_find_mapping(awi->gpio.irq.domain, n); + if (tmp <= 0) + continue; + handle_nested_irq(tmp); + } + + return IRQ_HANDLED; +} + +/* + * aw9523_irq_bus_lock - Grab lock for interrupt operation + * @d: irq data + */ +static void aw9523_irq_bus_lock(struct irq_data *d) +{ + struct aw9523 *awi = gpiochip_get_data(irq_data_get_irq_chip_data(d)); + + mutex_lock(&awi->irq->lock); + regcache_cache_only(awi->regmap, true); +} + +/* + * aw9523_irq_bus_sync_unlock - Synchronize state and unlock + * @d: irq data + * + * Writes the interrupt mask bits (found in the bit map) to the + * hardware, then unlocks the bus. + */ +static void aw9523_irq_bus_sync_unlock(struct irq_data *d) +{ + struct aw9523 *awi = gpiochip_get_data(irq_data_get_irq_chip_data(d)); + + regcache_cache_only(awi->regmap, false); + regcache_sync(awi->regmap); + mutex_unlock(&awi->irq->lock); +} + +static int aw9523_gpio_get_direction(struct gpio_chip *chip, + unsigned int offset) +{ + struct aw9523 *awi = gpiochip_get_data(chip); + u8 regbit = offset % AW9523_PINS_PER_PORT; + int ret; + + mutex_lock(&awi->i2c_lock); + ret = aw9523_get_pin_direction(awi->regmap, offset, regbit); + mutex_unlock(&awi->i2c_lock); + + return ret; +} + +static int aw9523_gpio_get(struct gpio_chip *chip, unsigned int offset) +{ + struct aw9523 *awi = gpiochip_get_data(chip); + u8 regbit = offset % AW9523_PINS_PER_PORT; + unsigned int val; + int ret; + + mutex_lock(&awi->i2c_lock); + ret = aw9523_get_port_state(awi->regmap, offset, regbit, &val); + mutex_unlock(&awi->i2c_lock); + if (ret) + return ret; + + return !!(val & BIT(regbit)); +} + +/** + * _aw9523_gpio_get_multiple - Get I/O state for an entire port + * @regmap: Regmap structure + * @pin: gpiolib pin number + * @regbit: hw pin index, used to retrieve port number + * @state: returned port I/O state + * + * Return: Zero for success or negative number for error + */ +static int _aw9523_gpio_get_multiple(struct aw9523 *awi, u8 regbit, + u8 *state, u8 mask) +{ + u32 dir_in, val; + u8 m; + int ret; + + /* Registers are 8-bits wide */ + ret = regmap_read(awi->regmap, AW9523_REG_CONF_STATE(regbit), &dir_in); + if (ret) + return ret; + *state = 0; + + m = mask & dir_in; + if (m) { + ret = regmap_read(awi->regmap, AW9523_REG_IN_STATE(regbit), + &val); + if (ret) + return ret; + *state |= (u8)val & m; + } + + m = mask & ~dir_in; + if (m) { + ret = regmap_read(awi->regmap, AW9523_REG_OUT_STATE(regbit), + &val); + if (ret) + return ret; + *state |= (u8)val & m; + } + + return 0; +} + +static int aw9523_gpio_get_multiple(struct gpio_chip *chip, + unsigned long *mask, + unsigned long *bits) +{ + struct aw9523 *awi = gpiochip_get_data(chip); + u8 m, state = 0; + int ret; + + mutex_lock(&awi->i2c_lock); + + /* Port 0 (gpio 0-7) */ + m = *mask & U8_MAX; + if (m) { + ret = _aw9523_gpio_get_multiple(awi, 0, &state, m); + if (ret) + goto out; + } + *bits = state; + + /* Port 1 (gpio 8-15) */ + m = (*mask >> 8) & U8_MAX; + if (m) { + ret = _aw9523_gpio_get_multiple(awi, AW9523_PINS_PER_PORT, + &state, m); + if (ret) + goto out; + + *bits |= (state << 8); + } +out: + mutex_unlock(&awi->i2c_lock); + return ret; +} + +static void aw9523_gpio_set_multiple(struct gpio_chip *chip, + unsigned long *mask, + unsigned long *bits) +{ + struct aw9523 *awi = gpiochip_get_data(chip); + u8 mask_lo, mask_hi, bits_lo, bits_hi; + unsigned int reg; + int ret = 0; + + mask_lo = *mask & U8_MAX; + mask_hi = (*mask >> 8) & U8_MAX; + mutex_lock(&awi->i2c_lock); + if (mask_hi) { + reg = AW9523_REG_OUT_STATE(AW9523_PINS_PER_PORT); + bits_hi = (*bits >> 8) & U8_MAX; + + ret = regmap_write_bits(awi->regmap, reg, mask_hi, bits_hi); + if (ret) { + dev_warn(awi->dev, "Cannot write port1 out level\n"); + goto out; + } + } + if (mask_lo) { + reg = AW9523_REG_OUT_STATE(0); + bits_lo = *bits & U8_MAX; + ret = regmap_write_bits(awi->regmap, reg, mask_lo, bits_lo); + if (ret) + dev_warn(awi->dev, "Cannot write port0 out level\n"); + } +out: + mutex_unlock(&awi->i2c_lock); +} + +static void aw9523_gpio_set(struct gpio_chip *chip, + unsigned int offset, int value) +{ + struct aw9523 *awi = gpiochip_get_data(chip); + u8 regbit = offset % AW9523_PINS_PER_PORT; + + mutex_lock(&awi->i2c_lock); + regmap_update_bits(awi->regmap, AW9523_REG_OUT_STATE(offset), + BIT(regbit), value ? BIT(regbit) : 0); + mutex_unlock(&awi->i2c_lock); +} + + +static int aw9523_direction_input(struct gpio_chip *chip, unsigned int offset) +{ + struct aw9523 *awi = gpiochip_get_data(chip); + u8 regbit = offset % AW9523_PINS_PER_PORT; + int ret; + + mutex_lock(&awi->i2c_lock); + ret = regmap_update_bits(awi->regmap, AW9523_REG_CONF_STATE(offset), + BIT(regbit), BIT(regbit)); + mutex_unlock(&awi->i2c_lock); + + return ret; +} + +static int aw9523_direction_output(struct gpio_chip *chip, + unsigned int offset, int value) +{ + struct aw9523 *awi = gpiochip_get_data(chip); + u8 regbit = offset % AW9523_PINS_PER_PORT; + int ret; + + mutex_lock(&awi->i2c_lock); + ret = regmap_update_bits(awi->regmap, AW9523_REG_OUT_STATE(offset), + BIT(regbit), value ? BIT(regbit) : 0); + if (ret) + goto end; + + ret = regmap_update_bits(awi->regmap, AW9523_REG_CONF_STATE(offset), + BIT(regbit), 0); +end: + mutex_unlock(&awi->i2c_lock); + return ret; +} + +static int aw9523_drive_reset_gpio(struct aw9523 *awi) +{ + unsigned int chip_id; + int ret; + + /* + * If the chip is already configured for any reason, then we + * will probably succeed in sending the soft reset signal to + * the hardware through I2C: this operation takes less time + * compared to a full HW reset and it gives the same results. + */ + ret = regmap_write(awi->regmap, AW9523_REG_SOFT_RESET, 0); + if (ret == 0) + goto done; + + dev_dbg(awi->dev, "Cannot execute soft reset: trying hard reset\n"); + ret = gpiod_direction_output(awi->reset_gpio, 0); + if (ret) + return ret; + + /* The reset pulse has to be longer than 20uS due to deglitch */ + usleep_range(AW9523_HW_RESET_US, AW9523_HW_RESET_US + 1); + + ret = gpiod_direction_output(awi->reset_gpio, 1); + if (ret) + return ret; +done: + /* The HW needs at least 1uS to reliably recover after reset */ + usleep_range(AW9523_HW_RESET_RECOVERY_US, + AW9523_HW_RESET_RECOVERY_US + 1); + + /* Check the ChipID */ + ret = regmap_read(awi->regmap, AW9523_REG_CHIPID, &chip_id); + if (ret) { + dev_err(awi->dev, "Cannot read Chip ID: %d\n", ret); + return ret; + } + if (chip_id != AW9523_VAL_EXPECTED_CHIPID) { + dev_err(awi->dev, "Bad ChipID; read 0x%x, expected 0x%x\n", + chip_id, AW9523_VAL_EXPECTED_CHIPID); + return -EINVAL; + } + + return 0; +} + +static int aw9523_hw_reset(struct aw9523 *awi) +{ + int ret, max_retries = 2; + + /* Sometimes the chip needs more than one reset cycle */ + do { + ret = aw9523_drive_reset_gpio(awi); + if (ret == 0) + break; + max_retries--; + } while (max_retries); + + return ret; +} + +static int aw9523_init_gpiochip(struct aw9523 *awi, unsigned int npins) +{ + struct device *dev = awi->dev; + struct gpio_chip *gpiochip = &awi->gpio; + + gpiochip->label = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL); + if (!gpiochip->label) + return -ENOMEM; + + gpiochip->base = -1; + gpiochip->ngpio = npins; + gpiochip->get_direction = aw9523_gpio_get_direction; + gpiochip->direction_input = aw9523_direction_input; + gpiochip->direction_output = aw9523_direction_output; + gpiochip->get = aw9523_gpio_get; + gpiochip->get_multiple = aw9523_gpio_get_multiple; + gpiochip->set = aw9523_gpio_set; + gpiochip->set_multiple = aw9523_gpio_set_multiple; + gpiochip->set_config = gpiochip_generic_config; + gpiochip->parent = dev; + gpiochip->of_node = dev->of_node; + gpiochip->owner = THIS_MODULE; + gpiochip->can_sleep = false; + + return 0; +} + +static int aw9523_init_irq(struct aw9523 *awi, int irq) +{ + struct device *dev = awi->dev; + struct gpio_irq_chip *gpioirq; + struct irq_chip *irqchip; + int ret; + + if (!device_property_read_bool(dev, "interrupt-controller")) + return 0; + + irqchip = devm_kzalloc(dev, sizeof(*irqchip), GFP_KERNEL); + if (!irqchip) + return -ENOMEM; + + awi->irq = devm_kzalloc(dev, sizeof(*awi->irq), GFP_KERNEL); + if (!awi->irq) + return -ENOMEM; + + irqchip->name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL); + if (!irqchip->name) + return -ENOMEM; + + irqchip->irq_mask = aw9523_irq_mask; + irqchip->irq_unmask = aw9523_irq_unmask; + irqchip->irq_bus_lock = aw9523_irq_bus_lock; + irqchip->irq_bus_sync_unlock = aw9523_irq_bus_sync_unlock; + irqchip->irq_set_type = aw9523_gpio_irq_type; + awi->irq->irqchip = irqchip; + mutex_init(&awi->irq->lock); + + ret = devm_request_threaded_irq(dev, irq, NULL, aw9523_irq_thread_func, + IRQF_ONESHOT, dev_name(dev), awi); + if (ret) { + dev_err(dev, "Failed to request irq %d\n", irq); + return ret; + } + + gpioirq = &awi->gpio.irq; + gpioirq->chip = irqchip; + gpioirq->parent_handler = NULL; + gpioirq->num_parents = 0; + gpioirq->parents = NULL; + gpioirq->default_type = IRQ_TYPE_LEVEL_MASK; + gpioirq->handler = handle_simple_irq; + gpioirq->threaded = true; + gpioirq->first = 0; + + return 0; +} + +static bool aw9523_is_reg_hole(unsigned int reg) +{ + return (reg > AW9523_REG_PORT_MODE(AW9523_PINS_PER_PORT) && + reg < AW9523_REG_SOFT_RESET) || + (reg > AW9523_REG_INTR_DIS(AW9523_PINS_PER_PORT) && + reg < AW9523_REG_CHIPID); +} + +static bool aw9523_readable_reg(struct device *dev, unsigned int reg) +{ + /* All available registers (minus holes) can be read */ + return !aw9523_is_reg_hole(reg); +} + +static bool aw9523_volatile_reg(struct device *dev, unsigned int reg) +{ + return aw9523_is_reg_hole(reg) || + reg == AW9523_REG_IN_STATE(0) || + reg == AW9523_REG_IN_STATE(AW9523_PINS_PER_PORT) || + reg == AW9523_REG_CHIPID || + reg == AW9523_REG_SOFT_RESET; +} + +static bool aw9523_writeable_reg(struct device *dev, unsigned int reg) +{ + return !aw9523_is_reg_hole(reg) && reg != AW9523_REG_CHIPID; +} + +static bool aw9523_precious_reg(struct device *dev, unsigned int reg) +{ + /* Reading AW9523_REG_IN_STATE clears interrupt status */ + return aw9523_is_reg_hole(reg) || + reg == AW9523_REG_IN_STATE(0) || + reg == AW9523_REG_IN_STATE(AW9523_PINS_PER_PORT); +} + +static const struct regmap_config aw9523_regmap = { + .reg_bits = 8, + .val_bits = 8, + .reg_stride = 1, + + .precious_reg = aw9523_precious_reg, + .readable_reg = aw9523_readable_reg, + .volatile_reg = aw9523_volatile_reg, + .writeable_reg = aw9523_writeable_reg, + + .cache_type = REGCACHE_FLAT, + .disable_locking = true, + + .num_reg_defaults_raw = AW9523_REG_SOFT_RESET, +}; + +static int aw9523_hw_init(struct aw9523 *awi) +{ + u8 p1_pin = AW9523_PINS_PER_PORT; + unsigned int val; + int ret; + + /* No register caching during initialization */ + regcache_cache_bypass(awi->regmap, true); + + /* Bring up the chip */ + ret = aw9523_hw_reset(awi); + if (ret) { + dev_err(awi->dev, "HW Reset failed: %d\n", ret); + return ret; + } + + /* + * This is the expected chip and it is running: it's time to + * set a safe default configuration in case the user doesn't + * configure (all of the available) pins in this chip. + * P.S.: The writes order doesn't matter. + */ + + /* Set all pins as GPIO */ + ret = regmap_write(awi->regmap, AW9523_REG_PORT_MODE(0), U8_MAX); + if (ret) + return ret; + ret = regmap_write(awi->regmap, AW9523_REG_PORT_MODE(p1_pin), U8_MAX); + if (ret) + return ret; + + /* Set Open-Drain mode on Port 0 (Port 1 is always P-P) */ + ret = regmap_write(awi->regmap, AW9523_REG_GCR, 0); + if (ret) + return ret; + + /* Set all pins as inputs */ + ret = regmap_write(awi->regmap, AW9523_REG_CONF_STATE(0), U8_MAX); + if (ret) + return ret; + ret = regmap_write(awi->regmap, AW9523_REG_CONF_STATE(p1_pin), U8_MAX); + if (ret) + return ret; + + /* Disable all interrupts to avoid unreasoned wakeups */ + ret = regmap_write(awi->regmap, AW9523_REG_INTR_DIS(0), U8_MAX); + if (ret) + return ret; + ret = regmap_write(awi->regmap, AW9523_REG_INTR_DIS(p1_pin), U8_MAX); + if (ret) + return ret; + + /* Clear setup-generated interrupts by performing a port state read */ + ret = aw9523_get_port_state(awi->regmap, 0, 0, &val); + if (ret) + return ret; + ret = aw9523_get_port_state(awi->regmap, p1_pin, 0, &val); + if (ret) + return ret; + + /* Everything went fine: activate and reinitialize register cache */ + regcache_cache_bypass(awi->regmap, false); + return regmap_reinit_cache(awi->regmap, &aw9523_regmap); +} + +static int aw9523_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct device *dev = &client->dev; + struct pinctrl_desc *pdesc; + struct aw9523 *awi; + int ret; + + awi = devm_kzalloc(dev, sizeof(*awi), GFP_KERNEL); + if (!awi) + return -ENOMEM; + + i2c_set_clientdata(client, awi); + + awi->dev = dev; + awi->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(awi->reset_gpio)) + return PTR_ERR(awi->reset_gpio); + gpiod_set_consumer_name(awi->reset_gpio, "aw9523 reset"); + + awi->regmap = devm_regmap_init_i2c(client, &aw9523_regmap); + if (IS_ERR(awi->regmap)) + return PTR_ERR(awi->regmap); + + awi->vio_vreg = devm_regulator_get_optional(dev, "vio"); + if (IS_ERR(awi->vio_vreg)) { + if (PTR_ERR(awi->vio_vreg) == -EPROBE_DEFER) + return -EPROBE_DEFER; + awi->vio_vreg = NULL; + } else { + ret = regulator_enable(awi->vio_vreg); + if (ret) + return ret; + } + + mutex_init(&awi->i2c_lock); + lockdep_set_subclass(&awi->i2c_lock, + i2c_adapter_depth(client->adapter)); + + pdesc = devm_kzalloc(dev, sizeof(*pdesc), GFP_KERNEL); + if (!pdesc) + return -ENOMEM; + + ret = aw9523_hw_init(awi); + if (ret) + goto err_disable_vregs; + + pdesc->name = dev_name(dev); + pdesc->owner = THIS_MODULE; + pdesc->pctlops = &aw9523_pinctrl_ops; + pdesc->pmxops = &aw9523_pinmux_ops; + pdesc->confops = &aw9523_pinconf_ops; + pdesc->pins = aw9523_pins; + pdesc->npins = ARRAY_SIZE(aw9523_pins); + + ret = aw9523_init_gpiochip(awi, pdesc->npins); + if (ret) + goto err_disable_vregs; + + if (client->irq) { + ret = aw9523_init_irq(awi, client->irq); + if (ret) + goto err_disable_vregs; + } + + awi->pctl = devm_pinctrl_register(dev, pdesc, awi); + if (IS_ERR(awi->pctl)) { + ret = PTR_ERR(awi->pctl); + dev_err(dev, "Cannot register pinctrl: %d", ret); + goto err_disable_vregs; + } + + ret = devm_gpiochip_add_data(dev, &awi->gpio, awi); + if (ret) + goto err_disable_vregs; + + return ret; + +err_disable_vregs: + if (awi->vio_vreg) + regulator_disable(awi->vio_vreg); + mutex_destroy(&awi->i2c_lock); + return ret; +} + +static int aw9523_remove(struct i2c_client *client) +{ + struct aw9523 *awi = i2c_get_clientdata(client); + int ret; + + if (!awi) + return 0; + + /* + * If the chip VIO is connected to a regulator that we can turn + * off, life is easy... otherwise, reinitialize the chip and + * set the pins to hardware defaults before removing the driver + * to leave it in a clean, safe and predictable state. + */ + if (awi->vio_vreg) { + regulator_disable(awi->vio_vreg); + } else { + mutex_lock(&awi->i2c_lock); + ret = aw9523_hw_init(awi); + mutex_unlock(&awi->i2c_lock); + if (ret) + return ret; + } + + mutex_destroy(&awi->i2c_lock); + return 0; +} + +static const struct i2c_device_id aw9523_i2c_id_table[] = { + { "aw9523_i2c", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, aw9523_i2c_id_table); + +static const struct of_device_id of_aw9523_i2c_match[] = { + { .compatible = "awinic,aw9523-pinctrl", }, +}; +MODULE_DEVICE_TABLE(of, of_aw9523_i2c_match); + +static struct i2c_driver aw9523_driver = { + .driver = { + .name = "aw9523-pinctrl", + .of_match_table = of_aw9523_i2c_match, + }, + .probe = aw9523_probe, + .remove = aw9523_remove, + .id_table = aw9523_i2c_id_table, +}; +module_i2c_driver(aw9523_driver); + +MODULE_DESCRIPTION("Awinic AW9523 I2C GPIO Expander driver"); +MODULE_AUTHOR("AngeloGioacchino Del Regno "); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:aw9523"); diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile index fc5223f3a..cd2c425ce 100644 --- a/target/linux/ramips/image/Makefile +++ b/target/linux/ramips/image/Makefile @@ -166,7 +166,7 @@ define Device/Default IMAGES := sysupgrade.bin COMPILE := sysupgrade_bin := append-kernel | append-rootfs | pad-rootfs - IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata | check-size + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | check-size | append-metadata endef define Device/netgear_sercomm_nor @@ -175,7 +175,7 @@ define Device/netgear_sercomm_nor IMAGES += factory.img IMAGE/default := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | \ pad-rootfs - IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata | check-size + IMAGE/sysupgrade.bin := $$(IMAGE/default) | check-size | append-metadata IMAGE/factory.img := pad-extra $$$$(SERCOMM_PAD) | $$(IMAGE/default) | \ pad-to $$$$(BLOCKSIZE) | sercom-footer | pad-to 128 | \ zip $$$$(SERCOMM_HWNAME).bin | sercom-seal @@ -190,7 +190,7 @@ define Device/seama # - 36 bytes of META data (4-bytes aligned) IMAGE/default := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-rootfs IMAGE/sysupgrade.bin := \ - $$(IMAGE/default) | seama | pad-rootfs | append-metadata | check-size + $$(IMAGE/default) | seama | pad-rootfs | check-size | append-metadata IMAGE/factory.bin := \ $$(IMAGE/default) | pad-rootfs -x 64 | seama | seama-seal | check-size SEAMA_SIGNATURE := diff --git a/target/linux/ramips/image/common-tp-link.mk b/target/linux/ramips/image/common-tp-link.mk index 07ad1ea25..915a086f9 100644 --- a/target/linux/ramips/image/common-tp-link.mk +++ b/target/linux/ramips/image/common-tp-link.mk @@ -11,8 +11,8 @@ define Device/tplink-v1 KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-v1-header -e -O IMAGES += factory.bin IMAGE/factory.bin := tplink-v1-image factory -e -O - IMAGE/sysupgrade.bin := tplink-v1-image sysupgrade -e -O | append-metadata | \ - check-size + IMAGE/sysupgrade.bin := tplink-v1-image sysupgrade -e -O | check-size | \ + append-metadata endef define Device/tplink-v2 @@ -26,8 +26,8 @@ define Device/tplink-v2 KERNEL_INITRAMFS := $(KERNEL_DTB) | tplink-v2-header -e IMAGES += factory.bin IMAGE/factory.bin := tplink-v2-image -e - IMAGE/sysupgrade.bin := tplink-v2-image -s -e | append-metadata | \ - check-size + IMAGE/sysupgrade.bin := tplink-v2-image -s -e | check-size | \ + append-metadata endef define Device/tplink-safeloader @@ -39,6 +39,6 @@ define Device/tplink-safeloader KERNEL := $(KERNEL_DTB) | tplink-v1-header -e -O IMAGES += factory.bin IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | \ - append-metadata | check-size + check-size | append-metadata IMAGE/factory.bin := append-rootfs | tplink-safeloader factory endef diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index 952f48844..c3b9bc9f6 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -54,7 +54,7 @@ define Device/alfa-network_tube-e4g DEVICE_VENDOR := ALFA Network DEVICE_MODEL := Tube-E4G DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci uboot-envtools uqmi -iwinfo \ - -kmod-rt2800-soc -wpad-openssl + -kmod-rt2800-soc -wpad-basic-wolfssl SUPPORTED_DEVICES += tube-e4g endef TARGET_DEVICES += alfa-network_tube-e4g @@ -327,7 +327,7 @@ define Device/edimax_br-6478ac-v2 IMAGE_SIZE := 7744k IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ edimax-header -s CSYS -m RN68 -f 0x70000 -S 0x01100000 | pad-rootfs | \ - append-metadata | check-size + check-size | append-metadata DEVICE_PACKAGES := kmod-mt76x2 kmod-usb2 kmod-usb-ohci \ kmod-usb-ledtrig-usbport endef @@ -341,7 +341,7 @@ define Device/edimax_ew-7476rpc IMAGE_SIZE := 7744k IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ edimax-header -s CSYS -m RN79 -f 0x70000 -S 0x01100000 | pad-rootfs | \ - append-metadata | check-size + check-size | append-metadata DEVICE_PACKAGES := kmod-mt76x2 kmod-phy-realtek endef TARGET_DEVICES += edimax_ew-7476rpc @@ -354,7 +354,7 @@ define Device/edimax_ew-7478ac IMAGE_SIZE := 7744k IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ edimax-header -s CSYS -m RN70 -f 0x70000 -S 0x01100000 | pad-rootfs | \ - append-metadata | check-size + check-size | append-metadata DEVICE_PACKAGES := kmod-mt76x2 kmod-phy-realtek endef TARGET_DEVICES += edimax_ew-7478ac @@ -367,7 +367,7 @@ define Device/edimax_ew-7478apc IMAGE_SIZE := 7744k IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ edimax-header -s CSYS -m RN75 -f 0x70000 -S 0x01100000 | pad-rootfs | \ - append-metadata | check-size + check-size | append-metadata DEVICE_PACKAGES := kmod-mt76x2 kmod-usb2 kmod-usb-ohci \ kmod-usb-ledtrig-usbport endef @@ -407,7 +407,7 @@ define Device/fon_fon2601 DEVICE_PACKAGES := kmod-mt76x2 kmod-usb2 kmod-usb-ohci KERNEL_INITRAMFS := $$(KERNEL) | uimage-padhdr IMAGE/sysupgrade.bin := append-kernel | append-rootfs | uimage-padhdr | \ - pad-rootfs | append-metadata | check-size + pad-rootfs | check-size | append-metadata endef TARGET_DEVICES += fon_fon2601 @@ -1010,20 +1010,6 @@ define Device/tplink_archer-c2-v1 endef TARGET_DEVICES += tplink_archer-c2-v1 -define Device/tplink_archer-c5-v4 - $(Device/tplink-v2) - SOC := mt7620a - TPLINK_FLASHLAYOUT := 8Mmtk - TPLINK_HWID := 0x04DA857C - TPLINK_HWREV := 0x0C000600 - TPLINK_HWREVADD := 0x04000000 - IMAGES += factory.bin - DEVICE_MODEL := Archer C5 - DEVICE_VARIANT := v4 - DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport kmod-mt76x2 kmod-switch-rtl8367b -endef -TARGET_DEVICES += tplink_archer-c5-v4 - define Device/tplink_archer-c50-v1 $(Device/tplink-v2) SOC := mt7620a @@ -1137,23 +1123,6 @@ define Device/xiaomi_miwifi-mini endef TARGET_DEVICES += xiaomi_miwifi-mini -define Device/xiaomi_miwifi-r3 - SOC := mt7620a - BLOCKSIZE := 128k - PAGESIZE := 2048 - KERNEL_SIZE := 4096k - IMAGE_SIZE := 32768k - UBINIZE_OPTS := -E 5 - IMAGES += kernel1.bin rootfs0.bin - IMAGE/kernel1.bin := append-kernel | check-size - IMAGE/rootfs0.bin := append-ubi | check-size - IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata - DEVICE_VENDOR := Xiaomi - DEVICE_MODEL := Mi Router R3 - DEVICE_PACKAGES := kmod-mt76x2 kmod-usb2 kmod-usb-ohci uboot-envtools -endef -TARGET_DEVICES += xiaomi_miwifi-r3 - define Device/youku_yk-l1 SOC := mt7620a IMAGE_SIZE := 32448k diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 581d9e789..671cc3ab0 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -12,20 +12,8 @@ DEVICE_VARS += ELECOM_HWNAME LINKSYS_HWNAME define Build/elecom-wrc-gs-factory $(eval product=$(word 1,$(1))) $(eval version=$(word 2,$(1))) - ( $(MKHASH) md5 $@ | tr -d '\n' ) >> $@ - ( \ - echo -n "ELECOM $(product) v$(version)" | \ - dd bs=32 count=1 conv=sync; \ - dd if=$@; \ - ) > $@.new - mv $@.new $@ - echo -n "MT7621_ELECOM_$(product)" >> $@ -endef - -define Build/elecom-wrc-factory - $(eval product=$(word 1,$(1))) - $(eval version=$(word 2,$(1))) - $(MKHASH) md5 $@ >> $@ + $(eval hash_opt=$(word 3,$(1))) + $(MKHASH) md5 $(hash_opt) $@ >> $@ ( \ echo -n "ELECOM $(product) v$(version)" | \ dd bs=32 count=1 conv=sync; \ @@ -102,7 +90,13 @@ define Build/zytrx-header mv $@.new $@ endef +define Device/dsa-migration + DEVICE_COMPAT_VERSION := 1.1 + DEVICE_COMPAT_MESSAGE := Config cannot be migrated from swconfig to DSA +endef + define Device/adslr_g7 + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := ADSLR DEVICE_MODEL := G7 @@ -111,6 +105,7 @@ endef TARGET_DEVICES += adslr_g7 define Device/afoundry_ew1200 + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := AFOUNDRY DEVICE_MODEL := EW1200 @@ -121,6 +116,7 @@ endef TARGET_DEVICES += afoundry_ew1200 define Device/alfa-network_quad-e4g + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := ALFA Network DEVICE_MODEL := Quad-E4G @@ -131,6 +127,7 @@ endef TARGET_DEVICES += alfa-network_quad-e4g define Device/ampedwireless_ally_common + $(Device/dsa-migration) DEVICE_VENDOR := Amped Wireless DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware uboot-envtools IMAGE_SIZE := 32768k @@ -157,6 +154,7 @@ endef TARGET_DEVICES += ampedwireless_ally-00x19k define Device/asiarf_ap7621-001 + $(Device/dsa-migration) IMAGE_SIZE := 16000k DEVICE_VENDOR := AsiaRF DEVICE_MODEL := AP7621-001 @@ -165,6 +163,7 @@ endef TARGET_DEVICES += asiarf_ap7621-001 define Device/asiarf_ap7621-nv1 + $(Device/dsa-migration) IMAGE_SIZE := 16000k DEVICE_VENDOR := AsiaRF DEVICE_MODEL := AP7621-NV1 @@ -173,6 +172,7 @@ endef TARGET_DEVICES += asiarf_ap7621-nv1 define Device/asus_rt-ac57u + $(Device/dsa-migration) DEVICE_VENDOR := ASUS DEVICE_MODEL := RT-AC57U IMAGE_SIZE := 16064k @@ -182,6 +182,7 @@ endef TARGET_DEVICES += asus_rt-ac57u define Device/asus_rt-ac65p + $(Device/dsa-migration) DEVICE_VENDOR := ASUS DEVICE_MODEL := RT-AC65P IMAGE_SIZE := 51200k @@ -198,6 +199,7 @@ endef TARGET_DEVICES += asus_rt-ac65p define Device/asus_rt-ac85p + $(Device/dsa-migration) DEVICE_VENDOR := ASUS DEVICE_MODEL := RT-AC85P IMAGE_SIZE := 51200k @@ -214,6 +216,7 @@ endef TARGET_DEVICES += asus_rt-ac85p define Device/asus_rt-n56u-b1 + $(Device/dsa-migration) DEVICE_VENDOR := ASUS DEVICE_MODEL := RT-N56U DEVICE_VARIANT := B1 @@ -224,6 +227,7 @@ endef TARGET_DEVICES += asus_rt-n56u-b1 define Device/buffalo_wsr-1166dhp + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE/sysupgrade.bin := trx | pad-rootfs | append-metadata IMAGE_SIZE := 15936k @@ -235,6 +239,7 @@ endef TARGET_DEVICES += buffalo_wsr-1166dhp define Device/buffalo_wsr-2533dhpl + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 7936k DEVICE_VENDOR := Buffalo @@ -247,6 +252,7 @@ endef TARGET_DEVICES += buffalo_wsr-2533dhpl define Device/buffalo_wsr-600dhp + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := Buffalo DEVICE_MODEL := WSR-600DHP @@ -256,6 +262,7 @@ endef TARGET_DEVICES += buffalo_wsr-600dhp define Device/cudy_wr1300 + $(Device/dsa-migration) IMAGE_SIZE := 15872k DEVICE_VENDOR := Cudy DEVICE_MODEL := WR1300 @@ -265,6 +272,7 @@ endef TARGET_DEVICES += cudy_wr1300 define Device/cudy_wr2100 + $(Device/dsa-migration) DEVICE_VENDOR := Cudy DEVICE_MODEL := WR2100 IMAGE_SIZE := 15872k @@ -274,22 +282,30 @@ endef TARGET_DEVICES += cudy_wr2100 define Device/dlink_dir-8xx-a1 + $(Device/dsa-migration) IMAGE_SIZE := 16000k DEVICE_VENDOR := D-Link - DEVICE_PACKAGES := kmod-mt7615d luci-app-mtwifi uboot-envtools -wpad-openssl + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware + KERNEL_INITRAMFS := $$(KERNEL) | uimage-padhdr 96 + IMAGES += factory.bin + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | uimage-padhdr 96 |\ + pad-rootfs | check-size | append-metadata + IMAGE/factory.bin := append-kernel | append-rootfs | uimage-padhdr 96 |\ + check-size endef define Device/dlink_dir-8xx-r1 + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := D-Link - DEVICE_PACKAGES := kmod-mt7615d luci-app-mtwifi -wpad-openssl + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware KERNEL_INITRAMFS := $$(KERNEL) - IMAGES += factory.bin - IMAGE/sysupgrade.bin := append-kernel | append-rootfs |\ - pad-rootfs | append-metadata | check-size + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | \ + check-size | append-metadata endef define Device/dlink_dir-xx60-a1 + $(Device/dsa-migration) BLOCKSIZE := 128k PAGESIZE := 2048 KERNEL_SIZE := 4096k @@ -326,7 +342,23 @@ define Device/dlink_dir-2660-a1 endef TARGET_DEVICES += dlink_dir-2660-a1 +define Device/dlink_dir-853-a3 + $(Device/dlink_dir-xx60-a1) + DEVICE_MODEL := DIR-853 + DEVICE_VARIANT := A3 +endef +TARGET_DEVICES += dlink_dir-853-a3 + +define Device/dlink_dir-853-r1 + $(Device/dlink_dir-8xx-r1) + DEVICE_MODEL := DIR-853 + DEVICE_VARIANT := R1 + DEVICE_PACKAGES += kmod-usb3 kmod-usb-ledtrig-usbport +endef +TARGET_DEVICES += dlink_dir-853-r1 + define Device/dlink_dir-860l-b1 + $(Device/dsa-migration) $(Device/seama) BLOCKSIZE := 64k SEAMA_SIGNATURE := wrgac13_dlink.2013gui_dir860lb @@ -369,23 +401,26 @@ define Device/dlink_dir-882-r1 DEVICE_MODEL := DIR-882 DEVICE_VARIANT := R1 DEVICE_PACKAGES += kmod-usb3 kmod-usb-ledtrig-usbport + IMAGES += factory.bin IMAGE/factory.bin := append-kernel | append-rootfs | check-size | \ - sign-dlink-ru 57c5375741c30ca9ebcb36713db4ba51 \ - ab0dff19af8842cdb70a86b4b68d23f7 + sign-dlink-ru 57c5375741c30ca9ebcb36713db4ba51 \ + ab0dff19af8842cdb70a86b4b68d23f7 endef TARGET_DEVICES += dlink_dir-882-r1 define Device/d-team_newifi-d2 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 32448k DEVICE_VENDOR := Newifi DEVICE_MODEL := D2 - DEVICE_PACKAGES := kmod-mt7603e kmod-mt76x2e kmod-usb3 \ - kmod-usb-ledtrig-usbport luci-app-mtwifi -wpad-openssl + DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \ + kmod-usb-ledtrig-usbport endef TARGET_DEVICES += d-team_newifi-d2 define Device/d-team_pbr-m1 + $(Device/dsa-migration) IMAGE_SIZE := 32448k DEVICE_VENDOR := PandoraBox DEVICE_MODEL := PBR-M1 @@ -396,6 +431,7 @@ endef TARGET_DEVICES += d-team_pbr-m1 define Device/edimax_ra21s + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := Edimax @@ -410,6 +446,7 @@ endef TARGET_DEVICES += edimax_ra21s define Device/edimax_re23s + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 15680k DEVICE_VENDOR := Edimax @@ -418,7 +455,7 @@ define Device/edimax_re23s DEVICE_ALT0_MODEL := Gemini RE23S IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ edimax-header -s CSYS -m RN76 -f 0x70000 -S 0x01100000 | pad-rootfs | \ - append-metadata | check-size + check-size | append-metadata IMAGES += factory.bin IMAGE/factory.bin := append-kernel | append-rootfs | \ edimax-header -s CSYS -m RN76 -f 0x70000 -S 0x01100000 | pad-rootfs | \ @@ -428,6 +465,7 @@ endef TARGET_DEVICES += edimax_re23s define Device/edimax_rg21s + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := Edimax @@ -440,22 +478,25 @@ endef TARGET_DEVICES += edimax_rg21s define Device/elecom_wrc-1167ghbk2-s + $(Device/dsa-migration) IMAGE_SIZE := 15488k DEVICE_VENDOR := ELECOM DEVICE_MODEL := WRC-1167GHBK2-S IMAGES += factory.bin IMAGE/factory.bin := $$(sysupgrade_bin) | check-size | \ - elecom-wrc-factory WRC-1167GHBK2-S 0.00 + elecom-wrc-gs-factory WRC-1167GHBK2-S 0.00 DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware endef TARGET_DEVICES += elecom_wrc-1167ghbk2-s define Device/elecom_wrc-gs + $(Device/dsa-migration) $(Device/uimage-lzma-loader) DEVICE_VENDOR := ELECOM IMAGES += factory.bin IMAGE/factory.bin := $$(sysupgrade_bin) | check-size | \ - elecom-wrc-gs-factory $$$$(ELECOM_HWNAME) 0.00 + elecom-wrc-gs-factory $$$$(ELECOM_HWNAME) 0.00 -N | \ + append-string MT7621_ELECOM_$$$$(ELECOM_HWNAME) DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware endef @@ -507,6 +548,20 @@ define Device/elecom_wrc-1900gst endef TARGET_DEVICES += elecom_wrc-1900gst +define Device/elecom_wrc-2533ghbk-i + $(Device/dsa-migration) + $(Device/uimage-lzma-loader) + DEVICE_VENDOR := ELECOM + DEVICE_MODEL := WRC-2533GHBK-I + IMAGE_SIZE := 9856k + IMAGES += factory.bin + IMAGE/factory.bin := $$(sysupgrade_bin) | check-size | \ + elx-header 0107002d 8844A2D168B45A2D | \ + elecom-product-header WRC-2533GHBK-I + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware +endef +TARGET_DEVICES += elecom_wrc-2533ghbk-i + define Device/elecom_wrc-2533gst $(Device/elecom_wrc-gs) IMAGE_SIZE := 11264k @@ -524,6 +579,7 @@ endef TARGET_DEVICES += elecom_wrc-2533gst2 define Device/firefly_firewrt + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := Firefly DEVICE_MODEL := FireWRT @@ -533,23 +589,26 @@ endef TARGET_DEVICES += firefly_firewrt define Device/gehua_ghl-r-001 + $(Device/dsa-migration) IMAGE_SIZE := 32448k DEVICE_VENDOR := GeHua DEVICE_MODEL := GHL-R-001 - DEVICE_PACKAGES := kmod-mt7603e kmod-mt76x2e kmod-usb3 \ - kmod-usb-ledtrig-usbport luci-app-mtwifi -wpad-openssl + DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \ + kmod-usb-ledtrig-usbport endef TARGET_DEVICES += gehua_ghl-r-001 define Device/glinet_gl-mt1300 + $(Device/dsa-migration) IMAGE_SIZE := 32448k DEVICE_VENDOR := GL.iNet DEVICE_MODEL := GL-MT1300 - DEVICE_PACKAGES := kmod-mt7615d kmod-usb3 luci-app-mtwifi -wpad-openssl + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 endef TARGET_DEVICES += glinet_gl-mt1300 define Device/gnubee_gb-pc1 + $(Device/dsa-migration) DEVICE_VENDOR := GnuBee DEVICE_MODEL := Personal Cloud One DEVICE_PACKAGES := kmod-ata-ahci kmod-usb3 kmod-sdhci-mt7620 -wpad-openssl @@ -558,6 +617,7 @@ endef TARGET_DEVICES += gnubee_gb-pc1 define Device/gnubee_gb-pc2 + $(Device/dsa-migration) DEVICE_VENDOR := GnuBee DEVICE_MODEL := Personal Cloud Two DEVICE_PACKAGES := kmod-ata-ahci kmod-usb3 kmod-sdhci-mt7620 -wpad-openssl @@ -566,6 +626,7 @@ endef TARGET_DEVICES += gnubee_gb-pc2 define Device/hiwifi_hc5962 + $(Device/dsa-migration) BLOCKSIZE := 128k PAGESIZE := 2048 KERNEL_SIZE := 4096k @@ -582,6 +643,7 @@ endef TARGET_DEVICES += hiwifi_hc5962 define Device/iodata_wn-ax1167gr + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 15552k KERNEL_INITRAMFS := $$(KERNEL) | \ @@ -593,6 +655,7 @@ endef TARGET_DEVICES += iodata_wn-ax1167gr define Device/iodata_nand + $(Device/dsa-migration) DEVICE_VENDOR := I-O DATA BLOCKSIZE := 128k PAGESIZE := 2048 @@ -647,6 +710,7 @@ endef TARGET_DEVICES += iodata_wn-dx1200gr define Device/iodata_wn-gx300gr + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 7616k DEVICE_VENDOR := I-O DATA @@ -656,6 +720,7 @@ endef TARGET_DEVICES += iodata_wn-gx300gr define Device/iodata_wnpr2600g + $(Device/dsa-migration) $(Device/uimage-lzma-loader) DEVICE_VENDOR := I-O DATA DEVICE_MODEL := WNPR2600G @@ -668,15 +733,18 @@ endef TARGET_DEVICES += iodata_wnpr2600g define Device/iptime_a6ns-m + $(Device/dsa-migration) IMAGE_SIZE := 16128k UIMAGE_NAME := a6nm DEVICE_VENDOR := ipTIME DEVICE_MODEL := A6ns-M - DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 kmod-usb-ledtrig-usbport + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 \ + kmod-usb-ledtrig-usbport endef TARGET_DEVICES += iptime_a6ns-m define Device/iptime_a8004t + $(Device/dsa-migration) IMAGE_SIZE := 16128k UIMAGE_NAME := a8004t DEVICE_VENDOR := ipTIME @@ -686,17 +754,20 @@ endef TARGET_DEVICES += iptime_a8004t define Device/jcg_jhr-ac876m + $(Device/dsa-migration) IMAGE_SIZE := 16064k IMAGES += factory.bin IMAGE/factory.bin := $$(sysupgrade_bin) | check-size | jcg-header 89.1 JCG_MAXSIZE := 16064k DEVICE_VENDOR := JCG DEVICE_MODEL := JHR-AC876M - DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 kmod-usb-ledtrig-usbport + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 \ + kmod-usb-ledtrig-usbport endef TARGET_DEVICES += jcg_jhr-ac876m define Device/jcg_q20 + $(Device/dsa-migration) BLOCKSIZE := 128k PAGESIZE := 2048 UBINIZE_OPTS := -E 5 @@ -713,6 +784,7 @@ endef TARGET_DEVICES += jcg_q20 define Device/jcg_y2 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k IMAGES += factory.bin @@ -720,20 +792,12 @@ define Device/jcg_y2 JCG_MAXSIZE := 16064k DEVICE_VENDOR := JCG DEVICE_MODEL := Y2 - DEVICE_PACKAGES := kmod-mt7615d kmod-usb3 luci-app-mtwifi -wpad-openssl + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 endef TARGET_DEVICES += jcg_y2 -define Device/jdcloud_re-sp-01b - IMAGE_SIZE := 27328k - DEVICE_VENDOR := JDCloud - DEVICE_MODEL := RE-SP-01B - DEVICE_PACKAGES := kmod-fs-ext4 kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware \ - kmod-sdhci-mt7620 kmod-usb3 wpad-openssl -endef -TARGET_DEVICES += jdcloud_re-sp-01b - define Device/lenovo_newifi-d1 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 32448k DEVICE_VENDOR := Newifi @@ -745,6 +809,7 @@ endef TARGET_DEVICES += lenovo_newifi-d1 define Device/linksys_e5600 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) BLOCKSIZE := 128k PAGESIZE := 2048 @@ -763,16 +828,18 @@ endef TARGET_DEVICES += linksys_e5600 define Device/linksys_ea7xxx + $(Device/dsa-migration) $(Device/uimage-lzma-loader) BLOCKSIZE := 128k PAGESIZE := 2048 KERNEL_SIZE := 4096k IMAGE_SIZE := 36864k DEVICE_VENDOR := Linksys - DEVICE_PACKAGES := kmod-usb3 kmod-mt7615e kmod-mt7615-firmware uboot-envtools + DEVICE_PACKAGES := kmod-usb3 kmod-mt7615e kmod-mt7615-firmware \ + uboot-envtools UBINIZE_OPTS := -E 5 IMAGES := sysupgrade.bin factory.bin - IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata | check-size + IMAGE/sysupgrade.bin := sysupgrade-tar | check-size | append-metadata IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | \ append-ubi | check-size | linksys-image type=$$$$(LINKSYS_HWNAME) endef @@ -785,6 +852,15 @@ define Device/linksys_ea7300-v1 endef TARGET_DEVICES += linksys_ea7300-v1 +define Device/linksys_ea7300-v2 + $(Device/linksys_ea7xxx) + DEVICE_MODEL := EA7300 + DEVICE_VARIANT := v2 + LINKSYS_HWNAME := EA7300v2 + DEVICE_PACKAGES += kmod-mt7603 +endef +TARGET_DEVICES += linksys_ea7300-v2 + define Device/linksys_ea7500-v2 $(Device/linksys_ea7xxx) DEVICE_MODEL := EA7500 @@ -801,7 +877,16 @@ define Device/linksys_ea8100-v1 endef TARGET_DEVICES += linksys_ea8100-v1 +define Device/linksys_ea8100-v2 + $(Device/linksys_ea7xxx) + DEVICE_MODEL := EA8100 + DEVICE_VARIANT := v2 + LINKSYS_HWNAME := EA8100v2 +endef +TARGET_DEVICES += linksys_ea8100-v2 + define Device/linksys_re6500 + $(Device/dsa-migration) IMAGE_SIZE := 7872k DEVICE_VENDOR := Linksys DEVICE_MODEL := RE6500 @@ -811,6 +896,7 @@ endef TARGET_DEVICES += linksys_re6500 define Device/mediatek_ap-mt7621a-v60 + $(Device/dsa-migration) IMAGE_SIZE := 7872k DEVICE_VENDOR := Mediatek DEVICE_MODEL := AP-MT7621A-V60 EVB @@ -819,6 +905,7 @@ endef TARGET_DEVICES += mediatek_ap-mt7621a-v60 define Device/mediatek_mt7621-eval-board + $(Device/dsa-migration) BLOCKSIZE := 64k IMAGE_SIZE := 15104k DEVICE_VENDOR := MediaTek @@ -829,6 +916,7 @@ endef TARGET_DEVICES += mediatek_mt7621-eval-board define Device/MikroTik + $(Device/dsa-migration) DEVICE_VENDOR := MikroTik BLOCKSIZE := 64k IMAGE_SIZE := 16128k @@ -836,8 +924,8 @@ define Device/MikroTik KERNEL_NAME := vmlinuz KERNEL := kernel-bin | append-dtb-elf IMAGE/sysupgrade.bin := append-kernel | kernel2minor -s 1024 | \ - pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | append-metadata | \ - check-size + pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size | \ + append-metadata endef define Device/mikrotik_routerboard-750gr3 @@ -871,16 +959,8 @@ define Device/mikrotik_routerboard-m33g endef TARGET_DEVICES += mikrotik_routerboard-m33g -define Device/motorola_mr2600 - IMAGE_SIZE := 16064k - DEVICE_VENDOR := Motorola - DEVICE_MODEL := MR2600 - DEVICE_PACKAGES := kmod-mt7615d kmod-usb3 kmod-usb-ledtrig-usbport \ - luci-app-mtwifi -wpad-openssl uboot-envtools -endef -TARGET_DEVICES += motorola_mr2600 - define Device/mqmaker_witi + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := MQmaker @@ -892,6 +972,7 @@ endef TARGET_DEVICES += mqmaker_witi define Device/mtc_wr1201 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16000k DEVICE_VENDOR := MTC @@ -903,6 +984,7 @@ endef TARGET_DEVICES += mtc_wr1201 define Device/netgear_ex6150 + $(Device/dsa-migration) DEVICE_VENDOR := NETGEAR DEVICE_MODEL := EX6150 DEVICE_PACKAGES := kmod-mt76x2 @@ -914,6 +996,7 @@ endef TARGET_DEVICES += netgear_ex6150 define Device/netgear_sercomm_nand + $(Device/dsa-migration) $(Device/uimage-lzma-loader) BLOCKSIZE := 128k PAGESIZE := 2048 @@ -943,6 +1026,7 @@ define Device/netgear_r6220 endef TARGET_DEVICES += netgear_r6220 + define Device/netgear_r6260 $(Device/netgear_sercomm_nand) DEVICE_MODEL := R6260 @@ -1035,6 +1119,7 @@ endef TARGET_DEVICES += netgear_wac124 define Device/netgear_wndr3700-v5 + $(Device/dsa-migration) $(Device/netgear_sercomm_nor) $(Device/uimage-lzma-loader) IMAGE_SIZE := 15232k @@ -1052,6 +1137,7 @@ endef TARGET_DEVICES += netgear_wndr3700-v5 define Device/netis_wf2881 + $(Device/dsa-migration) BLOCKSIZE := 128k PAGESIZE := 2048 FILESYSTEMS := squashfs @@ -1071,15 +1157,17 @@ endef TARGET_DEVICES += netis_wf2881 define Device/phicomm_k2p + $(Device/dsa-migration) IMAGE_SIZE := 15744k DEVICE_VENDOR := Phicomm DEVICE_MODEL := K2P SUPPORTED_DEVICES += k2p - DEVICE_PACKAGES := kmod-mt7615d luci-app-mtwifi -wpad-openssl + DEVICE_PACKAGES := -luci-newapi -wpad-openssl kmod-mt7615d_dbdc luci-app-adbyby-plus xray-core UnblockNeteaseMusicGo endef TARGET_DEVICES += phicomm_k2p define Device/planex_vr500 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 65216k DEVICE_VENDOR := Planex @@ -1090,6 +1178,7 @@ endef TARGET_DEVICES += planex_vr500 define Device/samknows_whitebox-v8 + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := SamKnows DEVICE_MODEL := Whitebox 8 @@ -1114,6 +1203,7 @@ endef TARGET_DEVICES += sercomm_na502 define Device/storylink_sap-g3200u3 + $(Device/dsa-migration) IMAGE_SIZE := 7872k DEVICE_VENDOR := STORYLiNK DEVICE_MODEL := SAP-G3200U3 @@ -1123,6 +1213,7 @@ endef TARGET_DEVICES += storylink_sap-g3200u3 define Device/telco-electronics_x1 + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := Telco Electronics DEVICE_MODEL := X1 @@ -1130,17 +1221,31 @@ define Device/telco-electronics_x1 endef TARGET_DEVICES += telco-electronics_x1 +define Device/tenbay_t-mb5eu-v01 + $(Device/dsa-migration) + DEVICE_VENDOR := Tenbay + DEVICE_MODEL := T-MB5EU-V01 + DEVICE_DTS_CONFIG := config@1 + DEVICE_PACKAGES += kmod-mt7915e kmod-usb3 + KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb + IMAGE_SIZE := 15808k + SUPPORTED_DEVICES += mt7621-dm2-t-mb5eu-v01-nor +endef +TARGET_DEVICES += tenbay_t-mb5eu-v01 + define Device/thunder_timecloud + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := Thunder DEVICE_MODEL := Timecloud - DEVICE_PACKAGES := kmod-usb3 kmod-sdhci-mt7620 -wpad-openssl + DEVICE_PACKAGES := kmod-usb3 -wpad-openssl SUPPORTED_DEVICES += timecloud endef TARGET_DEVICES += thunder_timecloud define Device/totolink_a7000r + $(Device/dsa-migration) IMAGE_SIZE := 16064k UIMAGE_NAME := C8340R1C-9999 DEVICE_VENDOR := TOTOLINK @@ -1149,7 +1254,18 @@ define Device/totolink_a7000r endef TARGET_DEVICES += totolink_a7000r +define Device/totolink_x5000r + $(Device/dsa-migration) + IMAGE_SIZE := 16064k + UIMAGE_NAME := C8343R-9999 + DEVICE_VENDOR := TOTOLINK + DEVICE_MODEL := X5000R + DEVICE_PACKAGES := kmod-mt7915e +endef +TARGET_DEVICES += totolink_x5000r + define Device/tplink_archer-a6-v3 + $(Device/dsa-migration) $(Device/tplink-safeloader) DEVICE_MODEL := Archer A6 DEVICE_VARIANT := V3 @@ -1162,6 +1278,7 @@ endef TARGET_DEVICES += tplink_archer-a6-v3 define Device/tplink_archer-c6-v3 + $(Device/dsa-migration) $(Device/tplink-safeloader) DEVICE_MODEL := Archer C6 DEVICE_VARIANT := V3 @@ -1174,6 +1291,7 @@ endef TARGET_DEVICES += tplink_archer-c6-v3 define Device/tplink_archer-c6u-v1 + $(Device/dsa-migration) $(Device/tplink-safeloader) DEVICE_MODEL := Archer C6U DEVICE_VARIANT := v1 @@ -1187,6 +1305,7 @@ endef TARGET_DEVICES += tplink_archer-c6u-v1 define Device/tplink_eap235-wall-v1 + $(Device/dsa-migration) $(Device/tplink-safeloader) DEVICE_MODEL := EAP235-Wall DEVICE_VARIANT := v1 @@ -1199,6 +1318,7 @@ endef TARGET_DEVICES += tplink_eap235-wall-v1 define Device/tplink_re350-v1 + $(Device/dsa-migration) $(Device/tplink-safeloader) DEVICE_MODEL := RE350 DEVICE_VARIANT := v1 @@ -1210,6 +1330,7 @@ endef TARGET_DEVICES += tplink_re350-v1 define Device/tplink_re500-v1 + $(Device/dsa-migration) $(Device/tplink-safeloader) DEVICE_MODEL := RE500 DEVICE_VARIANT := v1 @@ -1220,6 +1341,7 @@ endef TARGET_DEVICES += tplink_re500-v1 define Device/tplink_re650-v1 + $(Device/dsa-migration) $(Device/tplink-safeloader) DEVICE_MODEL := RE650 DEVICE_VARIANT := v1 @@ -1230,6 +1352,7 @@ endef TARGET_DEVICES += tplink_re650-v1 define Device/ubnt_edgerouter_common + $(Device/dsa-migration) $(Device/uimage-lzma-loader) DEVICE_VENDOR := Ubiquiti IMAGE_SIZE := 256768k @@ -1256,7 +1379,19 @@ define Device/ubnt_edgerouter-x-sfp endef TARGET_DEVICES += ubnt_edgerouter-x-sfp +define Device/ubnt_unifi-6-lite + $(Device/dsa-migration) + DEVICE_VENDOR := Ubiquiti + DEVICE_MODEL := UniFi 6 Lite + DEVICE_DTS_CONFIG := config@1 + DEVICE_PACKAGES += kmod-mt7603 kmod-mt7915e + KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb + IMAGE_SIZE := 15424k +endef +TARGET_DEVICES += ubnt_unifi-6-lite + define Device/ubnt_unifi-nanohd + $(Device/dsa-migration) DEVICE_VENDOR := Ubiquiti DEVICE_MODEL := UniFi nanoHD DEVICE_PACKAGES += kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware @@ -1265,6 +1400,7 @@ endef TARGET_DEVICES += ubnt_unifi-nanohd define Device/unielec_u7621-01-16m + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := UniElec @@ -1275,6 +1411,7 @@ endef TARGET_DEVICES += unielec_u7621-01-16m define Device/unielec_u7621-06-16m + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := UniElec @@ -1286,6 +1423,7 @@ endef TARGET_DEVICES += unielec_u7621-06-16m define Device/unielec_u7621-06-64m + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 65216k DEVICE_VENDOR := UniElec @@ -1297,6 +1435,7 @@ endef TARGET_DEVICES += unielec_u7621-06-64m define Device/wavlink_wl-wn531a6 + $(Device/dsa-migration) DEVICE_VENDOR := Wavlink DEVICE_MODEL := WL-WN531A6 DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware kmod-usb3 @@ -1305,6 +1444,7 @@ endef TARGET_DEVICES += wavlink_wl-wn531a6 define Device/wevo_11acnas + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k UIMAGE_NAME := 11AC-NAS-Router(0.0.0) @@ -1317,6 +1457,7 @@ endef TARGET_DEVICES += wevo_11acnas define Device/wevo_w2914ns-v2 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k UIMAGE_NAME := W2914NS-V2(0.0.0) @@ -1330,6 +1471,7 @@ endef TARGET_DEVICES += wevo_w2914ns-v2 define Device/winstars_ws-wn583a6 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 7872k DEVICE_VENDOR := Winstars @@ -1341,40 +1483,45 @@ define Device/winstars_ws-wn583a6 endef TARGET_DEVICES += winstars_ws-wn583a6 -define Device/xiaomi_mir3g +define Device/xiaomi_nand_separate + $(Device/dsa-migration) $(Device/uimage-lzma-loader) + DEVICE_VENDOR := Xiaomi + DEVICE_PACKAGES := uboot-envtools BLOCKSIZE := 128k PAGESIZE := 2048 KERNEL_SIZE := 4096k - IMAGE_SIZE := 124416k UBINIZE_OPTS := -E 5 IMAGES += kernel1.bin rootfs0.bin IMAGE/kernel1.bin := append-kernel IMAGE/rootfs0.bin := append-ubi | check-size IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata - DEVICE_VENDOR := Xiaomi - DEVICE_MODEL := Mi Router 3G - SUPPORTED_DEVICES += R3G - SUPPORTED_DEVICES += mir3g - DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \ - kmod-usb-ledtrig-usbport uboot-envtools endef -TARGET_DEVICES += xiaomi_mir3g -define Device/xiaomi_mir3g-v2 +define Device/xiaomi_mi-router-3g + $(Device/xiaomi_nand_separate) + DEVICE_MODEL := Mi Router 3G + IMAGE_SIZE := 124416k + DEVICE_PACKAGES += kmod-mt7603 kmod-mt76x2 kmod-usb3 \ + kmod-usb-ledtrig-usbport + SUPPORTED_DEVICES += R3G mir3g xiaomi,mir3g +endef +TARGET_DEVICES += xiaomi_mi-router-3g + +define Device/xiaomi_mi-router-3g-v2 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 14848k DEVICE_VENDOR := Xiaomi DEVICE_MODEL := Mi Router 3G DEVICE_VARIANT := v2 - DEVICE_ALT0_VENDOR := Xiaomi - DEVICE_ALT0_MODEL := Mi Router 4A - DEVICE_ALT0_VARIANT := Gigabit Edition DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 + SUPPORTED_DEVICES += xiaomi,mir3g-v2 endef -TARGET_DEVICES += xiaomi_mir3g-v2 +TARGET_DEVICES += xiaomi_mi-router-3g-v2 -define Device/xiaomi_mir3p +define Device/xiaomi_mi-router-3-pro + $(Device/dsa-migration) $(Device/uimage-lzma-loader) BLOCKSIZE := 128k PAGESIZE := 2048 @@ -1387,51 +1534,36 @@ define Device/xiaomi_mir3p IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \ check-size - DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 kmod-usb-ledtrig-usbport \ - uboot-envtools + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3 \ + kmod-usb-ledtrig-usbport uboot-envtools + SUPPORTED_DEVICES += xiaomi,mir3p endef -TARGET_DEVICES += xiaomi_mir3p +TARGET_DEVICES += xiaomi_mi-router-3-pro -define Device/xiaomi_mir4 - $(Device/uimage-lzma-loader) - BLOCKSIZE := 128k - PAGESIZE := 2048 - KERNEL_SIZE := 4096k - IMAGE_SIZE := 124416k - UBINIZE_OPTS := -E 5 - IMAGES += kernel1.bin rootfs0.bin - IMAGE/kernel1.bin := append-kernel - IMAGE/rootfs0.bin := append-ubi | check-size - IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata - DEVICE_VENDOR := Xiaomi +define Device/xiaomi_mi-router-4 + $(Device/xiaomi_nand_separate) DEVICE_MODEL := Mi Router 4 - DEVICE_PACKAGES := kmod-mt7603e kmod-mt76x2e luci-app-mtwifi \ - uboot-envtools -wpad-openssl + IMAGE_SIZE := 124416k + DEVICE_PACKAGES += kmod-mt7603 kmod-mt76x2 endef -TARGET_DEVICES += xiaomi_mir4 +TARGET_DEVICES += xiaomi_mi-router-4 -define Device/xiaomi-ac2100 +define Device/xiaomi_mi-router-4a-gigabit + $(Device/dsa-migration) $(Device/uimage-lzma-loader) - BLOCKSIZE := 128k - PAGESIZE := 2048 - KERNEL_SIZE := 4096k - IMAGE_SIZE := 120320k - UBINIZE_OPTS := -E 5 - IMAGES += kernel1.bin rootfs0.bin factory.bin breed-factory.bin - IMAGE/kernel1.bin := append-kernel - IMAGE/rootfs0.bin := append-ubi | check-size - IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata - IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | check-size - IMAGE/breed-factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | \ - append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | check-size + IMAGE_SIZE := 14848k DEVICE_VENDOR := Xiaomi - DEVICE_PACKAGES := kmod-mt7603e kmod-mt7615d luci-app-mtwifi \ - uboot-envtools -wpad-openssl + DEVICE_MODEL := Mi Router 4A + DEVICE_VARIANT := Gigabit Edition + DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 endef +TARGET_DEVICES += xiaomi_mi-router-4a-gigabit define Device/xiaomi_mi-router-ac2100 - $(Device/xiaomi-ac2100) + $(Device/xiaomi_nand_separate) DEVICE_MODEL := Mi Router AC2100 + IMAGE_SIZE := 120320k + DEVICE_PACKAGES += kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware endef TARGET_DEVICES += xiaomi_mi-router-ac2100 @@ -1446,18 +1578,21 @@ define Device/xiaomi_mi-router-cr6606 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | check-size DEVICE_VENDOR := Xiaomi - DEVICE_MODEL := Mi Router CR6606 + DEVICE_MODEL := Mi Router CR6606/CR6608/CR6609 DEVICE_PACKAGES += kmod-mt7915e wpad-openssl uboot-envtools endef TARGET_DEVICES += xiaomi_mi-router-cr6606 define Device/xiaomi_redmi-router-ac2100 - $(Device/xiaomi-ac2100) + $(Device/xiaomi_nand_separate) DEVICE_MODEL := Redmi Router AC2100 + IMAGE_SIZE := 120320k + DEVICE_PACKAGES += kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware endef TARGET_DEVICES += xiaomi_redmi-router-ac2100 define Device/xiaoyu_xy-c5 + $(Device/dsa-migration) IMAGE_SIZE := 32448k DEVICE_VENDOR := XiaoYu DEVICE_MODEL := XY-C5 @@ -1466,6 +1601,7 @@ endef TARGET_DEVICES += xiaoyu_xy-c5 define Device/xzwifi_creativebox-v1 + $(Device/dsa-migration) IMAGE_SIZE := 32448k DEVICE_VENDOR := CreativeBox DEVICE_MODEL := v1 @@ -1475,6 +1611,7 @@ endef TARGET_DEVICES += xzwifi_creativebox-v1 define Device/youhua_wr1200js + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := YouHua DEVICE_MODEL := WR1200JS @@ -1484,15 +1621,17 @@ endef TARGET_DEVICES += youhua_wr1200js define Device/youku_yk-l2 + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := Youku DEVICE_MODEL := YK-L2 - DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 kmod-sdhci-mt7620 \ + DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \ kmod-usb-ledtrig-usbport endef TARGET_DEVICES += youku_yk-l2 define Device/zbtlink_zbt-we1326 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := Zbtlink @@ -1502,16 +1641,8 @@ define Device/zbtlink_zbt-we1326 endef TARGET_DEVICES += zbtlink_zbt-we1326 -define Device/zbtlink_zbt-wg108 - IMAGE_SIZE := 32448k - DEVICE_VENDOR := Zbtlink - DEVICE_MODEL := ZBT-WG108 - DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb2 kmod-sdhci-mt7620 - SUPPORTED_DEVICES += zbt-wg108 -endef -TARGET_DEVICES += zbtlink_zbt-wg108 - define Device/zbtlink_zbt-we3526 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := Zbtlink @@ -1522,6 +1653,7 @@ endef TARGET_DEVICES += zbtlink_zbt-we3526 define Device/zbtlink_zbt-wg2626 + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := Zbtlink @@ -1533,6 +1665,7 @@ endef TARGET_DEVICES += zbtlink_zbt-wg2626 define Device/zbtlink_zbt-wg3526-16m + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := Zbtlink @@ -1545,6 +1678,7 @@ endef TARGET_DEVICES += zbtlink_zbt-wg3526-16m define Device/zbtlink_zbt-wg3526-32m + $(Device/dsa-migration) $(Device/uimage-lzma-loader) IMAGE_SIZE := 32448k DEVICE_VENDOR := Zbtlink @@ -1557,6 +1691,7 @@ endef TARGET_DEVICES += zbtlink_zbt-wg3526-32m define Device/zio_freezio + $(Device/dsa-migration) IMAGE_SIZE := 16064k DEVICE_VENDOR := ZIO DEVICE_MODEL := FREEZIO @@ -1566,6 +1701,7 @@ endef TARGET_DEVICES += zio_freezio define Device/zyxel_nr7101 + $(Device/dsa-migration) BLOCKSIZE := 128k PAGESIZE := 2048 UBINIZE_OPTS := -E 5 @@ -1580,6 +1716,7 @@ endef TARGET_DEVICES += zyxel_nr7101 define Device/zyxel_wap6805 + $(Device/dsa-migration) BLOCKSIZE := 128k PAGESIZE := 2048 KERNEL_SIZE := 4096k diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk index b01c974bd..3f6f842db 100644 --- a/target/linux/ramips/image/mt76x8.mk +++ b/target/linux/ramips/image/mt76x8.mk @@ -176,7 +176,6 @@ define Device/hiwifi_hc5661a DEVICE_VENDOR := HiWiFi DEVICE_MODEL := HC5661A SUPPORTED_DEVICES += hc5661a - DEVICE_PACKAGES := kmod-sdhci-mt7620 endef TARGET_DEVICES += hiwifi_hc5661a @@ -184,7 +183,7 @@ define Device/hiwifi_hc5761a IMAGE_SIZE := 15808k DEVICE_VENDOR := HiWiFi DEVICE_MODEL := HC5761A - DEVICE_PACKAGES := kmod-mt76x0e kmod-usb2 kmod-usb-ohci kmod-sdhci-mt7620 + DEVICE_PACKAGES := kmod-mt76x0e kmod-usb2 kmod-usb-ohci endef TARGET_DEVICES += hiwifi_hc5761a @@ -270,6 +269,15 @@ define Device/mercury_mac1200r-v2 endef TARGET_DEVICES += mercury_mac1200r-v2 +define Device/minew_g1-c + IMAGE_SIZE := 15744k + DEVICE_VENDOR := Minew + DEVICE_MODEL := G1-C + DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport kmod-usb-serial-cp210x + SUPPORTED_DEVICES += minew-g1c +endef +TARGET_DEVICES += minew_g1-c + define Device/netgear_r6020 $(Device/netgear_sercomm_nor) IMAGE_SIZE := 7104k @@ -535,6 +543,22 @@ define Device/tplink_tl-mr6400-v4 endef TARGET_DEVICES += tplink_tl-mr6400-v4 +define Device/tplink_tl-mr6400-v5 + $(Device/tplink-v2) + IMAGE_SIZE := 7808k + DEVICE_MODEL := TL-MR6400 + DEVICE_VARIANT := v5 + TPLINK_FLASHLAYOUT := 8Mmtk + TPLINK_HWID := 0x64000005 + TPLINK_HWREV := 0x5 + TPLINK_HWREVADD := 0x5 + DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport \ + kmod-usb-serial-option kmod-usb-net-qmi-wwan uqmi + IMAGES := sysupgrade.bin tftp-recovery.bin + IMAGE/tftp-recovery.bin := pad-extra 128k | $$(IMAGE/factory.bin) +endef +TARGET_DEVICES += tplink_tl-mr6400-v5 + define Device/tplink_tl-wa801nd-v5 $(Device/tplink-v2) IMAGE_SIZE := 7808k @@ -774,14 +798,15 @@ define Device/wrtnode_wrtnode2r endef TARGET_DEVICES += wrtnode_wrtnode2r -define Device/xiaomi_mir4a-100m +define Device/xiaomi_mi-router-4a-100m IMAGE_SIZE := 14976k DEVICE_VENDOR := Xiaomi DEVICE_MODEL := Mi Router 4A DEVICE_VARIANT := 100M Edition DEVICE_PACKAGES := kmod-mt76x2 + SUPPORTED_DEVICES += xiaomi,mir4a-100m endef -TARGET_DEVICES += xiaomi_mir4a-100m +TARGET_DEVICES += xiaomi_mi-router-4a-100m define Device/xiaomi_mi-router-4c IMAGE_SIZE := 14976k diff --git a/target/linux/ramips/image/rt305x.mk b/target/linux/ramips/image/rt305x.mk index 194550684..6c339dcba 100644 --- a/target/linux/ramips/image/rt305x.mk +++ b/target/linux/ramips/image/rt305x.mk @@ -500,7 +500,7 @@ define Device/edimax_3g-6200n IMAGE_SIZE := 3648k IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ edimax-header -s CSYS -m 3G62 -f 0x50000 -S 0x01100000 | pad-rootfs | \ - append-metadata | check-size + check-size | append-metadata DEVICE_VENDOR := Edimax DEVICE_MODEL := 3g-6200n SUPPORTED_DEVICES += 3g-6200n @@ -513,7 +513,7 @@ define Device/edimax_3g-6200nl IMAGE_SIZE := 3648k IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ edimax-header -s CSYS -m 3G62 -f 0x50000 -S 0x01100000 | pad-rootfs | \ - append-metadata | check-size + check-size | append-metadata DEVICE_VENDOR := Edimax DEVICE_MODEL := 3g-6200nl SUPPORTED_DEVICES += 3g-6200nl @@ -1047,7 +1047,7 @@ define Device/trendnet_tew-638apb-v2 BLOCKSIZE := 64k IMAGE_SIZE := 3776k IMAGE/sysupgrade.bin := $$(sysupgrade_bin) | umedia-header 0x026382 | \ - append-metadata | check-size + check-size | append-metadata DEVICE_VENDOR := TRENDnet DEVICE_MODEL := TEW-638APB DEVICE_VARIANT := v2 @@ -1071,7 +1071,7 @@ define Device/unbranded_a5-v11 IMAGES += factory.bin IMAGE/factory.bin := $$(sysupgrade_bin) | check-size | \ poray-header -B A5-V11 -F 4M - DEVICE_VENDOR := + DEVICE_VENDOR := DEVICE_MODEL := A5-V11 DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 SUPPORTED_DEVICES += a5-v11 @@ -1190,7 +1190,7 @@ define Device/zte_mf283plus DEVICE_VENDOR := ZTE DEVICE_MODEL := MF283+ DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb-net-qmi-wwan uqmi \ - kmod-usb-serial-option + kmod-usb-serial kmod-usb-serial-option endef TARGET_DEVICES += zte_mf283plus diff --git a/target/linux/ramips/image/rt3883.mk b/target/linux/ramips/image/rt3883.mk index f434172c5..148bfbbe4 100644 --- a/target/linux/ramips/image/rt3883.mk +++ b/target/linux/ramips/image/rt3883.mk @@ -52,13 +52,27 @@ define Device/edimax_br-6475nd IMAGE_SIZE := 7744k IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ edimax-header -s CSYS -m RN54 -f 0x70000 -S 0x01100000 | pad-rootfs | \ - append-metadata | check-size + check-size | append-metadata DEVICE_VENDOR := Edimax DEVICE_MODEL := BR-6475nD SUPPORTED_DEVICES += br-6475nd endef TARGET_DEVICES += edimax_br-6475nd +define Device/engenius_esr600h + $(Device/uimage-lzma-loader) + SOC := rt3662 + BLOCKSIZE := 4k + IMAGE_SIZE := 7872k + IMAGES += factory.dlf + IMAGE/factory.dlf := $$(sysupgrade_bin) | check-size | \ + senao-header -r 0x101 -p 0x44 -t 2 + DEVICE_VENDOR := EnGenius + DEVICE_MODEL := ESR600H + DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 uboot-envtools +endef +TARGET_DEVICES += engenius_esr600h + define Device/loewe_wmdr-143n SOC := rt3662 BLOCKSIZE := 64k diff --git a/target/linux/ramips/modules.mk b/target/linux/ramips/modules.mk index 6de3d5b62..6f199c46a 100644 --- a/target/linux/ramips/modules.mk +++ b/target/linux/ramips/modules.mk @@ -81,8 +81,7 @@ define KernelPackage/dma-ralink CONFIG_DMA_RALINK FILES:= \ $(LINUX_DIR)/drivers/dma/virt-dma.ko \ - $(LINUX_DIR)/drivers/dma/ralink-gdma.ko@lt5.4 \ - $(LINUX_DIR)/drivers/staging/ralink-gdma/ralink-gdma.ko@ge5.4 + $(LINUX_DIR)/drivers/staging/ralink-gdma/ralink-gdma.ko AUTOLOAD:=$(call AutoLoad,52,ralink-gdma) endef diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds old mode 100755 new mode 100644 index f807e5d6f..53487d752 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions/leds.sh . /lib/functions/uci-defaults.sh @@ -184,11 +183,6 @@ tplink,archer-c20i) ucidef_set_led_switch "lan" "lan" "blue:lan" "switch0" "0x1e" ucidef_set_led_switch "wan" "wan" "blue:wan" "switch0" "0x01" ;; -tplink,archer-c5-v4) - ucidef_set_led_switch "lan" "lan" "green:lan" "switch1" "0x0f" - ucidef_set_led_switch "wan" "wan" "green:wan" "switch1" "0x10" - ucidef_set_led_netdev "wlan2g" "wlan2g" "green:wlan2g" "wlan1" - ;; tplink,archer-c50-v1) ucidef_set_led_switch "lan" "lan" "green:lan" "switch0" "0x1e" ucidef_set_led_switch "wan" "wan" "green:wan" "switch0" "0x01" diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network old mode 100755 new mode 100644 index bc5222996..eaa8cbf7a --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions.sh . /lib/functions/uci-defaults.sh @@ -137,6 +136,9 @@ ramips_setup_interfaces() engenius,esr600) ucidef_add_switch "switch0" \ "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "0@eth0" + ucidef_add_switch "switch1" \ + "5:lan" "6@eth0" + ucidef_add_switch_attr "switch1" "enable" "false" ;; fon,fon2601) ucidef_add_switch "switch0" \ @@ -169,6 +171,9 @@ ramips_setup_interfaces() lava,lr-25g001) ucidef_add_switch "switch0" \ "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0" + ucidef_add_switch "switch1" \ + "5:lan" "6@eth0" + ucidef_add_switch_attr "switch1" "enable" "false" ;; lenovo,newifi-y1|\ xiaomi,miwifi-mini) @@ -207,10 +212,6 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "1:lan:3" "2:lan:4" "3:lan:1" "4:lan:2" "0:wan" "6@eth0" ;; - tplink,archer-c5-v4) - ucidef_add_switch "switch1" \ - "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "7@eth0" - ;; tplink,archer-mr200) ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:lan" "3:lan" "6t@eth0" @@ -220,10 +221,6 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "4:wan" "6@eth0" ;; - xiaomi,miwifi-r3) - ucidef_add_switch "switch0" \ - "1:lan" "4:lan" "0:wan" "6@eth0" - ;; wavlink,wl-wn579x3) ucidef_add_switch "switch0" \ "5:lan" "4:wan" "6@eth0" @@ -370,10 +367,6 @@ ramips_setup_macs() tplink,archer-mr200) wan_mac=$(macaddr_add "$(mtd_get_mac_binary rom 0xf100)" 1) ;; - xiaomi,miwifi-r3) - wan_mac=$(mtd_get_mac_binary factory 0x28) - lan_mac=$(macaddr_setbit_la "$wan_mac") - ;; zbtlink,zbt-we1026-5g-16m) label_mac=$(mtd_get_mac_binary factory 0x4) ;; diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/03_gpio_switches b/target/linux/ramips/mt7620/base-files/etc/board.d/03_gpio_switches old mode 100755 new mode 100644 index 959991598..969e9eba6 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/03_gpio_switches +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/03_gpio_switches @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions/uci-defaults.sh diff --git a/target/linux/ramips/mt7620/base-files/etc/uci-defaults/05_fix-compat-version b/target/linux/ramips/mt7620/base-files/etc/uci-defaults/05_fix-compat-version new file mode 100644 index 000000000..9f981dfb8 --- /dev/null +++ b/target/linux/ramips/mt7620/base-files/etc/uci-defaults/05_fix-compat-version @@ -0,0 +1,10 @@ +. /lib/functions.sh + +case "$(board_name)" in + ravpower,rp-wd03) + uci set system.@system[0].compat_version="2.0" + uci commit system + ;; +esac + +exit 0 diff --git a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh index 53b7e2c73..9f71dc918 100755 --- a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh @@ -30,10 +30,6 @@ platform_do_upgrade() { } default_do_upgrade "$1" ;; - xiaomi,miwifi-r3) - dd if=/dev/mtd0 bs=64 count=1 2>/dev/null | grep -qi breed && CI_KERNPART_EXT="kernel_stock" - nand_do_upgrade "$1" - ;; *) default_do_upgrade "$1" ;; diff --git a/target/linux/ramips/mt7620/config-5.10 b/target/linux/ramips/mt7620/config-5.10 index b6a8b03d2..391449cc5 100644 --- a/target/linux/ramips/mt7620/config-5.10 +++ b/target/linux/ramips/mt7620/config-5.10 @@ -148,6 +148,7 @@ CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y CONFIG_PHY_RALINK_USB=y CONFIG_PINCTRL=y +# CONFIG_PINCTRL_AW9523 is not set CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_RALINK=y diff --git a/target/linux/ramips/mt7620/config-5.4 b/target/linux/ramips/mt7620/config-5.4 index 2966f743d..ca96f09c5 100644 --- a/target/linux/ramips/mt7620/config-5.4 +++ b/target/linux/ramips/mt7620/config-5.4 @@ -33,12 +33,7 @@ CONFIG_CPU_R4K_CACHE_TLB=y CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y CONFIG_CPU_SUPPORTS_HIGHMEM=y CONFIG_CPU_SUPPORTS_MSA=y -CONFIG_CRC16=y -CONFIG_CRYPTO_ACOMP2=y -CONFIG_CRYPTO_DEFLATE=y -CONFIG_CRYPTO_HASH_INFO=y CONFIG_CRYPTO_LIB_POLY1305_RSIZE=2 -CONFIG_CRYPTO_LZO=y CONFIG_CRYPTO_RNG2=y CONFIG_CSRC_R4K=y CONFIG_DEBUG_PINCTRL=y @@ -92,8 +87,6 @@ CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y -CONFIG_LZO_COMPRESS=y -CONFIG_LZO_DECOMPRESS=y CONFIG_MARVELL_PHY=y CONFIG_MDIO_BUS=y CONFIG_MDIO_DEVICE=y @@ -118,7 +111,6 @@ CONFIG_MODULES_USE_ELF_REL=y # CONFIG_MT7621_WDT is not set # CONFIG_MTD_CFI_INTELEXT is not set CONFIG_MTD_CMDLINE_PARTS=y -CONFIG_MTD_NAND_MT7620=y CONFIG_MTD_PHYSMAP=y CONFIG_MTD_SPI_NOR=y CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y @@ -127,12 +119,7 @@ CONFIG_MTD_SPLIT_JIMAGE_FW=y CONFIG_MTD_SPLIT_SEAMA_FW=y CONFIG_MTD_SPLIT_TPLINK_FW=y CONFIG_MTD_SPLIT_UIMAGE_FW=y -CONFIG_MTD_UBI=y -CONFIG_MTD_UBI_BEB_LIMIT=20 -CONFIG_MTD_UBI_BLOCK=y -# CONFIG_MTD_UBI_FASTMAP is not set -# CONFIG_MTD_UBI_GLUEBI is not set -CONFIG_MTD_UBI_WL_THRESHOLD=4096 +CONFIG_MTD_VIRT_CONCAT=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NEED_PER_CPU_KM=y CONFIG_NET_RALINK_GSW_MT7620=y @@ -163,6 +150,7 @@ CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y CONFIG_PHY_RALINK_USB=y CONFIG_PINCTRL=y +# CONFIG_PINCTRL_AW9523 is not set CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_RALINK=y @@ -173,7 +161,6 @@ CONFIG_RESET_CONTROLLER=y CONFIG_SERIAL_8250_RT288X=y CONFIG_SERIAL_MCTRL_GPIO=y CONFIG_SERIAL_OF_PLATFORM=y -CONFIG_SGL_ALLOC=y CONFIG_SOC_MT7620=y # CONFIG_SOC_MT7621 is not set # CONFIG_SOC_RT288X is not set @@ -202,14 +189,6 @@ CONFIG_TICK_CPU_ACCOUNTING=y CONFIG_TIMER_OF=y CONFIG_TIMER_PROBE=y CONFIG_TINY_SRCU=y -CONFIG_UBIFS_ATIME_SUPPORT=y -CONFIG_UBIFS_FS=y -CONFIG_UBIFS_FS_ADVANCED_COMPR=y -CONFIG_UBIFS_FS_LZO=y -CONFIG_UBIFS_FS_ZLIB=y -# CONFIG_UBIFS_FS_ZSTD is not set CONFIG_USB_SUPPORT=y CONFIG_USE_OF=y CONFIG_WATCHDOG_CORE=y -CONFIG_ZLIB_DEFLATE=y -CONFIG_ZLIB_INFLATE=y diff --git a/target/linux/ramips/mt7620/target.mk b/target/linux/ramips/mt7620/target.mk index 6e8e678d6..5fc61e49c 100644 --- a/target/linux/ramips/mt7620/target.mk +++ b/target/linux/ramips/mt7620/target.mk @@ -4,10 +4,10 @@ SUBTARGET:=mt7620 BOARDNAME:=MT7620 based boards -FEATURES+=usb nand ramdisk +FEATURES+=usb ramdisk CPU_TYPE:=24kc -DEFAULT_PACKAGES += -ddns-scripts_aliyun -ddns-scripts_dnspod kmod-rt2800-soc wpad-openssl swconfig +DEFAULT_PACKAGES += kmod-rt2800-soc wpad-basic-wolfssl swconfig define Target/Description Build firmware images for Ralink MT7620 based boards. diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds old mode 100755 new mode 100644 index 2788b31c5..93e4981be --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions/leds.sh . /lib/functions/uci-defaults.sh @@ -20,11 +19,14 @@ cudy,wr2100) ucidef_set_led_netdev "wan" "wan" "green:wan" "wan" ;; d-team,newifi-d2) - ucidef_set_led_switch "internet" "internet" "amber:internet" "switch0" "0x10" - ucidef_set_led_netdev "wlan2g" "WiFi 2.4GHz" "blue:wlan2g" "ra0" - ucidef_set_led_netdev "wlan5g" "WiFi 5GHz" "blue:wlan5g" "rai0" + ucidef_set_led_netdev "internet" "internet" "amber:internet" "wan" + ucidef_set_led_netdev "wlan2g" "WiFi 2.4GHz" "blue:wlan2g" "wlan0" + ucidef_set_led_netdev "wlan5g" "WiFi 5GHz" "blue:wlan5g" "wlan1" ;; -d-team,pbr-m1) +d-team,pbr-m1|\ +gehua,ghl-r-001|\ +jcg,y2|\ +xzwifi,creativebox-v1) ucidef_set_led_netdev "internet" "internet" "blue:internet" "wan" ;; dlink,dir-1960-a1|\ @@ -32,21 +34,18 @@ dlink,dir-2640-a1|\ dlink,dir-2660-a1) ucidef_set_led_netdev "wan" "wan" "white:net" "wan" ;; -dlink,dir-860l-b1) - ucidef_set_led_netdev "wan" "wan" "green:net" "wan" +dlink,dir-853-a3) + ucidef_set_led_netdev "wan" "wan" "blue:net" "wan" ;; +dlink,dir-853-r1) + ucidef_set_led_netdev "internet" "internet" "blue:net" "wan" + ;; +dlink,dir-860l-b1|\ dlink,dir-867-a1|\ dlink,dir-878-a1|\ dlink,dir-882-a1|\ -dlink,dir-882-r1|\ -motorola,mr2600) +dlink,dir-882-r1) ucidef_set_led_netdev "wan" "wan" "green:net" "wan" - ucidef_set_led_netdev "wlan2g" "WiFi 2.4GHz" "green:wlan2g" "ra0" - ucidef_set_led_netdev "wlan5g" "WiFi 5GHz" "green:wlan5g" "rai0" - ;; -gehua,ghl-r-001|\ -jcg,y2) - ucidef_set_led_switch "internet" "internet" "blue:internet" "switch0" "0x10" ;; gnubee,gb-pc1|\ gnubee,gb-pc2) @@ -57,8 +56,10 @@ linksys,e5600) ucidef_set_led_netdev "wan" "wan link" "blue:wan" "wan" "link" ;; linksys,ea7300-v1|\ +linksys,ea7300-v2|\ linksys,ea7500-v2|\ -linksys,ea8100-v1) +linksys,ea8100-v1|\ +linksys,ea8100-v2) ucidef_set_led_netdev "lan1" "lan1 link" "green:lan1" "lan1" "link" ucidef_set_led_netdev "lan2" "lan2 link" "green:lan2" "lan2" "link" ucidef_set_led_netdev "lan3" "lan3 link" "green:lan3" "lan3" "link" @@ -112,17 +113,14 @@ tplink,re650-v1) ucidef_set_led_netdev "eth_act" "LAN act" "green:eth_act" "lan" "tx rx" ucidef_set_led_netdev "eth_link" "LAN link" "green:eth_link" "lan" "link" ;; -xzwifi,creativebox-v1) - ucidef_set_led_netdev "internet" "internet" "blue:internet" "wan" - ;; xiaomi,mi-router-ac2100) - ucidef_set_led_switch "wan" "wan" "blue:wan" "switch0" "0x1" + ucidef_set_led_netdev "wan-blue" "WAN (blue)" "blue:wan" "wan" ;; xiaomi,mi-router-cr6606) ucidef_set_led_netdev "internet" "internet" "$boardname:blue:net" "wan" ;; xiaomi,redmi-router-ac2100) - ucidef_set_led_switch "wan" "wan" "white:wan" "switch0" "0x1" + ucidef_set_led_netdev "wan" "wan" "white:wan" "wan" ;; youhua,wr1200js) ucidef_set_led_netdev "internet" "INTERNET" "green:wan" "wan" diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network old mode 100755 new mode 100644 index 52fc2c97f..40d22950d --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions.sh . /lib/functions/uci-defaults.sh @@ -18,12 +17,17 @@ ramips_setup_interfaces() tplink,re350-v1|\ tplink,re500-v1|\ tplink,re650-v1|\ + ubnt,unifi-6-lite|\ ubnt,unifi-nanohd) ucidef_set_interface_lan "lan" ;; ampedwireless,ally-r1900k|\ + gehua,ghl-r-001|\ hiwifi,hc5962|\ - xiaomi,mir3p) + xiaomi,mi-router-3-pro|\ + xiaomi,mi-router-ac2100|\ + xiaomi,mi-router-cr6606|\ + xiaomi,redmi-router-ac2100) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" ;; asiarf,ap7621-001|\ @@ -31,42 +35,20 @@ ramips_setup_interfaces() ucidef_set_interfaces_lan_wan "lan" "wan" ;; asiarf,ap7621-nv1|\ + glinet,gl-mt1300|\ jcg,q20|\ lenovo,newifi-d1|\ mikrotik,routerboard-m33g|\ - xiaomi,mir3g|\ - xiaomi,mir3g-v2) + xiaomi,mi-router-3g|\ + xiaomi,mi-router-3g-v2|\ + xiaomi,mi-router-4|\ + xiaomi,mi-router-4a-gigabit) ucidef_set_interfaces_lan_wan "lan1 lan2" "wan" ;; - d-team,newifi-d2) - ucidef_add_switch "switch0" \ - "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0" - ucidef_set_interface_lan "eth0.1 ra0 rai0" - ;; - dlink,dir-867-a1|\ - dlink,dir-878-a1|\ - dlink,dir-882-a1|\ - dlink,dir-882-r1|\ - motorola,mr2600) - ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 ra0 rai0" "wan" - ;; - gehua,ghl-r-001) - ucidef_add_switch "switch0" \ - "0:lan" "1:lan" "2:lan" "4:wan" "6@eth0" - ucidef_set_interface_lan "eth0.1 ra0 rai0" - ;; - glinet,gl-mt1300) - ucidef_set_interfaces_lan_wan "lan1 lan2 ra0 rax0" "wan" - ;; gnubee,gb-pc1|\ gnubee,gb-pc2) ucidef_set_interface_lan "lan1 lan2" ;; - jcg,y2) - ucidef_add_switch "switch0" \ - "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0" - ucidef_set_interface_lan "eth0.1 ra0 rax0" - ;; linksys,re6500|\ netgear,wac104) ucidef_set_interface_lan "lan1 lan2 lan3 lan4" @@ -77,17 +59,6 @@ ramips_setup_interfaces() mikrotik,routerboard-760igs) ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan sfp" ;; - netgear,r6700-v2|\ - netgear,r6800) - ucidef_add_switch "switch0" \ - "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0" - ;; - phicomm,k2p|\ - xiaoyu,xy-c5) - ucidef_add_switch "switch0" \ - "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0" - ucidef_set_interface_lan "eth0.1 ra0 rax0" - ;; tplink,eap235-wall-v1) ucidef_set_interface_lan "lan0 lan1 lan2 lan3" ;; @@ -97,17 +68,6 @@ ramips_setup_interfaces() ubnt,edgerouter-x-sfp) ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0" ;; - xiaomi,mir4) - ucidef_add_switch "switch0" \ - "1:lan:2" "2:lan:1" "4:wan" "6t@eth0" - ucidef_set_interface_lan "eth0.1 ra0 rai0" - ;; - xiaomi,mi-router-ac2100|\ - xiaomi,redmi-router-ac2100) - ucidef_add_switch "switch0" \ - "2:lan:1" "3:lan:2" "4:lan:3" "0:wan" "6@eth0" - ucidef_set_interface_lan "eth0.1 ra0 rai0" - ;; zyxel,nr7101) ucidef_set_interfaces_lan_wan "lan" "wan" ;; @@ -148,10 +108,6 @@ ramips_setup_macs() wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)" lan_mac=$wan_mac ;; - d-team,newifi-d2) - lan_mac=$(cat /sys/class/net/eth0/address) - wan_mac=$(mtd_get_mac_binary factory 0xe006) - ;; dlink,dir-860l-b1) lan_mac=$(mtd_get_mac_ascii factory lanmac) wan_mac=$(mtd_get_mac_ascii factory wanmac) @@ -161,9 +117,10 @@ ramips_setup_macs() lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr) wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr) ;; - gehua,ghl-r-001) - lan_mac=$(cat /sys/class/net/eth0/address) - wan_mac=$(macaddr_add "$lan_mac" 1) + elecom,wrc-2533ghbk-i) + lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr) + wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr) + label_mac=$wan_mac ;; hiwifi,hc5962) lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ") @@ -175,15 +132,20 @@ ramips_setup_macs() wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr) label_mac=$wan_mac ;; - jcg,y2) - lan_mac=$(cat /sys/class/net/eth0/address) - wan_mac=$(mtd_get_mac_binary factory 0xe006) + jcg,y2|\ + wavlink,wl-wn531a6|\ + winstars,ws-wn583a6|\ + zbtlink,zbt-we1326|\ + zbtlink,zbt-wg3526-16m|\ + zbtlink,zbt-wg3526-32m) label_mac=$(mtd_get_mac_binary factory 0x4) ;; linksys,e5600|\ linksys,ea7300-v1|\ + linksys,ea7300-v2|\ linksys,ea7500-v2|\ - linksys,ea8100-v1) + linksys,ea8100-v1|\ + linksys,ea8100-v2) lan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) wan_mac=$lan_mac label_mac=$lan_mac @@ -196,34 +158,6 @@ ramips_setup_macs() wan_mac=$label_mac lan_mac=$(macaddr_add $label_mac 1) ;; - netgear,r6700-v2|\ - netgear,r6800) - lan_mac=$(mtd_get_mac_binary factory 0x4) - wan_mac=$(macaddr_add "$lan_mac" 2) - ;; - phicomm,k2p) - wan_mac=$(mtd_get_mac_binary factory 0xe006) - ;; - xiaomi,mi-router-ac2100|\ - xiaomi,redmi-router-ac2100) - lan_mac=$(cat /sys/class/net/eth0/address) - wan_mac=$(mtd_get_mac_binary factory 0xe000) - ;; - xiaomi,mir4) - lan_mac=$(mtd_get_mac_binary factory 0xe006) - wan_mac=$(mtd_get_mac_binary factory 0xe000) - ;; - xiaoyu,xy-c5) - wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1) - ;; - wavlink,wl-wn531a6|\ - winstars,ws-wn583a6|\ - zbtlink,zbt-we1326|\ - zbtlink,zbt-wg108|\ - zbtlink,zbt-wg3526-16m|\ - zbtlink,zbt-wg3526-32m) - label_mac=$(mtd_get_mac_binary factory 0x4) - ;; esac [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches b/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches old mode 100755 new mode 100644 index 8ef815634..ed728b07c --- a/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions/uci-defaults.sh diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/05_compat-version b/target/linux/ramips/mt7621/base-files/etc/board.d/05_compat-version new file mode 100644 index 000000000..45bef9385 --- /dev/null +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/05_compat-version @@ -0,0 +1,18 @@ +# +# Copyright (C) 2020 OpenWrt.org +# + +. /lib/functions.sh +. /lib/functions/uci-defaults.sh + +board_config_update + +case "$(board_name)" in + *) + ucidef_set_compat_version "1.1" + ;; +esac + +board_config_flush + +exit 0 diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index b5422e7e0..711af4e3a 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -10,6 +10,17 @@ PHYNBR=${DEVPATH##*/phy} board=$(board_name) case "$board" in + dlink,dir-853-a3) + [ "$PHYNBR" = "0" ] && \ + macaddr_setbit_la "$(mtd_get_mac_binary factory 0xe000)" \ + > /sys${DEVPATH}/macaddress + ;; + dlink,dir-853-r1) + if [ "$PHYNBR" = "0" ]; then + base_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" -1) + macaddr_setbit_la "$base_mac" > /sys${DEVPATH}/macaddress + fi + ;; glinet,gl-mt1300) [ "$PHYNBR" = "1" ] && \ macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1 > /sys${DEVPATH}/macaddress @@ -20,8 +31,10 @@ case "$board" in ;; linksys,e5600|\ linksys,ea7300-v1|\ + linksys,ea7300-v2|\ linksys,ea7500-v2|\ - linksys,ea8100-v1) + linksys,ea8100-v1|\ + linksys,ea8100-v2) hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr) [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress diff --git a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount index 2e2f24cf5..7b4a63d66 100755 --- a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount @@ -10,8 +10,10 @@ boot() { ;; linksys,e5600|\ linksys,ea7300-v1|\ + linksys,ea7300-v2|\ linksys,ea7500-v2|\ - linksys,ea8100-v1) + linksys,ea8100-v1|\ + linksys,ea8100-v2) mtd resetbc s_env || true ;; samknows,whitebox-v8) diff --git a/target/linux/ramips/mt7621/base-files/etc/uci-defaults/01_enable_packet_steering b/target/linux/ramips/mt7621/base-files/etc/uci-defaults/01_enable_packet_steering new file mode 100644 index 000000000..114c7e1a4 --- /dev/null +++ b/target/linux/ramips/mt7621/base-files/etc/uci-defaults/01_enable_packet_steering @@ -0,0 +1,5 @@ +uci -q get network.globals.packet_steering > /dev/null || { + uci set network.globals='globals' + uci set network.globals.packet_steering=1 + uci commit network +} diff --git a/target/linux/ramips/mt7621/base-files/lib/preinit/07_mt7621_bringup_dsa_master b/target/linux/ramips/mt7621/base-files/lib/preinit/07_mt7621_bringup_dsa_master index 8e5127741..0f4660d24 100644 --- a/target/linux/ramips/mt7621/base-files/lib/preinit/07_mt7621_bringup_dsa_master +++ b/target/linux/ramips/mt7621/base-files/lib/preinit/07_mt7621_bringup_dsa_master @@ -17,4 +17,4 @@ mt7621_bringup_dsa_master() { ip link set $masterif up } -boot_hook_add preinit_main mt7621_bringup_dsa_master +boot_hook_add preinit_main mt7621_bringup_dsa_master \ No newline at end of file diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 3347113e3..a2ad38b7c 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -37,7 +37,7 @@ platform_do_upgrade() { mikrotik,routerboard-760igs|\ mikrotik,routerboard-m11g|\ mikrotik,routerboard-m33g) - [ -z "$(rootfs_type)" ] && mtd erase firmware + [ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware ;; asus,rt-ac65p|\ asus,rt-ac85p) @@ -56,12 +56,15 @@ platform_do_upgrade() { dlink,dir-1960-a1|\ dlink,dir-2640-a1|\ dlink,dir-2660-a1|\ + dlink,dir-853-a3|\ hiwifi,hc5962|\ jcg,q20|\ linksys,e5600|\ linksys,ea7300-v1|\ + linksys,ea7300-v2|\ linksys,ea7500-v2|\ linksys,ea8100-v1|\ + linksys,ea8100-v2|\ netgear,r6220|\ netgear,r6260|\ netgear,r6350|\ @@ -72,9 +75,9 @@ platform_do_upgrade() { netgear,wac124|\ netis,wf2881|\ sercomm,na502|\ - xiaomi,mir3g|\ - xiaomi,mir3p|\ - xiaomi,mir4|\ + xiaomi,mi-router-3g|\ + xiaomi,mi-router-3-pro|\ + xiaomi,mi-router-4|\ xiaomi,mi-router-ac2100|\ xiaomi,mi-router-cr6606|\ xiaomi,redmi-router-ac2100) diff --git a/target/linux/ramips/mt7621/config-5.10 b/target/linux/ramips/mt7621/config-5.10 index 5e1a5cd30..92165590f 100644 --- a/target/linux/ramips/mt7621/config-5.10 +++ b/target/linux/ramips/mt7621/config-5.10 @@ -102,6 +102,7 @@ CONFIG_HAS_IOPORT_MAP=y CONFIG_HIGHMEM=y CONFIG_I2C=y CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_GPIO=y CONFIG_I2C_MT7621=y CONFIG_INITRAMFS_SOURCE="" CONFIG_IRQCHIP=y @@ -212,6 +213,7 @@ CONFIG_PHYLIB=y CONFIG_PHYLINK=y # CONFIG_PHY_RALINK_USB is not set CONFIG_PINCTRL=y +CONFIG_PINCTRL_AW9523=y CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_PINCTRL_SX150X=y diff --git a/target/linux/ramips/mt7621/config-5.4 b/target/linux/ramips/mt7621/config-5.4 index 75676071d..0ce300c13 100644 --- a/target/linux/ramips/mt7621/config-5.4 +++ b/target/linux/ramips/mt7621/config-5.4 @@ -100,6 +100,7 @@ CONFIG_HIGHMEM=y CONFIG_HZ_PERIODIC=y CONFIG_I2C=y CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_GPIO=y CONFIG_I2C_MT7621=y CONFIG_INITRAMFS_SOURCE="" CONFIG_IRQCHIP=y @@ -156,6 +157,7 @@ CONFIG_MTD_PHYSMAP=y CONFIG_MTD_RAW_NAND=y CONFIG_MTD_ROUTERBOOT_PARTS=y CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_SPLIT_FIT_FW=y CONFIG_MTD_SPLIT_MINOR_FW=y CONFIG_MTD_SPLIT_SEAMA_FW=y CONFIG_MTD_SPLIT_TPLINK_FW=y @@ -174,15 +176,9 @@ CONFIG_NET_DSA_MT7530=y CONFIG_NET_DSA_TAG_MTK=y CONFIG_NET_FLOW_LIMIT=y CONFIG_NET_MEDIATEK_SOC=y -CONFIG_NET_RALINK_GSW_MT7621=y -CONFIG_NET_RALINK_MDIO=y -CONFIG_NET_RALINK_MDIO_MT7620=y -CONFIG_NET_RALINK_MT7621=y -CONFIG_NET_RALINK_OFFLOAD=y -CONFIG_NET_RALINK_SOC=y CONFIG_NET_SWITCHDEV=y CONFIG_NET_VENDOR_MEDIATEK=y -CONFIG_NET_VENDOR_RALINK=y +# CONFIG_NET_VENDOR_RALINK is not set CONFIG_NR_CPUS=4 CONFIG_OF=y CONFIG_OF_ADDRESS=y @@ -207,25 +203,13 @@ CONFIG_PHYLIB=y CONFIG_PHYLINK=y # CONFIG_PHY_RALINK_USB is not set CONFIG_PINCTRL=y +CONFIG_PINCTRL_AW9523=y CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_PINCTRL_SX150X=y CONFIG_POWER_RESET=y CONFIG_POWER_RESET_GPIO=y CONFIG_POWER_SUPPLY=y -CONFIG_PSTORE=y -# CONFIG_PSTORE_842_COMPRESS is not set -CONFIG_PSTORE_COMPRESS=y -CONFIG_PSTORE_COMPRESS_DEFAULT="deflate" -# CONFIG_PSTORE_CONSOLE is not set -CONFIG_PSTORE_DEFLATE_COMPRESS=y -CONFIG_PSTORE_DEFLATE_COMPRESS_DEFAULT=y -# CONFIG_PSTORE_LZ4HC_COMPRESS is not set -# CONFIG_PSTORE_LZ4_COMPRESS is not set -# CONFIG_PSTORE_LZO_COMPRESS is not set -# CONFIG_PSTORE_PMSG is not set -CONFIG_PSTORE_RAM=y -# CONFIG_PSTORE_ZSTD_COMPRESS is not set CONFIG_QUEUED_RWLOCKS=y CONFIG_QUEUED_SPINLOCKS=y CONFIG_RALINK=y @@ -233,9 +217,6 @@ CONFIG_RALINK=y CONFIG_RATIONAL=y CONFIG_RCU_NEED_SEGCBLIST=y CONFIG_RCU_STALL_COMMON=y -CONFIG_REED_SOLOMON=y -CONFIG_REED_SOLOMON_DEC8=y -CONFIG_REED_SOLOMON_ENC8=y CONFIG_REGMAP=y CONFIG_REGMAP_MMIO=y CONFIG_REGULATOR=y @@ -267,8 +248,6 @@ CONFIG_SPI_MEM=y CONFIG_SPI_MT7621=y # CONFIG_SPI_RT2880 is not set CONFIG_SRCU=y -CONFIG_SWCONFIG=y -CONFIG_SWCONFIG_LEDS=y CONFIG_SWPHY=y CONFIG_SYNC_R4K=y CONFIG_SYSCTL_EXCEPTION_TRACE=y diff --git a/target/linux/ramips/mt7621/target.mk b/target/linux/ramips/mt7621/target.mk index f7d87443b..1ecc3bc63 100644 --- a/target/linux/ramips/mt7621/target.mk +++ b/target/linux/ramips/mt7621/target.mk @@ -10,7 +10,7 @@ KERNELNAME:=vmlinux vmlinuz # make Kernel/CopyImage use $LINUX_DIR/vmlinuz IMAGES_DIR:=../../.. -DEFAULT_PACKAGES += kmod-crypto-hw-eip93 wpad-openssl swconfig +DEFAULT_PACKAGES += wpad-openssl define Target/Description Build firmware images for Ralink MT7621 based boards. diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds b/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds old mode 100755 new mode 100644 index 2bfd38422..e2fb44c81 --- a/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions/leds.sh . /lib/functions/uci-defaults.sh @@ -86,6 +85,10 @@ tplink,tl-mr6400-v4) ucidef_set_led_switch "lan" "lan" "white:lan" "switch0" "0x0e" ucidef_set_led_switch "wan" "wan" "white:wan" "switch0" "0x10" ;; +tplink,tl-mr6400-v5) + ucidef_set_led_switch "lan" "lan" "white:lan" "switch0" "0x07" + ucidef_set_led_switch "wan" "wan" "white:wan" "switch0" "0x08" + ;; tplink,tl-wr841n-v13) ucidef_set_led_wlan "wlan2g" "wlan2g" "green:wlan" "phy0tpt" ucidef_set_led_switch "lan1" "lan1" "green:lan1" "switch0" "0x2" diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network old mode 100755 new mode 100644 index 75fcfc50f..032d7e75b --- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions.sh . /lib/functions/uci-defaults.sh @@ -33,6 +32,11 @@ ramips_setup_interfaces() ucidef_add_switch_attr "switch0" "enable" "false" ucidef_set_interface_lan "eth0" ;; + minew,g1-c) + ucidef_add_switch "switch0" + ucidef_add_switch_attr "switch0" "enable" "false" + ucidef_set_interface_lan "eth0" "dhcp" + ;; asus,rt-n10p-v3|\ asus,rt-n11p-b1|\ asus,rt-n12-vp-b1|\ @@ -119,6 +123,10 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0" ;; + tplink,tl-mr6400-v5) + ucidef_add_switch "switch0" \ + "0:lan" "1:lan" "2:lan" "3:wan" "6@eth0" + ;; tplink,tl-wr902ac-v3) ucidef_add_switch "switch0" \ "4:lan" "6@eth0" @@ -132,7 +140,7 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:wan" "3:lan" "4:lan" "6@eth0" ;; - xiaomi,mir4a-100m) + xiaomi,mi-router-4a-100m) ucidef_add_switch "switch0" \ "4:lan:1" "2:lan:2" "0:wan" "6@eth0" ;; @@ -240,8 +248,8 @@ ramips_setup_macs() label_mac=$(mtd_get_mac_binary factory 0x4) wan_mac=$(mtd_get_mac_binary factory 0x28) ;; - xiaomi,mi-router-4c|\ - xiaomi,mir4a-100m) + xiaomi,mi-router-4a-100m|\ + xiaomi,mi-router-4c) wan_mac=$(mtd_get_mac_binary factory 0x4) ;; esac diff --git a/target/linux/ramips/mt76x8/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt76x8/base-files/lib/upgrade/platform.sh index 05de7c1c5..20adfafc3 100755 --- a/target/linux/ramips/mt76x8/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt76x8/base-files/lib/upgrade/platform.sh @@ -28,8 +28,8 @@ platform_do_upgrade() { } default_do_upgrade "$1" ;; - tplink,archer-c50-v4|\ - tplink,archer-c20-v5) + tplink,archer-c20-v5|\ + tplink,archer-c50-v4) MTD_ARGS="-t romfile" default_do_upgrade "$1" ;; diff --git a/target/linux/ramips/mt76x8/config-5.10 b/target/linux/ramips/mt76x8/config-5.10 index 8c612a643..3a42a5770 100644 --- a/target/linux/ramips/mt76x8/config-5.10 +++ b/target/linux/ramips/mt76x8/config-5.10 @@ -143,6 +143,7 @@ CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y CONFIG_PHY_RALINK_USB=y CONFIG_PINCTRL=y +# CONFIG_PINCTRL_AW9523 is not set CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_RALINK=y diff --git a/target/linux/ramips/mt76x8/config-5.4 b/target/linux/ramips/mt76x8/config-5.4 index 302a39adc..c69f12089 100644 --- a/target/linux/ramips/mt76x8/config-5.4 +++ b/target/linux/ramips/mt76x8/config-5.4 @@ -143,6 +143,7 @@ CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y CONFIG_PHY_RALINK_USB=y CONFIG_PINCTRL=y +# CONFIG_PINCTRL_AW9523 is not set CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_RALINK=y diff --git a/target/linux/ramips/mt76x8/target.mk b/target/linux/ramips/mt76x8/target.mk index b52d44e6b..f939e4ca4 100644 --- a/target/linux/ramips/mt76x8/target.mk +++ b/target/linux/ramips/mt76x8/target.mk @@ -7,7 +7,7 @@ BOARDNAME:=MT76x8 based boards FEATURES+=usb ramdisk CPU_TYPE:=24kc -DEFAULT_PACKAGES += kmod-mt7603 wpad-openssl swconfig +DEFAULT_PACKAGES += kmod-mt7603 wpad-basic-wolfssl swconfig define Target/Description Build firmware images for Ralink MT76x8 based boards. diff --git a/target/linux/ramips/patches-5.10/405-mtd-spi-nor-Add-support-for-BoHong-bh25q128as.patch b/target/linux/ramips/patches-5.10/405-mtd-spi-nor-Add-support-for-BoHong-bh25q128as.patch new file mode 100644 index 000000000..4c762925f --- /dev/null +++ b/target/linux/ramips/patches-5.10/405-mtd-spi-nor-Add-support-for-BoHong-bh25q128as.patch @@ -0,0 +1,75 @@ +From 52d14545d2fc276b1bf9ccf48d4612fab6edfb6a Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Thu, 6 May 2021 17:49:55 +0200 +Subject: [PATCH] mtd: spi-nor: Add support for BoHong bh25q128as + +Add MTD support for the BoHong bh25q128as SPI NOR chip. +The chip has 16MB of total capacity, divided into a total of 256 +sectors, each 64KB sized. The chip also supports 4KB sectors. +Additionally, it supports dual and quad read modes. + +Functionality was verified on an Tenbay WR1800K / MTK MT7621 board. + +Signed-off-by: David Bauer +--- + drivers/mtd/spi-nor/Makefile | 1 + + drivers/mtd/spi-nor/bohong.c | 21 +++++++++++++++++++++ + drivers/mtd/spi-nor/core.c | 1 + + drivers/mtd/spi-nor/core.h | 1 + + 4 files changed, 24 insertions(+) + create mode 100644 drivers/mtd/spi-nor/bohong.c + +--- a/drivers/mtd/spi-nor/Makefile ++++ b/drivers/mtd/spi-nor/Makefile +@@ -2,6 +2,7 @@ + + spi-nor-objs := core.o sfdp.o + spi-nor-objs += atmel.o ++spi-nor-objs += bohong.o + spi-nor-objs += catalyst.o + spi-nor-objs += eon.o + spi-nor-objs += esmt.o +--- /dev/null ++++ b/drivers/mtd/spi-nor/bohong.c +@@ -0,0 +1,21 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (C) 2005, Intec Automation Inc. ++ * Copyright (C) 2014, Freescale Semiconductor, Inc. ++ */ ++ ++#include ++ ++#include "core.h" ++ ++static const struct flash_info bohong_parts[] = { ++ /* BoHong Microelectronics */ ++ { "bh25q128as", INFO(0x684018, 0, 64 * 1024, 256, ++ SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, ++}; ++ ++const struct spi_nor_manufacturer spi_nor_bohong = { ++ .name = "bohong", ++ .parts = bohong_parts, ++ .nparts = ARRAY_SIZE(bohong_parts), ++}; +--- a/drivers/mtd/spi-nor/core.c ++++ b/drivers/mtd/spi-nor/core.c +@@ -2038,6 +2038,7 @@ int spi_nor_sr2_bit7_quad_enable(struct + + static const struct spi_nor_manufacturer *manufacturers[] = { + &spi_nor_atmel, ++ &spi_nor_bohong, + &spi_nor_catalyst, + &spi_nor_eon, + &spi_nor_esmt, +--- a/drivers/mtd/spi-nor/core.h ++++ b/drivers/mtd/spi-nor/core.h +@@ -382,6 +382,7 @@ struct spi_nor_manufacturer { + + /* Manufacturer drivers. */ + extern const struct spi_nor_manufacturer spi_nor_atmel; ++extern const struct spi_nor_manufacturer spi_nor_bohong; + extern const struct spi_nor_manufacturer spi_nor_catalyst; + extern const struct spi_nor_manufacturer spi_nor_eon; + extern const struct spi_nor_manufacturer spi_nor_esmt; diff --git a/target/linux/ramips/patches-5.10/710-at803x.patch b/target/linux/ramips/patches-5.10/710-at803x.patch index d15dd9296..2d874b125 100644 --- a/target/linux/ramips/patches-5.10/710-at803x.patch +++ b/target/linux/ramips/patches-5.10/710-at803x.patch @@ -149,4 +149,4 @@ Signed-off-by: RenĂ© van Dorst + .config_aneg = at803x_config_aneg, .flags = PHY_POLL_CABLE_TEST, .probe = at803x_probe, - .remove = at803x_remove, + .remove = at803x_remove, \ No newline at end of file diff --git a/target/linux/ramips/patches-5.10/805-pinctrl-AW9523.patch b/target/linux/ramips/patches-5.10/805-pinctrl-AW9523.patch new file mode 100644 index 000000000..e80d0c996 --- /dev/null +++ b/target/linux/ramips/patches-5.10/805-pinctrl-AW9523.patch @@ -0,0 +1,72 @@ +From: AngeloGioacchino Del Regno + +To: linus.walleij@linaro.org +Cc: linux-kernel@vger.kernel.org, konrad.dybcio@somainline.org, + marijn.suijten@somainline.org, martin.botka@somainline.org, + phone-devel@vger.kernel.org, linux-gpio@vger.kernel.org, + devicetree@vger.kernel.org, robh+dt@kernel.org, + AngeloGioacchino Del Regno + +Subject: [PATCH v5 1/2] pinctrl: Add driver for Awinic AW9523/B I2C GPIO + Expander +Date: Mon, 25 Jan 2021 19:22:18 +0100 + +The Awinic AW9523(B) is a multi-function I2C gpio expander in a +TQFN-24L package, featuring PWM (max 37mA per pin, or total max +power 3.2Watts) for LED driving capability. + +It has two ports with 8 pins per port (for a total of 16 pins), +configurable as either PWM with 1/256 stepping or GPIO input/output, +1.8V logic input; each GPIO can be configured as input or output +independently from each other. + +This IC also has an internal interrupt controller, which is capable +of generating an interrupt for each GPIO, depending on the +configuration, and will raise an interrupt on the INTN pin to +advertise this to an external interrupt controller. + +Signed-off-by: AngeloGioacchino Del Regno +--- + drivers/pinctrl/Kconfig | 17 + + drivers/pinctrl/Makefile | 1 + + drivers/pinctrl/pinctrl-aw9523.c | 1122 ++++++++++++++++++++++++++++++ + 3 files changed, 1140 insertions(+) + create mode 100644 drivers/pinctrl/pinctrl-aw9523.c + +--- a/drivers/pinctrl/Kconfig ++++ b/drivers/pinctrl/Kconfig +@@ -110,6 +110,24 @@ config PINCTRL_AMD + Requires ACPI/FDT device enumeration code to set up a platform + device. + ++config PINCTRL_AW9523 ++ bool "Awinic AW9523/AW9523B I2C GPIO expander pinctrl driver" ++ depends on OF && I2C ++ select PINMUX ++ select PINCONF ++ select GENERIC_PINCONF ++ select GPIOLIB ++ select GPIOLIB_IRQCHIP ++ select REGMAP ++ select REGMAP_I2C ++ help ++ The Awinic AW9523/AW9523B is a multi-function I2C GPIO ++ expander with PWM functionality. This driver bundles a ++ pinctrl driver to select the function muxing and a GPIO ++ driver to handle GPIO, when the GPIO function is selected. ++ ++ Say yes to enable pinctrl and GPIO support for the AW9523(B). ++ + config PINCTRL_BM1880 + bool "Bitmain BM1880 Pinctrl driver" + depends on OF && (ARCH_BITMAIN || COMPILE_TEST) +--- a/drivers/pinctrl/Makefile ++++ b/drivers/pinctrl/Makefile +@@ -14,6 +14,7 @@ obj-$(CONFIG_PINCTRL_AXP209) += pinctrl- + obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o + obj-$(CONFIG_PINCTRL_AT91PIO4) += pinctrl-at91-pio4.o + obj-$(CONFIG_PINCTRL_AMD) += pinctrl-amd.o ++obj-$(CONFIG_PINCTRL_AW9523) += pinctrl-aw9523.o + obj-$(CONFIG_PINCTRL_BM1880) += pinctrl-bm1880.o + obj-$(CONFIG_PINCTRL_DA850_PUPD) += pinctrl-da850-pupd.o + obj-$(CONFIG_PINCTRL_DA9062) += pinctrl-da9062.o diff --git a/target/linux/ramips/patches-5.4/0001-MIPS-cmdline-Clean-up-boot_command_line-initializati.patch b/target/linux/ramips/patches-5.4/0001-MIPS-cmdline-Clean-up-boot_command_line-initializati.patch new file mode 100644 index 000000000..eedc7498b --- /dev/null +++ b/target/linux/ramips/patches-5.4/0001-MIPS-cmdline-Clean-up-boot_command_line-initializati.patch @@ -0,0 +1,192 @@ +From: Paul Burton +Date: Wed, 9 Oct 2019 23:09:45 +0000 +Subject: MIPS: cmdline: Clean up boot_command_line initialization + +Our current code to initialize boot_command_line is a mess. Some of this +is due to the addition of too many options over the years, and some of +this is due to workarounds for early_init_dt_scan_chosen() performing +actions specific to options from other architectures that probably +shouldn't be in generic code. + +Clean this up by introducing a new bootcmdline_init() function that +simplifies the initialization somewhat. The major changes are: + +- Because bootcmdline_init() is a function it can return early in the + CONFIG_CMDLINE_OVERRIDE case. + +- We clear boot_command_line rather than inheriting whatever + early_init_dt_scan_chosen() may have left us. This means we no longer + need to set boot_command_line to a space character in an attempt to + prevent early_init_dt_scan_chosen() from copying CONFIG_CMDLINE into + boot_command_line without us knowing about it. + +- Indirection via USE_PROM_CMDLINE, USE_DTB_CMDLINE, EXTEND_WITH_PROM & + BUILTIN_EXTEND_WITH_PROM macros is removed; they seemingly served only + to obfuscate the code. + +- The logic is cleaner, clearer & commented. + +Two minor drawbacks of this approach are: + +1) We call of_scan_flat_dt(), which means we scan through the DT again. + The overhead is fairly minimal & shouldn't be noticeable. + +2) cmdline_scan_chosen() duplicates a small amount of the logic from + early_init_dt_scan_chosen(). Alternatives might be to allow the + generic FDT code to keep & expose a copy of the arguments taken from + the /chosen node's bootargs property, or to introduce a function like + early_init_dt_scan_chosen() that retrieves them without modification + to handle CONFIG_CMDLINE. Neither of these sounds particularly + cleaner though, and this way we at least keep the extra work in + arch/mips. + +Origin: upstream, https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7784cac697351f0cc0a4bb619594c0c99348c5aa +Signed-off-by: Paul Burton +Cc: linux-mips@vger.kernel.org + +--- a/arch/mips/kernel/setup.c ++++ b/arch/mips/kernel/setup.c +@@ -538,11 +538,88 @@ static void __init check_kernel_sections + } + } + +-#define USE_PROM_CMDLINE IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER) +-#define USE_DTB_CMDLINE IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_DTB) +-#define EXTEND_WITH_PROM IS_ENABLED(CONFIG_MIPS_CMDLINE_DTB_EXTEND) +-#define BUILTIN_EXTEND_WITH_PROM \ +- IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND) ++static void __init bootcmdline_append(const char *s, size_t max) ++{ ++ if (!s[0] || !max) ++ return; ++ ++ if (boot_command_line[0]) ++ strlcat(boot_command_line, " ", COMMAND_LINE_SIZE); ++ ++ strlcat(boot_command_line, s, max); ++} ++ ++static int __init bootcmdline_scan_chosen(unsigned long node, const char *uname, ++ int depth, void *data) ++{ ++ bool *dt_bootargs = data; ++ const char *p; ++ int l; ++ ++ if (depth != 1 || !data || ++ (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) ++ return 0; ++ ++ p = of_get_flat_dt_prop(node, "bootargs", &l); ++ if (p != NULL && l > 0) { ++ bootcmdline_append(p, min(l, COMMAND_LINE_SIZE)); ++ *dt_bootargs = true; ++ } ++ ++ return 1; ++} ++ ++static void __init bootcmdline_init(char **cmdline_p) ++{ ++ bool dt_bootargs = false; ++ ++ /* ++ * If CMDLINE_OVERRIDE is enabled then initializing the command line is ++ * trivial - we simply use the built-in command line unconditionally & ++ * unmodified. ++ */ ++ if (IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) { ++ strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); ++ return; ++ } ++ ++ /* ++ * If the user specified a built-in command line & ++ * MIPS_CMDLINE_BUILTIN_EXTEND, then the built-in command line is ++ * prepended to arguments from the bootloader or DT so we'll copy them ++ * to the start of boot_command_line here. Otherwise, empty ++ * boot_command_line to undo anything early_init_dt_scan_chosen() did. ++ */ ++ if (IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND)) ++ strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); ++ else ++ boot_command_line[0] = 0; ++ ++ /* ++ * If we're configured to take boot arguments from DT, look for those ++ * now. ++ */ ++ if (IS_ENABLED(CONFIG_MIPS_CMDLINE_FROM_DTB)) ++ of_scan_flat_dt(bootcmdline_scan_chosen, &dt_bootargs); ++ ++ /* ++ * If we didn't get any arguments from DT (regardless of whether that's ++ * because we weren't configured to look for them, or because we looked ++ * & found none) then we'll take arguments from the bootloader. ++ * plat_mem_setup() should have filled arcs_cmdline with arguments from ++ * the bootloader. ++ */ ++ if (IS_ENABLED(CONFIG_MIPS_CMDLINE_DTB_EXTEND) || !dt_bootargs) ++ bootcmdline_append(arcs_cmdline, COMMAND_LINE_SIZE); ++ ++ /* ++ * If the user specified a built-in command line & we didn't already ++ * prepend it, we append it to boot_command_line here. ++ */ ++ if (IS_ENABLED(CONFIG_CMDLINE_BOOL) && ++ !IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND)) ++ bootcmdline_append(builtin_cmdline, COMMAND_LINE_SIZE); ++} + + /* + * arch_mem_init - initialize memory management subsystem +@@ -570,48 +647,12 @@ static void __init arch_mem_init(char ** + { + extern void plat_mem_setup(void); + +- /* +- * Initialize boot_command_line to an innocuous but non-empty string in +- * order to prevent early_init_dt_scan_chosen() from copying +- * CONFIG_CMDLINE into it without our knowledge. We handle +- * CONFIG_CMDLINE ourselves below & don't want to duplicate its +- * content because repeating arguments can be problematic. +- */ +- strlcpy(boot_command_line, " ", COMMAND_LINE_SIZE); +- + /* call board setup routine */ + plat_mem_setup(); + memblock_set_bottom_up(true); + +-#if defined(CONFIG_CMDLINE_BOOL) && defined(CONFIG_CMDLINE_OVERRIDE) +- strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); +-#else +- if ((USE_PROM_CMDLINE && arcs_cmdline[0]) || +- (USE_DTB_CMDLINE && !boot_command_line[0])) +- strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE); +- +- if (EXTEND_WITH_PROM && arcs_cmdline[0]) { +- if (boot_command_line[0]) +- strlcat(boot_command_line, " ", COMMAND_LINE_SIZE); +- strlcat(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE); +- } +- +-#if defined(CONFIG_CMDLINE_BOOL) +- if (builtin_cmdline[0]) { +- if (boot_command_line[0]) +- strlcat(boot_command_line, " ", COMMAND_LINE_SIZE); +- strlcat(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); +- } +- +- if (BUILTIN_EXTEND_WITH_PROM && arcs_cmdline[0]) { +- if (boot_command_line[0]) +- strlcat(boot_command_line, " ", COMMAND_LINE_SIZE); +- strlcat(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE); +- } +-#endif +-#endif ++ bootcmdline_init(cmdline_p); + strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); +- + *cmdline_p = command_line; + + parse_early_param(); diff --git a/target/linux/ramips/patches-5.4/0002-MIPS-Always-define-builtin_cmdline.patch b/target/linux/ramips/patches-5.4/0002-MIPS-Always-define-builtin_cmdline.patch new file mode 100644 index 000000000..03124d07d --- /dev/null +++ b/target/linux/ramips/patches-5.4/0002-MIPS-Always-define-builtin_cmdline.patch @@ -0,0 +1,44 @@ +From b7340422cc16c5deff100812f38114bb5ec81203 Mon Sep 17 00:00:00 2001 +From: Paul Burton +Date: Sat, 12 Oct 2019 20:43:36 +0000 +Subject: [PATCH] MIPS: Always define builtin_cmdline + +Commit 7784cac69735 ("MIPS: cmdline: Clean up boot_command_line +initialization") made use of builtin_cmdline conditional upon plain C if +statements rather than preprocessor #ifdef's. This caused build failures +for configurations with CONFIG_CMDLINE_BOOL=n where builtin_cmdline +wasn't defined, for example: + + arch/mips/kernel/setup.c: In function 'bootcmdline_init': +>> arch/mips/kernel/setup.c:582:30: error: 'builtin_cmdline' undeclared + (first use in this function); did you mean 'builtin_driver'? + strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); + ^~~~~~~~~~~~~~~ + builtin_driver + arch/mips/kernel/setup.c:582:30: note: each undeclared identifier is + reported only once for each function it appears in + +Fix this by defining builtin_cmdline as an empty string in the affected +configurations. All of the paths that use it should be optimized out +anyway so the data itself gets optimized away too. + +Signed-off-by: Paul Burton +Fixes: 7784cac69735 ("MIPS: cmdline: Clean up boot_command_line initialization") +Reported-by: kbuild test robot +Reported-by: Nathan Chancellor +Cc: linux-mips@vger.kernel.org +--- + arch/mips/kernel/setup.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/arch/mips/kernel/setup.c ++++ b/arch/mips/kernel/setup.c +@@ -68,6 +68,8 @@ char __initdata arcs_cmdline[COMMAND_LIN + + #ifdef CONFIG_CMDLINE_BOOL + static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE; ++#else ++static const char builtin_cmdline[] __initconst = ""; + #endif + + /* diff --git a/target/linux/ramips/patches-5.4/0010-MIPS-add-bootargs-override-property.patch b/target/linux/ramips/patches-5.4/0010-MIPS-add-bootargs-override-property.patch new file mode 100644 index 000000000..c19a0fb48 --- /dev/null +++ b/target/linux/ramips/patches-5.4/0010-MIPS-add-bootargs-override-property.patch @@ -0,0 +1,63 @@ +From f15d27f9c90ede4b16eb37f9ae573ef81c2b6996 Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Thu, 31 Dec 2020 18:49:12 +0100 +Subject: [PATCH] MIPS: add bootargs-override property + +Add support for the bootargs-override property to the chosen node +similar to the one used on ipq806x or mpc85xx. + +This is necessary, as the U-Boot used on some boards, notably the +Ubiquiti UniFi 6 Lite, overwrite the bootargs property of the chosen +node leading to a kernel panic when loading OpenWrt. + +Signed-off-by: David Bauer +--- + arch/mips/kernel/setup.c | 30 ++++++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + +--- a/arch/mips/kernel/setup.c ++++ b/arch/mips/kernel/setup.c +@@ -571,8 +571,28 @@ static int __init bootcmdline_scan_chose + return 1; + } + ++static int __init bootcmdline_scan_chosen_override(unsigned long node, const char *uname, ++ int depth, void *data) ++{ ++ bool *dt_bootargs = data; ++ const char *p; ++ int l; ++ ++ if (depth != 1 || !data || strcmp(uname, "chosen") != 0) ++ return 0; ++ ++ p = of_get_flat_dt_prop(node, "bootargs-override", &l); ++ if (p != NULL && l > 0) { ++ strlcpy(boot_command_line, p, COMMAND_LINE_SIZE); ++ *dt_bootargs = true; ++ } ++ ++ return 1; ++} ++ + static void __init bootcmdline_init(char **cmdline_p) + { ++ bool dt_bootargs_override = false; + bool dt_bootargs = false; + + /* +@@ -586,6 +606,14 @@ static void __init bootcmdline_init(char + } + + /* ++ * If bootargs-override in the chosen node is set, use this as the ++ * command line ++ */ ++ of_scan_flat_dt(bootcmdline_scan_chosen_override, &dt_bootargs_override); ++ if (dt_bootargs_override) ++ return; ++ ++ /* + * If the user specified a built-in command line & + * MIPS_CMDLINE_BUILTIN_EXTEND, then the built-in command line is + * prepended to arguments from the bootloader or DT so we'll copy them diff --git a/target/linux/ramips/patches-5.4/0038-mtd-ralink-add-mt7620-nand-driver.patch b/target/linux/ramips/patches-5.4/0038-mtd-ralink-add-mt7620-nand-driver.patch deleted file mode 100644 index e70b6830e..000000000 --- a/target/linux/ramips/patches-5.4/0038-mtd-ralink-add-mt7620-nand-driver.patch +++ /dev/null @@ -1,2386 +0,0 @@ -From afb07a5b467217af1df4162c707cbe554a79130d Mon Sep 17 00:00:00 2001 -From: Chen Minqiang -Date: Thu, 3 Sep 2020 03:27:48 +0800 -Subject: [PATCH] mtd ralink add mt7620-nand driver - ---- - drivers/mtd/maps/Kconfig | 4 + - drivers/mtd/maps/Makefile | 1 + - drivers/mtd/maps/ralink_nand.c | 2095 ++++++++++++++++++++++++++++++++ - drivers/mtd/maps/ralink_nand.h | 240 ++++ - 4 files changed, 2340 insertions(+) - create mode 100644 drivers/mtd/maps/ralink_nand.c - create mode 100644 drivers/mtd/maps/ralink_nand.h - -diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig -index bc82305eb..aef3a33cb 100644 ---- a/drivers/mtd/maps/Kconfig -+++ b/drivers/mtd/maps/Kconfig -@@ -401,4 +401,8 @@ config MTD_PISMO - - When built as a module, it will be called pismo.ko - -+config MTD_NAND_MT7620 -+ tristate "Support for NAND on Mediatek MT7620" -+ depends on RALINK && SOC_MT7620 -+ - endmenu -diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile -index 1146009f4..0d41a57bb 100644 ---- a/drivers/mtd/maps/Makefile -+++ b/drivers/mtd/maps/Makefile -@@ -44,3 +44,4 @@ obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o - obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o - obj-$(CONFIG_MTD_VMU) += vmu-flash.o - obj-$(CONFIG_MTD_LANTIQ) += lantiq-flash.o -+obj-$(CONFIG_MTD_NAND_MT7620) += ralink_nand.o -diff --git a/drivers/mtd/maps/ralink_nand.c b/drivers/mtd/maps/ralink_nand.c -new file mode 100644 -index 000000000..7abb8affc ---- /dev/null -+++ b/drivers/mtd/maps/ralink_nand.c -@@ -0,0 +1,2095 @@ -+#define DEBUG -+#include -+#undef DEBUG -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "ralink_nand.h" -+#ifdef RANDOM_GEN_BAD_BLOCK -+#include -+#endif -+ -+#define LARGE_MTD_BOOT_PART_SIZE (CFG_BLOCKSIZE<<2) -+#define LARGE_MTD_CONFIG_PART_SIZE (CFG_BLOCKSIZE<<2) -+#define LARGE_MTD_FACTORY_PART_SIZE (CFG_BLOCKSIZE<<1) -+ -+#define BLOCK_ALIGNED(a) ((a) & (CFG_BLOCKSIZE - 1)) -+ -+#define READ_STATUS_RETRY 1000 -+ -+struct nand_ecclayout { -+ __u32 eccbytes; -+ __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES_LARGE]; -+ __u32 oobavail; -+ struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE]; -+}; -+ -+struct mtd_info *ranfc_mtd = NULL; -+ -+int skipbbt = 0; -+int ranfc_debug = 1; -+static int ranfc_bbt = 1; -+#if defined (WORKAROUND_RX_BUF_OV) -+static int ranfc_verify = 1; -+#endif -+static u32 nand_addrlen; -+ -+#if 0 -+module_param(ranfc_debug, int, 0644); -+module_param(ranfc_bbt, int, 0644); -+module_param(ranfc_verify, int, 0644); -+#endif -+ -+#if 0 -+#define ra_dbg(args...) do { if (ranfc_debug) printk(args); } while(0) -+#else -+#define ra_dbg(args...) -+#endif -+ -+#define CLEAR_INT_STATUS() ra_outl(NFC_INT_ST, ra_inl(NFC_INT_ST)) -+#define NFC_TRANS_DONE() (ra_inl(NFC_INT_ST) & INT_ST_ND_DONE) -+ -+int is_nand_page_2048 = 0; -+const unsigned int nand_size_map[2][3] = {{25, 30, 30}, {20, 27, 30}}; -+ -+static int nfc_wait_ready(int snooze_ms); -+ -+static const char * const mtk_probe_types[] = { "cmdlinepart", "ofpart", NULL }; -+ -+/** -+ * reset nand chip -+ */ -+static int nfc_chip_reset(void) -+{ -+ int status; -+ -+ //ra_dbg("%s:\n", __func__); -+ -+ // reset nand flash -+ ra_outl(NFC_CMD1, 0x0); -+ ra_outl(NFC_CMD2, 0xff); -+ ra_outl(NFC_ADDR, 0x0); -+ ra_outl(NFC_CONF, 0x0411); -+ -+ status = nfc_wait_ready(5); //erase wait 5us -+ if (status & NAND_STATUS_FAIL) { -+ printk("%s: fail \n", __func__); -+ } -+ -+ return (int)(status & NAND_STATUS_FAIL); -+} -+ -+/** -+ * clear NFC and flash chip. -+ */ -+static int nfc_all_reset(void) -+{ -+ int retry; -+ -+ ra_dbg("%s: \n", __func__); -+ -+ // reset controller -+ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x02); //clear data buffer -+ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) & ~0x02); //clear data buffer -+ -+ CLEAR_INT_STATUS(); -+ -+ retry = READ_STATUS_RETRY; -+ while ((ra_inl(NFC_INT_ST) & 0x02) != 0x02 && retry--); -+ if (retry <= 0) { -+ printk("nfc_all_reset: clean buffer fail \n"); -+ return -1; -+ } -+ -+ retry = READ_STATUS_RETRY; -+ while ((ra_inl(NFC_STATUS) & 0x1) != 0x0 && retry--) { //fixme, controller is busy ? -+ udelay(1); -+ } -+ -+ nfc_chip_reset(); -+ -+ return 0; -+} -+ -+/** NOTICE: only called by nfc_wait_ready(). -+ * @return -1, nfc can not get transction done -+ * @return 0, ok. -+ */ -+static int _nfc_read_status(char *status) -+{ -+ unsigned long cmd1, conf; -+ int int_st, nfc_st; -+ int retry; -+ -+ cmd1 = 0x70; -+ conf = 0x000101 | (1 << 20); -+ -+ //fixme, should we check nfc status? -+ CLEAR_INT_STATUS(); -+ -+ ra_outl(NFC_CMD1, cmd1); -+ ra_outl(NFC_CONF, conf); -+ -+ /* FIXME, -+ * 1. since we have no wired ready signal, directly -+ * calling this function is not gurantee to read right status under ready state. -+ * 2. the other side, we can not determine how long to become ready, this timeout retry is nonsense. -+ * 3. SUGGESTION: call nfc_read_status() from nfc_wait_ready(), -+ * that is aware about caller (in sementics) and has snooze plused nfc ND_DONE. -+ */ -+ retry = READ_STATUS_RETRY; -+ do { -+ nfc_st = ra_inl(NFC_STATUS); -+ int_st = ra_inl(NFC_INT_ST); -+ -+ ndelay(10); -+ } while (!(int_st & INT_ST_RX_BUF_RDY) && retry--); -+ -+ if (!(int_st & INT_ST_RX_BUF_RDY)) { -+ printk("nfc_read_status: NFC fail, int_st(%x), retry:%x. nfc:%x, reset nfc and flash. \n", -+ int_st, retry, nfc_st); -+ nfc_all_reset(); -+ *status = NAND_STATUS_FAIL; -+ return -1; -+ } -+ -+ *status = (char)(le32_to_cpu(ra_inl(NFC_DATA)) & 0x0ff); -+ return 0; -+} -+ -+/** -+ * @return !0, chip protect. -+ * @return 0, chip not protected. -+ */ -+static int nfc_check_wp(void) -+{ -+ /* Check the WP bit */ -+#if !defined CONFIG_NOT_SUPPORT_WP -+ return !!(ra_inl(NFC_CTRL) & 0x01); -+#else -+ char result = 0; -+ int ret; -+ -+ ret = _nfc_read_status(&result); -+ //FIXME, if ret < 0 -+ -+ return !(result & NAND_STATUS_WP); -+#endif -+} -+ -+#if !defined CONFIG_NOT_SUPPORT_RB -+/* -+ * @return !0, chip ready. -+ * @return 0, chip busy. -+ */ -+static int nfc_device_ready(void) -+{ -+ /* Check the ready */ -+ return !!(ra_inl(NFC_STATUS) & 0x04); -+} -+#endif -+ -+/** -+ * generic function to get data from flash. -+ * @return data length reading from flash. -+ */ -+static int _ra_nand_pull_data(char *buf, int len, int use_gdma) -+{ -+#ifdef RW_DATA_BY_BYTE -+ char *p = buf; -+#else -+ __u32 *p = (__u32 *)buf; -+#endif -+ int retry, int_st; -+ unsigned int ret_data; -+ int ret_size; -+ -+ // receive data by use_gdma -+ if (use_gdma) { -+ //if (_ra_nand_dma_pull((unsigned long)p, len)) { -+ if (1) { -+ printk("%s: fail \n", __func__); -+ len = -1; //return error -+ } -+ -+ return len; -+ } -+ -+ //fixme: retry count size? -+ retry = READ_STATUS_RETRY; -+ // no gdma -+ while (len > 0) { -+ int_st = ra_inl(NFC_INT_ST); -+ if (int_st & INT_ST_RX_BUF_RDY) { -+ -+ ret_data = ra_inl(NFC_DATA); -+ ra_outl(NFC_INT_ST, INT_ST_RX_BUF_RDY); -+#ifdef RW_DATA_BY_BYTE -+ ret_size = sizeof(unsigned int); -+ ret_size = min(ret_size, len); -+ len -= ret_size; -+ while (ret_size-- > 0) { -+ //nfc is little endian -+ *p++ = ret_data & 0x0ff; -+ ret_data >>= 8; -+ } -+#else -+ ret_size = min(len, 4); -+ len -= ret_size; -+ if (ret_size == 4) -+ *p++ = ret_data; -+ else { -+ __u8 *q = (__u8 *)p; -+ while (ret_size-- > 0) { -+ *q++ = ret_data & 0x0ff; -+ ret_data >>= 8; -+ } -+ p = (__u32 *)q; -+ } -+#endif -+ retry = READ_STATUS_RETRY; -+ } -+ else if (int_st & INT_ST_ND_DONE) { -+ break; -+ } -+ else { -+ udelay(1); -+ if (retry-- < 0) -+ break; -+ } -+ } -+ -+#ifdef RW_DATA_BY_BYTE -+ return (int)(p - buf); -+#else -+ return ((int)p - (int)buf); -+#endif -+} -+ -+/** -+ * generic function to put data into flash. -+ * @return data length writing into flash. -+ */ -+static int _ra_nand_push_data(char *buf, int len, int use_gdma) -+{ -+#ifdef RW_DATA_BY_BYTE -+ char *p = buf; -+#else -+ __u32 *p = (__u32 *)buf; -+#endif -+ int retry, int_st; -+ unsigned int tx_data = 0; -+ int tx_size, iter = 0; -+ -+ // receive data by use_gdma -+ if (use_gdma) { -+ //if (_ra_nand_dma_push((unsigned long)p, len)) -+ if (1) -+ len = 0; -+ printk("%s: fail \n", __func__); -+ return len; -+ } -+ -+ // no gdma -+ retry = READ_STATUS_RETRY; -+ while (len > 0) { -+ int_st = ra_inl(NFC_INT_ST); -+ if (int_st & INT_ST_TX_BUF_RDY) { -+#ifdef RW_DATA_BY_BYTE -+ tx_size = min(len, (int)sizeof(unsigned long)); -+ for (iter = 0; iter < tx_size; iter++) { -+ tx_data |= (*p++ << (8*iter)); -+ } -+#else -+ tx_size = min(len, 4); -+ if (tx_size == 4) -+ tx_data = (*p++); -+ else { -+ __u8 *q = (__u8 *)p; -+ for (iter = 0; iter < tx_size; iter++) -+ tx_data |= (*q++ << (8*iter)); -+ p = (__u32 *)q; -+ } -+#endif -+ ra_outl(NFC_INT_ST, INT_ST_TX_BUF_RDY); -+ ra_outl(NFC_DATA, tx_data); -+ len -= tx_size; -+ retry = READ_STATUS_RETRY; -+ } -+ else if (int_st & INT_ST_ND_DONE) { -+ break; -+ } -+ else { -+ udelay(1); -+ if (retry-- < 0) { -+ ra_dbg("%s p:%p buf:%p \n", __func__, p, buf); -+ break; -+ } -+ } -+ } -+ -+#ifdef RW_DATA_BY_BYTE -+ return (int)(p - buf); -+#else -+ return ((int)p - (int)buf); -+#endif -+} -+ -+static int nfc_select_chip(struct ra_nand_chip *ra, int chipnr) -+{ -+#if (CONFIG_NUMCHIPS == 1) -+ if (!(chipnr < CONFIG_NUMCHIPS)) -+ return -1; -+ return 0; -+#else -+ BUG(); -+#endif -+} -+ -+/** @return -1: chip_select fail -+ * 0 : both CE and WP==0 are OK -+ * 1 : CE OK and WP==1 -+ */ -+static int nfc_enable_chip(struct ra_nand_chip *ra, unsigned int offs, int read_only) -+{ -+ int chipnr = offs >> ra->chip_shift; -+ -+ ra_dbg("%s: offs:%x read_only:%x \n", __func__, offs, read_only); -+ -+ chipnr = nfc_select_chip(ra, chipnr); -+ if (chipnr < 0) { -+ printk("%s: chip select error, offs(%x)\n", __func__, offs); -+ return -1; -+ } -+ -+ if (!read_only) -+ return nfc_check_wp(); -+ -+ return 0; -+} -+ -+/** wait nand chip becomeing ready and return queried status. -+ * @param snooze: sleep time in ms unit before polling device ready. -+ * @return status of nand chip -+ * @return NAN_STATUS_FAIL if something unexpected. -+ */ -+static int nfc_wait_ready(int snooze_ms) -+{ -+ int retry; -+ char status; -+ -+ // wait nfc idle, -+ if (snooze_ms == 0) -+ snooze_ms = 1; -+ else -+ schedule_timeout(snooze_ms * HZ / 1000); -+ -+ snooze_ms = retry = snooze_ms *1000000 / 100 ; // ndelay(100) -+ -+ while (!NFC_TRANS_DONE() && retry--) { -+ if (!cond_resched()) -+ ndelay(100); -+ } -+ -+ if (!NFC_TRANS_DONE()) { -+ printk("nfc_wait_ready: no transaction done \n"); -+ return NAND_STATUS_FAIL; -+ } -+ -+#if !defined (CONFIG_NOT_SUPPORT_RB) -+ //fixme -+ while(!(status = nfc_device_ready()) && retry--) { -+ ndelay(100); -+ } -+ -+ if (status == 0) { -+ printk("nfc_wait_ready: no device ready. \n"); -+ return NAND_STATUS_FAIL; -+ } -+ -+ _nfc_read_status(&status); -+ return status; -+#else -+ -+ while(retry--) { -+ _nfc_read_status(&status); -+ if (status & NAND_STATUS_READY) -+ break; -+ ndelay(100); -+ } -+ if (retry<0) -+ printk("nfc_wait_ready 2: no device ready, status(%x). \n", status); -+ -+ return status; -+#endif -+} -+ -+/** -+ * return 0: erase OK -+ * return -EIO: fail -+ */ -+int nfc_erase_block(struct ra_nand_chip *ra, int row_addr) -+{ -+ unsigned long cmd1, cmd2, bus_addr, conf; -+ char status; -+ -+ cmd1 = 0x60; -+ cmd2 = 0xd0; -+ bus_addr = row_addr; -+ conf = 0x00511 | ((CFG_ROW_ADDR_CYCLE)<<16); -+ -+ // set NFC -+ ra_dbg("%s: cmd1: %lx, cmd2:%lx bus_addr: %lx, conf: %lx \n", -+ __func__, cmd1, cmd2, bus_addr, conf); -+ -+ //fixme, should we check nfc status? -+ CLEAR_INT_STATUS(); -+ -+ ra_outl(NFC_CMD1, cmd1); -+ ra_outl(NFC_CMD2, cmd2); -+ ra_outl(NFC_ADDR, bus_addr); -+ ra_outl(NFC_CONF, conf); -+ -+ status = nfc_wait_ready(3); //erase wait 3ms -+ if (status & NAND_STATUS_FAIL) { -+ printk("%s: fail \n", __func__); -+ return -EIO; -+ } -+ -+ return 0; -+} -+ -+static inline int _nfc_read_raw_data(int cmd1, int cmd2, int bus_addr, int bus_addr2, int conf, char *buf, int len, int flags) -+{ -+ int ret; -+ -+ CLEAR_INT_STATUS(); -+ ra_outl(NFC_CMD1, cmd1); -+ ra_outl(NFC_CMD2, cmd2); -+ ra_outl(NFC_ADDR, bus_addr); -+#if defined (CONFIG_SOC_MT7620) -+ ra_outl(NFC_ADDR2, bus_addr2); -+#endif -+ ra_outl(NFC_CONF, conf); -+ -+ ret = _ra_nand_pull_data(buf, len, 0); -+ if (ret != len) { -+ ra_dbg("%s: ret:%x (%x) \n", __func__, ret, len); -+ return NAND_STATUS_FAIL; -+ } -+ -+ //FIXME, this section is not necessary -+ ret = nfc_wait_ready(0); //wait ready -+ /* to prevent the DATA FIFO 's old data from next operation */ -+ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x02); //clear data buffer -+ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) & ~0x02); //clear data buffer -+ -+ if (ret & NAND_STATUS_FAIL) { -+ printk("%s: fail \n", __func__); -+ return NAND_STATUS_FAIL; -+ } -+ -+ return 0; -+} -+ -+static inline int _nfc_write_raw_data(int cmd1, int cmd3, int bus_addr, int bus_addr2, int conf, char *buf, int len, int flags) -+{ -+ int ret; -+ -+ CLEAR_INT_STATUS(); -+ ra_outl(NFC_CMD1, cmd1); -+ ra_outl(NFC_CMD3, cmd3); -+ ra_outl(NFC_ADDR, bus_addr); -+#if defined (CONFIG_SOC_MT7620) -+ ra_outl(NFC_ADDR2, bus_addr2); -+#endif -+ ra_outl(NFC_CONF, conf); -+ -+ ret = _ra_nand_push_data(buf, len, 0); -+ if (ret != len) { -+ ra_dbg("%s: ret:%x (%x) \n", __func__, ret, len); -+ return NAND_STATUS_FAIL; -+ } -+ -+ ret = nfc_wait_ready(1); //write wait 1ms -+ /* to prevent the DATA FIFO 's old data from next operation */ -+ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x02); //clear data buffer -+ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) & ~0x02); //clear data buffer -+ -+ if (ret & NAND_STATUS_FAIL) { -+ printk("%s: fail \n", __func__); -+ return NAND_STATUS_FAIL; -+ } -+ -+ return 0; -+} -+ -+/** -+ * @return !0: fail -+ * @return 0: OK -+ */ -+int nfc_read_oob(struct ra_nand_chip *ra, int page, unsigned int offs, char *buf, int len, int flags) -+{ -+ unsigned int cmd1 = 0, cmd2 = 0, conf = 0; -+ unsigned int bus_addr = 0, bus_addr2 = 0; -+ unsigned int ecc_en; -+ int use_gdma; -+ int status; -+ -+ int pages_perblock = 1<<(ra->erase_shift - ra->page_shift); -+ // constrain of nfc read function -+ -+#if defined (WORKAROUND_RX_BUF_OV) -+ BUG_ON (len > 60); //problem of rx-buffer overrun -+#endif -+ BUG_ON (offs >> ra->oob_shift); //page boundry -+ BUG_ON ((unsigned int)(((offs + len) >> ra->oob_shift) + page) > -+ ((page + pages_perblock) & ~(pages_perblock-1))); //block boundry -+ -+ use_gdma = flags & FLAG_USE_GDMA; -+ ecc_en = flags & FLAG_ECC_EN; -+ bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)) | (offs & ((1<> (CFG_COLUMN_ADDR_CYCLE*8); -+ cmd1 = 0x0; -+ cmd2 = 0x30; -+ conf = 0x000511| ((CFG_ADDR_CYCLE)<<16) | (len << 20); -+ } -+ else { -+ cmd1 = 0x50; -+ conf = 0x000141| ((CFG_ADDR_CYCLE)<<16) | (len << 20); -+ } -+ if (ecc_en) -+ conf |= (1<<3); -+ if (use_gdma) -+ conf |= (1<<2); -+ -+ ra_dbg("%s: cmd1:%x, bus_addr:%x, conf:%x, len:%x, flag:%x\n", -+ __func__, cmd1, bus_addr, conf, len, flags); -+ -+ status = _nfc_read_raw_data(cmd1, cmd2, bus_addr, bus_addr2, conf, buf, len, flags); -+ if (status & NAND_STATUS_FAIL) { -+ printk("%s: fail\n", __func__); -+ return -EIO; -+ } -+ -+ return 0; -+} -+ -+/** -+ * @return !0: fail -+ * @return 0: OK -+ */ -+int nfc_write_oob(struct ra_nand_chip *ra, int page, unsigned int offs, char *buf, int len, int flags) -+{ -+ unsigned int cmd1 = 0, cmd3=0, conf = 0; -+ unsigned int bus_addr = 0, bus_addr2 = 0; -+ int use_gdma; -+ int status; -+ -+ int pages_perblock = 1<<(ra->erase_shift - ra->page_shift); -+ // constrain of nfc read function -+ -+ BUG_ON (offs >> ra->oob_shift); //page boundry -+ BUG_ON ((unsigned int)(((offs + len) >> ra->oob_shift) + page) > -+ ((page + pages_perblock) & ~(pages_perblock-1))); //block boundry -+ -+ use_gdma = flags & FLAG_USE_GDMA; -+ bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)) | (offs & ((1<> (CFG_COLUMN_ADDR_CYCLE*8); -+ conf = 0x001123 | ((CFG_ADDR_CYCLE)<<16) | ((len) << 20); -+ } -+ else { -+ cmd1 = 0x08050; -+ cmd3 = 0x10; -+ conf = 0x001223 | ((CFG_ADDR_CYCLE)<<16) | ((len) << 20); -+ } -+ if (use_gdma) -+ conf |= (1<<2); -+ -+ // set NFC -+ ra_dbg("%s: cmd1: %x, cmd3: %x bus_addr: %x, conf: %x, len:%x\n", -+ __func__, cmd1, cmd3, bus_addr, conf, len); -+ -+ status = _nfc_write_raw_data(cmd1, cmd3, bus_addr, bus_addr2, conf, buf, len, flags); -+ if (status & NAND_STATUS_FAIL) { -+ printk("%s: fail \n", __func__); -+ return -EIO; -+ } -+ -+ return 0; -+} -+ -+ -+int nfc_read_page(struct ra_nand_chip *ra, char *buf, int page, int flags); -+int nfc_write_page(struct ra_nand_chip *ra, char *buf, int page, int flags); -+ -+ -+#if !defined (WORKAROUND_RX_BUF_OV) -+static int one_bit_correction(char *ecc, char *expected, int *bytes, int *bits); -+int nfc_ecc_verify(struct ra_nand_chip *ra, char *buf, int page, int mode) -+{ -+ int ret, i; -+ char *p, *e; -+ int ecc; -+ -+ //ra_dbg("%s, page:%x mode:%d\n", __func__, page, mode); -+ -+ if (mode == FL_WRITING) { -+ int len = CFG_PAGESIZE + CFG_PAGE_OOBSIZE; -+ int conf = 0x000141| ((CFG_ADDR_CYCLE)<<16) | (len << 20); -+ conf |= (1<<3); //(ecc_en) -+ //conf |= (1<<2); // (use_gdma) -+ -+ p = ra->readback_buffers; -+ ret = nfc_read_page(ra, ra->readback_buffers, page, FLAG_ECC_EN); -+ if (ret == 0) -+ goto ecc_check; -+ -+ //FIXME, double comfirm -+ printk("%s: read back fail, try again \n",__func__); -+ ret = nfc_read_page(ra, ra->readback_buffers, page, FLAG_ECC_EN); -+ if (ret != 0) { -+ printk("\t%s: read back fail agian \n",__func__); -+ goto bad_block; -+ } -+ } -+ else if (mode == FL_READING) { -+ p = buf; -+ } -+ else -+ return -2; -+ -+ecc_check: -+ p += CFG_PAGESIZE; -+ if (!is_nand_page_2048) { -+ ecc = ra_inl(NFC_ECC); -+ if (ecc == 0) //clean page. -+ return 0; -+ e = (char*)&ecc; -+ for (i=0; ireadback_buffers, page, FLAG_NONE); -+ if (ret != 0) //double comfirm -+ ret = nfc_read_page(ra, ra->readback_buffers, page, FLAG_NONE); -+ -+ if (ret != 0) { -+ printk("%s: mode:%x read back fail \n", __func__, mode); -+ return -1; -+ } -+ return memcmp(buf, ra->readback_buffers, 1<page_shift); -+ } -+ -+ if (mode == FL_READING) { -+#if 0 -+ if (ra->sandbox_page == 0) -+ return 0; -+ -+ ret = nfc_write_page(ra, buf, ra->sandbox_page, FLAG_USE_GDMA | FLAG_ECC_EN); -+ if (ret != 0) { -+ printk("%s, fail write sandbox_page \n", __func__); -+ return -1; -+ } -+#else -+ /** @note: -+ * The following command is actually not 'write' command to drive NFC to write flash. -+ * However, it can make NFC to calculate ECC, that will be used to compare with original ones. -+ * --YT -+ */ -+ unsigned int conf = 0x001223| (CFG_ADDR_CYCLE<<16) | (0x200 << 20) | (1<<3) | (1<<2); -+ _nfc_write_raw_data(0xff, 0xff, ra->sandbox_page<page_shift, conf, buf, 0x200, FLAG_USE_GDMA); -+#endif -+ -+ ecc = ra_inl(NFC_ECC); -+ if (ecc == 0) //clean page. -+ return 0; -+ e = (char*)&ecc; -+ p = buf + (1<page_shift); -+ for (i=0; i 0) { -+ int len; -+#if defined (WORKAROUND_RX_BUF_OV) -+ len = min(60, size); -+#else -+ len = size; -+#endif -+ bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)) | (offs & ((1<> (CFG_COLUMN_ADDR_CYCLE*8); -+ cmd1 = 0x0; -+ cmd2 = 0x30; -+ conf = 0x000511| ((CFG_ADDR_CYCLE)<<16) | (len << 20); -+ } -+ else { -+ if (offs & ~(CFG_PAGESIZE-1)) -+ cmd1 = 0x50; -+ else if (offs & ~((1<buffers_page = -1; //cached -+ } -+ -+ return 0; -+} -+ -+ -+/** -+ * @return -EIO, fail to write -+ * @return 0, OK -+ */ -+int nfc_write_page(struct ra_nand_chip *ra, char *buf, int page, int flags) -+{ -+ unsigned int cmd1 = 0, cmd3, conf = 0; -+ unsigned int bus_addr = 0, bus_addr2 = 0; -+ unsigned int ecc_en; -+ int use_gdma; -+ int size; -+ char status; -+ uint8_t *oob = buf + (1<page_shift); -+ -+ use_gdma = flags & FLAG_USE_GDMA; -+ ecc_en = flags & FLAG_ECC_EN; -+ -+ oob[ra->badblockpos] = 0xff; //tag as good block. -+ ra->buffers_page = -1; //cached -+ -+ page = page & (CFG_CHIPSIZE-1); //chip boundary -+ size = CFG_PAGESIZE + CFG_PAGE_OOBSIZE; //add oobsize -+ bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)); //write_page always write from offset 0. -+ -+ if (is_nand_page_2048) { -+ bus_addr2 = page >> (CFG_COLUMN_ADDR_CYCLE*8); -+ cmd1 = 0x80; -+ cmd3 = 0x10; -+ conf = 0x001123| ((CFG_ADDR_CYCLE)<<16) | (size << 20); -+ } -+ else { -+ cmd1 = 0x8000; -+ cmd3 = 0x10; -+ conf = 0x001223| ((CFG_ADDR_CYCLE)<<16) | (size << 20); -+ } -+ if (ecc_en) -+ conf |= (1<<3); //enable ecc -+ if (use_gdma) -+ conf |= (1<<2); -+ -+ // set NFC -+ ra_dbg("nfc_write_page: cmd1: %x, cmd3: %x bus_addr: %x, conf: %x, len:%x\n", -+ cmd1, cmd3, bus_addr, conf, size); -+ -+ status = _nfc_write_raw_data(cmd1, cmd3, bus_addr, bus_addr2, conf, buf, size, flags); -+ if (status & NAND_STATUS_FAIL) { -+ printk("%s: fail \n", __func__); -+ return -EIO; -+ } -+ -+ -+ if (flags & FLAG_VERIFY) { // verify and correct ecc -+ status = nfc_ecc_verify(ra, buf, page, FL_WRITING); -+ -+#ifdef RANDOM_GEN_BAD_BLOCK -+ if (((random32() & 0x1ff) == 0x0) && (page >= 0x100)) // randomly create bad block -+ { -+ printk("hmm... create a bad block at page %x\n", (bus_addr >> 16)); -+ status = -1; -+ } -+#endif -+ -+ if (status != 0) { -+ printk("%s: ecc_verify fail: ret:%x \n", __func__, status); -+ oob[ra->badblockpos] = 0x33; -+ page -= page % (CFG_BLOCKSIZE/CFG_PAGESIZE); -+ printk("create a bad block at page %x\n", page); -+ if (!is_nand_page_2048) -+ status = nfc_write_oob(ra, page, ra->badblockpos, oob+ra->badblockpos, 1, flags); -+ else -+ { -+ status = _nfc_write_raw_data(cmd1, cmd3, bus_addr, bus_addr2, conf, buf, size, flags); -+ nfc_write_oob(ra, page, 0, oob, 16, FLAG_NONE); -+ } -+ return -EBADMSG; -+ } -+ } -+ -+ ra->buffers_page = page; //cached -+ return 0; -+} -+ -+ -+ -+/************************************************************* -+ * nand internal process -+ *************************************************************/ -+ -+/** -+ * nand_release_device - [GENERIC] release chip -+ * @mtd: MTD device structure -+ * -+ * Deselect, release chip lock and wake up anyone waiting on the device -+ */ -+static void nand_release_device(struct ra_nand_chip *ra) -+{ -+ /* De-select the NAND device */ -+ nfc_select_chip(ra, -1); -+ -+ /* Release the controller and the chip */ -+ ra->state = FL_READY; -+ -+ mutex_unlock(ra->controller); -+} -+ -+/** -+ * nand_get_device - [GENERIC] Get chip for selected access -+ * @chip: the nand chip descriptor -+ * @mtd: MTD device structure -+ * @new_state: the state which is requested -+ * -+ * Get the device and lock it for exclusive access -+ */ -+static int -+nand_get_device(struct ra_nand_chip *ra, int new_state) -+{ -+ int ret = 0; -+ -+ ret = mutex_lock_interruptible(ra->controller); -+ if (!ret) -+ ra->state = new_state; -+ -+ return ret; -+} -+ -+/************************************************************* -+ * nand internal process -+ *************************************************************/ -+ -+int ra_nand_bbt_get(struct ra_nand_chip *ra, int block) -+{ -+ int byte, bits; -+ bits = block * BBTTAG_BITS; -+ -+ byte = bits / 8; -+ bits = bits % 8; -+ -+ return (ra->bbt[byte] >> bits) & BBTTAG_BITS_MASK; -+} -+ -+int ra_nand_bbt_set(struct ra_nand_chip *ra, int block, int tag) -+{ -+ int byte, bits; -+ bits = block * BBTTAG_BITS; -+ -+ byte = bits / 8; -+ bits = bits % 8; -+ -+ // If previous tag is bad, dont overwrite it -+ if (((ra->bbt[byte] >> bits) & BBTTAG_BITS_MASK) == BBT_TAG_BAD) -+ { -+ return BBT_TAG_BAD; -+ } -+ -+ ra->bbt[byte] = (ra->bbt[byte] & ~(BBTTAG_BITS_MASK << bits)) | ((tag & BBTTAG_BITS_MASK) << bits); -+ -+ return tag; -+} -+ -+/** -+ * nand_block_checkbad - [GENERIC] Check if a block is marked bad -+ * @mtd: MTD device structure -+ * @ofs: offset from device start -+ * -+ * Check, if the block is bad. Either by reading the bad block table or -+ * calling of the scan function. -+ */ -+int nand_block_checkbad(struct ra_nand_chip *ra, loff_t offs) -+{ -+ int page, block; -+ int ret = 4; -+ unsigned int tag; -+ char *str[]= {"UNK", "RES", "BAD", "GOOD"}; -+ -+ if (ranfc_bbt == 0) -+ return 0; -+ -+ { -+ // align with chip -+ -+ offs = offs & ((1<chip_shift) -1); -+ -+ page = offs >> ra->page_shift; -+ block = offs >> ra->erase_shift; -+ } -+ -+ tag = ra_nand_bbt_get(ra, block); -+ -+ if (tag == BBT_TAG_UNKNOWN) { -+ ret = nfc_read_oob(ra, page, ra->badblockpos, (char*)&tag, 1, FLAG_NONE); -+ if (ret == 0) -+ tag = ((le32_to_cpu(tag) & 0x0ff) == 0x0ff) ? BBT_TAG_GOOD : BBT_TAG_BAD; -+ else -+ tag = BBT_TAG_BAD; -+ -+ ra_nand_bbt_set(ra, block, tag); -+ } -+ -+ if (tag != BBT_TAG_GOOD) { -+ printk("%s: offs:%x tag: %s \n", __func__, (unsigned int)offs, str[tag]); -+ return 1; -+ } -+ else -+ return 0; -+} -+ -+/** -+ * nand_block_markbad - -+ */ -+int nand_block_markbad(struct ra_nand_chip *ra, loff_t offs) -+{ -+ int page, block; -+ int ret = 4; -+ unsigned int tag; -+ char *ecc; -+ -+ // align with chip -+ ra_dbg("%s offs: %x \n", __func__, (int)offs); -+ -+ offs = offs & ((1<chip_shift) -1); -+ -+ page = offs >> ra->page_shift; -+ block = offs >> ra->erase_shift; -+ -+ tag = ra_nand_bbt_get(ra, block); -+ -+ if (tag == BBT_TAG_BAD) { -+ printk("%s: mark repeatedly \n", __func__); -+ return 0; -+ } -+ -+ // new tag as bad -+ tag =BBT_TAG_BAD; -+ ret = nfc_read_page(ra, ra->buffers, page, FLAG_NONE); -+ if (ret != 0) { -+ printk("%s: fail to read bad block tag \n", __func__); -+ goto tag_bbt; -+ } -+ -+ ecc = &ra->buffers[(1<page_shift)+ra->badblockpos]; -+ if (*ecc == (char)0x0ff) { -+ //tag into flash -+ *ecc = (char)tag; -+ ret = nfc_write_page(ra, ra->buffers, page, FLAG_USE_GDMA); -+ if (ret) -+ printk("%s: fail to write bad block tag \n", __func__); -+ } -+ -+tag_bbt: -+ //update bbt -+ ra_nand_bbt_set(ra, block, tag); -+ -+ return 0; -+} -+ -+#if defined (WORKAROUND_RX_BUF_OV) -+/** -+ * to find a bad block for ecc verify of read_page -+ */ -+unsigned int nand_bbt_find_sandbox(struct ra_nand_chip *ra) -+{ -+ loff_t offs = 0; -+ int chipsize = 1 << ra->chip_shift; -+ int blocksize = 1 << ra->erase_shift; -+ -+ -+ while (offs < chipsize) { -+ if (nand_block_checkbad(ra, offs)) //scan and verify the unknown tag -+ break; -+ offs += blocksize; -+ } -+ -+ if (offs >= chipsize) { -+ offs = chipsize - blocksize; -+ } -+ -+ ra_nand_bbt_set(ra, (unsigned int)offs>>ra->erase_shift, BBT_TAG_RES); // tag bbt only, instead of update badblockpos of flash. -+ return (offs >> ra->page_shift); -+} -+#endif -+ -+/** -+ * nand_erase_nand - [Internal] erase block(s) -+ * @mtd: MTD device structure -+ * @instr: erase instruction -+ * @allowbbt: allow erasing the bbt area -+ * -+ * Erase one ore more blocks -+ */ -+static int _nand_erase_nand(struct ra_nand_chip *ra, struct erase_info *instr) -+{ -+ int page, len, status, ret, state; -+ unsigned int addr, blocksize = 1<erase_shift; -+ -+ ra_dbg("%s: start:%x, len:%x \n", __func__, -+ (unsigned int)instr->addr, (unsigned int)instr->len); -+ -+//#define BLOCK_ALIGNED(a) ((a) & (blocksize - 1)) // already defined -+ -+ if (BLOCK_ALIGNED(instr->addr) || BLOCK_ALIGNED(instr->len)) { -+ ra_dbg("%s: erase block not aligned, addr:%x len:%x\n", __func__, instr->addr, instr->len); -+ return -EINVAL; -+ } -+ -+ instr->fail_addr = 0xffffffff; -+ -+ len = instr->len; -+ addr = instr->addr; -+ state = MTD_ERASING; -+ -+ while (len) { -+ -+ page = (int)(addr >> ra->page_shift); -+ -+ /* select device and check wp */ -+ if (nfc_enable_chip(ra, addr, 0)) { -+ printk("%s: nand is write protected \n", __func__); -+ state = MTD_ERASE_FAILED; -+ goto erase_exit; -+ } -+ -+ /* if we have a bad block, we do not erase bad blocks */ -+ if (nand_block_checkbad(ra, addr)) { -+ printk(KERN_WARNING "nand_erase: attempt to erase a " -+ "bad block at 0x%08x\n", addr); -+ state = MTD_ERASE_FAILED; -+ goto erase_exit; -+ } -+ -+ /* -+ * Invalidate the page cache, if we erase the block which -+ * contains the current cached page -+ */ -+ if (BLOCK_ALIGNED(addr) == BLOCK_ALIGNED(ra->buffers_page << ra->page_shift)) -+ ra->buffers_page = -1; -+ -+ status = nfc_erase_block(ra, page); -+ /* See if block erase succeeded */ -+ if (status) { -+ printk("%s: failed erase, page 0x%08x\n", __func__, page); -+ state = MTD_ERASE_FAILED; -+ instr->fail_addr = (page << ra->page_shift); -+ goto erase_exit; -+ } -+ -+ /* Increment page address and decrement length */ -+ len -= blocksize; -+ addr += blocksize; -+ -+ } -+ state = MTD_ERASE_DONE; -+ -+erase_exit: -+ -+ ret = ((state == MTD_ERASE_DONE) ? 0 : -EIO); -+ -+ if (ret) { -+ ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_BAD); -+ } -+ -+ /* Return more or less happy */ -+ return ret; -+} -+ -+static int -+nand_write_oob_buf(struct ra_nand_chip *ra, uint8_t *buf, uint8_t *oob, size_t size, -+ int mode, int ooboffs) -+{ -+ size_t oobsize = 1<oob_shift; -+ struct nand_oobfree *free; -+ uint32_t woffs = ooboffs; -+ int retsize = 0; -+ -+ ra_dbg("%s: size:%x, mode:%x, offs:%x \n", __func__, size, mode, ooboffs); -+ -+ switch(mode) { -+ case MTD_OPS_PLACE_OOB: -+ case MTD_OPS_RAW: -+ if (ooboffs > oobsize) -+ return -1; -+ -+ size = min(size, oobsize - ooboffs); -+ memcpy(buf + ooboffs, oob, size); -+ retsize = size; -+ break; -+ -+ case MTD_OPS_AUTO_OOB: -+ if (ooboffs > ra->oob->oobavail) -+ return -1; -+ -+ while (size) { -+ for(free = ra->oob->oobfree; free->length && size; free++) { -+ int wlen = free->length - woffs; -+ int bytes = 0; -+ -+ /* Write request not from offset 0 ? */ -+ if (wlen <= 0) { -+ woffs = -wlen; -+ continue; -+ } -+ -+ bytes = min_t(size_t, size, wlen); -+ memcpy (buf + free->offset + woffs, oob, bytes); -+ woffs = 0; -+ oob += bytes; -+ size -= bytes; -+ retsize += bytes; -+ } -+ buf += oobsize; -+ } -+ break; -+ -+ default: -+ BUG(); -+ } -+ -+ return retsize; -+} -+ -+static int nand_read_oob_buf(struct ra_nand_chip *ra, uint8_t *oob, size_t size, -+ int mode, int ooboffs) -+{ -+ size_t oobsize = 1<oob_shift; -+ uint8_t *buf = ra->buffers + (1<page_shift); -+ int retsize=0; -+ -+ ra_dbg("%s: size:%x, mode:%x, offs:%x \n", __func__, size, mode, ooboffs); -+ -+ switch(mode) { -+ case MTD_OPS_PLACE_OOB: -+ case MTD_OPS_RAW: -+ if (ooboffs > oobsize) -+ return -1; -+ -+ size = min(size, oobsize - ooboffs); -+ memcpy(oob, buf + ooboffs, size); -+ return size; -+ -+ case MTD_OPS_AUTO_OOB: { -+ struct nand_oobfree *free; -+ uint32_t woffs = ooboffs; -+ -+ if (ooboffs > ra->oob->oobavail) -+ return -1; -+ -+ size = min(size, ra->oob->oobavail - ooboffs); -+ for(free = ra->oob->oobfree; free->length && size; free++) { -+ int wlen = free->length - woffs; -+ int bytes = 0; -+ -+ /* Write request not from offset 0 ? */ -+ if (wlen <= 0) { -+ woffs = -wlen; -+ continue; -+ } -+ -+ bytes = min_t(size_t, size, wlen); -+ memcpy (oob, buf + free->offset + woffs, bytes); -+ woffs = 0; -+ oob += bytes; -+ size -= bytes; -+ retsize += bytes; -+ } -+ return retsize; -+ } -+ default: -+ BUG(); -+ } -+ -+ return -1; -+} -+ -+/** -+ * nand_do_write_ops - [Internal] NAND write with ECC -+ * @mtd: MTD device structure -+ * @to: offset to write to -+ * @ops: oob operations description structure -+ * -+ * NAND write with ECC -+ */ -+static int nand_do_write_ops(struct ra_nand_chip *ra, loff_t to, -+ struct mtd_oob_ops *ops) -+{ -+ int page; -+ uint32_t datalen = ops->len; -+ uint32_t ooblen = ops->ooblen; -+ uint8_t *oob = ops->oobbuf; -+ uint8_t *data = ops->datbuf; -+ int pagesize = (1<page_shift); -+ int pagemask = (pagesize -1); -+ int oobsize = 1<oob_shift; -+ loff_t addr = to; -+ //int i = 0; //for ra_dbg only -+ -+ ra_dbg("%s: to:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x oobmode:%x \n", -+ __func__, (unsigned int)to, data, oob, datalen, ooblen, ops->ooboffs, ops->mode); -+ -+ ops->retlen = 0; -+ ops->oobretlen = 0; -+ -+ -+ /* Invalidate the page cache, when we write to the cached page */ -+ ra->buffers_page = -1; -+ -+ -+ if (data ==0) -+ datalen = 0; -+ -+ // oob sequential (burst) write -+ if (datalen == 0 && ooblen) { -+ int len = ((ooblen + ops->ooboffs) + (ra->oob->oobavail - 1)) / ra->oob->oobavail * oobsize; -+ -+ /* select chip, and check if it is write protected */ -+ if (nfc_enable_chip(ra, addr, 0)) -+ return -EIO; -+ -+ //FIXME, need sanity check of block boundary -+ page = (int)((to & ((1<chip_shift)-1)) >> ra->page_shift); //chip boundary -+ memset(ra->buffers, 0x0ff, pagesize); -+ //fixme, should we reserve the original content? -+ if (ops->mode == MTD_OPS_AUTO_OOB) { -+ nfc_read_oob(ra, page, 0, ra->buffers, len, FLAG_NONE); -+ } -+ //prepare buffers -+ if (ooblen != 8) -+ { -+ nand_write_oob_buf(ra, ra->buffers, oob, ooblen, ops->mode, ops->ooboffs); -+ // write out buffer to chip -+ nfc_write_oob(ra, page, 0, ra->buffers, len, FLAG_USE_GDMA); -+ } -+ -+ ops->oobretlen = ooblen; -+ ooblen = 0; -+ } -+ -+ // data sequential (burst) write -+ if (datalen && ooblen == 0) { -+ // ranfc can not support write_data_burst, since hw-ecc and fifo constraints.. -+ } -+ -+ // page write -+ while(datalen || ooblen) { -+ int len; -+ int ret; -+ int offs; -+ int ecc_en = 0; -+ -+ ra_dbg("%s (%d): addr:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x \n", -+ __func__, i++, (unsigned int)addr, data, oob, datalen, ooblen, ops->ooboffs); -+ -+ page = (int)((addr & ((1<chip_shift)-1)) >> ra->page_shift); //chip boundary -+ -+ /* select chip, and check if it is write protected */ -+ if (nfc_enable_chip(ra, addr, 0)) -+ return -EIO; -+ -+ // oob write -+ if (ops->mode == MTD_OPS_AUTO_OOB) { -+ //fixme, this path is not yet varified -+ nfc_read_oob(ra, page, 0, ra->buffers + pagesize, oobsize, FLAG_NONE); -+ } -+ if (oob && ooblen > 0) { -+ len = nand_write_oob_buf(ra, ra->buffers + pagesize, oob, ooblen, ops->mode, ops->ooboffs); -+ if (len < 0) -+ return -EINVAL; -+ -+ oob += len; -+ ops->oobretlen += len; -+ ooblen -= len; -+ } -+ -+ // data write -+ offs = addr & pagemask; -+ len = min_t(size_t, datalen, pagesize - offs); -+ if (data && len > 0) { -+ memcpy(ra->buffers + offs, data, len); // we can not sure ops->buf wether is DMA-able. -+ -+ data += len; -+ datalen -= len; -+ ops->retlen += len; -+ -+ ecc_en = FLAG_ECC_EN; -+ } -+ ret = nfc_write_page(ra, ra->buffers, page, FLAG_USE_GDMA | FLAG_VERIFY | -+ ((ops->mode == MTD_OPS_RAW || ops->mode == MTD_OPS_PLACE_OOB) ? 0 : ecc_en )); -+ if (ret) { -+ ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_BAD); -+ return ret; -+ } -+ -+ ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_GOOD); -+ -+ addr = (page+1) << ra->page_shift; -+ -+ } -+ return 0; -+} -+ -+/** -+ * nand_do_read_ops - [Internal] Read data with ECC -+ * -+ * @mtd: MTD device structure -+ * @from: offset to read from -+ * @ops: oob ops structure -+ * -+ * Internal function. Called with chip held. -+ */ -+static int nand_do_read_ops(struct ra_nand_chip *ra, loff_t from, -+ struct mtd_oob_ops *ops) -+{ -+ int page; -+ uint32_t datalen = ops->len; -+ uint32_t ooblen = ops->ooblen; -+ uint8_t *oob = ops->oobbuf; -+ uint8_t *data = ops->datbuf; -+ int pagesize = (1<page_shift); -+ int pagemask = (pagesize -1); -+ loff_t addr = from; -+ //int i = 0; //for ra_dbg only -+ -+ ra_dbg("%s: addr:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x \n", -+ __func__, (unsigned int)addr, data, oob, datalen, ooblen, ops->ooboffs); -+ -+ ops->retlen = 0; -+ ops->oobretlen = 0; -+ if (data == 0) -+ datalen = 0; -+ -+ -+ while(datalen || ooblen) { -+ int len; -+ int ret; -+ int offs; -+ -+ ra_dbg("%s (%d): addr:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x \n", -+ __func__, i++, (unsigned int)addr, data, oob, datalen, ooblen, ops->ooboffs); -+ /* select chip */ -+ if (nfc_enable_chip(ra, addr, 1) < 0) -+ return -EIO; -+ -+ page = (int)((addr & ((1<chip_shift)-1)) >> ra->page_shift); -+ -+ ret = nfc_read_page(ra, ra->buffers, page, FLAG_VERIFY | -+ ((ops->mode == MTD_OPS_RAW || ops->mode == MTD_OPS_PLACE_OOB) ? 0: FLAG_ECC_EN )); -+ //FIXME, something strange here, some page needs 2 more tries to guarantee read success. -+ if (ret) { -+ printk("read again:\n"); -+ ret = nfc_read_page(ra, ra->buffers, page, FLAG_VERIFY | -+ ((ops->mode == MTD_OPS_RAW || ops->mode == MTD_OPS_PLACE_OOB) ? 0: FLAG_ECC_EN )); -+ -+ if (ret) { -+ printk("read again fail \n"); -+ ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_BAD); -+ if ((ret != -EUCLEAN) && (ret != -EBADMSG)) { -+ return ret; -+ } -+ else { -+ /* ecc verification fail, but data need to be returned. */ -+ } -+ } -+ else { -+ printk(" read agian susccess \n"); -+ } -+ } -+ -+ // oob read -+ if (oob && ooblen > 0) { -+ len = nand_read_oob_buf(ra, oob, ooblen, ops->mode, ops->ooboffs); -+ if (len < 0) { -+ printk("nand_read_oob_buf: fail return %x \n", len); -+ return -EINVAL; -+ } -+ -+ oob += len; -+ ops->oobretlen += len; -+ ooblen -= len; -+ } -+ -+ // data read -+ offs = addr & pagemask; -+ len = min_t(size_t, datalen, pagesize - offs); -+ if (data && len > 0) { -+ memcpy(data, ra->buffers + offs, len); // we can not sure ops->buf wether is DMA-able. -+ -+ data += len; -+ datalen -= len; -+ ops->retlen += len; -+ if (ret) -+ return ret; -+ } -+ -+ -+ ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_GOOD); -+ // address go further to next page, instead of increasing of length of write. This avoids some special cases wrong. -+ addr = (page+1) << ra->page_shift; -+ } -+ return 0; -+} -+ -+static int -+ramtd_nand_erase(struct mtd_info *mtd, struct erase_info *instr) -+{ -+ struct ra_nand_chip *ra = (struct ra_nand_chip *)mtd->priv; -+ int ret; -+ -+ ra_dbg("%s: start:%x, len:%x \n", __func__, -+ (unsigned int)instr->addr, (unsigned int)instr->len); -+ -+ nand_get_device(ra, FL_ERASING); -+ ret = _nand_erase_nand((struct ra_nand_chip *)mtd->priv, instr); -+ nand_release_device(ra); -+ -+ return ret; -+} -+ -+static int -+ramtd_nand_write(struct mtd_info *mtd, loff_t to, size_t len, -+ size_t *retlen, const uint8_t *buf) -+{ -+ struct ra_nand_chip *ra = mtd->priv; -+ struct mtd_oob_ops ops; -+ int ret; -+ -+ ra_dbg("%s: to 0x%x len=0x%x\n", __func__, to, len); -+ -+ if ((to + len) > mtd->size) -+ return -EINVAL; -+ -+ if (!len) -+ return 0; -+ -+ nand_get_device(ra, FL_WRITING); -+ -+ memset(&ops, 0, sizeof(ops)); -+ ops.len = len; -+ ops.datbuf = (uint8_t *)buf; -+ ops.oobbuf = NULL; -+ ops.mode = MTD_OPS_AUTO_OOB; -+ -+ ret = nand_do_write_ops(ra, to, &ops); -+ -+ *retlen = ops.retlen; -+ -+ nand_release_device(ra); -+ -+ return ret; -+} -+ -+static int -+ramtd_nand_read(struct mtd_info *mtd, loff_t from, size_t len, -+ size_t *retlen, uint8_t *buf) -+{ -+ struct ra_nand_chip *ra = mtd->priv; -+ int ret; -+ struct mtd_oob_ops ops; -+ -+ ra_dbg("%s: mtd:%p from:%x, len:%x, buf:%p \n", __func__, mtd, (unsigned int)from, len, buf); -+ -+ /* Do not allow reads past end of device */ -+ if ((from + len) > mtd->size) -+ return -EINVAL; -+ if (!len) -+ return 0; -+ -+ nand_get_device(ra, FL_READING); -+ -+ memset(&ops, 0, sizeof(ops)); -+ ops.len = len; -+ ops.datbuf = buf; -+ ops.oobbuf = NULL; -+ ops.mode = MTD_OPS_AUTO_OOB; -+ -+ ret = nand_do_read_ops(ra, from, &ops); -+ -+ *retlen = ops.retlen; -+ -+ nand_release_device(ra); -+ -+ return ret; -+} -+ -+static int -+ramtd_nand_readoob(struct mtd_info *mtd, loff_t from, -+ struct mtd_oob_ops *ops) -+{ -+ struct ra_nand_chip *ra = mtd->priv; -+ int ret; -+ -+ ra_dbg("%s: \n", __func__); -+ -+ nand_get_device(ra, FL_READING); -+ -+ ret = nand_do_read_ops(ra, from, ops); -+ -+ nand_release_device(ra); -+ -+ return ret; -+} -+ -+static int -+ramtd_nand_writeoob(struct mtd_info *mtd, loff_t to, -+ struct mtd_oob_ops *ops) -+{ -+ struct ra_nand_chip *ra = mtd->priv; -+ int ret; -+ -+ nand_get_device(ra, FL_READING); -+ ret = nand_do_write_ops(ra, to, ops); -+ nand_release_device(ra); -+ -+ return ret; -+} -+ -+static int -+ramtd_nand_block_isbad(struct mtd_info *mtd, loff_t offs) -+{ -+ if (offs > mtd->size) -+ return -EINVAL; -+ -+ return nand_block_checkbad((struct ra_nand_chip *)mtd->priv, offs); -+} -+ -+static int -+ramtd_nand_block_markbad(struct mtd_info *mtd, loff_t ofs) -+{ -+ struct ra_nand_chip *ra = mtd->priv; -+ int ret; -+ -+ ra_dbg("%s: \n", __func__); -+ nand_get_device(ra, FL_WRITING); -+ ret = nand_block_markbad(ra, ofs); -+ nand_release_device(ra); -+ -+ return ret; -+} -+ -+// 1-bit error detection -+static int one_bit_correction(char *ecc1, char *ecc2, int *bytes, int *bits) -+{ -+ // check if ecc and expected are all valid -+ char *p, nibble, crumb; -+ int i, xor, iecc1 = 0, iecc2 = 0; -+ -+ printk("correction : %x %x %x\n", ecc1[0], ecc1[1], ecc1[2]); -+ printk("correction : %x %x %x\n", ecc2[0], ecc2[1], ecc2[2]); -+ -+ p = (char *)ecc1; -+ for (i = 0; i < CONFIG_ECC_BYTES; i++) -+ { -+ nibble = *(p+i) & 0xf; -+ if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) && -+ (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9)) -+ return -1; -+ nibble = ((*(p+i)) >> 4) & 0xf; -+ if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) && -+ (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9)) -+ return -1; -+ } -+ -+ p = (char *)ecc2; -+ for (i = 0; i < CONFIG_ECC_BYTES; i++) -+ { -+ nibble = *(p+i) & 0xf; -+ if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) && -+ (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9)) -+ return -1; -+ nibble = ((*(p+i)) >> 4) & 0xf; -+ if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) && -+ (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9)) -+ return -1; -+ } -+ -+ memcpy(&iecc1, ecc1, 3); -+ memcpy(&iecc2, ecc2, 3); -+ -+ xor = iecc1 ^ iecc2; -+ printk("xor = %x (%x %x)\n", xor, iecc1, iecc2); -+ -+ *bytes = 0; -+ for (i = 0; i < 9; i++) -+ { -+ crumb = (xor >> (2*i)) & 0x3; -+ if ((crumb == 0x0) || (crumb == 0x3)) -+ return -1; -+ if (crumb == 0x2) -+ *bytes += (1 << i); -+ } -+ -+ *bits = 0; -+ for (i = 0; i < 3; i++) -+ { -+ crumb = (xor >> (18 + 2*i)) & 0x3; -+ if ((crumb == 0x0) || (crumb == 0x3)) -+ return -1; -+ if (crumb == 0x2) -+ *bits += (1 << i); -+ } -+ -+ return 0; -+} -+ -+/************************************************************ -+ * the init/exit section. -+ */ -+ -+static struct nand_ecclayout ra_oob_layout = { -+ .eccbytes = CONFIG_ECC_BYTES, -+ .eccpos = {5, 6, 7}, -+ .oobfree = { -+ {.offset = 0, .length = 4}, -+ {.offset = 8, .length = 8}, -+ {.offset = 0, .length = 0} -+ }, -+#define RA_CHIP_OOB_AVAIL (4+8) -+ .oobavail = RA_CHIP_OOB_AVAIL, -+ // 5th byte is bad-block flag. -+}; -+ -+static int -+mtk_nand_probe(struct platform_device *pdev) -+{ -+ struct mtd_part_parser_data ppdata; -+ struct ra_nand_chip *ra; -+ int alloc_size, bbt_size, buffers_size, reg, err; -+ unsigned char chip_mode = 12; -+ -+ /* if(ra_check_flash_type()!=BOOT_FROM_NAND) { -+ return 0; -+ }*/ -+ -+ //FIXME: config 512 or 2048-byte page according to HWCONF -+#if defined (CONFIG_SOC_MT7620) -+ ra_outl(RALINK_SYSCTL_BASE+0x60, ra_inl(RALINK_SYSCTL_BASE+0x60) & ~(0x3<<18)); -+ reg = ra_inl(RALINK_SYSCTL_BASE+0x10); -+ chip_mode = (reg & 0x0F); -+ if((chip_mode==1)||(chip_mode==11)) { -+ ra_or(NFC_CONF1, 1); -+ is_nand_page_2048 = 1; -+ nand_addrlen = ((chip_mode!=11) ? 4 : 5); -+ printk("!!! nand page size = 2048, addr len=%d\n", nand_addrlen); -+ } -+ else { -+ ra_and(NFC_CONF1, ~1); -+ is_nand_page_2048 = 0; -+ nand_addrlen = ((chip_mode!=10) ? 3 : 4); -+ printk("!!! nand page size = 512, addr len=%d\n", nand_addrlen); -+ } -+#else -+ is_nand_page_2048 = 0; -+ nand_addrlen = 3; -+ printk("!!! nand page size = 512, addr len=%d\n", nand_addrlen); -+#endif -+ -+#if defined (CONFIG_SOC_MT7620) -+ //config ECC location -+ ra_and(NFC_CONF1, 0xfff000ff); -+ ra_or(NFC_CONF1, ((CONFIG_ECC_OFFSET + 2) << 16) + -+ ((CONFIG_ECC_OFFSET + 1) << 12) + -+ (CONFIG_ECC_OFFSET << 8)); -+#endif -+ -+#define ALIGNE_16(a) (((unsigned long)(a)+15) & ~15) -+ buffers_size = ALIGNE_16((1<buffers -+ bbt_size = BBTTAG_BITS * (1<<(CONFIG_CHIP_SIZE_BIT - (CONFIG_PAGE_SIZE_BIT + CONFIG_NUMPAGE_PER_BLOCK_BIT))) / 8; //ra->bbt -+ bbt_size = ALIGNE_16(bbt_size); -+ -+ alloc_size = buffers_size + bbt_size; -+ alloc_size += buffers_size; //for ra->readback_buffers -+ alloc_size += sizeof(*ra); -+ alloc_size += sizeof(*ranfc_mtd); -+ -+ //make sure gpio-0 is input -+ ra_outl(RALINK_PIO_BASE+0x24, ra_inl(RALINK_PIO_BASE+0x24) & ~0x01); -+ -+ ra = (struct ra_nand_chip *)kzalloc(alloc_size, GFP_KERNEL | GFP_DMA); -+ if (!ra) { -+ printk("%s: mem alloc fail \n", __func__); -+ return -ENOMEM; -+ } -+ memset(ra, 0, alloc_size); -+ -+ //dynamic -+ ra->buffers = (char *)((char *)ra + sizeof(*ra)); -+ ra->readback_buffers = ra->buffers + buffers_size; -+ ra->bbt = ra->readback_buffers + buffers_size; -+ ranfc_mtd = (struct mtd_info *)(ra->bbt + bbt_size); -+ -+ //static -+ ra->numchips = CONFIG_NUMCHIPS; -+ ra->chip_shift = CONFIG_CHIP_SIZE_BIT; -+ ra->page_shift = CONFIG_PAGE_SIZE_BIT; -+ ra->oob_shift = CONFIG_OOBSIZE_PER_PAGE_BIT; -+ ra->erase_shift = (CONFIG_PAGE_SIZE_BIT + CONFIG_NUMPAGE_PER_BLOCK_BIT); -+ ra->badblockpos = CONFIG_BAD_BLOCK_POS; -+ ra_oob_layout.eccpos[0] = CONFIG_ECC_OFFSET; -+ ra_oob_layout.eccpos[1] = CONFIG_ECC_OFFSET + 1; -+ ra_oob_layout.eccpos[2] = CONFIG_ECC_OFFSET + 2; -+ ra->oob = &ra_oob_layout; -+ ra->buffers_page = -1; -+ -+#if defined (WORKAROUND_RX_BUF_OV) -+ if (ranfc_verify) { -+ ra->sandbox_page = nand_bbt_find_sandbox(ra); -+ } -+#endif -+ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x01); //set wp to high -+ nfc_all_reset(); -+ -+ ranfc_mtd->type = MTD_NANDFLASH; -+ ranfc_mtd->flags = MTD_CAP_NANDFLASH; -+ ranfc_mtd->size = CONFIG_NUMCHIPS * CFG_CHIPSIZE; -+ ranfc_mtd->erasesize = CFG_BLOCKSIZE; -+ ranfc_mtd->writesize = CFG_PAGESIZE; -+ ranfc_mtd->writebufsize = ranfc_mtd->writesize; -+ ranfc_mtd->oobsize = CFG_PAGE_OOBSIZE; -+ ranfc_mtd->oobavail = RA_CHIP_OOB_AVAIL; -+ ranfc_mtd->name = "ra_nfc"; -+ //ranfc_mtd->index -+ //ranfc_mtd->ecclayout = &ra_oob_layout; -+ //ranfc_mtd->numberaseregions -+ //ranfc_mtd->eraseregions -+ //ranfc_mtd->bansize -+ ranfc_mtd->_erase = ramtd_nand_erase; -+ //ranfc_mtd->point -+ //ranfc_mtd->unpoint -+ ranfc_mtd->_read = ramtd_nand_read; -+ ranfc_mtd->_write = ramtd_nand_write; -+ //ranfc_mtd->_read_oob = ramtd_nand_readoob; -+ //ranfc_mtd->_write_oob = ramtd_nand_writeoob; -+ //ranfc_mtd->get_fact_prot_info; ranfc_mtd->read_fact_prot_reg; -+ //ranfc_mtd->get_user_prot_info; ranfc_mtd->read_user_prot_reg; -+ //ranfc_mtd->write_user_prot_reg; ranfc_mtd->lock_user_prot_reg; -+ //ranfc_mtd->writev; ranfc_mtd->sync; ranfc_mtd->lock; ranfc_mtd->unlock; ranfc_mtd->suspend; ranfc_mtd->resume; -+ ranfc_mtd->_block_isbad = ramtd_nand_block_isbad; -+ ranfc_mtd->_block_markbad = ramtd_nand_block_markbad; -+ //ranfc_mtd->reboot_notifier -+ //ranfc_mtd->ecc_stats; -+ // subpage_sht; -+ -+ //ranfc_mtd->get_device; ranfc_mtd->put_device -+ ranfc_mtd->priv = ra; -+ -+ ranfc_mtd->owner = THIS_MODULE; -+ ra->controller = &ra->hwcontrol; -+ mutex_init(ra->controller); -+ -+ printk("%s: alloc %x, at %p , btt(%p, %x), ranfc_mtd:%p\n", -+ __func__, alloc_size, ra, ra->bbt, bbt_size, ranfc_mtd); -+ -+ mtd_set_of_node(ranfc_mtd, pdev->dev.of_node); -+ err = mtd_device_parse_register(ranfc_mtd, mtk_probe_types, -+ &ppdata, NULL, 0); -+ -+ return err; -+} -+ -+static int -+mtk_nand_remove(struct platform_device *pdev) -+{ -+ struct ra_nand_chip *ra; -+ -+ if (ranfc_mtd) { -+ ra = (struct ra_nand_chip *)ranfc_mtd->priv; -+ -+ /* Deregister partitions */ -+ //del_mtd_partitions(ranfc_mtd); -+ kfree(ra); -+ } -+ return 0; -+} -+ -+static const struct of_device_id mtk_nand_match[] = { -+ { .compatible = "mtk,mt7620-nand" }, -+ {}, -+}; -+MODULE_DEVICE_TABLE(of, mtk_nand_match); -+ -+static struct platform_driver mtk_nand_driver = { -+ .probe = mtk_nand_probe, -+ .remove = mtk_nand_remove, -+ .driver = { -+ .name = "mt7620_nand", -+ .owner = THIS_MODULE, -+ .of_match_table = mtk_nand_match, -+ }, -+}; -+ -+module_platform_driver(mtk_nand_driver); -+ -+MODULE_LICENSE("GPL"); -diff --git a/drivers/mtd/maps/ralink_nand.h b/drivers/mtd/maps/ralink_nand.h -new file mode 100644 -index 000000000..b94dc0947 ---- /dev/null -+++ b/drivers/mtd/maps/ralink_nand.h -@@ -0,0 +1,240 @@ -+#ifndef RT2880_NAND_H -+#define RT2880_NAND_H -+ -+#include -+ -+#define MTD_ERASE_PENDING 0x01 -+#define MTD_ERASING 0x02 -+#define MTD_ERASE_SUSPEND 0x04 -+#define MTD_ERASE_DONE 0x08 -+#define MTD_ERASE_FAILED 0x10 -+ -+#define MTD_FAIL_ADDR_UNKNOWN -1LL -+ -+//#include "gdma.h" -+ -+#define RALINK_SYSCTL_BASE 0xB0000000 -+#define RALINK_PIO_BASE 0xB0000600 -+#define RALINK_NAND_CTRL_BASE 0xB0000810 -+#define CONFIG_RALINK_MT7620 -+ -+#define SKIP_BAD_BLOCK -+//#define RANDOM_GEN_BAD_BLOCK -+ -+#define ra_inl(addr) (*(volatile unsigned int *)(addr)) -+#define ra_outl(addr, value) (*(volatile unsigned int *)(addr) = (value)) -+#define ra_aor(addr, a_mask, o_value) ra_outl(addr, (ra_inl(addr) & (a_mask)) | (o_value)) -+#define ra_and(addr, a_mask) ra_aor(addr, a_mask, 0) -+#define ra_or(addr, o_value) ra_aor(addr, -1, o_value) -+ -+ -+#define CONFIG_NUMCHIPS 1 -+#define CONFIG_NOT_SUPPORT_WP //rt3052 has no WP signal for chip. -+//#define CONFIG_NOT_SUPPORT_RB -+ -+extern int is_nand_page_2048; -+extern const unsigned int nand_size_map[2][3]; -+ -+//chip -+// chip geometry: SAMSUNG small size 32MB. -+#define CONFIG_CHIP_SIZE_BIT (nand_size_map[is_nand_page_2048][nand_addrlen-3]) //! (1<=32)? 31 : CONFIG_CHIP_SIZE_BIT)) -+//#define CFG_CHIPSIZE (1 << CONFIG_CHIP_SIZE_BIT) -+#define CFG_PAGESIZE (1 << CONFIG_PAGE_SIZE_BIT) -+#define CFG_BLOCKSIZE (CFG_PAGESIZE << CONFIG_NUMPAGE_PER_BLOCK_BIT) -+#define CFG_NUMPAGE (1 << (CONFIG_CHIP_SIZE_BIT - CONFIG_PAGE_SIZE_BIT)) -+#define CFG_NUMBLOCK (CFG_NUMPAGE >> CONFIG_NUMPAGE_PER_BLOCK_BIT) -+#define CFG_BLOCK_OOBSIZE (1 << (CONFIG_OOBSIZE_PER_PAGE_BIT + CONFIG_NUMPAGE_PER_BLOCK_BIT)) -+#define CFG_PAGE_OOBSIZE (1 << CONFIG_OOBSIZE_PER_PAGE_BIT) -+ -+#define NAND_BLOCK_ALIGN(addr) ((addr) & (CFG_BLOCKSIZE-1)) -+#define NAND_PAGE_ALIGN(addr) ((addr) & (CFG_PAGESIZE-1)) -+ -+ -+#define NFC_BASE RALINK_NAND_CTRL_BASE -+#define NFC_CTRL (NFC_BASE + 0x0) -+#define NFC_CONF (NFC_BASE + 0x4) -+#define NFC_CMD1 (NFC_BASE + 0x8) -+#define NFC_CMD2 (NFC_BASE + 0xc) -+#define NFC_CMD3 (NFC_BASE + 0x10) -+#define NFC_ADDR (NFC_BASE + 0x14) -+#define NFC_DATA (NFC_BASE + 0x18) -+#if defined (CONFIG_RALINK_RT6855) || defined (CONFIG_RALINK_RT6855A) || \ -+ defined (CONFIG_RALINK_MT7620) || defined (CONFIG_RALINK_MT7621) -+#define NFC_ECC (NFC_BASE + 0x30) -+#else -+#define NFC_ECC (NFC_BASE + 0x1c) -+#endif -+#define NFC_STATUS (NFC_BASE + 0x20) -+#define NFC_INT_EN (NFC_BASE + 0x24) -+#define NFC_INT_ST (NFC_BASE + 0x28) -+#if defined (CONFIG_RALINK_RT6855) || defined (CONFIG_RALINK_RT6855A) || \ -+ defined (CONFIG_RALINK_MT7620) || defined (CONFIG_RALINK_MT7621) -+#define NFC_CONF1 (NFC_BASE + 0x2c) -+#define NFC_ECC_P1 (NFC_BASE + 0x30) -+#define NFC_ECC_P2 (NFC_BASE + 0x34) -+#define NFC_ECC_P3 (NFC_BASE + 0x38) -+#define NFC_ECC_P4 (NFC_BASE + 0x3c) -+#define NFC_ECC_ERR1 (NFC_BASE + 0x40) -+#define NFC_ECC_ERR2 (NFC_BASE + 0x44) -+#define NFC_ECC_ERR3 (NFC_BASE + 0x48) -+#define NFC_ECC_ERR4 (NFC_BASE + 0x4c) -+#define NFC_ADDR2 (NFC_BASE + 0x50) -+#endif -+ -+enum _int_stat { -+ INT_ST_ND_DONE = 1<<0, -+ INT_ST_TX_BUF_RDY = 1<<1, -+ INT_ST_RX_BUF_RDY = 1<<2, -+ INT_ST_ECC_ERR = 1<<3, -+ INT_ST_TX_TRAS_ERR = 1<<4, -+ INT_ST_RX_TRAS_ERR = 1<<5, -+ INT_ST_TX_KICK_ERR = 1<<6, -+ INT_ST_RX_KICK_ERR = 1<<7 -+}; -+ -+ -+//#define WORKAROUND_RX_BUF_OV 1 -+ -+ -+/************************************************************* -+ * stolen from nand.h -+ *************************************************************/ -+ -+/* -+ * Standard NAND flash commands -+ */ -+#define NAND_CMD_READ0 0 -+#define NAND_CMD_READ1 1 -+#define NAND_CMD_RNDOUT 5 -+#define NAND_CMD_PAGEPROG 0x10 -+#define NAND_CMD_READOOB 0x50 -+#define NAND_CMD_ERASE1 0x60 -+#define NAND_CMD_STATUS 0x70 -+#define NAND_CMD_STATUS_MULTI 0x71 -+#define NAND_CMD_SEQIN 0x80 -+#define NAND_CMD_RNDIN 0x85 -+#define NAND_CMD_READID 0x90 -+#define NAND_CMD_ERASE2 0xd0 -+#define NAND_CMD_RESET 0xff -+ -+/* Extended commands for large page devices */ -+#define NAND_CMD_READSTART 0x30 -+#define NAND_CMD_RNDOUTSTART 0xE0 -+#define NAND_CMD_CACHEDPROG 0x15 -+ -+/* Extended commands for AG-AND device */ -+/* -+ * Note: the command for NAND_CMD_DEPLETE1 is really 0x00 but -+ * there is no way to distinguish that from NAND_CMD_READ0 -+ * until the remaining sequence of commands has been completed -+ * so add a high order bit and mask it off in the command. -+ */ -+#define NAND_CMD_DEPLETE1 0x100 -+#define NAND_CMD_DEPLETE2 0x38 -+#define NAND_CMD_STATUS_MULTI 0x71 -+#define NAND_CMD_STATUS_ERROR 0x72 -+/* multi-bank error status (banks 0-3) */ -+#define NAND_CMD_STATUS_ERROR0 0x73 -+#define NAND_CMD_STATUS_ERROR1 0x74 -+#define NAND_CMD_STATUS_ERROR2 0x75 -+#define NAND_CMD_STATUS_ERROR3 0x76 -+#define NAND_CMD_STATUS_RESET 0x7f -+#define NAND_CMD_STATUS_CLEAR 0xff -+ -+#define NAND_CMD_NONE -1 -+ -+/* Status bits */ -+#define NAND_STATUS_FAIL 0x01 -+#define NAND_STATUS_FAIL_N1 0x02 -+#define NAND_STATUS_TRUE_READY 0x20 -+#define NAND_STATUS_READY 0x40 -+#define NAND_STATUS_WP 0x80 -+ -+typedef enum { -+ FL_READY, -+ FL_READING, -+ FL_WRITING, -+ FL_ERASING, -+ FL_SYNCING, -+ FL_CACHEDPRG, -+ FL_PM_SUSPENDED, -+} nand_state_t; -+ -+/*************************************************************/ -+ -+ -+ -+typedef enum _ra_flags { -+ FLAG_NONE = 0, -+ FLAG_ECC_EN = (1<<0), -+ FLAG_USE_GDMA = (1<<1), -+ FLAG_VERIFY = (1<<2), -+} RA_FLAGS; -+ -+ -+#define BBTTAG_BITS 2 -+#define BBTTAG_BITS_MASK ((1< +Date: Thu, 6 May 2021 17:49:55 +0200 +Subject: [PATCH] mtd: spi-nor: Add support for BoHong bh25q128as + +Add MTD support for the BoHong bh25q128as SPI NOR chip. +The chip has 16MB of total capacity, divided into a total of 256 +sectors, each 64KB sized. The chip also supports 4KB sectors. +Additionally, it supports dual and quad read modes. + +Functionality was verified on an Tenbay WR1800K / MTK MT7621 board. + +Signed-off-by: David Bauer +--- + drivers/mtd/spi-nor/Makefile | 1 + + drivers/mtd/spi-nor/bohong.c | 21 +++++++++++++++++++++ + drivers/mtd/spi-nor/core.c | 1 + + drivers/mtd/spi-nor/core.h | 1 + + 4 files changed, 24 insertions(+) + create mode 100644 drivers/mtd/spi-nor/bohong.c + +--- a/drivers/mtd/spi-nor/spi-nor.c ++++ b/drivers/mtd/spi-nor/spi-nor.c +@@ -2233,6 +2233,10 @@ static const struct flash_info spi_nor_i + + { "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16, SECT_4K) }, + ++ /* BoHong Microelectronics */ ++ { "bh25q128as", INFO(0x684018, 0, 64 * 1024, 256, ++ SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, ++ + /* EON -- en25xxx */ + { "en25f32", INFO(0x1c3116, 0, 64 * 1024, 64, SECT_4K) }, + { "en25p32", INFO(0x1c2016, 0, 64 * 1024, 64, 0) }, diff --git a/target/linux/ramips/patches-5.4/805-pinctrl-AW9523.patch b/target/linux/ramips/patches-5.4/805-pinctrl-AW9523.patch new file mode 100644 index 000000000..d8e17a671 --- /dev/null +++ b/target/linux/ramips/patches-5.4/805-pinctrl-AW9523.patch @@ -0,0 +1,72 @@ +From: AngeloGioacchino Del Regno + +To: linus.walleij@linaro.org +Cc: linux-kernel@vger.kernel.org, konrad.dybcio@somainline.org, + marijn.suijten@somainline.org, martin.botka@somainline.org, + phone-devel@vger.kernel.org, linux-gpio@vger.kernel.org, + devicetree@vger.kernel.org, robh+dt@kernel.org, + AngeloGioacchino Del Regno + +Subject: [PATCH v5 1/2] pinctrl: Add driver for Awinic AW9523/B I2C GPIO + Expander +Date: Mon, 25 Jan 2021 19:22:18 +0100 + +The Awinic AW9523(B) is a multi-function I2C gpio expander in a +TQFN-24L package, featuring PWM (max 37mA per pin, or total max +power 3.2Watts) for LED driving capability. + +It has two ports with 8 pins per port (for a total of 16 pins), +configurable as either PWM with 1/256 stepping or GPIO input/output, +1.8V logic input; each GPIO can be configured as input or output +independently from each other. + +This IC also has an internal interrupt controller, which is capable +of generating an interrupt for each GPIO, depending on the +configuration, and will raise an interrupt on the INTN pin to +advertise this to an external interrupt controller. + +Signed-off-by: AngeloGioacchino Del Regno +--- + drivers/pinctrl/Kconfig | 17 + + drivers/pinctrl/Makefile | 1 + + drivers/pinctrl/pinctrl-aw9523.c | 1122 ++++++++++++++++++++++++++++++ + 3 files changed, 1140 insertions(+) + create mode 100644 drivers/pinctrl/pinctrl-aw9523.c + +--- a/drivers/pinctrl/Kconfig ++++ b/drivers/pinctrl/Kconfig +@@ -109,6 +109,24 @@ config PINCTRL_AMD + Requires ACPI/FDT device enumeration code to set up a platform + device. + ++config PINCTRL_AW9523 ++ bool "Awinic AW9523/AW9523B I2C GPIO expander pinctrl driver" ++ depends on OF && I2C ++ select PINMUX ++ select PINCONF ++ select GENERIC_PINCONF ++ select GPIOLIB ++ select GPIOLIB_IRQCHIP ++ select REGMAP ++ select REGMAP_I2C ++ help ++ The Awinic AW9523/AW9523B is a multi-function I2C GPIO ++ expander with PWM functionality. This driver bundles a ++ pinctrl driver to select the function muxing and a GPIO ++ driver to handle GPIO, when the GPIO function is selected. ++ ++ Say yes to enable pinctrl and GPIO support for the AW9523(B). ++ + config PINCTRL_BM1880 + bool "Bitmain BM1880 Pinctrl driver" + depends on OF && (ARCH_BITMAIN || COMPILE_TEST) +--- a/drivers/pinctrl/Makefile ++++ b/drivers/pinctrl/Makefile +@@ -14,6 +14,7 @@ obj-$(CONFIG_PINCTRL_AXP209) += pinctrl- + obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o + obj-$(CONFIG_PINCTRL_AT91PIO4) += pinctrl-at91-pio4.o + obj-$(CONFIG_PINCTRL_AMD) += pinctrl-amd.o ++obj-$(CONFIG_PINCTRL_AW9523) += pinctrl-aw9523.o + obj-$(CONFIG_PINCTRL_BM1880) += pinctrl-bm1880.o + obj-$(CONFIG_PINCTRL_DA850_PUPD) += pinctrl-da850-pupd.o + obj-$(CONFIG_PINCTRL_DIGICOLOR) += pinctrl-digicolor.o diff --git a/target/linux/ramips/patches-5.4/991-at803x.patch b/target/linux/ramips/patches-5.4/991-at803x.patch index 4de311854..205877231 100644 --- a/target/linux/ramips/patches-5.4/991-at803x.patch +++ b/target/linux/ramips/patches-5.4/991-at803x.patch @@ -154,4 +154,4 @@ Signed-off-by: RenĂ© van Dorst + .config_aneg = at803x_config_aneg, .phy_id_mask = AT803X_PHY_ID_MASK, .probe = at803x_probe, - .config_init = at803x_config_init, + .config_init = at803x_config_init, \ No newline at end of file diff --git a/target/linux/ramips/rt288x/base-files/etc/board.d/01_leds b/target/linux/ramips/rt288x/base-files/etc/board.d/01_leds old mode 100755 new mode 100644 index b62ad7611..f9434023b --- a/target/linux/ramips/rt288x/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/rt288x/base-files/etc/board.d/01_leds @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions/leds.sh . /lib/functions/uci-defaults.sh diff --git a/target/linux/ramips/rt288x/base-files/etc/board.d/02_network b/target/linux/ramips/rt288x/base-files/etc/board.d/02_network old mode 100755 new mode 100644 index 134ac879c..dd433dd7d --- a/target/linux/ramips/rt288x/base-files/etc/board.d/02_network +++ b/target/linux/ramips/rt288x/base-files/etc/board.d/02_network @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions.sh . /lib/functions/uci-defaults.sh diff --git a/target/linux/ramips/rt288x/config-5.10 b/target/linux/ramips/rt288x/config-5.10 index 095c16c43..88d06266b 100644 --- a/target/linux/ramips/rt288x/config-5.10 +++ b/target/linux/ramips/rt288x/config-5.10 @@ -131,6 +131,7 @@ CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y # CONFIG_PHY_RALINK_USB is not set CONFIG_PINCTRL=y +# CONFIG_PINCTRL_AW9523 is not set CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_RALINK=y diff --git a/target/linux/ramips/rt288x/config-5.4 b/target/linux/ramips/rt288x/config-5.4 index ad269ff5b..d0de43e29 100644 --- a/target/linux/ramips/rt288x/config-5.4 +++ b/target/linux/ramips/rt288x/config-5.4 @@ -131,6 +131,7 @@ CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y # CONFIG_PHY_RALINK_USB is not set CONFIG_PINCTRL=y +# CONFIG_PINCTRL_AW9523 is not set CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_RALINK=y diff --git a/target/linux/ramips/rt305x/base-files/etc/board.d/01_leds b/target/linux/ramips/rt305x/base-files/etc/board.d/01_leds old mode 100755 new mode 100644 index d29328e4b..bc91b81a7 --- a/target/linux/ramips/rt305x/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/rt305x/base-files/etc/board.d/01_leds @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions/leds.sh . /lib/functions/uci-defaults.sh diff --git a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network old mode 100755 new mode 100644 index c3e39e76d..db200de9f --- a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network +++ b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions.sh . /lib/functions/uci-defaults.sh diff --git a/target/linux/ramips/rt305x/config-5.10 b/target/linux/ramips/rt305x/config-5.10 index fbc2edc84..1704accf9 100644 --- a/target/linux/ramips/rt305x/config-5.10 +++ b/target/linux/ramips/rt305x/config-5.10 @@ -131,6 +131,7 @@ CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y CONFIG_PHY_RALINK_USB=y CONFIG_PINCTRL=y +# CONFIG_PINCTRL_AW9523 is not set CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_RALINK=y diff --git a/target/linux/ramips/rt305x/config-5.4 b/target/linux/ramips/rt305x/config-5.4 index 6ab68f9d5..b4ee93c05 100644 --- a/target/linux/ramips/rt305x/config-5.4 +++ b/target/linux/ramips/rt305x/config-5.4 @@ -131,6 +131,7 @@ CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y CONFIG_PHY_RALINK_USB=y CONFIG_PINCTRL=y +# CONFIG_PINCTRL_AW9523 is not set CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_RALINK=y diff --git a/target/linux/ramips/rt3883/base-files/etc/board.d/01_leds b/target/linux/ramips/rt3883/base-files/etc/board.d/01_leds old mode 100755 new mode 100644 index 6e8497aff..ecae088d8 --- a/target/linux/ramips/rt3883/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/rt3883/base-files/etc/board.d/01_leds @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions/leds.sh . /lib/functions/uci-defaults.sh diff --git a/target/linux/ramips/rt3883/base-files/etc/board.d/02_network b/target/linux/ramips/rt3883/base-files/etc/board.d/02_network old mode 100755 new mode 100644 index 7b73f9394..519afe632 --- a/target/linux/ramips/rt3883/base-files/etc/board.d/02_network +++ b/target/linux/ramips/rt3883/base-files/etc/board.d/02_network @@ -1,4 +1,3 @@ -#!/bin/sh . /lib/functions.sh . /lib/functions/uci-defaults.sh @@ -25,6 +24,13 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0" ;; + engenius,esr600h|\ + sitecom,wlr-6000|\ + trendnet,tew-691gr|\ + trendnet,tew-692gr) + ucidef_add_switch "switch0" \ + "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0" + ;; loewe,wmdr-143n|\ omnima,hpm) ucidef_set_interface_lan "eth0" @@ -33,12 +39,6 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "9@eth0" ;; - sitecom,wlr-6000|\ - trendnet,tew-691gr|\ - trendnet,tew-692gr) - ucidef_add_switch "switch0" \ - "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0" - ;; esac } @@ -66,6 +66,11 @@ ramips_setup_macs() edimax,br-6475nd) wan_mac=$(mtd_get_mac_binary devdata 0x7) ;; + engenius,esr600h) + wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr) + lan_mac=$(macaddr_add "$wan_mac" 1) + label_mac=$wan_mac + ;; samsung,cy-swr1100) lan_mac=$(mtd_get_mac_ascii nvram lanmac) wan_mac=$(mtd_get_mac_ascii nvram wanmac) diff --git a/target/linux/ramips/rt3883/config-5.10 b/target/linux/ramips/rt3883/config-5.10 index 5bb641cbd..16d6fc32f 100644 --- a/target/linux/ramips/rt3883/config-5.10 +++ b/target/linux/ramips/rt3883/config-5.10 @@ -132,6 +132,7 @@ CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y CONFIG_PHY_RALINK_USB=y CONFIG_PINCTRL=y +# CONFIG_PINCTRL_AW9523 is not set CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_RALINK=y diff --git a/target/linux/ramips/rt3883/config-5.4 b/target/linux/ramips/rt3883/config-5.4 index 577743e79..f7d6a2cc2 100644 --- a/target/linux/ramips/rt3883/config-5.4 +++ b/target/linux/ramips/rt3883/config-5.4 @@ -133,6 +133,7 @@ CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y CONFIG_PHY_RALINK_USB=y CONFIG_PINCTRL=y +# CONFIG_PINCTRL_AW9523 is not set CONFIG_PINCTRL_RT2880=y # CONFIG_PINCTRL_SINGLE is not set CONFIG_RALINK=y