Merge Official Source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen
2024-02-25 13:24:47 +08:00
57 changed files with 1396 additions and 449 deletions

View File

@@ -1,2 +1,2 @@
LINUX_VERSION-6.1 = .78
LINUX_KERNEL_HASH-6.1.78 = 65206b969831236849c9906eba267e715734a93808e9909fd9b4f12eea10d689
LINUX_VERSION-6.1 = .79
LINUX_KERNEL_HASH-6.1.79 = faa49ca22fb55ed4d5ca2a55e07dd10e4e171cfc3b92568a631453cd2068b39b

View File

@@ -87,11 +87,11 @@ define prepare_rootfs
fi; \
done || true \
)
$(if $(IB),,awk -i inplace \
awk -i inplace \
'/^Status:/ { \
if ($$3 == "user") { $$3 = "ok" } \
else { sub(/,\<user\>|\<user\>,/, "", $$3) } \
}1' $(1)/usr/lib/opkg/status)
}1' $(1)/usr/lib/opkg/status
$(if $(SOURCE_DATE_EPOCH),sed -i "s/Installed-Time: .*/Installed-Time: $(SOURCE_DATE_EPOCH)/" $(1)/usr/lib/opkg/status)
@-find $(1) -name CVS -o -name .svn -o -name .git -o -name '.#*' | $(XARGS) rm -rf
rm -rf \

View File

@@ -53,7 +53,8 @@ aruba,ap-303)
aruba,ap-365)
ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x10000" "0x10000"
;;
buffalo,wtr-m2133hp)
buffalo,wtr-m2133hp|\
netgear,lbr20)
ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x40000" "0x20000"
;;
linksys,ea6350v3)

View File

@@ -13,10 +13,9 @@ board=$(board_name)
case "$board" in
bananapi,bpi-r2)
. /lib/upgrade/common.sh
export_bootdevice
export_partdevice ubootpart 1
ubootenv_add_uci_config "/dev/$ubootpart" "0xb0000" "0x10000" "0x10000" "1"
. /lib/upgrade/platform.sh
bootdev="$(platform_get_bootdev)"
ubootenv_add_uci_config "/dev/${bootdev%p[0-9]*}p1" "0xb0000" "0x10000" "0x10000" "1"
;;
unielec,u7623-02)
ubootenv_add_uci_config "/dev/mmcblk0p1" "0xc0000" "0x10000" "0x10000" "1"

View File

@@ -0,0 +1,46 @@
--- a/board/mediatek/mt7623/mt7623_rfb.c
+++ b/board/mediatek/mt7623/mt7623_rfb.c
@@ -5,6 +5,7 @@
#include <common.h>
#include <mmc.h>
+#include <part.h>
#include <asm/global_data.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -22,8 +23,9 @@ int mmc_get_boot_dev(void)
{
int g_mmc_devid = -1;
char *uflag = (char *)0x81DFFFF0;
+ struct blk_desc *desc;
- if (!find_mmc_device(1))
+ if (blk_get_device_by_str("mmc", "1", &desc) < 0)
return 0;
if (strncmp(uflag,"eMMC",4)==0) {
@@ -38,6 +40,23 @@ int mmc_get_boot_dev(void)
int mmc_get_env_dev(void)
{
- return mmc_get_boot_dev();
+ struct udevice *dev;
+ const char *mmcdev;
+
+ switch (mmc_get_boot_dev()) {
+ case 0:
+ mmcdev = "mmc@11230000";
+ break;
+ case 1:
+ mmcdev = "mmc@11240000";
+ break;
+ default:
+ return -1;
+ }
+
+ if (uclass_get_device_by_name(UCLASS_MMC, mmcdev, &dev))
+ return -1;
+
+ return dev_seq(dev);
}
#endif

View File

@@ -1,6 +1,6 @@
--- a/board/mediatek/mt7623/mt7623_rfb.c
+++ b/board/mediatek/mt7623/mt7623_rfb.c
@@ -4,8 +4,17 @@
@@ -4,9 +4,18 @@
*/
#include <common.h>
@@ -9,6 +9,7 @@
+#include <env.h>
+#include <init.h>
#include <mmc.h>
#include <part.h>
#include <asm/global_data.h>
+#include <linux/delay.h>
+
@@ -18,8 +19,8 @@
DECLARE_GLOBAL_DATA_PTR;
@@ -41,3 +50,25 @@ int mmc_get_env_dev(void)
return mmc_get_boot_dev();
@@ -60,3 +69,25 @@ int mmc_get_env_dev(void)
return dev_seq(dev);
}
#endif
+

View File

@@ -0,0 +1,46 @@
--- a/board/mediatek/mt7623/mt7623_rfb.c
+++ b/board/mediatek/mt7623/mt7623_rfb.c
@@ -91,3 +91,43 @@ int board_late_init(void)
env_relocate();
return 0;
}
+
+int ft_system_setup(void *blob, struct bd_info *bd)
+{
+ const u32 *media_handle_p;
+ int chosen, len, ret;
+ const char *media;
+ u32 media_handle;
+
+#ifdef CONFIG_MMC
+ switch (mmc_get_boot_dev()) {
+ case 0:
+ media = "rootdisk-emmc";
+ break
+ ;;
+ case 1:
+ media = "rootdisk-sd";
+ break
+ ;;
+ }
+
+ chosen = fdt_path_offset(blob, "/chosen");
+ if (chosen <= 0)
+ return 0;
+
+ media_handle_p = fdt_getprop(blob, chosen, media, &len);
+ if (media_handle_p <= 0 || len != 4)
+ return 0;
+
+ media_handle = *media_handle_p;
+ ret = fdt_setprop(blob, chosen, "rootdisk", &media_handle, sizeof(media_handle));
+ if (ret) {
+ printf("cannot set media phandle %s as rootdisk /chosen node\n", media);
+ return ret;
+ }
+
+ printf("set /chosen/rootdisk to bootrom media: %s (phandle 0x%08x)\n", media, fdt32_to_cpu(media_handle));
+#endif
+
+ return 0;
+}

View File

@@ -1,6 +1,6 @@
--- a/configs/mt7623n_bpir2_defconfig
+++ b/configs/mt7623n_bpir2_defconfig
@@ -7,34 +7,105 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000
@@ -7,34 +7,106 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000
CONFIG_NR_DRAM_BANKS=1
CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x81ffff10
@@ -18,6 +18,7 @@
+CONFIG_LED_GPIO=y
+CONFIG_LOGLEVEL=7
+CONFIG_LOG=y
+CONFIG_OF_SYSTEM_SETUP=y
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_AUTOBOOT_MENU_SHOW=y
+CONFIG_BOARD_LATE_INIT=y
@@ -110,7 +111,7 @@
CONFIG_USE_IPADDR=y
CONFIG_IPADDR="192.168.1.1"
CONFIG_USE_SERVERIP=y
@@ -46,6 +117,12 @@ CONFIG_CLK=y
@@ -46,6 +118,12 @@ CONFIG_CLK=y
CONFIG_SUPPORT_EMMC_BOOT=y
CONFIG_MMC_HS400_SUPPORT=y
CONFIG_MMC_MTK=y
@@ -123,7 +124,7 @@
CONFIG_PHY_FIXED=y
CONFIG_MEDIATEK_ETH=y
CONFIG_PINCTRL=y
@@ -55,10 +132,13 @@ CONFIG_POWER_DOMAIN=y
@@ -55,10 +133,13 @@ CONFIG_POWER_DOMAIN=y
CONFIG_MTK_POWER_DOMAIN=y
CONFIG_DM_SERIAL=y
CONFIG_MTK_SERIAL=y
@@ -139,7 +140,7 @@
# CONFIG_EFI_GRUB_ARM32_WORKAROUND is not set
--- /dev/null
+++ b/bananapi_bpi-r2_env
@@ -0,0 +1,70 @@
@@ -0,0 +1,69 @@
+ipaddr=192.168.1.1
+serverip=192.168.1.254
+loadaddr=0x88000000
@@ -192,14 +193,13 @@
+sdmmc_write_recovery=iminfo $fileaddr && mmc dev 1 && part start mmc 1 $part_recovery part_addr && part size mmc 1 $part_recovery part_size && run mmc_write_vol
+_checkbootedfrom=setenv _checkbootedfrom ; if itest.l *81dffff0 == 434d4d65 ; then setenv bootedfrom eMMC ; else setenv bootedfrom SD ; fi
+_init_env=setenv _init_env ; setenv _create_env ; saveenv ; saveenv
+_firstboot=setenv _firstboot ; led $bootled_pwr off ;led $bootled_rec on ; run _checkbootedfrom _switch_to_menu _update_bootdev _update_bootcmd _update_bootcmd2 _init_env boot_first
+_firstboot=setenv _firstboot ; led $bootled_pwr off ;led $bootled_rec on ; run _checkbootedfrom _switch_to_menu _update_bootcmd _update_bootcmd2 _init_env boot_first
+_set_bootcmd_sdmmc=setenv boot_production "led $bootled_rec off ; led $bootled_pwr on ; run sdmmc_read_production && bootm $loadaddr ; led $bootled_pwr off"
+_set_bootcmd_emmc=setenv boot_production "led $bootled_rec off ; led $bootled_pwr on ; run emmc_read_production && bootm $loadaddr ; led $bootled_pwr off"
+_update_bootcmd=setenv _update_bootcmd ; if test "$bootedfrom" = "SD" ; then run _set_bootcmd_sdmmc ; else run _set_bootcmd_emmc ; fi ; setenv _set_bootcmd_sdmmc ; setenv _set_bootcmd_emmc
+_set_bootcmd2_sdmmc=setenv boot_recovery "led $bootled_pwr off ; led $bootled_rec on ; run sdmmc_read_recovery && bootm $loadaddr ; led $bootled_rec off"
+_set_bootcmd2_emmc=setenv boot_recovery "led $bootled_pwr off ; led $bootled_rec on ; run emmc_read_recovery && bootm $loadaddr ; led $bootled_rec off"
+_update_bootcmd2=setenv _update_bootcmd2 ; if test "$bootedfrom" = "SD" ; then run _set_bootcmd2_sdmmc ; else run _set_bootcmd2_emmc ; fi ; setenv _set_bootcmd2_sdmmc ; setenv _set_bootcmd2_emmc
+_update_bootdev=setenv _update_bootdev ; if test "$bootedfrom" = "SD" ; then setenv bootargs "$console root=/dev/mmcblk1p65" ; else setenv bootargs "$console root=/dev/mmcblk0p65" ; fi
+_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title [$bootedfrom] $ver" ; run _set_bm2
+_set_bm2=setenv _set_bm2 ; setenv bootmenu_2 "Boot production system from $bootedfrom.=run boot_production ; run bootmenu_confirm_return" ; run _set_bm3

