Commit 6fb77c48e40c15afcc67bb8d3b5d7d300883d293

Authored by Maxime Ripard
Committed by Tom Rini
1 parent bf8940d35b

fastboot: nand: Add pre erase and write hooks

Some devices might need to do some per-partition initialization
(ECC/Randomizer settings change for example) before actually accessing it.

Add some hooks before the write and erase operations to let the boards
define what they need to do if needed.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

Showing 1 changed file with 18 additions and 0 deletions Side-by-side Diff

... ... @@ -23,6 +23,16 @@
23 23 struct part_info *part;
24 24 };
25 25  
  26 +__weak int board_fastboot_erase_partition_setup(char *name)
  27 +{
  28 + return 0;
  29 +}
  30 +
  31 +__weak int board_fastboot_write_partition_setup(char *name)
  32 +{
  33 + return 0;
  34 +}
  35 +
26 36 static int fb_nand_lookup(const char *partname, char *response,
27 37 nand_info_t **nand,
28 38 struct part_info **part)
... ... @@ -134,6 +144,10 @@
134 144 return;
135 145 }
136 146  
  147 + ret = board_fastboot_write_partition_setup(part->name);
  148 + if (ret)
  149 + return;
  150 +
137 151 if (is_sparse_image(download_buffer)) {
138 152 struct fb_nand_sparse sparse_priv;
139 153 sparse_storage_t sparse;
... ... @@ -183,6 +197,10 @@
183 197 fastboot_fail(response_str, "invalid NAND device");
184 198 return;
185 199 }
  200 +
  201 + ret = board_fastboot_erase_partition_setup(part->name);
  202 + if (ret)
  203 + return;
186 204  
187 205 ret = _fb_nand_erase(nand, part);
188 206 if (ret) {