2003-03-25 16:50:56 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2005-09-25 16:49:35 +00:00
|
|
|
* Copyright (c) 2005 MontaVista Software, Inc.
|
2005-09-25 14:27:55 +00:00
|
|
|
* Vitaly Bordug <vbordug@ru.mvista.com>
|
|
|
|
* Added support for PCI bridge on MPC8272ADS
|
|
|
|
*
|
2013-10-07 11:07:26 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2003-03-25 16:50:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
|
|
|
|
#include <pci.h>
|
2003-05-22 22:52:13 +00:00
|
|
|
#include <mpc8260.h>
|
2003-03-25 16:50:56 +00:00
|
|
|
#include <asm/m8260_pci.h>
|
2004-02-22 23:46:08 +00:00
|
|
|
#include <asm/io.h>
|
2008-07-06 09:57:00 +00:00
|
|
|
#ifdef CONFIG_OF_LIBFDT
|
|
|
|
#include <libfdt.h>
|
|
|
|
#include <fdt_support.h>
|
|
|
|
#endif
|
2006-03-31 16:32:53 +00:00
|
|
|
|
2006-05-30 21:32:44 +00:00
|
|
|
#if defined CONFIG_MPC8266ADS || defined CONFIG_MPC8272 || defined CONFIG_PM826
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
#endif
|
|
|
|
|
2003-03-25 16:50:56 +00:00
|
|
|
/*
|
2004-02-22 23:46:08 +00:00
|
|
|
* Local->PCI map (from CPU) controlled by
|
2003-03-25 16:50:56 +00:00
|
|
|
* MPC826x master window
|
|
|
|
*
|
2004-02-22 23:46:08 +00:00
|
|
|
* 0x80000000 - 0xBFFFFFFF CPU2PCI space PCIBR0
|
|
|
|
* 0xF4000000 - 0xF7FFFFFF CPU2PCI space PCIBR1
|
2003-06-27 21:31:46 +00:00
|
|
|
*
|
2004-02-22 23:46:08 +00:00
|
|
|
* 0x80000000 - 0x9FFFFFFF 0x80000000 - 0x9FFFFFFF (Outbound ATU #1)
|
|
|
|
* PCI Mem with prefetch
|
2003-05-22 22:52:13 +00:00
|
|
|
*
|
2004-02-22 23:46:08 +00:00
|
|
|
* 0xA0000000 - 0xBFFFFFFF 0xA0000000 - 0xBFFFFFFF (Outbound ATU #2)
|
|
|
|
* PCI Mem w/o prefetch
|
2003-05-22 22:52:13 +00:00
|
|
|
*
|
2004-02-22 23:46:08 +00:00
|
|
|
* 0xF4000000 - 0xF7FFFFFF 0x00000000 - 0x03FFFFFF (Outbound ATU #3)
|
|
|
|
* 32-bit PCI IO
|
2003-06-27 21:31:46 +00:00
|
|
|
*
|
2003-03-25 16:50:56 +00:00
|
|
|
* PCI->Local map (from PCI)
|
2004-02-22 23:46:08 +00:00
|
|
|
* MPC826x slave window controlled by
|
2003-03-25 16:50:56 +00:00
|
|
|
*
|
2004-02-22 23:46:08 +00:00
|
|
|
* 0x00000000 - 0x1FFFFFFF 0x00000000 - 0x1FFFFFFF (Inbound ATU #1)
|
|
|
|
* MPC826x local memory
|
2003-03-25 16:50:56 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
|
|
|
* Slave window that allows PCI masters to access MPC826x local memory.
|
2003-03-25 16:50:56 +00:00
|
|
|
* This window is set up using the first set of Inbound ATU registers
|
|
|
|
*/
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_SLV_MEM_LOCAL
|
|
|
|
#define PCI_SLV_MEM_LOCAL CONFIG_SYS_SDRAM_BASE /* Local base */
|
2003-06-27 21:31:46 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_SLV_MEM_LOCAL CONFIG_SYS_PCI_SLV_MEM_LOCAL
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_SLV_MEM_BUS
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_SLV_MEM_BUS 0x00000000 /* PCI base */
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_SLV_MEM_BUS CONFIG_SYS_PCI_SLV_MEM_BUS
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PICMR0_MASK_ATTRIB
|
2003-03-25 16:50:56 +00:00
|
|
|
#define PICMR0_MASK_ATTRIB (PICMR_MASK_512MB | PICMR_ENABLE | \
|
2003-06-27 21:31:46 +00:00
|
|
|
PICMR_PREFETCH_EN)
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PICMR0_MASK_ATTRIB CONFIG_SYS_PICMR0_MASK_ATTRIB
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
2003-05-22 22:52:13 +00:00
|
|
|
* These are the windows that allow the CPU to access PCI address space.
|
2003-06-27 21:31:46 +00:00
|
|
|
* All three PCI master windows, which allow the CPU to access PCI
|
|
|
|
* prefetch, non prefetch, and IO space (see below), must all fit within
|
2003-05-22 22:52:13 +00:00
|
|
|
* these windows.
|
2003-03-25 16:50:56 +00:00
|
|
|
*/
|
|
|
|
|
2003-05-22 22:52:13 +00:00
|
|
|
/* PCIBR0 */
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR0_LOCAL
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR0_LOCAL 0x80000000 /* Local base */
|
2003-06-27 21:31:46 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR0_LOCAL CONFIG_SYS_PCI_MSTR0_LOCAL
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCIMSK0_MASK
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCIMSK0_MASK PCIMSK_1GB /* Size of window */
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCIMSK0_MASK CONFIG_SYS_PCIMSK0_MASK
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* PCIBR1 */
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR1_LOCAL
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR1_LOCAL 0xF4000000 /* Local base */
|
2003-06-27 21:31:46 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR1_LOCAL CONFIG_SYS_PCI_MSTR1_LOCAL
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCIMSK1_MASK
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCIMSK1_MASK PCIMSK_64MB /* Size of window */
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCIMSK1_MASK CONFIG_SYS_PCIMSK1_MASK
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
2003-03-25 16:50:56 +00:00
|
|
|
* Master window that allows the CPU to access PCI Memory (prefetch).
|
|
|
|
* This window will be setup with the first set of Outbound ATU registers
|
|
|
|
* in the bridge.
|
|
|
|
*/
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR_MEM_LOCAL
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR_MEM_LOCAL 0x80000000 /* Local base */
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR_MEM_LOCAL CONFIG_SYS_PCI_MSTR_MEM_LOCAL
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR_MEM_BUS
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR_MEM_BUS 0x80000000 /* PCI base */
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR_MEM_BUS CONFIG_SYS_PCI_MSTR_MEM_BUS
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_CPU_PCI_MEM_START
|
2003-05-22 22:52:13 +00:00
|
|
|
#define CPU_PCI_MEM_START PCI_MSTR_MEM_LOCAL
|
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define CPU_PCI_MEM_START CONFIG_SYS_CPU_PCI_MEM_START
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR_MEM_SIZE
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR_MEM_SIZE 0x10000000 /* 256MB */
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR_MEM_SIZE CONFIG_SYS_PCI_MSTR_MEM_SIZE
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_POCMR0_MASK_ATTRIB
|
2003-03-25 16:50:56 +00:00
|
|
|
#define POCMR0_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PREFETCH_EN)
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define POCMR0_MASK_ATTRIB CONFIG_SYS_POCMR0_MASK_ATTRIB
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
2003-03-25 16:50:56 +00:00
|
|
|
* Master window that allows the CPU to access PCI Memory (non-prefetch).
|
|
|
|
* This window will be setup with the second set of Outbound ATU registers
|
|
|
|
* in the bridge.
|
|
|
|
*/
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR_MEMIO_LOCAL 0x90000000 /* Local base */
|
2003-06-27 21:31:46 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR_MEMIO_LOCAL CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_BUS
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR_MEMIO_BUS 0x90000000 /* PCI base */
|
2003-06-27 21:31:46 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR_MEMIO_BUS CONFIG_SYS_PCI_MSTR_MEMIO_BUS
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_CPU_PCI_MEMIO_START
|
2003-06-27 21:31:46 +00:00
|
|
|
#define CPU_PCI_MEMIO_START PCI_MSTR_MEMIO_LOCAL
|
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define CPU_PCI_MEMIO_START CONFIG_SYS_CPU_PCI_MEMIO_START
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_SIZE
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR_MEMIO_SIZE 0x10000000 /* 256 MB */
|
2003-06-27 21:31:46 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR_MEMIO_SIZE CONFIG_SYS_PCI_MSTR_MEMIO_SIZE
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_POCMR1_MASK_ATTRIB
|
2004-02-22 23:46:08 +00:00
|
|
|
#define POCMR1_MASK_ATTRIB (POCMR_MASK_512MB | POCMR_ENABLE)
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define POCMR1_MASK_ATTRIB CONFIG_SYS_POCMR1_MASK_ATTRIB
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
2003-03-25 16:50:56 +00:00
|
|
|
* Master window that allows the CPU to access PCI IO space.
|
|
|
|
* This window will be setup with the third set of Outbound ATU registers
|
|
|
|
* in the bridge.
|
|
|
|
*/
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR_IO_LOCAL
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR_IO_LOCAL 0xA0000000 /* Local base */
|
2003-06-27 21:31:46 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR_IO_LOCAL CONFIG_SYS_PCI_MSTR_IO_LOCAL
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR_IO_BUS
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR_IO_BUS 0xA0000000 /* PCI base */
|
2003-06-27 21:31:46 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR_IO_BUS CONFIG_SYS_PCI_MSTR_IO_BUS
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_CPU_PCI_IO_START
|
2003-06-27 21:31:46 +00:00
|
|
|
#define CPU_PCI_IO_START PCI_MSTR_IO_LOCAL
|
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define CPU_PCI_IO_START CONFIG_SYS_CPU_PCI_IO_START
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_PCI_MSTR_IO_SIZE
|
2004-02-22 23:46:08 +00:00
|
|
|
#define PCI_MSTR_IO_SIZE 0x10000000 /* 256MB */
|
2003-06-27 21:31:46 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define PCI_MSTR_IO_SIZE CONFIG_SYS_PCI_MSTR_IO_SIZE
|
2003-05-18 11:30:09 +00:00
|
|
|
#endif
|
2003-05-22 22:52:13 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifndef CONFIG_SYS_POCMR2_MASK_ATTRIB
|
2004-02-22 23:46:08 +00:00
|
|
|
#define POCMR2_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PCI_IO)
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2008-10-16 13:01:15 +00:00
|
|
|
#define POCMR2_MASK_ATTRIB CONFIG_SYS_POCMR2_MASK_ATTRIB
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
2003-03-25 16:50:56 +00:00
|
|
|
|
|
|
|
/* PCI bus configuration registers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PCI_CLASS_BRIDGE_CTLR 0x06
|
|
|
|
|
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
static inline void pci_outl (u32 addr, u32 data)
|
2003-03-25 16:50:56 +00:00
|
|
|
{
|
2004-02-22 23:46:08 +00:00
|
|
|
*(volatile u32 *) addr = cpu_to_le32 (data);
|
2003-03-25 16:50:56 +00:00
|
|
|
}
|
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
void pci_mpc8250_init (struct pci_controller *hose)
|
2003-03-25 16:50:56 +00:00
|
|
|
{
|
2004-02-22 23:46:08 +00:00
|
|
|
u16 tempShort;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
|
2004-02-22 23:46:08 +00:00
|
|
|
pci_dev_t host_devno = PCI_BDF (0, 0, 0);
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_setup_indirect (hose, CONFIG_SYS_IMMR + PCI_CFG_ADDR_REG,
|
|
|
|
CONFIG_SYS_IMMR + PCI_CFG_DATA_REG);
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
/*
|
|
|
|
* Setting required to enable local bus for PCI (SIUMCR [LBPC]).
|
|
|
|
*/
|
2003-05-22 22:52:13 +00:00
|
|
|
#ifdef CONFIG_MPC8266ADS
|
2004-02-22 23:46:08 +00:00
|
|
|
immap->im_siu_conf.sc_siumcr =
|
|
|
|
(immap->im_siu_conf.sc_siumcr & ~SIUMCR_LBPC11)
|
|
|
|
| SIUMCR_LBPC01;
|
2005-09-25 14:27:55 +00:00
|
|
|
#elif defined CONFIG_MPC8272
|
2005-09-25 16:49:35 +00:00
|
|
|
immap->im_siu_conf.sc_siumcr = (immap->im_siu_conf.sc_siumcr &
|
|
|
|
~SIUMCR_BBD &
|
|
|
|
~SIUMCR_ESE &
|
|
|
|
~SIUMCR_PBSE &
|
|
|
|
~SIUMCR_CDIS &
|
|
|
|
~SIUMCR_DPPC11 &
|
|
|
|
~SIUMCR_L2CPC11 &
|
|
|
|
~SIUMCR_LBPC11 &
|
|
|
|
~SIUMCR_APPC11 &
|
|
|
|
~SIUMCR_CS10PC11 &
|
|
|
|
~SIUMCR_BCTLC11 &
|
|
|
|
~SIUMCR_MMR11)
|
|
|
|
| SIUMCR_DPPC11
|
|
|
|
| SIUMCR_L2CPC01
|
|
|
|
| SIUMCR_LBPC00
|
|
|
|
| SIUMCR_APPC10
|
|
|
|
| SIUMCR_CS10PC00
|
|
|
|
| SIUMCR_BCTLC00
|
|
|
|
| SIUMCR_MMR11;
|
2006-12-21 16:17:02 +00:00
|
|
|
#elif defined(CONFIG_TQM8272)
|
2007-03-21 07:45:17 +00:00
|
|
|
/* nothing to do for this Board here */
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2004-02-22 23:46:08 +00:00
|
|
|
/*
|
|
|
|
* Setting required to enable IRQ1-IRQ7 (SIUMCR [DPPC]),
|
|
|
|
* and local bus for PCI (SIUMCR [LBPC]).
|
|
|
|
*/
|
|
|
|
immap->im_siu_conf.sc_siumcr = (immap->im_siu_conf.sc_siumcr &
|
|
|
|
~SIUMCR_LBPC11 &
|
2003-06-27 21:31:46 +00:00
|
|
|
~SIUMCR_CS10PC11 &
|
2004-02-22 23:46:08 +00:00
|
|
|
~SIUMCR_LBPC11) |
|
|
|
|
SIUMCR_LBPC01 |
|
|
|
|
SIUMCR_CS10PC01 |
|
|
|
|
SIUMCR_APPC10;
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
/* Make PCI lowest priority */
|
|
|
|
/* Each 4 bits is a device bus request and the MS 4bits
|
|
|
|
is highest priority */
|
|
|
|
/* Bus 4bit value
|
|
|
|
--- ----------
|
|
|
|
CPM high 0b0000
|
|
|
|
CPM middle 0b0001
|
|
|
|
CPM low 0b0010
|
|
|
|
PCI reguest 0b0011
|
|
|
|
Reserved 0b0100
|
|
|
|
Reserved 0b0101
|
|
|
|
Internal Core 0b0110
|
|
|
|
External Master 1 0b0111
|
|
|
|
External Master 2 0b1000
|
|
|
|
External Master 3 0b1001
|
|
|
|
The rest are reserved */
|
|
|
|
immap->im_siu_conf.sc_ppc_alrh = 0x61207893;
|
|
|
|
|
|
|
|
/* Park bus on core while modifying PCI Bus accesses */
|
|
|
|
immap->im_siu_conf.sc_ppc_acr = 0x6;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up master windows that allow the CPU to access PCI space. These
|
|
|
|
* windows are set up using the two SIU PCIBR registers.
|
|
|
|
*/
|
|
|
|
immap->im_memctl.memc_pcimsk0 = PCIMSK0_MASK;
|
|
|
|
immap->im_memctl.memc_pcibr0 = PCI_MSTR0_LOCAL | PCIBR_ENABLE;
|
2003-05-22 22:52:13 +00:00
|
|
|
|
2005-09-25 14:27:55 +00:00
|
|
|
#if defined CONFIG_MPC8266ADS || defined CONFIG_MPC8272
|
2004-04-18 21:17:30 +00:00
|
|
|
immap->im_memctl.memc_pcimsk1 = PCIMSK1_MASK;
|
|
|
|
immap->im_memctl.memc_pcibr1 = PCI_MSTR1_LOCAL | PCIBR_ENABLE;
|
2003-06-27 21:31:46 +00:00
|
|
|
#endif
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
/* Release PCI RST (by default the PCI RST signal is held low) */
|
|
|
|
immap->im_pci.pci_gcr = cpu_to_le32 (PCIGCR_PCI_BUS_EN);
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
/* give it some time */
|
|
|
|
{
|
2005-09-25 14:27:55 +00:00
|
|
|
#if defined CONFIG_MPC8266ADS || defined CONFIG_MPC8272
|
2003-06-27 21:31:46 +00:00
|
|
|
/* Give the PCI cards more time to initialize before query
|
2004-02-22 23:46:08 +00:00
|
|
|
This might be good for other boards also
|
|
|
|
*/
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 1000; ++i)
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
2004-02-22 23:46:08 +00:00
|
|
|
udelay (1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up master window that allows the CPU to access PCI Memory (prefetch)
|
|
|
|
* space. This window is set up using the first set of Outbound ATU registers.
|
|
|
|
*/
|
|
|
|
immap->im_pci.pci_potar0 = cpu_to_le32 (PCI_MSTR_MEM_BUS >> 12); /* PCI base */
|
|
|
|
immap->im_pci.pci_pobar0 = cpu_to_le32 (PCI_MSTR_MEM_LOCAL >> 12); /* Local base */
|
|
|
|
immap->im_pci.pci_pocmr0 = cpu_to_le32 (POCMR0_MASK_ATTRIB); /* Size & attribute */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up master window that allows the CPU to access PCI Memory (non-prefetch)
|
|
|
|
* space. This window is set up using the second set of Outbound ATU registers.
|
|
|
|
*/
|
|
|
|
immap->im_pci.pci_potar1 = cpu_to_le32 (PCI_MSTR_MEMIO_BUS >> 12); /* PCI base */
|
|
|
|
immap->im_pci.pci_pobar1 = cpu_to_le32 (PCI_MSTR_MEMIO_LOCAL >> 12); /* Local base */
|
|
|
|
immap->im_pci.pci_pocmr1 = cpu_to_le32 (POCMR1_MASK_ATTRIB); /* Size & attribute */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up master window that allows the CPU to access PCI IO space. This window
|
|
|
|
* is set up using the third set of Outbound ATU registers.
|
|
|
|
*/
|
|
|
|
immap->im_pci.pci_potar2 = cpu_to_le32 (PCI_MSTR_IO_BUS >> 12); /* PCI base */
|
|
|
|
immap->im_pci.pci_pobar2 = cpu_to_le32 (PCI_MSTR_IO_LOCAL >> 12); /* Local base */
|
|
|
|
immap->im_pci.pci_pocmr2 = cpu_to_le32 (POCMR2_MASK_ATTRIB); /* Size & attribute */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up slave window that allows PCI masters to access MPC826x local memory.
|
|
|
|
* This window is set up using the first set of Inbound ATU registers
|
|
|
|
*/
|
|
|
|
immap->im_pci.pci_pitar0 = cpu_to_le32 (PCI_SLV_MEM_LOCAL >> 12); /* PCI base */
|
|
|
|
immap->im_pci.pci_pibar0 = cpu_to_le32 (PCI_SLV_MEM_BUS >> 12); /* Local base */
|
|
|
|
immap->im_pci.pci_picmr0 = cpu_to_le32 (PICMR0_MASK_ATTRIB); /* Size & attribute */
|
|
|
|
|
|
|
|
/* See above for description - puts PCI request as highest priority */
|
2005-09-25 14:27:55 +00:00
|
|
|
#ifdef CONFIG_MPC8272
|
|
|
|
immap->im_siu_conf.sc_ppc_alrh = 0x01236745;
|
|
|
|
#else
|
2004-02-22 23:46:08 +00:00
|
|
|
immap->im_siu_conf.sc_ppc_alrh = 0x03124567;
|
2005-09-25 14:27:55 +00:00
|
|
|
#endif
|
2004-02-22 23:46:08 +00:00
|
|
|
|
|
|
|
/* Park the bus on the PCI */
|
|
|
|
immap->im_siu_conf.sc_ppc_acr = PPC_ACR_BUS_PARK_PCI;
|
|
|
|
|
|
|
|
/* Host mode - specify the bridge as a host-PCI bridge */
|
|
|
|
|
|
|
|
pci_hose_write_config_byte (hose, host_devno, PCI_CLASS_CODE,
|
|
|
|
PCI_CLASS_BRIDGE_CTLR);
|
|
|
|
|
|
|
|
/* Enable the host bridge to be a master on the PCI bus, and to act as a PCI memory target */
|
|
|
|
pci_hose_read_config_word (hose, host_devno, PCI_COMMAND, &tempShort);
|
|
|
|
pci_hose_write_config_word (hose, host_devno, PCI_COMMAND,
|
|
|
|
tempShort | PCI_COMMAND_MASTER |
|
|
|
|
PCI_COMMAND_MEMORY);
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2003-05-31 18:35:21 +00:00
|
|
|
/* do some bridge init, should be done on all 8260 based bridges */
|
2004-02-22 23:46:08 +00:00
|
|
|
pci_hose_write_config_byte (hose, host_devno, PCI_CACHE_LINE_SIZE,
|
|
|
|
0x08);
|
|
|
|
pci_hose_write_config_byte (hose, host_devno, PCI_LATENCY_TIMER,
|
|
|
|
0xF8);
|
2003-05-31 18:35:21 +00:00
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
hose->first_busno = 0;
|
|
|
|
hose->last_busno = 0xff;
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
/* System memory space */
|
2006-05-30 21:32:44 +00:00
|
|
|
#if defined CONFIG_MPC8266ADS || defined CONFIG_MPC8272 || defined CONFIG_PM826
|
2004-02-22 23:46:08 +00:00
|
|
|
pci_set_region (hose->regions + 0,
|
|
|
|
PCI_SLV_MEM_BUS,
|
|
|
|
PCI_SLV_MEM_LOCAL,
|
2009-02-06 15:49:31 +00:00
|
|
|
gd->ram_size, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2004-02-22 23:46:08 +00:00
|
|
|
pci_set_region (hose->regions + 0,
|
2008-10-16 13:01:15 +00:00
|
|
|
CONFIG_SYS_SDRAM_BASE,
|
|
|
|
CONFIG_SYS_SDRAM_BASE,
|
2009-02-06 15:49:31 +00:00
|
|
|
0x4000000, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
/* PCI memory space */
|
2005-09-25 16:49:35 +00:00
|
|
|
#if defined CONFIG_MPC8266ADS || defined CONFIG_MPC8272
|
2004-02-22 23:46:08 +00:00
|
|
|
pci_set_region (hose->regions + 1,
|
|
|
|
PCI_MSTR_MEMIO_BUS,
|
|
|
|
PCI_MSTR_MEMIO_LOCAL,
|
|
|
|
PCI_MSTR_MEMIO_SIZE, PCI_REGION_MEM);
|
2003-05-22 22:52:13 +00:00
|
|
|
#else
|
2004-02-22 23:46:08 +00:00
|
|
|
pci_set_region (hose->regions + 1,
|
|
|
|
PCI_MSTR_MEM_BUS,
|
|
|
|
PCI_MSTR_MEM_LOCAL,
|
|
|
|
PCI_MSTR_MEM_SIZE, PCI_REGION_MEM);
|
2003-05-22 22:52:13 +00:00
|
|
|
#endif
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
/* PCI I/O space */
|
|
|
|
pci_set_region (hose->regions + 2,
|
|
|
|
PCI_MSTR_IO_BUS,
|
|
|
|
PCI_MSTR_IO_LOCAL, PCI_MSTR_IO_SIZE, PCI_REGION_IO);
|
|
|
|
|
|
|
|
hose->region_count = 3;
|
|
|
|
|
|
|
|
pci_register_hose (hose);
|
|
|
|
/* Mask off master abort machine checks */
|
|
|
|
immap->im_pci.pci_emr &= cpu_to_le32 (~PCI_ERROR_PCI_NO_RSP);
|
|
|
|
eieio ();
|
|
|
|
|
|
|
|
hose->last_busno = pci_hose_scan (hose);
|
2003-03-25 16:50:56 +00:00
|
|
|
|
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
/* clear the error in the error status register */
|
|
|
|
immap->im_pci.pci_esr = cpu_to_le32 (PCI_ERROR_PCI_NO_RSP);
|
2003-03-25 16:50:56 +00:00
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
/* unmask master abort machine checks */
|
|
|
|
immap->im_pci.pci_emr |= cpu_to_le32 (PCI_ERROR_PCI_NO_RSP);
|
2003-03-25 16:50:56 +00:00
|
|
|
}
|
|
|
|
|
2008-07-06 09:57:00 +00:00
|
|
|
#if defined(CONFIG_OF_LIBFDT)
|
|
|
|
void ft_pci_setup(void *blob, bd_t *bd)
|
|
|
|
{
|
|
|
|
do_fixup_by_prop_u32(blob, "device_type", "pci", 4,
|
2008-08-12 10:10:11 +00:00
|
|
|
"clock-frequency", gd->pci_clk, 1);
|
2008-07-06 09:57:00 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-02-22 23:46:08 +00:00
|
|
|
#endif /* CONFIG_PCI */
|