blob: afc9df0923b7d76ff97f874c64ef20c196ed62f1 [file] [log] [blame]
Timur Tabi054838e2006-10-31 18:44:42 -06001/*
Kim Phillips57a2af32009-07-18 18:42:13 -05002 * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
Timur Tabi054838e2006-10-31 18:44:42 -06003 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Timur Tabi054838e2006-10-31 18:44:42 -06005 */
6
7#include <common.h>
8
Timur Tabi054838e2006-10-31 18:44:42 -06009#include <asm/mmu.h>
Kim Phillips57a2af32009-07-18 18:42:13 -050010#include <asm/io.h>
11#include <mpc83xx.h>
Timur Tabi054838e2006-10-31 18:44:42 -060012#include <pci.h>
Timur Tabi054838e2006-10-31 18:44:42 -060013#include <i2c.h>
Kim Phillips57a2af32009-07-18 18:42:13 -050014#include <asm/fsl_i2c.h>
Timur Tabi054838e2006-10-31 18:44:42 -060015
16DECLARE_GLOBAL_DATA_PTR;
17
Kim Phillips57a2af32009-07-18 18:42:13 -050018static struct pci_region pci1_regions[] = {
19 {
20 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
21 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
22 size: CONFIG_SYS_PCI1_MEM_SIZE,
23 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
24 },
25 {
26 bus_start: CONFIG_SYS_PCI1_IO_BASE,
27 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
28 size: CONFIG_SYS_PCI1_IO_SIZE,
29 flags: PCI_REGION_IO
30 },
Timur Tabi054838e2006-10-31 18:44:42 -060031 {
Kim Phillips57a2af32009-07-18 18:42:13 -050032 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
33 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
34 size: CONFIG_SYS_PCI1_MMIO_SIZE,
35 flags: PCI_REGION_MEM
36 },
Timur Tabi054838e2006-10-31 18:44:42 -060037};
Timur Tabi054838e2006-10-31 18:44:42 -060038
Kim Phillips57a2af32009-07-18 18:42:13 -050039#ifdef CONFIG_MPC83XX_PCI2
40static struct pci_region pci2_regions[] = {
Timur Tabi054838e2006-10-31 18:44:42 -060041 {
Kim Phillips57a2af32009-07-18 18:42:13 -050042 bus_start: CONFIG_SYS_PCI2_MEM_BASE,
43 phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
44 size: CONFIG_SYS_PCI2_MEM_SIZE,
45 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
46 },
Timur Tabi054838e2006-10-31 18:44:42 -060047 {
Kim Phillips57a2af32009-07-18 18:42:13 -050048 bus_start: CONFIG_SYS_PCI2_IO_BASE,
49 phys_start: CONFIG_SYS_PCI2_IO_PHYS,
50 size: CONFIG_SYS_PCI2_IO_SIZE,
51 flags: PCI_REGION_IO
52 },
53 {
54 bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
55 phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
56 size: CONFIG_SYS_PCI2_MMIO_SIZE,
57 flags: PCI_REGION_MEM
58 },
Timur Tabi054838e2006-10-31 18:44:42 -060059};
Kim Phillips57a2af32009-07-18 18:42:13 -050060#endif
Timur Tabi054838e2006-10-31 18:44:42 -060061
Timur Tabi054838e2006-10-31 18:44:42 -060062void pci_init_board(void)
63{
Kim Phillips57a2af32009-07-18 18:42:13 -050064 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
65 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
66 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
67#ifndef CONFIG_MPC83XX_PCI2
68 struct pci_region *reg[] = { pci1_regions };
69#else
70 struct pci_region *reg[] = { pci1_regions, pci2_regions };
71#endif
Timur Tabi054838e2006-10-31 18:44:42 -060072 u8 reg8;
Timur Tabi054838e2006-10-31 18:44:42 -060073
Heiko Schocherf2850742012-10-24 13:48:22 +020074#if defined(CONFIG_SYS_I2C)
Timur Tabiab347542006-11-03 19:15:00 -060075 i2c_set_bus_num(1);
Timur Tabi054838e2006-10-31 18:44:42 -060076 /* Read the PCI_M66EN jumper setting */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020077 if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0) ||
78 (i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0)) {
Timur Tabi054838e2006-10-31 18:44:42 -060079 if (reg8 & I2C_8574_PCI66)
80 clk->occr = 0xff000000; /* 66 MHz PCI */
81 else
82 clk->occr = 0xff600001; /* 33 MHz PCI */
83 } else {
84 clk->occr = 0xff600001; /* 33 MHz PCI */
85 }
86#else
87 clk->occr = 0xff000000; /* 66 MHz PCI */
88#endif
Timur Tabi054838e2006-10-31 18:44:42 -060089 udelay(2000);
Timur Tabi054838e2006-10-31 18:44:42 -060090
Kim Phillips57a2af32009-07-18 18:42:13 -050091 /* Configure PCI Local Access Windows */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020092 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Timur Tabi054838e2006-10-31 18:44:42 -060093 pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
94
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020095 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Timur Tabie9b04f02006-10-31 19:14:41 -060096 pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
Timur Tabi054838e2006-10-31 18:44:42 -060097
Kim Phillips57a2af32009-07-18 18:42:13 -050098 udelay(2000);
Kim Phillips21416812007-08-15 22:30:33 -050099
Kim Phillips57a2af32009-07-18 18:42:13 -0500100#ifndef CONFIG_MPC83XX_PCI2
Peter Tysere2283322010-09-14 19:13:50 -0500101 mpc83xx_pci_init(1, reg);
Kim Phillips57a2af32009-07-18 18:42:13 -0500102#else
Peter Tysere2283322010-09-14 19:13:50 -0500103 mpc83xx_pci_init(2, reg);
Kim Phillips21416812007-08-15 22:30:33 -0500104#endif
Kim Phillips774e1b52006-11-01 00:10:40 -0600105}