1 From 6792b57b3ba61ca6d69ea4a13a58bed65fc5da87 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Sun, 7 Aug 2022 04:04:46 +0200
4 Subject: [PATCH] board: mediatek: wire-up NMBM support
7 board/mediatek/mt7622/mt7622_rfb.c | 38 +++++++++++++++++++++
8 board/mediatek/mt7629/mt7629_rfb.c | 38 +++++++++++++++++++++
9 board/mediatek/mt7981/mt7981_rfb.c | 52 ++++++++++++++++++++++++++++
10 board/mediatek/mt7986/mt7986_rfb.c | 54 ++++++++++++++++++++++++++++++
11 4 files changed, 182 insertions(+)
13 --- a/board/mediatek/mt7622/mt7622_rfb.c
14 +++ b/board/mediatek/mt7622/mt7622_rfb.c
17 #include <asm/global_data.h>
20 +#include <linux/mtd/mtd.h>
21 +#include <nmbm/nmbm.h>
22 +#include <nmbm/nmbm-mtd.h>
24 DECLARE_GLOBAL_DATA_PTR;
27 @@ -23,3 +28,36 @@ int board_late_init(void)
32 +int board_nmbm_init(void)
34 +#ifdef CONFIG_ENABLE_NAND_NMBM
35 + struct mtd_info *lower, *upper;
39 + printf("Initializing NMBM ...\n");
41 + mtd_probe_devices();
43 + lower = get_mtd_device_nm("spi-nand0");
44 + if (IS_ERR(lower) || !lower) {
45 + printf("Lower MTD device 'spi-nand0' not found\n");
49 + ret = nmbm_attach_mtd(lower,
50 + NMBM_F_CREATE | NMBM_F_EMPTY_PAGE_ECC_OK,
51 + CONFIG_NMBM_MAX_RATIO,
52 + CONFIG_NMBM_MAX_BLOCKS, &upper);
59 + add_mtd_device(upper);
64 --- a/board/mediatek/mt7629/mt7629_rfb.c
65 +++ b/board/mediatek/mt7629/mt7629_rfb.c
68 #include <asm/global_data.h>
71 +#include <linux/mtd/mtd.h>
72 +#include <nmbm/nmbm.h>
73 +#include <nmbm/nmbm-mtd.h>
75 DECLARE_GLOBAL_DATA_PTR;
78 @@ -20,3 +25,36 @@ uint32_t spl_nand_get_uboot_raw_page(voi
80 return CONFIG_SPL_PAD_TO;
83 +int board_nmbm_init(void)
85 +#ifdef CONFIG_ENABLE_NAND_NMBM
86 + struct mtd_info *lower, *upper;
90 + printf("Initializing NMBM ...\n");
92 + mtd_probe_devices();
94 + lower = get_mtd_device_nm("spi-nand0");
95 + if (IS_ERR(lower) || !lower) {
96 + printf("Lower MTD device 'spi-nand0' not found\n");
100 + ret = nmbm_attach_mtd(lower,
101 + NMBM_F_CREATE | NMBM_F_EMPTY_PAGE_ECC_OK,
102 + CONFIG_NMBM_MAX_RATIO,
103 + CONFIG_NMBM_MAX_BLOCKS, &upper);
110 + add_mtd_device(upper);
115 --- a/board/mediatek/mt7981/mt7981_rfb.c
116 +++ b/board/mediatek/mt7981/mt7981_rfb.c
118 * Author: Sam Shih <sam.shih@mediatek.com>
125 +#include <asm/global_data.h>
128 +#include <linux/mtd/mtd.h>
129 +#include <nmbm/nmbm.h>
130 +#include <nmbm/nmbm-mtd.h>
132 +DECLARE_GLOBAL_DATA_PTR;
139 +int board_late_init(void)
141 + gd->env_valid = 1; //to load environment variable from persistent store
146 +int board_nmbm_init(void)
148 +#ifdef CONFIG_ENABLE_NAND_NMBM
149 + struct mtd_info *lower, *upper;
153 + printf("Initializing NMBM ...\n");
155 + mtd_probe_devices();
157 + lower = get_mtd_device_nm("spi-nand0");
158 + if (IS_ERR(lower) || !lower) {
159 + printf("Lower MTD device 'spi-nand0' not found\n");
163 + ret = nmbm_attach_mtd(lower, NMBM_F_CREATE, CONFIG_NMBM_MAX_RATIO,
164 + CONFIG_NMBM_MAX_BLOCKS, &upper);
171 + add_mtd_device(upper);
176 --- a/board/mediatek/mt7986/mt7986_rfb.c
177 +++ b/board/mediatek/mt7986/mt7986_rfb.c
179 * Author: Sam Shih <sam.shih@mediatek.com>
186 +#include <asm/global_data.h>
189 +#include <linux/mtd/mtd.h>
190 +#include <nmbm/nmbm.h>
191 +#include <nmbm/nmbm-mtd.h>
193 +DECLARE_GLOBAL_DATA_PTR;
200 +int board_late_init(void)
202 + gd->env_valid = 1; //to load environment variable from persistent store
207 +int board_nmbm_init(void)
209 +#ifdef CONFIG_ENABLE_NAND_NMBM
210 + struct mtd_info *lower, *upper;
214 + printf("Initializing NMBM ...\n");
216 + mtd_probe_devices();
218 + lower = get_mtd_device_nm("spi-nand0");
219 + if (IS_ERR(lower) || !lower) {
220 + printf("Lower MTD device 'spi-nand0' not found\n");
224 + ret = nmbm_attach_mtd(lower,
225 + NMBM_F_CREATE | NMBM_F_EMPTY_PAGE_ECC_OK,
226 + CONFIG_NMBM_MAX_RATIO,
227 + CONFIG_NMBM_MAX_BLOCKS, &upper);
234 + add_mtd_device(upper);