Skip to content

Commit

Permalink
sunxi: support ThingsLink K4X device
Browse files Browse the repository at this point in the history
  • Loading branch information
srdgame committed May 8, 2024
1 parent 0bc969e commit 84283f2
Show file tree
Hide file tree
Showing 12 changed files with 964 additions and 5 deletions.
8 changes: 8 additions & 0 deletions package/boot/uboot-sunxi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@ define U-Boot/tlink_k2x
UENV:=display
endef

define U-Boot/tlink_k4x
BUILD_SUBTARGET:=cortexa7
NAME:=ThingsLink K4X
BUILD_DEVICES:=kooiot_tlink-k4x
UENV:=display
endef

define U-Boot/tlink_m408
BUILD_SUBTARGET:=cortexa7
NAME:=ThingsLink M408
Expand Down Expand Up @@ -425,6 +432,7 @@ UBOOT_TARGETS := \
tlink_k1 \
tlink_k2 \
tlink_k2x \
tlink_k4x \
tlink_m408 \
tlink_m416 \
tlink_s1 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
+
+ status {
+ label = "kooiot:green:status";
+ gpios = <&pio 7 11 GPIO_ACTIVE_LOW>; /* PG7 */
+ gpios = <&pio 6 7 GPIO_ACTIVE_LOW>; /* PG7 */
+ linux,default-trigger = "heartbeat";
+ };
+ };
Expand Down
271 changes: 271 additions & 0 deletions package/boot/uboot-sunxi/patches/916-ARM-dts-tlink-k4x.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
--- /dev/null
+++ b/configs/tlink_k4x_defconfig
@@ -0,0 +1,32 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SPL=y
+CONFIG_MACH_SUN8I_R40=y
+CONFIG_DRAM_CLK=576
+CONFIG_DRAM_ZQ=3881979
+# CONFIG_SUNXI_DRAM_DW_R40_DUAL_RANK is not set
+CONFIG_MMC0_CD_PIN="PB8"
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+CONFIG_USB0_VBUS_PIN="PC18"
+CONFIG_AHCI=y
+CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
+# CONFIG_NR_DRAM_BANKS is not set
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL_I2C_SUPPORT=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_DEFAULT_DEVICE_TREE="sun8i-r40-tlink-k4x"
+CONFIG_SCSI_AHCI=y
+CONFIG_MII=y
+CONFIG_SUN8I_EMAC=y
+CONFIG_AXP_GPIO=y
+CONFIG_AXP_DCDC3_VOLT=1200
+CONFIG_AXP_DCDC5_VOLT=1200
+CONFIG_AXP_ALDO1_VOLT=3300
+CONFIG_AXP_ALDO2_VOLT=1800
+CONFIG_AXP_DLDO1_VOLT=3300
+CONFIG_AXP_DLDO4_VOLT=1800
+CONFIG_AXP_ELDO2_VOLT=1200
+CONFIG_AXP_ELDO3_VOLT=2500
+CONFIG_SCSI=y
+CONFIG_USB_ECHI_HCD=y
+CONFIG_USB_OCHI_HCD=y
+++ a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -547,6 +547,7 @@
sun8i-r40-bananapi-m2-ultra.dtb \
sun8i-r40-tlink-k1.dtb \
sun8i-r40-tlink-k2x.dtb \
+ sun8i-r40-tlink-k4x.dtb \
sun8i-v40-bananapi-m2-berry.dtb \
sun8i-t3-tlink-m408.dtb
dtb-$(CONFIG_MACH_SUN8I_V3S) += \
--- /dev/null
+++ b/arch/arm/dts/sun8i-r40-tlink-k4x.dts
@@ -0,0 +1,223 @@
+/*
+ * Copyright (C) 2024 Dirk Chang <[email protected]>
+ *
+ */
+
+/dts-v1/;
+#include "sun8i-r40.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+ model = "ThingsLink K4X";
+ compatible = "kooiot,tlink-k4x", "allwinner,sun8i-r40";
+
+ aliases {
+ ethernet0 = &gmac;
+ ethernet1 = &emac;
+ serial0 = &uart0;
+ mmc0 = &mmc0;
+ mmc1 = &mmc2;
+ };
+
+ chosen {
+ stdout-path = "serial0:115200n8";
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ status {
+ label = "green:status";
+ gpios = <&pio 6 8 GPIO_ACTIVE_HIGH>; /* PG8 */
+ linux,default-trigger = "heartbeat";
+ };
+ };
+
+ reg_vcc3v3_sdc: vcc3v3-sdc {
+ compatible = "regulator-fixed";
+ regulator-name = "vcc3v3-sdc";
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ vin-supply = <&reg_dcdc1>;
+ gpio = <&pio 2 16 GPIO_ACTIVE_LOW>; /* PC16 CARD0-PWR*/
+ // enable-active-high;
+ };
+};
+
+&emac {
+ pinctrl-names = "default";
+ pinctrl-0 = <&emac_mii_pins>;
+ phy-handle = <&emac_phy>;
+ phy-supply = <&reg_dcdc1>;
+ phy-mode = "mii";
+ status = "okay";
+};
+
+&emac_mdio {
+ status = "okay";
+ phy-supply = <&reg_dcdc1>;
+ reset-gpios = <&pio 7 27 GPIO_ACTIVE_LOW>; /* PH27 */
+ reset-assert-us = <10000>;
+ reset-deassert-us = <1000000>;
+ emac_phy: ethernet-phy@3 {
+ compatible = "ethernet-phy-ieee802.3-c22";
+ reg = <3>;
+ };
+};
+
+&gmac {
+ pinctrl-names = "default";
+ pinctrl-0 = <&gmac_rgmii_pins>;
+ phy-handle = <&phy1>;
+ phy-mode = "rgmii";
+ phy-supply = <&reg_dcdc1>;
+ snps,reset-gpio = <&pio 0 9 GPIO_ACTIVE_LOW>; /* PA9 */
+ snps,reset-delays-us = <0 10000 1000000>;
+ status = "okay";
+};
+
+&gmac_mdio {
+ phy1: ethernet-phy@3 {
+ compatible = "ethernet-phy-ieee802.3-c22";
+ reg = <3>;
+ // reset-gpios = <&pio 0 9 GPIO_ACTIVE_LOW>; /* PA9 */
+ // reset-assert-us = <10000>;
+ // reset-deassert-us = <1000000>;
+ // interrupt-parent = <&pio>;
+ // interrupts = <&pio 0 17 GPIO_ACTIVE_LOW>; /* PA17 */
+ };
+};
+
+&i2c0 {
+ status = "okay";
+
+ axp22x: pmic@34 {
+ compatible = "x-powers,axp221";
+ reg = <0x34>;
+ interrupt-parent = <&nmi_intc>;
+ interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+ };
+};
+
+#include "axp22x.dtsi"
+
+&mmc0 {
+ vmmc-supply = <&reg_vcc3v3_sdc>;
+ bus-width = <4>;
+ cd-gpios = <&pio 1 8 GPIO_ACTIVE_LOW>; /* PB3 */
+ status = "okay";
+};
+
+&mmc2 {
+ vmmc-supply = <&reg_dcdc1>;
+ vqmmc-supply = <&reg_aldo2>;
+ bus-width = <8>;
+ non-removable;
+ status = "okay";
+};
+
+&pio {
+ pinctrl-names = "default";
+ // pinctrl-0 = <&clk_out_a_pin>; // used by UART6
+ vcc-pa-supply = <&reg_dcdc1>;
+ vcc-pc-supply = <&reg_dcdc1>;
+ vcc-pd-supply = <&reg_dcdc1>;
+ vcc-pe-supply = <&reg_dcdc1>;
+ vcc-pf-supply = <&reg_dcdc1>;
+ vcc-pg-supply = <&reg_dcdc1>;
+};
+
+&reg_aldo1 {
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-name = "vcc-wifi-io";
+};
+
+&reg_aldo2 {
+ regulator-always-on;
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-name = "vcc-pc";
+};
+
+&reg_aldo3 {
+ regulator-always-on;
+ regulator-min-microvolt = <3000000>;
+ regulator-max-microvolt = <3000000>;
+ regulator-name = "vcc-pll";
+};
+
+&reg_dc1sw {
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-name = "vcc-wifi";
+};
+
+&reg_dcdc1 {
+ regulator-always-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-name = "vcc-3v3";
+};
+
+&reg_dcdc2 {
+ regulator-always-on;
+ regulator-min-microvolt = <1000000>;
+ regulator-max-microvolt = <1300000>;
+ regulator-name = "vdd-sys";
+};
+
+&reg_dcdc3 {
+ regulator-always-on;
+ regulator-min-microvolt = <1000000>;
+ regulator-max-microvolt = <1300000>;
+ regulator-name = "vdd-cpu";
+};
+
+&reg_dcdc5 {
+ regulator-always-on;
+ regulator-min-microvolt = <1200000>;
+ regulator-max-microvolt = <1200000>;
+ regulator-name = "vcc-dram";
+};
+
+&reg_dldo1 {
+ regulator-always-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-name = "vcc-eth-io";
+};
+
+&reg_dldo2 {
+ regulator-always-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-name = "vcc-eth-io-2";
+};
+
+&reg_dldo3 {
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-name = "vcc-wifi-1v8";
+};
+
+&reg_dldo4 {
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-name = "vcc-wifi-1v8-2";
+};
+
+&reg_eldo3 {
+ regulator-min-microvolt = <2500000>;
+ regulator-max-microvolt = <2500000>;
+ regulator-name = "vdd1v2-sata";
+};
+
+&uart0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart0_pb_pins>;
+ status = "okay";
+};
1 change: 1 addition & 0 deletions target/linux/sunxi/base-files/etc/board.d/01_leds
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ kooiot,tlink-r1)
ucidef_set_led_netdev "modem" "modem" "kooiot:green:modem" "wwan0"
;;
kooiot,tlink-k2)
kooiot,tlink-k4x)
ucidef_set_led_netdev "modem" "modem" "kooiot:green:modem" "wwan0"
;;
kooiot,tlink-k2x)
Expand Down
1 change: 1 addition & 0 deletions target/linux/sunxi/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ kooiot,tlink-k1)
ucidef_set_interface_lan "eth0 eth1"
;;
kooiot,tlink-k2|\
kooiot,tlink-k4x|\
kooiot,tlink-m408|\
kooiot,tlink-m416)
# tlink_setup_macs
Expand Down
2 changes: 2 additions & 0 deletions target/linux/sunxi/base-files/etc/uci-defaults/99_tlink
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ tlink_default() {

case "$(board_name)" in
"kooiot,tlink-k2x"|\
"kooiot,tlink-k4x"|\
"kooiot,tlink-k2")
tlink_init_5g
;;
Expand Down Expand Up @@ -298,6 +299,7 @@ case "$(board_name)" in
"kooiot,tlink-k1"|\
"kooiot,tlink-k2"|\
"kooiot,tlink-k2x"|\
"kooiot,tlink-k4x"|\
"kooiot,tlink-s1"|\
"kooiot,tlink-m408"|\
"kooiot,tlink-m416"|\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ case $(board_name) in
tlink_csq_leds_mixed
;;
kooiot,tlink-k2|\
kooiot,tlink-k2x)
kooiot,tlink-k2x|\
kooiot,tlink-k4x)
tlink_csq_leds_single
;;
*)
Expand Down
3 changes: 2 additions & 1 deletion target/linux/sunxi/base-files/lib/preinit/04_tlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ do_kooiot_tlink_generic() {
"kooiot,tlink-k2")
do_product_sn_kooiot_nvmem "3" "0050"
;;
"kooiot,tlink-k2x")
"kooiot,tlink-k2x"|\
"kooiot,tlink-k4x")
do_product_sn_kooiot_nvmem "2" "0050"
;;
esac
Expand Down
4 changes: 3 additions & 1 deletion target/linux/sunxi/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ platform_check_image() {
;;
"kooiot,tlink-k1"|\
"kooiot,tlink-k2"|\
"kooiot,tlink-k2x")
"kooiot,tlink-k2x"|\
"kooiot,tlink-k4x")
tlink_check_image "sun8i-r40" "$1" && return 0
return 1
;;
Expand Down Expand Up @@ -101,6 +102,7 @@ platform_pre_upgrade() {
"kooiot,tlink-k1"|\
"kooiot,tlink-k2"|\
"kooiot,tlink-k2x"|\
"kooiot,tlink-k4x"|\
"kooiot,tlink-s1"|\
"kooiot,tlink-m408"|\
"kooiot,tlink-m416"|\
Expand Down
3 changes: 2 additions & 1 deletion target/linux/sunxi/base-files/sbin/write_psn
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ case "$(board_name)" in
NVMEM_PATH="/sys/bus/i2c/devices/3-0050/3-00501/nvmem"
fi
;;
"kooiot,tlink-k2x")
"kooiot,tlink-k2x" |\
"kooiot,tlink-k4x")
NVMEM_PATH="/sys/bus/i2c/devices/2-0050/eeprom"
if [ ! -f ${NVMEM_PATH} ]; then
NVMEM_PATH="/sys/bus/i2c/devices/2-0050/2-00500/nvmem"
Expand Down
Loading

0 comments on commit 84283f2

Please sign in to comment.