blob: a09b6586882fef96383642d5b082ebc7413c8943 [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>
Simon Glassdbd79542020-05-10 11:40:11 -06008#include <linux/delay.h>
Timur Tabi054838e2006-10-31 18:44:42 -06009
Timur Tabi054838e2006-10-31 18:44:42 -060010#include <asm/mmu.h>
Kim Phillips57a2af32009-07-18 18:42:13 -050011#include <asm/io.h>
12#include <mpc83xx.h>
Timur Tabi054838e2006-10-31 18:44:42 -060013#include <pci.h>
Timur Tabi054838e2006-10-31 18:44:42 -060014#include <i2c.h>
Kim Phillips57a2af32009-07-18 18:42:13 -050015#include <asm/fsl_i2c.h>
Timur Tabi054838e2006-10-31 18:44:42 -060016
Kim Phillips57a2af32009-07-18 18:42:13 -050017static struct pci_region pci1_regions[] = {
18 {
19 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
20 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
21 size: CONFIG_SYS_PCI1_MEM_SIZE,
22 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
23 },
24 {
25 bus_start: CONFIG_SYS_PCI1_IO_BASE,
26 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
27 size: CONFIG_SYS_PCI1_IO_SIZE,
28 flags: PCI_REGION_IO
29 },
Timur Tabi054838e2006-10-31 18:44:42 -060030 {
Kim Phillips57a2af32009-07-18 18:42:13 -050031 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
32 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
33 size: CONFIG_SYS_PCI1_MMIO_SIZE,
34 flags: PCI_REGION_MEM
35 },
Timur Tabi054838e2006-10-31 18:44:42 -060036};
Timur Tabi054838e2006-10-31 18:44:42 -060037
Kim Phillips57a2af32009-07-18 18:42:13 -050038#ifdef CONFIG_MPC83XX_PCI2
39static struct pci_region pci2_regions[] = {
Timur Tabi054838e2006-10-31 18:44:42 -060040 {
Kim Phillips57a2af32009-07-18 18:42:13 -050041 bus_start: CONFIG_SYS_PCI2_MEM_BASE,
42 phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
43 size: CONFIG_SYS_PCI2_MEM_SIZE,
44 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
45 },
Timur Tabi054838e2006-10-31 18:44:42 -060046 {
Kim Phillips57a2af32009-07-18 18:42:13 -050047 bus_start: CONFIG_SYS_PCI2_IO_BASE,
48 phys_start: CONFIG_SYS_PCI2_IO_PHYS,
49 size: CONFIG_SYS_PCI2_IO_SIZE,
50 flags: PCI_REGION_IO
51 },
52 {
53 bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
54 phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
55 size: CONFIG_SYS_PCI2_MMIO_SIZE,
56 flags: PCI_REGION_MEM
57 },
Timur Tabi054838e2006-10-31 18:44:42 -060058};
Kim Phillips57a2af32009-07-18 18:42:13 -050059#endif
Timur Tabi054838e2006-10-31 18:44:42 -060060
Timur Tabi054838e2006-10-31 18:44:42 -060061void pci_init_board(void)
62{
Kim Phillips57a2af32009-07-18 18:42:13 -050063 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
64 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
65 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
66#ifndef CONFIG_MPC83XX_PCI2
67 struct pci_region *reg[] = { pci1_regions };
68#else
69 struct pci_region *reg[] = { pci1_regions, pci2_regions };
70#endif
Timur Tabi054838e2006-10-31 18:44:42 -060071 u8 reg8;
Timur Tabi054838e2006-10-31 18:44:42 -060072
Heiko Schocherf2850742012-10-24 13:48:22 +020073#if defined(CONFIG_SYS_I2C)
Timur Tabiab347542006-11-03 19:15:00 -060074 i2c_set_bus_num(1);
Timur Tabi054838e2006-10-31 18:44:42 -060075 /* Read the PCI_M66EN jumper setting */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020076 if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0) ||
77 (i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, &reg8, sizeof(reg8)) == 0)) {
Timur Tabi054838e2006-10-31 18:44:42 -060078 if (reg8 & I2C_8574_PCI66)
79 clk->occr = 0xff000000; /* 66 MHz PCI */
80 else
81 clk->occr = 0xff600001; /* 33 MHz PCI */
82 } else {
83 clk->occr = 0xff600001; /* 33 MHz PCI */
84 }
85#else
86 clk->occr = 0xff000000; /* 66 MHz PCI */
87#endif
Timur Tabi054838e2006-10-31 18:44:42 -060088 udelay(2000);
Timur Tabi054838e2006-10-31 18:44:42 -060089
Kim Phillips57a2af32009-07-18 18:42:13 -050090 /* Configure PCI Local Access Windows */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020091 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Timur Tabi054838e2006-10-31 18:44:42 -060092 pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
93
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020094 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Timur Tabie9b04f02006-10-31 19:14:41 -060095 pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
Timur Tabi054838e2006-10-31 18:44:42 -060096
Kim Phillips57a2af32009-07-18 18:42:13 -050097 udelay(2000);
Kim Phillips21416812007-08-15 22:30:33 -050098
Kim Phillips57a2af32009-07-18 18:42:13 -050099#ifndef CONFIG_MPC83XX_PCI2
Peter Tysere2283322010-09-14 19:13:50 -0500100 mpc83xx_pci_init(1, reg);
Kim Phillips57a2af32009-07-18 18:42:13 -0500101#else
Peter Tysere2283322010-09-14 19:13:50 -0500102 mpc83xx_pci_init(2, reg);
Kim Phillips21416812007-08-15 22:30:33 -0500103#endif
Kim Phillips774e1b52006-11-01 00:10:40 -0600104}