/* Check that the core has been initied and if not, do it */ static int __init ppc4xx_pciex_check_core_init(struct device_node *np) { static int core_init; int count = -ENODEV; if (core_init++) return 0; #ifdef CONFIG_44x if (of_device_is_compatible(np, "ibm,plb-pciex-440spe")) { if (ppc440spe_revA()) ppc4xx_pciex_hwops = &ppc440speA_pcie_hwops; else ppc4xx_pciex_hwops = &ppc440speB_pcie_hwops; } if (of_device_is_compatible(np, "ibm,plb-pciex-460ex")) ppc4xx_pciex_hwops = &ppc460ex_pcie_hwops; #endif /* CONFIG_44x */ #ifdef CONFIG_40x if (of_device_is_compatible(np, "ibm,plb-pciex-405ex")) ppc4xx_pciex_hwops = &ppc405ex_pcie_hwops; #endif if (ppc4xx_pciex_hwops == NULL) { printk(KERN_WARNING "PCIE: unknown host type %s\n", np->full_name); return -ENODEV; } count = ppc4xx_pciex_hwops->core_init(np); if (count > 0) { ppc4xx_pciex_ports = kzalloc(count * sizeof(struct ppc4xx_pciex_port), GFP_KERNEL); if (ppc4xx_pciex_ports) { ppc4xx_pciex_port_count = count; return 0; } printk(KERN_WARNING "PCIE: failed to allocate ports array\n"); return -ENOMEM; } return -ENODEV; }
static int ppc440spe_pciex_init_port_hw(struct ppc4xx_pciex_port *port) { u32 val = 1 << 24; if (port->endpoint) val = PTYPE_LEGACY_ENDPOINT << 20; else val = PTYPE_ROOT_PORT << 20; if (port->index == 0) val |= LNKW_X8 << 12; else val |= LNKW_X4 << 12; mtdcri(SDR0, port->sdr_base + PESDRn_DLPSET, val); mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET1, 0x20222222); if (ppc440spe_revA()) mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET2, 0x11000000); mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL0SET1, 0x35000000); mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL1SET1, 0x35000000); mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL2SET1, 0x35000000); mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL3SET1, 0x35000000); if (port->index == 0) { mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL4SET1, 0x35000000); mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL5SET1, 0x35000000); mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL6SET1, 0x35000000); mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL7SET1, 0x35000000); } val = mfdcri(SDR0, port->sdr_base + PESDRn_RCSSET); mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, (val & ~(1 << 24 | 1 << 16)) | 1 << 12); return 0; }