blob: f14837ad404071d6aba7e85f1712d245d6f359f0 [file] [log] [blame]
Andre Schwarza1293e52008-06-10 09:14:05 +02001/*
Kumar Gala4c2e3da2009-07-28 21:49:52 -05002 * Copyright (C) Freescale Semiconductor, Inc. 2006.
Andre Schwarza1293e52008-06-10 09:14:05 +02003 *
4 * (C) Copyright 2008
5 * Andre Schwarz, Matrix Vision GmbH, andre.schwarz@matrix-vision.de
6 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Andre Schwarza1293e52008-06-10 09:14:05 +02008 */
9
10#include <common.h>
11#if defined(CONFIG_OF_LIBFDT)
12#include <libfdt.h>
13#endif
14#include <pci.h>
15#include <mpc83xx.h>
Kim Phillips2329fe12008-06-10 13:25:24 -050016#include <fpga.h>
Andre Schwarza1293e52008-06-10 09:14:05 +020017#include "mvblm7.h"
Kim Phillips2329fe12008-06-10 13:25:24 -050018#include "fpga.h"
André Schwarz28887d82009-08-27 14:48:35 +020019#include "../common/mv_common.h"
Andre Schwarza1293e52008-06-10 09:14:05 +020020
21DECLARE_GLOBAL_DATA_PTR;
22
Andre Schwarza1293e52008-06-10 09:14:05 +020023static struct pci_region pci_regions[] = {
24 {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020025 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
26 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
27 size: CONFIG_SYS_PCI1_MEM_SIZE,
Andre Schwarza1293e52008-06-10 09:14:05 +020028 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
29 },
30 {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020031 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
32 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
33 size: CONFIG_SYS_PCI1_MMIO_SIZE,
Andre Schwarza1293e52008-06-10 09:14:05 +020034 flags: PCI_REGION_MEM
35 },
36 {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020037 bus_start: CONFIG_SYS_PCI1_IO_BASE,
38 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
39 size: CONFIG_SYS_PCI1_IO_SIZE,
Andre Schwarza1293e52008-06-10 09:14:05 +020040 flags: PCI_REGION_IO
41 }
42};
43
44void pci_init_board(void)
45{
Andre Schwarza1293e52008-06-10 09:14:05 +020046 int i;
Andre Schwarza1293e52008-06-10 09:14:05 +020047 volatile immap_t *immr;
48 volatile pcictrl83xx_t *pci_ctrl;
49 volatile gpio83xx_t *gpio;
50 volatile clk83xx_t *clk;
51 volatile law83xx_t *pci_law;
52 struct pci_region *reg[] = { pci_regions };
53
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020054 immr = (immap_t *) CONFIG_SYS_IMMR;
Andre Schwarza1293e52008-06-10 09:14:05 +020055 clk = (clk83xx_t *) &immr->clk;
56 pci_ctrl = immr->pci_ctrl;
57 pci_law = immr->sysconf.pcilaw;
58 gpio = (volatile gpio83xx_t *)&immr->gpio[0];
59
Andre Schwarza1293e52008-06-10 09:14:05 +020060 gpio->dat = MV_GPIO_DAT;
61 gpio->odr = MV_GPIO_ODE;
André Schwarz28887d82009-08-27 14:48:35 +020062 gpio->dir = MV_GPIO_OUT;
Andre Schwarza1293e52008-06-10 09:14:05 +020063
64 printf("SICRH / SICRL : 0x%08x / 0x%08x\n", immr->sysconf.sicrh,
65 immr->sysconf.sicrl);
66
67 mvblm7_init_fpga();
André Schwarz28887d82009-08-27 14:48:35 +020068 mv_load_fpga();
69
70 gpio->dir = MV_GPIO_OUT & ~(FPGA_DIN|FPGA_CCLK);
Andre Schwarza1293e52008-06-10 09:14:05 +020071
72 /* Enable PCI_CLK_OUTPUTs 0 and 1 with 1:1 clocking */
73 clk->occr = 0xc0000000;
74
75 pci_ctrl[0].gcr = 0;
76 udelay(2000);
77 pci_ctrl[0].gcr = 1;
78
79 for (i = 0; i < 1000; ++i)
80 udelay(1000);
81
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020082 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Andre Schwarza1293e52008-06-10 09:14:05 +020083 pci_law[0].ar = LBLAWAR_EN | LBLAWAR_1GB;
84
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020085 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Andre Schwarza1293e52008-06-10 09:14:05 +020086 pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
87
Peter Tyser6aa3d3b2010-09-14 19:13:50 -050088 mpc83xx_pci_init(1, reg);
Andre Schwarza1293e52008-06-10 09:14:05 +020089}