blob: 56f290ca92d682a2adf2f6c5731571ed372aaa54 [file] [log] [blame]
wdenk28536032003-03-25 16:50:56 +00001/*
2 * (C) Copyright 2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denk34ca9d32005-09-25 18:49:35 +02005 * Copyright (c) 2005 MontaVista Software, Inc.
Wolfgang Denk8cc89d92005-09-25 16:27:55 +02006 * Vitaly Bordug <vbordug@ru.mvista.com>
7 * Added support for PCI bridge on MPC8272ADS
8 *
Wolfgang Denkbd8ec7e2013-10-07 13:07:26 +02009 * SPDX-License-Identifier: GPL-2.0+
wdenk28536032003-03-25 16:50:56 +000010 */
11
12#include <common.h>
13
14#ifdef CONFIG_PCI
15
16#include <pci.h>
wdenkbf2f8c92003-05-22 22:52:13 +000017#include <mpc8260.h>
wdenk28536032003-03-25 16:50:56 +000018#include <asm/m8260_pci.h>
wdenk56ed43e2004-02-22 23:46:08 +000019#include <asm/io.h>
Matvejchikov Ilya8743c792008-07-06 13:57:00 +040020#ifdef CONFIG_OF_LIBFDT
21#include <libfdt.h>
22#include <fdt_support.h>
23#endif
Wolfgang Denk6405a152006-03-31 18:32:53 +020024
wdenk28536032003-03-25 16:50:56 +000025/*
wdenk56ed43e2004-02-22 23:46:08 +000026 * Local->PCI map (from CPU) controlled by
wdenk28536032003-03-25 16:50:56 +000027 * MPC826x master window
28 *
wdenk56ed43e2004-02-22 23:46:08 +000029 * 0x80000000 - 0xBFFFFFFF CPU2PCI space PCIBR0
30 * 0xF4000000 - 0xF7FFFFFF CPU2PCI space PCIBR1
wdenk57b2d802003-06-27 21:31:46 +000031 *
wdenk56ed43e2004-02-22 23:46:08 +000032 * 0x80000000 - 0x9FFFFFFF 0x80000000 - 0x9FFFFFFF (Outbound ATU #1)
33 * PCI Mem with prefetch
wdenkbf2f8c92003-05-22 22:52:13 +000034 *
wdenk56ed43e2004-02-22 23:46:08 +000035 * 0xA0000000 - 0xBFFFFFFF 0xA0000000 - 0xBFFFFFFF (Outbound ATU #2)
36 * PCI Mem w/o prefetch
wdenkbf2f8c92003-05-22 22:52:13 +000037 *
wdenk56ed43e2004-02-22 23:46:08 +000038 * 0xF4000000 - 0xF7FFFFFF 0x00000000 - 0x03FFFFFF (Outbound ATU #3)
39 * 32-bit PCI IO
wdenk57b2d802003-06-27 21:31:46 +000040 *
wdenk28536032003-03-25 16:50:56 +000041 * PCI->Local map (from PCI)
wdenk56ed43e2004-02-22 23:46:08 +000042 * MPC826x slave window controlled by
wdenk28536032003-03-25 16:50:56 +000043 *
wdenk56ed43e2004-02-22 23:46:08 +000044 * 0x00000000 - 0x1FFFFFFF 0x00000000 - 0x1FFFFFFF (Inbound ATU #1)
45 * MPC826x local memory
wdenk28536032003-03-25 16:50:56 +000046 */
47
wdenk57b2d802003-06-27 21:31:46 +000048/*
49 * Slave window that allows PCI masters to access MPC826x local memory.
wdenk28536032003-03-25 16:50:56 +000050 * This window is set up using the first set of Inbound ATU registers
51 */
52
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020053#ifndef CONFIG_SYS_PCI_SLV_MEM_LOCAL
54#define PCI_SLV_MEM_LOCAL CONFIG_SYS_SDRAM_BASE /* Local base */
wdenk57b2d802003-06-27 21:31:46 +000055#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020056#define PCI_SLV_MEM_LOCAL CONFIG_SYS_PCI_SLV_MEM_LOCAL
wdenkbf2f8c92003-05-22 22:52:13 +000057#endif
58
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020059#ifndef CONFIG_SYS_PCI_SLV_MEM_BUS
wdenk56ed43e2004-02-22 23:46:08 +000060#define PCI_SLV_MEM_BUS 0x00000000 /* PCI base */
wdenkbf2f8c92003-05-22 22:52:13 +000061#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020062#define PCI_SLV_MEM_BUS CONFIG_SYS_PCI_SLV_MEM_BUS
wdenkbf2f8c92003-05-22 22:52:13 +000063#endif
64
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020065#ifndef CONFIG_SYS_PICMR0_MASK_ATTRIB
wdenk28536032003-03-25 16:50:56 +000066#define PICMR0_MASK_ATTRIB (PICMR_MASK_512MB | PICMR_ENABLE | \
wdenk57b2d802003-06-27 21:31:46 +000067 PICMR_PREFETCH_EN)
wdenkbf2f8c92003-05-22 22:52:13 +000068#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020069#define PICMR0_MASK_ATTRIB CONFIG_SYS_PICMR0_MASK_ATTRIB
wdenkbf2f8c92003-05-22 22:52:13 +000070#endif
wdenk28536032003-03-25 16:50:56 +000071
wdenk57b2d802003-06-27 21:31:46 +000072/*
wdenkbf2f8c92003-05-22 22:52:13 +000073 * These are the windows that allow the CPU to access PCI address space.
wdenk57b2d802003-06-27 21:31:46 +000074 * All three PCI master windows, which allow the CPU to access PCI
75 * prefetch, non prefetch, and IO space (see below), must all fit within
wdenkbf2f8c92003-05-22 22:52:13 +000076 * these windows.
wdenk28536032003-03-25 16:50:56 +000077 */
78
wdenkbf2f8c92003-05-22 22:52:13 +000079/* PCIBR0 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020080#ifndef CONFIG_SYS_PCI_MSTR0_LOCAL
wdenk56ed43e2004-02-22 23:46:08 +000081#define PCI_MSTR0_LOCAL 0x80000000 /* Local base */
wdenk57b2d802003-06-27 21:31:46 +000082#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020083#define PCI_MSTR0_LOCAL CONFIG_SYS_PCI_MSTR0_LOCAL
wdenkbf2f8c92003-05-22 22:52:13 +000084#endif
85
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020086#ifndef CONFIG_SYS_PCIMSK0_MASK
wdenk56ed43e2004-02-22 23:46:08 +000087#define PCIMSK0_MASK PCIMSK_1GB /* Size of window */
wdenkbf2f8c92003-05-22 22:52:13 +000088#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020089#define PCIMSK0_MASK CONFIG_SYS_PCIMSK0_MASK
wdenkbf2f8c92003-05-22 22:52:13 +000090#endif
91
92/* PCIBR1 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020093#ifndef CONFIG_SYS_PCI_MSTR1_LOCAL
wdenk56ed43e2004-02-22 23:46:08 +000094#define PCI_MSTR1_LOCAL 0xF4000000 /* Local base */
wdenk57b2d802003-06-27 21:31:46 +000095#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020096#define PCI_MSTR1_LOCAL CONFIG_SYS_PCI_MSTR1_LOCAL
wdenkbf2f8c92003-05-22 22:52:13 +000097#endif
98
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020099#ifndef CONFIG_SYS_PCIMSK1_MASK
wdenk56ed43e2004-02-22 23:46:08 +0000100#define PCIMSK1_MASK PCIMSK_64MB /* Size of window */
wdenkbf2f8c92003-05-22 22:52:13 +0000101#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200102#define PCIMSK1_MASK CONFIG_SYS_PCIMSK1_MASK
wdenkbf2f8c92003-05-22 22:52:13 +0000103#endif
wdenk28536032003-03-25 16:50:56 +0000104
wdenk57b2d802003-06-27 21:31:46 +0000105/*
wdenk28536032003-03-25 16:50:56 +0000106 * Master window that allows the CPU to access PCI Memory (prefetch).
107 * This window will be setup with the first set of Outbound ATU registers
108 * in the bridge.
109 */
110
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200111#ifndef CONFIG_SYS_PCI_MSTR_MEM_LOCAL
wdenk56ed43e2004-02-22 23:46:08 +0000112#define PCI_MSTR_MEM_LOCAL 0x80000000 /* Local base */
wdenkbf2f8c92003-05-22 22:52:13 +0000113#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200114#define PCI_MSTR_MEM_LOCAL CONFIG_SYS_PCI_MSTR_MEM_LOCAL
wdenkbf2f8c92003-05-22 22:52:13 +0000115#endif
116
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200117#ifndef CONFIG_SYS_PCI_MSTR_MEM_BUS
wdenk56ed43e2004-02-22 23:46:08 +0000118#define PCI_MSTR_MEM_BUS 0x80000000 /* PCI base */
wdenkbf2f8c92003-05-22 22:52:13 +0000119#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200120#define PCI_MSTR_MEM_BUS CONFIG_SYS_PCI_MSTR_MEM_BUS
wdenkbf2f8c92003-05-22 22:52:13 +0000121#endif
122
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200123#ifndef CONFIG_SYS_CPU_PCI_MEM_START
wdenkbf2f8c92003-05-22 22:52:13 +0000124#define CPU_PCI_MEM_START PCI_MSTR_MEM_LOCAL
125#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200126#define CPU_PCI_MEM_START CONFIG_SYS_CPU_PCI_MEM_START
wdenkbf2f8c92003-05-22 22:52:13 +0000127#endif
128
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200129#ifndef CONFIG_SYS_PCI_MSTR_MEM_SIZE
wdenk56ed43e2004-02-22 23:46:08 +0000130#define PCI_MSTR_MEM_SIZE 0x10000000 /* 256MB */
wdenkbf2f8c92003-05-22 22:52:13 +0000131#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200132#define PCI_MSTR_MEM_SIZE CONFIG_SYS_PCI_MSTR_MEM_SIZE
wdenkbf2f8c92003-05-22 22:52:13 +0000133#endif
134
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200135#ifndef CONFIG_SYS_POCMR0_MASK_ATTRIB
wdenk28536032003-03-25 16:50:56 +0000136#define POCMR0_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PREFETCH_EN)
wdenkbf2f8c92003-05-22 22:52:13 +0000137#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200138#define POCMR0_MASK_ATTRIB CONFIG_SYS_POCMR0_MASK_ATTRIB
wdenkbf2f8c92003-05-22 22:52:13 +0000139#endif
wdenk28536032003-03-25 16:50:56 +0000140
wdenk57b2d802003-06-27 21:31:46 +0000141/*
wdenk28536032003-03-25 16:50:56 +0000142 * Master window that allows the CPU to access PCI Memory (non-prefetch).
143 * This window will be setup with the second set of Outbound ATU registers
144 * in the bridge.
145 */
146
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200147#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL
wdenk56ed43e2004-02-22 23:46:08 +0000148#define PCI_MSTR_MEMIO_LOCAL 0x90000000 /* Local base */
wdenk57b2d802003-06-27 21:31:46 +0000149#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200150#define PCI_MSTR_MEMIO_LOCAL CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL
wdenkbf2f8c92003-05-22 22:52:13 +0000151#endif
152
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200153#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_BUS
wdenk56ed43e2004-02-22 23:46:08 +0000154#define PCI_MSTR_MEMIO_BUS 0x90000000 /* PCI base */
wdenk57b2d802003-06-27 21:31:46 +0000155#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200156#define PCI_MSTR_MEMIO_BUS CONFIG_SYS_PCI_MSTR_MEMIO_BUS
wdenkbf2f8c92003-05-22 22:52:13 +0000157#endif
158
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200159#ifndef CONFIG_SYS_CPU_PCI_MEMIO_START
wdenk57b2d802003-06-27 21:31:46 +0000160#define CPU_PCI_MEMIO_START PCI_MSTR_MEMIO_LOCAL
161#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200162#define CPU_PCI_MEMIO_START CONFIG_SYS_CPU_PCI_MEMIO_START
wdenkbf2f8c92003-05-22 22:52:13 +0000163#endif
164
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200165#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_SIZE
wdenk56ed43e2004-02-22 23:46:08 +0000166#define PCI_MSTR_MEMIO_SIZE 0x10000000 /* 256 MB */
wdenk57b2d802003-06-27 21:31:46 +0000167#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200168#define PCI_MSTR_MEMIO_SIZE CONFIG_SYS_PCI_MSTR_MEMIO_SIZE
wdenkbf2f8c92003-05-22 22:52:13 +0000169#endif
170
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200171#ifndef CONFIG_SYS_POCMR1_MASK_ATTRIB
wdenk56ed43e2004-02-22 23:46:08 +0000172#define POCMR1_MASK_ATTRIB (POCMR_MASK_512MB | POCMR_ENABLE)
wdenkbf2f8c92003-05-22 22:52:13 +0000173#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200174#define POCMR1_MASK_ATTRIB CONFIG_SYS_POCMR1_MASK_ATTRIB
wdenkbf2f8c92003-05-22 22:52:13 +0000175#endif
wdenk28536032003-03-25 16:50:56 +0000176
wdenk57b2d802003-06-27 21:31:46 +0000177/*
wdenk28536032003-03-25 16:50:56 +0000178 * Master window that allows the CPU to access PCI IO space.
179 * This window will be setup with the third set of Outbound ATU registers
180 * in the bridge.
181 */
182
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200183#ifndef CONFIG_SYS_PCI_MSTR_IO_LOCAL
wdenk56ed43e2004-02-22 23:46:08 +0000184#define PCI_MSTR_IO_LOCAL 0xA0000000 /* Local base */
wdenk57b2d802003-06-27 21:31:46 +0000185#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200186#define PCI_MSTR_IO_LOCAL CONFIG_SYS_PCI_MSTR_IO_LOCAL
wdenkbf2f8c92003-05-22 22:52:13 +0000187#endif
188
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200189#ifndef CONFIG_SYS_PCI_MSTR_IO_BUS
wdenk56ed43e2004-02-22 23:46:08 +0000190#define PCI_MSTR_IO_BUS 0xA0000000 /* PCI base */
wdenk57b2d802003-06-27 21:31:46 +0000191#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200192#define PCI_MSTR_IO_BUS CONFIG_SYS_PCI_MSTR_IO_BUS
wdenkbf2f8c92003-05-22 22:52:13 +0000193#endif
194
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200195#ifndef CONFIG_SYS_CPU_PCI_IO_START
wdenk57b2d802003-06-27 21:31:46 +0000196#define CPU_PCI_IO_START PCI_MSTR_IO_LOCAL
197#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200198#define CPU_PCI_IO_START CONFIG_SYS_CPU_PCI_IO_START
wdenkbf2f8c92003-05-22 22:52:13 +0000199#endif
200
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200201#ifndef CONFIG_SYS_PCI_MSTR_IO_SIZE
wdenk56ed43e2004-02-22 23:46:08 +0000202#define PCI_MSTR_IO_SIZE 0x10000000 /* 256MB */
wdenk57b2d802003-06-27 21:31:46 +0000203#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200204#define PCI_MSTR_IO_SIZE CONFIG_SYS_PCI_MSTR_IO_SIZE
wdenke5d61c72003-05-18 11:30:09 +0000205#endif
wdenkbf2f8c92003-05-22 22:52:13 +0000206
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200207#ifndef CONFIG_SYS_POCMR2_MASK_ATTRIB
wdenk56ed43e2004-02-22 23:46:08 +0000208#define POCMR2_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PCI_IO)
wdenkbf2f8c92003-05-22 22:52:13 +0000209#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200210#define POCMR2_MASK_ATTRIB CONFIG_SYS_POCMR2_MASK_ATTRIB
wdenkbf2f8c92003-05-22 22:52:13 +0000211#endif
wdenk28536032003-03-25 16:50:56 +0000212
213/* PCI bus configuration registers.
214 */
215
216#define PCI_CLASS_BRIDGE_CTLR 0x06
217
218
wdenk56ed43e2004-02-22 23:46:08 +0000219static inline void pci_outl (u32 addr, u32 data)
wdenk28536032003-03-25 16:50:56 +0000220{
wdenk56ed43e2004-02-22 23:46:08 +0000221 *(volatile u32 *) addr = cpu_to_le32 (data);
wdenk28536032003-03-25 16:50:56 +0000222}
223
wdenk56ed43e2004-02-22 23:46:08 +0000224void pci_mpc8250_init (struct pci_controller *hose)
wdenk28536032003-03-25 16:50:56 +0000225{
wdenk56ed43e2004-02-22 23:46:08 +0000226 u16 tempShort;
227
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200228 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
wdenk56ed43e2004-02-22 23:46:08 +0000229 pci_dev_t host_devno = PCI_BDF (0, 0, 0);
wdenk28536032003-03-25 16:50:56 +0000230
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200231 pci_setup_indirect (hose, CONFIG_SYS_IMMR + PCI_CFG_ADDR_REG,
232 CONFIG_SYS_IMMR + PCI_CFG_DATA_REG);
wdenk28536032003-03-25 16:50:56 +0000233
wdenk56ed43e2004-02-22 23:46:08 +0000234 /*
wdenk56ed43e2004-02-22 23:46:08 +0000235 * Setting required to enable IRQ1-IRQ7 (SIUMCR [DPPC]),
236 * and local bus for PCI (SIUMCR [LBPC]).
237 */
238 immap->im_siu_conf.sc_siumcr = (immap->im_siu_conf.sc_siumcr &
239 ~SIUMCR_LBPC11 &
wdenk57b2d802003-06-27 21:31:46 +0000240 ~SIUMCR_CS10PC11 &
wdenk56ed43e2004-02-22 23:46:08 +0000241 ~SIUMCR_LBPC11) |
242 SIUMCR_LBPC01 |
243 SIUMCR_CS10PC01 |
244 SIUMCR_APPC10;
wdenk28536032003-03-25 16:50:56 +0000245
wdenk56ed43e2004-02-22 23:46:08 +0000246 /* Make PCI lowest priority */
247 /* Each 4 bits is a device bus request and the MS 4bits
248 is highest priority */
249 /* Bus 4bit value
250 --- ----------
251 CPM high 0b0000
252 CPM middle 0b0001
253 CPM low 0b0010
254 PCI reguest 0b0011
255 Reserved 0b0100
256 Reserved 0b0101
257 Internal Core 0b0110
258 External Master 1 0b0111
259 External Master 2 0b1000
260 External Master 3 0b1001
261 The rest are reserved */
262 immap->im_siu_conf.sc_ppc_alrh = 0x61207893;
wdenk28536032003-03-25 16:50:56 +0000263
wdenk56ed43e2004-02-22 23:46:08 +0000264 /* Park bus on core while modifying PCI Bus accesses */
265 immap->im_siu_conf.sc_ppc_acr = 0x6;
wdenk28536032003-03-25 16:50:56 +0000266
wdenk56ed43e2004-02-22 23:46:08 +0000267 /*
268 * Set up master windows that allow the CPU to access PCI space. These
269 * windows are set up using the two SIU PCIBR registers.
270 */
271 immap->im_memctl.memc_pcimsk0 = PCIMSK0_MASK;
272 immap->im_memctl.memc_pcibr0 = PCI_MSTR0_LOCAL | PCIBR_ENABLE;
wdenkbf2f8c92003-05-22 22:52:13 +0000273
wdenk56ed43e2004-02-22 23:46:08 +0000274 /* Release PCI RST (by default the PCI RST signal is held low) */
275 immap->im_pci.pci_gcr = cpu_to_le32 (PCIGCR_PCI_BUS_EN);
wdenk28536032003-03-25 16:50:56 +0000276
wdenk56ed43e2004-02-22 23:46:08 +0000277 /* give it some time */
278 {
wdenk56ed43e2004-02-22 23:46:08 +0000279 udelay (1000);
280 }
wdenk28536032003-03-25 16:50:56 +0000281
wdenk56ed43e2004-02-22 23:46:08 +0000282 /*
283 * Set up master window that allows the CPU to access PCI Memory (prefetch)
284 * space. This window is set up using the first set of Outbound ATU registers.
285 */
286 immap->im_pci.pci_potar0 = cpu_to_le32 (PCI_MSTR_MEM_BUS >> 12); /* PCI base */
287 immap->im_pci.pci_pobar0 = cpu_to_le32 (PCI_MSTR_MEM_LOCAL >> 12); /* Local base */
288 immap->im_pci.pci_pocmr0 = cpu_to_le32 (POCMR0_MASK_ATTRIB); /* Size & attribute */
wdenk28536032003-03-25 16:50:56 +0000289
wdenk56ed43e2004-02-22 23:46:08 +0000290 /*
291 * Set up master window that allows the CPU to access PCI Memory (non-prefetch)
292 * space. This window is set up using the second set of Outbound ATU registers.
293 */
294 immap->im_pci.pci_potar1 = cpu_to_le32 (PCI_MSTR_MEMIO_BUS >> 12); /* PCI base */
295 immap->im_pci.pci_pobar1 = cpu_to_le32 (PCI_MSTR_MEMIO_LOCAL >> 12); /* Local base */
296 immap->im_pci.pci_pocmr1 = cpu_to_le32 (POCMR1_MASK_ATTRIB); /* Size & attribute */
wdenk57b2d802003-06-27 21:31:46 +0000297
wdenk56ed43e2004-02-22 23:46:08 +0000298 /*
299 * Set up master window that allows the CPU to access PCI IO space. This window
300 * is set up using the third set of Outbound ATU registers.
301 */
302 immap->im_pci.pci_potar2 = cpu_to_le32 (PCI_MSTR_IO_BUS >> 12); /* PCI base */
303 immap->im_pci.pci_pobar2 = cpu_to_le32 (PCI_MSTR_IO_LOCAL >> 12); /* Local base */
304 immap->im_pci.pci_pocmr2 = cpu_to_le32 (POCMR2_MASK_ATTRIB); /* Size & attribute */
wdenk28536032003-03-25 16:50:56 +0000305
wdenk56ed43e2004-02-22 23:46:08 +0000306 /*
307 * Set up slave window that allows PCI masters to access MPC826x local memory.
308 * This window is set up using the first set of Inbound ATU registers
309 */
310 immap->im_pci.pci_pitar0 = cpu_to_le32 (PCI_SLV_MEM_LOCAL >> 12); /* PCI base */
311 immap->im_pci.pci_pibar0 = cpu_to_le32 (PCI_SLV_MEM_BUS >> 12); /* Local base */
312 immap->im_pci.pci_picmr0 = cpu_to_le32 (PICMR0_MASK_ATTRIB); /* Size & attribute */
wdenk28536032003-03-25 16:50:56 +0000313
wdenk56ed43e2004-02-22 23:46:08 +0000314 /* See above for description - puts PCI request as highest priority */
315 immap->im_siu_conf.sc_ppc_alrh = 0x03124567;
wdenk28536032003-03-25 16:50:56 +0000316
wdenk56ed43e2004-02-22 23:46:08 +0000317 /* Park the bus on the PCI */
318 immap->im_siu_conf.sc_ppc_acr = PPC_ACR_BUS_PARK_PCI;
wdenk28536032003-03-25 16:50:56 +0000319
wdenk56ed43e2004-02-22 23:46:08 +0000320 /* Host mode - specify the bridge as a host-PCI bridge */
wdenk28536032003-03-25 16:50:56 +0000321
wdenk56ed43e2004-02-22 23:46:08 +0000322 pci_hose_write_config_byte (hose, host_devno, PCI_CLASS_CODE,
323 PCI_CLASS_BRIDGE_CTLR);
wdenk28536032003-03-25 16:50:56 +0000324
wdenk56ed43e2004-02-22 23:46:08 +0000325 /* Enable the host bridge to be a master on the PCI bus, and to act as a PCI memory target */
326 pci_hose_read_config_word (hose, host_devno, PCI_COMMAND, &tempShort);
327 pci_hose_write_config_word (hose, host_devno, PCI_COMMAND,
328 tempShort | PCI_COMMAND_MASTER |
329 PCI_COMMAND_MEMORY);
wdenk28536032003-03-25 16:50:56 +0000330
wdenkabda5ca2003-05-31 18:35:21 +0000331 /* do some bridge init, should be done on all 8260 based bridges */
wdenk56ed43e2004-02-22 23:46:08 +0000332 pci_hose_write_config_byte (hose, host_devno, PCI_CACHE_LINE_SIZE,
333 0x08);
334 pci_hose_write_config_byte (hose, host_devno, PCI_LATENCY_TIMER,
335 0xF8);
wdenkabda5ca2003-05-31 18:35:21 +0000336
wdenk56ed43e2004-02-22 23:46:08 +0000337 hose->first_busno = 0;
338 hose->last_busno = 0xff;
wdenk28536032003-03-25 16:50:56 +0000339
wdenk56ed43e2004-02-22 23:46:08 +0000340 /* System memory space */
wdenk56ed43e2004-02-22 23:46:08 +0000341 pci_set_region (hose->regions + 0,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200342 CONFIG_SYS_SDRAM_BASE,
343 CONFIG_SYS_SDRAM_BASE,
Kumar Galaefa1f1d2009-02-06 09:49:31 -0600344 0x4000000, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
wdenk28536032003-03-25 16:50:56 +0000345
wdenk56ed43e2004-02-22 23:46:08 +0000346 /* PCI memory space */
wdenk56ed43e2004-02-22 23:46:08 +0000347 pci_set_region (hose->regions + 1,
348 PCI_MSTR_MEM_BUS,
349 PCI_MSTR_MEM_LOCAL,
350 PCI_MSTR_MEM_SIZE, PCI_REGION_MEM);
wdenk28536032003-03-25 16:50:56 +0000351
wdenk56ed43e2004-02-22 23:46:08 +0000352 /* PCI I/O space */
353 pci_set_region (hose->regions + 2,
354 PCI_MSTR_IO_BUS,
355 PCI_MSTR_IO_LOCAL, PCI_MSTR_IO_SIZE, PCI_REGION_IO);
356
357 hose->region_count = 3;
wdenk28536032003-03-25 16:50:56 +0000358
wdenk56ed43e2004-02-22 23:46:08 +0000359 pci_register_hose (hose);
360 /* Mask off master abort machine checks */
361 immap->im_pci.pci_emr &= cpu_to_le32 (~PCI_ERROR_PCI_NO_RSP);
362 eieio ();
wdenk28536032003-03-25 16:50:56 +0000363
wdenk56ed43e2004-02-22 23:46:08 +0000364 hose->last_busno = pci_hose_scan (hose);
wdenk28536032003-03-25 16:50:56 +0000365
wdenk56ed43e2004-02-22 23:46:08 +0000366
367 /* clear the error in the error status register */
368 immap->im_pci.pci_esr = cpu_to_le32 (PCI_ERROR_PCI_NO_RSP);
369
370 /* unmask master abort machine checks */
371 immap->im_pci.pci_emr |= cpu_to_le32 (PCI_ERROR_PCI_NO_RSP);
wdenk28536032003-03-25 16:50:56 +0000372}
373
Matvejchikov Ilya8743c792008-07-06 13:57:00 +0400374#if defined(CONFIG_OF_LIBFDT)
375void ft_pci_setup(void *blob, bd_t *bd)
376{
377 do_fixup_by_prop_u32(blob, "device_type", "pci", 4,
Wolfgang Denk20de6ac2008-08-12 12:10:11 +0200378 "clock-frequency", gd->pci_clk, 1);
Matvejchikov Ilya8743c792008-07-06 13:57:00 +0400379}
380#endif
381
wdenk56ed43e2004-02-22 23:46:08 +0000382#endif /* CONFIG_PCI */