uboot-mediatek: update to 2021.04-rc3 with MediaTek's patches

MediaTek published their current U-Boot patchset on github:
https://github.com/mtk-openwrt/u-boot/commits/mtksoc

Import the platform patches from there (`00-mtk-*.patch`), arrange,
them nicely, drop no longer needed local patches and rebase on top of
U-Boot 2021.04-rc3.

Tested and works well on Linksys E8450 (snand-1ddr) as well as
Bananapi BPi-R64 (sdmmc-2ddr, emmc-2ddr).

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
Daniel Golle 2021-02-20 13:04:38 +00:00
parent e2cffbb805
commit 9dfc2b3ca4
No known key found for this signature in database
GPG Key ID: 5A8F39C31C3217CA
39 changed files with 5711 additions and 8847 deletions

View File

@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_VERSION:=2020.10
PKG_HASH:=0d481bbdc05c0ee74908ec2f56a6daa53166cc6a78a0e4fac2ac5d025770a622
PKG_VERSION:=2021.04-rc3
PKG_HASH:=7c418e07f6065c8761eb2df890bb524d7109864325d8850ddb0c93eb345734f9
PKG_BUILD_DEPENDS:=arm-trusted-firmware-tools/host
include $(INCLUDE_DIR)/u-boot.mk

View File

