Scott Wood | 865b8ae | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) Freescale Semiconductor, Inc. 2006-2007 |
| 3 | * |
| 4 | * Author: Scott Wood <scottwood@freescale.com> |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 26 | #if defined(CONFIG_OF_FLAT_TREE) |
Scott Wood | 865b8ae | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 27 | #include <ft_build.h> |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 28 | #elif defined(CONFIG_OF_LIBFDT) |
| 29 | #include <libfdt.h> |
| 30 | #endif |
Scott Wood | 865b8ae | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 31 | #include <pci.h> |
| 32 | #include <mpc83xx.h> |
| 33 | |
| 34 | DECLARE_GLOBAL_DATA_PTR; |
| 35 | |
| 36 | int board_early_init_f(void) |
| 37 | { |
| 38 | #ifndef CFG_8313ERDB_BROKEN_PMC |
| 39 | volatile immap_t *im = (immap_t *)CFG_IMMR; |
| 40 | |
| 41 | if (im->pmc.pmccr1 & PMCCR1_POWER_OFF) |
| 42 | gd->flags |= GD_FLG_SILENT; |
| 43 | #endif |
| 44 | |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | int checkboard(void) |
| 49 | { |
| 50 | puts("Board: Freescale MPC8313ERDB\n"); |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | static struct pci_region pci_regions[] = { |
| 55 | { |
| 56 | bus_start: CFG_PCI1_MEM_BASE, |
| 57 | phys_start: CFG_PCI1_MEM_PHYS, |
| 58 | size: CFG_PCI1_MEM_SIZE, |
| 59 | flags: PCI_REGION_MEM | PCI_REGION_PREFETCH |
| 60 | }, |
| 61 | { |
| 62 | bus_start: CFG_PCI1_MMIO_BASE, |
| 63 | phys_start: CFG_PCI1_MMIO_PHYS, |
| 64 | size: CFG_PCI1_MMIO_SIZE, |
| 65 | flags: PCI_REGION_MEM |
| 66 | }, |
| 67 | { |
| 68 | bus_start: CFG_PCI1_IO_BASE, |
| 69 | phys_start: CFG_PCI1_IO_PHYS, |
| 70 | size: CFG_PCI1_IO_SIZE, |
| 71 | flags: PCI_REGION_IO |
| 72 | } |
| 73 | }; |
| 74 | |
| 75 | void pci_init_board(void) |
| 76 | { |
| 77 | volatile immap_t *immr = (volatile immap_t *)CFG_IMMR; |
| 78 | volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk; |
| 79 | volatile law83xx_t *pci_law = immr->sysconf.pcilaw; |
| 80 | struct pci_region *reg[] = { pci_regions }; |
| 81 | int warmboot; |
| 82 | |
| 83 | /* Enable all 3 PCI_CLK_OUTPUTs. */ |
| 84 | clk->occr |= 0xe0000000; |
| 85 | |
| 86 | /* |
| 87 | * Configure PCI Local Access Windows |
| 88 | */ |
| 89 | pci_law[0].bar = CFG_PCI1_MEM_PHYS & LAWBAR_BAR; |
| 90 | pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB; |
| 91 | |
| 92 | pci_law[1].bar = CFG_PCI1_IO_PHYS & LAWBAR_BAR; |
| 93 | pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB; |
| 94 | |
| 95 | warmboot = gd->bd->bi_bootflags & BOOTFLAG_WARM; |
| 96 | #ifndef CFG_8313ERDB_BROKEN_PMC |
| 97 | warmboot |= immr->pmc.pmccr1 & PMCCR1_POWER_OFF; |
| 98 | #endif |
| 99 | |
| 100 | mpc83xx_pci_init(1, reg, warmboot); |
| 101 | } |
| 102 | |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 103 | #if defined(CONFIG_OF_BOARD_SETUP) |
Scott Wood | 865b8ae | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 104 | void ft_board_setup(void *blob, bd_t *bd) |
| 105 | { |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 106 | #if defined(CONFIG_OF_FLAT_TREE) |
Scott Wood | 865b8ae | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 107 | u32 *p; |
| 108 | int len; |
| 109 | |
Scott Wood | 865b8ae | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 110 | p = ft_get_prop(blob, "/memory/reg", &len); |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 111 | if (p != NULL) { |
Scott Wood | 865b8ae | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 112 | *p++ = cpu_to_be32(bd->bi_memstart); |
| 113 | *p = cpu_to_be32(bd->bi_memsize); |
| 114 | } |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 115 | #endif |
| 116 | ft_cpu_setup(blob, bd); |
| 117 | #ifdef CONFIG_PCI |
| 118 | ft_pci_setup(blob, bd); |
| 119 | #endif |
Scott Wood | 865b8ae | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 120 | } |
| 121 | #endif |