blob: 7d30d9b85f003b98da5ab16ca342977d4d32baf3 [file] [log] [blame]
Timur Tabi2ad6b512006-10-31 18:44:42 -06001/*
Kim Phillips9993e192009-07-18 18:42:13 -05002 * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
Timur Tabi2ad6b512006-10-31 18:44:42 -06003 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23#include <common.h>
24
Timur Tabi2ad6b512006-10-31 18:44:42 -060025#include <asm/mmu.h>
Kim Phillips9993e192009-07-18 18:42:13 -050026#include <asm/io.h>
27#include <mpc83xx.h>
Timur Tabi2ad6b512006-10-31 18:44:42 -060028#include <pci.h>
Timur Tabi2ad6b512006-10-31 18:44:42 -060029#include <i2c.h>
Kim Phillips9993e192009-07-18 18:42:13 -050030#include <asm/fsl_i2c.h>
Timur Tabi2ad6b512006-10-31 18:44:42 -060031
32DECLARE_GLOBAL_DATA_PTR;
33
Kim Phillips9993e192009-07-18 18:42:13 -050034static struct pci_region pci1_regions[] = {
Timur Tabi2ad6b512006-10-31 18:44:42 -060035 {
Kim Phillips9993e192009-07-18 18:42:13 -050036 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
37 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
38 size: CONFIG_SYS_PCI1_MEM_SIZE,
39 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
40 },
41 {
42 bus_start: CONFIG_SYS_PCI1_IO_BASE,
43 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
44 size: CONFIG_SYS_PCI1_IO_SIZE,
45 flags: PCI_REGION_IO
46 },
47 {
48 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
49 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
50 size: CONFIG_SYS_PCI1_MMIO_SIZE,
51 flags: PCI_REGION_MEM
52 },
53};
54
55#ifdef CONFIG_MPC83XX_PCI2
56static struct pci_region pci2_regions[] = {
57 {
58 bus_start: CONFIG_SYS_PCI2_MEM_BASE,
59 phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
60 size: CONFIG_SYS_PCI2_MEM_SIZE,
61 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
62 },
63 {
64 bus_start: CONFIG_SYS_PCI2_IO_BASE,
65 phys_start: CONFIG_SYS_PCI2_IO_PHYS,
66 size: CONFIG_SYS_PCI2_IO_SIZE,
67 flags: PCI_REGION_IO
68 },
69 {
70 bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
71 phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
72 size: CONFIG_SYS_PCI2_MMIO_SIZE,
73 flags: PCI_REGION_MEM
74 },
Timur Tabi2ad6b512006-10-31 18:44:42 -060075};
76#endif
77
Timur Tabi2ad6b512006-10-31 18:44:42 -060078void pci_init_board(void)
79{
Kim Phillips9993e192009-07-18 18:42:13 -050080 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
81 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
82 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
83#ifndef CONFIG_MPC83XX_PCI2
84 struct pci_region *reg[] = { pci1_regions };
85#else
86 struct pci_region *reg[] = { pci1_regions, pci2_regions };
87#endif
Timur Tabi2ad6b512006-10-31 18:44:42 -060088 u8 reg8;
Timur Tabi2ad6b512006-10-31 18:44:42 -060089
90#ifdef CONFIG_HARD_I2C
Timur Tabibe5e6182006-11-03 19:15:00 -060091 i2c_set_bus_num(1);
Timur Tabi2ad6b512006-10-31 18:44:42 -060092 /* Read the PCI_M66EN jumper setting */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020093 if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0) ||
94 (i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0)) {
Timur Tabi2ad6b512006-10-31 18:44:42 -060095 if (reg8 & I2C_8574_PCI66)
96 clk->occr = 0xff000000; /* 66 MHz PCI */
97 else
98 clk->occr = 0xff600001; /* 33 MHz PCI */
99 } else {
100 clk->occr = 0xff600001; /* 33 MHz PCI */
101 }
102#else
103 clk->occr = 0xff000000; /* 66 MHz PCI */
104#endif
Timur Tabi2ad6b512006-10-31 18:44:42 -0600105 udelay(2000);
106
Kim Phillips9993e192009-07-18 18:42:13 -0500107 /* Configure PCI Local Access Windows */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200108 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Timur Tabi2ad6b512006-10-31 18:44:42 -0600109 pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
110
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200111 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Timur Tabi98883332006-10-31 19:14:41 -0600112 pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
Timur Tabi2ad6b512006-10-31 18:44:42 -0600113
Kim Phillips9993e192009-07-18 18:42:13 -0500114 udelay(2000);
Timur Tabi2ad6b512006-10-31 18:44:42 -0600115
Kim Phillips9993e192009-07-18 18:42:13 -0500116#ifndef CONFIG_MPC83XX_PCI2
Peter Tyser6aa3d3b2010-09-14 19:13:50 -0500117 mpc83xx_pci_init(1, reg);
Kim Phillips9993e192009-07-18 18:42:13 -0500118#else
Peter Tyser6aa3d3b2010-09-14 19:13:50 -0500119 mpc83xx_pci_init(2, reg);
Timur Tabi2ad6b512006-10-31 18:44:42 -0600120#endif
121}