ipq50xx: Add Redmi AX3000

This commit is contained in:
hzy 2023-06-08 10:11:57 +00:00
parent 6a8750eeff
commit c8cc4b1fc3
14 changed files with 831 additions and 0 deletions

View File

@ -0,0 +1,20 @@
#!/bin/sh
[ -e /etc/config/ubootenv ] && exit 0
touch /etc/config/ubootenv
. /lib/uboot-envtools.sh
. /lib/functions.sh
board=$(board_name)
case "$board" in
redmi,ax3000)
ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x10000" "0x20000"
;;
esac
config_load ubootenv
config_foreach ubootenv_add_app_config ubootenv
exit 0

View File

@ -36,6 +36,7 @@ ALLWIFIBOARDS:= \
netgear_wax218 \
prpl_haze \
qnap_301w \
redmi_ax3000 \
redmi_ax6 \
wallys_dr40x9 \
xiaomi_ax3600 \
@ -129,6 +130,7 @@ $(eval $(call generate-ipq-wifi-package,edimax_cax1800,Edimax CAX1800))
$(eval $(call generate-ipq-wifi-package,netgear_wax218,Netgear WAX218))
$(eval $(call generate-ipq-wifi-package,qnap_301w,QNAP 301w))
$(eval $(call generate-ipq-wifi-package,prpl_haze,prpl Haze))
$(eval $(call generate-ipq-wifi-package,redmi_ax3000,Redmi AX3000))
$(eval $(call generate-ipq-wifi-package,redmi_ax6,Redmi AX6))
$(eval $(call generate-ipq-wifi-package,wallys_dr40x9,Wallys DR40X9))
$(eval $(call generate-ipq-wifi-package,xiaomi_ax3600,Xiaomi AX3600))

View File

@ -0,0 +1,29 @@
#!/bin/sh
. /lib/functions/uci-defaults.sh
bits() {
local val
val=0
while [ -n "$1" ]; do
val=$(( val | (1 << $1) ))
shift 1
done
printf "0x%x" "$val"
}
board_config_update
board=$(board_name)
case $board in
redmi,ax3000)
ucidef_set_led_switch "wan" "WAN" "blue:internet" "switch1" "$( bits 4 )"
;;
esac
board_config_flush
exit 0

View File

@ -0,0 +1,23 @@
#!/bin/sh
. /lib/functions/uci-defaults.sh
ipq50xx_setup_interfaces()
{
local board="$1"
case $board in
redmi,ax3000)
ucidef_add_switch "switch1" \
"6u@eth1" "5u@eth0" \
"1:lan:1" "2:lan:2" "3:lan:3" \
"4:wan"
;;
esac
}
board_config_update
board=$(board_name)
ipq50xx_setup_interfaces $board
board_config_flush
exit 0

View File

@ -0,0 +1,25 @@
#!/bin/sh
[ -e /lib/firmware/$FIRMWARE ] && exit 0
set_board_id() {
echo "$1" >/lib/firmware/$FIRMWARE
}
board=$(board_name)
case "$FIRMWARE" in
"ath11k/IPQ5018/hw1.0/board_id-ahb-c000000.wifi")
case "$board" in
redmi,ax3000)
case "$(strings /dev/mtdblock15 | grep wl_pa_type= | cut -d= -f2)" in
epa) set_board_id 0x24 ;;
ipa|*) set_board_id 0x10 ;;
esac
;;
esac
;;
*)
exit 1
;;
esac

View File

@ -0,0 +1,27 @@
#!/bin/sh
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions/caldata.sh
board=$(board_name)
case "$FIRMWARE" in
"ath11k/IPQ5018/hw1.0/caldata.bin")
case "$board" in
redmi,ax3000)
caldata_extract "0:ART" 0x1000 0x20000
;;
esac
;;
"ath11k/qcn6122/hw1.0/caldata_1.bin")
case "$board" in
redmi,ax3000)
caldata_extract "0:ART" 0x26800 0x20000
;;
esac
;;
*)
exit 1
;;
esac

View File

