Skip to content

Commit 05ff8c2

Browse files
Joe SchaackDavid Woodhouse
authored andcommitted
mtd: ofpart: support partitions of 4 GiB and larger
Previously, partitions were limited to less than 4 GiB in size because the address and size were read as 32-bit values. Add support for 64-bit values to support devices of 4 GiB and larger. Signed-off-by: Joe Schaack <jschaack@xes-inc.com> Signed-off-by: Nate Case <ncase@xes-inc.com> Signed-off-by: Aaron Sierra <asierra@xes-inc.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent e66e280 commit 05ff8c2

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

Documentation/devicetree/bindings/mtd/partition.txt

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ on platforms which have strong conventions about which portions of a flash are
55
used for what purposes, but which don't use an on-flash partition table such
66
as RedBoot.
77

8-
#address-cells & #size-cells must both be present in the mtd device and be
9-
equal to 1.
8+
#address-cells & #size-cells must both be present in the mtd device. There are
9+
two valid values for both:
10+
<1>: for partitions that require a single 32-bit cell to represent their
11+
size/address (aka the value is below 4 GiB)
12+
<2>: for partitions that require two 32-bit cells to represent their
13+
size/address (aka the value is 4 GiB or greater).
1014

1115
Required properties:
1216
- reg : The partition's offset and size within the mtd bank.
@@ -36,3 +40,31 @@ flash@0 {
3640
reg = <0x0100000 0x200000>;
3741
};
3842
};
43+
44+
flash@1 {
45+
#address-cells = <1>;
46+
#size-cells = <2>;
47+
48+
/* a 4 GiB partition */
49+
partition@0 {
50+
label = "filesystem";
51+
reg = <0x00000000 0x1 0x00000000>;
52+
};
53+
};
54+
55+
flash@2 {
56+
#address-cells = <2>;
57+
#size-cells = <2>;
58+
59+
/* an 8 GiB partition */
60+
partition@0 {
61+
label = "filesystem #1";
62+
reg = <0x0 0x00000000 0x2 0x00000000>;
63+
};
64+
65+
/* a 4 GiB partition */
66+
partition@200000000 {
67+
label = "filesystem #2";
68+
reg = <0x2 0x00000000 0x1 0x00000000>;
69+
};
70+
};

drivers/mtd/ofpart.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,18 @@ static int parse_ofpart_partitions(struct mtd_info *master,
5555
while ((pp = of_get_next_child(node, pp))) {
5656
const __be32 *reg;
5757
int len;
58+
int a_cells, s_cells;
5859

5960
reg = of_get_property(pp, "reg", &len);
6061
if (!reg) {
6162
nr_parts--;
6263
continue;
6364
}
6465

65-
(*pparts)[i].offset = be32_to_cpu(reg[0]);
66-
(*pparts)[i].size = be32_to_cpu(reg[1]);
66+
a_cells = of_n_addr_cells(pp);
67+
s_cells = of_n_size_cells(pp);
68+
(*pparts)[i].offset = of_read_number(reg, a_cells);
69+
(*pparts)[i].size = of_read_number(reg + a_cells, s_cells);
6770

6871
partname = of_get_property(pp, "label", &len);
6972
if (!partname)

0 commit comments

Comments
 (0)