Skip to content

Commit b426433

Browse files
committed
Merge tag 'mtd/for-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux
Pull MTD updates from Miquel Raynal: "MTD: - Simon Glass wanted to support binman's output properties in order to check their validity using the binding checks and proposed changes with the missing properties as well as a binman compatible. - Krzysztof Kozlowski on his side shared a new yaml for describing Samsung's OneNAND interface. - The interface with NVMEM has also been slightly improved/fixed, especially now that OTP are also supported in the NAND subsystem. - Along with these changes, small cleanups have also been contributed around ID tables, structure sizes, arithmetic checks and comments. Raw NAND subsystem: - Two small fixes, one in the Hynix vendor code for properly returning an error which might have been ignored and another in the Davinci driver to properly synchronize the controller with the gpio domain. SPI NOR subsystem: - SPI NOR now uses div_u64() instead of div64_u64() in places where the divisor is 32 bits. Many 32 bit architectures can optimize this variant better than a full 64 bit divide" * tag 'mtd/for-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: mtd: spi-nor: replace unnecessary div64_u64() with div_u64() mtd: mchp23k256: drop unneeded MODULE_ALIAS dt-bindings: mtd: fixed-partition: Add binman compatibles dt-bindings: mtd: fixed-partitions: Add alignment properties mtd: maps: sa1100-flash: Prefer struct_size over open coded arithmetic mtd: core: Align comment with an action in mtd_otp_nvmem_add() mtd: rawnand: hynix: fixed typo mtd: rawnand: davinci: Add dummy read after sending command mtd: partitions: redboot: Added conversion of operands to a larger type dt-bindings: mtd: Add Samsung S5Pv210 OneNAND mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported mtd: core: Report error if first mtd_otp_size() call fails in mtd_otp_nvmem_add()
2 parents 8b06f75 + 552c938 commit b426433

File tree

11 files changed

+212
-12
lines changed

11 files changed

+212
-12
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/mtd/partitions/binman.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Binman entries
8+
9+
description: |
10+
This corresponds to a binman 'entry'. It is a single partition which holds
11+
data of a defined type.
12+
13+
Binman uses the type to indicate what data file / type to place in the
14+
partition. There are quite a number of binman-specific entry types, such as
15+
section, fill and files, to be added later.
16+
17+
maintainers:
18+
- Simon Glass <[email protected]>
19+
20+
allOf:
21+
- $ref: /schemas/mtd/partitions/partition.yaml#
22+
23+
properties:
24+
compatible:
25+
enum:
26+
- u-boot # u-boot.bin from U-Boot project
27+
- tfa-bl31 # bl31.bin or bl31.elf from TF-A project
28+
29+
required:
30+
- compatible
31+
32+
unevaluatedProperties: false
33+
34+
examples:
35+
- |
36+
partitions {
37+
compatible = "fixed-partitions";
38+
#address-cells = <1>;
39+
#size-cells = <1>;
40+
41+
partition@100000 {
42+
compatible = "u-boot";
43+
reg = <0x100000 0xf00000>;
44+
align-size = <0x1000>;
45+
align-end = <0x10000>;
46+
};
47+
48+
partition@200000 {
49+
compatible = "tfa-bl31";
50+
reg = <0x200000 0x100000>;
51+
align = <0x4000>;
52+
};
53+
};

Documentation/devicetree/bindings/mtd/partitions/partition.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,57 @@ properties:
5757
user space from
5858
type: boolean
5959

