Skip to content

Commit f4e70c2

Browse files
committed
Merge tag 'mtd/for-4.18' of git://git.infradead.org/linux-mtd
Pull MTD updates from Boris Brezillon: "Core changes: - Add a sysfs attribute to expose available OOB size Driver changes: - Remove HAS_DMA dependency on various drivers - Use dev_get_drvdata() instead of platform_get_drvdata() in docg3 - Replace msleep by usleep_range() in the dataflash driver - Avoid VLA usage in nftl layers - Remove useless .owner assignment in pismo - Fix various issues in the CFI driver - Improve TRX partition handling expose a DT compat for this part parser - Clarify OFFSET_CONTINUOUS meaning NAND core changes: - Add Miquel as a NAND maintainer - Add access mode to the nand_page_io_req struct - Fix kernel-doc in rawnand.h - Support bit-wise majority to recover from corrupted ONFI parameter pages - Stop checking FAIL bit after a SET_FEATURES, as documented in the ONFI spec Raw NAND Driver changes: - Fix and cleanup the error path of many NAND controller drivers - GPMI: + Cleanup/simplification of a few aspects in the driver + Take ECC setup specified in the DT into account - sunxi: remove support for GPIO-based R/B polling - MTK: + Use of_device_get_match_data() instead of of_match_device() + Add an entry in MAINTAINERS for this driver + Fix nand-ecc-step-size and nand-ecc-strength description in the DT bindings doc - fsl_ifc: fix ->cmdfunc() to read more than one ONFI parameter page OneNAND driver changes: - samsung: use dev_get_drvdata() instead of platform_get_drvdata() SPI NOR core changes: - Add support for a bunch of SPI NOR chips - Clear EAR reg when switching to 3-byte addressing mode on Winbond chips SPI NOR controller driver changes: - cadence: Add DMA support for direct mode reads - hisi: Prefix a few functions with hisi_ - intel: + Mark the driver as "dangerous" in Kconfig + Fix atomic sequence handling + Pass a 40us delay (instead of 0us) to readl_poll_timeout() - fsl: + fix a typo in a function name + add support for IP variants embedded in the ls2080a and ls1080a SoCs - stm32: request exclusive control of the reset line" * tag 'mtd/for-4.18' of git://git.infradead.org/linux-mtd: (66 commits) mtd: nand: Pass mode information to nand_page_io_req mtd: cfi_cmdset_0002: Change erase one block to enable XIP once mtd: cfi_cmdset_0002: Change erase functions to check chip good only mtd: cfi_cmdset_0002: Change erase functions to retry for error mtd: cfi_cmdset_0002: Change definition naming to retry write operation mtd: cfi_cmdset_0002: Change write buffer to check correct value mtd: cmdlinepart: Update comment for introduction of OFFSET_CONTINUOUS mtd: bcm47xxpart: add of_match_table with a new DT binding dt-bindings: mtd: document Broadcom's BCM47xx partitions mtd: spi-nor: Add support for EN25QH32 mtd: spi-nor: Add support for is25wp series chips mtd: spi-nor: Add Winbond w25q32jv support mtd: spi-nor: fsl-quadspi: add support for ls2080a/ls1080a mtd: spi-nor: stm32-quadspi: explicitly request exclusive reset control mtd: spi-nor: intel: provide a range for poll_timout mtd: spi-nor: fsl-quadspi: fix api naming typo _init_ahb_read mtd: spi-nor: intel-spi: Explicitly mark the driver as dangerous in Kconfig mtd: spi-nor: intel-spi: Fix atomic sequence handling mtd: rawnand: Do not check FAIL bit when executing a SET_FEATURES op mtd: rawnand: use bit-wise majority to recover the ONFI param page ...
2 parents ea125de + b771327 commit f4e70c2

46 files changed

Lines changed: 773 additions & 536 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/ABI/testing/sysfs-class-mtd‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,11 @@ Description:
232232
of the parent (another partition or a flash device) in bytes.
233233
This attribute is absent on flash devices, so it can be used
234234
to distinguish them from partitions.
235+
236+
What: /sys/class/mtd/mtdX/oobavail
237+
Date: April 2018
238+
KernelVersion: 4.16
239+
Contact: linux-mtd@lists.infradead.org
240+
Description:
241+
Number of bytes available for a client to place data into
242+
the out of band area.

