dm: pci: Add a function to read a PCI BAR
Add a driver-model function for reading the PCI BAR from a device. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
a0eb835635
commit
bab17cf143
@ -1055,6 +1055,19 @@ int pci_get_regions(struct udevice *dev, struct pci_region **iop,
|
|||||||
return (*iop != NULL) + (*memp != NULL) + (*prefp != NULL);
|
return (*iop != NULL) + (*memp != NULL) + (*prefp != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 dm_pci_read_bar32(struct udevice *dev, int barnum)
|
||||||
|
{
|
||||||
|
u32 addr;
|
||||||
|
int bar;
|
||||||
|
|
||||||
|
bar = PCI_BASE_ADDRESS_0 + barnum * 4;
|
||||||
|
dm_pci_read_config32(dev, bar, &addr);
|
||||||
|
if (addr & PCI_BASE_ADDRESS_SPACE_IO)
|
||||||
|
return addr & PCI_BASE_ADDRESS_IO_MASK;
|
||||||
|
else
|
||||||
|
return addr & PCI_BASE_ADDRESS_MEM_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
UCLASS_DRIVER(pci) = {
|
UCLASS_DRIVER(pci) = {
|
||||||
.id = UCLASS_PCI,
|
.id = UCLASS_PCI,
|
||||||
.name = "pci",
|
.name = "pci",
|
||||||
|
@ -1166,6 +1166,15 @@ struct udevice *pci_get_controller(struct udevice *dev);
|
|||||||
int pci_get_regions(struct udevice *dev, struct pci_region **iop,
|
int pci_get_regions(struct udevice *dev, struct pci_region **iop,
|
||||||
struct pci_region **memp, struct pci_region **prefp);
|
struct pci_region **memp, struct pci_region **prefp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dm_pci_read_bar32() - read a base address register from a device
|
||||||
|
*
|
||||||
|
* @dev: Device to check
|
||||||
|
* @barnum: Bar number to read (numbered from 0)
|
||||||
|
* @return: value of BAR
|
||||||
|
*/
|
||||||
|
u32 dm_pci_read_bar32(struct udevice *dev, int barnum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dm_pci_find_device() - find a device by vendor/device ID
|
* dm_pci_find_device() - find a device by vendor/device ID
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user