Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 1 | /* |
Kumar Gala | 6a6d948 | 2009-07-28 21:49:52 -0500 | [diff] [blame] | 2 | * Copyright (C) Freescale Semiconductor, Inc. 2006. |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 3 | * |
| 4 | * (C) Copyright 2008 |
| 5 | * Andre Schwarz, Matrix Vision GmbH, andre.schwarz@matrix-vision.de |
| 6 | * |
| 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 23 | * MA 02111-1307 USA |
| 24 | */ |
| 25 | |
| 26 | #include <common.h> |
| 27 | #if defined(CONFIG_OF_LIBFDT) |
| 28 | #include <libfdt.h> |
| 29 | #endif |
| 30 | #include <pci.h> |
| 31 | #include <mpc83xx.h> |
Kim Phillips | 1558d0d | 2008-06-10 13:25:24 -0500 | [diff] [blame] | 32 | #include <fpga.h> |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 33 | #include "mvblm7.h" |
Kim Phillips | 1558d0d | 2008-06-10 13:25:24 -0500 | [diff] [blame] | 34 | #include "fpga.h" |
André Schwarz | a8e1d95 | 2009-08-27 14:48:35 +0200 | [diff] [blame] | 35 | #include "../common/mv_common.h" |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 36 | |
| 37 | DECLARE_GLOBAL_DATA_PTR; |
| 38 | |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 39 | static struct pci_region pci_regions[] = { |
| 40 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 41 | bus_start: CONFIG_SYS_PCI1_MEM_BASE, |
| 42 | phys_start: CONFIG_SYS_PCI1_MEM_PHYS, |
| 43 | size: CONFIG_SYS_PCI1_MEM_SIZE, |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 44 | flags: PCI_REGION_MEM | PCI_REGION_PREFETCH |
| 45 | }, |
| 46 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 47 | bus_start: CONFIG_SYS_PCI1_MMIO_BASE, |
| 48 | phys_start: CONFIG_SYS_PCI1_MMIO_PHYS, |
| 49 | size: CONFIG_SYS_PCI1_MMIO_SIZE, |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 50 | flags: PCI_REGION_MEM |
| 51 | }, |
| 52 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 53 | bus_start: CONFIG_SYS_PCI1_IO_BASE, |
| 54 | phys_start: CONFIG_SYS_PCI1_IO_PHYS, |
| 55 | size: CONFIG_SYS_PCI1_IO_SIZE, |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 56 | flags: PCI_REGION_IO |
| 57 | } |
| 58 | }; |
| 59 | |
| 60 | void pci_init_board(void) |
| 61 | { |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 62 | int i; |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 63 | volatile immap_t *immr; |
| 64 | volatile pcictrl83xx_t *pci_ctrl; |
| 65 | volatile gpio83xx_t *gpio; |
| 66 | volatile clk83xx_t *clk; |
| 67 | volatile law83xx_t *pci_law; |
| 68 | struct pci_region *reg[] = { pci_regions }; |
| 69 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 70 | immr = (immap_t *) CONFIG_SYS_IMMR; |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 71 | clk = (clk83xx_t *) &immr->clk; |
| 72 | pci_ctrl = immr->pci_ctrl; |
| 73 | pci_law = immr->sysconf.pcilaw; |
| 74 | gpio = (volatile gpio83xx_t *)&immr->gpio[0]; |
| 75 | |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 76 | gpio->dat = MV_GPIO_DAT; |
| 77 | gpio->odr = MV_GPIO_ODE; |
André Schwarz | a8e1d95 | 2009-08-27 14:48:35 +0200 | [diff] [blame] | 78 | gpio->dir = MV_GPIO_OUT; |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 79 | |
| 80 | printf("SICRH / SICRL : 0x%08x / 0x%08x\n", immr->sysconf.sicrh, |
| 81 | immr->sysconf.sicrl); |
| 82 | |
| 83 | mvblm7_init_fpga(); |
André Schwarz | a8e1d95 | 2009-08-27 14:48:35 +0200 | [diff] [blame] | 84 | mv_load_fpga(); |
| 85 | |
| 86 | gpio->dir = MV_GPIO_OUT & ~(FPGA_DIN|FPGA_CCLK); |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 87 | |
| 88 | /* Enable PCI_CLK_OUTPUTs 0 and 1 with 1:1 clocking */ |
| 89 | clk->occr = 0xc0000000; |
| 90 | |
| 91 | pci_ctrl[0].gcr = 0; |
| 92 | udelay(2000); |
| 93 | pci_ctrl[0].gcr = 1; |
| 94 | |
| 95 | for (i = 0; i < 1000; ++i) |
| 96 | udelay(1000); |
| 97 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 98 | pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR; |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 99 | pci_law[0].ar = LBLAWAR_EN | LBLAWAR_1GB; |
| 100 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 101 | pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR; |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 102 | pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB; |
| 103 | |
Peter Tyser | e228332 | 2010-09-14 19:13:50 -0500 | [diff] [blame] | 104 | mpc83xx_pci_init(1, reg); |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 105 | } |