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