Skip to content

Commit 48476df

Browse files
committed
Merge tag 'for-linus-20130301' of git://git.infradead.org/linux-mtd
Pull MTD update from David Woodhouse: "Fairly unexciting MTD merge for 3.9: - misc clean-ups in the MTD command-line partitioning parser (cmdlinepart) - add flash locking support for STmicro chips serial flash chips, as well as for CFI command set 2 chips. - new driver for the ELM error correction HW module found in various TI chips, enable the OMAP NAND driver to use the ELM HW error correction - added number of new serial flash IDs - various fixes and improvements in the gpmi NAND driver - bcm47xx NAND driver improvements - make the mtdpart module actually removable" * tag 'for-linus-20130301' of git://git.infradead.org/linux-mtd: (45 commits) mtd: map: BUG() in non handled cases mtd: bcm47xxnflash: use pr_fmt for module prefix in messages mtd: davinci_nand: Use managed resources mtd: mtd_torturetest can cause stack overflows mtd: physmap_of: Convert device allocation to managed devm_kzalloc() mtd: at91: atmel_nand: for PMECC, add code to check the ONFI parameter ECC requirement. mtd: atmel_nand: make pmecc-cap, pmecc-sector-size in dts is optional. mtd: atmel_nand: avoid to report an error when lookup table offset is 0. mtd: bcm47xxsflash: adjust names of bus-specific functions mtd: bcm47xxpart: improve probing of nvram partition mtd: bcm47xxpart: add support for other erase sizes mtd: bcm47xxnflash: register this as normal driver mtd: bcm47xxnflash: fix message mtd: bcm47xxsflash: register this as normal driver mtd: bcm47xxsflash: write number of written bytes mtd: gpmi: add sanity check for the ECC mtd: gpmi: set the Golois Field bit for mx6q's BCH mtd: devices: elm: Removes <xx> literals in elm DT node mtd: gpmi: fix a dereferencing freed memory error mtd: fix the wrong timeo for panic_nand_wait() ...
2 parents 37cae6a + 24dea0c commit 48476df

38 files changed

Lines changed: 1881 additions & 331 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Error location module
2+
3+
Required properties:
4+
- compatible: Must be "ti,am33xx-elm"
5+
- reg: physical base address and size of the registers map.
6+
- interrupts: Interrupt number for the elm.
7+
8+
Optional properties:
9+
- ti,hwmods: Name of the hwmod associated to the elm
10+
11+
Example:
12+
elm: elm@0 {
13+
compatible = "ti,am3352-elm";
14+
reg = <0x48080000 0x2000>;
15+
interrupts = <4>;
16+
};

‎Documentation/devicetree/bindings/mtd/mtd-physmap.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ file systems on embedded devices.
2626
- linux,mtd-name: allow to specify the mtd name for retro capability with
2727
physmap-flash drivers as boot loader pass the mtd partition via the old
2828
device name physmap-flash.
29+
- use-advanced-sector-protection: boolean to enable support for the
30+
advanced sector protection (Spansion: PPB - Persistent Protection
31+
Bits) locking.
2932

3033
For JEDEC compatible devices, the following additional properties
3134
are defined:

‎drivers/mtd/Kconfig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ config MTD_REDBOOT_PARTS_READONLY
7474
endif # MTD_REDBOOT_PARTS
7575

7676
config MTD_CMDLINE_PARTS
77-
bool "Command line partition table parsing"
78-
depends on MTD = "y"
77+
tristate "Command line partition table parsing"
78+
depends on MTD
7979
---help---
8080
Allow generic configuration of the MTD partition tables via the kernel
8181
command line. Multiple flash resources are supported for hardware where

‎drivers/mtd/ar7part.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ static int __init ar7_parser_init(void)
142142
return register_mtd_parser(&ar7_parser);
143143
}
144144

145+
static void __exit ar7_parser_exit(void)
146+
{
147+
deregister_mtd_parser(&ar7_parser);
148+
}
149+
145150
module_init(ar7_parser_init);
151+
module_exit(ar7_parser_exit);
146152