@ -0,0 +1,34 @@
#!/bin/sh /etc/rc.common
START=99
. /lib/functions.sh
boot() {
case $(board_name) in
redmi,ax3000)
fw_printenv >/dev/null || return 0
local flag_ota_reboot="$(fw_printenv flag_ota_reboot | cut -d'=' -f2)"
if [[ "$flag_ota_reboot" == 1 ]]; then
local mtd="$(grep -oE 'ubi.mtd=[a-zA-Z0-9\-\_]*' /proc/cmdline | cut -d'=' -f2)"
case $mtd in
rootfs)
fw_setenv flag_last_success 0
fw_setenv flag_ota_reboot 0
fw_setenv flag_boot_success 1
;;
rootfs_1)
fw_setenv flag_last_success 1
fw_setenv flag_ota_reboot 0
fw_setenv flag_boot_success 1
;;
*)
echo "Unable to determine UBIPART: ubi.mtd=$mtd"
return 1
;;
esac
fi
;;
esac
}

View File

@ -0,0 +1,80 @@
. /lib/functions.sh
mi_dualboot_check_image() {
local ret=0
local file_type="$( identify "$1" )"
if [ "${file_type}" != ubi ]; then
v "Unsupport file type: ${file_type}"
v "Please use ubi file"
ret=1
fi
local mtd="$( grep -oE 'ubi.mtd=[a-zA-Z0-9\-\_]*' /proc/cmdline | cut -d'=' -f2 )"
if [[ "${mtd}" != "rootfs" ]] && [[ "${mtd}" != "rootfs_1" ]]; then
v "Unable to determine UBIPART: ubi.mtd=${mtd}"
ret=1
fi
if ! fw_printenv >/dev/null; then
v "Fail to read U-Boot env"
ret=1
fi
return ${ret}
}
mi_dualboot_do_upgrade() {
mkdir -p /var/lock
fw_printenv >/dev/null || return 1
# Determine UBIPART
local mtd="$( grep -oE 'ubi.mtd=[a-zA-Z0-9\-\_]*' /proc/cmdline | cut -d'=' -f2 )"
case "${mtd}" in
rootfs)
CI_UBIPART="rootfs_1"
local current=0
;;
rootfs_1)
CI_UBIPART="rootfs"
local current=1
;;
*)
v "Unable to determine UBIPART: ubi.mtd=$mtd"
return 1
;;
esac
local mtdnum="$( find_mtd_index "${CI_UBIPART}" )"
v "Flashing to ${CI_UBIPART}(mtd${mtdnum})"
ubiformat "/dev/mtd${mtdnum}" -f "$1" -y || return 1
sync
ubiattach --mtdn "${mtdnum}"
# Check to avoid the bug of the vendor U-Boot
local ubidev="$( nand_find_ubi "${CI_UBIPART}" )"
if [ -z "$( nand_find_volume "${ubidev}" "kernel" )" ]; then
v "\"kernel\" volume doesn't exist, which causes a bug of the vendor U-Boot."
v "When try to boot this system, U-Boot will always set flag_try_sys1_failed=0 even if this is the sysem 2"
return 1
fi
# Restore configurations
[ -f "${UPGRADE_BACKUP}" ] && CI_UBIPART="${CI_UBIPART}" nand_restore_config "${UPGRADE_BACKUP}"
# Clean the failed flag. So we can boot to them.
fw_setenv flag_try_sys1_failed 0 || return 1
fw_setenv flag_try_sys2_failed 0 || return 1
# Tell u-boot that the current is able to boot.
fw_setenv flag_last_success ${current} || return 1
# Tell u-boot to try to boot the other system.
# If it failed, it will clean this flag.
fw_setenv flag_ota_reboot 1 || return 1
# When this flag is set to 0 and the `flag_ota_reboot` is 1,
# the u-boot will roll back to `flag_last_success`.
fw_setenv flag_boot_success || return 1
}

View File

