Skip to content

Commit 49045d1

Browse files
committed
[DM/PCI] Add /proc access in RT-Smart user.
1. Add ROM base info. 2. Save th PM status. Signed-off-by: GuEe-GUI <[email protected]>
1 parent 3ebad06 commit 49045d1

File tree

7 files changed

+418
-0
lines changed

7 files changed

+418
-0
lines changed

components/drivers/include/drivers/pci.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ struct rt_pci_device
157157
rt_uint8_t pin;
158158
struct rt_pic *intx_pic;
159159

160+
rt_bool_t pm_enabled;
161+
160162
struct rt_pci_bus_resource resource[RT_PCI_BAR_NR_MAX];
163+
struct rt_pci_bus_resource rom;
161164

162165
rt_uint8_t pme_cap;
163166
rt_uint8_t msi_cap;

components/drivers/pci/SConscript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ src = ['access.c', 'host-bridge.c', 'irq.c', 'pci.c', 'pme.c', 'probe.c']
1414
if GetDepend(['RT_USING_OFW']):
1515
src += ['ofw.c']
1616

17+
if GetDepend(['RT_USING_DFS_PROCFS']):
18+
src += ['procfs.c']
19+
1720
if GetDepend(['RT_PCI_ECAM']):
1821
src += ['ecam.c']
1922

components/drivers/pci/pci.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,10 @@ rt_err_t rt_pci_device_alloc_resource(struct rt_pci_host_bridge *host_bridge,
695695
rt_pci_write_config_u32(pdev, rom_addr, addr);
696696
}
697697
command |= PCIM_CMD_MEMEN;
698+
699+
pdev->rom.base = addr;
700+
pdev->rom.size = size;
701+
pdev->rom.flags = PCI_BUS_REGION_F_MEM;
698702
}
699703
}
700704

components/drivers/pci/pme.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ static void pci_pme_active(struct rt_pci_device *pdev, rt_bool_t enable)
107107
}
108108

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

112113
void rt_pci_pme_active(struct rt_pci_device *pdev, rt_bool_t enable)

components/drivers/pci/probe.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <drivers/pci.h>
1818
#include <drivers/core/bus.h>
1919

20+
#include "procfs.h"
21+
2022
rt_inline void spin_lock(struct rt_spinlock *spinlock)
2123
{
2224
rt_hw_spin_lock(&spinlock->lock);
@@ -146,6 +148,7 @@ struct rt_pci_device *rt_pci_scan_single_device(struct rt_pci_bus *bus, rt_uint3
146148
goto _end;
147149
}
148150

151+
pci_procfs_attach(pdev);
149152
rt_pci_device_register(pdev);
150153

151154
_end:
@@ -901,6 +904,8 @@ rt_err_t rt_pci_device_remove(struct rt_pci_device *pdev)
901904
{
902905
struct rt_pci_bus *bus = pdev->bus;
903906

907+
pci_procfs_detach(pdev);
908+
904909
spin_lock(&bus->lock);
905910

906911
while (pdev->parent.ref_count > 1)

0 commit comments

Comments
 (0)