|
26 | 26 | #include <linux/slab.h>
|
27 | 27 | #include <linux/of.h>
|
28 | 28 | #include <linux/of_device.h>
|
| 29 | +#include <linux/of_mtd.h> |
29 | 30 |
|
30 | 31 | #if defined(CONFIG_ARCH_PXA) || defined(CONFIG_ARCH_MMP)
|
31 | 32 | #define ARCH_HAS_DMA
|
@@ -241,6 +242,29 @@ static struct pxa3xx_nand_flash builtin_flash_types[] = {
|
241 | 242 | { "256MiB 16-bit", 0xba20, 64, 2048, 16, 16, 2048, &timing[3] },
|
242 | 243 | };
|
243 | 244 |
|
| 245 | +static u8 bbt_pattern[] = {'M', 'V', 'B', 'b', 't', '0' }; |
| 246 | +static u8 bbt_mirror_pattern[] = {'1', 't', 'b', 'B', 'V', 'M' }; |
| 247 | + |
| 248 | +static struct nand_bbt_descr bbt_main_descr = { |
| 249 | + .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
| 250 | + | NAND_BBT_2BIT | NAND_BBT_VERSION, |
| 251 | + .offs = 8, |
| 252 | + .len = 6, |
| 253 | + .veroffs = 14, |
| 254 | + .maxblocks = 8, /* Last 8 blocks in each chip */ |
| 255 | + .pattern = bbt_pattern |
| 256 | +}; |
| 257 | + |
| 258 | +static struct nand_bbt_descr bbt_mirror_descr = { |
| 259 | + .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
| 260 | + | NAND_BBT_2BIT | NAND_BBT_VERSION, |
| 261 | + .offs = 8, |
| 262 | + .len = 6, |
| 263 | + .veroffs = 14, |
| 264 | + .maxblocks = 8, /* Last 8 blocks in each chip */ |
| 265 | + .pattern = bbt_mirror_pattern |
| 266 | +}; |
| 267 | + |
244 | 268 | /* Define a default flash type setting serve as flash detecting only */
|
245 | 269 | #define DEFAULT_FLASH_TYPE (&builtin_flash_types[0])
|
246 | 270 |
|
@@ -1122,6 +1146,18 @@ static int pxa3xx_nand_scan(struct mtd_info *mtd)
|
1122 | 1146 |
|
1123 | 1147 | if (nand_scan_ident(mtd, 1, def))
|
1124 | 1148 | return -ENODEV;
|
| 1149 | + |
| 1150 | + if (pdata->flash_bbt) { |
| 1151 | + /* |
| 1152 | + * We'll use a bad block table stored in-flash and don't |
| 1153 | + * allow writing the bad block marker to the flash. |
| 1154 | + */ |
| 1155 | + chip->bbt_options |= NAND_BBT_USE_FLASH | |
| 1156 | + NAND_BBT_NO_OOB_BBM; |
| 1157 | + chip->bbt_td = &bbt_main_descr; |
| 1158 | + chip->bbt_md = &bbt_mirror_descr; |
| 1159 | + } |
| 1160 | + |
1125 | 1161 | /* calculate addressing information */
|
1126 | 1162 | if (mtd->writesize >= 2048)
|
1127 | 1163 | host->col_addr_cycles = 2;
|
@@ -1316,6 +1352,7 @@ static int pxa3xx_nand_probe_dt(struct platform_device *pdev)
|
1316 | 1352 | if (of_get_property(np, "marvell,nand-keep-config", NULL))
|
1317 | 1353 | pdata->keep_config = 1;
|
1318 | 1354 | of_property_read_u32(np, "num-cs", &pdata->num_cs);
|
| 1355 | + pdata->flash_bbt = of_get_nand_on_flash_bbt(np); |
1319 | 1356 |
|
1320 | 1357 | pdev->dev.platform_data = pdata;
|
1321 | 1358 |
|
|
0 commit comments