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 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 8 | */ |
| 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 Phillips | 1558d0d | 2008-06-10 13:25:24 -0500 | [diff] [blame] | 16 | #include <fpga.h> |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 17 | #include "mvblm7.h" |
Kim Phillips | 1558d0d | 2008-06-10 13:25:24 -0500 | [diff] [blame] | 18 | #include "fpga.h" |
André Schwarz | a8e1d95 | 2009-08-27 14:48:35 +0200 | [diff] [blame] | 19 | #include "../common/mv_common.h" |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 23 | static struct pci_region pci_regions[] = { |
| 24 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 25 | bus_start: CONFIG_SYS_PCI1_MEM_BASE, |
| 26 | phys_start: CONFIG_SYS_PCI1_MEM_PHYS, |
| 27 | size: CONFIG_SYS_PCI1_MEM_SIZE, |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 28 | flags: PCI_REGION_MEM | PCI_REGION_PREFETCH |
| 29 | }, |
| 30 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 31 | bus_start: CONFIG_SYS_PCI1_MMIO_BASE, |
| 32 | phys_start: CONFIG_SYS_PCI1_MMIO_PHYS, |
| 33 | size: CONFIG_SYS_PCI1_MMIO_SIZE, |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 34 | flags: PCI_REGION_MEM |
| 35 | }, |
| 36 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 37 | bus_start: CONFIG_SYS_PCI1_IO_BASE, |
| 38 | phys_start: CONFIG_SYS_PCI1_IO_PHYS, |
| 39 | size: CONFIG_SYS_PCI1_IO_SIZE, |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 40 | flags: PCI_REGION_IO |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | void pci_init_board(void) |
| 45 | { |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 46 | int i; |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 47 | 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-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 54 | immr = (immap_t *) CONFIG_SYS_IMMR; |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 55 | 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 Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 60 | gpio->dat = MV_GPIO_DAT; |
| 61 | gpio->odr = MV_GPIO_ODE; |
André Schwarz | a8e1d95 | 2009-08-27 14:48:35 +0200 | [diff] [blame] | 62 | gpio->dir = MV_GPIO_OUT; |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 63 | |
| 64 | printf("SICRH / SICRL : 0x%08x / 0x%08x\n", immr->sysconf.sicrh, |
| 65 | immr->sysconf.sicrl); |
| 66 | |
| 67 | mvblm7_init_fpga(); |
André Schwarz | a8e1d95 | 2009-08-27 14:48:35 +0200 | [diff] [blame] | 68 | mv_load_fpga(); |
| 69 | |
| 70 | gpio->dir = MV_GPIO_OUT & ~(FPGA_DIN|FPGA_CCLK); |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 71 | |
| 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-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 82 | pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR; |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 83 | pci_law[0].ar = LBLAWAR_EN | LBLAWAR_1GB; |
| 84 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 85 | pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR; |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 86 | pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB; |
| 87 | |
Peter Tyser | e228332 | 2010-09-14 19:13:50 -0500 | [diff] [blame] | 88 | mpc83xx_pci_init(1, reg); |
Andre Schwarz | b2de424 | 2008-06-10 09:14:05 +0200 | [diff] [blame] | 89 | } |