dm: pci: Add a function to read a PCI BAR

At present PCI address transaction is not supported so drivers must
manually read the correct BAR after reading the device tree info. The
ns16550 has a suitable implementation, so move this code into the core
DM support.

Note that there is no live-tree equivalent at present.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: correct the unclear comments in test.dts]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index b6d0960..25cac05 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -456,12 +456,15 @@
 		};
 		pci@1,0 {
 			compatible = "pci-generic";
-			reg = <0x0800 0 0 0 0>;
+			/* reg 0 is at 0x14, using FDT_PCI_SPACE_MEM32 */
+			reg = <0x02000814 0 0 0 0
+			       0x01000810 0 0 0 0>;
 			sandbox,emul = <&swap_case_emul0_1>;
 		};
 		pci@1f,0 {
 			compatible = "pci-generic";
-			reg = <0xf800 0 0 0 0>;
+			/* reg 0 is at 0x10, using FDT_PCI_SPACE_IO */
+			reg = <0x0100f810 0 0 0 0>;
 			sandbox,emul = <&swap_case_emul0_1f>;
 		};
 	};