static void cds_pci_fixup(void *blob) { int node; const char *path; int len, slot, i; u32 *map = NULL, *piccells = NULL; int off, cells; node = fdt_path_offset(blob, "/aliases"); if (node >= 0) { path = fdt_getprop(blob, node, "pci0", NULL); if (path) { node = fdt_path_offset(blob, path); if (node >= 0) { map = fdt_getprop_w(blob, node, "interrupt-map", &len); } /* Each item in "interrupt-map" property is translated with * following cells: * PCI #address-cells, PCI #interrupt-cells, * PIC address, PIC #address-cells, PIC #interrupt-cells. */ cells = fdt_getprop_u32_default(blob, path, "#address-cells", 1); cells += fdt_getprop_u32_default(blob, path, "#interrupt-cells", 1); off = fdt_node_offset_by_phandle(blob, fdt32_to_cpu(*(map+cells))); if (off <= 0) return; cells += 1; piccells = (u32 *)fdt_getprop(blob, off, "#address-cells", NULL); if (piccells == NULL) return; cells += *piccells; piccells = (u32 *)fdt_getprop(blob, off, "#interrupt-cells", NULL); if (piccells == NULL) return; cells += *piccells; } } if (map) { len /= sizeof(u32); slot = get_pci_slot(); for (i=0;i<len;i+=cells) { /* We rotate the interrupt pins so that the mapping * changes depending on the slot the carrier card is in. */ map[3] = ((map[3] + slot - 2) % 4) + 1; map+=cells; } } }
int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose) { int addrcell, sizecell, len, r; u32 *dma_range; /* sized based on pci addr cells, size-cells, & address-cells */ u32 dma_ranges[(3 + 2 + 2) * CONFIG_SYS_PCI_NR_INBOUND_WIN]; addrcell = fdt_getprop_u32_default(blob, "/", "#address-cells", 1); sizecell = fdt_getprop_u32_default(blob, "/", "#size-cells", 1); dma_range = &dma_ranges[0]; for (r = 0; r < hose->region_count; r++) { u64 bus_start, phys_start, size; /* skip if !PCI_REGION_SYS_MEMORY */ if (!(hose->regions[r].flags & PCI_REGION_SYS_MEMORY)) continue; bus_start = (u64)hose->regions[r].bus_start; phys_start = (u64)hose->regions[r].phys_start; size = (u64)hose->regions[r].size; dma_range[0] = 0; if (size >= 0x100000000ull) dma_range[0] |= FDT_PCI_MEM64; else dma_range[0] |= FDT_PCI_MEM32; if (hose->regions[r].flags & PCI_REGION_PREFETCH) dma_range[0] |= FDT_PCI_PREFETCH; #ifdef CONFIG_SYS_PCI_64BIT dma_range[1] = bus_start >> 32; #else dma_range[1] = 0; #endif dma_range[2] = bus_start & 0xffffffff; if (addrcell == 2) { dma_range[3] = phys_start >> 32; dma_range[4] = phys_start & 0xffffffff; } else {
static int mc_fixup_dpl(u64 dpl_addr) { void *blob = (void *)dpl_addr; u32 ver = fdt_getprop_u32_default(blob, "/", "dpl-version", 0); int err = 0; /* The DPL fixup for mac addresses is only relevant * for old-style DPLs */ if (ver >= 10) return 0; err = mc_fixup_mac_addrs(blob, MC_FIXUP_DPL); flush_dcache_range(dpl_addr, dpl_addr + fdt_totalsize(blob)); return err; }