Skip to content

Commit

Permalink
mediatek: init for tenbay_wr3000k-gsw-emmc-nor
Browse files Browse the repository at this point in the history
  • Loading branch information
ptpt52 committed Jun 20, 2023
1 parent cd1da96 commit fab9c69
Show file tree
Hide file tree
Showing 5 changed files with 358 additions and 0 deletions.
8 changes: 8 additions & 0 deletions package/boot/uboot-envtools/files/mediatek_filogic
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ zyxel,ex5601-t0)
local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x40000" "2"
;;
tenbay,wr3000k-gsw-emmc-nor)
if cat /proc/device-tree/chosen/bootargs-append | grep -q env=emmc; then
blk_dev=$(blkid -t "PARTLABEL=ubootenv" -o device)
ubootenv_add_uci_config "$blk_dev" "0x0" "0x80000" "0x200"
else
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
fi
;;
esac

config_load ubootenv
Expand Down
277 changes: 277 additions & 0 deletions target/linux/mediatek/dts/mt7981b-tenbay-wr3000k-gsw-emmc-nor.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
/dts-v1/;

#include "mt7981.dtsi"

/ {
model = "Tenbay WR3000K gsw emmc nor";
compatible = "tenbay,wr3000k-gsw-emmc-nor", "mediatek,mt7981";

aliases {
ethernet0 = &gmac0;
ethernet1 = &gmac1;
serial0 = &uart0;
};

chosen {
stdout-path = "serial0:115200n8";
};

gpio-keys {
compatible = "gpio-keys";

reset {
label = "reset";
linux,code = <KEY_RESTART>;
gpios = <&pio 1 GPIO_ACTIVE_LOW>;
};
};

reg_3p3v: regulator-3p3v {
compatible = "regulator-fixed";
regulator-name = "fixed-3.3V";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
};

&uart0 {
status = "okay";
};

&watchdog {
status = "okay";
};

&eth {
pinctrl-names = "default";
pinctrl-0 = <&mdio_pins>;

status = "okay";

gmac0: mac@0 {
compatible = "mediatek,eth-mac";
reg = <0>;
phy-mode = "2500base-x";
nvmem-cells = <&macaddr_2a>;
nvmem-cell-names = "mac-address";

fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};

gmac1: mac@1 {
compatible = "mediatek,eth-mac";
reg = <1>;
phy-mode = "gmii";
phy-handle = <&int_gbe_phy>;
nvmem-cells = <&macaddr_24>;
nvmem-cell-names = "mac-address";
};
};

&mdio_bus {
switch0: switch@0 {
compatible = "mediatek,mt7531";
reg = <31>;
dsa,member = <0 0>;
reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
interrupt-controller;
#interrupt-cells = <1>;
interrupt-parent = <&pio>;
interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
};
};

&switch0 {
ports {
#address-cells = <1>;
#size-cells = <0>;

port@0 {
reg = <0>;
label = "lan1";
};

port@1 {
reg = <1>;
label = "lan2";
};

port@2 {
reg = <2>;
label = "lan3";
};

port@6 {
reg = <6>;
ethernet = <&gmac0>;
phy-mode = "2500base-x";

fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
};

&mmc0 {
pinctrl-names = "default", "state_uhs";
pinctrl-0 = <&mmc0_pins_default>;
pinctrl-1 = <&mmc0_pins_uhs>;
bus-width = <8>;
max-frequency = <52000000>;
cap-mmc-highspeed;
vmmc-supply = <&reg_3p3v>;
non-removable;
status = "okay";
};

&spi2 {
pinctrl-names = "default";
pinctrl-0 = <&spi2_flash_pins>;
status = "okay";

spi_nor@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <52000000>;
spi-tx-buswidth = <4>;
spi-rx-buswidth = <4>;

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@00000 {
label = "BL2";
reg = <0x00000 0x0040000>;
};
partition@40000 {
label = "u-boot-env";
reg = <0x40000 0x0010000>;
};
partition@50000 {
label = "Product";
reg = <0x50000 0x0020000>;
};
factory: partition@70000 {
label = "Factory";
reg = <0x70000 0x0090000>;
};
partition@100000 {
label = "FIP";
reg = <0x100000 0x00c0000>;
};
partition@1c0000 {
label = "firmware";
reg = <0x1c0000 0xdc0000>;
};
};
};
};

&pio {
spi2_flash_pins: spi2-pins {
mux {
function = "spi";
groups = "spi2", "spi2_wp_hold";
};

conf-pu {
pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
drive-strength = <MTK_DRIVE_8mA>;
bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
};

conf-pd {
pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
drive-strength = <MTK_DRIVE_8mA>;
bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
};
};

mmc0_pins_default: mmc0-pins-default {
mux {
function = "flash";
groups = "emmc_45";
};

conf-cmd-dat {
pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO",
"SPI0_CS", "SPI0_HOLD", "SPI0_WP",
"SPI1_CLK", "SPI1_MOSI", "SPI1_MISO";
input-enable;
drive-strength = <MTK_DRIVE_4mA>;
bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
};

conf-clk {
pins = "SPI1_CS";
drive-strength = <MTK_DRIVE_6mA>;
bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
};

conf-rst {
pins = "PWM0";
drive-strength = <MTK_DRIVE_4mA>;
bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
};
};

mmc0_pins_uhs: mmc0-pins-uhs {
mux {
function = "flash";
groups = "emmc_45";
};

conf-cmd-dat {
pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO",
"SPI0_CS", "SPI0_HOLD", "SPI0_WP",
"SPI1_CLK", "SPI1_MOSI", "SPI1_MISO";
input-enable;
drive-strength = <MTK_DRIVE_4mA>;
bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
};

conf-clk {
pins = "SPI1_CS";
drive-strength = <MTK_DRIVE_6mA>;
bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
};

conf-rst {
pins = "PWM0";
drive-strength = <MTK_DRIVE_4mA>;
bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
};
};
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_24: macaddr@24 {
reg = <0x24 0x6>;
};
macaddr_2a: macaddr@2a {
reg = <0x2a 0x6>;
};
};

&wifi {
mediatek,mtd-eeprom = <&factory 0x0>;

status = "okay";
};
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ mediatek_setup_interfaces()
tplink,tl-xdr6086)
ucidef_set_interfaces_lan_wan "lan1 lan2" eth1
;;
tenbay,wr3000k-gsw-emmc-nor)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" eth1
;;
xiaomi,redmi-router-ax6000-stock|\
xiaomi,redmi-router-ax6000-ubootlayout|\
xiaomi,redmi-router-ax6000-ubootmod)
Expand Down
56 changes: 56 additions & 0 deletions target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,53 @@ redmi_ax6000_initial_setup()
fw_setenv mtdparts "nmbm0:1024k(bl2),256k(Nvram),256k(Bdata),2048k(factory),2048k(fip),256k(crash),256k(crash_log),30720k(ubi),30720k(ubi1),51200k(overlay)"
}