View File

@@ -370,7 +370,7 @@
mt7981-rfb.dtb \
--- /dev/null
+++ b/linksys_e8450_env
@@ -0,0 +1,54 @@
@@ -0,0 +1,55 @@
+ethaddr_factory=ubi read 0x40080000 factory && env readmem -b ethaddr 0x400ffff4 0x6 ; setenv ethaddr_factory
+ipaddr=192.168.1.1
+serverip=192.168.1.254

View File

@@ -1,21 +0,0 @@
--- a/board/mediatek/mt7623/mt7623_rfb.c
+++ b/board/mediatek/mt7623/mt7623_rfb.c
@@ -9,6 +9,7 @@
#include <env.h>
#include <init.h>
#include <mmc.h>
+#include <part.h>
#include <asm/global_data.h>
#include <linux/delay.h>
@@ -31,8 +32,9 @@ int mmc_get_boot_dev(void)
{
int g_mmc_devid = -1;
char *uflag = (char *)0x81DFFFF0;
+ struct blk_desc *desc;
- if (!find_mmc_device(1))
+ if (blk_get_device_by_str("mmc", "1", &desc) < 0)
return 0;
if (strncmp(uflag,"eMMC",4)==0) {

View File

@@ -38,6 +38,7 @@ ALLWIFIBOARDS:= \
edimax_cax1800 \
linksys_mx4200 \
linksys_mx5300 \
netgear_lbr20 \
netgear_rax120v2 \
netgear_wax218 \
netgear_wax620 \
@@ -154,6 +155,7 @@ $(eval $(call generate-ipq-wifi-package,edgecore_eap102,Edgecore EAP102))
$(eval $(call generate-ipq-wifi-package,edimax_cax1800,Edimax CAX1800))
$(eval $(call generate-ipq-wifi-package,linksys_mx4200,Linksys MX4200))
$(eval $(call generate-ipq-wifi-package,linksys_mx5300,Linksys MX5300))
$(eval $(call generate-ipq-wifi-package,netgear_lbr20,Netgear LBR20))
$(eval $(call generate-ipq-wifi-package,netgear_rax120v2,Netgear RAX120v2))
$(eval $(call generate-ipq-wifi-package,netgear_wax218,Netgear WAX218))
$(eval $(call generate-ipq-wifi-package,netgear_wax620,Netgear WAX620))

View File

@@ -12,9 +12,9 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git
PKG_MIRROR_HASH:=48e5d555b5beb15cf936e1d2433b8e614de64a4eaf25293f0211eeb9ac79d534
PKG_SOURCE_DATE:=2023-11-28
PKG_SOURCE_VERSION:=7e6c6efd6fbcc7955801c5e2ac915a90697e1fd9
PKG_MIRROR_HASH:=fc7ea415ebb1946661c1204a16b2a2b129014d39521da5883524e5ced8c3c9b4
PKG_SOURCE_DATE:=2024-02-24
PKG_SOURCE_VERSION:=1901aba90b6841ec1a99a25224a92d2519c603fd
CMAKE_INSTALL:=1
PKG_LICENSE:=GPL-2.0

View File

@@ -12,9 +12,9 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/rpcd.git
PKG_MIRROR_HASH:=76467ff072b50190f93d071b7792ade7c717674397a2547e995a8f819a48954e
PKG_SOURCE_DATE:=2023-07-01
PKG_SOURCE_VERSION:=c07ab2f91061ad64209e9aaa1fb1b77061a1af25
PKG_MIRROR_HASH:=cf77c8aca75f893315620e2e3abf7fa02d8c8a21f54808b238973e43c66d0059
PKG_SOURCE_DATE:=2024-02-22
PKG_SOURCE_VERSION:=8ef4c2587ac0041049c67befed281a70cf240769
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
PKG_LICENSE:=ISC

View File

@@ -86,7 +86,7 @@ SVN-Revision: 35130
} while (word != stop);
return csum_fold(csum);
@@ -179,73 +183,6 @@ static inline __sum16 ip_compute_csum(co
@@ -179,74 +183,6 @@ static inline __sum16 ip_compute_csum(co
return csum_fold(csum_partial(buff, len, 0));
}
@@ -152,7 +152,8 @@ SVN-Revision: 35130
- " .set pop"
- : "=&r" (sum), "=&r" (tmp)
- : "r" (saddr), "r" (daddr),
- "0" (htonl(len)), "r" (htonl(proto)), "r" (sum));
- "0" (htonl(len)), "r" (htonl(proto)), "r" (sum)
- : "memory");
-
- return csum_fold(sum);
-}

View File