@ -0,0 +1,69 @@
From 5efb7855a9d33ac897d6e2a7117e4e3d35d433a5 Mon Sep 17 00:00:00 2001
From: Daniel Golle <daniel@makrotopia.org>
Date: Thu, 11 Mar 2021 10:28:53 +0000
Subject: [PATCH 01/21] Revert "clk: Add debugging for return values"
This reverts commit 5c5992cb90cf9ca4d51e38d9a95a13c293904df5.
---
drivers/clk/clk-uclass.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -84,7 +84,7 @@ static int clk_get_by_index_tail(int ret
if (ret) {
debug("%s: uclass_get_device_by_of_offset failed: err=%d\n",
__func__, ret);
- return log_msg_ret("get", ret);
+ return ret;
}
clk->dev = dev_clk;
@@ -97,15 +97,14 @@ static int clk_get_by_index_tail(int ret
ret = clk_of_xlate_default(clk, args);
if (ret) {
debug("of_xlate() failed: %d\n", ret);
- return log_msg_ret("xlate", ret);
+ return ret;
}
return clk_request(dev_clk, clk);
err:
debug("%s: Node '%s', property '%s', failed to request CLK index %d: %d\n",
__func__, ofnode_get_name(node), list_name, index, ret);
-
- return log_msg_ret("prop", ret);
+ return ret;
}
static int clk_get_by_indexed_prop(struct udevice *dev, const char *prop_name,
@@ -124,7 +123,7 @@ static int clk_get_by_indexed_prop(struc
if (ret) {
debug("%s: fdtdec_parse_phandle_with_args failed: err=%d\n",
__func__, ret);
- return log_ret(ret);
+ return ret;
}
@@ -472,7 +471,6 @@ int clk_free(struct clk *clk)
ulong clk_get_rate(struct clk *clk)
{
const struct clk_ops *ops;
- int ret;
debug("%s(clk=%p)\n", __func__, clk);
if (!clk_valid(clk))
@@ -482,11 +480,7 @@ ulong clk_get_rate(struct clk *clk)
if (!ops->get_rate)
return -ENOSYS;
- ret = ops->get_rate(clk);
- if (ret)
- return log_ret(ret);
-
- return 0;
+ return ops->get_rate(clk);
}
struct clk *clk_get_parent(struct clk *clk)

View File

@ -0,0 +1,21 @@
From 04815ef5a49a9996acacfcb5e18924569f5e1bf5 Mon Sep 17 00:00:00 2001
From: Matthias Brugger <mbrugger@suse.com>
Date: Tue, 16 Feb 2021 20:54:08 +0100
Subject: [PATCH 02/21] configs: RPi2: Disable EFI Grub workaround
The EFI Grub workaround isn't needed with Grub version 2.04 or higher.
This version was published over a year ago, so disable the workaround
to reduce boot time.
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
configs/rpi_2_defconfig | 1 +
1 file changed, 1 insertion(+)
--- a/configs/rpi_2_defconfig
+++ b/configs/rpi_2_defconfig
@@ -42,3 +42,4 @@ CONFIG_SYS_WHITE_ON_BLACK=y
CONFIG_CONSOLE_SCROLL_LINES=10
CONFIG_PHYS_TO_BUS=y
CONFIG_OF_LIBFDT_OVERLAY=y
+# CONFIG_EFI_GRUB_ARM32_WORKAROUND is not set

View File

@ -0,0 +1,25 @@
From 6f18e581a7e98db3675b4c111701263647b20781 Mon Sep 17 00:00:00 2001
From: Sam Shih <sam.shih@mediatek.com>
Date: Thu, 17 Dec 2020 19:29:56 +0800
Subject: [PATCH 03/21] pinctrl: mediatek: fix wrong assignment in
mtk_get_pin_name
This is a bug fix for mtk pinctrl common part. Appearently pins should be
used instead of grps in mtk_get_pin_name().
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -219,7 +219,7 @@ static const char *mtk_get_pin_name(stru
{
struct mtk_pinctrl_priv *priv = dev_get_priv(dev);
- if (!priv->soc->grps[selector].name)
+ if (!priv->soc->pins[selector].name)
return mtk_pinctrl_dummy_name;
return priv->soc->pins[selector].name;

View File

@ -0,0 +1,43 @@
From ca73da39ff0c9f599f75d7ccac0196030aa946b9 Mon Sep 17 00:00:00 2001
From: Sam Shih <sam.shih@mediatek.com>
Date: Thu, 17 Dec 2020 19:32:48 +0800
Subject: [PATCH 04/21] pinctrl: mediatek: add get_pin_muxing ops for mediatek
pinctrl
This patch add get_pin_muxing support for mediatek pinctrl drivers
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -232,6 +232,19 @@ static int mtk_get_pins_count(struct ude
return priv->soc->npins;
}
+static int mtk_get_pin_muxing(struct udevice *dev,
+ unsigned int selector,
+ char *buf, int size)
+{
+ int val, err;
+ err = mtk_hw_get_value(dev, selector, PINCTRL_PIN_REG_MODE, &val);
+ if (err)
+ return err;
+
+ snprintf(buf, size, "Aux Func.%d", val);
+ return 0;
+}
+
static const char *mtk_get_group_name(struct udevice *dev,
unsigned int selector)
{
@@ -512,6 +525,7 @@ static int mtk_pinconf_group_set(struct
const struct pinctrl_ops mtk_pinctrl_ops = {
.get_pins_count = mtk_get_pins_count,
.get_pin_name = mtk_get_pin_name,
+ .get_pin_muxing = mtk_get_pin_muxing,
.get_groups_count = mtk_get_groups_count,
.get_group_name = mtk_get_group_name,
.get_functions_count = mtk_get_functions_count,

View File

@ -0,0 +1,58 @@
From d3fbbef13853a695cdea75a980a3d6bd150a68c1 Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Mon, 11 Jan 2021 10:17:15 +0800
Subject: [PATCH 05/21] pinctrl: mediatek: do not probe gpio driver if not
enabled
The mtk pinctrl driver is a combination driver with support for both
pinctrl and gpio. When this driver is used in SPL, gpio support may not be
enabled, and this will result in a compilation error.
To fix this, macros are added to make sure gpio related code will only be
compiled when gpio support is enabled.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -540,6 +540,8 @@ const struct pinctrl_ops mtk_pinctrl_ops
.set_state = pinctrl_generic_set_state,
};
+#if CONFIG_IS_ENABLED(DM_GPIO) || \
+ (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_GPIO_SUPPORT))
static int mtk_gpio_get(struct udevice *dev, unsigned int off)
{
int val, err;
@@ -647,12 +649,13 @@ static int mtk_gpiochip_register(struct
return 0;
}
+#endif
int mtk_pinctrl_common_probe(struct udevice *dev,
struct mtk_pinctrl_soc *soc)
{
struct mtk_pinctrl_priv *priv = dev_get_priv(dev);
- int ret;
+ int ret = 0;
priv->base = dev_read_addr_ptr(dev);
if (!priv->base)
@@ -660,9 +663,10 @@ int mtk_pinctrl_common_probe(struct udev
priv->soc = soc;
+#if CONFIG_IS_ENABLED(DM_GPIO) || \
+ (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_GPIO_SUPPORT))
ret = mtk_gpiochip_register(dev);
- if (ret)
- return ret;
+#endif
- return 0;
+ return ret;
}

View File

@ -0,0 +1,50 @@
From 1c6d07abf7fc79bf3950dc9ac56e3b566c334d3d Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Wed, 13 Jan 2021 16:29:23 +0800
Subject: [PATCH 06/21] pinctrl: mt7629: add jtag function and pin group
The EPHY LEDs of mt7629 can be used as JTAG. This patch adds the jtag pin
group to the pinctrl driver.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
drivers/pinctrl/mediatek/pinctrl-mt7629.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/drivers/pinctrl/mediatek/pinctrl-mt7629.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7629.c
@@ -201,6 +201,10 @@ static int mt7629_wf2g_led_funcs[] = { 1
static int mt7629_wf5g_led_pins[] = { 18, };
static int mt7629_wf5g_led_funcs[] = { 1, };
+/* LED for EPHY used as JTAG */
+static int mt7629_ephy_leds_jtag_pins[] = { 12, 13, 14, 15, 16, };
+static int mt7629_ephy_leds_jtag_funcs[] = { 7, 7, 7, 7, 7, };
+
/* Watchdog */
static int mt7629_watchdog_pins[] = { 11, };
static int mt7629_watchdog_funcs[] = { 1, };
@@ -297,6 +301,7 @@ static const struct mtk_group_desc mt762
PINCTRL_PIN_GROUP("ephy_led2", mt7629_ephy_led2),
PINCTRL_PIN_GROUP("ephy_led3", mt7629_ephy_led3),
PINCTRL_PIN_GROUP("ephy_led4", mt7629_ephy_led4),
+ PINCTRL_PIN_GROUP("ephy_leds_jtag", mt7629_ephy_leds_jtag),
PINCTRL_PIN_GROUP("wf2g_led", mt7629_wf2g_led),
PINCTRL_PIN_GROUP("wf5g_led", mt7629_wf5g_led),
PINCTRL_PIN_GROUP("watchdog", mt7629_watchdog),
@@ -364,6 +369,7 @@ static const char *const mt7629_uart_gro
static const char *const mt7629_wdt_groups[] = { "watchdog", };
static const char *const mt7629_wifi_groups[] = { "wf0_5g", "wf0_2g", };
static const char *const mt7629_flash_groups[] = { "snfi", "spi_nor" };
+static const char *const mt7629_jtag_groups[] = { "ephy_leds_jtag" };
static const struct mtk_function_desc mt7629_functions[] = {
{"eth", mt7629_ethernet_groups, ARRAY_SIZE(mt7629_ethernet_groups)},
@@ -376,6 +382,7 @@ static const struct mtk_function_desc mt
{"watchdog", mt7629_wdt_groups, ARRAY_SIZE(mt7629_wdt_groups)},
{"wifi", mt7629_wifi_groups, ARRAY_SIZE(mt7629_wifi_groups)},
{"flash", mt7629_flash_groups, ARRAY_SIZE(mt7629_flash_groups)},
+ {"jtag", mt7629_jtag_groups, ARRAY_SIZE(mt7629_jtag_groups)},
};
static struct mtk_pinctrl_soc mt7629_data = {

View File

@ -0,0 +1,25 @@
From c47a5b927787a463eff8f67339d91e60fe0381c4 Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Tue, 2 Mar 2021 15:02:50 +0800
Subject: [PATCH 07/21] configs: mt7622: use ARMv8 Generic Timer instead of
mtk_timer
It's better to use the generic timer which is correctly initialized by
the ATF. The generic timer has higher resolution than the mtk_timer.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
configs/mt7622_rfb_defconfig | 2 --
1 file changed, 2 deletions(-)
--- a/configs/mt7622_rfb_defconfig
+++ b/configs/mt7622_rfb_defconfig
@@ -51,8 +51,6 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_MTK_SNOR=y
CONFIG_SYSRESET_WATCHDOG=y
-CONFIG_TIMER=y
-CONFIG_MTK_TIMER=y
CONFIG_WDT_MTK=y
CONFIG_LZO=y
CONFIG_HEXDUMP=y

View File

@ -0,0 +1,50 @@
From 4bee3f9e285007ccf77ca9916fff3d93fc4d8a80 Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Tue, 2 Mar 2021 15:43:27 +0800
Subject: [PATCH 08/21] dts: mt7629: enable JTAG pins by default
The EPHY LEDs belongs to the built-in FE switch of MT7629, which is barely
used. These LED pins on reference boards are used as JTAG socket. So it's
a good idea to change the default state to JTAG, and this will make it
convenience for debugging.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
arch/arm/dts/mt7629-rfb.dts | 10 ++++++++++
arch/arm/dts/mt7629.dtsi | 6 ++++++
2 files changed, 16 insertions(+)
--- a/arch/arm/dts/mt7629-rfb.dts
+++ b/arch/arm/dts/mt7629-rfb.dts
@@ -36,6 +36,16 @@
};
&pinctrl {
+ state_default: pinmux_conf {
+ u-boot,dm-pre-reloc;
+
+ mux {
+ function = "jtag";
+ groups = "ephy_leds_jtag";
+ u-boot,dm-pre-reloc;
+ };
+ };
+
snfi_pins: snfi-pins {
mux {
function = "flash";
--- a/arch/arm/dts/mt7629.dtsi
+++ b/arch/arm/dts/mt7629.dtsi
@@ -152,6 +152,12 @@
compatible = "mediatek,mt7629-pinctrl";
reg = <0x10217000 0x8000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&state_default>;
+
+ state_default: pinmux_conf {
+ };
+
gpio: gpio-controller {
gpio-controller;
#gpio-cells = <2>;

View File

@ -0,0 +1,44 @@
From f3f320af7078a8c5647d870a31c1d3695dacd7cf Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Tue, 2 Mar 2021 15:47:45 +0800
Subject: [PATCH 09/21] board: mediatek: add more network configurations
Make the network configurations uniform for mediatek boards
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
include/configs/mt7622.h | 3 ++-
include/configs/mt7623.h | 1 +
include/configs/mt7629.h | 1 +
3 files changed, 4 insertions(+), 1 deletion(-)
--- a/include/configs/mt7622.h
+++ b/include/configs/mt7622.h
@@ -36,6 +36,7 @@
/* Ethernet */
#define CONFIG_IPADDR 192.168.1.1
-#define CONFIG_SERVERIP 192.168.1.3
+#define CONFIG_SERVERIP 192.168.1.2
+#define CONFIG_NETMASK 255.255.255.0
#endif
--- a/include/configs/mt7623.h
+++ b/include/configs/mt7623.h
@@ -54,6 +54,7 @@
/* Ethernet */
#define CONFIG_IPADDR 192.168.1.1
#define CONFIG_SERVERIP 192.168.1.2
+#define CONFIG_NETMASK 255.255.255.0
#ifdef CONFIG_DISTRO_DEFAULTS
--- a/include/configs/mt7629.h
+++ b/include/configs/mt7629.h
@@ -52,5 +52,6 @@
/* Ethernet */
#define CONFIG_IPADDR 192.168.1.1
#define CONFIG_SERVERIP 192.168.1.2
+#define CONFIG_NETMASK 255.255.255.0
#endif

View File

@ -0,0 +1,38 @@
From ed880b7572e1135e3bd8382d4670a375f7d9c91b Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Tue, 2 Mar 2021 15:56:17 +0800
Subject: [PATCH 10/21] mmc: mtk-sd: increase the minimum bus frequency
With a 48MHz input clock, the lowest bus frequency can be as low as
48000000 / (4 * 4095) = 2930Hz. Such an extremely low frequency will cause
the mmc framework take seconds to finish the initialization.
Limiting the minimum bus frequency to a slightly higher value can solve the
issue without any side effects.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
drivers/mmc/mtk-sd.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/drivers/mmc/mtk-sd.c
+++ b/drivers/mmc/mtk-sd.c
@@ -232,6 +232,8 @@
#define SCLK_CYCLES_SHIFT 20
+#define MIN_BUS_CLK 260000
+
#define CMD_INTS_MASK \
(MSDC_INT_CMDRDY | MSDC_INT_RSPCRCERR | MSDC_INT_CMDTMO)
@@ -1639,6 +1641,9 @@ static int msdc_drv_probe(struct udevice
else
cfg->f_min = host->src_clk_freq / (4 * 4095);
+ if (cfg->f_min < MIN_BUS_CLK)
+ cfg->f_min = MIN_BUS_CLK;
+
cfg->f_max = host->src_clk_freq;
cfg->b_max = 1024;

View File

@ -0,0 +1,141 @@
From d8bde59186dafdea5bbe8d29d3a6ae7cac98e9d0 Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Mon, 25 Jan 2021 11:19:08 +0800
Subject: [PATCH 11/21] serial: serial-mtk: rewrite the setbrg function
Currently the setbrg logic of serial-mtk is messy, and should be rewritten.
Also an option is added to make it possible to use highspeed=3 mode for all
bauds.
The new logic is:
1. If baud clock > 12MHz
a) If baud <= 115200, highspeed=0 mode will be used (ns16550 compatible)
b) If baud <= 576000, highspeed=2 mode will be used
c) any baud > 576000, highspeed=3 mode will be used
2. If baud clock <= 12MHz
Always uses highspeed=3 mode
a) If baud <= 115200, calculates the divisor using DIV_ROUND_CLOSEST
b) any baud > 115200, the same as 1. c)
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
drivers/serial/serial_mtk.c | 74 +++++++++++++++++--------------------
1 file changed, 33 insertions(+), 41 deletions(-)
--- a/drivers/serial/serial_mtk.c
+++ b/drivers/serial/serial_mtk.c
@@ -73,74 +73,64 @@ struct mtk_serial_regs {
struct mtk_serial_priv {
struct mtk_serial_regs __iomem *regs;
u32 clock;
+ bool force_highspeed;
};
static void _mtk_serial_setbrg(struct mtk_serial_priv *priv, int baud)
{
- bool support_clk12m_baud115200;
- u32 quot, samplecount, realbaud;
+ u32 quot, realbaud, samplecount = 1;
- if ((baud <= 115200) && (priv->clock == 12000000))
- support_clk12m_baud115200 = true;
- else
- support_clk12m_baud115200 = false;
+ /* Special case for low baud clock */
+ if ((baud <= 115200) && (priv->clock == 12000000)) {
+ writel(3, &priv->regs->highspeed);
+
+ quot = DIV_ROUND_CLOSEST(priv->clock, 256 * baud);
+ if (quot == 0)
+ quot = 1;
+
+ samplecount = DIV_ROUND_CLOSEST(priv->clock, quot * baud);
+
+ realbaud = priv->clock / samplecount / quot;
+ if ((realbaud > BAUD_ALLOW_MAX(baud)) ||
+ (realbaud < BAUD_ALLOW_MIX(baud))) {
+ pr_info("baud %d can't be handled\n", baud);
+ }
+
+ goto set_baud;
+ }
+
+ if (priv->force_highspeed)
+ goto use_hs3;
if (baud <= 115200) {
writel(0, &priv->regs->highspeed);
quot = DIV_ROUND_CLOSEST(priv->clock, 16 * baud);
-
- if (support_clk12m_baud115200) {
- writel(3, &priv->regs->highspeed);
- quot = DIV_ROUND_CLOSEST(priv->clock, 256 * baud);
- if (quot == 0)
- quot = 1;
-
- samplecount = DIV_ROUND_CLOSEST(priv->clock,
- quot * baud);
- if (samplecount != 0) {
- realbaud = priv->clock / samplecount / quot;
- if ((realbaud > BAUD_ALLOW_MAX(baud)) ||
- (realbaud < BAUD_ALLOW_MIX(baud))) {
- pr_info("baud %d can't be handled\n",
- baud);
- }
- } else {
- pr_info("samplecount is 0\n");
- }
- }
} else if (baud <= 576000) {
writel(2, &priv->regs->highspeed);
/* Set to next lower baudrate supported */
if ((baud == 500000) || (baud == 576000))
baud = 460800;
+
quot = DIV_ROUND_UP(priv->clock, 4 * baud);
} else {
+use_hs3:
writel(3, &priv->regs->highspeed);
+
quot = DIV_ROUND_UP(priv->clock, 256 * baud);
+ samplecount = DIV_ROUND_CLOSEST(priv->clock, quot * baud);
}
+set_baud:
/* set divisor */
writel(UART_LCR_WLS_8 | UART_LCR_DLAB, &priv->regs->lcr);
writel(quot & 0xff, &priv->regs->dll);
writel((quot >> 8) & 0xff, &priv->regs->dlm);
writel(UART_LCR_WLS_8, &priv->regs->lcr);
- if (baud > 460800) {
- u32 tmp;
-
- tmp = DIV_ROUND_CLOSEST(priv->clock, quot * baud);
- writel(tmp - 1, &priv->regs->sample_count);
- writel((tmp - 2) >> 1, &priv->regs->sample_point);
- } else {
- writel(0, &priv->regs->sample_count);
- writel(0xff, &priv->regs->sample_point);
- }
-
- if (support_clk12m_baud115200) {
- writel(samplecount - 1, &priv->regs->sample_count);
- writel((samplecount - 2) >> 1, &priv->regs->sample_point);
- }
+ /* set highspeed mode sample count & point */
+ writel(samplecount - 1, &priv->regs->sample_count);
+ writel((samplecount - 2) >> 1, &priv->regs->sample_point);
}
static int _mtk_serial_putc(struct mtk_serial_priv *priv, const char ch)
@@ -248,6 +238,8 @@ static int mtk_serial_of_to_plat(struct
return -EINVAL;
}
+ priv->force_highspeed = dev_read_bool(dev, "mediatek,force-highspeed");
+
return 0;
}

View File

@ -0,0 +1,94 @@
From a80ef99cb308904b82662deb66c5ed7a6ff59928 Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Wed, 3 Mar 2021 11:13:36 +0800
Subject: [PATCH 12/21] board: mt7629: enable compression of u-boot to reduce
the size of final image
This patch makes use of the decompression mechanism implemented for mt7628
previously to reduce the total image size. Binman will be also removed.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
Makefile | 3 +++
arch/arm/dts/mt7629-rfb-u-boot.dtsi | 18 ------------------
arch/arm/mach-mediatek/Kconfig | 1 -
configs/mt7629_rfb_defconfig | 6 ++++++
4 files changed, 9 insertions(+), 19 deletions(-)
--- a/Makefile
+++ b/Makefile
@@ -1728,6 +1728,9 @@ u-boot-elf.lds: arch/u-boot-elf.lds prep
ifeq ($(CONFIG_SPL),y)
spl/u-boot-spl-mtk.bin: spl/u-boot-spl
+
+u-boot-mtk.bin: u-boot-with-spl.bin
+ $(call if_changed,copy)
else
MKIMAGEFLAGS_u-boot-mtk.bin = -T mtk_image \
-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \
--- a/arch/arm/dts/mt7629-rfb-u-boot.dtsi
+++ b/arch/arm/dts/mt7629-rfb-u-boot.dtsi
@@ -5,24 +5,6 @@
* Author: Weijie Gao <weijie.gao@mediatek.com>
*/
-#include <config.h>
-/ {
- binman {
- filename = "u-boot-mtk.bin";
- pad-byte = <0xff>;
-
-#ifdef CONFIG_SPL
- blob {
- filename = "spl/u-boot-spl-mtk.bin";
- size = <CONFIG_SPL_PAD_TO>;
- };
-
- u-boot-img {
- };
-#endif
- };
-};
-
&infracfg {
u-boot,dm-pre-reloc;
};
--- a/arch/arm/mach-mediatek/Kconfig
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -36,7 +36,6 @@ config TARGET_MT7629
bool "MediaTek MT7629 SoC"
select CPU_V7A
select SPL
- select BINMAN
help
The MediaTek MT7629 is a ARM-based SoC with a dual-core Cortex-A7
including DDR3, crypto engine, 3x3 11n/ac Wi-Fi, Gigabit Ethernet,
--- a/configs/mt7629_rfb_defconfig
+++ b/configs/mt7629_rfb_defconfig
@@ -10,7 +10,11 @@ CONFIG_SPL_TEXT_BASE=0x201000
CONFIG_TARGET_MT7629=y
CONFIG_SPL_SERIAL_SUPPORT=y
CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_SPL_STACK_R_ADDR=0x40800000
+CONFIG_SPL_PAYLOAD="u-boot-lzma.img"
+CONFIG_BUILD_TARGET="u-boot-mtk.bin"
CONFIG_DEFAULT_DEVICE_TREE="mt7629-rfb"
+CONFIG_SPL_IMAGE="spl/u-boot-spl-mtk.bin"
CONFIG_FIT=y
CONFIG_FIT_VERBOSE=y
CONFIG_BOOTDELAY=3
@@ -18,6 +22,7 @@ CONFIG_DEFAULT_FDT_FILE="mt7629-rfb"
CONFIG_SYS_CONSOLE_IS_IN_ENV=y
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_STACK_R=y
CONFIG_SPL_NOR_SUPPORT=y
CONFIG_SPL_WATCHDOG_SUPPORT=y
CONFIG_HUSH_PARSER=y
@@ -87,4 +92,5 @@ CONFIG_USB_STORAGE=y
CONFIG_USB_KEYBOARD=y
CONFIG_WDT_MTK=y
CONFIG_LZMA=y
+CONFIG_SPL_LZMA=y
# CONFIG_EFI_LOADER is not set

View File

@ -0,0 +1,26 @@
From acd49b1549ff52286aace5e841420aa750325f8b Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Wed, 3 Mar 2021 10:53:14 +0800
Subject: [PATCH 13/21] configs: mt7622: enable debug uart for
mt7622_rfb_defconfig
Enable debug uart for mt7622_rfb_defconfig
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
configs/mt7622_rfb_defconfig | 3 +++
1 file changed, 3 insertions(+)
--- a/configs/mt7622_rfb_defconfig
+++ b/configs/mt7622_rfb_defconfig
@@ -4,7 +4,10 @@ CONFIG_ARCH_MEDIATEK=y
CONFIG_SYS_TEXT_BASE=0x41e00000
CONFIG_SYS_MALLOC_F_LEN=0x4000
CONFIG_NR_DRAM_BANKS=1
+CONFIG_DEBUG_UART_BASE=0x11002000
+CONFIG_DEBUG_UART_CLOCK=25000000
CONFIG_DEFAULT_DEVICE_TREE="mt7622-rfb"
+CONFIG_DEBUG_UART=y
CONFIG_FIT=y
CONFIG_DEFAULT_FDT_FILE="mt7622-rfb"
CONFIG_LOGLEVEL=7

View File

@ -0,0 +1,174 @@
From 0c857d4c9cd9dc8e8ebba18cf9e9b10513ccb35d Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Wed, 3 Mar 2021 08:57:29 +0800
Subject: [PATCH 15/21] mtd: mtk-snand: add support for SPL
Add support to initialize SPI-NAND in SPL.
Add implementation for SPL NAND loader.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
drivers/mtd/mtk-snand/Kconfig | 6 ++
drivers/mtd/mtk-snand/Makefile | 4 +
drivers/mtd/mtk-snand/mtk-snand-spl.c | 132 ++++++++++++++++++++++++++
3 files changed, 142 insertions(+)
create mode 100644 drivers/mtd/mtk-snand/mtk-snand-spl.c
--- a/drivers/mtd/mtk-snand/Kconfig
+++ b/drivers/mtd/mtk-snand/Kconfig
@@ -19,3 +19,9 @@ config MTK_SPI_NAND_MTD
help
This option enables access to SPI-NAND flashes through the
MTD interface of MediaTek SPI NAND Flash Controller
+
+config SPL_MTK_SPI_NAND
+ tristate "SPL support for MediaTek SPI NAND flash controller"
+ depends on MTK_SPI_NAND
+ help
+ This option enables access to SPI-NAND flashes in the SPL stage
--- a/drivers/mtd/mtk-snand/Makefile
+++ b/drivers/mtd/mtk-snand/Makefile
@@ -8,4 +8,8 @@
obj-y += mtk-snand.o mtk-snand-ecc.o mtk-snand-ids.o mtk-snand-os.o
obj-$(CONFIG_MTK_SPI_NAND_MTD) += mtk-snand-mtd.o
+ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SPL_MTK_SPI_NAND) += mtk-snand-spl.o
+endif
+
ccflags-y += -DPRIVATE_MTK_SNAND_HEADER
--- /dev/null
+++ b/drivers/mtd/mtk-snand/mtk-snand-spl.c
@@ -0,0 +1,132 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Weijie Gao <weijie.gao@mediatek.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/uclass.h>
+#include <malloc.h>
+#include <mapmem.h>
+#include <mtd.h>
+#include <watchdog.h>
+
+#include "mtk-snand.h"
+
+static struct mtk_snand *snf;
+static struct mtk_snand_chip_info cinfo;
+static u32 oobavail;
+
+static u8 *page_cache;
+
+int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
+{
+ u32 sizeremain = size, chunksize, leading;
+ uint32_t off = offs, writesize_mask = cinfo.pagesize - 1;
+ uint8_t *ptr = dst;
+ int ret;
+
+ if (!snf)
+ return -ENODEV;
+
+ while (sizeremain) {
+ WATCHDOG_RESET();
+
+ leading = off & writesize_mask;
+ chunksize = cinfo.pagesize - leading;
+ if (chunksize > sizeremain)
+ chunksize = sizeremain;
+
+ if (chunksize == cinfo.pagesize) {
+ ret = mtk_snand_read_page(snf, off - leading, ptr,
+ NULL, false);
+ if (ret)
+ break;
+ } else {
+ ret = mtk_snand_read_page(snf, off - leading,
+ page_cache, NULL, false);
+ if (ret)
+ break;
+
+ memcpy(ptr, page_cache + leading, chunksize);
+ }
+
+ off += chunksize;
+ ptr += chunksize;
+ sizeremain -= chunksize;
+ }
+
+ return ret;
+}
+
+void nand_init(void)
+{
+ struct mtk_snand_platdata mtk_snand_pdata = {};
+ struct udevice *dev;
+ fdt_addr_t base;
+ int ret;
+
+ ret = uclass_get_device_by_driver(UCLASS_MTD, DM_DRIVER_GET(mtk_snand),
+ &dev);
+ if (ret) {
+ printf("mtk-snand-spl: Device instance not found!\n");
+ return;
+ }
+
+ base = dev_read_addr_name(dev, "nfi");
+ if (base == FDT_ADDR_T_NONE) {
+ printf("mtk-snand-spl: NFI base not set\n");
+ return;
+ }
+ mtk_snand_pdata.nfi_base = map_sysmem(base, 0);
+
+ base = dev_read_addr_name(dev, "ecc");
+ if (base == FDT_ADDR_T_NONE) {
+ printf("mtk-snand-spl: ECC base not set\n");
+ return;
+ }
+ mtk_snand_pdata.ecc_base = map_sysmem(base, 0);
+
+ mtk_snand_pdata.soc = dev_get_driver_data(dev);
+ mtk_snand_pdata.quad_spi = dev_read_bool(dev, "quad-spi");
+
+ ret = mtk_snand_init(NULL, &mtk_snand_pdata, &snf);
+ if (ret) {
+ printf("mtk-snand-spl: failed to initialize SPI-NAND\n");
+ return;
+ }
+
+ mtk_snand_get_chip_info(snf, &cinfo);
+
+ oobavail = cinfo.num_sectors * (cinfo.fdm_size - 1);
+
+ printf("SPI-NAND: %s (%uMB)\n", cinfo.model,
+ (u32)(cinfo.chipsize >> 20));
+
+ page_cache = malloc(cinfo.pagesize + cinfo.sparesize);
+ if (!page_cache) {
+ mtk_snand_cleanup(snf);
+ printf("mtk-snand-spl: failed to allocate page cache\n");
+ }
+}
+
+void nand_deselect(void)
+{
+
+}
+
+static const struct udevice_id mtk_snand_ids[] = {
+ { .compatible = "mediatek,mt7622-snand", .data = SNAND_SOC_MT7622 },
+ { .compatible = "mediatek,mt7629-snand", .data = SNAND_SOC_MT7629 },
+ { .compatible = "mediatek,mt7986-snand", .data = SNAND_SOC_MT7986 },
+ { /* sentinel */ },
+};
+
+U_BOOT_DRIVER(mtk_snand) = {
+ .name = "mtk-snand",
+ .id = UCLASS_MTD,
+ .of_match = mtk_snand_ids,
+ .flags = DM_FLAG_PRE_RELOC,
+};

View File

@ -0,0 +1,409 @@
From eaa9bc597e0bf8bcd1486ea49c8c7c070a37a8aa Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Wed, 3 Mar 2021 10:11:32 +0800
Subject: [PATCH 16/21] env: add support for generic MTD device
Add an env driver for generic MTD device.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
cmd/nvedit.c | 3 +-
env/Kconfig | 37 +++++-
env/Makefile | 1 +
env/env.c | 3 +
env/mtd.c | 256 +++++++++++++++++++++++++++++++++++++++++
include/env_internal.h | 1 +
tools/Makefile | 1 +
7 files changed, 299 insertions(+), 3 deletions(-)
create mode 100644 env/mtd.c
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -50,6 +50,7 @@ DECLARE_GLOBAL_DATA_PTR;
defined(CONFIG_ENV_IS_IN_MMC) || \
defined(CONFIG_ENV_IS_IN_FAT) || \
defined(CONFIG_ENV_IS_IN_EXT4) || \
+ defined(CONFIG_ENV_IS_IN_MTD) || \
defined(CONFIG_ENV_IS_IN_NAND) || \
defined(CONFIG_ENV_IS_IN_NVRAM) || \
defined(CONFIG_ENV_IS_IN_ONENAND) || \
@@ -64,7 +65,7 @@ DECLARE_GLOBAL_DATA_PTR;
#if !defined(ENV_IS_IN_DEVICE) && \
!defined(CONFIG_ENV_IS_NOWHERE)
-# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|\
+# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|MMC|FAT|EXT4|MTD|\
NAND|NVRAM|ONENAND|SATA|SPI_FLASH|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
#endif
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -19,7 +19,7 @@ config ENV_IS_NOWHERE
!ENV_IS_IN_MMC && !ENV_IS_IN_NAND && \
!ENV_IS_IN_NVRAM && !ENV_IS_IN_ONENAND && \
!ENV_IS_IN_REMOTE && !ENV_IS_IN_SPI_FLASH && \
- !ENV_IS_IN_UBI
+ !ENV_IS_IN_UBI && !ENV_IS_IN_MTD
help
Define this if you don't want to or can't have an environment stored
on a storage medium. In this case the environment will still exist
@@ -207,6 +207,27 @@ config ENV_IS_IN_MMC
This value is also in units of bytes, but must also be aligned to
an MMC sector boundary.
+config ENV_IS_IN_MTD
+ bool "Environment in a MTD device"
+ depends on !CHAIN_OF_TRUST
+ depends on MTD
+ help
+ Define this if you have a MTD device which you want to use for
+ the environment.
+
+ - CONFIG_ENV_MTD_NAME:
+ - CONFIG_ENV_OFFSET:
+ - CONFIG_ENV_SIZE:
+
+ These three #defines specify the MTD device where the environment
+ is stored, offset and size of the environment area within the MTD
+ device. CONFIG_ENV_OFFSET must be aligned to an erase block boundary.
+
+ - CONFIG_ENV_SIZE_REDUND:
+
+ This #define specify the maximum size allowed for read/write/erase
+ with skipped bad blocks starting from ENV_OFFSET.
+
config ENV_IS_IN_NAND
bool "Environment in a NAND device"
depends on !CHAIN_OF_TRUST
@@ -513,10 +534,16 @@ config ENV_ADDR_REDUND
Offset from the start of the device (or partition) of the redundant
environment location.
+config ENV_MTD_NAME
+ string "Name of the MTD device storing the environment"
+ depends on ENV_IS_IN_MTD
+ help
+ Name of the MTD device that stores the environment
+
config ENV_OFFSET
hex "Environment offset"
depends on ENV_IS_IN_EEPROM || ENV_IS_IN_MMC || ENV_IS_IN_NAND || \
- ENV_IS_IN_SPI_FLASH
+ ENV_IS_IN_SPI_FLASH || ENV_IS_IN_MTD
default 0x3f8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC
default 0x140000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH
default 0x88000 if ARCH_SUNXI
@@ -560,6 +587,12 @@ config ENV_SECT_SIZE
help
Size of the sector containing the environment.
+config ENV_SIZE_REDUND
+ hex "Redundant environment size"
+ depends on ENV_IS_IN_MTD
+ help
+ The maximum size allowed for read/write/erase with skipped bad blocks.
+
config ENV_UBI_PART
string "UBI partition name"
depends on ENV_IS_IN_UBI
--- a/env/Makefile
+++ b/env/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_$(SPL_TPL_)ENV_IS_NOWHERE)
obj-$(CONFIG_$(SPL_TPL_)ENV_IS_IN_MMC) += mmc.o
obj-$(CONFIG_$(SPL_TPL_)ENV_IS_IN_FAT) += fat.o
obj-$(CONFIG_$(SPL_TPL_)ENV_IS_IN_EXT4) += ext4.o
+obj-$(CONFIG_$(SPL_TPL_)ENV_IS_IN_MTD) += mtd.o
obj-$(CONFIG_$(SPL_TPL_)ENV_IS_IN_NAND) += nand.o
obj-$(CONFIG_$(SPL_TPL_)ENV_IS_IN_SPI_FLASH) += sf.o
obj-$(CONFIG_$(SPL_TPL_)ENV_IS_IN_FLASH) += flash.o
--- a/env/env.c
+++ b/env/env.c
@@ -69,6 +69,9 @@ static enum env_location env_locations[]
#ifdef CONFIG_ENV_IS_IN_MMC
ENVL_MMC,
#endif
+#ifdef CONFIG_ENV_IS_IN_MTD
+ ENVL_MTD,
+#endif
#ifdef CONFIG_ENV_IS_IN_NAND
ENVL_NAND,
#endif
--- /dev/null
+++ b/env/mtd.c
@@ -0,0 +1,256 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2021 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Weijie Gao <weijie.gao@mediatek.com>
+ */
+
+#include <command.h>
+#include <env.h>
+#include <env_internal.h>
+#include <errno.h>
+#include <linux/kernel.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
+#include <linux/mtd/mtd.h>
+#include <malloc.h>
+#include <memalign.h>
+#include <mtd.h>
+#include <search.h>
+
+#if CONFIG_ENV_SIZE_REDUND < CONFIG_ENV_SIZE
+#undef CONFIG_ENV_SIZE_REDUND
+#define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE
+#endif
+
+#if defined(ENV_IS_EMBEDDED)
+env_t *env_ptr = &environment;
+#else /* ! ENV_IS_EMBEDDED */
+env_t *env_ptr;
+#endif /* ENV_IS_EMBEDDED */
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int env_mtd_init(void)
+{
+#if defined(ENV_IS_EMBEDDED)
+ int crc1_ok = 0, crc2_ok = 0;
+ env_t *tmp_env1;
+
+ tmp_env1 = env_ptr;
+ crc1_ok = crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc;
+
+ if (!crc1_ok && !crc2_ok) {
+ gd->env_addr = 0;
+ gd->env_valid = ENV_INVALID;
+
+ return 0;
+ } else if (crc1_ok && !crc2_ok) {
+ gd->env_valid = ENV_VALID;
+ }
+
+ if (gd->env_valid == ENV_VALID)
+ env_ptr = tmp_env1;
+
+ gd->env_addr = (ulong)env_ptr->data;
+
+#else /* ENV_IS_EMBEDDED */
+ gd->env_addr = (ulong)&default_environment[0];
+ gd->env_valid = ENV_VALID;
+#endif /* ENV_IS_EMBEDDED */
+
+ return 0;
+}
+
+static struct mtd_info *env_mtd_get_dev(void)
+{
+ struct mtd_info *mtd;
+
+ mtd_probe_devices();
+
+ mtd = get_mtd_device_nm(CONFIG_ENV_MTD_NAME);
+ if (IS_ERR(mtd) || !mtd) {
+ printf("MTD device '%s' not found\n", CONFIG_ENV_MTD_NAME);
+ return NULL;
+ }
+
+ return mtd;
+}
+
+static inline bool mtd_addr_is_block_aligned(struct mtd_info *mtd, u64 addr)
+{
+ return (addr & mtd->erasesize_mask) == 0;
+}
+
+static int mtd_io_skip_bad(struct mtd_info *mtd, bool read, loff_t offset,
+ size_t length, size_t redund, u8 *buffer)
+{
+ struct mtd_oob_ops io_op = {};
+ size_t remaining = length;
+ loff_t off, end;
+ int ret;
+
+ io_op.mode = MTD_OPS_PLACE_OOB;
+ io_op.len = mtd->writesize;
+ io_op.datbuf = (void *)buffer;
+
+ /* Search for the first good block after the given offset */
+ off = offset;
+ end = (off + redund) | (mtd->erasesize - 1);
+ while (mtd_block_isbad(mtd, off) && off < end)
+ off += mtd->erasesize;
+
+ /* Reached end position */
+ if (off >= end)
+ return -EIO;
+
+ /* Loop over the pages to do the actual read/write */
+ while (remaining) {
+ /* Skip the block if it is bad */
+ if (mtd_addr_is_block_aligned(mtd, off) &&
+ mtd_block_isbad(mtd, off)) {
+ off += mtd->erasesize;
+ continue;
+ }
+
+ if (read)
+ ret = mtd_read_oob(mtd, off, &io_op);
+ else
+ ret = mtd_write_oob(mtd, off, &io_op);
+
+ if (ret) {
+ printf("Failure while %s at offset 0x%llx\n",
+ read ? "reading" : "writing", off);
+ break;
+ }
+
+ off += io_op.retlen;
+ remaining -= io_op.retlen;
+ io_op.datbuf += io_op.retlen;
+ io_op.oobbuf += io_op.oobretlen;
+
+ /* Reached end position */
+ if (off >= end)
+ return -EIO;
+ }
+
+ return 0;
+}
+
+#ifdef CONFIG_CMD_SAVEENV
+static int mtd_erase_skip_bad(struct mtd_info *mtd, loff_t offset,
+ size_t length, size_t redund)
+{
+ struct erase_info erase_op = {};
+ loff_t end = (offset + redund) | (mtd->erasesize - 1);
+ int ret;
+
+ erase_op.mtd = mtd;
+ erase_op.addr = offset;
+ erase_op.len = length;
+
+ while (erase_op.len) {
+ ret = mtd_erase(mtd, &erase_op);
+
+ /* Abort if its not a bad block error */
+ if (ret != -EIO)
+ return ret;
+
+ printf("Skipping bad block at 0x%08llx\n", erase_op.fail_addr);
+
+ /* Skip bad block and continue behind it */
+ erase_op.len -= erase_op.fail_addr - erase_op.addr;
+ erase_op.len -= mtd->erasesize;
+ erase_op.addr = erase_op.fail_addr + mtd->erasesize;
+
+ /* Reached end position */
+ if (erase_op.addr >= end)
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int env_mtd_save(void)
+{
+ ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
+ struct mtd_info *mtd;
+ int ret = 0;
+
+ ret = env_export(env_new);
+ if (ret)
+ return ret;
+
+ mtd = env_mtd_get_dev();
+ if (!mtd)
+ return 1;
+
+ printf("Erasing on MTD device '%s'... ", mtd->name);
+
+ ret = mtd_erase_skip_bad(mtd, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
+ CONFIG_ENV_SIZE_REDUND);
+
+ puts(ret ? "FAILED\n" : "OK\n");
+
+ if (ret) {
+ put_mtd_device(mtd);
+ return 1;
+ }
+
+ printf("Writing to MTD device '%s'... ", mtd->name);
+
+ ret = mtd_io_skip_bad(mtd, false, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
+ CONFIG_ENV_SIZE_REDUND, (u8 *)env_new);
+
+ puts(ret ? "FAILED\n" : "OK\n");
+
+ put_mtd_device(mtd);
+
+ return !!ret;
+}
+#endif /* CONFIG_CMD_SAVEENV */
+
+static int readenv(size_t offset, u_char *buf)
+{
+ struct mtd_info *mtd;
+ int ret;
+
+ mtd = env_mtd_get_dev();
+ if (!mtd)
+ return 1;
+
+ ret = mtd_io_skip_bad(mtd, true, offset, CONFIG_ENV_SIZE,
+ CONFIG_ENV_SIZE_REDUND, buf);
+
+ put_mtd_device(mtd);
+
+ return !!ret;
+}
+
+static int env_mtd_load(void)
+{
+#if !defined(ENV_IS_EMBEDDED)
+ ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
+ int ret;
+
+ ret = readenv(CONFIG_ENV_OFFSET, (u_char *)buf);
+ if (ret) {
+ env_set_default("readenv() failed", 0);
+ return -EIO;
+ }
+
+ return env_import(buf, 1, H_EXTERNAL);
+#endif /* ! ENV_IS_EMBEDDED */
+
+ return 0;
+}
+
+U_BOOT_ENV_LOCATION(mtd) = {
+ .location = ENVL_MTD,
+ ENV_NAME("MTD")
+ .load = env_mtd_load,
+#if defined(CONFIG_CMD_SAVEENV)
+ .save = env_save_ptr(env_mtd_save),
+#endif
+ .init = env_mtd_init,
+};
--- a/include/env_internal.h
+++ b/include/env_internal.h
@@ -131,6 +131,7 @@ enum env_location {
ENVL_FAT,
ENVL_FLASH,
ENVL_MMC,
+ ENVL_MTD,
ENVL_NAND,
ENVL_NVRAM,
ENVL_ONENAND,
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -22,6 +22,7 @@ ENVCRC-$(CONFIG_ENV_IS_EMBEDDED) = y
ENVCRC-$(CONFIG_ENV_IS_IN_EEPROM) = y
ENVCRC-$(CONFIG_ENV_IS_IN_FLASH) = y
ENVCRC-$(CONFIG_ENV_IS_IN_ONENAND) = y
+ENVCRC-$(CONFIG_ENV_IS_IN_MTD) = y
ENVCRC-$(CONFIG_ENV_IS_IN_NAND) = y
ENVCRC-$(CONFIG_ENV_IS_IN_NVRAM) = y
ENVCRC-$(CONFIG_ENV_IS_IN_SPI_FLASH) = y

View File

@ -0,0 +1,266 @@
From 47b386259625061b376f538055a4f3fbd0ab7fef Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Wed, 3 Mar 2021 10:48:53 +0800
Subject: [PATCH 17/21] board: mt7629: add support for booting from SPI-NAND
Add support for mt7629 to boot from SPI-NAND.
Add a new defconfig for mt7629+spi-nand configuration.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
arch/arm/dts/mt7629-rfb-u-boot.dtsi | 8 ++
arch/arm/dts/mt7629-rfb.dts | 10 +++
arch/arm/dts/mt7629.dtsi | 16 ++++
board/mediatek/mt7629/Kconfig | 35 ++++++++-
configs/mt7629_nand_rfb_defconfig | 111 ++++++++++++++++++++++++++++
include/configs/mt7629.h | 7 ++
6 files changed, 186 insertions(+), 1 deletion(-)
create mode 100644 configs/mt7629_nand_rfb_defconfig
--- a/arch/arm/dts/mt7629-rfb-u-boot.dtsi
+++ b/arch/arm/dts/mt7629-rfb-u-boot.dtsi
@@ -40,3 +40,11 @@
&snfi {
u-boot,dm-pre-reloc;
};
+
+&pinctrl {
+ u-boot,dm-pre-reloc;
+};
+
+&snand {
+ u-boot,dm-pre-reloc;
+};
--- a/arch/arm/dts/mt7629-rfb.dts
+++ b/arch/arm/dts/mt7629-rfb.dts
@@ -47,9 +47,12 @@
};
snfi_pins: snfi-pins {
+ u-boot,dm-pre-reloc;
+
mux {
function = "flash";
groups = "snfi";
+ u-boot,dm-pre-reloc;
};
};
@@ -102,6 +105,13 @@
};
};
+&snand {
+ pinctrl-names = "default";
+ pinctrl-0 = <&snfi_pins>;
+ status = "okay";
+ quad-spi;
+};
+
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins>;
--- a/arch/arm/dts/mt7629.dtsi
+++ b/arch/arm/dts/mt7629.dtsi
@@ -229,6 +229,22 @@
#size-cells = <0>;
};
+ snand: snand@1100d000 {
+ compatible = "mediatek,mt7629-snand";
+ reg = <0x1100d000 0x1000>,
+ <0x1100e000 0x1000>;
+ reg-names = "nfi", "ecc";
+ clocks = <&pericfg CLK_PERI_NFI_PD>,
+ <&pericfg CLK_PERI_SNFI_PD>,
+ <&pericfg CLK_PERI_NFIECC_PD>;
+ clock-names = "nfi_clk", "pad_clk", "ecc_clk";
+ assigned-clocks = <&topckgen CLK_TOP_AXI_SEL>,
+ <&topckgen CLK_TOP_NFI_INFRA_SEL>;
+ assigned-clock-parents = <&topckgen CLK_TOP_SYSPLL1_D2>,
+ <&topckgen CLK_TOP_UNIVPLL2_D8>;
+ status = "disabled";
+ };
+
snor: snor@11014000 {
compatible = "mediatek,mtk-snor";
reg = <0x11014000 0x1000>;
--- a/board/mediatek/mt7629/Kconfig
+++ b/board/mediatek/mt7629/Kconfig
@@ -12,6 +12,39 @@ config MTK_SPL_PAD_SIZE
config MTK_BROM_HEADER_INFO
string
- default "media=nor"
+ default "media=nor" if BOOT_FROM_SNOR
+ default "media=snand;nandinfo=2k+64" if BOOT_FROM_SNAND_2K_64
+ default "media=snand;nandinfo=2k+128" if BOOT_FROM_SNAND_2K_128
+ default "media=snand;nandinfo=4k+128" if BOOT_FROM_SNAND_4K_128
+ default "media=snand;nandinfo=4k+256" if BOOT_FROM_SNAND_4K_256
+
+choice
+ prompt "Boot device"
+ default BOOT_FROM_SNOR
+
+config BOOT_FROM_SNOR
+ bool "SPI-NOR"
+
+config BOOT_FROM_SNAND_2K_64
+ bool "SPI-NAND (2K+64)"
+ select MT7629_BOOT_FROM_SNAND
+
+config BOOT_FROM_SNAND_2K_128
+ bool "SPI-NAND (2K+128)"
+ select MT7629_BOOT_FROM_SNAND
+
+config BOOT_FROM_SNAND_4K_128
+ bool "SPI-NAND (4K+128)"
+ select MT7629_BOOT_FROM_SNAND
+
+config BOOT_FROM_SNAND_4K_256
+ bool "SPI-NAND (4K+256)"
+ select MT7629_BOOT_FROM_SNAND
+
+endchoice
+
+config MT7629_BOOT_FROM_SNAND
+ bool
+ default n
endif
--- /dev/null
+++ b/configs/mt7629_nand_rfb_defconfig
@@ -0,0 +1,111 @@
+CONFIG_ARM=y
+CONFIG_SYS_ARCH_TIMER=y
+CONFIG_SYS_THUMB_BUILD=y
+CONFIG_ARCH_MEDIATEK=y
+CONFIG_SYS_TEXT_BASE=0x41e00000
+CONFIG_SYS_MALLOC_F_LEN=0x4000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x20000
+CONFIG_ENV_OFFSET=0x100000
+CONFIG_SPL_TEXT_BASE=0x201000
+CONFIG_TARGET_MT7629=y
+CONFIG_BOOT_FROM_SNAND_2K_64=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_SPL_STACK_R_ADDR=0x40800000
+CONFIG_SPL_PAYLOAD="u-boot.img"
+CONFIG_BUILD_TARGET="u-boot-mtk.bin"
+CONFIG_DEFAULT_DEVICE_TREE="mt7629-rfb"
+CONFIG_SPL_IMAGE="spl/u-boot-spl-mtk.bin"
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_BOOTDELAY=3
+CONFIG_DEFAULT_FDT_FILE="mt7629-rfb"
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_STDIO_DEREGISTER=y
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_SPL_STACK_R=y
+CONFIG_SPL_MTD_SUPPORT=y
+CONFIG_SPL_NAND_SUPPORT=y
+CONFIG_SPL_WATCHDOG_SUPPORT=y
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="U-Boot> "
+CONFIG_CMD_BOOTMENU=y
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_XIMG is not set
+CONFIG_CMD_BIND=y
+CONFIG_CMD_DM=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_MTD=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_SETEXPR is not set
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_PING=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_LOG=y
+CONFIG_EFI_PARTITION=y
+# CONFIG_SPL_PARTITION_UUIDS is not set
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent assigned-clocks assigned-clock-parents"
+CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_IN_MTD=y
+CONFIG_ENV_MTD_NAME="spi-nand0"
+CONFIG_ENV_SIZE_REDUND=0x40000
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_REGMAP=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
+CONFIG_SPL_SYSCON=y
+CONFIG_BLK=y
+CONFIG_CLK=y
+CONFIG_SPL_CLK=y
+# CONFIG_MMC is not set
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_MTK_SPI_NAND=y
+CONFIG_MTK_SPI_NAND_MTD=y
+CONFIG_SPL_MTK_SPI_NAND=y
+CONFIG_DM_ETH=y
+CONFIG_MEDIATEK_ETH=y
+CONFIG_PHY=y
+CONFIG_PHY_MTK_TPHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCONF=y
+CONFIG_SPL_PINCTRL=y
+CONFIG_SPL_PINCONF=y
+CONFIG_PINCTRL_MT7629=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MTK_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_RAM=y
+CONFIG_SPL_RAM=y
+CONFIG_DM_SERIAL=y
+CONFIG_MTK_SERIAL=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_SPI_MEM=y
+CONFIG_MTK_SNFI_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_WATCHDOG=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+# CONFIG_SPL_DM_USB is not set
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MTK=y
+CONFIG_USB_STORAGE=y
+CONFIG_WDT_MTK=y
+CONFIG_FAT_WRITE=y
+CONFIG_LZMA=y
+CONFIG_SPL_LZMA=y
+# CONFIG_EFI_LOADER is not set
--- a/include/configs/mt7629.h
+++ b/include/configs/mt7629.h
@@ -30,12 +30,19 @@
/* Defines for SPL */
#define CONFIG_SPL_STACK 0x106000
+#ifdef CONFIG_MT7629_BOOT_FROM_SNAND
+#define CONFIG_SPL_MAX_SIZE SZ_128K
+#define CONFIG_SPL_MAX_FOOTPRINT SZ_128K
+#define CONFIG_SPL_PAD_TO 0x20000
+#define CONFIG_SYS_NAND_U_BOOT_OFFS CONFIG_SPL_PAD_TO
+#else
#define CONFIG_SPL_MAX_SIZE SZ_64K
#define CONFIG_SPL_MAX_FOOTPRINT SZ_64K
#define CONFIG_SPL_PAD_TO 0x10000
#define CONFIG_SPI_ADDR 0x30000000
#define CONFIG_SYS_UBOOT_BASE (CONFIG_SPI_ADDR + CONFIG_SPL_PAD_TO)
+#endif
/* SPL -> Uboot */
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE + SZ_2M - \

View File

@ -0,0 +1,76 @@
From ec0d1899b035700a657721761ff6370b940450ab Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Wed, 3 Mar 2021 10:51:43 +0800
Subject: [PATCH 18/21] board: mt7622: use new spi-nand driver
Enable new spi-nand driver support for mt7622_rfb_defconfig
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
arch/arm/dts/mt7622-rfb.dts | 7 +++++++
arch/arm/dts/mt7622.dtsi | 16 ++++++++++++++++
configs/mt7622_rfb_defconfig | 5 +++++
3 files changed, 28 insertions(+)
--- a/arch/arm/dts/mt7622-rfb.dts
+++ b/arch/arm/dts/mt7622-rfb.dts
@@ -188,6 +188,13 @@
};
};
+&snand {
+ pinctrl-names = "default";
+ pinctrl-0 = <&snfi_pins>;
+ status = "okay";
+ quad-spi;
+};
+
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins>;
--- a/arch/arm/dts/mt7622.dtsi
+++ b/arch/arm/dts/mt7622.dtsi
@@ -53,6 +53,22 @@
#size-cells = <0>;
};
+ snand: snand@1100d000 {
+ compatible = "mediatek,mt7622-snand";
+ reg = <0x1100d000 0x1000>,
+ <0x1100e000 0x1000>;
+ reg-names = "nfi", "ecc";
+ clocks = <&pericfg CLK_PERI_NFI_PD>,
+ <&pericfg CLK_PERI_SNFI_PD>,
+ <&pericfg CLK_PERI_NFIECC_PD>;
+ clock-names = "nfi_clk", "pad_clk", "ecc_clk";
+ assigned-clocks = <&topckgen CLK_TOP_AXI_SEL>,
+ <&topckgen CLK_TOP_NFI_INFRA_SEL>;
+ assigned-clock-parents = <&topckgen CLK_TOP_SYSPLL1_D2>,
+ <&topckgen CLK_TOP_UNIVPLL2_D8>;
+ status = "disabled";
+ };
+
snor: snor@11014000 {
compatible = "mediatek,mtk-snor";
reg = <0x11014000 0x1000>;
--- a/configs/mt7622_rfb_defconfig
+++ b/configs/mt7622_rfb_defconfig
@@ -15,6 +15,7 @@ CONFIG_LOG=y
CONFIG_SYS_PROMPT="MT7622> "
CONFIG_CMD_BOOTMENU=y
CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
CONFIG_CMD_PCI=y
CONFIG_CMD_SF_TEST=y
CONFIG_CMD_PING=y
@@ -28,6 +29,10 @@ CONFIG_CLK=y
CONFIG_DM_MMC=y
CONFIG_MMC_HS200_SUPPORT=y
CONFIG_MMC_MTK=y
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_MTK_SPI_NAND=y
+CONFIG_MTK_SPI_NAND_MTD=y
CONFIG_DM_SPI_FLASH=y
CONFIG_SPI_FLASH_EON=y
CONFIG_SPI_FLASH_GIGADEVICE=y

View File

@ -0,0 +1,31 @@
From 2f7aaf3c2c127bd53d5e8bfe39e808fdd6eb99be Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Wed, 3 Mar 2021 12:12:39 +0800
Subject: [PATCH 19/21] configs: mt7629: remove unused options and add dm
command
Remove unused bootm options
Add dm command
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
configs/mt7629_rfb_defconfig | 5 +++++
1 file changed, 5 insertions(+)
--- a/configs/mt7629_rfb_defconfig
+++ b/configs/mt7629_rfb_defconfig
@@ -28,9 +28,14 @@ CONFIG_SPL_WATCHDOG_SUPPORT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PROMPT="U-Boot> "
CONFIG_CMD_BOOTMENU=y
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
# CONFIG_CMD_ELF is not set
# CONFIG_CMD_XIMG is not set
CONFIG_CMD_BIND=y
+CONFIG_CMD_DM=y
# CONFIG_CMD_FLASH is not set
CONFIG_CMD_GPIO=y
CONFIG_CMD_SF_TEST=y

View File

@ -0,0 +1,33 @@
From e5a71a0eebadfb3d75d8619a8b317eec58b2bca2 Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Sat, 6 Mar 2021 16:29:33 +0800
Subject: [PATCH 20/21] configs: mt7622: enable environment for mt7622_rfb
Enable environment vairables for mt7622_rfb
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
configs/mt7622_rfb_defconfig | 5 +++++
1 file changed, 5 insertions(+)
--- a/configs/mt7622_rfb_defconfig
+++ b/configs/mt7622_rfb_defconfig
@@ -4,6 +4,8 @@ CONFIG_ARCH_MEDIATEK=y
CONFIG_SYS_TEXT_BASE=0x41e00000
CONFIG_SYS_MALLOC_F_LEN=0x4000
CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x20000
+CONFIG_ENV_OFFSET=0x280000
CONFIG_DEBUG_UART_BASE=0x11002000
CONFIG_DEBUG_UART_CLOCK=25000000
CONFIG_DEFAULT_DEVICE_TREE="mt7622-rfb"
@@ -21,6 +23,9 @@ CONFIG_CMD_SF_TEST=y
CONFIG_CMD_PING=y
CONFIG_CMD_SMC=y
CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_IN_MTD=y
+CONFIG_ENV_MTD_NAME="spi-nand0"
+CONFIG_ENV_SIZE_REDUND=0x40000
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
CONFIG_NET_RANDOM_ETHADDR=y
CONFIG_REGMAP=y

View File

@ -0,0 +1,31 @@
From 4bdab0ea008113dda4e001ab8d6863945000c1b2 Mon Sep 17 00:00:00 2001
From: Daniel Golle <daniel@makrotopia.org>
Date: Thu, 11 Mar 2021 14:58:26 +0000
Subject: [PATCH 21/21] mmc: mtk-sd: don't ignore max-frequency from device
tree
commit e58e68d9 ("mmc: mtk-sd: assign plat->cfg.f_max with a correct value")
wrongly assumed that plat->cfg.f_max is always unset at the time
mscd_drv_probe() is run. This is not true in case max-frequency being
defined in device tree, as it is then already set by mmc_of_parser()
in msdc_of_to_plat().
Only set plat->cfg.f_max to the default maximum value in case it is
not already set to a sane value.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/mmc/mtk-sd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/drivers/mmc/mtk-sd.c
+++ b/drivers/mmc/mtk-sd.c
@@ -1644,7 +1644,8 @@ static int msdc_drv_probe(struct udevice
if (cfg->f_min < MIN_BUS_CLK)
cfg->f_min = MIN_BUS_CLK;
- cfg->f_max = host->src_clk_freq;
+ if (cfg->f_max < cfg->f_min || cfg->f_max > host->src_clk_freq)
+ cfg->f_max = host->src_clk_freq;
cfg->b_max = 1024;
cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;

View File

@ -1,57 +0,0 @@
From b1b3c3d2ce62872c8dec4a7d645af6b3c565e094 Mon Sep 17 00:00:00 2001
From: Sam Shih <sam.shih@mediatek.com>
Date: Mon, 20 Apr 2020 17:11:32 +0800
Subject: [PATCH 2/3] mt7622 uboot: add dts and config for spi nand
This patch add dts and config for mt7622 spi nand
Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
---
arch/arm/dts/mt7622-rfb.dts | 6 ++++++
arch/arm/dts/mt7622.dtsi | 20 ++++++++++++++++++++
2 files changed, 26 insertions(+)
--- a/arch/arm/dts/mt7622-rfb.dts
+++ b/arch/arm/dts/mt7622-rfb.dts
@@ -174,6 +174,12 @@
};
};
+&nandc {
+ pinctrl-names = "default";
+ pinctrl-0 = <&snfi_pins>;
+ status = "okay";
+};
+
&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins>;
--- a/arch/arm/dts/mt7622.dtsi
+++ b/arch/arm/dts/mt7622.dtsi
@@ -53,6 +53,26 @@
#size-cells = <0>;
};
+ nandc: nfi@1100d000 {
+ compatible = "mediatek,mt7622-nfc";
+ reg = <0x1100d000 0x1000>,
+ <0x1100e000 0x1000>;
+ interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>,
+ <GIC_SPI 95 IRQ_TYPE_LEVEL_LOW>;
+ clocks = <&pericfg CLK_PERI_NFI_PD>,
+ <&pericfg CLK_PERI_NFIECC_PD>,
+ <&pericfg CLK_PERI_SNFI_PD>,
+ <&topckgen CLK_TOP_NFI_INFRA_SEL>,
+ <&topckgen CLK_TOP_UNIVPLL2_D8>;
+ clock-names = "nfi_clk",
+ "ecc_clk",
+ "snfi_clk",
+ "spinfi_sel",
+ "spinfi_parent_50m";
+ nand-ecc-mode = "hw";
+ status = "disabled";
+ };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <&gic>;

View File

@ -1,22 +0,0 @@
From e5745143a2984cf44fbfc0b3aedb49e57873f109 Mon Sep 17 00:00:00 2001
From: Sam Shih <sam.shih@mediatek.com>
Date: Mon, 20 Apr 2020 17:17:04 +0800
Subject: [PATCH 3/3] configs: enable mtd and mtk_spi_nand in defconfig
This patch enable mtk and mtk_spi_nand in mt7622_rfb defconfig
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
---
configs/mt7622_rfb_defconfig | 5 +++++
1 file changed, 5 insertions(+)
--- a/configs/mt7622_rfb_defconfig
+++ b/configs/mt7622_rfb_defconfig
@@ -13,6 +13,7 @@ CONFIG_DEFAULT_FDT_FILE="mt7622-rfb"
CONFIG_SYS_PROMPT="MT7622> "
CONFIG_CMD_BOOTMENU=y
CONFIG_CMD_MMC=y
+CONFIG_CMD_NAND=y
CONFIG_CMD_PCI=y
CONFIG_CMD_SF_TEST=y
CONFIG_CMD_PING=y

View File

@ -1,38 +0,0 @@
From a6bfd71a96201127836d59736abcb54dc2d5e1a5 Mon Sep 17 00:00:00 2001
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
Date: Mon, 14 Sep 2020 12:50:56 +0200
Subject: [PATCH] cmd/button: return button status
To make the button command useful in a shell script it should return the
status of the button:
* 0 (true) - pressed, on
* 1 (false) - not pressed, off
The button command takes only one argument. Correct maxargs.
Adjust the Python unit test.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Philippe Reynes <philippe.reynes@softathome.com>
---
cmd/button.c | 4 ++--
test/py/tests/test_button.py | 34 ++++++++++++++++++++++++++--------
2 files changed, 28 insertions(+), 10 deletions(-)
--- a/cmd/button.c
+++ b/cmd/button.c
@@ -75,11 +75,11 @@ int do_button(struct cmd_tbl *cmdtp, int
ret = show_button_state(dev);
- return 0;
+ return !ret;
}
U_BOOT_CMD(
- button, 4, 1, do_button,
+ button, 2, 1, do_button,
"manage buttons",
"<button_label> \tGet button state\n"
"button list\t\tShow a list of buttons"

View File

@ -1,23 +0,0 @@
--- a/Makefile
+++ b/Makefile
@@ -1716,6 +1716,10 @@ u-boot-elf.lds: arch/u-boot-elf.lds prep
ifeq ($(CONFIG_SPL),y)
spl/u-boot-spl-mtk.bin: spl/u-boot-spl
+OBJCOPYFLAGS_u-boot-mtk.bin = -I binary -O binary \
+ --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff
+u-boot-mtk.bin: u-boot.img spl/u-boot-spl-mtk.bin FORCE
+ $(call if_changed,pad_cat)
else
MKIMAGEFLAGS_u-boot-mtk.bin = -T mtk_image \
-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \
--- a/arch/arm/mach-mediatek/Kconfig
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -36,7 +36,6 @@ config TARGET_MT7629
bool "MediaTek MT7629 SoC"
select CPU_V7A
select SPL
- select BINMAN
help
The MediaTek MT7629 is a ARM-based SoC with a dual-core Cortex-A7
including DDR3, crypto engine, 3x3 11n/ac Wi-Fi, Gigabit Ethernet,

View File

@ -1,11 +0,0 @@
--- a/include/configs/mt7622.h
+++ b/include/configs/mt7622.h
@@ -37,7 +37,7 @@
#endif
#define CONFIG_SYS_MAXARGS 8
-#define CONFIG_SYS_BOOTM_LEN SZ_64M
+#define CONFIG_SYS_BOOTM_LEN SZ_128M
#define CONFIG_SYS_CBSIZE SZ_1K
#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
sizeof(CONFIG_SYS_PROMPT) + 16)

View File

@ -0,0 +1,24 @@
From b137ca16b54c67d76714ea5a0138741959b0dc29 Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Mon, 13 Jul 2020 23:37:37 +0200
Subject: [PATCH] scripts: remove dependency on swig
Don't build the libfdt tool, as it has a dependency on swig (which
OpenWrt does not ship).
This requires more hacks, as of-platdata generation does not work
without it.
Signed-off-by: David Bauer <mail@david-bauer.net>
---
scripts/dtc/Makefile | 2 --
1 file changed, 2 deletions(-)
--- a/scripts/dtc/Makefile
+++ b/scripts/dtc/Makefile
@@ -18,5 +18,3 @@ HOSTCFLAGS_dtc-parser.tab.o := -I$(src)
# dependencies on generated files need to be listed explicitly
$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
-# Added for U-Boot
-subdir-$(CONFIG_PYLIBFDT) += pylibfdt

