15e918a98SKim Phillips /* 25e918a98SKim Phillips * Copyright (C) 2007 Freescale Semiconductor, Inc. 35e918a98SKim Phillips * 45e918a98SKim Phillips * See file CREDITS for list of people who contributed to this 55e918a98SKim Phillips * project. 65e918a98SKim Phillips * 75e918a98SKim Phillips * This program is free software; you can redistribute it and/or 85e918a98SKim Phillips * modify it under the terms of the GNU General Public License as 95e918a98SKim Phillips * published by the Free Software Foundation; either version 2 of 105e918a98SKim Phillips * the License, or (at your option) any later version. 115e918a98SKim Phillips */ 125e918a98SKim Phillips 135e918a98SKim Phillips #include <common.h> 145e918a98SKim Phillips #include <mpc83xx.h> 155e918a98SKim Phillips #include <pci.h> 16*7e915580SAnton Vorontsov #include <asm/io.h> 175e918a98SKim Phillips 185e918a98SKim Phillips #if defined(CONFIG_PCI) 195e918a98SKim Phillips static struct pci_region pci_regions[] = { 205e918a98SKim Phillips { 216d0f6bcfSJean-Christophe PLAGNIOL-VILLARD bus_start: CONFIG_SYS_PCI_MEM_BASE, 226d0f6bcfSJean-Christophe PLAGNIOL-VILLARD phys_start: CONFIG_SYS_PCI_MEM_PHYS, 236d0f6bcfSJean-Christophe PLAGNIOL-VILLARD size: CONFIG_SYS_PCI_MEM_SIZE, 245e918a98SKim Phillips flags: PCI_REGION_MEM | PCI_REGION_PREFETCH 255e918a98SKim Phillips }, 265e918a98SKim Phillips { 276d0f6bcfSJean-Christophe PLAGNIOL-VILLARD bus_start: CONFIG_SYS_PCI_MMIO_BASE, 286d0f6bcfSJean-Christophe PLAGNIOL-VILLARD phys_start: CONFIG_SYS_PCI_MMIO_PHYS, 296d0f6bcfSJean-Christophe PLAGNIOL-VILLARD size: CONFIG_SYS_PCI_MMIO_SIZE, 305e918a98SKim Phillips flags: PCI_REGION_MEM 315e918a98SKim Phillips }, 325e918a98SKim Phillips { 336d0f6bcfSJean-Christophe PLAGNIOL-VILLARD bus_start: CONFIG_SYS_PCI_IO_BASE, 346d0f6bcfSJean-Christophe PLAGNIOL-VILLARD phys_start: CONFIG_SYS_PCI_IO_PHYS, 356d0f6bcfSJean-Christophe PLAGNIOL-VILLARD size: CONFIG_SYS_PCI_IO_SIZE, 365e918a98SKim Phillips flags: PCI_REGION_IO 375e918a98SKim Phillips } 385e918a98SKim Phillips }; 395e918a98SKim Phillips 40*7e915580SAnton Vorontsov static struct pci_region pcie_regions_0[] = { 41*7e915580SAnton Vorontsov { 42*7e915580SAnton Vorontsov .bus_start = CONFIG_SYS_PCIE1_MEM_BASE, 43*7e915580SAnton Vorontsov .phys_start = CONFIG_SYS_PCIE1_MEM_PHYS, 44*7e915580SAnton Vorontsov .size = CONFIG_SYS_PCIE1_MEM_SIZE, 45*7e915580SAnton Vorontsov .flags = PCI_REGION_MEM, 46*7e915580SAnton Vorontsov }, 47*7e915580SAnton Vorontsov { 48*7e915580SAnton Vorontsov .bus_start = CONFIG_SYS_PCIE1_IO_BASE, 49*7e915580SAnton Vorontsov .phys_start = CONFIG_SYS_PCIE1_IO_PHYS, 50*7e915580SAnton Vorontsov .size = CONFIG_SYS_PCIE1_IO_SIZE, 51*7e915580SAnton Vorontsov .flags = PCI_REGION_IO, 52*7e915580SAnton Vorontsov }, 53*7e915580SAnton Vorontsov }; 54*7e915580SAnton Vorontsov 55*7e915580SAnton Vorontsov static struct pci_region pcie_regions_1[] = { 56*7e915580SAnton Vorontsov { 57*7e915580SAnton Vorontsov .bus_start = CONFIG_SYS_PCIE2_MEM_BASE, 58*7e915580SAnton Vorontsov .phys_start = CONFIG_SYS_PCIE2_MEM_PHYS, 59*7e915580SAnton Vorontsov .size = CONFIG_SYS_PCIE2_MEM_SIZE, 60*7e915580SAnton Vorontsov .flags = PCI_REGION_MEM, 61*7e915580SAnton Vorontsov }, 62*7e915580SAnton Vorontsov { 63*7e915580SAnton Vorontsov .bus_start = CONFIG_SYS_PCIE2_IO_BASE, 64*7e915580SAnton Vorontsov .phys_start = CONFIG_SYS_PCIE2_IO_PHYS, 65*7e915580SAnton Vorontsov .size = CONFIG_SYS_PCIE2_IO_SIZE, 66*7e915580SAnton Vorontsov .flags = PCI_REGION_IO, 67*7e915580SAnton Vorontsov }, 68*7e915580SAnton Vorontsov }; 69*7e915580SAnton Vorontsov 705e918a98SKim Phillips void pci_init_board(void) 715e918a98SKim Phillips { 726d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR; 73*7e915580SAnton Vorontsov volatile sysconf83xx_t *sysconf = &immr->sysconf; 745e918a98SKim Phillips volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk; 755e918a98SKim Phillips volatile law83xx_t *pci_law = immr->sysconf.pcilaw; 76*7e915580SAnton Vorontsov volatile law83xx_t *pcie_law = sysconf->pcielaw; 775e918a98SKim Phillips struct pci_region *reg[] = { pci_regions }; 78*7e915580SAnton Vorontsov struct pci_region *pcie_reg[] = { pcie_regions_0, pcie_regions_1, }; 79*7e915580SAnton Vorontsov u32 spridr = in_be32(&immr->sysconf.spridr); 805e918a98SKim Phillips 815e918a98SKim Phillips /* Enable all 5 PCI_CLK_OUTPUTS */ 825e918a98SKim Phillips clk->occr |= 0xf8000000; 835e918a98SKim Phillips udelay(2000); 845e918a98SKim Phillips 855e918a98SKim Phillips /* Configure PCI Local Access Windows */ 866d0f6bcfSJean-Christophe PLAGNIOL-VILLARD pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR; 875e918a98SKim Phillips pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB; 885e918a98SKim Phillips 896d0f6bcfSJean-Christophe PLAGNIOL-VILLARD pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR; 905e918a98SKim Phillips pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB; 915e918a98SKim Phillips 925e918a98SKim Phillips mpc83xx_pci_init(1, reg, 0); 93*7e915580SAnton Vorontsov 94*7e915580SAnton Vorontsov /* There is no PEX in MPC8379 parts. */ 95*7e915580SAnton Vorontsov if (PARTID_NO_E(spridr) == SPR_8379) 96*7e915580SAnton Vorontsov return; 97*7e915580SAnton Vorontsov 98*7e915580SAnton Vorontsov /* Configure the clock for PCIE controller */ 99*7e915580SAnton Vorontsov clrsetbits_be32(&clk->sccr, SCCR_PCIEXP1CM | SCCR_PCIEXP2CM, 100*7e915580SAnton Vorontsov SCCR_PCIEXP1CM_1 | SCCR_PCIEXP2CM_1); 101*7e915580SAnton Vorontsov 102*7e915580SAnton Vorontsov /* Deassert the resets in the control register */ 103*7e915580SAnton Vorontsov out_be32(&sysconf->pecr1, 0xE0008000); 104*7e915580SAnton Vorontsov out_be32(&sysconf->pecr2, 0xE0008000); 105*7e915580SAnton Vorontsov udelay(2000); 106*7e915580SAnton Vorontsov 107*7e915580SAnton Vorontsov /* Configure PCI Express Local Access Windows */ 108*7e915580SAnton Vorontsov out_be32(&pcie_law[0].bar, CONFIG_SYS_PCIE1_BASE & LAWBAR_BAR); 109*7e915580SAnton Vorontsov out_be32(&pcie_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB); 110*7e915580SAnton Vorontsov 111*7e915580SAnton Vorontsov out_be32(&pcie_law[1].bar, CONFIG_SYS_PCIE2_BASE & LAWBAR_BAR); 112*7e915580SAnton Vorontsov out_be32(&pcie_law[1].ar, LBLAWAR_EN | LBLAWAR_512MB); 113*7e915580SAnton Vorontsov 114*7e915580SAnton Vorontsov mpc83xx_pcie_init(2, pcie_reg, 0); 1155e918a98SKim Phillips } 1165e918a98SKim Phillips #endif /* CONFIG_PCI */ 117