blob: 2c013bbe5d122a6388bbda297357e3d3db00ef7e [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
Wolfgang Denk392c2522006-05-30 23:32:44 +020025#if defined CONFIG_MPC8266ADS || defined CONFIG_MPC8272 || defined CONFIG_PM826
Wolfgang Denkd87080b2006-03-31 18:32:53 +020026DECLARE_GLOBAL_DATA_PTR;
27#endif
28
wdenk4d75a502003-03-25 16:50:56 +000029/*
wdenk3c74e322004-02-22 23:46:08 +000030 * Local->PCI map (from CPU) controlled by
wdenk4d75a502003-03-25 16:50:56 +000031 * MPC826x master window
32 *
wdenk3c74e322004-02-22 23:46:08 +000033 * 0x80000000 - 0xBFFFFFFF CPU2PCI space PCIBR0
34 * 0xF4000000 - 0xF7FFFFFF CPU2PCI space PCIBR1
wdenk8bde7f72003-06-27 21:31:46 +000035 *
wdenk3c74e322004-02-22 23:46:08 +000036 * 0x80000000 - 0x9FFFFFFF 0x80000000 - 0x9FFFFFFF (Outbound ATU #1)
37 * PCI Mem with prefetch
wdenk5d232d02003-05-22 22:52:13 +000038 *
wdenk3c74e322004-02-22 23:46:08 +000039 * 0xA0000000 - 0xBFFFFFFF 0xA0000000 - 0xBFFFFFFF (Outbound ATU #2)
40 * PCI Mem w/o prefetch
wdenk5d232d02003-05-22 22:52:13 +000041 *
wdenk3c74e322004-02-22 23:46:08 +000042 * 0xF4000000 - 0xF7FFFFFF 0x00000000 - 0x03FFFFFF (Outbound ATU #3)
43 * 32-bit PCI IO
wdenk8bde7f72003-06-27 21:31:46 +000044 *
wdenk4d75a502003-03-25 16:50:56 +000045 * PCI->Local map (from PCI)
wdenk3c74e322004-02-22 23:46:08 +000046 * MPC826x slave window controlled by
wdenk4d75a502003-03-25 16:50:56 +000047 *
wdenk3c74e322004-02-22 23:46:08 +000048 * 0x00000000 - 0x1FFFFFFF 0x00000000 - 0x1FFFFFFF (Inbound ATU #1)
49 * MPC826x local memory
wdenk4d75a502003-03-25 16:50:56 +000050 */
51
wdenk8bde7f72003-06-27 21:31:46 +000052/*
53 * Slave window that allows PCI masters to access MPC826x local memory.
wdenk4d75a502003-03-25 16:50:56 +000054 * This window is set up using the first set of Inbound ATU registers
55 */
56
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020057#ifndef CONFIG_SYS_PCI_SLV_MEM_LOCAL
58#define PCI_SLV_MEM_LOCAL CONFIG_SYS_SDRAM_BASE /* Local base */
wdenk8bde7f72003-06-27 21:31:46 +000059#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020060#define PCI_SLV_MEM_LOCAL CONFIG_SYS_PCI_SLV_MEM_LOCAL
wdenk5d232d02003-05-22 22:52:13 +000061#endif
62
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020063#ifndef CONFIG_SYS_PCI_SLV_MEM_BUS
wdenk3c74e322004-02-22 23:46:08 +000064#define PCI_SLV_MEM_BUS 0x00000000 /* PCI base */
wdenk5d232d02003-05-22 22:52:13 +000065#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020066#define PCI_SLV_MEM_BUS CONFIG_SYS_PCI_SLV_MEM_BUS
wdenk5d232d02003-05-22 22:52:13 +000067#endif
68
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020069#ifndef CONFIG_SYS_PICMR0_MASK_ATTRIB
wdenk4d75a502003-03-25 16:50:56 +000070#define PICMR0_MASK_ATTRIB (PICMR_MASK_512MB | PICMR_ENABLE | \
wdenk8bde7f72003-06-27 21:31:46 +000071 PICMR_PREFETCH_EN)
wdenk5d232d02003-05-22 22:52:13 +000072#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020073#define PICMR0_MASK_ATTRIB CONFIG_SYS_PICMR0_MASK_ATTRIB
wdenk5d232d02003-05-22 22:52:13 +000074#endif
wdenk4d75a502003-03-25 16:50:56 +000075
wdenk8bde7f72003-06-27 21:31:46 +000076/*
wdenk5d232d02003-05-22 22:52:13 +000077 * These are the windows that allow the CPU to access PCI address space.
wdenk8bde7f72003-06-27 21:31:46 +000078 * All three PCI master windows, which allow the CPU to access PCI
79 * prefetch, non prefetch, and IO space (see below), must all fit within
wdenk5d232d02003-05-22 22:52:13 +000080 * these windows.
wdenk4d75a502003-03-25 16:50:56 +000081 */
82
wdenk5d232d02003-05-22 22:52:13 +000083/* PCIBR0 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020084#ifndef CONFIG_SYS_PCI_MSTR0_LOCAL
wdenk3c74e322004-02-22 23:46:08 +000085#define PCI_MSTR0_LOCAL 0x80000000 /* Local base */
wdenk8bde7f72003-06-27 21:31:46 +000086#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020087#define PCI_MSTR0_LOCAL CONFIG_SYS_PCI_MSTR0_LOCAL
wdenk5d232d02003-05-22 22:52:13 +000088#endif
89
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020090#ifndef CONFIG_SYS_PCIMSK0_MASK
wdenk3c74e322004-02-22 23:46:08 +000091#define PCIMSK0_MASK PCIMSK_1GB /* Size of window */
wdenk5d232d02003-05-22 22:52:13 +000092#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020093#define PCIMSK0_MASK CONFIG_SYS_PCIMSK0_MASK
wdenk5d232d02003-05-22 22:52:13 +000094#endif
95
96/* PCIBR1 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020097#ifndef CONFIG_SYS_PCI_MSTR1_LOCAL
wdenk3c74e322004-02-22 23:46:08 +000098#define PCI_MSTR1_LOCAL 0xF4000000 /* Local base */
wdenk8bde7f72003-06-27 21:31:46 +000099#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200100#define PCI_MSTR1_LOCAL CONFIG_SYS_PCI_MSTR1_LOCAL
wdenk5d232d02003-05-22 22:52:13 +0000101#endif
102
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200103#ifndef CONFIG_SYS_PCIMSK1_MASK
wdenk3c74e322004-02-22 23:46:08 +0000104#define PCIMSK1_MASK PCIMSK_64MB /* Size of window */
wdenk5d232d02003-05-22 22:52:13 +0000105#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200106#define PCIMSK1_MASK CONFIG_SYS_PCIMSK1_MASK
wdenk5d232d02003-05-22 22:52:13 +0000107#endif
wdenk4d75a502003-03-25 16:50:56 +0000108
wdenk8bde7f72003-06-27 21:31:46 +0000109/*
wdenk4d75a502003-03-25 16:50:56 +0000110 * Master window that allows the CPU to access PCI Memory (prefetch).
111 * This window will be setup with the first set of Outbound ATU registers
112 * in the bridge.
113 */
114
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200115#ifndef CONFIG_SYS_PCI_MSTR_MEM_LOCAL
wdenk3c74e322004-02-22 23:46:08 +0000116#define PCI_MSTR_MEM_LOCAL 0x80000000 /* Local base */
wdenk5d232d02003-05-22 22:52:13 +0000117#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200118#define PCI_MSTR_MEM_LOCAL CONFIG_SYS_PCI_MSTR_MEM_LOCAL
wdenk5d232d02003-05-22 22:52:13 +0000119#endif
120
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200121#ifndef CONFIG_SYS_PCI_MSTR_MEM_BUS
wdenk3c74e322004-02-22 23:46:08 +0000122#define PCI_MSTR_MEM_BUS 0x80000000 /* PCI base */
wdenk5d232d02003-05-22 22:52:13 +0000123#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200124#define PCI_MSTR_MEM_BUS CONFIG_SYS_PCI_MSTR_MEM_BUS
wdenk5d232d02003-05-22 22:52:13 +0000125#endif
126
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200127#ifndef CONFIG_SYS_CPU_PCI_MEM_START
wdenk5d232d02003-05-22 22:52:13 +0000128#define CPU_PCI_MEM_START PCI_MSTR_MEM_LOCAL
129#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200130#define CPU_PCI_MEM_START CONFIG_SYS_CPU_PCI_MEM_START
wdenk5d232d02003-05-22 22:52:13 +0000131#endif
132
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200133#ifndef CONFIG_SYS_PCI_MSTR_MEM_SIZE
wdenk3c74e322004-02-22 23:46:08 +0000134#define PCI_MSTR_MEM_SIZE 0x10000000 /* 256MB */
wdenk5d232d02003-05-22 22:52:13 +0000135#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200136#define PCI_MSTR_MEM_SIZE CONFIG_SYS_PCI_MSTR_MEM_SIZE
wdenk5d232d02003-05-22 22:52:13 +0000137#endif
138
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200139#ifndef CONFIG_SYS_POCMR0_MASK_ATTRIB
wdenk4d75a502003-03-25 16:50:56 +0000140#define POCMR0_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PREFETCH_EN)
wdenk5d232d02003-05-22 22:52:13 +0000141#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200142#define POCMR0_MASK_ATTRIB CONFIG_SYS_POCMR0_MASK_ATTRIB
wdenk5d232d02003-05-22 22:52:13 +0000143#endif
wdenk4d75a502003-03-25 16:50:56 +0000144
wdenk8bde7f72003-06-27 21:31:46 +0000145/*
wdenk4d75a502003-03-25 16:50:56 +0000146 * Master window that allows the CPU to access PCI Memory (non-prefetch).
147 * This window will be setup with the second set of Outbound ATU registers
148 * in the bridge.
149 */
150
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200151#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL
wdenk3c74e322004-02-22 23:46:08 +0000152#define PCI_MSTR_MEMIO_LOCAL 0x90000000 /* Local base */
wdenk8bde7f72003-06-27 21:31:46 +0000153#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200154#define PCI_MSTR_MEMIO_LOCAL CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL
wdenk5d232d02003-05-22 22:52:13 +0000155#endif
156
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200157#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_BUS
wdenk3c74e322004-02-22 23:46:08 +0000158#define PCI_MSTR_MEMIO_BUS 0x90000000 /* PCI base */
wdenk8bde7f72003-06-27 21:31:46 +0000159#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200160#define PCI_MSTR_MEMIO_BUS CONFIG_SYS_PCI_MSTR_MEMIO_BUS
wdenk5d232d02003-05-22 22:52:13 +0000161#endif
162
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200163#ifndef CONFIG_SYS_CPU_PCI_MEMIO_START
wdenk8bde7f72003-06-27 21:31:46 +0000164#define CPU_PCI_MEMIO_START PCI_MSTR_MEMIO_LOCAL
165#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200166#define CPU_PCI_MEMIO_START CONFIG_SYS_CPU_PCI_MEMIO_START
wdenk5d232d02003-05-22 22:52:13 +0000167#endif
168
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200169#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_SIZE
wdenk3c74e322004-02-22 23:46:08 +0000170#define PCI_MSTR_MEMIO_SIZE 0x10000000 /* 256 MB */
wdenk8bde7f72003-06-27 21:31:46 +0000171#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200172#define PCI_MSTR_MEMIO_SIZE CONFIG_SYS_PCI_MSTR_MEMIO_SIZE
wdenk5d232d02003-05-22 22:52:13 +0000173#endif
174
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200175#ifndef CONFIG_SYS_POCMR1_MASK_ATTRIB
wdenk3c74e322004-02-22 23:46:08 +0000176#define POCMR1_MASK_ATTRIB (POCMR_MASK_512MB | POCMR_ENABLE)
wdenk5d232d02003-05-22 22:52:13 +0000177#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200178#define POCMR1_MASK_ATTRIB CONFIG_SYS_POCMR1_MASK_ATTRIB
wdenk5d232d02003-05-22 22:52:13 +0000179#endif
wdenk4d75a502003-03-25 16:50:56 +0000180
wdenk8bde7f72003-06-27 21:31:46 +0000181/*
wdenk4d75a502003-03-25 16:50:56 +0000182 * Master window that allows the CPU to access PCI IO space.
183 * This window will be setup with the third set of Outbound ATU registers
184 * in the bridge.
185 */
186
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200187#ifndef CONFIG_SYS_PCI_MSTR_IO_LOCAL
wdenk3c74e322004-02-22 23:46:08 +0000188#define PCI_MSTR_IO_LOCAL 0xA0000000 /* Local base */
wdenk8bde7f72003-06-27 21:31:46 +0000189#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200190#define PCI_MSTR_IO_LOCAL CONFIG_SYS_PCI_MSTR_IO_LOCAL
wdenk66fd3d12003-05-18 11:30:09 +0000191#endif
wdenk5d232d02003-05-22 22:52:13 +0000192
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200193#ifndef CONFIG_SYS_PCI_MSTR_IO_BUS
wdenk3c74e322004-02-22 23:46:08 +0000194#define PCI_MSTR_IO_BUS 0xA0000000 /* PCI base */
wdenk8bde7f72003-06-27 21:31:46 +0000195#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200196#define PCI_MSTR_IO_BUS CONFIG_SYS_PCI_MSTR_IO_BUS
wdenk5d232d02003-05-22 22:52:13 +0000197#endif
198
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200199#ifndef CONFIG_SYS_CPU_PCI_IO_START
wdenk8bde7f72003-06-27 21:31:46 +0000200#define CPU_PCI_IO_START PCI_MSTR_IO_LOCAL
201#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200202#define CPU_PCI_IO_START CONFIG_SYS_CPU_PCI_IO_START
wdenk5d232d02003-05-22 22:52:13 +0000203#endif
204
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200205#ifndef CONFIG_SYS_PCI_MSTR_IO_SIZE
wdenk3c74e322004-02-22 23:46:08 +0000206#define PCI_MSTR_IO_SIZE 0x10000000 /* 256MB */
wdenk8bde7f72003-06-27 21:31:46 +0000207#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200208#define PCI_MSTR_IO_SIZE CONFIG_SYS_PCI_MSTR_IO_SIZE
wdenk5d232d02003-05-22 22:52:13 +0000209#endif
210
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200211#ifndef CONFIG_SYS_POCMR2_MASK_ATTRIB
wdenk3c74e322004-02-22 23:46:08 +0000212#define POCMR2_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PCI_IO)
wdenk5d232d02003-05-22 22:52:13 +0000213#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200214#define POCMR2_MASK_ATTRIB CONFIG_SYS_POCMR2_MASK_ATTRIB
wdenk5d232d02003-05-22 22:52:13 +0000215#endif
wdenk4d75a502003-03-25 16:50:56 +0000216
217/* PCI bus configuration registers.
218 */
219
220#define PCI_CLASS_BRIDGE_CTLR 0x06
221
222
wdenk3c74e322004-02-22 23:46:08 +0000223static inline void pci_outl (u32 addr, u32 data)
wdenk4d75a502003-03-25 16:50:56 +0000224{
wdenk3c74e322004-02-22 23:46:08 +0000225 *(volatile u32 *) addr = cpu_to_le32 (data);
wdenk4d75a502003-03-25 16:50:56 +0000226}
227
wdenk3c74e322004-02-22 23:46:08 +0000228void pci_mpc8250_init (struct pci_controller *hose)
wdenk4d75a502003-03-25 16:50:56 +0000229{
wdenk3c74e322004-02-22 23:46:08 +0000230 u16 tempShort;
wdenk4d75a502003-03-25 16:50:56 +0000231
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200232 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
wdenk3c74e322004-02-22 23:46:08 +0000233 pci_dev_t host_devno = PCI_BDF (0, 0, 0);
wdenk4d75a502003-03-25 16:50:56 +0000234
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200235 pci_setup_indirect (hose, CONFIG_SYS_IMMR + PCI_CFG_ADDR_REG,
236 CONFIG_SYS_IMMR + PCI_CFG_DATA_REG);
wdenk3c74e322004-02-22 23:46:08 +0000237
238 /*
239 * Setting required to enable local bus for PCI (SIUMCR [LBPC]).
240 */
wdenk5d232d02003-05-22 22:52:13 +0000241#ifdef CONFIG_MPC8266ADS
wdenk3c74e322004-02-22 23:46:08 +0000242 immap->im_siu_conf.sc_siumcr =
243 (immap->im_siu_conf.sc_siumcr & ~SIUMCR_LBPC11)
244 | SIUMCR_LBPC01;
Scott Wood8701ece2009-04-03 15:26:45 -0500245#elif defined(CONFIG_ADSTYPE) && CONFIG_ADSTYPE == CONFIG_SYS_PQ2FADS
246/* nothing to do for this board here */
Wolfgang Denk1972dc02005-09-25 16:27:55 +0200247#elif defined CONFIG_MPC8272
Wolfgang Denk716c1dc2005-09-25 18:49:35 +0200248 immap->im_siu_conf.sc_siumcr = (immap->im_siu_conf.sc_siumcr &
249 ~SIUMCR_BBD &
250 ~SIUMCR_ESE &
251 ~SIUMCR_PBSE &
252 ~SIUMCR_CDIS &
253 ~SIUMCR_DPPC11 &
254 ~SIUMCR_L2CPC11 &
255 ~SIUMCR_LBPC11 &
256 ~SIUMCR_APPC11 &
257 ~SIUMCR_CS10PC11 &
258 ~SIUMCR_BCTLC11 &
259 ~SIUMCR_MMR11)
260 | SIUMCR_DPPC11
261 | SIUMCR_L2CPC01
262 | SIUMCR_LBPC00
263 | SIUMCR_APPC10
264 | SIUMCR_CS10PC00
265 | SIUMCR_BCTLC00
266 | SIUMCR_MMR11;
Heiko Schocherfa230442006-12-21 17:17:02 +0100267#elif defined(CONFIG_TQM8272)
Heiko Schocher07e82cb2007-03-21 08:45:17 +0100268/* nothing to do for this Board here */
wdenk5d232d02003-05-22 22:52:13 +0000269#else
wdenk3c74e322004-02-22 23:46:08 +0000270 /*
271 * Setting required to enable IRQ1-IRQ7 (SIUMCR [DPPC]),
272 * and local bus for PCI (SIUMCR [LBPC]).
273 */
274 immap->im_siu_conf.sc_siumcr = (immap->im_siu_conf.sc_siumcr &
275 ~SIUMCR_LBPC11 &
wdenk8bde7f72003-06-27 21:31:46 +0000276 ~SIUMCR_CS10PC11 &
wdenk3c74e322004-02-22 23:46:08 +0000277 ~SIUMCR_LBPC11) |
278 SIUMCR_LBPC01 |
279 SIUMCR_CS10PC01 |
280 SIUMCR_APPC10;
wdenk5d232d02003-05-22 22:52:13 +0000281#endif
wdenk4d75a502003-03-25 16:50:56 +0000282
wdenk3c74e322004-02-22 23:46:08 +0000283 /* Make PCI lowest priority */
284 /* Each 4 bits is a device bus request and the MS 4bits
285 is highest priority */
286 /* Bus 4bit value
287 --- ----------
288 CPM high 0b0000
289 CPM middle 0b0001
290 CPM low 0b0010
291 PCI reguest 0b0011
292 Reserved 0b0100
293 Reserved 0b0101
294 Internal Core 0b0110
295 External Master 1 0b0111
296 External Master 2 0b1000
297 External Master 3 0b1001
298 The rest are reserved */
299 immap->im_siu_conf.sc_ppc_alrh = 0x61207893;
wdenk4d75a502003-03-25 16:50:56 +0000300
wdenk3c74e322004-02-22 23:46:08 +0000301 /* Park bus on core while modifying PCI Bus accesses */
302 immap->im_siu_conf.sc_ppc_acr = 0x6;
wdenk4d75a502003-03-25 16:50:56 +0000303
wdenk3c74e322004-02-22 23:46:08 +0000304 /*
305 * Set up master windows that allow the CPU to access PCI space. These
306 * windows are set up using the two SIU PCIBR registers.
307 */
308 immap->im_memctl.memc_pcimsk0 = PCIMSK0_MASK;
309 immap->im_memctl.memc_pcibr0 = PCI_MSTR0_LOCAL | PCIBR_ENABLE;
wdenk5d232d02003-05-22 22:52:13 +0000310
Wolfgang Denk1972dc02005-09-25 16:27:55 +0200311#if defined CONFIG_MPC8266ADS || defined CONFIG_MPC8272
wdenkd4326ac2004-04-18 21:17:30 +0000312 immap->im_memctl.memc_pcimsk1 = PCIMSK1_MASK;
313 immap->im_memctl.memc_pcibr1 = PCI_MSTR1_LOCAL | PCIBR_ENABLE;
wdenk8bde7f72003-06-27 21:31:46 +0000314#endif
wdenk4d75a502003-03-25 16:50:56 +0000315
wdenk3c74e322004-02-22 23:46:08 +0000316 /* Release PCI RST (by default the PCI RST signal is held low) */
317 immap->im_pci.pci_gcr = cpu_to_le32 (PCIGCR_PCI_BUS_EN);
wdenk4d75a502003-03-25 16:50:56 +0000318
wdenk3c74e322004-02-22 23:46:08 +0000319 /* give it some time */
320 {
Wolfgang Denk1972dc02005-09-25 16:27:55 +0200321#if defined CONFIG_MPC8266ADS || defined CONFIG_MPC8272
wdenk8bde7f72003-06-27 21:31:46 +0000322 /* Give the PCI cards more time to initialize before query
wdenk3c74e322004-02-22 23:46:08 +0000323 This might be good for other boards also
324 */
325 int i;
326
327 for (i = 0; i < 1000; ++i)
wdenk5d232d02003-05-22 22:52:13 +0000328#endif
wdenk3c74e322004-02-22 23:46:08 +0000329 udelay (1000);
330 }
wdenk4d75a502003-03-25 16:50:56 +0000331
wdenk3c74e322004-02-22 23:46:08 +0000332 /*
333 * Set up master window that allows the CPU to access PCI Memory (prefetch)
334 * space. This window is set up using the first set of Outbound ATU registers.
335 */
336 immap->im_pci.pci_potar0 = cpu_to_le32 (PCI_MSTR_MEM_BUS >> 12); /* PCI base */
337 immap->im_pci.pci_pobar0 = cpu_to_le32 (PCI_MSTR_MEM_LOCAL >> 12); /* Local base */
338 immap->im_pci.pci_pocmr0 = cpu_to_le32 (POCMR0_MASK_ATTRIB); /* Size & attribute */
wdenk4d75a502003-03-25 16:50:56 +0000339
wdenk3c74e322004-02-22 23:46:08 +0000340 /*
341 * Set up master window that allows the CPU to access PCI Memory (non-prefetch)
342 * space. This window is set up using the second set of Outbound ATU registers.
343 */
344 immap->im_pci.pci_potar1 = cpu_to_le32 (PCI_MSTR_MEMIO_BUS >> 12); /* PCI base */
345 immap->im_pci.pci_pobar1 = cpu_to_le32 (PCI_MSTR_MEMIO_LOCAL >> 12); /* Local base */
346 immap->im_pci.pci_pocmr1 = cpu_to_le32 (POCMR1_MASK_ATTRIB); /* Size & attribute */
wdenk8bde7f72003-06-27 21:31:46 +0000347
wdenk3c74e322004-02-22 23:46:08 +0000348 /*
349 * Set up master window that allows the CPU to access PCI IO space. This window
350 * is set up using the third set of Outbound ATU registers.
351 */
352 immap->im_pci.pci_potar2 = cpu_to_le32 (PCI_MSTR_IO_BUS >> 12); /* PCI base */
353 immap->im_pci.pci_pobar2 = cpu_to_le32 (PCI_MSTR_IO_LOCAL >> 12); /* Local base */
354 immap->im_pci.pci_pocmr2 = cpu_to_le32 (POCMR2_MASK_ATTRIB); /* Size & attribute */
wdenk4d75a502003-03-25 16:50:56 +0000355
wdenk3c74e322004-02-22 23:46:08 +0000356 /*
357 * Set up slave window that allows PCI masters to access MPC826x local memory.
358 * This window is set up using the first set of Inbound ATU registers
359 */
360 immap->im_pci.pci_pitar0 = cpu_to_le32 (PCI_SLV_MEM_LOCAL >> 12); /* PCI base */
361 immap->im_pci.pci_pibar0 = cpu_to_le32 (PCI_SLV_MEM_BUS >> 12); /* Local base */
362 immap->im_pci.pci_picmr0 = cpu_to_le32 (PICMR0_MASK_ATTRIB); /* Size & attribute */
wdenk4d75a502003-03-25 16:50:56 +0000363
wdenk3c74e322004-02-22 23:46:08 +0000364 /* See above for description - puts PCI request as highest priority */
Wolfgang Denk1972dc02005-09-25 16:27:55 +0200365#ifdef CONFIG_MPC8272
366 immap->im_siu_conf.sc_ppc_alrh = 0x01236745;
367#else
wdenk3c74e322004-02-22 23:46:08 +0000368 immap->im_siu_conf.sc_ppc_alrh = 0x03124567;
Wolfgang Denk1972dc02005-09-25 16:27:55 +0200369#endif
wdenk4d75a502003-03-25 16:50:56 +0000370
wdenk3c74e322004-02-22 23:46:08 +0000371 /* Park the bus on the PCI */
372 immap->im_siu_conf.sc_ppc_acr = PPC_ACR_BUS_PARK_PCI;
wdenk4d75a502003-03-25 16:50:56 +0000373
wdenk3c74e322004-02-22 23:46:08 +0000374 /* Host mode - specify the bridge as a host-PCI bridge */
wdenk4d75a502003-03-25 16:50:56 +0000375
wdenk3c74e322004-02-22 23:46:08 +0000376 pci_hose_write_config_byte (hose, host_devno, PCI_CLASS_CODE,
377 PCI_CLASS_BRIDGE_CTLR);
wdenk4d75a502003-03-25 16:50:56 +0000378
wdenk3c74e322004-02-22 23:46:08 +0000379 /* Enable the host bridge to be a master on the PCI bus, and to act as a PCI memory target */
380 pci_hose_read_config_word (hose, host_devno, PCI_COMMAND, &tempShort);
381 pci_hose_write_config_word (hose, host_devno, PCI_COMMAND,
382 tempShort | PCI_COMMAND_MASTER |
383 PCI_COMMAND_MEMORY);
wdenk4d75a502003-03-25 16:50:56 +0000384
wdenk7a8e9bed2003-05-31 18:35:21 +0000385 /* do some bridge init, should be done on all 8260 based bridges */
wdenk3c74e322004-02-22 23:46:08 +0000386 pci_hose_write_config_byte (hose, host_devno, PCI_CACHE_LINE_SIZE,
387 0x08);
388 pci_hose_write_config_byte (hose, host_devno, PCI_LATENCY_TIMER,
389 0xF8);
wdenk7a8e9bed2003-05-31 18:35:21 +0000390
wdenk3c74e322004-02-22 23:46:08 +0000391 hose->first_busno = 0;
392 hose->last_busno = 0xff;
wdenk4d75a502003-03-25 16:50:56 +0000393
wdenk3c74e322004-02-22 23:46:08 +0000394 /* System memory space */
Wolfgang Denk392c2522006-05-30 23:32:44 +0200395#if defined CONFIG_MPC8266ADS || defined CONFIG_MPC8272 || defined CONFIG_PM826
wdenk3c74e322004-02-22 23:46:08 +0000396 pci_set_region (hose->regions + 0,
397 PCI_SLV_MEM_BUS,
398 PCI_SLV_MEM_LOCAL,
Kumar Galaff4e66e2009-02-06 09:49:31 -0600399 gd->ram_size, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
wdenk5d232d02003-05-22 22:52:13 +0000400#else
wdenk3c74e322004-02-22 23:46:08 +0000401 pci_set_region (hose->regions + 0,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200402 CONFIG_SYS_SDRAM_BASE,
403 CONFIG_SYS_SDRAM_BASE,
Kumar Galaff4e66e2009-02-06 09:49:31 -0600404 0x4000000, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
wdenk5d232d02003-05-22 22:52:13 +0000405#endif
wdenk4d75a502003-03-25 16:50:56 +0000406
wdenk3c74e322004-02-22 23:46:08 +0000407 /* PCI memory space */
Wolfgang Denk716c1dc2005-09-25 18:49:35 +0200408#if defined CONFIG_MPC8266ADS || defined CONFIG_MPC8272
wdenk3c74e322004-02-22 23:46:08 +0000409 pci_set_region (hose->regions + 1,
410 PCI_MSTR_MEMIO_BUS,
411 PCI_MSTR_MEMIO_LOCAL,
412 PCI_MSTR_MEMIO_SIZE, PCI_REGION_MEM);
wdenk5d232d02003-05-22 22:52:13 +0000413#else
wdenk3c74e322004-02-22 23:46:08 +0000414 pci_set_region (hose->regions + 1,
415 PCI_MSTR_MEM_BUS,
416 PCI_MSTR_MEM_LOCAL,
417 PCI_MSTR_MEM_SIZE, PCI_REGION_MEM);
wdenk5d232d02003-05-22 22:52:13 +0000418#endif
wdenk4d75a502003-03-25 16:50:56 +0000419
wdenk3c74e322004-02-22 23:46:08 +0000420 /* PCI I/O space */
421 pci_set_region (hose->regions + 2,
422 PCI_MSTR_IO_BUS,
423 PCI_MSTR_IO_LOCAL, PCI_MSTR_IO_SIZE, PCI_REGION_IO);
wdenk4d75a502003-03-25 16:50:56 +0000424
wdenk3c74e322004-02-22 23:46:08 +0000425 hose->region_count = 3;
wdenk4d75a502003-03-25 16:50:56 +0000426
wdenk3c74e322004-02-22 23:46:08 +0000427 pci_register_hose (hose);
428 /* Mask off master abort machine checks */
429 immap->im_pci.pci_emr &= cpu_to_le32 (~PCI_ERROR_PCI_NO_RSP);
430 eieio ();
wdenk4d75a502003-03-25 16:50:56 +0000431
wdenk3c74e322004-02-22 23:46:08 +0000432 hose->last_busno = pci_hose_scan (hose);
433
434
435 /* clear the error in the error status register */
436 immap->im_pci.pci_esr = cpu_to_le32 (PCI_ERROR_PCI_NO_RSP);
437
438 /* unmask master abort machine checks */
439 immap->im_pci.pci_emr |= cpu_to_le32 (PCI_ERROR_PCI_NO_RSP);
wdenk4d75a502003-03-25 16:50:56 +0000440}
441
Matvejchikov Ilya0e6989b2008-07-06 13:57:00 +0400442#if defined(CONFIG_OF_LIBFDT)
443void ft_pci_setup(void *blob, bd_t *bd)
444{
445 do_fixup_by_prop_u32(blob, "device_type", "pci", 4,
Wolfgang Denk52b047a2008-08-12 12:10:11 +0200446 "clock-frequency", gd->pci_clk, 1);
Matvejchikov Ilya0e6989b2008-07-06 13:57:00 +0400447}
448#endif
449
wdenk3c74e322004-02-22 23:46:08 +0000450#endif /* CONFIG_PCI */