119580e66SDave Liu /*
219580e66SDave Liu  * Copyright (C) 2007 Freescale Semiconductor, Inc.
319580e66SDave Liu  *
419580e66SDave Liu  * See file CREDITS for list of people who contributed to this
519580e66SDave Liu  * project.
619580e66SDave Liu  *
719580e66SDave Liu  * This program is free software; you can redistribute it and/or
819580e66SDave Liu  * modify it under the terms of the GNU General Public License as
919580e66SDave Liu  * published by the Free Software Foundation; either version 2 of
1019580e66SDave Liu  * the License, or (at your option) any later version.
1119580e66SDave Liu  */
1219580e66SDave Liu 
1319580e66SDave Liu #include <asm/mmu.h>
1419580e66SDave Liu #include <asm/io.h>
1519580e66SDave Liu #include <common.h>
1619580e66SDave Liu #include <mpc83xx.h>
1719580e66SDave Liu #include <pci.h>
1819580e66SDave Liu #include <i2c.h>
1919580e66SDave Liu #include <asm/fsl_i2c.h>
2019580e66SDave Liu 
2119580e66SDave Liu #if defined(CONFIG_PCI)
2219580e66SDave Liu static struct pci_region pci_regions[] = {
2319580e66SDave Liu 	{
246d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		bus_start: CONFIG_SYS_PCI_MEM_BASE,
256d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		phys_start: CONFIG_SYS_PCI_MEM_PHYS,
266d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		size: CONFIG_SYS_PCI_MEM_SIZE,
2719580e66SDave Liu 		flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
2819580e66SDave Liu 	},
2919580e66SDave Liu 	{
306d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		bus_start: CONFIG_SYS_PCI_MMIO_BASE,
316d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		phys_start: CONFIG_SYS_PCI_MMIO_PHYS,
326d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		size: CONFIG_SYS_PCI_MMIO_SIZE,
3319580e66SDave Liu 		flags: PCI_REGION_MEM
3419580e66SDave Liu 	},
3519580e66SDave Liu 	{
366d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		bus_start: CONFIG_SYS_PCI_IO_BASE,
376d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		phys_start: CONFIG_SYS_PCI_IO_PHYS,
386d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 		size: CONFIG_SYS_PCI_IO_SIZE,
3919580e66SDave Liu 		flags: PCI_REGION_IO
4019580e66SDave Liu 	}
4119580e66SDave Liu };
4219580e66SDave Liu 
4319580e66SDave Liu void pci_init_board(void)
4419580e66SDave Liu {
456d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
4619580e66SDave Liu 	volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
4719580e66SDave Liu 	volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
4819580e66SDave Liu 	struct pci_region *reg[] = { pci_regions };
4919580e66SDave Liu 
50*00f7bbaeSAnton Vorontsov 	if (board_pci_host_broken())
51*00f7bbaeSAnton Vorontsov 		return;
52*00f7bbaeSAnton Vorontsov 
5319580e66SDave Liu 	/* Enable all 5 PCI_CLK_OUTPUTS */
5419580e66SDave Liu 	clk->occr |= 0xf8000000;
5519580e66SDave Liu 	udelay(2000);
5619580e66SDave Liu 
5719580e66SDave Liu 	/* Configure PCI Local Access Windows */
586d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR;
5919580e66SDave Liu 	pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
6019580e66SDave Liu 
616d0f6bcfSJean-Christophe PLAGNIOL-VILLARD 	pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR;
6219580e66SDave Liu 	pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
6319580e66SDave Liu 
6419580e66SDave Liu 	udelay(2000);
6519580e66SDave Liu 
6619580e66SDave Liu 	mpc83xx_pci_init(1, reg, 0);
6719580e66SDave Liu }
6819580e66SDave Liu #endif /* CONFIG_PCI */
69