1# Copyright (c) 2023 Bjarki Arge Andreasen
2# SPDX-License-Identifier: Apache-2.0
3
4description: |
5  This binding describes the Atmel SAM flash area layout.
6
7  The Atmel SAM flash area varies in write-block-size, memory area,
8  and the layout of erase-blocks.
9
10  E.g. the flash area layout of the ATSAM4E16C:
11
12    |--------------------|
13    | 8 Kbytes           |  erase block size = 2048
14    |--------------------|
15    | 8 Kbytes           |  erase block size = 2048
16    |--------------------|
17    | 48 Kbytes          |  erase block size = 4096
18    |--------------------|
19    | 64 Kbytes          |  erase block size = 4096
20    |--------------------|
21    | ...                |
22
23  The ATSAM4E16C has a flash area which is 1000Kbytes
24  (1024 * 1024 bytes) with a write-block-size of 8 bytes. The first
25  16 Kbytes can be erased in blocks of 2048 bytes
26  (8 blocks of 2048 bytes), the remaining flash area is erasable
27  in blocks of 4096 bytes (252 blocks of 4096 bytes).
28
29  This flash area layout would described as:
30
31    / {
32      soc {
33        eefc: flash-controller@400e0a00 {
34        compatible = "atmel,sam-flash-controller";
35        reg = <0x400e0a00 0x200>;
36        clocks = <&pmc PMC_TYPE_PERIPHERAL 6>;
37        status = "okay";
38
39        #address-cells = <1>;
40        #size-cells = <1>;
41        #erase-block-cells = <2>;
42
43        flash0: flash@400000 {
44          compatible = "atmel,sam-flash", "soc-nv-flash";
45          reg = <0x400000 0x100000>;
46          write-block-size = <8>;
47          erase-block-size = <4096>;
48          erase-blocks = <&eefc 8 2048>, <&eefc 252 4096>;
49        };
50      };
51    };
52
53  Notes:
54    The flash area layout node flash0 should have both this
55    compatible, "atmel,sam-flash", and the "soc-nv-flash"
56    compatible. The latter is used from mcuboot and other
57    modules to identify the flash area.
58
59    If partitions are used, remember that their addresses are
60    offsets relative to the flash area address.  E.g. using
61    mcuboot and a allocating a storage partition:
62
63      &flash0 {
64        partitions {
65          compatible = "fixed-partitions";
66          #address-cells = <1>;
67          #size-cells = <1>;
68
69          boot_partition: partition@0 {
70            label = "mcuboot";
71            reg = <0x0 0x10000>;
72          };
73
74          slot0_partition: partition@10000 {
75            label = "slot0";
76            reg = <0x10000 0x70000>;
77          };
78
79          slot1_partition: partition@80000 {
80            label = "slot1";
81            reg = <0x80000 0x70000>;
82          };
83
84          storage_partition: partition@f0000 {
85            label = "storage";
86            reg = <0xf0000 0x100000>;
87          };
88        };
89      };
90
91compatible: "atmel,sam-flash"
92
93include: base.yaml
94
95properties:
96  write-block-size:
97    type: int
98    description: |
99      The flash controller is limited by hardware to writing blocks of
100      this size, aligned to this size, in bytes, to previously erased
101      flash, within the flash memory area.
102
103  erase-block-size:
104    type: int
105    description: |
106      The flash controller is limited by hardware to erase whole
107      blocks of flash at a time. This property describes the largest
108      erase block size in erase-blocks.
109
110  erase-blocks:
111    type: phandle-array
112    required: true
113    description: |
114      The flash controller is limited by hardware to erase whole
115      blocks of flash at a time. This property describes the layout of
116      the erase-blocks, which can vary in size within the flash memory
117      area.
118