tenbay_mmc_do_upgrade_dual_boot()
{
local tar_file="$1"
local kernel_dev=
local rootfs_dev=
local current_sys=0

CI_KERNPART=kernel
CI_ROOTPART=rootfs

if cat /proc/device-tree/chosen/bootargs-append | grep -q sys=1; then
current_sys=1
fi

if [ "$current_sys" = "1" ]; then
rootfs_dev=$(blkid -t "PARTLABEL=rootfs" -o device)
kernel_dev=$(blkid -t "PARTLABEL=kernel" -o device)
CI_KERNPART=kernel
CI_ROOTPART=rootfs
else
rootfs_dev=$(blkid -t "PARTLABEL=rootfs_1" -o device)
kernel_dev=$(blkid -t "PARTLABEL=kernel_1" -o device)
CI_KERNPART=kernel_1
CI_ROOTPART=rootfs_1
fi

[ -z "${rootfs_dev}" ] && return 1
[ -z "${kernel_dev}" ] && return 1
fw_printenv env_init &>/dev/null || {
v "Failed to fetch env, please check /etc/fw_env.config"
return 1
}

#Switch sys to boot
if [ "$current_sys" = "1" ]; then
fw_setenv bootargs "console=ttyS0,115200n1 loglevel=8 earlycon=uart8250,mmio32,0x11002000 root=PARTLABEL=rootfs rootfstype=squashfs,f2fs"
else
fw_setenv bootargs "console=ttyS0,115200n1 loglevel=8 earlycon=uart8250,mmio32,0x11002000 root=PARTLABEL=rootfs_1 rootfstype=squashfs,f2fs"
fi
sync

rootdev="${rootfs_dev##*/}"
rootdev="${rootdev%p[0-9]*}"
CI_ROOTDEV=${rootdev}
emmc_do_upgrade "${tar_file}"
}

platform_do_upgrade() {
local board=$(board_name)

Expand Down Expand Up @@ -83,6 +130,9 @@ platform_do_upgrade() {
CI_ROOT_UBIPART=ubi
nand_do_upgrade "$1"
;;
tenbay,wr3000k-gsw-emmc-nor)
tenbay_mmc_do_upgrade_dual_boot "$1"
;;
*)
nand_do_upgrade "$1"
;;
Expand All @@ -105,6 +155,9 @@ platform_check_image() {
}
return 0
;;
tenbay,wr3000k-gsw-emmc-nor)
return 0
;;
*)
nand_do_platform_check "$board" "$1"
return $?
Expand All @@ -123,6 +176,9 @@ platform_copy_config() {
;;
esac
;;
tenbay,wr3000k-gsw-emmc-nor)
emmc_copy_config
;;
esac
}

Expand Down
Loading

0 comments on commit fab9c69

Please sign in to comment.