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