@@ -1185,7 +1185,7 @@ Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
}
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -5669,7 +5669,7 @@ static void port_event(struct usb_hub *h
@@ -5677,7 +5677,7 @@ static void port_event(struct usb_hub *h
port_dev->over_current_count++;
port_over_current_notify(port_dev);

View File

@@ -52,7 +52,7 @@ Signed-off-by: Dom Cobley <popcornmix@gmail.com>
/* L2 intc private data structure */
struct brcmstb_l2_intc_data {
struct irq_domain *domain;
@@ -286,11 +296,18 @@ static int __init brcmstb_l2_lvl_intc_of
@@ -289,11 +299,18 @@ static int __init brcmstb_l2_lvl_intc_of
return brcmstb_l2_intc_of_init(np, parent, &l2_lvl_intc_init);
}

View File

@@ -42,7 +42,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
__netif_tx_unlock_bh(netdev_get_tx_queue(priv->dev, queue));
@@ -5485,12 +5489,13 @@ static int stmmac_napi_poll_tx(struct na
@@ -5488,12 +5492,13 @@ static int stmmac_napi_poll_tx(struct na
struct stmmac_channel *ch =
container_of(napi, struct stmmac_channel, tx_napi);
struct stmmac_priv *priv = ch->priv_data;
@@ -57,7 +57,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
work_done = min(work_done, budget);
if (work_done < budget && napi_complete_done(napi, work_done)) {
@@ -5501,6 +5506,10 @@ static int stmmac_napi_poll_tx(struct na
@@ -5504,6 +5509,10 @@ static int stmmac_napi_poll_tx(struct na
spin_unlock_irqrestore(&ch->lock, flags);
}
@@ -68,7 +68,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
return work_done;
}
@@ -5509,12 +5518,13 @@ static int stmmac_napi_poll_rxtx(struct
@@ -5512,12 +5521,13 @@ static int stmmac_napi_poll_rxtx(struct
struct stmmac_channel *ch =
container_of(napi, struct stmmac_channel, rxtx_napi);
struct stmmac_priv *priv = ch->priv_data;
@@ -83,7 +83,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
tx_done = min(tx_done, budget);
rx_done = stmmac_rx_zc(priv, budget, chan);
@@ -5539,6 +5549,10 @@ static int stmmac_napi_poll_rxtx(struct
@@ -5542,6 +5552,10 @@ static int stmmac_napi_poll_rxtx(struct
spin_unlock_irqrestore(&ch->lock, flags);
}

View File

@@ -21,7 +21,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1144,8 +1144,8 @@ static struct device_node *parse_prop_ce
@@ -1146,8 +1146,8 @@ static struct device_node *parse_prop_ce
if (strcmp(prop_name, list_name))
return NULL;

View File

@@ -19,7 +19,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1249,7 +1249,7 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-c
@@ -1251,7 +1251,7 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-c
DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells")
DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells")
DEFINE_SIMPLE_PROP(extcon, "extcon", NULL)

View File

@@ -256,7 +256,7 @@ static int __rtl8366_smi_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data)
int __rtl8366_mdio_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data)
{
u32 phy_id = MDC_REALTEK_PHY_ADDR;
u32 phy_id = smi->phy_id;
struct mii_bus *mbus = smi->ext_mbus;
BUG_ON(in_interrupt());
@@ -293,7 +293,7 @@ int __rtl8366_mdio_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data)
static int __rtl8366_mdio_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data)
{
u32 phy_id = MDC_REALTEK_PHY_ADDR;
u32 phy_id = smi->phy_id;
struct mii_bus *mbus = smi->ext_mbus;
BUG_ON(in_interrupt());
@@ -1547,6 +1547,9 @@ int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi)
goto try_gpio;
}
if (of_property_read_u32(np, "phy-id", &smi->phy_id))
smi->phy_id = MDC_REALTEK_PHY_ADDR;
return 0;
try_gpio:
@@ -1586,6 +1589,7 @@ int rtl8366_smi_probe_plat(struct platform_device *pdev, struct rtl8366_smi *smi
smi->gpio_sda = pdata->gpio_sda;
smi->gpio_sck = pdata->gpio_sck;
smi->hw_reset = pdata->hw_reset;
smi->phy_id = MDC_REALTEK_PHY_ADDR;
return 0;
}

View File

@@ -63,6 +63,7 @@ struct rtl8366_smi {
u16 dbg_reg;
u8 dbg_vlan_4k_page;
#endif
u32 phy_id;
struct mii_bus *ext_mbus;
};

View File

@@ -605,6 +605,20 @@ static const struct rtl8367b_initval rtl8367r_vb_initvals_1[] = {
{0x133E, 0x000E}, {0x133F, 0x0010},
};
static const struct rtl8367b_initval rtl8367c_initvals[] = {
{0x13c2, 0x0000}, {0x0018, 0x0f00}, {0x0038, 0x0f00}, {0x0058, 0x0f00},
{0x0078, 0x0f00}, {0x0098, 0x0f00}, {0x1d15, 0x0a69}, {0x2000, 0x1340},
{0x2020, 0x1340}, {0x2040, 0x1340}, {0x2060, 0x1340}, {0x2080, 0x1340},
{0x13eb, 0x15bb}, {0x1303, 0x06d6}, {0x1304, 0x0700}, {0x13E2, 0x003F},
{0x13F9, 0x0090}, {0x121e, 0x03CA}, {0x1233, 0x0352}, {0x1237, 0x00a0},
{0x123a, 0x0030}, {0x1239, 0x0084}, {0x0301, 0x1000}, {0x1349, 0x001F},
{0x18e0, 0x4004}, {0x122b, 0x641c}, {0x1305, 0xc000}, {0x1200, 0x7fcb},
{0x0884, 0x0003}, {0x06eb, 0x0001}, {0x00cf, 0xffff}, {0x00d0, 0x0007},
{0x00ce, 0x48b0}, {0x00ce, 0x48b0}, {0x0398, 0xffff}, {0x0399, 0x0007},
{0x0300, 0x0001}, {0x03fa, 0x0007}, {0x08c8, 0x00c0}, {0x0a30, 0x020e},
{0x0800, 0x0000}, {0x0802, 0x0000}, {0x09da, 0x0017}, {0x1d32, 0x0002},
};
static int rtl8367b_write_initvals(struct rtl8366_smi *smi,
const struct rtl8367b_initval *initvals,
int count)
@@ -716,31 +730,35 @@ static int rtl8367b_write_phy_reg(struct rtl8366_smi *smi,
static int rtl8367b_init_regs(struct rtl8366_smi *smi)
{
const struct rtl8367b_initval *initvals;
u32 chip_num;
u32 chip_ver;
u32 rlvid;
int count;
int err;
REG_WR(smi, RTL8367B_RTL_MAGIC_ID_REG, RTL8367B_RTL_MAGIC_ID_VAL);
REG_RD(smi, RTL8367B_CHIP_NUMBER_REG, &chip_num);
REG_RD(smi, RTL8367B_CHIP_VER_REG, &chip_ver);
rlvid = (chip_ver >> RTL8367B_CHIP_VER_RLVID_SHIFT) &
RTL8367B_CHIP_VER_RLVID_MASK;
switch (rlvid) {
case 0:
initvals = rtl8367r_vb_initvals_0;
count = ARRAY_SIZE(rtl8367r_vb_initvals_0);
break;
case 1:
initvals = rtl8367r_vb_initvals_1;
count = ARRAY_SIZE(rtl8367r_vb_initvals_1);
break;
default:
dev_err(smi->parent, "unknow rlvid %u\n", rlvid);
return -ENODEV;
if ((chip_ver == 0x0020 || chip_ver == 0x00A0) && chip_num == 0x6367) {
initvals = rtl8367c_initvals;
count = ARRAY_SIZE(rtl8367c_initvals);
} else {
rlvid = (chip_ver >> RTL8367B_CHIP_VER_RLVID_SHIFT) &
RTL8367B_CHIP_VER_RLVID_MASK;
switch (rlvid) {
case 0:
initvals = rtl8367r_vb_initvals_0;
count = ARRAY_SIZE(rtl8367r_vb_initvals_0);
break;
case 1:
initvals = rtl8367r_vb_initvals_1;
count = ARRAY_SIZE(rtl8367r_vb_initvals_1);
break;
default:
dev_err(smi->parent, "unknow rlvid %u\n", rlvid);
return -ENODEV;
}
}
/* TODO: disable RLTP */
@@ -1509,7 +1527,7 @@ static int rtl8367b_mii_write(struct mii_bus *bus, int addr, int reg, u16 val)
static int rtl8367b_detect(struct rtl8366_smi *smi)
{
const char *chip_name;
const char *chip_name = NULL;
u32 chip_num;
u32 chip_ver;
u32 chip_mode;
@@ -1541,13 +1559,22 @@ static int rtl8367b_detect(struct rtl8366_smi *smi)
}
switch (chip_ver) {
case 0x0020:
if (chip_num == 0x6367)
chip_name = "8367RB-VB";
break;
case 0x00A0:
if (chip_num == 0x6367)
chip_name = "8367S";
break;
case 0x1000:
chip_name = "8367RB";
break;
case 0x1010:
chip_name = "8367R-VB";
break;
default:
}
if (!chip_name) {
dev_err(smi->parent,
"unknown chip num:%04x ver:%04x, mode:%04x\n",
chip_num, chip_ver, chip_mode);

View File

@@ -141,7 +141,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1781,7 +1781,9 @@ static void read_symbols(const char *mod
@@ -1785,7 +1785,9 @@ static void read_symbols(const char *mod
symname = remove_dot(info.strtab + sym->st_name);
handle_symbol(mod, &info, sym, symname);
@@ -151,7 +151,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
}
for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
@@ -1944,8 +1946,10 @@ static void add_header(struct buffer *b,
@@ -1948,8 +1950,10 @@ static void add_header(struct buffer *b,
buf_printf(b, "BUILD_SALT;\n");
buf_printf(b, "BUILD_LTO_INFO;\n");
buf_printf(b, "\n");
@@ -162,7 +162,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
buf_printf(b, "\n");
buf_printf(b, "__visible struct module __this_module\n");
buf_printf(b, "__section(\".gnu.linkonce.this_module\") = {\n");
@@ -1959,8 +1963,10 @@ static void add_header(struct buffer *b,
@@ -1963,8 +1967,10 @@ static void add_header(struct buffer *b,
buf_printf(b, "\t.arch = MODULE_ARCH_INIT,\n");
buf_printf(b, "};\n");
@@ -173,7 +173,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
buf_printf(b,
"\n"
@@ -1968,8 +1974,10 @@ static void add_header(struct buffer *b,
@@ -1972,8 +1978,10 @@ static void add_header(struct buffer *b,
"MODULE_INFO(retpoline, \"Y\");\n"
"#endif\n");
@@ -184,7 +184,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (strstarts(mod->name, "tools/testing"))
buf_printf(b, "\nMODULE_INFO(test, \"Y\");\n");
@@ -2065,11 +2073,13 @@ static void add_depends(struct buffer *b
@@ -2069,11 +2077,13 @@ static void add_depends(struct buffer *b
static void add_srcversion(struct buffer *b, struct module *mod)
{
@@ -198,7 +198,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
}
static void write_buf(struct buffer *b, const char *fname)
@@ -2155,7 +2165,9 @@ static void write_mod_c_file(struct modu
@@ -2159,7 +2169,9 @@ static void write_mod_c_file(struct modu
add_exported_symbols(&buf, mod);
add_versions(&buf, mod);
add_depends(&buf, mod);

View File

@@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* Align . to a 8 byte boundary equals to maximum function alignment. */
#define ALIGN_FUNCTION() . = ALIGN(8)
@@ -512,14 +522,14 @@
@@ -511,14 +521,14 @@
/* Kernel symbol table: Normal symbols */ \
__ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
__start___ksymtab = .; \
@@ -47,7 +47,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
__stop___ksymtab_gpl = .; \
} \
\
@@ -539,7 +549,7 @@
@@ -538,7 +548,7 @@
\
/* Kernel symbol table: strings */ \
__ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
@@ -56,7 +56,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
} \
\
/* __*init sections */ \
@@ -1048,6 +1058,8 @@
@@ -1042,6 +1052,8 @@
#define COMMON_DISCARDS \
SANITIZER_DISCARDS \
PATCHABLE_DISCARDS \

View File

@@ -10,7 +10,7 @@ Subject: [PATCH] Kconfig: add tristate for OID and ASNI string
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -2004,7 +2004,7 @@ config PADATA
@@ -2013,7 +2013,7 @@ config PADATA
bool
config ASN1

View File

@@ -19,7 +19,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1700,7 +1700,7 @@ static void device_links_purge(struct de
@@ -1702,7 +1702,7 @@ static void device_links_purge(struct de
#define FW_DEVLINK_FLAGS_RPM (FW_DEVLINK_FLAGS_ON | \
DL_FLAG_PM_RUNTIME)

View File

@@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/Makefile
+++ b/Makefile
@@ -606,7 +606,7 @@ endif
@@ -605,7 +605,7 @@ endif
# Allows the usage of unstable features in stable compilers.
export RUSTC_BOOTSTRAP := 1

View File

@@ -13,7 +13,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1482,6 +1482,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
@@ -1491,6 +1491,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
the unaligned access emulation.
see arch/parisc/kernel/unaligned.c for reference
@@ -105,7 +105,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -160,6 +160,10 @@ kallsyms()
@@ -165,6 +165,10 @@ kallsyms()
kallsymopt="${kallsymopt} --lto-clang"
fi

View File

@@ -81,7 +81,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
swim_mod-y := swim.o swim_asm.o
--- /dev/null
+++ b/drivers/block/fitblk.c
@@ -0,0 +1,635 @@
@@ -0,0 +1,636 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * uImage.FIT virtual block device driver.
@@ -454,7 +454,8 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+ bytes_left = size;
+ fit_c = fit;
+ while (bytes_left > 0) {
+ bytes_to_copy = min(bytes_left, folio_size(folio) - offset_in_folio(folio, 0));
+ bytes_to_copy = min_t(size_t, bytes_left,
+ folio_size(folio) - offset_in_folio(folio, 0));
+ memcpy(fit_c, pre_fit, bytes_to_copy);
+ fit_c += bytes_to_copy;
+ bytes_left -= bytes_to_copy;

View File

@@ -13,7 +13,7 @@ Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1827,6 +1827,15 @@ config EMBEDDED
@@ -1836,6 +1836,15 @@ config EMBEDDED
an embedded system so certain expert options are available
for configuration.

View File

@@ -63,7 +63,7 @@ Signed-off-by: Petr Štetiar <ynezz@true.cz>
reg_3v3_vmmc: regulator-3v3-vmmc {
compatible = "regulator-fixed";
enable-active-high;
@@ -260,6 +271,12 @@
@@ -262,6 +273,12 @@
>;
};

View File

@@ -124,6 +124,10 @@ ipq40xx_setup_interfaces()
ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
ucidef_set_interface "wan" device "/dev/cdc-wdm0" protocol "qmi"
;;
netgear,lbr20)
ucidef_set_interface_lan "lan1 lan2"
ucidef_set_interface "wan" device "/dev/cdc-wdm0" protocol "qmi"
;;
*)
echo "Unsupported hardware. Network interfaces not initialized"
;;

View File

@@ -0,0 +1,34 @@
#!/bin/sh /etc/rc.common
START=15
STOP=10
boot() {
case $(board_name) in
netgear,lbr20)
echo "0" > /sys/class/gpio/lte_rst/value
echo "0" > /sys/class/gpio/lte_pwrkey/value
echo "0" > /sys/class/gpio/lte_usb_boot/value
echo "0" > /sys/class/gpio/lte_pwm/value
sleep 1
echo "1" > /sys/class/gpio/lte_pwm/value
echo "1" > /sys/class/gpio/lte_pwrkey/value
echo "1" > /sys/class/gpio/lte_rst/value
sleep 1
echo "0" > /sys/class/gpio/lte_pwrkey/value
sleep 1
echo "1" > /sys/class/gpio/lte_pwrkey/value
;;
esac
}
shutdown() {
case $(board_name) in
netgear,lbr20)
echo "0" > /sys/class/gpio/lte_pwrkey/value
sleep 1
echo "1" > /sys/class/gpio/lte_pwrkey/value
sleep 10
;;
esac
}

View File

@@ -120,6 +120,7 @@ platform_do_upgrade() {
glinet,gl-ap1300 |\
luma,wrtq-329acn |\
mobipromo,cm520-79f |\
netgear,lbr20 |\
netgear,wac510 |\
p2w,r619ac-64m |\
p2w,r619ac-128m |\

View File

@@ -0,0 +1,516 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "qcom-ipq4019.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/soc/qcom,tcsr.h>
#include <dt-bindings/leds/common.h>
/ {
model = "Netgear LBR20";
compatible = "netgear,lbr20";
chosen {
bootargs-append = "ubi.mtd=ubi root=/dev/ubiblock0_0";
};
aliases {
led-boot = &led_backlight_white;
led-failsafe = &led_status_green;
led-running = &led_status_green;
led-upgrade = &led_status_red;
label-mac-device = &gmac;
};
keys {
compatible = "gpio-keys";
reset {
label = "reset";
gpios = <&tlmm 18 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
wps {
label = "wps";
gpios = <&tlmm 49 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
};
};
leds {
compatible = "gpio-leds";
led_status_green: led-status-green {
function = LED_FUNCTION_STATUS;
color = <LED_COLOR_ID_GREEN>;
gpios = <&tlmm 22 GPIO_ACTIVE_LOW>;
default-state = "keep";
};
led_status_red: led-status-red {
function = LED_FUNCTION_STATUS;
color = <LED_COLOR_ID_RED>;
gpios = <&tlmm 23 GPIO_ACTIVE_LOW>;
};
};
gpio_export {
compatible = "gpio-export";
#size-cells = <0>;
lte_rst {
gpio-export,name = "lte_rst";
gpio-export,output = <1>;
gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>;
};
lte_pwrkey {
gpio-export,name = "lte_pwrkey";
gpio-export,output = <1>;
gpios = <&tlmm 29 GPIO_ACTIVE_HIGH>;
};
lte_usb_boot {
gpio-export,name = "lte_usb_boot";
gpio-export,output = <0>;
gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>;
};
lte_pwm {
gpio-export,name = "lte_pwm";
gpio-export,output = <1>;
gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>;
};
};
soc {
tcsr@1949000 {
compatible = "qcom,tcsr";
reg = <0x1949000 0x100>;
qcom,wifi_glb_cfg = <TCSR_WIFI_GLB_CFG>;
};
tcsr@194b000 {
status = "okay";
compatible = "qcom,tcsr";
reg = <0x194b000 0x100>;
qcom,usb-hsphy-mode-select = <TCSR_USB_HSPHY_HOST_MODE>;
};
ess_tcsr@1953000 {
compatible = "qcom,tcsr";
reg = <0x1953000 0x1000>;
qcom,ess-interface-select = <TCSR_ESS_PSGMII>;
};
tcsr@1957000 {
compatible = "qcom,tcsr";
reg = <0x1957000 0x100>;
qcom,wifi_noc_memtype_m0_m2 = <TCSR_WIFI_NOC_MEMTYPE_M0_M2>;
};
};
};
&prng {
status = "okay";
};
&mdio {
status = "okay";
pinctrl-0 = <&mdio_pins>;
pinctrl-names = "default";
};
&crypto {
status = "okay";
};
&watchdog {
status = "okay";
};
&usb2_hs_phy {
status = "okay";
};
&usb2 {
status = "okay";
};
&usb3_ss_phy {
status = "okay";
};
&usb3_hs_phy {
status = "okay";
};
&usb3 {
status = "okay";
};
&blsp_dma {
status = "okay";
};
&qpic_bam {
status = "okay";
};
&tlmm {
mdio_pins: mdio-pinmux {
mux_mdio {
pins = "gpio6";
function = "mdio";
bias-pull-up;
};
mux_mdc {
pins = "gpio7";
function = "mdc";
bias-pull-up;
};
};
serial_pins: serial-pinmux {
function = "blsp_uart0";
pins = "gpio16", "gpio17";
bias-disable;
};
nand_pins: nand-pins {
pullups {
pins = "gpio52", "gpio53", "gpio58", "gpio59";
function = "qpic";
bias-pull-up;
};
pulldowns {
pins = "gpio54", "gpio55", "gpio56",
"gpio57", "gpio60", "gpio61",
"gpio62", "gpio63", "gpio64",
"gpio65", "gpio66", "gpio67",
"gpio68", "gpio69";
function = "qpic";
bias-pull-down;
};
};
};
&nand {
pinctrl-0 = <&nand_pins>;
pinctrl-names = "default";
status = "okay";
nand@0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "0:SBL1";
reg = <0x00000000 0x00100000>;
read-only;
};
partition@100000 {
label = "0:MIBIB";
reg = <0x00100000 0x00100000>;
read-only;
};
partition@200000 {
label = "0:BOOTCONFIG";
reg = <0x00200000 0x00100000>;
read-only;
};
partition@300000 {
label = "0:QSEE";
reg = <0x00300000 0x00100000>;
read-only;
};
partition@400000 {
label = "0:QSEE_1";
reg = <0x00400000 0x00100000>;
read-only;
};
partition@500000 {
label = "0:CDT";
reg = <0x00500000 0x00080000>;
read-only;
};
partition@580000 {
label = "0:CDT_1";
reg = <0x00580000 0x00080000>;
read-only;
};
partition@600000 {
label = "0:BOOTCONFIG1";
reg = <0x00600000 0x00080000>;
read-only;
};
partition@680000 {
label = "0:APPSBLENV";
reg = <0x00680000 0x00080000>;
};
partition@700000 {
label = "0:APPSBL";
reg = <0x00700000 0x00200000>;
read-only;
};
partition@900000 {
label = "0:APPSBL_1";
reg = <0x00900000 0x00200000>;
read-only;
};
partition@b00000 {
label = "0:ART";
reg = <0x00b00000 0x00080000>;
read-only;
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
precal_art_1000: precal@1000 {
reg = <0x1000 0x2f20>;
};
precal_art_5000: precal@5000 {
reg = <0x5000 0x2f20>;
};
precal_art_9000: precal@9000 {
reg = <0x9000 0x2f20>;
};
};
};
partition@b80000 {
label = "0:ART.bak";
reg = <0x00b80000 0x00080000>;
read-only;
};
partition@c00000 {
label = "config";
reg = <0x00c00000 0x00100000>;
read-only;
};
partition@d00000 {
label = "boarddata1";
reg = <0x00d00000 0x00080000>;
read-only;
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
mac_address_lan: macaddr@0 {
compatible = "mac-base";
reg = <0x0 0x6>;
#nvmem-cell-cells = <1>;
};
mac_address_wan: macaddr@6 {
compatible = "mac-base";
reg = <0x6 0x6>;
#nvmem-cell-cells = <1>;
};
mac_address_wlan_5g: macaddr@c {
compatible = "mac-base";
reg = <0xc 0x6>;
#nvmem-cell-cells = <1>;
};
mac_address_wlan_2nd5g: macaddr@12 {
compatible = "mac-base";
reg = <0x12 0x6>;
#nvmem-cell-cells = <1>;
};
};
};
partition@d80000 {
label = "boarddata2";
reg = <0x00d80000 0x00040000>;
read-only;
};
partition@dc0000 {
label = "pot";
reg = <0x00dc0000 0x00100000>;
read-only;
};
partition@ec0000 {
label = "boarddata1.bak";
reg = <0x00ec0000 0x00080000>;
read-only;
};
partition@f40000 {
label = "boarddata2.bak";
reg = <0x00f40000 0x00040000>;
read-only;
};
partition@f80000 {
label = "language";
reg = <0x00f80000 0x00300000>;
read-only;
};
partition@1280000 {
label = "cert";
reg = <0x01280000 0x00080000>;
read-only;
};
partition@1300000 {
label = "ntgrdata";
reg = <0x01300000 0x09300000>;
};
partition@a600000 {
label = "kernel";
reg = <0x0a600000 0x00700000>;
};
partition@a9c0000 {
label = "ubi";
reg = <0x0ad00000 0x05300000>;
};
};
};
};
&blsp1_i2c3 {
status = "okay";
led-controller {
#address-cells = <1>;
#size-cells = <0>;
compatible = "ti,tlc59108"; /* really is tlc59208f */
reg = <0x27>;
led_backlight_green: led-backlight-green {
function = LED_FUNCTION_BACKLIGHT;
color = <LED_COLOR_ID_GREEN>;
reg = <0x0>;
linux,default-trigger = "default-off";
};
led_backlight_red: led-backlight-red {
function = LED_FUNCTION_BACKLIGHT;
color = <LED_COLOR_ID_RED>;
reg = <0x1>;
linux,default-trigger = "default-off";
};
led_backlight_blue: led-backlight-blue {
function = LED_FUNCTION_BACKLIGHT;
color = <LED_COLOR_ID_BLUE>;
reg = <0x2>;
linux,default-trigger = "default-off";
};
led_backlight_white: led-backlight-white {
function = LED_FUNCTION_BACKLIGHT;
color = <LED_COLOR_ID_WHITE>;
reg = <0x3>;
linux,default-trigger = "default-off";
};
};
};
&blsp1_uart1 {
status = "okay";
pinctrl-0 = <&serial_pins>;
pinctrl-names = "default";
};
&cryptobam {
status = "okay";
};
&gmac {
status = "okay";
nvmem-cell-names = "mac-address";
nvmem-cells = <&mac_address_lan 0>;
};
&switch {
status = "okay";
};
&swport4 {
status = "okay";
label = "lan1";
};
&swport5 {
status = "okay";
label = "lan2";
};
&pcie0 {
status = "okay";
perst-gpios = <&tlmm 38 GPIO_ACTIVE_LOW>;
wake-gpios = <&tlmm 50 GPIO_ACTIVE_LOW>;
bridge@0,0 {
reg = <0x00000000 0 0 0 0>;
#address-cells = <3>;
#size-cells = <2>;
ranges;
wifi@1,0 {
compatible = "qcom,ath10k";
status = "okay";
reg = <0x00010000 0 0 0 0>;
ieee80211-freq-limit = <5170000 5350000>;
nvmem-cell-names = "pre-calibration", "mac-address";
nvmem-cells = <&precal_art_9000>, <&mac_address_wlan_2nd5g 0>;
qcom,ath10k-calibration-variant = "Netgear-LBR20";
};
};
};
&wifi0 {
status = "okay";
nvmem-cell-names = "pre-calibration", "mac-address";
nvmem-cells = <&precal_art_1000>, <&mac_address_lan 0>;
qcom,ath10k-calibration-variant = "Netgear-LBR20";
};
&wifi1 {
status = "okay";
ieee80211-freq-limit = <5470000 5815000>;
nvmem-cell-names = "pre-calibration", "mac-address";
nvmem-cells = <&precal_art_5000>, <&mac_address_wlan_5g 0>;
qcom,ath10k-calibration-variant = "Netgear-LBR20";
};

View File

@@ -841,6 +841,25 @@ define Device/netgear_orbi
DEVICE_PACKAGES := ath10k-firmware-qca9984-ct e2fsprogs kmod-fs-ext4 losetup
endef
define Device/netgear_lbr20
$(call Device/netgear_orbi)
DEVICE_MODEL := LBR20
NETGEAR_BOARD_ID := LBR20
NETGEAR_HW_ID := 29766182+0+256+512+2x2+2x2+2x2+1
KERNEL_SIZE := 7340032
BLOCKSIZE := 128k
PAGESIZE := 2048
UBINIZE_OPTS := -E 5
IMAGE/factory.img := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \
append-uImage-fakehdr filesystem | pad-to $$$$(KERNEL_SIZE) | \
append-ubi | netgear-dni
IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \
append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | \
append-metadata
DEVICE_PACKAGES := ipq-wifi-netgear_lbr20 ath10k-firmware-qca9888-ct kmod-usb-net-qmi-wwan kmod-usb-serial-option uqmi
endef
TARGET_DEVICES += netgear_lbr20
define Device/netgear_rbx40
$(call Device/netgear_orbi)
NETGEAR_HW_ID := 29765515+0+4096+512+2x2+2x2+2x2

View File

@@ -136,7 +136,7 @@ Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
#include <net/dst.h>
#include <net/sock.h>
#include <net/checksum.h>
@@ -4516,6 +4520,9 @@ static const u8 skb_ext_type_len[] = {
@@ -4517,6 +4521,9 @@ static const u8 skb_ext_type_len[] = {
#if IS_ENABLED(CONFIG_MCTP_FLOWS)
[SKB_EXT_MCTP] = SKB_EXT_CHUNKSIZEOF(struct mctp_flow),
#endif
@@ -146,7 +146,7 @@ Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
};
static __always_inline unsigned int skb_ext_total_length(void)
@@ -4536,6 +4543,9 @@ static __always_inline unsigned int skb_
@@ -4537,6 +4544,9 @@ static __always_inline unsigned int skb_
#if IS_ENABLED(CONFIG_MCTP_FLOWS)
skb_ext_type_len[SKB_EXT_MCTP] +
#endif

View File

@@ -4,7 +4,6 @@ CONFIG_ALIGNMENT_TRAP=y
CONFIG_ARCH_32BIT_OFF_T=y
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
# CONFIG_ARCH_IPQ40XX is not set
CONFIG_ARCH_IPQ806X=y
CONFIG_ARCH_KEEP_MEMBLOCK=y
# CONFIG_ARCH_MDM9615 is not set
CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
@@ -31,6 +30,7 @@ CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y
CONFIG_ARM_ATAG_DTB_COMPAT=y
# CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER is not set
CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE=y
CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM=y
CONFIG_ARM_CPUIDLE=y
CONFIG_ARM_CPU_SUSPEND=y
# CONFIG_ARM_CPU_TOPOLOGY is not set
@@ -49,6 +49,7 @@ CONFIG_ARM_QCOM_SPM_CPUIDLE=y
CONFIG_ARM_THUMB=y
CONFIG_ARM_UNWIND=y
CONFIG_ARM_VIRT_EXT=y
CONFIG_AUTO_ZRELADDR=y
CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_MQ_PCI=y
@@ -147,7 +148,6 @@ CONFIG_DWMAC_IPQ806X=y
# CONFIG_DWMAC_QCOM_ETHQOS is not set
CONFIG_EDAC_ATOMIC_SCRUB=y
CONFIG_EDAC_SUPPORT=y
CONFIG_ETHERNET_PACKET_MANGLE=y
CONFIG_EXCLUSIVE_SYSTEM_RAM=y
CONFIG_FIXED_PHY=y
CONFIG_FIX_EARLYCON_MEM=y
@@ -313,6 +313,7 @@ CONFIG_NO_HZ_COMMON=y
CONFIG_NO_HZ_IDLE=y
CONFIG_NR_CPUS=2
CONFIG_NVMEM=y
CONFIG_NVMEM_LAYOUTS=y
CONFIG_NVMEM_QCOM_QFPROM=y
# CONFIG_NVMEM_QCOM_SEC_QFPROM is not set
# CONFIG_NVMEM_SPMI_SDAM is not set
@@ -333,6 +334,7 @@ CONFIG_PAGE_OFFSET=0xC0000000
CONFIG_PAGE_POOL=y
CONFIG_PAGE_SIZE_LESS_THAN_256KB=y
CONFIG_PAGE_SIZE_LESS_THAN_64KB=y
CONFIG_PAHOLE_HAS_LANG_EXCLUDE=y
CONFIG_PCI=y
CONFIG_PCIEAER=y
CONFIG_PCIEPORTBUS=y
@@ -349,8 +351,8 @@ CONFIG_PCS_XPCS=y
CONFIG_PERF_USE_VMALLOC=y
CONFIG_PGTABLE_LEVELS=2
CONFIG_PHYLIB=y
CONFIG_PHYLIB_LEDS=y
CONFIG_PHYLINK=y
CONFIG_PHYS_OFFSET=0x42000000
# CONFIG_PHY_QCOM_APQ8064_SATA is not set
# CONFIG_PHY_QCOM_EDP is not set
# CONFIG_PHY_QCOM_IPQ4019_USB is not set
@@ -404,6 +406,7 @@ CONFIG_QCOM_HFPLL=y
# CONFIG_QCOM_ICC_BWMON is not set
# CONFIG_QCOM_IOMMU is not set
# CONFIG_QCOM_LLCC is not set
CONFIG_QCOM_NET_PHYLIB=y
# CONFIG_QCOM_OCMEM is not set
# CONFIG_QCOM_PDC is not set
# CONFIG_QCOM_RMTFS_MEM is not set

View File

@@ -1,60 +0,0 @@
From 9c896e9fc2ef1209e4a56d8c9fdd183847c2c814 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Tue, 18 Oct 2022 22:02:46 +0200
Subject: [PATCH] ARM: mach-qcom: fix support for ipq806x
Add a specific config flag for Qcom IPQ806x as this SoC can't use
AUTO_ZRELADDR and require the PHYS_OFFSET set to 0x42000000.
This is needed as some legacy board (or some wrongly configured
bootloader) pass the wrong memory map and doesn't exclude the first
~20MB of RAM reserved for the hardware network accellerators.
With this change we can correctly support each board and prevent any
kind of misconfiguration done by the OEM.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
arch/arm/Kconfig | 3 ++-
arch/arm/mach-qcom/Kconfig | 13 +++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -285,6 +285,7 @@ config PHYS_OFFSET
default 0x30000000 if ARCH_S3C24XX
default 0xa0000000 if ARCH_IOP32X || ARCH_PXA
default 0xc0000000 if ARCH_EP93XX || ARCH_SA1100
+ default 0x42000000 if ARCH_IPQ806X
default 0
help
Please provide the physical address corresponding to the
@@ -1704,7 +1705,7 @@ config CRASH_DUMP
config AUTO_ZRELADDR
bool "Auto calculation of the decompressed kernel image address" if !ARCH_MULTIPLATFORM
- default !(ARCH_FOOTBRIDGE || ARCH_RPC || ARCH_SA1100)
+ default !(ARCH_FOOTBRIDGE || ARCH_RPC || ARCH_SA1100 || ARCH_IPQ806X)
help
ZRELADDR is the physical address where the decompressed kernel
image will be placed. If AUTO_ZRELADDR is selected, the address
--- a/arch/arm/mach-qcom/Kconfig
+++ b/arch/arm/mach-qcom/Kconfig
@@ -46,4 +46,17 @@ config ARCH_MDM9615
bool "Enable support for MDM9615"
select CLKSRC_QCOM
+config ARCH_IPQ806X
+ bool "Enable support for IPQ806x"
+ help
+ Enable support for the Qualcomm IPQ806x.
+
+ IPQ806x require special PHYS_OFFSET and can't use AUTO_ZRELADDR.
+ The first ~20MB of RAM is reserved for the hardware network accelerators,
+ and the bootloader removes this section from the layout passed from the
+ ATAGS (when used by some bootloader doesn't even do that).
+
+ To support every system and handle legacy systems, hardcode PHYS_OFFSET and
+ disable AUTO_ZRELADDR.
+
endif

View File

@@ -1,280 +0,0 @@
From 71270226b14733a4b1f2cde58ea9265caa50b38d Mon Sep 17 00:00:00 2001
From: Adrian Panella <ianchi74@outlook.com>
Date: Thu, 9 Mar 2017 09:37:17 +0100
Subject: [PATCH 67/69] generic: Mangle bootloader's kernel arguments
The command-line arguments provided by the boot loader will be
appended to a new device tree property: bootloader-args.
If there is a property "append-rootblock" in DT under /chosen
and a root= option in bootloaders command line it will be parsed
and added to DT bootargs with the form: <append-rootblock>XX.
Only command line ATAG will be processed, the rest of the ATAGs
sent by bootloader will be ignored.
This is usefull in dual boot systems, to get the current root partition
without afecting the rest of the system.
Signed-off-by: Adrian Panella <ianchi74@outlook.com>
---
arch/arm/Kconfig | 11 +++++
arch/arm/boot/compressed/atags_to_fdt.c | 72 ++++++++++++++++++++++++++++++++-
init/main.c | 16 ++++++++
3 files changed, 98 insertions(+), 1 deletion(-)
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1588,6 +1588,17 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN
The command-line arguments provided by the boot loader will be
appended to the the device tree bootargs property.
+config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE
+ bool "Append rootblock parsing bootloader's kernel arguments"
+ help
+ The command-line arguments provided by the boot loader will be
+ appended to a new device tree property: bootloader-args.
+ If there is a property "append-rootblock" in DT under /chosen
+ and a root= option in bootloaders command line it will be parsed
+ and added to DT bootargs with the form: <append-rootblock>XX.
+ Only command line ATAG will be processed, the rest of the ATAGs
+ sent by bootloader will be ignored.
+
endchoice
config CMDLINE
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -5,6 +5,8 @@
#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND)
#define do_extend_cmdline 1
+#elif defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)
+#define do_extend_cmdline 1
#else
#define do_extend_cmdline 0
#endif
@@ -20,6 +22,7 @@ static int node_offset(void *fdt, const
return offset;
}
+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE
static int setprop(void *fdt, const char *node_path, const char *property,
void *val_array, int size)
{
@@ -28,6 +31,7 @@ static int setprop(void *fdt, const char
return offset;
return fdt_setprop(fdt, offset, property, val_array, size);
}
+#endif
static int setprop_string(void *fdt, const char *node_path,
const char *property, const char *string)
@@ -38,6 +42,7 @@ static int setprop_string(void *fdt, con
return fdt_setprop_string(fdt, offset, property, string);
}
+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE
static int setprop_cell(void *fdt, const char *node_path,
const char *property, uint32_t val)
{
@@ -46,6 +51,7 @@ static int setprop_cell(void *fdt, const
return offset;
return fdt_setprop_cell(fdt, offset, property, val);
}
+#endif
static const void *getprop(const void *fdt, const char *node_path,
const char *property, int *len)
@@ -58,6 +64,7 @@ static const void *getprop(const void *f
return fdt_getprop(fdt, offset, property, len);
}
+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE
static uint32_t get_cell_size(const void *fdt)
{
int len;
@@ -68,6 +75,81 @@ static uint32_t get_cell_size(const void
cell_size = fdt32_to_cpu(*size_len);
return cell_size;
}
+#endif
+
+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)
+/**
+ * taken from arch/x86/boot/string.c
+ * local_strstr - Find the first substring in a %NUL terminated string
+ * @s1: The string to be searched
+ * @s2: The string to search for
+ */
+static char *local_strstr(const char *s1, const char *s2)
+{
+ size_t l1, l2;
+
+ l2 = strlen(s2);
+ if (!l2)
+ return (char *)s1;
+ l1 = strlen(s1);
+ while (l1 >= l2) {
+ l1--;
+ if (!memcmp(s1, s2, l2))
+ return (char *)s1;
+ s1++;
+ }
+ return NULL;
+}
+
+static char *append_rootblock(char *dest, const char *str, int len, void *fdt)
+{
+ char *ptr, *end, *tmp;
+ const char *root="root=";
+ const char *find_rootblock;
+ int i, l;
+ const char *rootblock;
+
+ find_rootblock = getprop(fdt, "/chosen", "find-rootblock", &l);
+ if (!find_rootblock)
+ find_rootblock = root;
+
+ //ARM doesn't have __HAVE_ARCH_STRSTR, so it was copied from x86
+ ptr = local_strstr(str, find_rootblock);
+
+ if(!ptr)
+ return dest;
+
+ end = strchr(ptr, ' ');
+ end = end ? (end - 1) : (strchr(ptr, 0) - 1);
+
+ // Some boards ubi.mtd=XX,ZZZZ, so let's check for '," too.
+ tmp = strchr(ptr, ',');
+
+ if(tmp)
+ end = end < tmp ? end : tmp - 1;
+
+ //find partition number (assumes format root=/dev/mtdXX | /dev/mtdblockXX | yy:XX | ubi.mtd=XX,ZZZZ )
+ for( i = 0; end >= ptr && *end >= '0' && *end <= '9'; end--, i++);
+ ptr = end + 1;
+
+ /* if append-rootblock property is set use it to append to command line */
+ rootblock = getprop(fdt, "/chosen", "append-rootblock", &l);
+ if(rootblock != NULL) {
+ if(*dest != ' ') {
+ *dest = ' ';
+ dest++;
+ len++;
+ }
+ if (len + l + i <= COMMAND_LINE_SIZE) {
+ memcpy(dest, rootblock, l);
+ dest += l - 1;
+ memcpy(dest, ptr, i);
+ dest += i;
+ }
+ }
+ return dest;
+}
+#endif
static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
{
@@ -88,18 +170,28 @@ static void merge_fdt_bootargs(void *fdt
/* and append the ATAG_CMDLINE */
if (fdt_cmdline) {
+
+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)
+ //save original bootloader args
+ //and append ubi.mtd with root partition number to current cmdline
+ setprop_string(fdt, "/chosen", "bootloader-args", fdt_cmdline);
+ ptr = append_rootblock(ptr, fdt_cmdline, len, fdt);
+
+#else
len = strlen(fdt_cmdline);
if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) {
*ptr++ = ' ';
memcpy(ptr, fdt_cmdline, len);
ptr += len;
}
+#endif
}
*ptr = '\0';
setprop_string(fdt, "/chosen", "bootargs", cmdline);
}
+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE
static void hex_str(char *out, uint32_t value)
{
uint32_t digit;
@@ -117,6 +209,7 @@ static void hex_str(char *out, uint32_t
}
*out = '\0';
}
+#endif
/*
* Convert and fold provided ATAGs into the provided FDT.
@@ -131,9 +224,11 @@ int atags_to_fdt(void *atag_list, void *
struct tag *atag = atag_list;
/* In the case of 64 bits memory size, need to reserve 2 cells for
* address and size for each bank */
+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE
__be32 mem_reg_property[2 * 2 * NR_BANKS];
- int memcount = 0;
- int ret, memsize;
+ int memsize, memcount = 0;
+#endif
+ int ret;
/* make sure we've got an aligned pointer */
if ((u32)atag_list & 0x3)
@@ -168,7 +263,9 @@ int atags_to_fdt(void *atag_list, void *
else
setprop_string(fdt, "/chosen", "bootargs",
atag->u.cmdline.cmdline);
- } else if (atag->hdr.tag == ATAG_MEM) {
+ }
+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE
+ else if (atag->hdr.tag == ATAG_MEM) {
if (memcount >= sizeof(mem_reg_property)/4)
continue;
if (!atag->u.mem.size)
@@ -212,6 +309,10 @@ int atags_to_fdt(void *atag_list, void *
setprop(fdt, "/memory", "reg", mem_reg_property,
4 * memcount * memsize);
}
+#else
+
+ }
+#endif
return fdt_pack(fdt);
}
--- a/init/main.c
+++ b/init/main.c
@@ -112,6 +112,10 @@
#include <kunit/test.h>
+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)
+#include <linux/of.h>
+#endif
+
static int kernel_init(void *);
extern void init_IRQ(void);
@@ -995,6 +999,18 @@ asmlinkage __visible void __init __no_sa
pr_notice("Kernel command line: %s\n", saved_command_line);
/* parameters may set static keys */
jump_label_init();
+
+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)
+ //Show bootloader's original command line for reference
+ if(of_chosen) {
+ const char *prop = of_get_property(of_chosen, "bootloader-args", NULL);
+ if(prop)
+ pr_notice("Bootloader command line (ignored): %s\n", prop);
+ else
+ pr_notice("Bootloader command line not present\n");
+ }
+#endif
+
parse_early_param();
after_dashes = parse_args("Booting kernel",
static_command_line, __start___param,

View File

@@ -1,6 +1,6 @@
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1601,6 +1601,14 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGL
@@ -1589,6 +1589,14 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN
endchoice

View File

@@ -0,0 +1,75 @@
From 2f86b9b71a11f86e3d850214ab781ebb17d7260e Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Fri, 19 Jan 2024 19:48:30 +0100
Subject: [PATCH v2 1/2] ARM: decompressor: support memory start validation for
appended DTB
There is currently a problem with a very specific sets of kernel config
and AUTO_ZRELADDR.
For the most common case AUTO_ZRELADDR check the PC register and
calculate the start of the physical memory. Then fdt_check_mem_start is
called to make sure the detected value makes sense by comparing it with
what is present in DTB in the memory nodes and if additional fixup are
required with the use of linux,usable-memory-range in the chosen node to
hardcode usable memory range in case some reserved space needs to be
addressed. With the help of this function the right address is
calculated and the kernel correctly decompress and loads.
Things starts to become problematic when in the mix,
CONFIG_ARM_APPENDED_DTB is used. This is a particular kernel config is
used when legacy systems doesn't support passing a DTB directly and a
DTB is appended at the end of the image.
In such case, fdt_check_mem_start is skipped in AUTO_ZRELADDR iteration
as the appended DTB can be augumented later with ATAGS passed from the
bootloader (if CONFIG_ARM_ATAG_DTB_COMPAT is enabled).
The main problem and what this patch address is the fact that
fdt_check_mem_start is never called later when the appended DTB is
augumented, hence any fixup and validation is not done making AUTO_ZRELADDR
detection inconsistent and most of the time wrong.
Add support in head.S for this by checking if AUTO_ZRELADDR is enabled
and calling fdt_check_mem_start with the appended DTB and the augumented
values permitting legacy device to provide info in DTB instead of
disabling AUTO_ZRELADDR and hardcoding the physical address offsets.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
arch/arm/boot/compressed/head.S | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -443,6 +443,28 @@ restart: adr r0, LC1
add r6, r6, r5
add r10, r10, r5
add sp, sp, r5
+
+#ifdef CONFIG_AUTO_ZRELADDR
+ /*
+ * Validate calculated start of physical memory with appended DTB.
+ * In the first iteration for physical memory start calculation,
+ * we skipped validating it as it could have been augumented by
+ * ATAGS stored at an offset from the same start of physical memory.
+ *
+ * We now have parsed them and augumented the appended DTB if asked
+ * so we can finally validate the start of physical memory.
+ *
+ * This is needed to apply additional fixup with
+ * linux,usable-memory-range or to make sure AUTO_ZRELADDR detected
+ * the correct value.
+ */
+ sub r0, r4, #TEXT_OFFSET @ revert to base address
+ mov r1, r8 @ use appended DTB
+ bl fdt_check_mem_start
+
+ /* Determine final kernel image address. */
+ add r4, r0, #TEXT_OFFSET
+#endif
dtb_check_done:
#endif

View File

@@ -0,0 +1,54 @@
From 781d7cd4c3364e9d38fa12a342c5ad4c7e33a5ba Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Fri, 19 Jan 2024 20:33:10 +0100
Subject: [PATCH v2 2/2] ARM: decompressor: add option to ignore MEM ATAGs
Some bootloaders can pass broken MEM ATAGs that provide hardcoded
information about mounted RAM size and physical location.
Example booloader provide RAM of size 1.7Gb but actual mounted RAM
size is 512Mb causing kernel panic.
Add option CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM to ignore these ATAG
and not augument appended DTB memory node.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
arch/arm/Kconfig | 12 ++++++++++++
arch/arm/boot/compressed/atags_to_fdt.c | 4 ++++
2 files changed, 16 insertions(+)
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1570,6 +1570,18 @@ config ARM_ATAG_DTB_COMPAT
bootloaders, this option allows zImage to extract the information
from the ATAG list and store it at run time into the appended DTB.
+config ARM_ATAG_DTB_COMPAT_IGNORE_MEM
+ bool "Ignore MEM ATAG information from bootloader"
+ depends on ARM_ATAG_DTB_COMPAT
+ help
+ Some bootloaders can pass broken MEM ATAGs that provide hardcoded
+ information about mounted RAM size and physical location.
+ Example booloader provide RAM of size 1.7Gb but actual mounted RAM
+ size is 512Mb causing kernel panic.
+
+ Enable this option if MEM ATAGs should be ignored and the memory
+ node in the appended DTB should NOT be augumented.
+
choice
prompt "Kernel command line type" if ARM_ATAG_DTB_COMPAT
default ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -169,6 +169,10 @@ int atags_to_fdt(void *atag_list, void *
setprop_string(fdt, "/chosen", "bootargs",
atag->u.cmdline.cmdline);
} else if (atag->hdr.tag == ATAG_MEM) {
+ /* Bootloader MEM ATAG are broken and should be ignored */
+ if (IS_ENABLED(CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM))
+ continue;
+
if (memcount >= sizeof(mem_reg_property)/4)
continue;
if (!atag->u.mem.size)

View File

@@ -0,0 +1,197 @@
From 13bb6d8dd9138927950a520a288401db82871dc9 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sun, 21 Jan 2024 23:36:57 +0100
Subject: [PATCH] ARM: decompressor: support for ATAGs rootblock parsing
The command-line arguments provided by the boot loader will be
appended to a new device tree property: bootloader-args.
If there is a property "append-rootblock" in DT under /chosen
and a root= option in bootloaders command line it will be parsed
and added to DT bootargs with the form: <append-rootblock>XX.
This is usefull in dual boot systems, to get the current root partition
without afecting the rest of the system.
Signed-off-by: Adrian Panella <ianchi74@outlook.com>
[ reworked to a cleaner patch ]
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
arch/arm/Kconfig | 10 +++
arch/arm/boot/compressed/atags_to_fdt.c | 102 ++++++++++++++++++++++--
init/main.c | 12 +++
3 files changed, 117 insertions(+), 7 deletions(-)
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1599,6 +1599,16 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN
The command-line arguments provided by the boot loader will be
appended to the the device tree bootargs property.
+config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE
+ bool "Append rootblock parsing bootloader's kernel arguments"
+ help
+ The command-line arguments provided by the boot loader will be
+ appended to a new device tree property: bootloader-args.
+
+ If there is a property "append-rootblock" in DT under /chosen
+ and a root= option in bootloaders command line it will be parsed
+ and added to DT bootargs with the form: <append-rootblock>XX.
+
endchoice
config CMDLINE_OVERRIDE
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -3,7 +3,8 @@
#include <asm/setup.h>
#include <libfdt.h>
-#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND)
+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND) || \
+ defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)
#define do_extend_cmdline 1
#else
#define do_extend_cmdline 0
@@ -69,6 +70,83 @@ static uint32_t get_cell_size(const void
return cell_size;
}
+/**
+ * taken from arch/x86/boot/string.c
+ * local_strstr - Find the first substring in a %NUL terminated string
+ * @s1: The string to be searched
+ * @s2: The string to search for
+ */
+static char *local_strstr(const char *s1, const char *s2)
+{
+ size_t l1, l2;
+
+ l2 = strlen(s2);
+ if (!l2)
+ return (char *)s1;
+ l1 = strlen(s1);
+ while (l1 >= l2) {
+ l1--;
+ if (!memcmp(s1, s2, l2))
+ return (char *)s1;
+ s1++;
+ }
+ return NULL;
+}
+
+static char *append_rootblock(char *dest, const char *str, int len, void *fdt)
+{
+ char *ptr, *end, *tmp;
+ const char *root="root=";
+ const char *find_rootblock;
+ int i, l;
+ const char *rootblock;
+
+ find_rootblock = getprop(fdt, "/chosen", "find-rootblock", &l);
+ if (!find_rootblock)
+ find_rootblock = root;
+
+ /* ARM doesn't have __HAVE_ARCH_STRSTR, so it was copied from x86 */
+ ptr = local_strstr(str, find_rootblock);
+ if (!ptr)
+ return dest;
+
+ end = strchr(ptr, ' ');
+ end = end ? (end - 1) : (strchr(ptr, 0) - 1);
+
+ /* Some boards ubi.mtd=XX,ZZZZ, so let's check for '," too. */
+ tmp = strchr(ptr, ',');
+ if (tmp)
+ end = end < tmp ? end : tmp - 1;
+
+ /*
+ * find partition number
+ * (assumes format root=/dev/mtdXX | /dev/mtdblockXX | yy:XX | ubi.mtd=XX,ZZZZ )
+ */
+ for (i = 0; end >= ptr && *end >= '0' && *end <= '9'; end--, i++);
+
+ ptr = end + 1;
+
+ /* if append-rootblock property is set use it to append to command line */
+ rootblock = getprop(fdt, "/chosen", "append-rootblock", &l);
+ if (rootblock != NULL) {
+ if (*dest != ' ') {
+ *dest = ' ';
+ dest++;
+ len++;
+ }
+
+ if (len + l + i <= COMMAND_LINE_SIZE) {
+ memcpy(dest, rootblock, l);
+ dest += l - 1;
+
+ memcpy(dest, ptr, i);
+ dest += i;
+ }
+ }
+
+ return dest;
+}
+
static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
{
char cmdline[COMMAND_LINE_SIZE];
@@ -86,13 +164,23 @@ static void merge_fdt_bootargs(void *fdt
ptr += len - 1;
}
- /* and append the ATAG_CMDLINE */
if (fdt_cmdline) {
- len = strlen(fdt_cmdline);
- if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) {
- *ptr++ = ' ';
- memcpy(ptr, fdt_cmdline, len);
- ptr += len;
+ if (IS_ENABLED(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)) {
+ /*
+ * save original bootloader args
+ * and append ubi.mtd with root partition number
+ * to current cmdline
+ */
+ setprop_string(fdt, "/chosen", "bootloader-args", fdt_cmdline);
+ ptr = append_rootblock(ptr, fdt_cmdline, len, fdt);
+ } else {
+ /* and append the ATAG_CMDLINE */
+ len = strlen(fdt_cmdline);
+ if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) {
+ *ptr++ = ' ';
+ memcpy(ptr, fdt_cmdline, len);
+ ptr += len;
+ }
}
}
*ptr = '\0';
--- a/init/main.c
+++ b/init/main.c
@@ -28,6 +28,7 @@
#include <linux/initrd.h>
#include <linux/memblock.h>
#include <linux/acpi.h>
+#include <linux/of.h>
#include <linux/bootconfig.h>
#include <linux/console.h>
#include <linux/nmi.h>
@@ -995,6 +996,17 @@ asmlinkage __visible void __init __no_sa
pr_notice("Kernel command line: %s\n", saved_command_line);
/* parameters may set static keys */
jump_label_init();
+
+ /* Show bootloader's original command line for reference */
+ if (IS_ENABLED(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) && of_chosen) {
+ const char *prop = of_get_property(of_chosen, "bootloader-args", NULL);
+
+ if(prop)
+ pr_notice("Bootloader command line (ignored): %s\n", prop);
+ else
+ pr_notice("Bootloader command line not present\n");
+ }
+
parse_early_param();
after_dashes = parse_args("Booting kernel",
static_command_line, __start___param,

View File

@@ -9,4 +9,26 @@
/ {
model = "UniElec U7623-02 eMMC";
compatible = "unielec,u7623-02", "mediatek,mt7623";
chosen {
stdout-path = "serial0:115200n8";
bootargs = "earlycon=uart8250,mmio32,0x11004000 root=/dev/fit0";
rootdisk = <&emmc_rootdisk>;
};
};
&mmc0 {
card@0 {
compatible = "mmc-card";
reg = <0>;
block {
compatible = "block-device";
partitions {
emmc_rootdisk: block-partition-env {
partno = <3>;
};
};
};
};
};

View File

@@ -116,6 +116,8 @@ endif
gzip
ARTIFACTS := u-boot.bin preloader.bin sdcard.img.gz
SUPPORTED_DEVICES := bananapi,bpi-r2
DEVICE_COMPAT_VERSION := 1.1
DEVICE_COMPAT_MESSAGE := Bootloader update required for switch to fitblk
endef
TARGET_DEVICES += bananapi_bpi-r2

View File

@@ -0,0 +1,14 @@
. /lib/functions.sh
. /lib/functions/uci-defaults.sh
board_config_update
case "$(board_name)" in
bananapi,bpi-r2)
ucidef_set_compat_version "1.1"
;;
esac
board_config_flush
exit 0

View File

@@ -0,0 +1,10 @@
. /lib/functions.sh
case "$(board_name)" in
bananapi,bpi-r2)
uci set system.@system[0].compat_version="1.1"
uci commit system
;;
esac
exit 0

View File

@@ -1,5 +1,20 @@
REQUIRE_IMAGE_METADATA=1
platform_get_bootdev() {
local rootdisk="$(cat /sys/firmware/devicetree/base/chosen/rootdisk)"
local handle bootdev
for handle in /sys/class/block/*/of_node/phandle /sys/class/block/*/device/of_node/phandle; do
[ ! -e "$handle" ] && continue
if [ "$rootdisk" = "$(cat $handle)" ]; then
bootdev="${handle%/of_node/phandle}"
bootdev="${bootdev%/device}"
bootdev="${bootdev#/sys/class/block/}"
echo "$bootdev"
break
fi
done
}
# Legacy full system upgrade including preloader for MediaTek SoCs on eMMC or SD
legacy_mtk_mmc_full_upgrade() {
local diskdev partdev diff oldrecovery
@@ -83,10 +98,10 @@ platform_do_upgrade() {
case "$board" in
bananapi,bpi-r2|\
unielec,u7623-02)
export_bootdevice
export_partdevice fitpart 3
[ "$fitpart" ] || return 1
EMMC_KERN_DEV="/dev/$fitpart"
[ -e /dev/fit0 ] && fitblk /dev/fit0
[ -e /dev/fitrw ] && fitblk /dev/fitrw
bootdev="$(platform_get_bootdev)"
EMMC_KERN_DEV="/dev/$bootdev"
emmc_do_upgrade "$1"
;;
unielec,u7623-02-emmc-512m)

View File

@@ -215,7 +215,7 @@ CONFIG_FB_SYS_COPYAREA=y
CONFIG_FB_SYS_FILLRECT=y
CONFIG_FB_SYS_FOPS=y
CONFIG_FB_SYS_IMAGEBLIT=y
CONFIG_FIT_PARTITION=y
# CONFIG_FIT_PARTITION is not set
CONFIG_FIXED_PHY=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_FONT_8x16=y
@@ -564,6 +564,7 @@ CONFIG_TREE_SRCU=y
# CONFIG_UACCE is not set
CONFIG_UBIFS_FS=y
CONFIG_UEVENT_HELPER_PATH=""
CONFIG_UIMAGE_FIT_BLK=y
CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h"
CONFIG_UNINLINE_SPIN_UNLOCK=y
CONFIG_UNWINDER_ARM=y

View File

@@ -0,0 +1,55 @@
--- a/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
+++ b/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
@@ -26,7 +26,9 @@
chosen {
stdout-path = "serial2:115200n8";
- bootargs = "earlycon=uart8250,mmio32,0x11004000 console=ttyS2,115200n8 console=tty1";
+ bootargs = "root=/dev/fit0 earlycon=uart8250,mmio32,0x11004000 console=ttyS2,115200n8 console=tty1";
+ rootdisk-emmc = <&emmc_rootdisk>;
+ rootdisk-sd = <&sd_rootdisk>;
};
connector {
@@ -315,6 +317,20 @@
vmmc-supply = <&reg_3p3v>;
vqmmc-supply = <&reg_1p8v>;
non-removable;
+
+ card@0 {
+ compatible = "mmc-card";
+ reg = <0>;
+
+ block {
+ compatible = "block-device";
+ partitions {
+ emmc_rootdisk: block-partition-fit {
+ partno = <3>;
+ };
+ };
+ };
+ };
};
&mmc1 {
@@ -328,6 +344,20 @@
cd-gpios = <&pio 261 GPIO_ACTIVE_LOW>;
vmmc-supply = <&reg_3p3v>;
vqmmc-supply = <&reg_3p3v>;
+
+ card@0 {
+ compatible = "mmc-card";
+ reg = <0>;
+
+ block {
+ compatible = "block-device";
+ partitions {
+ sd_rootdisk: block-partition-fit {
+ partno = <3>;
+ };
+ };
+ };
+ };
};
&mt6323_leds {

View File

@@ -0,0 +1,129 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include <dt-bindings/leds/common.h>
#include "mt7620a_tplink_archer.dtsi"
/ {
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 = &ethernet;
};
leds {
compatible = "gpio-leds";
led_power: led-0 {
function = LED_FUNCTION_POWER;
color = <LED_COLOR_ID_GREEN>;
gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
};
led-1 {
function = LED_FUNCTION_WLAN;
color = <LED_COLOR_ID_GREEN>;
function-enumerator = <2>;
gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
linux,default-trigger = "phy1tpt";
};
led-2 {
function = LED_FUNCTION_WLAN;
color = <LED_COLOR_ID_GREEN>;
function-enumerator = <5>;
gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
linux,default-trigger = "phy0tpt";
};
led-3 {
function = LED_FUNCTION_WAN;
color = <LED_COLOR_ID_GREEN>;
gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
};
led-4 {
function = LED_FUNCTION_WAN;
color = <LED_COLOR_ID_ORANGE>;
gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
};
led-5 {
function = LED_FUNCTION_LAN;
color = <LED_COLOR_ID_GREEN>;
gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
};
led-6 {
function = LED_FUNCTION_USB;
color = <LED_COLOR_ID_GREEN>;
gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
trigger-sources = <&ohci_port1>, <&ehci_port1>;
linux,default-trigger = "usbport";
};
led-7 {
function = LED_FUNCTION_WPS;
color = <LED_COLOR_ID_GREEN>;
gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
};
};
rtl8367s {
compatible = "realtek,rtl8367b";
cpu_port = <7>;
realtek,extif2 = <1 0 1 1 1 1 1 1 2>;
mii-bus = <&mdio0>;
phy-id = <29>;
};
};
&spi0 {
flash@0 {
#address-cells = <1>;
#size-cells = <1>;
};
};
&state_default {
gpio {
groups = "i2c", "uartf", "ephy", "rgmii2";
function = "gpio";
};
};
&ethernet {
pinctrl-names = "default";
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>;
};
};
&wmac {
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;
nvmem-cells = <&eeprom_radio_0>, <&macaddr_rom_f100 0>;
nvmem-cell-names = "eeprom", "mac-address";
};
&wifi {
nvmem-cells = <&eeprom_radio_8000>, <&macaddr_rom_f100 2>;
nvmem-cell-names = "eeprom", "mac-address";
};

View File

@@ -118,7 +118,7 @@
&ethernet {
pinctrl-names = "default";
nvmem-cells = <&macaddr_rom_f100>;
nvmem-cells = <&macaddr_rom_f100 0>;
nvmem-cell-names = "mac-address";
mediatek,portmap = "wllll";

View File

@@ -1225,6 +1225,23 @@ define Device/tplink_archer-c2-v1
endef
TARGET_DEVICES += tplink_archer-c2-v1
define Device/tplink_archer-c5-v4
$(Device/tplink-v2)
SOC := mt7620a
IMAGE_SIZE := 7808k
TPLINK_FLASHLAYOUT := 8Mmtk
TPLINK_HWID := 0x04da857c
TPLINK_HWREV := 0x0c000600
TPLINK_HWREVADD := 0x04000000
IMAGES += tftp-recovery.bin
IMAGE/tftp-recovery.bin := pad-extra 128k | $$(IMAGE/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

View File

@@ -229,6 +229,10 @@ 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"
;;
tplink,archer-c50-v1)
ucidef_set_led_switch "lan" "lan" "green:lan" "switch0" "0x1e"
ucidef_set_led_switch "wan" "wan" "green:wan" "switch0" "0x01"

View File

@@ -236,6 +236,12 @@ 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 "switch0"
ucidef_add_switch_attr "switch0" "enable" "0"
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"
@@ -408,6 +414,7 @@ ramips_setup_macs()
tplink,archer-c2-v1|\
tplink,archer-c20-v1|\
tplink,archer-c20i|\
tplink,archer-c5-v4|\
tplink,archer-c50-v1|\
tplink,archer-mr200)
wan_mac=$(macaddr_add "$(mtd_get_mac_binary rom 0xf100)" 1)

View File

@@ -59,7 +59,7 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
depends on ARCH_RENESAS || COMPILE_TEST
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -97,6 +97,7 @@ obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pc
@@ -95,6 +95,7 @@ obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pc
obj-$(CONFIG_I2C_PNX) += i2c-pnx.o
obj-$(CONFIG_I2C_PXA) += i2c-pxa.o
obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o