cfi_flash: Fix devicetree address determination
authorAndre Przywara <andre.przywara@arm.com>
Wed, 23 Sep 2020 23:22:04 +0000 (00:22 +0100)
committerStefan Roese <sr@denx.de>
Thu, 8 Oct 2020 07:04:41 +0000 (09:04 +0200)
commit492b9917c684bbfd42479e049c00b1e502f8b53f
treee29ff9dae84eb821a4d07aac33a6939c82eb2a2d
parent3f891a103c5c90c186a5a0b1584dfa39e8688b8f
cfi_flash: Fix devicetree address determination

The cfi-flash driver uses an open-coded version of the generic
algorithm to decode and translate multiple frames of a "reg" property.

This starts off the wrong foot by using the address-cells and size-cells
properties of *this* very node, and not of the parent. This somewhat
happened to work back when we were using a wrong default size of 2,
but broke about a year ago with commit 0ba41ce1b781 ("libfdt: return
correct value if #size-cells property is not present").

Instead of fixing the reinvented wheel, just use the generic function
that does all of this properly.

This fixes U-Boot on QEMU (-arm64), which was crashing due to decoding
a wrong flash base address:
DRAM:  1 GiB
Flash: "Synchronous Abort" handler, esr 0x96000044
elr: 00000000000211dc lr : 00000000000211b0 (reloc)
elr: 000000007ff5e1dc lr : 000000007ff5e1b0
x0 : 00000000000000f0 x1 : 000000007ff5e1d8
x2 : 000000007edfbc48 x3 : 0000000000000000
x4 : 0000000000000000 x5 : 00000000000000f0
x6 : 000000007edfbc2c x7 : 0000000000000000
x8 : 000000007ffd8d70 x9 : 000000000000000c
x10: 0400000000000003 x11: 0000000000000055
     ^^^^^^^^^^^^^^^^

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Stefan Roese <sr@denx.de>
drivers/mtd/cfi_flash.c