blob: 550a2afcb733fd1745109f1f775b075bc4f42405 [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>
Simon Glass18afe102019-11-14 12:57:47 -07007#include <init.h>
Timur Tabi054838e2006-10-31 18:44:42 -06008
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
Kim Phillips57a2af32009-07-18 18:42:13 -050016static struct pci_region pci1_regions[] = {
17 {
18 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
19 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
20 size: CONFIG_SYS_PCI1_MEM_SIZE,
21 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
22 },
23 {
24 bus_start: CONFIG_SYS_PCI1_IO_BASE,
25 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
26 size: CONFIG_SYS_PCI1_IO_SIZE,
27 flags: PCI_REGION_IO
28 },
Timur Tabi054838e2006-10-31 18:44:42 -060029 {
Kim Phillips57a2af32009-07-18 18:42:13 -050030 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
31 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
32 size: CONFIG_SYS_PCI1_MMIO_SIZE,
33 flags: PCI_REGION_MEM
34 },
Timur Tabi054838e2006-10-31 18:44:42 -060035};
Timur Tabi054838e2006-10-31 18:44:42 -060036
Kim Phillips57a2af32009-07-18 18:42:13 -050037#ifdef CONFIG_MPC83XX_PCI2
38static struct pci_region pci2_regions[] = {
Timur Tabi054838e2006-10-31 18:44:42 -060039 {
Kim Phillips57a2af32009-07-18 18:42:13 -050040 bus_start: CONFIG_SYS_PCI2_MEM_BASE,
41 phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
42 size: CONFIG_SYS_PCI2_MEM_SIZE,
43 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
44 },
Timur Tabi054838e2006-10-31 18:44:42 -060045 {
Kim Phillips57a2af32009-07-18 18:42:13 -050046 bus_start: CONFIG_SYS_PCI2_IO_BASE,
47 phys_start: CONFIG_SYS_PCI2_IO_PHYS,
48 size: CONFIG_SYS_PCI2_IO_SIZE,
49 flags: PCI_REGION_IO
50 },
51 {
52 bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
53 phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
54 size: CONFIG_SYS_PCI2_MMIO_SIZE,
55 flags: PCI_REGION_MEM
56 },
Timur Tabi054838e2006-10-31 18:44:42 -060057};
Kim Phillips57a2af32009-07-18 18:42:13 -050058#endif
Timur Tabi054838e2006-10-31 18:44:42 -060059
Timur Tabi054838e2006-10-31 18:44:42 -060060void pci_init_board(void)
61{
Kim Phillips57a2af32009-07-18 18:42:13 -050062 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
63 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
64 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
65#ifndef CONFIG_MPC83XX_PCI2
66 struct pci_region *reg[] = { pci1_regions };
67#else
68 struct pci_region *reg[] = { pci1_regions, pci2_regions };
69#endif
Timur Tabi054838e2006-10-31 18:44:42 -060070 u8 reg8;
Timur Tabi054838e2006-10-31 18:44:42 -060071
Heiko Schocherf2850742012-10-24 13:48:22 +020072#if defined(CONFIG_SYS_I2C)
Timur Tabiab347542006-11-03 19:15:00 -060073 i2c_set_bus_num(1);
Timur Tabi054838e2006-10-31 18:44:42 -060074 /* Read the PCI_M66EN jumper setting */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020075 if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0) ||
76 (i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0)) {
Timur Tabi054838e2006-10-31 18:44:42 -060077 if (reg8 & I2C_8574_PCI66)
78 clk->occr = 0xff000000; /* 66 MHz PCI */
79 else
80 clk->occr = 0xff600001; /* 33 MHz PCI */
81 } else {
82 clk->occr = 0xff600001; /* 33 MHz PCI */
83 }
84#else
85 clk->occr = 0xff000000; /* 66 MHz PCI */
86#endif
Timur Tabi054838e2006-10-31 18:44:42 -060087 udelay(2000);
Timur Tabi054838e2006-10-31 18:44:42 -060088
Kim Phillips57a2af32009-07-18 18:42:13 -050089 /* Configure PCI Local Access Windows */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020090 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Timur Tabi054838e2006-10-31 18:44:42 -060091 pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
92
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020093 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Timur Tabie9b04f02006-10-31 19:14:41 -060094 pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
Timur Tabi054838e2006-10-31 18:44:42 -060095
Kim Phillips57a2af32009-07-18 18:42:13 -050096 udelay(2000);
Kim Phillips21416812007-08-15 22:30:33 -050097
Kim Phillips57a2af32009-07-18 18:42:13 -050098#ifndef CONFIG_MPC83XX_PCI2
Peter Tysere2283322010-09-14 19:13:50 -050099 mpc83xx_pci_init(1, reg);
Kim Phillips57a2af32009-07-18 18:42:13 -0500100#else
Peter Tysere2283322010-09-14 19:13:50 -0500101 mpc83xx_pci_init(2, reg);
Kim Phillips21416812007-08-15 22:30:33 -0500102#endif
Kim Phillips774e1b52006-11-01 00:10:40 -0600103}