TRINATH KARRI
Member
How to ressign BARs in EP from RC
Hey there, dude! To reassign Base Address Registers (BARs) in Extended Partition (EP) from Root Complex (RC), you'll need to follow these steps:How to ressign BARs in EP from RC
Whoa, my bad if I misunderstood your question, dude! If you want to change the memory that's already mapped for a Base Address Register (BAR), you can't just modify the BAR in the PCI configuration space. Instead, you'll need to remap the memory in software.This does not change memory which is already mapped
#include <linux/pci.h>
struct pci_dev *dev; // Represents your PCI device
// Request and remap the memory
if (pci_request_region(dev, bar_number, "my_driver") < 0) {
// Error handling
}
void __iomem *base_addr = pci_iomap(dev, bar_number, region_size);
// Use the newly remapped memory as needed
// When you're done, unmap the memory
pci_iounmap(dev, base_addr);
pci_release_region(dev, bar_number);
Ah, got it! My apologies for assuming you were referring to Linux. If you want to remap memory in U-Boot, here's how you can do it:i want to remap in uboot
ranges = <0x00000000 0x80000000 0x80000000 0x00000000 0x10000000>;
<cpu_addr> <pci_addr> <size>
. Adjust the values based on your desired memory mapping.To set Base Address Register (BAR) addresses in a Device Tree Source (DTS) file, follow these steps:how to set bar addresses in dts file
your_device {
compatible = "your_device";
reg = <0x01234567 0x1000>; // BAR address: 0x01234567, size: 0x1000
// ...
};
To modify the DTS file of the Root Complex (RC), you'll need to follow these steps:i want to modify rootcomplex dts file
ranges = <0x02000000 0 0x40000000 0x80000000 0 0x10000000>;
In Linux, the PCI memory mapping is handled by the kernel through the pci_map_*() functions. Here's a general overview of how you can perform PCI memory mapping in Linux:how to pci memory mapping in linux
c
resource = pci_request_region(dev, bar_num, "my_driver");
if (!resource) {
// handle error
}
virt_addr = ioremap(pci_resource_start(dev, bar_num), pci_resource_len(dev, bar_num));
if (!virt_addr) {
// handle error
}
c
value = readl(virt_addr);
writel(new_value, virt_addr);
c
iounmap(virt_addr);
pci_release_region(dev, bar_num);