‎Documentation/devicetree/bindings/mtd/gpmi-nand.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ Optional properties:
4747
partitions written from Linux with this feature
4848
turned on may not be accessible by the BootROM
4949
code.
50+
- nand-ecc-strength: integer representing the number of bits to correct
51+
per ECC step. Needs to be a multiple of 2.
52+
- nand-ecc-step-size: integer representing the number of data bytes
53+
that are covered by a single ECC step. The driver
54+
supports 512 and 1024.
5055

5156
The device tree may optionally contain sub-nodes describing partitions of the
5257
address space. See partition.txt for more detail.

‎Documentation/devicetree/bindings/mtd/mtk-nand.txt‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,19 @@ Optional:
4848
- nand-on-flash-bbt: Store BBT on NAND Flash.
4949
- nand-ecc-mode: the NAND ecc mode (check driver for supported modes)
5050
- nand-ecc-step-size: Number of data bytes covered by a single ECC step.
51-
valid values: 512 and 1024.
51+
valid values:
52+
512 and 1024 on mt2701 and mt2712.
53+
512 only on mt7622.
5254
1024 is recommended for large page NANDs.
5355
- nand-ecc-strength: Number of bits to correct per ECC step.
54-
The valid values that the controller supports are: 4, 6,
55-
8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 44,
56-
48, 52, 56, 60.
56+
The valid values that each controller supports:
57+
mt2701: 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28,
58+
32, 36, 40, 44, 48, 52, 56, 60.
59+
mt2712: 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28,
60+
32, 36, 40, 44, 48, 52, 56, 60, 68, 72, 80.
61+
mt7622: 4, 6, 8, 10, 12, 14, 16.
5762
The strength should be calculated as follows:
58-
E = (S - F) * 8 / 14
63+
E = (S - F) * 8 / B
5964
S = O / (P / Q)
6065
E : nand-ecc-strength.
6166
S : spare size per sector.
@@ -64,6 +69,15 @@ Optional:
6469
O : oob size.
6570
P : page size.
6671
Q : nand-ecc-step-size.
72+
B : number of parity bits needed to correct
73+
1 bitflip.
74+
According to MTK NAND controller design,
75+
this number depends on max ecc step size
76+
that MTK NAND controller supports.
77+
If max ecc step size supported is 1024,
78+
then it should be always 14. And if max
79+
ecc step size is 512, then it should be
80+
always 13.
6781
If the result does not match any one of the listed
6882
choices above, please select the smaller valid value from
6983
the list.

‎Documentation/devicetree/bindings/mtd/partition.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ method is used for a given flash device. To describe the method there should be
1414
a subnode of the flash device that is named 'partitions'. It must have a
1515
'compatible' property, which is used to identify the method to use.
1616

17-
We currently only document a binding for fixed layouts.
17+
Available bindings are listed in the "partitions" subdirectory.
1818

1919

2020
Fixed Partitions
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Broadcom BCM47xx Partitions
2+
===========================
3+
4+
Broadcom is one of hardware manufacturers providing SoCs (BCM47xx) used in
5+
home routers. Their BCM947xx boards using CFE bootloader have several partitions
6+
without any on-flash partition table. On some devices their sizes and/or
7+
meanings can also vary so fixed partitioning can't be used.
8+
9+
Discovering partitions on these devices is possible thanks to having a special
10+
header and/or magic signature at the beginning of each of them. They are also
11+
block aligned which is important for determinig a size.
12+
13+
Most of partitions use ASCII text based magic for determining a type. More
14+
complex partitions (like TRX with its HDR0 magic) may include extra header
15+
containing some details, including a length.
16+
17+
A list of supported partitions includes:
18+
1) Bootloader with Broadcom's CFE (Common Firmware Environment)
19+
2) NVRAM with configuration/calibration data
20+
3) Device manufacturer's data with some default values (e.g. SSIDs)
21+
4) TRX firmware container which can hold up to 4 subpartitions
22+
5) Backup TRX firmware used after failed upgrade
23+
24+
As mentioned earlier, role of some partitions may depend on extra configuration.
25+
For example both: main firmware and backup firmware use the same TRX format with
26+
the same header. To distinguish currently used firmware a CFE's environment
27+
variable "bootpartition" is used.
28+
29+
30+
Devices using Broadcom partitions described above should should have flash node
31+
with a subnode named "partitions" using following properties:
32+
33+
Required properties:
34+
- compatible : (required) must be "brcm,bcm947xx-cfe-partitions"
35+
36+
Example:
37+
38+
flash@0 {
39+
partitions {
40+
compatible = "brcm,bcm947xx-cfe-partitions";
41+
};
42+
};

