mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 05:20:50 +00:00
PPC: e500: dt: create pci node dynamically
Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
f5038483e4
commit
0dbc07985b
@ -62,6 +62,27 @@ struct boot_info
|
||||
uint32_t entry;
|
||||
};
|
||||
|
||||
static void pci_map_create(void *fdt, uint32_t *pci_map, uint32_t mpic)
|
||||
{
|
||||
int i;
|
||||
const uint32_t tmp[] = {
|
||||
/* IDSEL 0x11 J17 Slot 1 */
|
||||
0x8800, 0x0, 0x0, 0x1, mpic, 0x2, 0x1,
|
||||
0x8800, 0x0, 0x0, 0x2, mpic, 0x3, 0x1,
|
||||
0x8800, 0x0, 0x0, 0x3, mpic, 0x4, 0x1,
|
||||
0x8800, 0x0, 0x0, 0x4, mpic, 0x1, 0x1,
|
||||
|
||||
/* IDSEL 0x12 J16 Slot 2 */
|
||||
0x9000, 0x0, 0x0, 0x1, mpic, 0x3, 0x1,
|
||||
0x9000, 0x0, 0x0, 0x2, mpic, 0x4, 0x1,
|
||||
0x9000, 0x0, 0x0, 0x3, mpic, 0x2, 0x1,
|
||||
0x9000, 0x0, 0x0, 0x4, mpic, 0x1, 0x1,
|
||||
};
|
||||
for (i = 0; i < (7 * 8); i++) {
|
||||
pci_map[i] = cpu_to_be32(tmp[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static int mpc8544_load_device_tree(CPUPPCState *env,
|
||||
target_phys_addr_t addr,
|
||||
uint32_t ramsize,
|
||||
@ -86,6 +107,11 @@ static int mpc8544_load_device_tree(CPUPPCState *env,
|
||||
char mpic[128];
|
||||
uint32_t mpic_ph;
|
||||
char gutil[128];
|
||||
char pci[128];
|
||||
uint32_t pci_map[7 * 8];
|
||||
uint32_t pci_ranges[12] = { 0x2000000, 0x0, 0xc0000000, 0xc0000000, 0x0,
|
||||
0x20000000, 0x1000000, 0x0, 0x0, 0xe1000000,
|
||||
0x0, 0x10000 };
|
||||
|
||||
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
|
||||
if (!filename) {
|
||||
@ -256,6 +282,30 @@ static int mpc8544_load_device_tree(CPUPPCState *env,
|
||||
MPC8544_CCSRBAR_BASE, 0x1000);
|
||||
qemu_devtree_setprop(fdt, gutil, "fsl,has-rstcr", NULL, 0);
|
||||
|
||||
snprintf(pci, sizeof(pci), "/pci@%x", MPC8544_PCI_REGS_BASE);
|
||||
qemu_devtree_add_subnode(fdt, pci);
|
||||
qemu_devtree_setprop_cell(fdt, pci, "cell-index", 0);
|
||||
qemu_devtree_setprop_string(fdt, pci, "compatible", "fsl,mpc8540-pci");
|
||||
qemu_devtree_setprop_string(fdt, pci, "device_type", "pci");
|
||||
qemu_devtree_setprop_cells(fdt, pci, "interrupt-map-mask", 0xf800, 0x0,
|
||||
0x0, 0x7);
|
||||
pci_map_create(fdt, pci_map, qemu_devtree_get_phandle(fdt, mpic));
|
||||
qemu_devtree_setprop(fdt, pci, "interrupt-map", pci_map, sizeof(pci_map));
|
||||
qemu_devtree_setprop_phandle(fdt, pci, "interrupt-parent", mpic);
|
||||
qemu_devtree_setprop_cells(fdt, pci, "interrupts", 24, 2);
|
||||
qemu_devtree_setprop_cells(fdt, pci, "bus-range", 0, 255);
|
||||
for (i = 0; i < 12; i++) {
|
||||
pci_ranges[i] = cpu_to_be32(pci_ranges[i]);
|
||||
}
|
||||
qemu_devtree_setprop(fdt, pci, "ranges", pci_ranges, sizeof(pci_ranges));
|
||||
qemu_devtree_setprop_cells(fdt, pci, "reg", MPC8544_PCI_REGS_BASE,
|
||||
0x1000);
|
||||
qemu_devtree_setprop_cell(fdt, pci, "clock-frequency", 66666666);
|
||||
qemu_devtree_setprop_cell(fdt, pci, "#interrupt-cells", 1);
|
||||
qemu_devtree_setprop_cell(fdt, pci, "#size-cells", 2);
|
||||
qemu_devtree_setprop_cell(fdt, pci, "#address-cells", 3);
|
||||
qemu_devtree_setprop_string(fdt, "/aliases", "pci0", pci);
|
||||
|
||||
ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
|
Binary file not shown.
@ -11,50 +11,4 @@
|
||||
|
||||
/dts-v1/;
|
||||
/ {
|
||||
aliases {
|
||||
pci0 = &pci0;
|
||||
};
|
||||
|
||||
soc8544@e0000000 {
|
||||
mpic: pic@40000 {
|
||||
interrupt-controller;
|
||||
#address-cells = <0>;
|
||||
#interrupt-cells = <2>;
|
||||
reg = <0x40000 0x40000>;
|
||||
compatible = "chrp,open-pic";
|
||||
device_type = "open-pic";
|
||||
};
|
||||
};
|
||||
|
||||
pci0: pci@e0008000 {
|
||||
cell-index = <0>;
|
||||
compatible = "fsl,mpc8540-pci";
|
||||
device_type = "pci";
|
||||
interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
|
||||
interrupt-map = <
|
||||
|
||||
/* IDSEL 0x11 J17 Slot 1 */
|
||||
0x8800 0x0 0x0 0x1 &mpic 0x2 0x1
|
||||
0x8800 0x0 0x0 0x2 &mpic 0x3 0x1
|
||||
0x8800 0x0 0x0 0x3 &mpic 0x4 0x1
|
||||
0x8800 0x0 0x0 0x4 &mpic 0x1 0x1
|
||||
|
||||
/* IDSEL 0x12 J16 Slot 2 */
|
||||
|
||||
0x9000 0x0 0x0 0x1 &mpic 0x3 0x1
|
||||
0x9000 0x0 0x0 0x2 &mpic 0x4 0x1
|
||||
0x9000 0x0 0x0 0x3 &mpic 0x2 0x1
|
||||
0x9000 0x0 0x0 0x4 &mpic 0x1 0x1>;
|
||||
|
||||
interrupt-parent = <&mpic>;
|
||||
interrupts = <24 2>;
|
||||
bus-range = <0 255>;
|
||||
ranges = <0x2000000 0x0 0xc0000000 0xc0000000 0x0 0x20000000
|
||||
0x1000000 0x0 0x0 0xe1000000 0x0 0x10000>;
|
||||
clock-frequency = <66666666>;
|
||||
#interrupt-cells = <1>;
|
||||
#size-cells = <2>;
|
||||
#address-cells = <3>;
|
||||
reg = <0xe0008000 0x1000>;
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user