summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/pciaccess.h2
-rw-r--r--src/common_interface.c11
-rw-r--r--src/linux_sysfs.c25
-rw-r--r--src/pciaccess_private.h1
4 files changed, 38 insertions, 1 deletions
diff --git a/include/pciaccess.h b/include/pciaccess.h
index de8b4b3..cf32876 100644
--- a/include/pciaccess.h
+++ b/include/pciaccess.h
@@ -110,6 +110,8 @@ const char *pci_device_get_subdevice_name(const struct pci_device *dev);
const char *pci_device_get_vendor_name(const struct pci_device *dev);
const char *pci_device_get_subvendor_name(const struct pci_device *dev);
+void pci_device_enable(struct pci_device *dev);
+
int pci_device_cfg_read (struct pci_device *dev, void *data,
pciaddr_t offset, pciaddr_t size, pciaddr_t *bytes_read);
int pci_device_cfg_read_u8 (struct pci_device *dev, uint8_t *data,
diff --git a/src/common_interface.c b/src/common_interface.c
index aee2754..663ab44 100644
--- a/src/common_interface.c
+++ b/src/common_interface.c
@@ -604,3 +604,14 @@ pci_device_cfg_write_bits( struct pci_device * dev, uint32_t mask,
return err;
}
+
+void
+pci_device_enable(struct pci_device *dev)
+{
+ if (dev == NULL) {
+ return;
+ }
+
+ if (pci_sys->methods->enable)
+ pci_sys->methods->enable(dev);
+}
diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
index 78584d6..5fa0ea1 100644
--- a/src/linux_sysfs.c
+++ b/src/linux_sysfs.c
@@ -55,6 +55,8 @@
#include "pciaccess_private.h"
#include "linux_devmem.h"
+static void pci_device_linux_sysfs_enable(struct pci_device *dev);
+
static int pci_device_linux_sysfs_read_rom( struct pci_device * dev,
void * buffer );
@@ -84,7 +86,8 @@ static const struct pci_system_methods linux_sysfs_methods = {
.read = pci_device_linux_sysfs_read,
.write = pci_device_linux_sysfs_write,
- .fill_capabilities = pci_fill_capabilities_generic
+ .fill_capabilities = pci_fill_capabilities_generic,
+ .enable = pci_device_linux_sysfs_enable,
};
#define SYS_BUS_PCI "/sys/bus/pci/devices"
@@ -622,3 +625,23 @@ pci_device_linux_sysfs_unmap_range(struct pci_device *dev,
return err;
}
+
+static void pci_device_linux_sysfs_enable(struct pci_device *dev)
+{
+ char name[256];
+ int fd;
+
+ snprintf( name, 255, "%s/%04x:%02x:%02x.%1u/enable",
+ SYS_BUS_PCI,
+ dev->domain,
+ dev->bus,
+ dev->dev,
+ dev->func );
+
+ fd = open( name, O_RDWR );
+ if (fd == -1)
+ return;
+
+ write( fd, "1", 1 );
+ close(fd);
+}
diff --git a/src/pciaccess_private.h b/src/pciaccess_private.h
index 494f577..6048af1 100644
--- a/src/pciaccess_private.h
+++ b/src/pciaccess_private.h
@@ -59,6 +59,7 @@ struct pci_system_methods {
pciaddr_t size, pciaddr_t * bytes_written );
int (*fill_capabilities)( struct pci_device * dev );
+ void (*enable)( struct pci_device *dev );
};
struct pci_device_mapping {