Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions components/drivers/include/drivers/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ struct rt_pci_device
rt_uint8_t pin;
struct rt_pic *intx_pic;

rt_bool_t pm_enabled;

struct rt_pci_bus_resource resource[RT_PCI_BAR_NR_MAX];
struct rt_pci_bus_resource rom;

rt_uint8_t pme_cap;
rt_uint8_t msi_cap;
Expand Down
3 changes: 3 additions & 0 deletions components/drivers/pci/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ src = ['access.c', 'host-bridge.c', 'irq.c', 'pci.c', 'pme.c', 'probe.c']
if GetDepend(['RT_USING_OFW']):
src += ['ofw.c']

if GetDepend(['RT_USING_DFS_PROCFS']):
src += ['procfs.c']

if GetDepend(['RT_PCI_ECAM']):
src += ['ecam.c']

Expand Down
4 changes: 4 additions & 0 deletions components/drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,10 @@ rt_err_t rt_pci_device_alloc_resource(struct rt_pci_host_bridge *host_bridge,
rt_pci_write_config_u32(pdev, rom_addr, addr);
}
command |= PCIM_CMD_MEMEN;

pdev->rom.base = addr;
pdev->rom.size = size;
pdev->rom.flags = PCI_BUS_REGION_F_MEM;
}
}

Expand Down
1 change: 1 addition & 0 deletions components/drivers/pci/pme.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ static void pci_pme_active(struct rt_pci_device *pdev, rt_bool_t enable)
}

rt_pci_write_config_u16(pdev, pdev->pme_cap + PCIR_POWER_STATUS, pmcsr);
pdev->pm_enabled = enable;
}

void rt_pci_pme_active(struct rt_pci_device *pdev, rt_bool_t enable)
Expand Down
5 changes: 5 additions & 0 deletions components/drivers/pci/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <drivers/pci.h>
#include <drivers/core/bus.h>

#include "procfs.h"

rt_inline void spin_lock(struct rt_spinlock *spinlock)
{
rt_hw_spin_lock(&spinlock->lock);
Expand Down Expand Up @@ -146,6 +148,7 @@ struct rt_pci_device *rt_pci_scan_single_device(struct rt_pci_bus *bus, rt_uint3
goto _end;
}

pci_procfs_attach(pdev);
rt_pci_device_register(pdev);

_end:
Expand Down Expand Up @@ -901,6 +904,8 @@ rt_err_t rt_pci_device_remove(struct rt_pci_device *pdev)
{
struct rt_pci_bus *bus = pdev->bus;

pci_procfs_detach(pdev);

spin_lock(&bus->lock);

while (pdev->parent.ref_count > 1)
Expand Down
Loading