Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 1 | /* |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 2 | * Copyright (C) 2006-2009 Freescale Semiconductor, Inc. |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <common.h> |
| 24 | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 25 | #include <asm/mmu.h> |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 26 | #include <asm/io.h> |
| 27 | #include <mpc83xx.h> |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 28 | #include <pci.h> |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 29 | #include <i2c.h> |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 30 | #include <asm/fsl_i2c.h> |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 31 | |
| 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 34 | static struct pci_region pci1_regions[] = { |
| 35 | { |
| 36 | bus_start: CONFIG_SYS_PCI1_MEM_BASE, |
| 37 | phys_start: CONFIG_SYS_PCI1_MEM_PHYS, |
| 38 | size: CONFIG_SYS_PCI1_MEM_SIZE, |
| 39 | flags: PCI_REGION_MEM | PCI_REGION_PREFETCH |
| 40 | }, |
| 41 | { |
| 42 | bus_start: CONFIG_SYS_PCI1_IO_BASE, |
| 43 | phys_start: CONFIG_SYS_PCI1_IO_PHYS, |
| 44 | size: CONFIG_SYS_PCI1_IO_SIZE, |
| 45 | flags: PCI_REGION_IO |
| 46 | }, |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 47 | { |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 48 | bus_start: CONFIG_SYS_PCI1_MMIO_BASE, |
| 49 | phys_start: CONFIG_SYS_PCI1_MMIO_PHYS, |
| 50 | size: CONFIG_SYS_PCI1_MMIO_SIZE, |
| 51 | flags: PCI_REGION_MEM |
| 52 | }, |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 53 | }; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 54 | |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 55 | #ifdef CONFIG_MPC83XX_PCI2 |
| 56 | static struct pci_region pci2_regions[] = { |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 57 | { |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 58 | bus_start: CONFIG_SYS_PCI2_MEM_BASE, |
| 59 | phys_start: CONFIG_SYS_PCI2_MEM_PHYS, |
| 60 | size: CONFIG_SYS_PCI2_MEM_SIZE, |
| 61 | flags: PCI_REGION_MEM | PCI_REGION_PREFETCH |
| 62 | }, |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 63 | { |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 64 | bus_start: CONFIG_SYS_PCI2_IO_BASE, |
| 65 | phys_start: CONFIG_SYS_PCI2_IO_PHYS, |
| 66 | size: CONFIG_SYS_PCI2_IO_SIZE, |
| 67 | flags: PCI_REGION_IO |
| 68 | }, |
| 69 | { |
| 70 | bus_start: CONFIG_SYS_PCI2_MMIO_BASE, |
| 71 | phys_start: CONFIG_SYS_PCI2_MMIO_PHYS, |
| 72 | size: CONFIG_SYS_PCI2_MMIO_SIZE, |
| 73 | flags: PCI_REGION_MEM |
| 74 | }, |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 75 | }; |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 76 | #endif |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 77 | |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 78 | void pci_init_board(void) |
| 79 | { |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 80 | volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR; |
| 81 | volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk; |
| 82 | volatile law83xx_t *pci_law = immr->sysconf.pcilaw; |
| 83 | #ifndef CONFIG_MPC83XX_PCI2 |
| 84 | struct pci_region *reg[] = { pci1_regions }; |
| 85 | #else |
| 86 | struct pci_region *reg[] = { pci1_regions, pci2_regions }; |
| 87 | #endif |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 88 | u8 reg8; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 89 | |
| 90 | #ifdef CONFIG_HARD_I2C |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 91 | i2c_set_bus_num(1); |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 92 | /* Read the PCI_M66EN jumper setting */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 93 | if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, ®8, sizeof(reg8)) == 0) || |
| 94 | (i2c_read(CONFIG_SYS_I2C_8574A_ADDR2, 0, 0, ®8, sizeof(reg8)) == 0)) { |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 95 | if (reg8 & I2C_8574_PCI66) |
| 96 | clk->occr = 0xff000000; /* 66 MHz PCI */ |
| 97 | else |
| 98 | clk->occr = 0xff600001; /* 33 MHz PCI */ |
| 99 | } else { |
| 100 | clk->occr = 0xff600001; /* 33 MHz PCI */ |
| 101 | } |
| 102 | #else |
| 103 | clk->occr = 0xff000000; /* 66 MHz PCI */ |
| 104 | #endif |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 105 | udelay(2000); |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 106 | |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 107 | /* Configure PCI Local Access Windows */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 108 | pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 109 | pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G; |
| 110 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 111 | pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR; |
Timur Tabi | e9b04f0 | 2006-10-31 19:14:41 -0600 | [diff] [blame] | 112 | pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M; |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 113 | |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 114 | udelay(2000); |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 115 | |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 116 | #ifndef CONFIG_MPC83XX_PCI2 |
Peter Tyser | e228332 | 2010-09-14 19:13:50 -0500 | [diff] [blame] | 117 | mpc83xx_pci_init(1, reg); |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 118 | #else |
Peter Tyser | e228332 | 2010-09-14 19:13:50 -0500 | [diff] [blame] | 119 | mpc83xx_pci_init(2, reg); |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 120 | #endif |
Kim Phillips | 774e1b5 | 2006-11-01 00:10:40 -0600 | [diff] [blame] | 121 | } |