blob: 1acec849683d1f736295c796d63263aa627094e7 [file] [log] [blame]
Rafal Jaworowski6902df52005-10-17 02:39:53 +02001/*
2 * (C) Copyright 2005
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Kim Phillips9993e192009-07-18 18:42:13 -05004 * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
Rafal Jaworowski6902df52005-10-17 02:39:53 +02005 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Rafal Jaworowski6902df52005-10-17 02:39:53 +02007 */
8
9#include <asm/mmu.h>
Kim Phillips9993e192009-07-18 18:42:13 -050010#include <asm/io.h>
Rafal Jaworowski6902df52005-10-17 02:39:53 +020011#include <common.h>
Kim Phillips9993e192009-07-18 18:42:13 -050012#include <mpc83xx.h>
Rafal Jaworowski6902df52005-10-17 02:39:53 +020013#include <pci.h>
Kim Phillips9993e192009-07-18 18:42:13 -050014#include <i2c.h>
15#include <asm/fsl_i2c.h>
Wolfgang Denk4681e672009-05-14 23:18:34 +020016
17DECLARE_GLOBAL_DATA_PTR;
Rafal Jaworowski6902df52005-10-17 02:39:53 +020018
Kim Phillips9993e192009-07-18 18:42:13 -050019static struct pci_region pci1_regions[] = {
20 {
21 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
22 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
23 size: CONFIG_SYS_PCI1_MEM_SIZE,
24 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
Rafal Jaworowski6902df52005-10-17 02:39:53 +020025 },
Kim Phillips9993e192009-07-18 18:42:13 -050026 {
27 bus_start: CONFIG_SYS_PCI1_IO_BASE,
28 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
29 size: CONFIG_SYS_PCI1_IO_SIZE,
30 flags: PCI_REGION_IO
31 },
32 {
33 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
34 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
35 size: CONFIG_SYS_PCI1_MMIO_SIZE,
36 flags: PCI_REGION_MEM
37 },
Rafal Jaworowski6902df52005-10-17 02:39:53 +020038};
39
Kim Phillips9993e192009-07-18 18:42:13 -050040/*
Rafal Jaworowski6902df52005-10-17 02:39:53 +020041 * pci_init_board()
42 *
43 * NOTICE: MPC8349 internally has two PCI controllers (PCI1 and PCI2) but since
44 * per TQM834x design physical connections to external devices (PCI sockets)
45 * are routed only to the PCI1 we do not account for the second one - this code
46 * supports PCI1 module only. Should support for the PCI2 be required in the
47 * future it needs a separate pci_controller structure (above) and handling -
48 * please refer to other boards' implementation for dual PCI host controllers,
49 * for example board/Marvell/db64360/pci.c, pci_init_board()
50 *
51 */
52void
53pci_init_board(void)
54{
Kim Phillips9993e192009-07-18 18:42:13 -050055 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
56 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
57 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
58 struct pci_region *reg[] = { pci1_regions };
Rafal Jaworowski6902df52005-10-17 02:39:53 +020059 u32 reg32;
Wolfgang Denkf013dac2005-12-04 00:40:34 +010060
Rafal Jaworowski6902df52005-10-17 02:39:53 +020061 /*
Wolfgang Denkf013dac2005-12-04 00:40:34 +010062 * Configure PCI controller and PCI_CLK_OUTPUT
Kim Phillips9993e192009-07-18 18:42:13 -050063 *
Rafal Jaworowski6902df52005-10-17 02:39:53 +020064 * WARNING! only PCI_CLK_OUTPUT1 is enabled here as this is the one
65 * line actually used for clocking all external PCI devices in TQM83xx.
Wolfgang Denkf013dac2005-12-04 00:40:34 +010066 * Enabling other PCI_CLK_OUTPUT lines may lead to board's hang for
Rafal Jaworowski6902df52005-10-17 02:39:53 +020067 * unknown reasons - particularly PCI_CLK_OUTPUT6 and PCI_CLK_OUTPUT7
Wolfgang Denkf013dac2005-12-04 00:40:34 +010068 * are known to hang the board; this issue is under investigation
Rafal Jaworowski6902df52005-10-17 02:39:53 +020069 * (13 oct 05)
70 */
71 reg32 = OCCR_PCICOE1;
Wolfgang Denkf013dac2005-12-04 00:40:34 +010072#if 0
Rafal Jaworowski6902df52005-10-17 02:39:53 +020073 /* enabling all PCI_CLK_OUTPUT lines HANGS the board... */
74 reg32 = 0xff000000;
Wolfgang Denkf013dac2005-12-04 00:40:34 +010075#endif
Rafal Jaworowski6902df52005-10-17 02:39:53 +020076 if (clk->spmr & SPMR_CKID) {
77 /* PCI Clock is half CONFIG_83XX_CLKIN so need to set up OCCR
78 * fields accordingly */
79 reg32 |= (OCCR_PCI1CR | OCCR_PCI2CR);
Wolfgang Denkf013dac2005-12-04 00:40:34 +010080
Rafal Jaworowski6902df52005-10-17 02:39:53 +020081 reg32 |= (OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 \
82 | OCCR_PCICD3 | OCCR_PCICD4 | OCCR_PCICD5 \
83 | OCCR_PCICD6 | OCCR_PCICD7);
84 }
85
86 clk->occr = reg32;
87 udelay(2000);
88
Kim Phillips9993e192009-07-18 18:42:13 -050089 /* Configure PCI Local Access Windows */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020090 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Rafal Jaworowski5a164c82005-11-17 00:26:18 +010091 pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
Rafal Jaworowski6902df52005-10-17 02:39:53 +020092
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020093 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Rafal Jaworowski5a164c82005-11-17 00:26:18 +010094 pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_16M;
Rafal Jaworowski6902df52005-10-17 02:39:53 +020095
Kim Phillips9993e192009-07-18 18:42:13 -050096 udelay(2000);
Rafal Jaworowski6902df52005-10-17 02:39:53 +020097
Peter Tyser6aa3d3b2010-09-14 19:13:50 -050098 mpc83xx_pci_init(1, reg);
Rafal Jaworowski6902df52005-10-17 02:39:53 +020099}