mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 15:32:33 +00:00
d3a337a592
* updated SNAND/SNFI driver brings support for MT7981 * add support for MediaTek NAND Memory bad Block Management (NMBM) (not used for any boards atm, but could be useful in future) * wire up NMBM support for MT7622, MT7629, MT7981 and MT7986 * replace some local patches with updated version from SDK * bring some legacy precompiler symbols which haven't been converted into Kconfig symbols in U-Boot 2022.07, remove when bumbping to U-Boot 2022.10: 100-28-include-configs-mt7986-h-from-SDK.patch Source: https://github.com/mtk-openwrt/u-boot Signed-off-by: Daniel Golle <daniel@makrotopia.org>
241 lines
4.8 KiB
Diff
241 lines
4.8 KiB
Diff
From 6792b57b3ba61ca6d69ea4a13a58bed65fc5da87 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Golle <daniel@makrotopia.org>
|
|
Date: Sun, 7 Aug 2022 04:04:46 +0200
|
|
Subject: [PATCH] board: mediatek: wire-up NMBM support
|
|
|
|
---
|
|
board/mediatek/mt7622/mt7622_rfb.c | 38 +++++++++++++++++++++
|
|
board/mediatek/mt7629/mt7629_rfb.c | 38 +++++++++++++++++++++
|
|
board/mediatek/mt7981/mt7981_rfb.c | 52 ++++++++++++++++++++++++++++
|
|
board/mediatek/mt7986/mt7986_rfb.c | 54 ++++++++++++++++++++++++++++++
|
|
4 files changed, 182 insertions(+)
|
|
|
|
--- a/board/mediatek/mt7622/mt7622_rfb.c
|
|
+++ b/board/mediatek/mt7622/mt7622_rfb.c
|
|
@@ -10,6 +10,11 @@
|
|
#include <init.h>
|
|
#include <asm/global_data.h>
|
|
|
|
+#include <mtd.h>
|
|
+#include <linux/mtd/mtd.h>
|
|
+#include <nmbm/nmbm.h>
|
|
+#include <nmbm/nmbm-mtd.h>
|
|
+
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
int board_init(void)
|
|
@@ -24,3 +29,36 @@ int board_late_init(void)
|
|
env_relocate();
|
|
return 0;
|
|
}
|
|
+
|
|
+int board_nmbm_init(void)
|
|
+{
|
|
+#ifdef CONFIG_ENABLE_NAND_NMBM
|
|
+ struct mtd_info *lower, *upper;
|
|
+ int ret;
|
|
+
|
|
+ printf("\n");
|
|
+ printf("Initializing NMBM ...\n");
|
|
+
|
|
+ mtd_probe_devices();
|
|
+
|
|
+ lower = get_mtd_device_nm("spi-nand0");
|
|
+ if (IS_ERR(lower) || !lower) {
|
|
+ printf("Lower MTD device 'spi-nand0' not found\n");
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ ret = nmbm_attach_mtd(lower,
|
|
+ NMBM_F_CREATE | NMBM_F_EMPTY_PAGE_ECC_OK,
|
|
+ CONFIG_NMBM_MAX_RATIO,
|
|
+ CONFIG_NMBM_MAX_BLOCKS, &upper);
|
|
+
|
|
+ printf("\n");
|
|
+
|
|
+ if (ret)
|
|
+ return 0;
|
|
+
|
|
+ add_mtd_device(upper);
|
|
+#endif
|
|
+
|
|
+ return 0;
|
|
+}
|
|
--- a/board/mediatek/mt7629/mt7629_rfb.c
|
|
+++ b/board/mediatek/mt7629/mt7629_rfb.c
|
|
@@ -6,6 +6,11 @@
|
|
#include <common.h>
|
|
#include <asm/global_data.h>
|
|
|
|
+#include <mtd.h>
|
|
+#include <linux/mtd/mtd.h>
|
|
+#include <nmbm/nmbm.h>
|
|
+#include <nmbm/nmbm-mtd.h>
|
|
+
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
int board_init(void)
|
|
@@ -20,3 +25,36 @@ uint32_t spl_nand_get_uboot_raw_page(voi
|
|
{
|
|
return CONFIG_SPL_PAD_TO;
|
|
}
|
|
+
|
|
+int board_nmbm_init(void)
|
|
+{
|
|
+#ifdef CONFIG_ENABLE_NAND_NMBM
|
|
+ struct mtd_info *lower, *upper;
|
|
+ int ret;
|
|
+
|
|
+ printf("\n");
|
|
+ printf("Initializing NMBM ...\n");
|
|
+
|
|
+ mtd_probe_devices();
|
|
+
|
|
+ lower = get_mtd_device_nm("spi-nand0");
|
|
+ if (IS_ERR(lower) || !lower) {
|
|
+ printf("Lower MTD device 'spi-nand0' not found\n");
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ ret = nmbm_attach_mtd(lower,
|
|
+ NMBM_F_CREATE | NMBM_F_EMPTY_PAGE_ECC_OK,
|
|
+ CONFIG_NMBM_MAX_RATIO,
|
|
+ CONFIG_NMBM_MAX_BLOCKS, &upper);
|
|
+
|
|
+ printf("\n");
|
|
+
|
|
+ if (ret)
|
|
+ return 0;
|
|
+
|
|
+ add_mtd_device(upper);
|
|
+#endif
|
|
+
|
|
+ return 0;
|
|
+}
|
|
--- a/board/mediatek/mt7981/mt7981_rfb.c
|
|
+++ b/board/mediatek/mt7981/mt7981_rfb.c
|
|
@@ -4,7 +4,59 @@
|
|
* Author: Sam Shih <sam.shih@mediatek.com>
|
|
*/
|
|
|
|
+#include <common.h>
|
|
+#include <config.h>
|
|
+#include <env.h>
|
|
+#include <init.h>
|
|
+#include <asm/global_data.h>
|
|
+
|
|
+#include <mtd.h>
|
|
+#include <linux/mtd/mtd.h>
|
|
+#include <nmbm/nmbm.h>
|
|
+#include <nmbm/nmbm-mtd.h>
|
|
+
|
|
+DECLARE_GLOBAL_DATA_PTR;
|
|
+
|
|
int board_init(void)
|
|
{
|
|
+ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+int board_late_init(void)
|
|
+{
|
|
+ gd->env_valid = 1; //to load environment variable from persistent store
|
|
+ env_relocate();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+int board_nmbm_init(void)
|
|
+{
|
|
+#ifdef CONFIG_ENABLE_NAND_NMBM
|
|
+ struct mtd_info *lower, *upper;
|
|
+ int ret;
|
|
+
|
|
+ printf("\n");
|
|
+ printf("Initializing NMBM ...\n");
|
|
+
|
|
+ mtd_probe_devices();
|
|
+
|
|
+ lower = get_mtd_device_nm("spi-nand0");
|
|
+ if (IS_ERR(lower) || !lower) {
|
|
+ printf("Lower MTD device 'spi-nand0' not found\n");
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ ret = nmbm_attach_mtd(lower, NMBM_F_CREATE, CONFIG_NMBM_MAX_RATIO,
|
|
+ CONFIG_NMBM_MAX_BLOCKS, &upper);
|
|
+
|
|
+ printf("\n");
|
|
+
|
|
+ if (ret)
|
|
+ return 0;
|
|
+
|
|
+ add_mtd_device(upper);
|
|
+#endif
|
|
+
|
|
return 0;
|
|
}
|
|
--- a/board/mediatek/mt7986/mt7986_rfb.c
|
|
+++ b/board/mediatek/mt7986/mt7986_rfb.c
|
|
@@ -4,7 +4,61 @@
|
|
* Author: Sam Shih <sam.shih@mediatek.com>
|
|
*/
|
|
|
|
+#include <common.h>
|
|
+#include <config.h>
|
|
+#include <env.h>
|
|
+#include <init.h>
|
|
+#include <asm/global_data.h>
|
|
+
|
|
+#include <mtd.h>
|
|
+#include <linux/mtd/mtd.h>
|
|
+#include <nmbm/nmbm.h>
|
|
+#include <nmbm/nmbm-mtd.h>
|
|
+
|
|
+DECLARE_GLOBAL_DATA_PTR;
|
|
+
|
|
int board_init(void)
|
|
{
|
|
+ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+int board_late_init(void)
|
|
+{
|
|
+ gd->env_valid = 1; //to load environment variable from persistent store
|
|
+ env_relocate();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+int board_nmbm_init(void)
|
|
+{
|
|
+#ifdef CONFIG_ENABLE_NAND_NMBM
|
|
+ struct mtd_info *lower, *upper;
|
|
+ int ret;
|
|
+
|
|
+ printf("\n");
|
|
+ printf("Initializing NMBM ...\n");
|
|
+
|
|
+ mtd_probe_devices();
|
|
+
|
|
+ lower = get_mtd_device_nm("spi-nand0");
|
|
+ if (IS_ERR(lower) || !lower) {
|
|
+ printf("Lower MTD device 'spi-nand0' not found\n");
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ ret = nmbm_attach_mtd(lower,
|
|
+ NMBM_F_CREATE | NMBM_F_EMPTY_PAGE_ECC_OK,
|
|
+ CONFIG_NMBM_MAX_RATIO,
|
|
+ CONFIG_NMBM_MAX_BLOCKS, &upper);
|
|
+
|
|
+ printf("\n");
|
|
+
|
|
+ if (ret)
|
|
+ return 0;
|
|
+
|
|
+ add_mtd_device(upper);
|
|
+#endif
|
|
+
|
|
return 0;
|
|
}
|