blob: c3c2328dcd2094609417cae7b743446d5bf8cf46 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Timur Tabi2ad6b512006-10-31 18:44:42 -06002/*
Kim Phillips9993e192009-07-18 18:42:13 -05003 * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
Timur Tabi2ad6b512006-10-31 18:44:42 -06004 */
5
6#include <common.h>
7
Timur Tabi2ad6b512006-10-31 18:44:42 -06008#include <asm/mmu.h>
Kim Phillips9993e192009-07-18 18:42:13 -05009#include <asm/io.h>
10#include <mpc83xx.h>
Timur Tabi2ad6b512006-10-31 18:44:42 -060011#include <pci.h>
Timur Tabi2ad6b512006-10-31 18:44:42 -060012#include <i2c.h>
Kim Phillips9993e192009-07-18 18:42:13 -050013#include <asm/fsl_i2c.h>
Timur Tabi2ad6b512006-10-31 18:44:42 -060014
Kim Phillips9993e192009-07-18 18:42:13 -050015static struct pci_region pci1_regions[] = {
Timur Tabi2ad6b512006-10-31 18:44:42 -060016 {
Kim Phillips9993e192009-07-18 18:42:13 -050017 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
18 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
19 size: CONFIG_SYS_PCI1_MEM_SIZE,
20 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
21 },
22 {
23 bus_start: CONFIG_SYS_PCI1_IO_BASE,
24 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
25 size: CONFIG_SYS_PCI1_IO_SIZE,
26 flags: PCI_REGION_IO
27 },
28 {
29 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
30 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
31 size: CONFIG_SYS_PCI1_MMIO_SIZE,
32 flags: PCI_REGION_MEM
33 },
34};
35
36#ifdef CONFIG_MPC83XX_PCI2
37static struct pci_region pci2_regions[] = {
38 {
39 bus_start: CONFIG_SYS_PCI2_MEM_BASE,
40 phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
41 size: CONFIG_SYS_PCI2_MEM_SIZE,
42 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
43 },
44 {
45 bus_start: CONFIG_SYS_PCI2_IO_BASE,
46 phys_start: CONFIG_SYS_PCI2_IO_PHYS,
47 size: CONFIG_SYS_PCI2_IO_SIZE,
48 flags: PCI_REGION_IO
49 },
50 {
51 bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
52 phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
53 size: CONFIG_SYS_PCI2_MMIO_SIZE,
54 flags: PCI_REGION_MEM
55 },
Timur Tabi2ad6b512006-10-31 18:44:42 -060056};
57#endif
58
Timur Tabi2ad6b512006-10-31 18:44:42 -060059void pci_init_board(void)
60{
Kim Phillips9993e192009-07-18 18:42:13 -050061 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
62 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
63 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
64#ifndef CONFIG_MPC83XX_PCI2
65 struct pci_region *reg[] = { pci1_regions };
66#else
67 struct pci_region *reg[] = { pci1_regions, pci2_regions };
68#endif
Timur Tabi2ad6b512006-10-31 18:44:42 -060069 u8 reg8;
Timur Tabi2ad6b512006-10-31 18:44:42 -060070
Heiko Schocher00f792e2012-10-24 13:48:22 +020071#if defined(CONFIG_SYS_I2C)
Timur Tabibe5e6182006-11-03 19:15:00 -060072 i2c_set_bus_num(1);
Timur Tabi2ad6b512006-10-31 18:44:42 -060073 /* Read the PCI_M66EN jumper setting */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020074 if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0) ||
75 (i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0)) {
Timur Tabi2ad6b512006-10-31 18:44:42 -060076 if (reg8 & I2C_8574_PCI66)
77 clk->occr = 0xff000000; /* 66 MHz PCI */
78 else
79 clk->occr = 0xff600001; /* 33 MHz PCI */
80 } else {
81 clk->occr = 0xff600001; /* 33 MHz PCI */
82 }
83#else
84 clk->occr = 0xff000000; /* 66 MHz PCI */
85#endif
Timur Tabi2ad6b512006-10-31 18:44:42 -060086 udelay(2000);
87
Kim Phillips9993e192009-07-18 18:42:13 -050088 /* Configure PCI Local Access Windows */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020089 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Timur Tabi2ad6b512006-10-31 18:44:42 -060090 pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
91
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020092 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Timur Tabi98883332006-10-31 19:14:41 -060093 pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
Timur Tabi2ad6b512006-10-31 18:44:42 -060094
Kim Phillips9993e192009-07-18 18:42:13 -050095 udelay(2000);
Timur Tabi2ad6b512006-10-31 18:44:42 -060096
Kim Phillips9993e192009-07-18 18:42:13 -050097#ifndef CONFIG_MPC83XX_PCI2
Peter Tyser6aa3d3b2010-09-14 19:13:50 -050098 mpc83xx_pci_init(1, reg);
Kim Phillips9993e192009-07-18 18:42:13 -050099#else
Peter Tyser6aa3d3b2010-09-14 19:13:50 -0500100 mpc83xx_pci_init(2, reg);
Timur Tabi2ad6b512006-10-31 18:44:42 -0600101#endif
102}