Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
ret = pci_bus_read_config(ctrl->bus, devfn, io->pi_reg,
io->pi_width, &io->pi_data);
break;
}

Check failure on line 292 in drivers/pci/pci.c

View workflow job for this annotation

GitHub Actions / check

Bad right brace alignment

case PCIOCWRITE:
{
Expand Down Expand Up @@ -425,6 +425,60 @@
}
}

/****************************************************************************
* Name: pci_enable_parent_bridges
*
* Description:
* Enable memory forwarding and bus mastering on all bridges between a PCI
* device and the root bus.
*
****************************************************************************/

static int pci_enable_parent_bridges(FAR struct pci_device_s *dev)
{
FAR struct pci_device_s *bridge;
FAR struct pci_device_s *candidate;
FAR struct pci_bus_s *bus = dev->bus;
uint16_t command;
int ret;

while (bus != NULL && bus->parent_bus != NULL)
{
bridge = NULL;
list_for_every_entry(&bus->parent_bus->devices, candidate,
struct pci_device_s, bus_list)
{
if (candidate->subordinate == bus)
{
bridge = candidate;
break;
}
}

if (bridge == NULL)
{
return -ENODEV;
}

ret = pci_read_config_word(bridge, PCI_COMMAND, &command);
if (ret < 0)
{
return ret;
}

command |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
ret = pci_write_config_word(bridge, PCI_COMMAND, command);
if (ret < 0)
{
return ret;
}

bus = bus->parent_bus;
}

return OK;
}

/****************************************************************************
* Name: pci_bus_find_start_cap
*
Expand Down Expand Up @@ -456,17 +510,17 @@
/* Ignore MF bit */

switch (hdr_type & 0x7f)
{

Check failure on line 513 in drivers/pci/pci.c

View workflow job for this annotation

GitHub Actions / check

Bad left brace alignment
case PCI_HEADER_TYPE_NORMAL:

Check failure on line 514 in drivers/pci/pci.c

View workflow job for this annotation

GitHub Actions / check

Bad alignment
case PCI_HEADER_TYPE_BRIDGE:

Check failure on line 515 in drivers/pci/pci.c

View workflow job for this annotation

GitHub Actions / check

Bad alignment
return PCI_CAPABILITY_LIST;

Check failure on line 516 in drivers/pci/pci.c

View workflow job for this annotation

GitHub Actions / check

Bad alignment

case PCI_HEADER_TYPE_CARDBUS:

Check failure on line 518 in drivers/pci/pci.c

View workflow job for this annotation

GitHub Actions / check

Bad alignment
return PCI_CB_CAPABILITY_LIST;

Check failure on line 519 in drivers/pci/pci.c

View workflow job for this annotation

GitHub Actions / check

Bad alignment

default:

Check failure on line 521 in drivers/pci/pci.c

View workflow job for this annotation

GitHub Actions / check

Bad alignment
return 0;

Check failure on line 522 in drivers/pci/pci.c

View workflow job for this annotation

GitHub Actions / check

Bad alignment
}

Check failure on line 523 in drivers/pci/pci.c

View workflow job for this annotation

GitHub Actions / check

Bad right brace alignment
}

/****************************************************************************
Expand Down Expand Up @@ -1649,6 +1703,13 @@
int pci_enable_device(FAR struct pci_device_s *dev)
{
uint32_t cmd;
int ret;

ret = pci_enable_parent_bridges(dev);
if (ret < 0)
{
return ret;
}

pci_read_config_dword(dev, PCI_COMMAND, &cmd);
return pci_write_config_dword(dev, PCI_COMMAND,
Expand Down
Loading