Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 1 | /* |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame] | 2 | * Copyright (C) 2007,2010 Freescale Semiconductor, Inc. |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 3 | * Dave Liu <daveliu@freescale.com> |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Anton Vorontsov | 5cd6152 | 2009-06-10 00:25:31 +0400 | [diff] [blame] | 9 | #include <hwconfig.h> |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 10 | #include <i2c.h> |
Dave Liu | b8dc587 | 2008-03-26 22:56:36 +0800 | [diff] [blame] | 11 | #include <asm/io.h> |
Kumar Gala | b7c3ccf | 2010-04-20 10:02:24 -0500 | [diff] [blame] | 12 | #include <asm/fsl_mpc83xx_serdes.h> |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 13 | #include <spd_sdram.h> |
Anton Vorontsov | 32b1b70 | 2008-10-02 18:32:25 +0400 | [diff] [blame] | 14 | #include <tsec.h> |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 15 | #include <libfdt.h> |
Anton Vorontsov | 504867a | 2008-10-14 22:58:53 +0400 | [diff] [blame] | 16 | #include <fdt_support.h> |
Anton Vorontsov | 5cd6152 | 2009-06-10 00:25:31 +0400 | [diff] [blame] | 17 | #include <fsl_esdhc.h> |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 18 | #include <fsl_mdio.h> |
Andy Fleming | 7832a46 | 2011-04-13 00:37:12 -0500 | [diff] [blame] | 19 | #include <phy.h> |
Anton Vorontsov | 62842ec | 2009-01-08 04:26:19 +0300 | [diff] [blame] | 20 | #include "pci.h" |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 21 | #include "../common/pq-mds-pib.h" |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 22 | |
Simon Glass | 39f90ba | 2017-03-31 08:40:25 -0600 | [diff] [blame] | 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 25 | int board_early_init_f(void) |
| 26 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 27 | u8 *bcsr = (u8 *)CONFIG_SYS_BCSR; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 28 | |
| 29 | /* Enable flash write */ |
| 30 | bcsr[0x9] &= ~0x04; |
| 31 | /* Clear all of the interrupt of BCSR */ |
| 32 | bcsr[0xe] = 0xff; |
| 33 | |
Dave Liu | b8dc587 | 2008-03-26 22:56:36 +0800 | [diff] [blame] | 34 | #ifdef CONFIG_FSL_SERDES |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 35 | immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; |
Dave Liu | b8dc587 | 2008-03-26 22:56:36 +0800 | [diff] [blame] | 36 | u32 spridr = in_be32(&immr->sysconf.spridr); |
| 37 | |
| 38 | /* we check only part num, and don't look for CPU revisions */ |
Dave Liu | 1f2f86e | 2008-03-31 17:05:12 +0800 | [diff] [blame] | 39 | switch (PARTID_NO_E(spridr)) { |
Kim Phillips | ecb2d6f | 2008-03-28 10:19:07 -0500 | [diff] [blame] | 40 | case SPR_8377: |
Dave Liu | b8dc587 | 2008-03-26 22:56:36 +0800 | [diff] [blame] | 41 | fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA, |
Andy Fleming | 1463b4b | 2008-10-30 16:50:14 -0500 | [diff] [blame] | 42 | FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V); |
Dave Liu | b8dc587 | 2008-03-26 22:56:36 +0800 | [diff] [blame] | 43 | break; |
Kim Phillips | ecb2d6f | 2008-03-28 10:19:07 -0500 | [diff] [blame] | 44 | case SPR_8378: |
Anton Vorontsov | 32b1b70 | 2008-10-02 18:32:25 +0400 | [diff] [blame] | 45 | fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SGMII, |
Andy Fleming | 1463b4b | 2008-10-30 16:50:14 -0500 | [diff] [blame] | 46 | FSL_SERDES_CLK_125, FSL_SERDES_VDD_1V); |
Dave Liu | b8dc587 | 2008-03-26 22:56:36 +0800 | [diff] [blame] | 47 | break; |
Kim Phillips | ecb2d6f | 2008-03-28 10:19:07 -0500 | [diff] [blame] | 48 | case SPR_8379: |
Dave Liu | b8dc587 | 2008-03-26 22:56:36 +0800 | [diff] [blame] | 49 | fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA, |
Andy Fleming | 1463b4b | 2008-10-30 16:50:14 -0500 | [diff] [blame] | 50 | FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V); |
Kim Phillips | ecb2d6f | 2008-03-28 10:19:07 -0500 | [diff] [blame] | 51 | fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_SATA, |
Andy Fleming | 1463b4b | 2008-10-30 16:50:14 -0500 | [diff] [blame] | 52 | FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V); |
Dave Liu | b8dc587 | 2008-03-26 22:56:36 +0800 | [diff] [blame] | 53 | break; |
| 54 | default: |
| 55 | printf("serdes not configured: unknown CPU part number: " |
Andy Fleming | 1463b4b | 2008-10-30 16:50:14 -0500 | [diff] [blame] | 56 | "%04x\n", spridr >> 16); |
Dave Liu | b8dc587 | 2008-03-26 22:56:36 +0800 | [diff] [blame] | 57 | break; |
| 58 | } |
| 59 | #endif /* CONFIG_FSL_SERDES */ |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 60 | return 0; |
| 61 | } |
| 62 | |
Anton Vorontsov | 5cd6152 | 2009-06-10 00:25:31 +0400 | [diff] [blame] | 63 | #ifdef CONFIG_FSL_ESDHC |
| 64 | int board_mmc_init(bd_t *bd) |
| 65 | { |
| 66 | struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR; |
| 67 | u8 *bcsr = (u8 *)CONFIG_SYS_BCSR; |
| 68 | |
| 69 | if (!hwconfig("esdhc")) |
| 70 | return 0; |
| 71 | |
| 72 | /* Set SPI_SD, SER_SD, and IRQ4_WP so that SD signals go through */ |
| 73 | bcsr[0xc] |= 0x4c; |
| 74 | |
| 75 | /* Set proper bits in SICR to allow SD signals through */ |
| 76 | clrsetbits_be32(&im->sysconf.sicrl, SICRL_USB_B, SICRL_USB_B_SD); |
| 77 | clrsetbits_be32(&im->sysconf.sicrh, SICRH_GPIO2_E | SICRH_SPI, |
| 78 | SICRH_GPIO2_E_SD | SICRH_SPI_SD); |
| 79 | |
| 80 | return fsl_esdhc_mmc_init(bd); |
| 81 | } |
| 82 | #endif |
| 83 | |
Anton Vorontsov | 32b1b70 | 2008-10-02 18:32:25 +0400 | [diff] [blame] | 84 | #if defined(CONFIG_TSEC1) || defined(CONFIG_TSEC2) |
| 85 | int board_eth_init(bd_t *bd) |
| 86 | { |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 87 | struct fsl_pq_mdio_info mdio_info; |
Anton Vorontsov | 32b1b70 | 2008-10-02 18:32:25 +0400 | [diff] [blame] | 88 | struct tsec_info_struct tsec_info[2]; |
| 89 | struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR; |
| 90 | u32 rcwh = in_be32(&im->reset.rcwh); |
| 91 | u32 tsec_mode; |
| 92 | int num = 0; |
| 93 | |
| 94 | /* New line after Net: */ |
| 95 | printf("\n"); |
| 96 | |
| 97 | #ifdef CONFIG_TSEC1 |
| 98 | SET_STD_TSEC_INFO(tsec_info[num], 1); |
| 99 | |
| 100 | printf(CONFIG_TSEC1_NAME ": "); |
| 101 | |
| 102 | tsec_mode = rcwh & HRCWH_TSEC1M_MASK; |
| 103 | if (tsec_mode == HRCWH_TSEC1M_IN_RGMII) { |
| 104 | printf("RGMII\n"); |
| 105 | /* this is default, no need to fixup */ |
| 106 | } else if (tsec_mode == HRCWH_TSEC1M_IN_SGMII) { |
| 107 | printf("SGMII\n"); |
| 108 | tsec_info[num].phyaddr = TSEC1_PHY_ADDR_SGMII; |
| 109 | tsec_info[num].flags = TSEC_GIGABIT; |
| 110 | } else { |
| 111 | printf("unsupported PHY type\n"); |
| 112 | } |
| 113 | num++; |
| 114 | #endif |
| 115 | #ifdef CONFIG_TSEC2 |
| 116 | SET_STD_TSEC_INFO(tsec_info[num], 2); |
| 117 | |
| 118 | printf(CONFIG_TSEC2_NAME ": "); |
| 119 | |
| 120 | tsec_mode = rcwh & HRCWH_TSEC2M_MASK; |
| 121 | if (tsec_mode == HRCWH_TSEC2M_IN_RGMII) { |
| 122 | printf("RGMII\n"); |
| 123 | /* this is default, no need to fixup */ |
| 124 | } else if (tsec_mode == HRCWH_TSEC2M_IN_SGMII) { |
| 125 | printf("SGMII\n"); |
| 126 | tsec_info[num].phyaddr = TSEC2_PHY_ADDR_SGMII; |
| 127 | tsec_info[num].flags = TSEC_GIGABIT; |
| 128 | } else { |
| 129 | printf("unsupported PHY type\n"); |
| 130 | } |
| 131 | num++; |
| 132 | #endif |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 133 | |
| 134 | mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR; |
| 135 | mdio_info.name = DEFAULT_MII_NAME; |
| 136 | fsl_pq_mdio_init(bd, &mdio_info); |
| 137 | |
Anton Vorontsov | 32b1b70 | 2008-10-02 18:32:25 +0400 | [diff] [blame] | 138 | return tsec_eth_init(bd, tsec_info, num); |
| 139 | } |
| 140 | |
| 141 | static void __ft_tsec_fixup(void *blob, bd_t *bd, const char *alias, |
| 142 | int phy_addr) |
| 143 | { |
Anton Vorontsov | 32b1b70 | 2008-10-02 18:32:25 +0400 | [diff] [blame] | 144 | const u32 *ph; |
| 145 | int off; |
| 146 | int err; |
| 147 | |
| 148 | off = fdt_path_offset(blob, alias); |
| 149 | if (off < 0) { |
| 150 | printf("WARNING: could not find %s alias: %s.\n", alias, |
| 151 | fdt_strerror(off)); |
| 152 | return; |
| 153 | } |
| 154 | |
Andy Fleming | 7832a46 | 2011-04-13 00:37:12 -0500 | [diff] [blame] | 155 | err = fdt_fixup_phy_connection(blob, off, PHY_INTERFACE_MODE_SGMII); |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame] | 156 | |
Anton Vorontsov | 32b1b70 | 2008-10-02 18:32:25 +0400 | [diff] [blame] | 157 | if (err) { |
| 158 | printf("WARNING: could not set phy-connection-type for %s: " |
| 159 | "%s.\n", alias, fdt_strerror(err)); |
| 160 | return; |
| 161 | } |
| 162 | |
| 163 | ph = (u32 *)fdt_getprop(blob, off, "phy-handle", 0); |
| 164 | if (!ph) { |
| 165 | printf("WARNING: could not get phy-handle for %s.\n", |
| 166 | alias); |
| 167 | return; |
| 168 | } |
| 169 | |
| 170 | off = fdt_node_offset_by_phandle(blob, *ph); |
| 171 | if (off < 0) { |
| 172 | printf("WARNING: could not get phy node for %s: %s\n", alias, |
| 173 | fdt_strerror(off)); |
| 174 | return; |
| 175 | } |
| 176 | |
| 177 | phy_addr = cpu_to_fdt32(phy_addr); |
| 178 | err = fdt_setprop(blob, off, "reg", &phy_addr, sizeof(phy_addr)); |
| 179 | if (err < 0) { |
| 180 | printf("WARNING: could not set phy node's reg for %s: " |
| 181 | "%s.\n", alias, fdt_strerror(err)); |
| 182 | return; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | static void ft_tsec_fixup(void *blob, bd_t *bd) |
| 187 | { |
| 188 | struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR; |
| 189 | u32 rcwh = in_be32(&im->reset.rcwh); |
| 190 | u32 tsec_mode; |
| 191 | |
| 192 | #ifdef CONFIG_TSEC1 |
| 193 | tsec_mode = rcwh & HRCWH_TSEC1M_MASK; |
| 194 | if (tsec_mode == HRCWH_TSEC1M_IN_SGMII) |
| 195 | __ft_tsec_fixup(blob, bd, "ethernet0", TSEC1_PHY_ADDR_SGMII); |
| 196 | #endif |
| 197 | |
| 198 | #ifdef CONFIG_TSEC2 |
| 199 | tsec_mode = rcwh & HRCWH_TSEC2M_MASK; |
| 200 | if (tsec_mode == HRCWH_TSEC2M_IN_SGMII) |
| 201 | __ft_tsec_fixup(blob, bd, "ethernet1", TSEC2_PHY_ADDR_SGMII); |
| 202 | #endif |
| 203 | } |
| 204 | #else |
| 205 | static inline void ft_tsec_fixup(void *blob, bd_t *bd) {} |
| 206 | #endif /* defined(CONFIG_TSEC1) || defined(CONFIG_TSEC2) */ |
| 207 | |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 208 | int board_early_init_r(void) |
| 209 | { |
| 210 | #ifdef CONFIG_PQ_MDS_PIB |
| 211 | pib_init(); |
| 212 | #endif |
| 213 | return 0; |
| 214 | } |
| 215 | |
Peter Tyser | cb4731f | 2009-06-30 17:15:50 -0500 | [diff] [blame] | 216 | #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 217 | extern void ddr_enable_ecc(unsigned int dram_size); |
| 218 | #endif |
| 219 | int fixed_sdram(void); |
| 220 | |
Simon Glass | d35f338 | 2017-04-06 12:47:05 -0600 | [diff] [blame] | 221 | int dram_init(void) |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 222 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 223 | volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 224 | u32 msize = 0; |
| 225 | |
| 226 | if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im) |
Simon Glass | 39f90ba | 2017-03-31 08:40:25 -0600 | [diff] [blame] | 227 | return -ENXIO; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 228 | |
| 229 | #if defined(CONFIG_SPD_EEPROM) |
| 230 | msize = spd_sdram(); |
| 231 | #else |
| 232 | msize = fixed_sdram(); |
| 233 | #endif |
| 234 | |
Peter Tyser | cb4731f | 2009-06-30 17:15:50 -0500 | [diff] [blame] | 235 | #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 236 | /* Initialize DDR ECC byte */ |
| 237 | ddr_enable_ecc(msize * 1024 * 1024); |
| 238 | #endif |
| 239 | |
| 240 | /* return total bus DDR size(bytes) */ |
Simon Glass | 39f90ba | 2017-03-31 08:40:25 -0600 | [diff] [blame] | 241 | gd->ram_size = msize * 1024 * 1024; |
| 242 | |
| 243 | return 0; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | #if !defined(CONFIG_SPD_EEPROM) |
| 247 | /************************************************************************* |
| 248 | * fixed sdram init -- doesn't use serial presence detect. |
| 249 | ************************************************************************/ |
| 250 | int fixed_sdram(void) |
| 251 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 252 | volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR; |
| 253 | u32 msize = CONFIG_SYS_DDR_SIZE * 1024 * 1024; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 254 | u32 msize_log2 = __ilog2(msize); |
| 255 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 256 | im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_SDRAM_BASE & 0xfffff000; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 257 | im->sysconf.ddrlaw[0].ar = LBLAWAR_EN | (msize_log2 - 1); |
| 258 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 259 | #if (CONFIG_SYS_DDR_SIZE != 512) |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 260 | #warning Currenly any ddr size other than 512 is not supported |
| 261 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 262 | im->sysconf.ddrcdr = CONFIG_SYS_DDRCDR_VALUE; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 263 | udelay(50000); |
| 264 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 265 | im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_SDRAM_CLK_CNTL; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 266 | udelay(1000); |
| 267 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 268 | im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS; |
| 269 | im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 270 | udelay(1000); |
| 271 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 272 | im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0; |
| 273 | im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1; |
| 274 | im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2; |
| 275 | im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3; |
| 276 | im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG; |
| 277 | im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2; |
| 278 | im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE; |
| 279 | im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2; |
| 280 | im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 281 | __asm__ __volatile__("sync"); |
| 282 | udelay(1000); |
| 283 | |
| 284 | im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN; |
| 285 | udelay(2000); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 286 | return CONFIG_SYS_DDR_SIZE; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 287 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 288 | #endif /*!CONFIG_SYS_SPD_EEPROM */ |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 289 | |
| 290 | int checkboard(void) |
| 291 | { |
| 292 | puts("Board: Freescale MPC837xEMDS\n"); |
| 293 | return 0; |
| 294 | } |
| 295 | |
Anton Vorontsov | 30c6992 | 2008-10-02 19:17:33 +0400 | [diff] [blame] | 296 | #ifdef CONFIG_PCI |
| 297 | int board_pci_host_broken(void) |
| 298 | { |
| 299 | struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR; |
| 300 | const u32 rcw_mask = HRCWH_PCI1_ARBITER_ENABLE | HRCWH_PCI_HOST; |
Anton Vorontsov | 30c6992 | 2008-10-02 19:17:33 +0400 | [diff] [blame] | 301 | |
| 302 | /* It's always OK in case of external arbiter. */ |
Anton Vorontsov | cb647ee | 2009-06-10 00:25:38 +0400 | [diff] [blame] | 303 | if (hwconfig_subarg_cmp("pci", "arbiter", "external")) |
Anton Vorontsov | 30c6992 | 2008-10-02 19:17:33 +0400 | [diff] [blame] | 304 | return 0; |
| 305 | |
| 306 | if ((in_be32(&im->reset.rcwh) & rcw_mask) != rcw_mask) |
| 307 | return 1; |
| 308 | |
| 309 | return 0; |
| 310 | } |
| 311 | |
| 312 | static void ft_pci_fixup(void *blob, bd_t *bd) |
| 313 | { |
| 314 | const char *status = "broken (no arbiter)"; |
| 315 | int off; |
| 316 | int err; |
| 317 | |
| 318 | off = fdt_path_offset(blob, "pci0"); |
| 319 | if (off < 0) { |
| 320 | printf("WARNING: could not find pci0 alias: %s.\n", |
| 321 | fdt_strerror(off)); |
| 322 | return; |
| 323 | } |
| 324 | |
| 325 | err = fdt_setprop(blob, off, "status", status, strlen(status) + 1); |
| 326 | if (err) { |
| 327 | printf("WARNING: could not set status for pci0: %s.\n", |
| 328 | fdt_strerror(err)); |
| 329 | return; |
| 330 | } |
| 331 | } |
| 332 | #endif |
| 333 | |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 334 | #if defined(CONFIG_OF_BOARD_SETUP) |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 335 | int ft_board_setup(void *blob, bd_t *bd) |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 336 | { |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 337 | ft_cpu_setup(blob, bd); |
Anton Vorontsov | 32b1b70 | 2008-10-02 18:32:25 +0400 | [diff] [blame] | 338 | ft_tsec_fixup(blob, bd); |
Sriram Dash | 9fd465c | 2016-09-16 17:12:15 +0530 | [diff] [blame] | 339 | fsl_fdt_fixup_dr_usb(blob, bd); |
Anton Vorontsov | 5cd6152 | 2009-06-10 00:25:31 +0400 | [diff] [blame] | 340 | fdt_fixup_esdhc(blob, bd); |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 341 | #ifdef CONFIG_PCI |
| 342 | ft_pci_setup(blob, bd); |
Anton Vorontsov | 30c6992 | 2008-10-02 19:17:33 +0400 | [diff] [blame] | 343 | if (board_pci_host_broken()) |
| 344 | ft_pci_fixup(blob, bd); |
Anton Vorontsov | 62842ec | 2009-01-08 04:26:19 +0300 | [diff] [blame] | 345 | ft_pcie_fixup(blob, bd); |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 346 | #endif |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 347 | |
| 348 | return 0; |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 349 | } |
| 350 | #endif /* CONFIG_OF_BOARD_SETUP */ |