147153
MODULE_LICENSE("GPL");
148154
MODULE_AUTHOR( "Felix Fietkau <nbd@openwrt.org>, "

‎drivers/mtd/bcm47xxpart.c‎

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
/* 10 parts were found on sflash on Netgear WNDR4500 */
2020
#define BCM47XXPART_MAX_PARTS 12
2121

22-
/*
23-
* Amount of bytes we read when analyzing each block of flash memory.
24-
* Set it big enough to allow detecting partition and reading important data.
25-
*/
26-
#define BCM47XXPART_BYTES_TO_READ 0x404
27-
2822
/* Magics */
2923
#define BOARD_DATA_MAGIC 0x5246504D /* MPFR */
3024
#define POT_MAGIC1 0x54544f50 /* POTT */
@@ -59,13 +53,21 @@ static int bcm47xxpart_parse(struct mtd_info *master,
5953
uint32_t *buf;
6054
size_t bytes_read;
6155
uint32_t offset;
62-
uint32_t blocksize = 0x10000;
56+
uint32_t blocksize = master->erasesize;
6357
struct trx_header *trx;
58+
int trx_part = -1;
59+
int last_trx_part = -1;
60+
int max_bytes_to_read = 0x8004;
61+
62+
if (blocksize <= 0x10000)
63+
blocksize = 0x10000;
64+
if (blocksize == 0x20000)
65+
max_bytes_to_read = 0x18004;
6466

6567
/* Alloc */
6668
parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS,
6769
GFP_KERNEL);
68-
buf = kzalloc(BCM47XXPART_BYTES_TO_READ, GFP_KERNEL);
70+
buf = kzalloc(max_bytes_to_read, GFP_KERNEL);
6971

7072
/* Parse block by block looking for magics */
7173
for (offset = 0; offset <= master->size - blocksize;
@@ -80,7 +82,7 @@ static int bcm47xxpart_parse(struct mtd_info *master,
8082
}
8183

8284
/* Read beginning of the block */
83-
if (mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
85+
if (mtd_read(master, offset, max_bytes_to_read,
8486
&bytes_read, (uint8_t *)buf) < 0) {
8587
pr_err("mtd_read error while parsing (offset: 0x%X)!\n",
8688
offset);
@@ -95,9 +97,16 @@ static int bcm47xxpart_parse(struct mtd_info *master,
9597
}
9698

9799
/* Standard NVRAM */
98-
if (buf[0x000 / 4] == NVRAM_HEADER) {
100+
if (buf[0x000 / 4] == NVRAM_HEADER ||
101+
buf[0x1000 / 4] == NVRAM_HEADER ||
102+
buf[0x8000 / 4] == NVRAM_HEADER ||
103+
(blocksize == 0x20000 && (
104+
buf[0x10000 / 4] == NVRAM_HEADER ||
105+
buf[0x11000 / 4] == NVRAM_HEADER ||
106+
buf[0x18000 / 4] == NVRAM_HEADER))) {
99107
bcm47xxpart_add_part(&parts[curr_part++], "nvram",
100108
offset, 0);
109+
offset = rounddown(offset, blocksize);
101110
continue;
102111
}
103112

@@ -131,6 +140,10 @@ static int bcm47xxpart_parse(struct mtd_info *master,
131140
if (buf[0x000 / 4] == TRX_MAGIC) {
132141
trx = (struct trx_header *)buf;
133142

143+
trx_part = curr_part;
144+
bcm47xxpart_add_part(&parts[curr_part++], "firmware",
145+
offset, 0);
146+
134147
i = 0;
135148
/* We have LZMA loader if offset[2] points to sth */
136149
if (trx->offset[2]) {
@@ -154,6 +167,8 @@ static int bcm47xxpart_parse(struct mtd_info *master,
154167
offset + trx->offset[i], 0);
155168
i++;
156169

170+
last_trx_part = curr_part - 1;
171+
157172
/*
158173
* We have whole TRX scanned, skip to the next part. Use
159174
* roundown (not roundup), as the loop will increase
@@ -169,11 +184,15 @@ static int bcm47xxpart_parse(struct mtd_info *master,
169184
* Assume that partitions end at the beginning of the one they are
170185
* followed by.
171186
*/
172-
for (i = 0; i < curr_part - 1; i++)
173-
parts[i].size = parts[i + 1].offset - parts[i].offset;
174-
if (curr_part > 0)
175-
parts[curr_part - 1].size =
176-
master->size - parts[curr_part - 1].offset;
187+
for (i = 0; i < curr_part; i++) {
188+
u64 next_part_offset = (i < curr_part - 1) ?
189+
parts[i + 1].offset : master->size;
190+
191+
parts[i].size = next_part_offset - parts[i].offset;
192+
if (i == last_trx_part && trx_part >= 0)
193+
parts[trx_part].size = next_part_offset -
194+
parts[trx_part].offset;
195+
}
177196

178197
*pparts = parts;
179198
return curr_part;

0 commit comments

Comments
 (0)