diff options
author | Simon Glass <sjg@chromium.org> | 2019-09-25 08:56:42 -0600 |
---|---|---|
committer | Bin Meng <bmeng.cn@gmail.com> | 2019-10-08 13:57:48 +0800 |
commit | 75d8f49481a5c260d0cf1024d41f0b29d57e0efe (patch) | |
tree | f434a546d0cc97e9cad48f59e54902d1307fad24 /drivers/misc/swap_case.c | |
parent | 594d272cfd3dc43f118efb952676715b0382af24 (diff) | |
download | u-boot-75d8f49481a5c260d0cf1024d41f0b29d57e0efe.zip u-boot-75d8f49481a5c260d0cf1024d41f0b29d57e0efe.tar.gz u-boot-75d8f49481a5c260d0cf1024d41f0b29d57e0efe.tar.bz2 |
sandbox: pci: Create a new sandbox_pci_read_bar() function
The code in swapcase can be used by other sandbox drivers. Move it into a
common place to allow this.
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: remove inclusion of <asm/test.h> in pci_sandbox.c]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/misc/swap_case.c')
-rw-r--r-- | drivers/misc/swap_case.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c index 75fe641..11189d1 100644 --- a/drivers/misc/swap_case.c +++ b/drivers/misc/swap_case.c @@ -139,25 +139,13 @@ static int sandbox_swap_case_read_config(struct udevice *emul, uint offset, case PCI_BASE_ADDRESS_4: case PCI_BASE_ADDRESS_5: { int barnum; - u32 *bar, result; + u32 *bar; barnum = pci_offset_to_barnum(offset); bar = &plat->bar[barnum]; - result = *bar; - if (*bar == 0xffffffff) { - if (barinfo[barnum].type) { - result = (~(barinfo[barnum].size - 1) & - PCI_BASE_ADDRESS_IO_MASK) | - PCI_BASE_ADDRESS_SPACE_IO; - } else { - result = (~(barinfo[barnum].size - 1) & - PCI_BASE_ADDRESS_MEM_MASK) | - PCI_BASE_ADDRESS_MEM_TYPE_32; - } - } - debug("r bar %d=%x\n", barnum, result); - *valuep = result; + *valuep = sandbox_pci_read_bar(*bar, barinfo[barnum].type, + barinfo[barnum].size); break; } case PCI_CAPABILITY_LIST: |