@ -1,8 +1,15 @@
. /lib/functions.sh
RAMFS_COPY_BIN='fw_printenv fw_setenv'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
platform_check_image() {
local board=$(board_name)
case $board in
redmi,ax3000)
mi_dualboot_check_image "$1"
return $?
;;
*)
v "Sysupgrade is not supported on your board($board) yet."
return 1
@ -13,6 +20,9 @@ platform_check_image() {
platform_do_upgrade() {
local board=$(board_name)
case $board in
redmi,ax3000)
mi_dualboot_do_upgrade "$1"
;;
*)
default_do_upgrade "$1"
;;

View File

@ -1297,6 +1297,8 @@ CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT=y
# CONFIG_MTD_UBI_GLUEBI is not set
CONFIG_MDIO_IPQ4019=y
CONFIG_BRIDGE_VLAN_FILTERING=y
CONFIG_LEDS_GPIO=y
CONFIG_SWCONFIG_LEDS=y
CONFIG_IPQ_APSS_PLL=y
CONFIG_IPQ_APSS_6018=y

View File

@ -0,0 +1,556 @@
// SPDX-License-Identifier: (GPL-2.0+)
/dts-v1/;
#include "ipq5018.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
/ {
model = "Redmi AX3000";
compatible = "redmi,ax3000", "qcom,ipq5018";
#address-cells = <2>;
#size-cells = <2>;
interrupt-parent = <&intc>;
aliases {
serial0 = &blsp1_uart1;
ethernet0 = &mac0;
ethernet1 = &mac1;
led-boot = &led_system_blue;
led-failsafe = &led_system_yellow;
led-running = &led_system_blue;
led-upgrade = &led_system_yellow;
};
chosen {
// Override the root parameter from u-boot
// Increase coherent_pool size for WiFi
bootargs-append = " root=/dev/ubiblock0_1 coherent_pool=2M";
stdout-path = "serial0:115200n8";
};
reserved-memory {
// Not sure why but without this, WiFi will crash
tz_apps@4a400000 {
no-map;
// The size is incorrent, but it works
reg = <0x0 0x4a400000 0x0 0x700000>;
};
q6_mem_regions: q6_mem_regions@4b000000 {
no-map;
// reg = <0x0 0x4b000000 0x0 0x3b00000>;
reg = <0x0 0x4b000000 0x0 0x3000000>;
};
};
thermal-zones {
status = "ok";
};
};
&tlmm {
blsp_uart0_pins: blsp_uart0_pins {
pins =
"gpio28", // RX
"gpio29"; // TX
function = "blsp0_uart1";
drive-strength = <8>;
bias-disable;
};
qspi_nand_pins: qspi_nand_pins {
clock {
pins = "gpio9";
function = "qspi_clk";
drive-strength = <8>;
bias-disable;
};
cs {
pins = "gpio8";
function = "qspi_cs";
drive-strength = <8>;
bias-disable;
};
data0 {
pins = "gpio7";
function = "qspi0";
drive-strength = <8>;
bias-disable;
};
data1 {
pins = "gpio6";
function = "qspi1";
drive-strength = <8>;
bias-disable;
};
data2 {
pins = "gpio5";
function = "qspi2";
drive-strength = <8>;
bias-disable;
};
data3 {
pins = "gpio4";
function = "qspi3";
drive-strength = <8>;
bias-disable;
};
};
mdio1_pins: mdio1_pins {
mdc {
pins = "gpio36";
function = "mdc";
drive-strength = <8>;
bias-pull-up;
};
mdio {
pins = "gpio37";
function = "mdio";
drive-strength = <8>;
bias-pull-up;
};
};
leds_pins: leds_pins {
led_system_blue {
pins = "gpio19";
function = "gpio";
drive-strength = <8>;
bias-pull-down;
};
led_system_yellow {
pins = "gpio17";
function = "gpio";
drive-strength = <8>;
bias-pull-down;
};
led_internet_blue {
pins = "gpio22";
function = "gpio";
drive-strength = <8>;
bias-pull-down;
};
led_internet_yellow {
pins = "gpio20";
function = "gpio";
drive-strength = <8>;
bias-pull-down;
};
};
button_pins: button_pins {
button_reset {
pins = "gpio25";
function = "gpio";
drive-strength = <8>;
bias-pull-up;
};
button_mesh {
pins = "gpio23";
function = "gpio";
drive-strength = <8>;
bias-pull-up;
};
};
};
&blsp1_uart1 {
pinctrl-0 = <&blsp_uart0_pins>;
pinctrl-names = "default";
status = "ok";
};
&qpic_bam {
status = "ok";
};
&nand {
pinctrl-0 = <&qspi_nand_pins>;
pinctrl-names = "default";
status = "ok";
};
&soc {
leds {
compatible = "gpio-leds";
pinctrl-0 = <&leds_pins>;
pinctrl-names = "default";
led_system_blue: led_system_blue {
label = "blue:system";
gpio = <&tlmm 19 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
led_system_yellow: led_system_yellow {
label = "yellow:system";
gpio = <&tlmm 17 GPIO_ACTIVE_HIGH>;
};
led_internet_blue: led_internet_blue {
label = "blue:internet";
gpio = <&tlmm 22 GPIO_ACTIVE_HIGH>;
};
led_internet_yellow: led_internet_yellow {
label = "yellow:internet";
gpio = <&tlmm 20 GPIO_ACTIVE_HIGH>;
};
};
button {
compatible = "gpio-keys";
pinctrl-0 = <&button_pins>;
pinctrl-names = "default";
button_reset {
label = "reset";
gpios = <&tlmm 25 GPIO_ACTIVE_LOW>;
linux,input-type = <EV_KEY>;
linux,code = <KEY_RESTART>;
debounce-interval = <60>;
};
button_mesh {
label = "mesh";
gpios = <&tlmm 23 GPIO_ACTIVE_LOW>;
linux,input-type = <EV_KEY>;
linux,code = <KEY_WPS_BUTTON>;
debounce-interval = <60>;
};
};
ess-instance {
num_devices = <2>;
// Dummy switch, to describe how the external ports connects to the MAC
// For example, some chips have PSGMII ports which combine 5 MAC into
// 1 external port.
// For IPQ50xx, this is used to choose SGMII or SGMII-plus
ess-switch@0x39c00000 {
compatible = "qcom,ess-switch-ipq50xx";
device_id = <0>;
cmnblk_clk = "internal_96MHz";
// MAC1 Mode
// switch_mac_mode = <0xc>; // PORT_WRAPPER_SGMII_PLUS
switch_mac_mode = <0xf>; // PORT_WRAPPER_SGMII_CHANNEL0
qcom,port_phyinfo {
// MAC0 -> GE Phy -> QCA8337 Phy4
port@0 {
port_id = <1>;
mdiobus = <&mdio0>;
phy_address = <7>;
phy_dac = <0x10 0x10>;
};
// MAC1 ---SGMII---> QCA8337 SerDes
port@1 {
port_id = <2>;
forced-speed = <1000>;
forced-duplex = <1>;
};
};
};
// QCA8337
ess-switch1@1 {
compatible = "qcom,ess-switch-qca83xx";
device_id = <1>;
reset_gpio = <26>;
switch_access_mode = "mdio";
mdio-bus = <&mdio1>;
qca,ar8327-initvals = <
0x000c 0x00000080 // PAD6_MODE = MAC6_SGMII_EN
0x0010 0x002613a0 // PWS_REG = DEFAULT_VALUE | SERDES_AEN
0x0094 0x000010ce // PORT6_STATUS = DEFAULT_VALUE | DUPLEX_MODE_6 | RXMAC_EN_6 |
// TXMAC_EN_6 | SPEED_6(1000M)
0x00e0 0xc74164de // SGMII_CTRL = DEFAULT_VALUE | MODE_CTRL_25M(SGMII_PHY) | SGMII_EN_SD |
// SGMII_EN_TX | SGMII_EN_RX | SGMII_EN_PLL
>;
switch_cpu_bmp = <0x60>; // CPU port bitmap: 5 6
switch_lan_bmp = <0x0e>; // LAN port bitmap: 1 2 3
switch_wan_bmp = <0x10>; // WAN port bitmap: 4
qcom,port_phyinfo {
// MAC1 -> Phy0 -> LAN1
port@1 {
port_id = <1>;
phy_address = <0>;
};
// MAC2 -> Phy1 -> LAN2
port@2 {
port_id = <2>;
phy_address = <1>;
};
// MAC3 -> Phy2 -> LAN3
port@3 {
port_id = <3>;
phy_address = <2>;
};
// MAC4 -> Phy3 -> WAN
port@4 {
port_id = <4>;
phy_address = <3>;
};
// MAC5 -> Phy4 -> IPQ5000 GE Phy
port@5 {
port_id = <5>;
phy_address = <4>;
};
// MAC6 ---SGMII---> IPQ5000 MAC1
port@6 {
port_id = <6>;
forced-speed = <1000>;
forced-duplex = <1>;
};
};
};
};
// MAC0 -> GE Phy
mac0: dp1 {
compatible = "qcom,nss-dp";
device_type = "network";
qcom,id = <1>;
reg = <0x39C00000 0x10000>;
interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&gcc GCC_SNOC_GMAC0_AXI_CLK>;
clock-names = "nss-snoc-gmac-axi-clk";
qcom,mactype = <2>; // GMAC_HAL_TYPE_SYN_GMAC
local-mac-address = [000000000000];
phy-handle = <&ge_phy>;
phy-mode = "internal";
};
// MAC1 ---SGMII---> QCA8337 SerDes
mac1: dp2 {
compatible = "qcom,nss-dp";
device_type = "network";
qcom,id = <2>;
reg = <0x39D00000 0x10000>;
interrupts = <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&gcc GCC_SNOC_GMAC1_AXI_CLK>;
clock-names = "nss-snoc-gmac-axi-clk";
qcom,mactype = <2>; // GMAC_HAL_TYPE_SYN_GMAC
local-mac-address = [000000000000];
phy-mode = "sgmii";
};
};
&mdio0 {
status = "ok";
resets = <&gcc GCC_GEPHY_MDC_SW_ARES>;
reset-names = "phy";
// IPQ5018 GE Phy -> QCA8337 Phy4
ge_phy: ethernet-phy@0 {
reg = <7>;
};
};
&mdio1 {
pinctrl-0 = <&mdio1_pins>;
pinctrl-names = "default";
status = "ok";
reset-gpios = <&tlmm 26 GPIO_ACTIVE_LOW>;
// QCA8337 Phy0 -> LAN1
ethernet-phy@0 {
reg = <0>;
};
// QCA8337 Phy1 -> LAN2
ethernet-phy@1 {
reg = <1>;
};
// QCA8337 Phy2 -> LAN3
ethernet-phy@2 {
reg = <2>;
};
// QCA8337 Phy3 -> WAN
ethernet-phy@3 {
reg = <3>;
};
// QCA8337 Phy4 -> IPQ5018 GE Phy
ethernet-phy@4 {
reg = <4>;
};
};
&q6v5_wcss {
memory-region = <&q6_mem_regions>;
qcom,rproc = <&q6v5_wcss>;
firmware = "IPQ5018/q6_fw.mdt";
qcom,bootargs_smem = <507>;
boot-args = </* type: */ 0x2 /* PCIE1 */
/* length: */ 4
/* PD id: */ 2
/* reset GPIO: */ 27
/* reserved: */ 0 0>;
status = "ok";
// IPQ5018
q6_wcss_pd1: remoteproc_pd1@4ab000 {
compatible = "qcom,ipq5018-wcss-ahb-mpd";
resets =
<&gcc GCC_WCSSAON_RESET>,
<&gcc GCC_WCSS_BCR>,
<&gcc GCC_CE_BCR>;
reset-names =
"wcss_aon_reset",
"wcss_reset",
"ce_reset";
clocks =
<&gcc GCC_WCSS_AHB_S_CLK>,
<&gcc GCC_WCSS_ACMT_CLK>,
<&gcc GCC_WCSS_AXI_M_CLK>;
clock-names =
"gcc_wcss_ahb_s_clk",
"gcc_wcss_acmt_clk",
"gcc_wcss_axi_m_clk";
reg = <0x4ab000 0x20>;
reg-names = "rmb";
// qcom,halt-regs = <&tcsr_q6_block 0xa000 0xd000 0x0>;
interrupts-extended =
<&wcss_smp2p_in 8 0>,
<&wcss_smp2p_in 9 0>,
<&wcss_smp2p_in 12 0>,
<&wcss_smp2p_in 11 0>;
interrupt-names =
"fatal",
"ready",
"spawn-ack",
"stop-ack";
qcom,smem-states =
<&wcss_smp2p_out 8>,
<&wcss_smp2p_out 9>,
<&wcss_smp2p_out 10>;
qcom,smem-state-names =
"shutdown",
"stop",
"spawn";
firmware = "IPQ5018/q6_fw.mdt";
m3_firmware = "IPQ5018/m3_fw.mdt";
};
// QCN6102
q6_wcss_pd2: remoteproc_pd2 {
compatible = "qcom,ipq5018-wcss-pcie-mpd";
interrupts-extended =
<&wcss_smp2p_in 16 0>,
<&wcss_smp2p_in 17 0>,
<&wcss_smp2p_in 20 0>,
<&wcss_smp2p_in 19 0>;
interrupt-names =
"fatal",
"ready",
"spawn-ack",
"stop-ack";
qcom,smem-states =
<&wcss_smp2p_out 16>,
<&wcss_smp2p_out 17>,
<&wcss_smp2p_out 18>;
qcom,smem-state-names =
"shutdown",
"stop",
"spawn";
firmware = "IPQ5018/q6_fw.mdt";
m3_firmware = "qcn6122/m3_fw.mdt";
};
};
&wifi0 {
// IPQ5000
qcom,multipd_arch;
qcom,rproc = <&q6_wcss_pd1>;
qcom,userpd-subsys-name = "q6v5_wcss_userpd1";
// Be overridden by /etc/hotplug.d/firmware/10-ath11k-board_id
// M79: 0x10
// M81: 0x24
qcom,board_id = <0x24>;
// qcom,ath11k-fw-memory-mode = <0>;
// qcom,bdf-addr = <0x4c400000>;
// qcom,caldb-addr = <0x4d200000>;
// qcom,m3-dump-addr = <0x4d400000>;
qcom,ath11k-fw-memory-mode = <2>;
qcom,bdf-addr = <0x4c400000>;
status = "ok";
};
&wifi1 {
// QCN6102
qcom,multipd_arch;
qcom,rproc = <&q6_wcss_pd2>;
qcom,userpd-subsys-name = "q6v5_wcss_userpd2";
qcom,board_id = <0x60>;
// qcom,ath11k-fw-memory-mode = <0>;
// qcom,bdf-addr = <0x4d500000>;
// qcom,caldb-addr = <0x4e500000>;
// qcom,m3-dump-addr = <0x4ea00000>;
qcom,ath11k-fw-memory-mode = <2>;
qcom,bdf-addr = <0x4d100000>;
qcom,m3-dump-addr = <0x4df00000>;
status = "ok";
};

View File

@ -31,4 +31,27 @@ define Device/UbiFit
IMAGE/nand-sysupgrade.bin := sysupgrade-tar | append-metadata
endef
define Device/redmi_ax3000
$(call Device/FitImage)
$(call Device/UbiFit)
SOC := ipq5000
DEVICE_VENDOR := Redmi
DEVICE_MODEL := AX3000
DEVICE_ALT0_VENDOR := Xiaomi
DEVICE_ALT0_MODEL := CR880x
DEVICE_ALT0_VARIANT := (M81 version)
DEVICE_ALT1_VENDOR := Xiaomi
DEVICE_ALT1_MODEL := CR880x
DEVICE_ALT1_VARIANT := (M79 version)
BLOCKSIZE := 128k
PAGESIZE := 2048
DEVICE_DTS_CONFIG := config@mp02.1
IMAGES := nand-factory.ubi
DEVICE_PACKAGES := \
ath11k-firmware-ipq5018 \
ath11k-firmware-qcn6122 \
ipq-wifi-redmi_ax3000
endef
TARGET_DEVICES += redmi_ax3000
$(eval $(call BuildImage))