diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-07 06:14:59 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-07 06:14:59 +0200 |
commit | f1ee4e8b73a356278056666da8d0c6b5aa53088d (patch) | |
tree | 160f8440f19bd0702aed7323900e7412ea11ff0f /drivers/of | |
parent | c138893990013fa9f3008325fdf4fd8ac0628ba2 (diff) | |
parent | 11b34ab22f4072db0cdbf605d6ffbd472618175b (diff) | |
download | barebox-f1ee4e8b73a356278056666da8d0c6b5aa53088d.tar.gz barebox-f1ee4e8b73a356278056666da8d0c6b5aa53088d.tar.xz |
Merge branch 'for-next/marvell'
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/Kconfig | 6 | ||||
-rw-r--r-- | drivers/of/Makefile | 1 | ||||
-rw-r--r-- | drivers/of/of_pci.c | 27 |
3 files changed, 34 insertions, 0 deletions
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 2b28cf3fb4..81955063d7 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -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 diff --git a/drivers/of/Makefile b/drivers/of/Makefile index c883e516c8..0dc2f8d63e 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -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 diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c new file mode 100644 index 0000000000..2d0fbd2e5f --- /dev/null +++ b/drivers/of/of_pci.c @@ -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); |