of: pci: import of_pci_get_devfn()
Marvell MVEBU PCIe driver requires of_pcie_get_devfn(), import it from Linux. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Acked-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
916ca9472f
commit
846da3d7df
|
@ -27,6 +27,12 @@ config OF_GPIO
|
|||
depends on OFDEVICE
|
||||
def_bool y
|
||||
|
||||
config OF_PCI
|
||||
bool
|
||||
depends on PCI
|
||||
help
|
||||
OpenFirmware PCI bus accessors
|
||||
|
||||
config OF_BAREBOX_DRIVERS
|
||||
depends on OFDEVICE
|
||||
depends on ENV_HANDLING
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
obj-y += address.o base.o fdt.o platform.o
|
||||
obj-$(CONFIG_OFTREE_MEM_GENERIC) += mem_generic.o
|
||||
obj-$(CONFIG_OF_GPIO) += of_gpio.o
|
||||
obj-$(CONFIG_OF_PCI) += of_pci.o
|
||||
obj-y += partition.o
|
||||
obj-y += of_net.o
|
||||
obj-$(CONFIG_MTD) += of_mtd.o
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#include <common.h>
|
||||
#include <errno.h>
|
||||
#include <of.h>
|
||||
#include <of_pci.h>
|
||||
|
||||
/**
|
||||
* of_pci_get_devfn() - Get device and function numbers for a device node
|
||||
* @np: device node
|
||||
*
|
||||
* Parses a standard 5-cell PCI resource and returns an 8-bit value that can
|
||||
* be passed to the PCI_SLOT() and PCI_FUNC() macros to extract the device
|
||||
* and function numbers respectively. On error a negative error code is
|
||||
* returned.
|
||||
*/
|
||||
int of_pci_get_devfn(struct device_node *np)
|
||||
{
|
||||
unsigned int size;
|
||||
const __be32 *reg;
|
||||
|
||||
reg = of_get_property(np, "reg", &size);
|
||||
|
||||
if (!reg || size < 5 * sizeof(__be32))
|
||||
return -EINVAL;
|
||||
|
||||
return (be32_to_cpup(reg) >> 8) & 0xff;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_pci_get_devfn);
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef __OF_PCI_H
|
||||
#define __OF_PCI_H
|
||||
|
||||
#include <linux/pci.h>
|
||||
|
||||
#ifdef CONFIG_OF_PCI
|
||||
int of_pci_get_devfn(struct device_node *np);
|
||||
|
||||
#else
|
||||
static inline int of_pci_get_devfn(struct device_node *np)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue