blob: c3c2328dcd2094609417cae7b743446d5bf8cf46 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Timur Tabi054838e2006-10-31 18:44:42 -06002/*
Kim Phillips57a2af32009-07-18 18:42:13 -05003 * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
Timur Tabi054838e2006-10-31 18:44:42 -06004 */
5
6#include <common.h>
7
Timur Tabi054838e2006-10-31 18:44:42 -06008#include <asm/mmu.h>
Kim Phillips57a2af32009-07-18 18:42:13 -05009#include <asm/io.h>
10#include <mpc83xx.h>
Timur Tabi054838e2006-10-31 18:44:42 -060011#include <pci.h>
Timur Tabi054838e2006-10-31 18:44:42 -060012#include <i2c.h>
Kim Phillips57a2af32009-07-18 18:42:13 -050013#include <asm/fsl_i2c.h>
Timur Tabi054838e2006-10-31 18:44:42 -060014
Kim Phillips57a2af32009-07-18 18:42:13 -050015static struct pci_region pci1_regions[] = {
16 {
17 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 },
Timur Tabi054838e2006-10-31 18:44:42 -060028 {
Kim Phillips57a2af32009-07-18 18:42:13 -050029 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 },
Timur Tabi054838e2006-10-31 18:44:42 -060034};
Timur Tabi054838e2006-10-31 18:44:42 -060035
Kim Phillips57a2af32009-07-18 18:42:13 -050036#ifdef CONFIG_MPC83XX_PCI2
37static struct pci_region pci2_regions[] = {
Timur Tabi054838e2006-10-31 18:44:42 -060038 {
Kim Phillips57a2af32009-07-18 18:42:13 -050039 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 },
Timur Tabi054838e2006-10-31 18:44:42 -060044 {
Kim Phillips57a2af32009-07-18 18:42:13 -050045 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 Tabi054838e2006-10-31 18:44:42 -060056};
Kim Phillips57a2af32009-07-18 18:42:13 -050057#endif
Timur Tabi054838e2006-10-31 18:44:42 -060058
Timur Tabi054838e2006-10-31 18:44:42 -060059void pci_init_board(void)
60{
Kim Phillips57a2af32009-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 Tabi054838e2006-10-31 18:44:42 -060069 u8 reg8;
Timur Tabi054838e2006-10-31 18:44:42 -060070
Heiko Schocherf2850742012-10-24 13:48:22 +020071#if defined(CONFIG_SYS_I2C)
Timur Tabiab347542006-11-03 19:15:00 -060072 i2c_set_bus_num(1);
Timur Tabi054838e2006-10-31 18:44:42 -060073 /* Read the PCI_M66EN jumper setting */
Jean-Christophe PLAGNIOL-VILLARD03836942008-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 Tabi054838e2006-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 Tabi054838e2006-10-31 18:44:42 -060086 udelay(2000);
Timur Tabi054838e2006-10-31 18:44:42 -060087
Kim Phillips57a2af32009-07-18 18:42:13 -050088 /* Configure PCI Local Access Windows */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020089 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Timur Tabi054838e2006-10-31 18:44:42 -060090 pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
91
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020092 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Timur Tabie9b04f02006-10-31 19:14:41 -060093 pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
Timur Tabi054838e2006-10-31 18:44:42 -060094
Kim Phillips57a2af32009-07-18 18:42:13 -050095 udelay(2000);
Kim Phillips21416812007-08-15 22:30:33 -050096
Kim Phillips57a2af32009-07-18 18:42:13 -050097#ifndef CONFIG_MPC83XX_PCI2
Peter Tysere2283322010-09-14 19:13:50 -050098 mpc83xx_pci_init(1, reg);
Kim Phillips57a2af32009-07-18 18:42:13 -050099#else
Peter Tysere2283322010-09-14 19:13:50 -0500100 mpc83xx_pci_init(2, reg);
Kim Phillips21416812007-08-15 22:30:33 -0500101#endif
Kim Phillips774e1b52006-11-01 00:10:40 -0600102}