xref: /rk3399_rockchip-uboot/board/freescale/mpc837xerdb/pci.c (revision 5e918a98c26e8ab9b5d2d48d998a2ced2b5b85b3)
1*5e918a98SKim Phillips /*
2*5e918a98SKim Phillips  * Copyright (C) 2007 Freescale Semiconductor, Inc.
3*5e918a98SKim Phillips  *
4*5e918a98SKim Phillips  * See file CREDITS for list of people who contributed to this
5*5e918a98SKim Phillips  * project.
6*5e918a98SKim Phillips  *
7*5e918a98SKim Phillips  * This program is free software; you can redistribute it and/or
8*5e918a98SKim Phillips  * modify it under the terms of the GNU General Public License as
9*5e918a98SKim Phillips  * published by the Free Software Foundation; either version 2 of
10*5e918a98SKim Phillips  * the License, or (at your option) any later version.
11*5e918a98SKim Phillips  */
12*5e918a98SKim Phillips 
13*5e918a98SKim Phillips #include <common.h>
14*5e918a98SKim Phillips #include <mpc83xx.h>
15*5e918a98SKim Phillips #include <pci.h>
16*5e918a98SKim Phillips 
17*5e918a98SKim Phillips #if defined(CONFIG_PCI)
18*5e918a98SKim Phillips static struct pci_region pci_regions[] = {
19*5e918a98SKim Phillips 	{
20*5e918a98SKim Phillips 		bus_start: CFG_PCI_MEM_BASE,
21*5e918a98SKim Phillips 		phys_start: CFG_PCI_MEM_PHYS,
22*5e918a98SKim Phillips 		size: CFG_PCI_MEM_SIZE,
23*5e918a98SKim Phillips 		flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
24*5e918a98SKim Phillips 	},
25*5e918a98SKim Phillips 	{
26*5e918a98SKim Phillips 		bus_start: CFG_PCI_MMIO_BASE,
27*5e918a98SKim Phillips 		phys_start: CFG_PCI_MMIO_PHYS,
28*5e918a98SKim Phillips 		size: CFG_PCI_MMIO_SIZE,
29*5e918a98SKim Phillips 		flags: PCI_REGION_MEM
30*5e918a98SKim Phillips 	},
31*5e918a98SKim Phillips 	{
32*5e918a98SKim Phillips 		bus_start: CFG_PCI_IO_BASE,
33*5e918a98SKim Phillips 		phys_start: CFG_PCI_IO_PHYS,
34*5e918a98SKim Phillips 		size: CFG_PCI_IO_SIZE,
35*5e918a98SKim Phillips 		flags: PCI_REGION_IO
36*5e918a98SKim Phillips 	}
37*5e918a98SKim Phillips };
38*5e918a98SKim Phillips 
39*5e918a98SKim Phillips void pci_init_board(void)
40*5e918a98SKim Phillips {
41*5e918a98SKim Phillips 	volatile immap_t *immr = (volatile immap_t *)CFG_IMMR;
42*5e918a98SKim Phillips 	volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
43*5e918a98SKim Phillips 	volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
44*5e918a98SKim Phillips 	struct pci_region *reg[] = { pci_regions };
45*5e918a98SKim Phillips 
46*5e918a98SKim Phillips 	/* Enable all 5 PCI_CLK_OUTPUTS */
47*5e918a98SKim Phillips 	clk->occr |= 0xf8000000;
48*5e918a98SKim Phillips 	udelay(2000);
49*5e918a98SKim Phillips 
50*5e918a98SKim Phillips 	/* Configure PCI Local Access Windows */
51*5e918a98SKim Phillips 	pci_law[0].bar = CFG_PCI_MEM_PHYS & LAWBAR_BAR;
52*5e918a98SKim Phillips 	pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
53*5e918a98SKim Phillips 
54*5e918a98SKim Phillips 	pci_law[1].bar = CFG_PCI_IO_PHYS & LAWBAR_BAR;
55*5e918a98SKim Phillips 	pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
56*5e918a98SKim Phillips 
57*5e918a98SKim Phillips 	mpc83xx_pci_init(1, reg, 0);
58*5e918a98SKim Phillips }
59*5e918a98SKim Phillips #endif	/* CONFIG_PCI */
60