View File

@ -1,6 +1,6 @@
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -227,6 +227,65 @@ U_BOOT_CMD(
@@ -228,6 +228,65 @@ U_BOOT_CMD(
/* iminfo - print header info for a requested image */
/*******************************************************************/
#if defined(CONFIG_CMD_IMI)
@ -10,7 +10,7 @@
+{
+ ulong addr;
+ void *fit;
+ int bsize, tsize, maxhdrsize;
+ int bsize, tsize;
+ char buf[16];
+
+ if (argc >= 2)
@ -68,7 +68,7 @@
{
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1878,6 +1878,51 @@ static const char *fit_get_image_type_pr
@@ -1970,6 +1970,51 @@ static const char *fit_get_image_type_pr
return "unknown";
}
@ -122,7 +122,7 @@
int arch, int image_type, int bootstage_id,
--- a/include/image.h
+++ b/include/image.h
@@ -1027,6 +1027,7 @@ int fit_parse_subimage(const char *spec,
@@ -1041,6 +1041,7 @@ int fit_parse_subimage(const char *spec,
ulong *addr, const char **image_name);
int fit_get_subimage_count(const void *fit, int images_noffset);

View File

@ -0,0 +1,192 @@
From 26d4e2e58bf0007db74b47c783785c3305ea1fa0 Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Tue, 19 Jan 2021 10:58:48 +0800
Subject: [PATCH 17/23] cmd: bootmenu: add ability to select item by shortkey
Add ability to use shortkey to select item for bootmenu command
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
cmd/bootmenu.c | 77 +++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 70 insertions(+), 7 deletions(-)
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -11,6 +11,7 @@
#include <menu.h>
#include <watchdog.h>
#include <malloc.h>
+#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/string.h>
@@ -38,6 +39,7 @@ struct bootmenu_data {
int active; /* active menu entry */
int count; /* total count of menu entries */
struct bootmenu_entry *first; /* first menu entry */
+ bool last_choiced;
};
enum bootmenu_key {
@@ -46,8 +48,27 @@ enum bootmenu_key {
KEY_DOWN,
KEY_SELECT,
KEY_QUIT,
+ KEY_CHOICE,
};
+static const char choice_chars[] = {
+ '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
+ 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
+ 'u', 'v', 'w', 'x', 'y', 'z'
+};
+
+static int find_choice(char choice)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(choice_chars); i++)
+ if (tolower(choice) == choice_chars[i])
+ return i;
+
+ return -1;
+}
+
static char *bootmenu_getoption(unsigned short int n)
{
char name[MAX_ENV_SIZE];
@@ -82,7 +103,7 @@ static void bootmenu_print_entry(void *d
}
static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
- enum bootmenu_key *key, int *esc)
+ enum bootmenu_key *key, int *esc, int *choice)
{
int i, c;
@@ -115,6 +136,19 @@ static void bootmenu_autoboot_loop(struc
break;
default:
*key = KEY_NONE;
+ if (*esc)
+ break;
+
+ *choice = find_choice(c);
+ if ((*choice >= 0 &&
+ *choice < menu->count - 1)) {
+ *key = KEY_CHOICE;
+ } else if (c == '0') {
+ *choice = menu->count - 1;
+ *key = KEY_CHOICE;
+ } else {
+ *key = KEY_NONE;
+ }
break;
}
@@ -136,10 +170,16 @@ static void bootmenu_autoboot_loop(struc
}
static void bootmenu_loop(struct bootmenu_data *menu,
- enum bootmenu_key *key, int *esc)
+ enum bootmenu_key *key, int *esc, int *choice)
{
int c;
+ if (menu->last_choiced) {
+ menu->last_choiced = false;
+ *key = KEY_SELECT;
+ return;
+ }
+
if (*esc == 1) {
if (tstc()) {
c = getchar();
@@ -165,6 +205,14 @@ static void bootmenu_loop(struct bootmen
if (c == '\e') {
*esc = 1;
*key = KEY_NONE;
+ } else {
+ *choice = find_choice(c);
+ if ((*choice >= 0 && *choice < menu->count - 1)) {
+ *key = KEY_CHOICE;
+ } else if (c == '0') {
+ *choice = menu->count - 1;
+ *key = KEY_CHOICE;
+ }
}
break;
case 1:
@@ -216,16 +264,17 @@ static char *bootmenu_choice_entry(void
struct bootmenu_data *menu = data;
struct bootmenu_entry *iter;
enum bootmenu_key key = KEY_NONE;
+ int choice = -1;
int esc = 0;
int i;
while (1) {
if (menu->delay >= 0) {
/* Autoboot was not stopped */
- bootmenu_autoboot_loop(menu, &key, &esc);
+ bootmenu_autoboot_loop(menu, &key, &esc, &choice);
} else {
/* Some key was pressed, so autoboot was stopped */
- bootmenu_loop(menu, &key, &esc);
+ bootmenu_loop(menu, &key, &esc, &choice);
}
switch (key) {
@@ -239,6 +288,12 @@ static char *bootmenu_choice_entry(void
++menu->active;
/* no menu key selected, regenerate menu */
return NULL;
+ case KEY_CHOICE:
+ menu->active = choice;
+ if (!menu->last_choiced) {
+ menu->last_choiced = true;
+ return NULL;
+ }
case KEY_SELECT:
iter = menu->first;
for (i = 0; i < menu->active; ++i)
@@ -294,6 +349,7 @@ static struct bootmenu_data *bootmenu_cr
menu->delay = delay;
menu->active = 0;
menu->first = NULL;
+ menu->last_choiced = false;
default_str = env_get("bootmenu_default");
if (default_str)
@@ -311,12 +367,19 @@ static struct bootmenu_data *bootmenu_cr
goto cleanup;
len = sep-option;
- entry->title = malloc(len + 1);
+ entry->title = malloc(len + 4);
if (!entry->title) {
free(entry);
goto cleanup;
}
- memcpy(entry->title, option, len);
+
+ if (i < ARRAY_SIZE(choice_chars)) {
+ len = sprintf(entry->title, "%c. %.*s", choice_chars[i],
+ len, option);
+ } else {
+ len = sprintf(entry->title, " %.*s", len, option);
+ }
+
entry->title[len] = 0;
len = strlen(sep + 1);
@@ -353,7 +416,7 @@ static struct bootmenu_data *bootmenu_cr
if (!entry)
goto cleanup;
- entry->title = strdup("U-Boot console");
+ entry->title = strdup("0. U-Boot console");
if (!entry->title) {
free(entry);
goto cleanup;

View File

@ -1,14 +1,14 @@
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -38,6 +38,7 @@ struct bootmenu_data {
@@ -39,6 +39,7 @@ struct bootmenu_data {
int active; /* active menu entry */
int count; /* total count of menu entries */
struct bootmenu_entry *first; /* first menu entry */
+ char *mtitle; /* custom menu title */
bool last_choiced;
};
enum bootmenu_key {
@@ -380,7 +381,12 @@ static void menu_display_statusline(stru
@@ -471,7 +472,12 @@ static void menu_display_statusline(stru
printf(ANSI_CURSOR_POSITION, 1, 1);
puts(ANSI_CLEAR_LINE);
printf(ANSI_CURSOR_POSITION, 2, 1);
@ -22,7 +22,7 @@
puts(ANSI_CLEAR_LINE_TO_END);
printf(ANSI_CURSOR_POSITION, 3, 1);
puts(ANSI_CLEAR_LINE);
@@ -434,6 +440,7 @@ static void bootmenu_show(int delay)
@@ -525,6 +531,7 @@ static void bootmenu_show(int delay)
return;
}

View File

@ -1,6 +1,6 @@
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -571,6 +571,12 @@ config CMD_ENV_EXISTS
@@ -465,6 +465,12 @@ config CMD_ENV_EXISTS
Check if a variable is defined in the environment for use in
shell scripting.
@ -15,7 +15,7 @@
help
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -469,6 +469,60 @@ int do_env_ask(struct cmd_tbl *cmdtp, in
@@ -473,6 +473,60 @@ int do_env_ask(struct cmd_tbl *cmdtp, in
}
#endif
@ -76,7 +76,7 @@
#if defined(CONFIG_CMD_ENV_CALLBACK)
static int print_static_binding(const char *var_name, const char *callback_name,
void *priv)
@@ -1373,6 +1427,9 @@ static struct cmd_tbl cmd_env_sub[] = {
@@ -1377,6 +1431,9 @@ static struct cmd_tbl cmd_env_sub[] = {
U_BOOT_CMD_MKENT(load, 1, 0, do_env_load, "", ""),
#endif
U_BOOT_CMD_MKENT(print, CONFIG_SYS_MAXARGS, 1, do_env_print, "", ""),
@ -86,7 +86,7 @@
#if defined(CONFIG_CMD_RUN)
U_BOOT_CMD_MKENT(run, CONFIG_SYS_MAXARGS, 1, do_run, "", ""),
#endif
@@ -1461,6 +1518,9 @@ static char env_help_text[] =
@@ -1465,6 +1522,9 @@ static char env_help_text[] =
#if defined(CONFIG_CMD_NVEDIT_EFI)
"env print -e [-guid guid] [-n] [name ...] - print UEFI environment\n"
#endif
@ -96,7 +96,7 @@
#if defined(CONFIG_CMD_RUN)
"env run var [...] - run commands in an environment variable\n"
#endif
@@ -1570,6 +1630,17 @@ U_BOOT_CMD(
@@ -1574,6 +1634,17 @@ U_BOOT_CMD(
);
#endif

View File

@ -1,13 +1,15 @@
--- a/board/mediatek/mt7622/mt7622_rfb.c
+++ b/board/mediatek/mt7622/mt7622_rfb.c
@@ -6,9 +6,15 @@
@@ -6,10 +6,17 @@
#include <common.h>
#include <config.h>
+#include <dm.h>
+#include <button.h>
+
#include <env.h>
#include <init.h>
#include <asm/global_data.h>
+#ifndef CONFIG_RESET_BUTTON_LABEL
+#define CONFIG_RESET_BUTTON_LABEL "reset"
@ -16,7 +18,7 @@
DECLARE_GLOBAL_DATA_PTR;
int board_init(void)
@@ -19,7 +25,15 @@ int board_init(void)
@@ -20,7 +27,15 @@ int board_init(void)
int board_late_init(void)
{

View File

@ -1,6 +1,6 @@
--- a/configs/mt7623n_bpir2_defconfig
+++ b/configs/mt7623n_bpir2_defconfig
@@ -51,5 +51,15 @@ CONFIG_SYSRESET=y
@@ -51,6 +51,16 @@ CONFIG_SYSRESET=y
CONFIG_SYSRESET_WATCHDOG=y
CONFIG_TIMER=y
CONFIG_MTK_TIMER=y
@ -16,3 +16,4 @@
+CONFIG_CMD_SETEXPR=y
CONFIG_WDT_MTK=y
CONFIG_LZMA=y
# CONFIG_EFI_GRUB_ARM32_WORKAROUND is not set

View File

@ -8,7 +8,7 @@
};
memory@40000000 {
@@ -27,6 +29,42 @@
@@ -27,6 +28,42 @@
reg = <0x40000000 0x40000000>;
};
@ -51,30 +51,7 @@
reg_1p8v: regulator-1p8v {
compatible = "regulator-fixed";
regulator-name = "fixed-1.8V";
@@ -139,11 +177,12 @@
};
- mmc1_pins_default: mmc1default {
+ sd0_pins_default: sd0-pins-default {
mux {
function = "sd";
- groups = "sd_0";
+ groups = "sd_0";
};
+
/* "I2S2_OUT, "I2S4_IN"", "I2S3_IN", "I2S2_IN",
* "I2S4_OUT", "I2S3_OUT" are used as DAT0, DAT1,
* DAT2, DAT3, CMD, CLK for SD respectively.
@@ -164,7 +203,6 @@
pins = "TXD3";
bias-pull-up;
};
-
};
};
@@ -199,7 +237,7 @@
@@ -199,7 +236,7 @@
status = "okay";
bus-width = <8>;
max-frequency = <50000000>;
@ -83,21 +60,12 @@
vmmc-supply = <&reg_3p3v>;
vqmmc-supply = <&reg_3p3v>;
non-removable;
@@ -207,14 +245,15 @@
&mmc1 {
pinctrl-names = "default";
- pinctrl-0 = <&mmc1_pins_default>;
+ pinctrl-0 = <&sd0_pins_default>;
@@ -210,7 +247,7 @@
pinctrl-0 = <&mmc1_pins_default>;
status = "okay";
bus-width = <4>;
- max-frequency = <50000000>;
+ max-frequency = <20000000>;
+ max-frequency = <12000000>;
cap-sd-highspeed;
r_smpl = <1>;
vmmc-supply = <&reg_3p3v>;
vqmmc-supply = <&reg_3p3v>;
+ cd-gpios = <&gpio 81 GPIO_ACTIVE_LOW>;
};
&watchdog {

View File

@ -1,6 +1,6 @@
--- /dev/null
+++ b/configs/mt7622_bananapi_bpi-r64-sdmmc_defconfig
@@ -0,0 +1,123 @@
@@ -0,0 +1,124 @@
+CONFIG_ARM=y
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_ARCH_MEDIATEK=y
@ -10,7 +10,10 @@
+CONFIG_BOARD_LATE_INIT=y
+CONFIG_BOOTP_SEND_HOSTNAME=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_DEBUG_UART_BASE=0x11002000
+CONFIG_DEBUG_UART_CLOCK=25000000
+CONFIG_DEFAULT_DEVICE_TREE="mt7622-bananapi-bpi-r64"
+CONFIG_DEBUG_UART=y
+CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r64-sdmmc_env"
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SMBIOS_PRODUCT_NAME=""
@ -50,7 +53,7 @@
+CONFIG_CMD_LED=y
+CONFIG_CMD_LICENSE=y
+CONFIG_CMD_LINK_LOCAL=y
+CONFIG_CMD_MBR=y
+# CONFIG_CMD_MBR is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_SF_TEST=y
@ -61,7 +64,7 @@
+CONFIG_CMD_TFTPSRV=y
+CONFIG_CMD_ASKENV=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_PSTORE=y
+# CONFIG_CMD_PSTORE is not set
+CONFIG_CMD_RARP=y
+CONFIG_CMD_SETEXPR=y
+CONFIG_CMD_SLEEP=y
@ -111,8 +114,6 @@
+CONFIG_MMC_MTK=y
+CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_SYSRESET_WATCHDOG=y
+CONFIG_TIMER=y
+CONFIG_MTK_TIMER=y
+CONFIG_WDT_MTK=y
+CONFIG_LZO=y
+CONFIG_ZSTD=y
@ -131,26 +132,26 @@
+serverip=192.168.1.254
+loadaddr=0x4007ff28
+bootcmd=run boot_sdmmc
+bootargs=earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n1 swiotlb=512 root=/dev/mmcblk1p6
+bootargs=root=/dev/mmcblk1p6
+bootdelay=0
+bootfile=openwrt-mediatek-mt7622-bananapi_bpi-r64-initramfs-recovery.itb
+bootfile_upg=openwrt-mediatek-mt7622-bananapi_bpi-r64-squashfs-sysupgrade.itb
+bootfile_emmcbl3=openwrt-mediatek-mt7622-bananapi_bpi-r64-boot-emmc.img
+bootfile_emmcbl2=openwrt-mediatek-mt7622-bananapi_bpi-r64-bl2-emmc.bin
+bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu
+bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
+bootmenu_default=0
+bootmenu_delay=0
+bootmenu_title= ( ( ( OpenWrt ) ) ) [SD card]
+bootmenu_0=0. Initialize environment.=run _firstboot
+bootmenu_0d=0. Run default boot command.=run boot_default
+bootmenu_1=1. Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
+bootmenu_2=2. Boot production system from SD card.=run boot_production ; run bootmenu_confirm_return
+bootmenu_3=3. Boot recovery system from SD card.=run boot_recovery ; run bootmenu_confirm_return
+bootmenu_4=4. Load production system via TFTP then write to SD card.=setenv noboot 1 ; run boot_tftp_production ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_5=5. Load recovery system via TFTP then write to SD card.=setenv noboot 1 ; run boot_tftp_recovery ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_6=6. Install bootloader and recovery to eMMC.=run emmc_init ; run bootmenu_confirm_return
+bootmenu_7=7. Reboot.=reset
+bootmenu_8=8. Reset all settings to factory defaults.=run reset_factory ; reset
+bootmenu_0=Initialize environment.=run _firstboot
+bootmenu_0d=Run default boot command.=run boot_default
+bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
+bootmenu_2=Boot production system from SD card.=run boot_production ; run bootmenu_confirm_return
+bootmenu_3=Boot recovery system from SD card.=run boot_recovery ; run bootmenu_confirm_return
+bootmenu_4=Load production system via TFTP then write to SD card.=setenv noboot 1 ; run boot_tftp_production ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_5=Load recovery system via TFTP then write to SD card.=setenv noboot 1 ; run boot_tftp_recovery ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_6=Install bootloader and recovery to eMMC.=run emmc_init ; run bootmenu_confirm_return
+bootmenu_7=Reboot.=reset
+bootmenu_8=Reset all settings to factory defaults.=run reset_factory ; reset
+boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; run boot_tftp_forever
+boot_first=if button reset ; then run boot_tftp_forever ; fi ; setenv flag_recover 1 ; bootmenu
+boot_production=led bpi-r64:pio:green on ; run sdmmc_read_production && bootm $loadaddr
@ -183,7 +184,7 @@
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver"
--- /dev/null
+++ b/configs/mt7622_bananapi_bpi-r64-emmc_defconfig
@@ -0,0 +1,123 @@
@@ -0,0 +1,125 @@
+CONFIG_ARM=y
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_ARCH_MEDIATEK=y
@ -193,7 +194,10 @@
+CONFIG_BOARD_LATE_INIT=y
+CONFIG_BOOTP_SEND_HOSTNAME=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_DEBUG_UART_BASE=0x11002000
+CONFIG_DEBUG_UART_CLOCK=25000000
+CONFIG_DEFAULT_DEVICE_TREE="mt7622-bananapi-bpi-r64"
+CONFIG_DEBUG_UART=y
+CONFIG_DEFAULT_ENV_FILE="bananapi_bpi-r64-emmc_env"
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SMBIOS_PRODUCT_NAME=""
@ -233,7 +237,7 @@
+CONFIG_CMD_LED=y
+CONFIG_CMD_LICENSE=y
+CONFIG_CMD_LINK_LOCAL=y
+CONFIG_CMD_MBR=y
+# CONFIG_CMD_MBR is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_SF_TEST=y
@ -244,7 +248,7 @@
+CONFIG_CMD_TFTPSRV=y
+CONFIG_CMD_ASKENV=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_PSTORE=y
+# CONFIG_CMD_PSTORE is not set
+CONFIG_CMD_RARP=y
+CONFIG_CMD_SETEXPR=y
+CONFIG_CMD_SLEEP=y
@ -292,10 +296,9 @@
+CONFIG_MMC=y
+CONFIG_MMC_DEFAULT_DEV=0
+CONFIG_MMC_MTK=y
+CONFIG_MMC_SUPPORTS_TUNING=y
+CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_SYSRESET_WATCHDOG=y
+CONFIG_TIMER=y
+CONFIG_MTK_TIMER=y
+CONFIG_WDT_MTK=y
+CONFIG_LZO=y
+CONFIG_ZSTD=y
@ -314,23 +317,23 @@
+serverip=192.168.1.254
+loadaddr=0x4007ff28
+bootcmd=run boot_emmc
+bootargs=earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n1 swiotlb=512 root=/dev/mmcblk0p5
+bootargs=root=/dev/mmcblk0p5
+bootdelay=0
+bootfile=openwrt-mediatek-mt7622-bananapi_bpi-r64-initramfs-recovery.itb
+bootfile_upg=openwrt-mediatek-mt7622-bananapi_bpi-r64-squashfs-sysupgrade.itb
+bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu
+bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
+bootmenu_default=0
+bootmenu_delay=0
+bootmenu_title= ( ( ( OpenWrt ) ) ) [eMMC]
+bootmenu_0=0. Initialize environment.=run _firstboot
+bootmenu_0d=0. Run default boot command.=run boot_default
+bootmenu_1=1. Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
+bootmenu_2=2. Boot production system from eMMC.=run boot_production ; run bootmenu_confirm_return
+bootmenu_3=3. Boot recovery system from eMMC.=run boot_recovery ; run bootmenu_confirm_return
+bootmenu_4=4. Load production system via TFTP then write to eMMC.=setenv noboot 1 ; run boot_tftp_production ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_5=5. Load recovery system via TFTP then write to eMMC.=setenv noboot 1 ; run boot_tftp_recovery ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_6=6. Reboot.=reset
+bootmenu_7=7. Reset all settings to factory defaults.=run reset_factory ; reset
+bootmenu_0=Initialize environment.=run _firstboot
+bootmenu_0d=Run default boot command.=run boot_default
+bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
+bootmenu_2=Boot production system from eMMC.=run boot_production ; run bootmenu_confirm_return
+bootmenu_3=Boot recovery system from eMMC.=run boot_recovery ; run bootmenu_confirm_return
+bootmenu_4=Load production system via TFTP then write to eMMC.=setenv noboot 1 ; run boot_tftp_production ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_5=Load recovery system via TFTP then write to eMMC.=setenv noboot 1 ; run boot_tftp_recovery ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_6=Reboot.=reset
+bootmenu_7=Reset all settings to factory defaults.=run reset_factory ; reset
+boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; run boot_tftp_forever
+boot_first=if button reset ; then run boot_tftp_forever ; fi ; setenv flag_recover 1 ; bootmenu
+boot_production=led bpi-r64:pio:green on ; run emmc_read_production && bootm $loadaddr

View File

@ -1,6 +1,6 @@
--- /dev/null
+++ b/configs/mt7622_linksys_e8450_defconfig
@@ -0,0 +1,130 @@
@@ -0,0 +1,128 @@
+CONFIG_ARM=y
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_ARCH_MEDIATEK=y
@ -11,7 +11,10 @@
+CONFIG_BOOTP_SEND_HOSTNAME=y
+CONFIG_DEFAULT_ENV_FILE="linksys_e8450_env"
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_DEBUG_UART_BASE=0x11002000
+CONFIG_DEBUG_UART_CLOCK=25000000
+CONFIG_DEFAULT_DEVICE_TREE="mt7622-linksys-e8450-ubi"
+CONFIG_DEBUG_UART=y
+CONFIG_SMBIOS_PRODUCT_NAME=""
+CONFIG_AUTOBOOT_KEYED=y
+CONFIG_BOOTDELAY=30
@ -49,10 +52,9 @@
+CONFIG_CMD_LED=y
+CONFIG_CMD_LICENSE=y
+CONFIG_CMD_LINK_LOCAL=y
+CONFIG_CMD_MBR=y
+# CONFIG_CMD_MBR is not set
+CONFIG_CMD_MTD=y
+CONFIG_CMD_MTDPART=y
+CONFIG_CMD_NAND=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_PING=y
@ -65,7 +67,7 @@
+CONFIG_CMD_UBIFS=y
+CONFIG_CMD_ASKENV=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_PSTORE=y
+# CONFIG_CMD_PSTORE is not set
+CONFIG_CMD_RARP=y
+CONFIG_CMD_SETEXPR=y
+CONFIG_CMD_SLEEP=y
@ -98,7 +100,6 @@
+CONFIG_MEDIATEK_ETH=y
+CONFIG_PCI=y
+CONFIG_MTD=y
+CONFIG_MTD_RAW_NAND=y
+CONFIG_MTD_UBI_FASTMAP=y
+CONFIG_DM_PCI=y
+CONFIG_PCIE_MEDIATEK=y
@ -114,12 +115,9 @@
+CONFIG_MTK_SERIAL=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_MTK_SNFI_SPI=y
+CONFIG_MTK_SPI_NAND=y
+CONFIG_NAND_SUPPORT=y
+CONFIG_MTK_SPI_NAND_MTD=y
+CONFIG_SYSRESET_WATCHDOG=y
+CONFIG_TIMER=y
+CONFIG_MTK_TIMER=y
+CONFIG_WDT_MTK=y
+CONFIG_LZO=y
+CONFIG_ZSTD=y
@ -133,7 +131,7 @@
+CONFIG_USB_STORAGE=y
--- /dev/null
+++ b/arch/arm/dts/mt7622-linksys-e8450-ubi.dts
@@ -0,0 +1,206 @@
@@ -0,0 +1,195 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019 MediaTek Inc.
@ -155,7 +153,7 @@
+ };
+
+ aliases {
+ spi0 = &snfi;
+ spi0 = &snand;
+ };
+
+ gpio-keys {
@ -288,22 +286,11 @@
+ };
+};
+
+&snfi {
+&snand {
+ pinctrl-names = "default";
+ pinctrl-0 = <&snfi_pins>;
+ status = "okay";
+
+ mediatek,bmt-v2;
+
+ spi-flash@0{
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ u-boot,dm-pre-reloc;
+ };
+};
+
+&nandc {
+ status = "okay";
+ quad-spi;
+};
+
+&uart0 {
@ -342,7 +329,7 @@
+};
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -963,6 +963,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
@@ -996,6 +996,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
mt7622-rfb.dtb \
mt7623a-unielec-u7623-02-emmc.dtb \
mt7622-bananapi-bpi-r64.dtb \
@ -350,35 +337,11 @@
mt7623n-bananapi-bpi-r2.dtb \
mt7629-rfb.dtb \
mt8512-bm1-emmc.dtb \
--- a/drivers/mtd/nandx/core/nand/device_spi.c
+++ b/drivers/mtd/nandx/core/nand/device_spi.c
@@ -150,6 +150,21 @@ static struct device_spi spi_nand[] = {
&spi_extend_cmds, 0xff, 0xff
},
{
+ NAND_DEVICE("FM35X1GA",
+ NAND_PACK_ID(0xe5, 0x71, 0, 0, 0, 0, 0, 0),
+ 2, 0, 3, 3,
+ 1, 1, 1, 1024, KB(128), KB(2), 64, 1,
+ &spi_cmds, &spi_addressing, &spi_status[0],
+ &spi_endurance, &spi_array_timing),
+ {
+ NAND_SPI_PROTECT(0xa0, 1, 2, 6),
+ NAND_SPI_CONFIG(0xb0, 4, 6, 1),
+ NAND_SPI_STATUS(0xc0, 4, 5),
+ NAND_SPI_CHARACTER(0xff, 0xff, 0xff, 0xff)
+ },
+ &spi_extend_cmds, 0xff, 0xff
+ },
+ {
NAND_DEVICE("NO-DEVICE",
NAND_PACK_ID(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1,
--- /dev/null
+++ b/linksys_e8450_env
@@ -0,0 +1,57 @@
+mtdparts=nand0:512k(bl2),1280k(fip),1024k(factory),256k(reserved),-(ubi)
+ethaddr_factory=nand read 0x40080000 0x220000 0x20000 && env readmem -b ethaddr 0x4009fff4 0x6 ; setenv ethaddr_factory
+mtdparts=spi-nand0:512k(bl2),1280k(fip),1024k(factory),256k(reserved),-(ubi)
+ethaddr_factory=mtd read spi-nand0 0x40080000 0x220000 0x20000 && env readmem -b ethaddr 0x4009fff4 0x6 ; setenv ethaddr_factory
+ipaddr=192.168.1.1
+serverip=192.168.1.254
+loadaddr=0x4007ff28
@ -388,21 +351,21 @@
+bootfile_bl2=openwrt-mediatek-mt7622-linksys_e8450-ubi-preloader.bin
+bootfile_fip=openwrt-mediatek-mt7622-linksys_e8450-ubi-bl31-uboot.fip
+bootfile_upg=openwrt-mediatek-mt7622-linksys_e8450-ubi-squashfs-sysupgrade.itb
+bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu
+bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
+bootmenu_default=0
+bootmenu_delay=0
+bootmenu_title= ( ( ( OpenWrt ) ) )
+bootmenu_0=0. Initialize environment.=run _firstboot
+bootmenu_0d=0. Run default boot command.=run boot_default
+bootmenu_1=1. Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
+bootmenu_3=2. Boot production system from flash.=run boot_production ; run bootmenu_confirm_return
+bootmenu_2=3. Boot recovery system from flash.=run boot_recovery ; run bootmenu_confirm_return
+bootmenu_5=4. Load production system via TFTP then write to flash.=setenv noboot 1 ; run boot_tftp_production ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_4=5. Load recovery system via TFTP then write to flash.=setenv noboot 1 ; run boot_tftp_recovery ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_6=6. Load BL31+U-Boot FIP via TFTP then write to flash.=run boot_tftp_write_fip ; run bootmenu_confirm_return
+bootmenu_7=7. Load BL2 preloader via TFTP then write to flash.=run boot_tftp_write_preloader ; run bootmenu_confirm_return
+bootmenu_8=8. Reboot.=reset
+bootmenu_9=9. Reset all settings to factory defaults.=run reset_factory ; reset
+bootmenu_0=Initialize environment.=run _firstboot
+bootmenu_0d=Run default boot command.=run boot_default
+bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
+bootmenu_2=Boot production system from flash.=run boot_production ; run bootmenu_confirm_return
+bootmenu_3=Boot recovery system from flash.=run boot_recovery ; run bootmenu_confirm_return
+bootmenu_4=Load production system via TFTP then write to flash.=setenv noboot 1 ; run boot_tftp_production ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_5=Load recovery system via TFTP then write to flash.=setenv noboot 1 ; run boot_tftp_recovery ; setenv noboot ; run bootmenu_confirm_return
+bootmenu_6=Load BL31+U-Boot FIP via TFTP then write to flash.=run boot_tftp_write_fip ; run bootmenu_confirm_return
+bootmenu_7=Load BL2 preloader via TFTP then write to flash.=run boot_tftp_write_preloader ; run bootmenu_confirm_return
+bootmenu_8=Reboot.=reset
+bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
+boot_first=if button reset ; then run boot_tftp_forever ; fi ; setenv flag_recover 1 ; bootmenu
+boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; run boot_tftp_forever
+boot_production=led power:blue on ; run ubi_read_production && bootm $loadaddr
@ -417,18 +380,18 @@
+boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run boot_write_fip
+boot_tftp_write_preloader=tftpboot $loadaddr $bootfile_bl2 && run boot_write_preloader
+boot_ubi=ubi part ubi && run boot_production_or_recovery
+boot_write_fip=nand erase 0x80000 0x140000 && nand write $loadaddr 0x80000 0x140000
+boot_write_preloader=nand erase 0x0 0x80000 && nand write $loadaddr 0x0 0x20000 && nand write $loadaddr 0x20000 0x20000 && nand write $loadaddr 0x40000 0x20000 && nand write $loadaddr 0x60000 0x20000
+boot_write_fip=mtd erase spi-nand0 0x80000 0x140000 && mtd write spi-nand0 $loadaddr 0x80000 0x140000
+boot_write_preloader=mtd erase spi-nand0 0x0 0x80000 && mtd write spi-nand0 $loadaddr 0x0 0x20000 && mtd write spi-nand0 $loadaddr 0x20000 0x20000 && mtd write spi-nand0 $loadaddr 0x40000 0x20000 && mtd write spi-nand0 $loadaddr 0x60000 0x20000
+check_recovery=run ubi_read_recovery ; if iminfo $loadaddr ; then bootm $loadaddr ; else ubi remove recovery ; fi
+check_ubi=ubi part ubi || run ubi_format
+reset_factory=ubi part ubi ; ubi write 0x0 ubootenv 0x0 ; ubi write 0x0 ubootenv2 0x0 ; ubi remove rootfs_data
+ubi_format=ubi detach ; nand erase 0x300000 0x7D00000 && ubi part ubi ; reset
+ubi_format=ubi detach ; mtd erase spi-nand0 0x300000 0x7D00000 && ubi part ubi ; reset
+ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi
+ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
+ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery
+ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
+ubi_write_production=run ubi_remove_rootfs ; ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
+ubi_write_recovery=run ubi_remove_rootfs ; ubi check recovery && ubi remove recovery; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
+ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
+ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
+_create_env=ubi create ubootenv 0x100000 dynamic ; ubi create ubootenv2 0x100000 dynamic
+_init_env=setenv _init_env ; if ubi check ubootenv && ubi check ubootenv2 ; then else run _create_env ; fi ; setenv _create_env ; saveenv || run ubi_format ; saveenv || run ubi_format
+_firstboot=setenv _firstboot ; led power:orange on ; run _switch_to_menu ; run ethaddr_factory ; run check_ubi ; run _init_env ; run boot_first