‎Documentation/devicetree/bindings/mtd/sunxi-nand.txt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ Optional properties:
2222
- reset : phandle + reset specifier pair
2323
- reset-names : must contain "ahb"
2424
- allwinner,rb : shall contain the native Ready/Busy ids.
25-
or
26-
- rb-gpios : shall contain the gpios used as R/B pins.
2725
- nand-ecc-mode : one of the supported ECC modes ("hw", "soft", "soft_bch" or
2826
"none")
2927

‎MAINTAINERS‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9022,6 +9022,13 @@ L: linux-wireless@vger.kernel.org
90229022
S: Maintained
90239023
F: drivers/net/wireless/mediatek/mt7601u/
90249024

9025+
MEDIATEK NAND CONTROLLER DRIVER
9026+
M: Xiaolei Li <xiaolei.li@mediatek.com>
9027+
L: linux-mtd@lists.infradead.org
9028+
S: Maintained
9029+
F: drivers/mtd/nand/raw/mtk_*
9030+
F: Documentation/devicetree/bindings/mtd/mtk-nand.txt
9031+
90259032
MEDIATEK RANDOM NUMBER GENERATOR SUPPORT
90269033
M: Sean Wang <sean.wang@mediatek.com>
90279034
S: Maintained
@@ -9666,6 +9673,7 @@ F: drivers/net/ethernet/myricom/myri10ge/
96669673

96679674
NAND FLASH SUBSYSTEM
96689675
M: Boris Brezillon <boris.brezillon@bootlin.com>
9676+
M: Miquel Raynal <miquel.raynal@bootlin.com>
96699677
R: Richard Weinberger <richard@nod.at>
96709678
L: linux-mtd@lists.infradead.org
96719679
W: http://www.linux-mtd.infradead.org/

‎drivers/mtd/bcm47xxpart.c‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ static int bcm47xxpart_parse(struct mtd_info *master,
186186
/* TRX */
187187
if (buf[0x000 / 4] == TRX_MAGIC) {
188188
struct trx_header *trx;
189+
uint32_t last_subpart;
190+
uint32_t trx_size;
189191

190192
if (trx_num >= ARRAY_SIZE(trx_parts))
191193
pr_warn("No enough space to store another TRX found at 0x%X\n",
@@ -195,11 +197,23 @@ static int bcm47xxpart_parse(struct mtd_info *master,
195197
bcm47xxpart_add_part(&parts[curr_part++], "firmware",
196198
offset, 0);
197199

198-
/* Jump to the end of TRX */
200+
/*
201+
* Try to find TRX size. The "length" field isn't fully
202+
* reliable as it could be decreased to make CRC32 cover
203+
* only part of TRX data. It's commonly used as checksum
204+
* can't cover e.g. ever-changing rootfs partition.
205+
* Use offsets as helpers for assuming min TRX size.
206+
*/
199207
trx = (struct trx_header *)buf;
200-
offset = roundup(offset + trx->length, blocksize);
201-
/* Next loop iteration will increase the offset */
202-
offset -= blocksize;
208+
last_subpart = max3(trx->offset[0], trx->offset[1],
209+
trx->offset[2]);
210+
trx_size = max(trx->length, last_subpart + blocksize);
211+
212+
/*
213+
* Skip the TRX data. Decrease offset by block size as
214+
* the next loop iteration will increase it.
215+
*/
216+
offset += roundup(trx_size, blocksize) - blocksize;
203217
continue;
204218
}
205219

@@ -290,9 +304,16 @@ static int bcm47xxpart_parse(struct mtd_info *master,
290304
return curr_part;
291305
};
292306

307+
static const struct of_device_id bcm47xxpart_of_match_table[] = {
308+
{ .compatible = "brcm,bcm947xx-cfe-partitions" },
309+
{},
310+
};
311+
MODULE_DEVICE_TABLE(of, bcm47xxpart_of_match_table);
312+
293313
static struct mtd_part_parser bcm47xxpart_mtd_parser = {
294314
.parse_fn = bcm47xxpart_parse,
295315
.name = "bcm47xxpart",
316+
.of_match_table = bcm47xxpart_of_match_table,
296317
};
297318
module_mtd_part_parser(bcm47xxpart_mtd_parser);
298319

0 commit comments

Comments
 (0)