This will activate the bus mastering bit for the device represented by the given PCI configuration.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- drivers/pci.c | 12 ++++++++++++ drivers/pci_database.h | 2 ++ 2 files changed, 14 insertions(+)
diff --git a/drivers/pci.c b/drivers/pci.c index eec6a20..8ceb9c1 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -919,6 +919,18 @@ int usb_ohci_config_cb(const pci_config_t *config) return 0; }
+void ob_pci_enable_bus_master(const pci_config_t *config) +{ + /* Enable bus mastering for the PCI device */ + uint16_t cmd; + pci_addr addr = PCI_ADDR( + PCI_BUS(config->dev), PCI_DEV(config->dev), PCI_FN(config->dev)); + + cmd = pci_config_read16(addr, PCI_COMMAND); + cmd |= PCI_COMMAND_BUS_MASTER; + pci_config_write16(addr, PCI_COMMAND, cmd); +} + static void ob_pci_add_properties(phandle_t phandle, pci_addr addr, const pci_dev_t *pci_dev, const pci_config_t *config, int num_bars) diff --git a/drivers/pci_database.h b/drivers/pci_database.h index 7f053d8..9e8dc05 100644 --- a/drivers/pci_database.h +++ b/drivers/pci_database.h @@ -55,3 +55,5 @@ static inline int pci_compat_len(const pci_dev_t *dev) extern const pci_dev_t *pci_find_device(uint8_t class, uint8_t subclass, uint8_t iface, uint16_t vendor, uint16_t product); + +extern void ob_pci_enable_bus_master(const pci_config_t *config);