60+
align:
61+
$ref: /schemas/types.yaml#/definitions/uint32
62+
minimum: 2
63+
maximum: 0x80000000
64+
multipleOf: 2
65+
description:
66+
This sets the alignment of the entry in bytes.
67+
68+
The entry offset is adjusted so that the entry starts on an aligned
69+
boundary within the containing section or image. For example ‘align =
70+
<16>’ means that the entry will start on a 16-byte boundary. This may
71+
mean that padding is added before the entry. The padding is part of
72+
the containing section but is not included in the entry, meaning that
73+
an empty space may be created before the entry starts. Alignment
74+
must be a power of 2. If ‘align’ is not provided, no alignment is
75+
performed.
76+
77+
align-size:
78+
$ref: /schemas/types.yaml#/definitions/uint32
79+
minimum: 2
80+
maximum: 0x80000000
81+
multipleOf: 2
82+
description:
83+
This sets the alignment of the entry size in bytes. It must be a power
84+
of 2.
85+
86+
For example, to ensure that the size of an entry is a multiple of 64
87+
bytes, set this to 64. While this does not affect the content of the
88+
entry itself (the padding is performed only when its parent section is
89+
assembled), the end result is that the entry ends with the padding
90+
bytes, so may grow. If ‘align-size’ is not provided, no alignment is
91+
performed.
92+
93+
align-end:
94+
$ref: /schemas/types.yaml#/definitions/uint32
95+
minimum: 2
96+
maximum: 0x80000000
97+
multipleOf: 2
98+
description:
99+
This sets the alignment (in bytes) of the end of an entry with respect
100+
to the containing section. It must be a power of 2.
101+
102+
Some entries require that they end on an alignment boundary,
103+
regardless of where they start. This does not move the start of the
104+
entry, so the content of the entry will still start at the beginning.
105+
But there may be padding at the end. While this does not affect the
106+
content of the entry itself (the padding is performed only when its
107+
parent section is assembled), the end result is that the entry ends
108+
with the padding bytes, so may grow. If ‘align-end’ is not provided,
109+
no alignment is performed.
110+
60111
if:
61112
not:
62113
required: [ reg ]
@@ -67,3 +118,24 @@ then:
67118

68119
# This is a generic file other binding inherit from and extend
69120
additionalProperties: true
121+
122+
examples:
123+
- |
124+
partitions {
125+
compatible = "fixed-partitions";
126+
#address-cells = <1>;
127+
#size-cells = <1>;
128+
129+
partition@100000 {
130+
compatible = "u-boot";
131+
reg = <0x100000 0xf00000>;
132+
align-size = <0x1000>;
133+
align-end = <0x10000>;
134+
};
135+
136+
partition@200000 {
137+
compatible = "tfa-bl31";
138+
reg = <0x200000 0x100000>;
139+
align = <0x4000>;
140+
};
141+
};
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/mtd/samsung,s5pv210-onenand.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Samsung S5Pv210 SoC OneNAND Controller
8+
9+
maintainers:
10+
- Krzysztof Kozlowski <[email protected]>
11+
12+
properties:
13+
compatible:
14+
enum:
15+
- samsung,s5pv210-onenand
16+
17+
reg:
18+
items:
19+
- description: Control registers
20+
- description: OneNAND interface nCE[0]
21+
- description: OneNAND interface nCE[1]
22+
23+
clocks:
24+
maxItems: 2
25+
26+
clock-names:
27+
items:
28+
- const: bus
29+
- const: onenand
30+
31+
interrupts:
32+
maxItems: 1
33+
34+
required:
35+
- compatible
36+
- reg
37+
- clocks
38+
- clock-names
39+
- interrupts
40+
41+
allOf:
42+
- $ref: nand-controller.yaml
43+
44+
unevaluatedProperties: false
45+
46+
examples:
47+
- |
48+
#include <dt-bindings/clock/s5pv210.h>
49+
50+
nand-controller@b0600000 {
51+
compatible = "samsung,s5pv210-onenand";
52+
reg = <0xb0600000 0x2000>,
53+
<0xb0000000 0x20000>,
54+
<0xb0040000 0x20000>;
55+
clocks = <&clocks CLK_NANDXL>, <&clocks DOUT_FLASH>;
56+
clock-names = "bus", "onenand";
57+
interrupt-parent = <&vic1>;
58+
interrupts = <31>;
59+
#address-cells = <1>;
60+
#size-cells = <0>;
61+
62+
nand@0 {
63+
reg = <0>;
64+
};
65+
};

MAINTAINERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,6 +3671,11 @@ F: Documentation/filesystems/bfs.rst
36713671
F: fs/bfs/
36723672
F: include/uapi/linux/bfs_fs.h
36733673

3674+
BINMAN
3675+
M: Simon Glass <[email protected]>
3676+
S: Supported
3677+
F: Documentation/devicetree/bindings/mtd/partitions/binman*
3678+
36743679
BITMAP API
36753680
M: Yury Norov <[email protected]>
36763681
R: Rasmus Villemoes <[email protected]>

drivers/mtd/devices/mchp23k256.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,3 @@ module_spi_driver(mchp23k256_driver);
257257
MODULE_DESCRIPTION("MTD SPI driver for MCHP23K256 RAM chips");
258258
MODULE_AUTHOR("Andrew Lunn <[email protected]>");
259259
MODULE_LICENSE("GPL v2");
260-
MODULE_ALIAS("spi:mchp23k256");

drivers/mtd/maps/sa1100-flash.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static struct sa_info *sa1100_setup_mtd(struct platform_device *pdev,
153153
struct flash_platform_data *plat)
154154
{
155155
struct sa_info *info;
156-
int nr, size, i, ret = 0;
156+
int nr, i, ret = 0;
157157

158158
/*
159159
* Count number of devices.
@@ -167,12 +167,10 @@ static struct sa_info *sa1100_setup_mtd(struct platform_device *pdev,
167167
goto out;
168168
}
169169

170-
size = sizeof(struct sa_info) + sizeof(struct sa_subdev_info) * nr;
171-
172170
/*
173171
* Allocate the map_info structs in one go.
174172
*/
175-
info = kzalloc(size, GFP_KERNEL);
173+
info = kzalloc(struct_size(info, subdev, nr), GFP_KERNEL);
176174
if (!info) {
177175
ret = -ENOMEM;
178176
goto out;

drivers/mtd/mtdcore.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,10 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)
956956

957957
if (mtd->_get_user_prot_info && mtd->_read_user_prot_reg) {
958958
size = mtd_otp_size(mtd, true);
959-
if (size < 0)
960-
return size;
959+
if (size < 0) {
960+
err = size;
961+
goto err;
962+
}
961963

962964
if (size > 0) {
963965
nvmem = mtd_otp_nvmem_register(mtd, "user-otp", size,
@@ -1012,6 +1014,9 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)
10121014

10131015
err:
10141016
nvmem_unregister(mtd->otp_user_nvmem);
1017+
/* Don't report error if OTP is not supported. */
1018+
if (err == -EOPNOTSUPP)
1019+
return 0;
10151020
return dev_err_probe(dev, err, "Failed to register OTP NVMEM device\n");
10161021
}
10171022

drivers/mtd/nand/raw/davinci_nand.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,11 @@ static int davinci_nand_exec_instr(struct davinci_nand_info *info,
671671
break;
672672
}
673673

674-
if (instr->delay_ns)
674+
if (instr->delay_ns) {
675+
/* Dummy read to be sure that command is sent before ndelay starts */
676+
davinci_nand_readl(info, 0);
675677
ndelay(instr->delay_ns);
678+
}
676679

677680
return 0;
678681
}

drivers/mtd/nand/raw/nand_hynix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ static int hynix_nand_rr_init(struct nand_chip *chip)
401401
if (ret)
402402
pr_warn("failed to initialize read-retry infrastructure");
403403

404-
return 0;
404+
return ret;
405405
}
406406

407407
static void hynix_nand_extract_oobsize(struct nand_chip *chip,

drivers/mtd/parsers/redboot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
102102
offset -= master->erasesize;
103103
}
104104
} else {
105-
offset = directory * master->erasesize;
105+
offset = (unsigned long) directory * master->erasesize;
106106
while (mtd_block_isbad(master, offset)) {
107107
offset += master->erasesize;
108108
if (offset == master->size)

0 commit comments

Comments
 (0)