mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-23 05:08:24 +00:00
sandbox: pci: Move pci_offset_to_barnum() to pci.h
This function is useful in PCI emulators. More it into the header file to avoid duplicating it in other drivers. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
fae2c16ede
commit
37a1cf9c9c
2 changed files with 6 additions and 5 deletions
|
@ -24,9 +24,6 @@ struct swap_case_platdata {
|
||||||
u32 bar[6];
|
u32 bar[6];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define offset_to_barnum(offset) \
|
|
||||||
(((offset) - PCI_BASE_ADDRESS_0) / sizeof(u32))
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MEM_TEXT_SIZE = 0x100,
|
MEM_TEXT_SIZE = 0x100,
|
||||||
};
|
};
|
||||||
|
@ -144,7 +141,7 @@ static int sandbox_swap_case_read_config(struct udevice *emul, uint offset,
|
||||||
int barnum;
|
int barnum;
|
||||||
u32 *bar, result;
|
u32 *bar, result;
|
||||||
|
|
||||||
barnum = offset_to_barnum(offset);
|
barnum = pci_offset_to_barnum(offset);
|
||||||
bar = &plat->bar[barnum];
|
bar = &plat->bar[barnum];
|
||||||
|
|
||||||
result = *bar;
|
result = *bar;
|
||||||
|
@ -224,7 +221,7 @@ static int sandbox_swap_case_write_config(struct udevice *emul, uint offset,
|
||||||
int barnum;
|
int barnum;
|
||||||
u32 *bar;
|
u32 *bar;
|
||||||
|
|
||||||
barnum = offset_to_barnum(offset);
|
barnum = pci_offset_to_barnum(offset);
|
||||||
bar = &plat->bar[barnum];
|
bar = &plat->bar[barnum];
|
||||||
|
|
||||||
debug("w bar %d=%lx\n", barnum, value);
|
debug("w bar %d=%lx\n", barnum, value);
|
||||||
|
|
|
@ -215,6 +215,10 @@
|
||||||
#define PCI_BASE_ADDRESS_IO_MASK (~0x03ULL)
|
#define PCI_BASE_ADDRESS_IO_MASK (~0x03ULL)
|
||||||
/* bit 1 is reserved if address_space = 1 */
|
/* bit 1 is reserved if address_space = 1 */
|
||||||
|
|
||||||
|
/* Convert a regsister address (e.g. PCI_BASE_ADDRESS_1) to a bar # (e.g. 1) */
|
||||||
|
#define pci_offset_to_barnum(offset) \
|
||||||
|
(((offset) - PCI_BASE_ADDRESS_0) / sizeof(u32))
|
||||||
|
|
||||||
/* Header type 0 (normal devices) */
|
/* Header type 0 (normal devices) */
|
||||||
#define PCI_CARDBUS_CIS 0x28
|
#define PCI_CARDBUS_CIS 0x28
|
||||||
#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
|
#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
|
||||||
|
|
Loading…
Add table
Reference in a new issue