blob: 56f290ca92d682a2adf2f6c5731571ed372aaa54 [file] [log] [blame]
wdenk4d75a502003-03-25 16:50:56 +00001/*
2 * (C) Copyright 2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denk716c1dc2005-09-25 18:49:35 +02005 * Copyright (c) 2005 MontaVista Software, Inc.
Wolfgang Denk1972dc02005-09-25 16:27:55 +02006 * Vitaly Bordug <vbordug@ru.mvista.com>
7 * Added support for PCI bridge on MPC8272ADS
8 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02009 * SPDX-License-Identifier: GPL-2.0+
wdenk4d75a502003-03-25 16:50:56 +000010 */
11
12#include <common.h>
13
14#ifdef CONFIG_PCI
15
16#include <pci.h>
wdenk5d232d02003-05-22 22:52:13 +000017#include <mpc8260.h>
wdenk4d75a502003-03-25 16:50:56 +000018#include <asm/m8260_pci.h>
wdenk3c74e322004-02-22 23:46:08 +000019#include <asm/io.h>
Matvejchikov Ilya0e6989b2008-07-06 13:57:00 +040020#ifdef CONFIG_OF_LIBFDT
21#include <libfdt.h>
22#include <fdt_support.h>
23#endif
Wolfgang Denkd87080b2006-03-31 18:32:53 +020024
wdenk4d75a502003-03-25 16:50:56 +000025/*
wdenk3c74e322004-02-22 23:46:08 +000026 * Local->PCI map (from CPU) controlled by
wdenk4d75a502003-03-25 16:50:56 +000027 * MPC826x master window
28 *
wdenk3c74e322004-02-22 23:46:08 +000029 * 0x80000000 - 0xBFFFFFFF CPU2PCI space PCIBR0
30 * 0xF4000000 - 0xF7FFFFFF CPU2PCI space PCIBR1
wdenk8bde7f72003-06-27 21:31:46 +000031 *
wdenk3c74e322004-02-22 23:46:08 +000032 * 0x80000000 - 0x9FFFFFFF 0x80000000 - 0x9FFFFFFF (Outbound ATU #1)
33 * PCI Mem with prefetch
wdenk5d232d02003-05-22 22:52:13 +000034 *
wdenk3c74e322004-02-22 23:46:08 +000035 * 0xA0000000 - 0xBFFFFFFF 0xA0000000 - 0xBFFFFFFF (Outbound ATU #2)
36 * PCI Mem w/o prefetch
wdenk5d232d02003-05-22 22:52:13 +000037 *
wdenk3c74e322004-02-22 23:46:08 +000038 * 0xF4000000 - 0xF7FFFFFF 0x00000000 - 0x03FFFFFF (Outbound ATU #3)
39 * 32-bit PCI IO
wdenk8bde7f72003-06-27 21:31:46 +000040 *
wdenk4d75a502003-03-25 16:50:56 +000041 * PCI->Local map (from PCI)
wdenk3c74e322004-02-22 23:46:08 +000042 * MPC826x slave window controlled by
wdenk4d75a502003-03-25 16:50:56 +000043 *
wdenk3c74e322004-02-22 23:46:08 +000044 * 0x00000000 - 0x1FFFFFFF 0x00000000 - 0x1FFFFFFF (Inbound ATU #1)
45 * MPC826x local memory
wdenk4d75a502003-03-25 16:50:56 +000046 */
47
wdenk8bde7f72003-06-27 21:31:46 +000048/*
49 * Slave window that allows PCI masters to access MPC826x local memory.
wdenk4d75a502003-03-25 16:50:56 +000050 * This window is set up using the first set of Inbound ATU registers
51 */
52
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-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 */
wdenk8bde7f72003-06-27 21:31:46 +000055#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020056#define PCI_SLV_MEM_LOCAL CONFIG_SYS_PCI_SLV_MEM_LOCAL
wdenk5d232d02003-05-22 22:52:13 +000057#endif
58
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020059#ifndef CONFIG_SYS_PCI_SLV_MEM_BUS
wdenk3c74e322004-02-22 23:46:08 +000060#define PCI_SLV_MEM_BUS 0x00000000 /* PCI base */
wdenk5d232d02003-05-22 22:52:13 +000061#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020062#define PCI_SLV_MEM_BUS CONFIG_SYS_PCI_SLV_MEM_BUS
wdenk5d232d02003-05-22 22:52:13 +000063#endif
64
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020065#ifndef CONFIG_SYS_PICMR0_MASK_ATTRIB
wdenk4d75a502003-03-25 16:50:56 +000066#define PICMR0_MASK_ATTRIB (PICMR_MASK_512MB | PICMR_ENABLE | \
wdenk8bde7f72003-06-27 21:31:46 +000067 PICMR_PREFETCH_EN)
wdenk5d232d02003-05-22 22:52:13 +000068#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020069#define PICMR0_MASK_ATTRIB CONFIG_SYS_PICMR0_MASK_ATTRIB
wdenk5d232d02003-05-22 22:52:13 +000070#endif
wdenk4d75a502003-03-25 16:50:56 +000071
wdenk8bde7f72003-06-27 21:31:46 +000072/*
wdenk5d232d02003-05-22 22:52:13 +000073 * These are the windows that allow the CPU to access PCI address space.
wdenk8bde7f72003-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
wdenk5d232d02003-05-22 22:52:13 +000076 * these windows.
wdenk4d75a502003-03-25 16:50:56 +000077 */
78
wdenk5d232d02003-05-22 22:52:13 +000079/* PCIBR0 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020080#ifndef CONFIG_SYS_PCI_MSTR0_LOCAL
wdenk3c74e322004-02-22 23:46:08 +000081#define PCI_MSTR0_LOCAL 0x80000000 /* Local base */
wdenk8bde7f72003-06-27 21:31:46 +000082#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020083#define PCI_MSTR0_LOCAL CONFIG_SYS_PCI_MSTR0_LOCAL
wdenk5d232d02003-05-22 22:52:13 +000084#endif
85
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020086#ifndef CONFIG_SYS_PCIMSK0_MASK
wdenk3c74e322004-02-22 23:46:08 +000087#define PCIMSK0_MASK PCIMSK_1GB /* Size of window */
wdenk5d232d02003-05-22 22:52:13 +000088#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020089#define PCIMSK0_MASK CONFIG_SYS_PCIMSK0_MASK
wdenk5d232d02003-05-22 22:52:13 +000090#endif
91
92/* PCIBR1 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020093#ifndef CONFIG_SYS_PCI_MSTR1_LOCAL
wdenk3c74e322004-02-22 23:46:08 +000094#define PCI_MSTR1_LOCAL 0xF4000000 /* Local base */
wdenk8bde7f72003-06-27 21:31:46 +000095#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020096#define PCI_MSTR1_LOCAL CONFIG_SYS_PCI_MSTR1_LOCAL
wdenk5d232d02003-05-22 22:52:13 +000097#endif
98
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020099#ifndef CONFIG_SYS_PCIMSK1_MASK
wdenk3c74e322004-02-22 23:46:08 +0000100#define PCIMSK1_MASK PCIMSK_64MB /* Size of window */
wdenk5d232d02003-05-22 22:52:13 +0000101#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200102#define PCIMSK1_MASK CONFIG_SYS_PCIMSK1_MASK
wdenk5d232d02003-05-22 22:52:13 +0000103#endif
wdenk4d75a502003-03-25 16:50:56 +0000104
wdenk8bde7f72003-06-27 21:31:46 +0000105/*
wdenk4d75a502003-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-VILLARD6d0f6bc2008-10-16 15:01:15 +0200111#ifndef CONFIG_SYS_PCI_MSTR_MEM_LOCAL
wdenk3c74e322004-02-22 23:46:08 +0000112#define PCI_MSTR_MEM_LOCAL 0x80000000 /* Local base */
wdenk5d232d02003-05-22 22:52:13 +0000113#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200114#define PCI_MSTR_MEM_LOCAL CONFIG_SYS_PCI_MSTR_MEM_LOCAL
wdenk5d232d02003-05-22 22:52:13 +0000115#endif
116
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200117#ifndef CONFIG_SYS_PCI_MSTR_MEM_BUS
wdenk3c74e322004-02-22 23:46:08 +0000118#define PCI_MSTR_MEM_BUS 0x80000000 /* PCI base */
wdenk5d232d02003-05-22 22:52:13 +0000119#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200120#define PCI_MSTR_MEM_BUS CONFIG_SYS_PCI_MSTR_MEM_BUS
wdenk5d232d02003-05-22 22:52:13 +0000121#endif
122
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200123#ifndef CONFIG_SYS_CPU_PCI_MEM_START
wdenk5d232d02003-05-22 22:52:13 +0000124#define CPU_PCI_MEM_START PCI_MSTR_MEM_LOCAL
125#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200126#define CPU_PCI_MEM_START CONFIG_SYS_CPU_PCI_MEM_START
wdenk5d232d02003-05-22 22:52:13 +0000127#endif
128
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200129#ifndef CONFIG_SYS_PCI_MSTR_MEM_SIZE
wdenk3c74e322004-02-22 23:46:08 +0000130#define PCI_MSTR_MEM_SIZE 0x10000000 /* 256MB */
wdenk5d232d02003-05-22 22:52:13 +0000131#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200132#define PCI_MSTR_MEM_SIZE CONFIG_SYS_PCI_MSTR_MEM_SIZE
wdenk5d232d02003-05-22 22:52:13 +0000133#endif
134
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200135#ifndef CONFIG_SYS_POCMR0_MASK_ATTRIB
wdenk4d75a502003-03-25 16:50:56 +0000136#define POCMR0_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PREFETCH_EN)
wdenk5d232d02003-05-22 22:52:13 +0000137#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200138#define POCMR0_MASK_ATTRIB CONFIG_SYS_POCMR0_MASK_ATTRIB
wdenk5d232d02003-05-22 22:52:13 +0000139#endif
wdenk4d75a502003-03-25 16:50:56 +0000140
wdenk8bde7f72003-06-27 21:31:46 +0000141/*
wdenk4d75a502003-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-VILLARD6d0f6bc2008-10-16 15:01:15 +0200147#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL
wdenk3c74e322004-02-22 23:46:08 +0000148#define PCI_MSTR_MEMIO_LOCAL 0x90000000 /* Local base */
wdenk8bde7f72003-06-27 21:31:46 +0000149#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200150#define PCI_MSTR_MEMIO_LOCAL CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL
wdenk5d232d02003-05-22 22:52:13 +0000151#endif
152
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200153#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_BUS
wdenk3c74e322004-02-22 23:46:08 +0000154#define PCI_MSTR_MEMIO_BUS 0x90000000 /* PCI base */
wdenk8bde7f72003-06-27 21:31:46 +0000155#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200156#define PCI_MSTR_MEMIO_BUS CONFIG_SYS_PCI_MSTR_MEMIO_BUS
wdenk5d232d02003-05-22 22:52:13 +0000157#endif
158
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200159#ifndef CONFIG_SYS_CPU_PCI_MEMIO_START
wdenk8bde7f72003-06-27 21:31:46 +0000160#define CPU_PCI_MEMIO_START PCI_MSTR_MEMIO_LOCAL
161#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200162#define CPU_PCI_MEMIO_START CONFIG_SYS_CPU_PCI_MEMIO_START
wdenk5d232d02003-05-22 22:52:13 +0000163#endif
164
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200165#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_SIZE
wdenk3c74e322004-02-22 23:46:08 +0000166#define PCI_MSTR_MEMIO_SIZE 0x10000000 /* 256 MB */
wdenk8bde7f72003-06-27 21:31:46 +0000167#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200168#define PCI_MSTR_MEMIO_SIZE CONFIG_SYS_PCI_MSTR_MEMIO_SIZE
wdenk5d232d02003-05-22 22:52:13 +0000169#endif
170
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200171#ifndef CONFIG_SYS_POCMR1_MASK_ATTRIB
wdenk3c74e322004-02-22 23:46:08 +0000172#define POCMR1_MASK_ATTRIB (POCMR_MASK_512MB | POCMR_ENABLE)
wdenk5d232d02003-05-22 22:52:13 +0000173#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200174#define POCMR1_MASK_ATTRIB CONFIG_SYS_POCMR1_MASK_ATTRIB
wdenk5d232d02003-05-22 22:52:13 +0000175#endif
wdenk4d75a502003-03-25 16:50:56 +0000176
wdenk8bde7f72003-06-27 21:31:46 +0000177/*
wdenk4d75a502003-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-VILLARD6d0f6bc2008-10-16 15:01:15 +0200183#ifndef CONFIG_SYS_PCI_MSTR_IO_LOCAL
wdenk3c74e322004-02-22 23:46:08 +0000184#define PCI_MSTR_IO_LOCAL 0xA0000000 /* Local base */
wdenk8bde7f72003-06-27 21:31:46 +0000185#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200186#define PCI_MSTR_IO_LOCAL CONFIG_SYS_PCI_MSTR_IO_LOCAL
wdenk66fd3d12003-05-18 11:30:09 +0000187#endif
wdenk5d232d02003-05-22 22:52:13 +0000188
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200189#ifndef CONFIG_SYS_PCI_MSTR_IO_BUS
wdenk3c74e322004-02-22 23:46:08 +0000190#define PCI_MSTR_IO_BUS 0xA0000000 /* PCI base */
wdenk8bde7f72003-06-27 21:31:46 +0000191#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200192#define PCI_MSTR_IO_BUS CONFIG_SYS_PCI_MSTR_IO_BUS
wdenk5d232d02003-05-22 22:52:13 +0000193#endif
194
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200195#ifndef CONFIG_SYS_CPU_PCI_IO_START
wdenk8bde7f72003-06-27 21:31:46 +0000196#define CPU_PCI_IO_START PCI_MSTR_IO_LOCAL
197#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200198#define CPU_PCI_IO_START CONFIG_SYS_CPU_PCI_IO_START
wdenk5d232d02003-05-22 22:52:13 +0000199#endif
200
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200201#ifndef CONFIG_SYS_PCI_MSTR_IO_SIZE
wdenk3c74e322004-02-22 23:46:08 +0000202#define PCI_MSTR_IO_SIZE 0x10000000 /* 256MB */
wdenk8bde7f72003-06-27 21:31:46 +0000203#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200204#define PCI_MSTR_IO_SIZE CONFIG_SYS_PCI_MSTR_IO_SIZE
wdenk5d232d02003-05-22 22:52:13 +0000205#endif
206
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200207#ifndef CONFIG_SYS_POCMR2_MASK_ATTRIB
wdenk3c74e322004-02-22 23:46:08 +0000208#define POCMR2_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PCI_IO)
wdenk5d232d02003-05-22 22:52:13 +0000209#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200210#define POCMR2_MASK_ATTRIB CONFIG_SYS_POCMR2_MASK_ATTRIB
wdenk5d232d02003-05-22 22:52:13 +0000211#endif
wdenk4d75a502003-03-25 16:50:56 +0000212
213/* PCI bus configuration registers.
214 */
215
216#define PCI_CLASS_BRIDGE_CTLR 0x06
217
218
wdenk3c74e322004-02-22 23:46:08 +0000219static inline void pci_outl (u32 addr, u32 data)
wdenk4d75a502003-03-25 16:50:56 +0000220{
wdenk3c74e322004-02-22 23:46:08 +0000221 *(volatile u32 *) addr = cpu_to_le32 (data);
wdenk4d75a502003-03-25 16:50:56 +0000222}
223
wdenk3c74e322004-02-22 23:46:08 +0000224void pci_mpc8250_init (struct pci_controller *hose)
wdenk4d75a502003-03-25 16:50:56 +0000225{
wdenk3c74e322004-02-22 23:46:08 +0000226 u16 tempShort;
wdenk4d75a502003-03-25 16:50:56 +0000227
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200228 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
wdenk3c74e322004-02-22 23:46:08 +0000229 pci_dev_t host_devno = PCI_BDF (0, 0, 0);
wdenk4d75a502003-03-25 16:50:56 +0000230
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-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);
wdenk3c74e322004-02-22 23:46:08 +0000233
234 /*
wdenk3c74e322004-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 &
wdenk8bde7f72003-06-27 21:31:46 +0000240 ~SIUMCR_CS10PC11 &
wdenk3c74e322004-02-22 23:46:08 +0000241 ~SIUMCR_LBPC11) |
242 SIUMCR_LBPC01 |
243 SIUMCR_CS10PC01 |
244 SIUMCR_APPC10;
wdenk4d75a502003-03-25 16:50:56 +0000245
wdenk3c74e322004-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;
wdenk4d75a502003-03-25 16:50:56 +0000263
wdenk3c74e322004-02-22 23:46:08 +0000264 /* Park bus on core while modifying PCI Bus accesses */
265 immap->im_siu_conf.sc_ppc_acr = 0x6;
wdenk4d75a502003-03-25 16:50:56 +0000266
wdenk3c74e322004-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;
wdenk5d232d02003-05-22 22:52:13 +0000273
wdenk3c74e322004-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);
wdenk4d75a502003-03-25 16:50:56 +0000276
wdenk3c74e322004-02-22 23:46:08 +0000277 /* give it some time */
278 {
wdenk3c74e322004-02-22 23:46:08 +0000279 udelay (1000);
280 }
wdenk4d75a502003-03-25 16:50:56 +0000281
wdenk3c74e322004-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 */
wdenk4d75a502003-03-25 16:50:56 +0000289
wdenk3c74e322004-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 */
wdenk8bde7f72003-06-27 21:31:46 +0000297
wdenk3c74e322004-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 */
wdenk4d75a502003-03-25 16:50:56 +0000305
wdenk3c74e322004-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 */
wdenk4d75a502003-03-25 16:50:56 +0000313
wdenk3c74e322004-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;
wdenk4d75a502003-03-25 16:50:56 +0000316
wdenk3c74e322004-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;
wdenk4d75a502003-03-25 16:50:56 +0000319
wdenk3c74e322004-02-22 23:46:08 +0000320 /* Host mode - specify the bridge as a host-PCI bridge */
wdenk4d75a502003-03-25 16:50:56 +0000321
wdenk3c74e322004-02-22 23:46:08 +0000322 pci_hose_write_config_byte (hose, host_devno, PCI_CLASS_CODE,
323 PCI_CLASS_BRIDGE_CTLR);
wdenk4d75a502003-03-25 16:50:56 +0000324
wdenk3c74e322004-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);
wdenk4d75a502003-03-25 16:50:56 +0000330
wdenk7a8e9bed2003-05-31 18:35:21 +0000331 /* do some bridge init, should be done on all 8260 based bridges */
wdenk3c74e322004-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);
wdenk7a8e9bed2003-05-31 18:35:21 +0000336
wdenk3c74e322004-02-22 23:46:08 +0000337 hose->first_busno = 0;
338 hose->last_busno = 0xff;
wdenk4d75a502003-03-25 16:50:56 +0000339
wdenk3c74e322004-02-22 23:46:08 +0000340 /* System memory space */
wdenk3c74e322004-02-22 23:46:08 +0000341 pci_set_region (hose->regions + 0,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200342 CONFIG_SYS_SDRAM_BASE,
343 CONFIG_SYS_SDRAM_BASE,
Kumar Galaff4e66e2009-02-06 09:49:31 -0600344 0x4000000, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
wdenk4d75a502003-03-25 16:50:56 +0000345
wdenk3c74e322004-02-22 23:46:08 +0000346 /* PCI memory space */
wdenk3c74e322004-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);
wdenk4d75a502003-03-25 16:50:56 +0000351
wdenk3c74e322004-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);
wdenk4d75a502003-03-25 16:50:56 +0000356
wdenk3c74e322004-02-22 23:46:08 +0000357 hose->region_count = 3;
wdenk4d75a502003-03-25 16:50:56 +0000358
wdenk3c74e322004-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 ();
wdenk4d75a502003-03-25 16:50:56 +0000363
wdenk3c74e322004-02-22 23:46:08 +0000364 hose->last_busno = pci_hose_scan (hose);
365
366
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);
wdenk4d75a502003-03-25 16:50:56 +0000372}
373
Matvejchikov Ilya0e6989b2008-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 Denk52b047a2008-08-12 12:10:11 +0200378 "clock-frequency", gd->pci_clk, 1);
Matvejchikov Ilya0e6989b2008-07-06 13:57:00 +0400379}
380#endif
381
wdenk3c74e322004-02-22 23:46:08 +0000382#endif /* CONFIG_PCI */