Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 2 | /* |
Kumar Gala | d0f27d3 | 2010-07-08 22:37:44 -0500 | [diff] [blame] | 3 | * Copyright 2009-2010 Freescale Semiconductor. |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 4 | * |
| 5 | * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com> |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | a73bda4 | 2015-11-08 23:47:45 -0700 | [diff] [blame] | 9 | #include <console.h> |
Simon Glass | 8e20188 | 2020-05-10 11:39:54 -0600 | [diff] [blame] | 10 | #include <flash.h> |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 11 | #include <hwconfig.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 12 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 13 | #include <log.h> |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 14 | #include <pci.h> |
| 15 | #include <asm/processor.h> |
| 16 | #include <asm/mmu.h> |
Haiying Wang | fac2385 | 2010-09-29 13:31:35 -0400 | [diff] [blame] | 17 | #include <asm/cache.h> |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 18 | #include <asm/immap_85xx.h> |
Kumar Gala | 9bbd643 | 2009-04-02 13:22:48 -0500 | [diff] [blame] | 19 | #include <asm/fsl_pci.h> |
York Sun | f062659 | 2013-09-30 09:22:09 -0700 | [diff] [blame] | 20 | #include <fsl_ddr_sdram.h> |
Kumar Gala | 3d02038 | 2010-12-15 04:55:20 -0600 | [diff] [blame] | 21 | #include <asm/fsl_serdes.h> |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 22 | #include <asm/io.h> |
| 23 | #include <spd_sdram.h> |
| 24 | #include <i2c.h> |
| 25 | #include <ioports.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 26 | #include <linux/delay.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 27 | #include <linux/libfdt.h> |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 28 | #include <fdt_support.h> |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 29 | #include <fsl_esdhc.h> |
Andy Fleming | 7832a46 | 2011-04-13 00:37:12 -0500 | [diff] [blame] | 30 | #include <phy.h> |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 31 | |
| 32 | #include "bcsr.h" |
Liu Yu | c39aa4f | 2009-11-27 15:31:51 +0800 | [diff] [blame] | 33 | #if defined(CONFIG_PQ_MDS_PIB) |
| 34 | #include "../common/pq-mds-pib.h" |
| 35 | #endif |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 36 | |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 37 | const qe_iop_conf_t qe_iop_conf_tab[] = { |
| 38 | /* QE_MUX_MDC */ |
| 39 | {2, 31, 1, 0, 1}, /* QE_MUX_MDC */ |
| 40 | |
| 41 | /* QE_MUX_MDIO */ |
| 42 | {2, 30, 3, 0, 2}, /* QE_MUX_MDIO */ |
| 43 | |
Haiying Wang | bc759ee | 2009-05-20 12:30:37 -0400 | [diff] [blame] | 44 | #if defined(CONFIG_SYS_UCC_RGMII_MODE) |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 45 | /* UCC_1_RGMII */ |
| 46 | {2, 11, 2, 0, 1}, /* CLK12 */ |
| 47 | {0, 0, 1, 0, 3}, /* ENET1_TXD0_SER1_TXD0 */ |
| 48 | {0, 1, 1, 0, 3}, /* ENET1_TXD1_SER1_TXD1 */ |
| 49 | {0, 2, 1, 0, 1}, /* ENET1_TXD2_SER1_TXD2 */ |
| 50 | {0, 3, 1, 0, 2}, /* ENET1_TXD3_SER1_TXD3 */ |
| 51 | {0, 6, 2, 0, 3}, /* ENET1_RXD0_SER1_RXD0 */ |
| 52 | {0, 7, 2, 0, 1}, /* ENET1_RXD1_SER1_RXD1 */ |
| 53 | {0, 8, 2, 0, 2}, /* ENET1_RXD2_SER1_RXD2 */ |
| 54 | {0, 9, 2, 0, 2}, /* ENET1_RXD3_SER1_RXD3 */ |
| 55 | {0, 4, 1, 0, 2}, /* ENET1_TX_EN_SER1_RTS_B */ |
| 56 | {0, 12, 2, 0, 3}, /* ENET1_RX_DV_SER1_CTS_B */ |
| 57 | {2, 8, 2, 0, 1}, /* ENET1_GRXCLK */ |
| 58 | {2, 20, 1, 0, 2}, /* ENET1_GTXCLK */ |
| 59 | |
| 60 | /* UCC_2_RGMII */ |
| 61 | {2, 16, 2, 0, 3}, /* CLK17 */ |
| 62 | {0, 14, 1, 0, 2}, /* ENET2_TXD0_SER2_TXD0 */ |
| 63 | {0, 15, 1, 0, 2}, /* ENET2_TXD1_SER2_TXD1 */ |
| 64 | {0, 16, 1, 0, 1}, /* ENET2_TXD2_SER2_TXD2 */ |
| 65 | {0, 17, 1, 0, 1}, /* ENET2_TXD3_SER2_TXD3 */ |
| 66 | {0, 20, 2, 0, 2}, /* ENET2_RXD0_SER2_RXD0 */ |
| 67 | {0, 21, 2, 0, 1}, /* ENET2_RXD1_SER2_RXD1 */ |
| 68 | {0, 22, 2, 0, 1}, /* ENET2_RXD2_SER2_RXD2 */ |
| 69 | {0, 23, 2, 0, 1}, /* ENET2_RXD3_SER2_RXD3 */ |
| 70 | {0, 18, 1, 0, 2}, /* ENET2_TX_EN_SER2_RTS_B */ |
| 71 | {0, 26, 2, 0, 3}, /* ENET2_RX_DV_SER2_CTS_B */ |
| 72 | {2, 3, 2, 0, 1}, /* ENET2_GRXCLK */ |
| 73 | {2, 2, 1, 0, 2}, /* ENET2_GTXCLK */ |
| 74 | |
Haiying Wang | df1bbbd | 2009-05-20 12:30:36 -0400 | [diff] [blame] | 75 | /* UCC_3_RGMII */ |
| 76 | {2, 11, 2, 0, 1}, /* CLK12 */ |
| 77 | {0, 29, 1, 0, 2}, /* ENET3_TXD0_SER3_TXD0 */ |
| 78 | {0, 30, 1, 0, 3}, /* ENET3_TXD1_SER3_TXD1 */ |
| 79 | {0, 31, 1, 0, 2}, /* ENET3_TXD2_SER3_TXD2 */ |
| 80 | {1, 0, 1, 0, 3}, /* ENET3_TXD3_SER3_TXD3 */ |
| 81 | {1, 3, 2, 0, 3}, /* ENET3_RXD0_SER3_RXD0 */ |
| 82 | {1, 4, 2, 0, 1}, /* ENET3_RXD1_SER3_RXD1 */ |
| 83 | {1, 5, 2, 0, 2}, /* ENET3_RXD2_SER3_RXD2 */ |
| 84 | {1, 6, 2, 0, 3}, /* ENET3_RXD3_SER3_RXD3 */ |
| 85 | {1, 1, 1, 0, 1}, /* ENET3_TX_EN_SER3_RTS_B */ |
| 86 | {1, 9, 2, 0, 3}, /* ENET3_RX_DV_SER3_CTS_B */ |
| 87 | {2, 9, 2, 0, 2}, /* ENET3_GRXCLK */ |
| 88 | {2, 25, 1, 0, 2}, /* ENET3_GTXCLK */ |
| 89 | |
| 90 | /* UCC_4_RGMII */ |
| 91 | {2, 16, 2, 0, 3}, /* CLK17 */ |
| 92 | {1, 12, 1, 0, 2}, /* ENET4_TXD0_SER4_TXD0 */ |
| 93 | {1, 13, 1, 0, 2}, /* ENET4_TXD1_SER4_TXD1 */ |
| 94 | {1, 14, 1, 0, 1}, /* ENET4_TXD2_SER4_TXD2 */ |
| 95 | {1, 15, 1, 0, 2}, /* ENET4_TXD3_SER4_TXD3 */ |
| 96 | {1, 18, 2, 0, 2}, /* ENET4_RXD0_SER4_RXD0 */ |
| 97 | {1, 19, 2, 0, 1}, /* ENET4_RXD1_SER4_RXD1 */ |
| 98 | {1, 20, 2, 0, 1}, /* ENET4_RXD2_SER4_RXD2 */ |
| 99 | {1, 21, 2, 0, 2}, /* ENET4_RXD3_SER4_RXD3 */ |
| 100 | {1, 16, 1, 0, 2}, /* ENET4_TX_EN_SER4_RTS_B */ |
| 101 | {1, 24, 2, 0, 3}, /* ENET4_RX_DV_SER4_CTS_B */ |
| 102 | {2, 17, 2, 0, 2}, /* ENET4_GRXCLK */ |
| 103 | {2, 24, 1, 0, 2}, /* ENET4_GTXCLK */ |
| 104 | |
Haiying Wang | bc759ee | 2009-05-20 12:30:37 -0400 | [diff] [blame] | 105 | #elif defined(CONFIG_SYS_UCC_RMII_MODE) |
| 106 | /* UCC_1_RMII */ |
| 107 | {2, 15, 2, 0, 1}, /* CLK16 */ |
| 108 | {0, 0, 1, 0, 3}, /* ENET1_TXD0_SER1_TXD0 */ |
| 109 | {0, 1, 1, 0, 3}, /* ENET1_TXD1_SER1_TXD1 */ |
| 110 | {0, 6, 2, 0, 3}, /* ENET1_RXD0_SER1_RXD0 */ |
| 111 | {0, 7, 2, 0, 1}, /* ENET1_RXD1_SER1_RXD1 */ |
| 112 | {0, 4, 1, 0, 2}, /* ENET1_TX_EN_SER1_RTS_B */ |
| 113 | {0, 12, 2, 0, 3}, /* ENET1_RX_DV_SER1_CTS_B */ |
| 114 | |
| 115 | /* UCC_2_RMII */ |
| 116 | {2, 15, 2, 0, 1}, /* CLK16 */ |
| 117 | {0, 14, 1, 0, 2}, /* ENET2_TXD0_SER2_TXD0 */ |
| 118 | {0, 15, 1, 0, 2}, /* ENET2_TXD1_SER2_TXD1 */ |
| 119 | {0, 20, 2, 0, 2}, /* ENET2_RXD0_SER2_RXD0 */ |
| 120 | {0, 21, 2, 0, 1}, /* ENET2_RXD1_SER2_RXD1 */ |
| 121 | {0, 18, 1, 0, 2}, /* ENET2_TX_EN_SER2_RTS_B */ |
| 122 | {0, 26, 2, 0, 3}, /* ENET2_RX_DV_SER2_CTS_B */ |
| 123 | |
| 124 | /* UCC_3_RMII */ |
| 125 | {2, 15, 2, 0, 1}, /* CLK16 */ |
| 126 | {0, 29, 1, 0, 2}, /* ENET3_TXD0_SER3_TXD0 */ |
| 127 | {0, 30, 1, 0, 3}, /* ENET3_TXD1_SER3_TXD1 */ |
| 128 | {1, 3, 2, 0, 3}, /* ENET3_RXD0_SER3_RXD0 */ |
| 129 | {1, 4, 2, 0, 1}, /* ENET3_RXD1_SER3_RXD1 */ |
| 130 | {1, 1, 1, 0, 1}, /* ENET3_TX_EN_SER3_RTS_B */ |
| 131 | {1, 9, 2, 0, 3}, /* ENET3_RX_DV_SER3_CTS_B */ |
| 132 | |
| 133 | /* UCC_4_RMII */ |
| 134 | {2, 15, 2, 0, 1}, /* CLK16 */ |
| 135 | {1, 12, 1, 0, 2}, /* ENET4_TXD0_SER4_TXD0 */ |
| 136 | {1, 13, 1, 0, 2}, /* ENET4_TXD1_SER4_TXD1 */ |
| 137 | {1, 18, 2, 0, 2}, /* ENET4_RXD0_SER4_RXD0 */ |
| 138 | {1, 19, 2, 0, 1}, /* ENET4_RXD1_SER4_RXD1 */ |
| 139 | {1, 16, 1, 0, 2}, /* ENET4_TX_EN_SER4_RTS_B */ |
| 140 | {1, 24, 2, 0, 3}, /* ENET4_RX_DV_SER4_CTS_B */ |
| 141 | #endif |
| 142 | |
Haiying Wang | 32250bf | 2009-05-20 12:30:33 -0400 | [diff] [blame] | 143 | /* UART1 is muxed with QE PortF bit [9-12].*/ |
| 144 | {5, 12, 2, 0, 3}, /* UART1_SIN */ |
| 145 | {5, 9, 1, 0, 3}, /* UART1_SOUT */ |
| 146 | {5, 10, 2, 0, 3}, /* UART1_CTS_B */ |
| 147 | {5, 11, 1, 0, 2}, /* UART1_RTS_B */ |
| 148 | |
Anton Vorontsov | 0a154a0 | 2009-10-15 17:47:13 +0400 | [diff] [blame] | 149 | /* QE UART */ |
| 150 | {0, 19, 1, 0, 2}, /* QEUART_TX */ |
| 151 | {1, 17, 2, 0, 3}, /* QEUART_RX */ |
| 152 | {0, 25, 1, 0, 1}, /* QEUART_RTS */ |
| 153 | {1, 23, 2, 0, 1}, /* QEUART_CTS */ |
| 154 | |
Anton Vorontsov | d8e7582 | 2009-10-15 17:47:16 +0400 | [diff] [blame] | 155 | /* QE USB */ |
| 156 | {5, 3, 1, 0, 1}, /* USB_OE */ |
| 157 | {5, 4, 1, 0, 2}, /* USB_TP */ |
| 158 | {5, 5, 1, 0, 2}, /* USB_TN */ |
| 159 | {5, 6, 2, 0, 2}, /* USB_RP */ |
| 160 | {5, 7, 2, 0, 1}, /* USB_RX */ |
| 161 | {5, 8, 2, 0, 1}, /* USB_RN */ |
| 162 | {2, 4, 2, 0, 2}, /* CLK5 */ |
| 163 | |
Anton Vorontsov | b1f075e | 2009-10-15 17:47:11 +0400 | [diff] [blame] | 164 | /* SPI Flash, M25P40 */ |
| 165 | {4, 27, 3, 0, 1}, /* SPI_MOSI */ |
| 166 | {4, 28, 3, 0, 1}, /* SPI_MISO */ |
| 167 | {4, 29, 3, 0, 1}, /* SPI_CLK */ |
| 168 | {4, 30, 1, 0, 0}, /* SPI_SEL, GPIO */ |
| 169 | |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 170 | {0, 0, 0, 0, QE_IOP_TAB_END} /* END of table */ |
| 171 | }; |
| 172 | |
| 173 | void local_bus_init(void); |
| 174 | |
| 175 | int board_early_init_f (void) |
| 176 | { |
| 177 | /* |
| 178 | * Initialize local bus. |
| 179 | */ |
| 180 | local_bus_init (); |
| 181 | |
| 182 | enable_8569mds_flash_write(); |
| 183 | |
| 184 | #ifdef CONFIG_QE |
Haiying Wang | bc759ee | 2009-05-20 12:30:37 -0400 | [diff] [blame] | 185 | enable_8569mds_qe_uec(); |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 186 | #endif |
| 187 | |
| 188 | #if CONFIG_SYS_I2C2_OFFSET |
| 189 | /* Enable I2C2 signals instead of SD signals */ |
| 190 | volatile struct ccsr_gur *gur; |
| 191 | gur = (struct ccsr_gur *)(CONFIG_SYS_IMMR + 0xe0000); |
| 192 | gur->plppar1 &= ~PLPPAR1_I2C_BIT_MASK; |
| 193 | gur->plppar1 |= PLPPAR1_I2C2_VAL; |
| 194 | gur->plpdir1 &= ~PLPDIR1_I2C_BIT_MASK; |
| 195 | gur->plpdir1 |= PLPDIR1_I2C2_VAL; |
| 196 | |
| 197 | disable_8569mds_brd_eeprom_write_protect(); |
| 198 | #endif |
| 199 | |
| 200 | return 0; |
| 201 | } |
| 202 | |
Haiying Wang | fac2385 | 2010-09-29 13:31:35 -0400 | [diff] [blame] | 203 | int board_early_init_r(void) |
| 204 | { |
| 205 | const unsigned int flashbase = CONFIG_SYS_NAND_BASE; |
| 206 | const u8 flash_esel = 0; |
| 207 | |
| 208 | /* |
| 209 | * Remap Boot flash to caching-inhibited |
| 210 | * so that flash can be erased properly. |
| 211 | */ |
| 212 | |
| 213 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 214 | flush_dcache(); |
| 215 | invalidate_icache(); |
| 216 | |
| 217 | /* invalidate existing TLB entry for flash */ |
| 218 | disable_tlb(flash_esel); |
| 219 | |
| 220 | set_tlb(1, flashbase, CONFIG_SYS_NAND_BASE, /* tlb, epn, rpn */ |
| 221 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */ |
| 222 | 0, flash_esel, /* ts, esel */ |
| 223 | BOOKE_PAGESZ_64M, 1); /* tsize, iprot */ |
| 224 | |
| 225 | return 0; |
| 226 | } |
| 227 | |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 228 | int checkboard (void) |
| 229 | { |
| 230 | printf ("Board: 8569 MDS\n"); |
| 231 | |
| 232 | return 0; |
| 233 | } |
| 234 | |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 235 | #if !defined(CONFIG_SPD_EEPROM) |
| 236 | phys_size_t fixed_sdram(void) |
| 237 | { |
York Sun | a21803d | 2013-11-18 10:29:32 -0800 | [diff] [blame] | 238 | struct ccsr_ddr __iomem *ddr = |
| 239 | (struct ccsr_ddr __iomem *)CONFIG_SYS_FSL_DDR_ADDR; |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 240 | uint d_init; |
| 241 | |
| 242 | out_be32(&ddr->cs0_bnds, CONFIG_SYS_DDR_CS0_BNDS); |
| 243 | out_be32(&ddr->cs0_config, CONFIG_SYS_DDR_CS0_CONFIG); |
| 244 | out_be32(&ddr->timing_cfg_3, CONFIG_SYS_DDR_TIMING_3); |
| 245 | out_be32(&ddr->timing_cfg_0, CONFIG_SYS_DDR_TIMING_0); |
| 246 | out_be32(&ddr->timing_cfg_1, CONFIG_SYS_DDR_TIMING_1); |
| 247 | out_be32(&ddr->timing_cfg_2, CONFIG_SYS_DDR_TIMING_2); |
| 248 | out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_SDRAM_CFG); |
| 249 | out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_SDRAM_CFG_2); |
| 250 | out_be32(&ddr->sdram_mode, CONFIG_SYS_DDR_SDRAM_MODE); |
| 251 | out_be32(&ddr->sdram_mode_2, CONFIG_SYS_DDR_SDRAM_MODE_2); |
| 252 | out_be32(&ddr->sdram_interval, CONFIG_SYS_DDR_SDRAM_INTERVAL); |
| 253 | out_be32(&ddr->sdram_data_init, CONFIG_SYS_DDR_DATA_INIT); |
| 254 | out_be32(&ddr->sdram_clk_cntl, CONFIG_SYS_DDR_SDRAM_CLK_CNTL); |
| 255 | out_be32(&ddr->timing_cfg_4, CONFIG_SYS_DDR_TIMING_4); |
| 256 | out_be32(&ddr->timing_cfg_5, CONFIG_SYS_DDR_TIMING_5); |
| 257 | out_be32(&ddr->ddr_zq_cntl, CONFIG_SYS_DDR_ZQ_CNTL); |
| 258 | out_be32(&ddr->ddr_wrlvl_cntl, CONFIG_SYS_DDR_WRLVL_CNTL); |
| 259 | out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_SDRAM_CFG_2); |
| 260 | #if defined (CONFIG_DDR_ECC) |
| 261 | out_be32(&ddr->err_int_en, CONFIG_SYS_DDR_ERR_INT_EN); |
| 262 | out_be32(&ddr->err_disable, CONFIG_SYS_DDR_ERR_DIS); |
| 263 | out_be32(&ddr->err_sbe, CONFIG_SYS_DDR_SBE); |
| 264 | #endif |
| 265 | udelay(500); |
| 266 | |
| 267 | out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL); |
| 268 | #if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
| 269 | d_init = 1; |
| 270 | debug("DDR - 1st controller: memory initializing\n"); |
| 271 | /* |
| 272 | * Poll until memory is initialized. |
| 273 | * 512 Meg at 400 might hit this 200 times or so. |
| 274 | */ |
| 275 | while ((ddr->sdram_cfg_2 & (d_init << 4)) != 0) { |
| 276 | udelay(1000); |
| 277 | } |
| 278 | debug("DDR: memory initialized\n\n"); |
| 279 | udelay(500); |
| 280 | #endif |
| 281 | return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024; |
| 282 | } |
| 283 | #endif |
| 284 | |
| 285 | /* |
| 286 | * Initialize Local Bus |
| 287 | */ |
| 288 | void |
| 289 | local_bus_init(void) |
| 290 | { |
| 291 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 292 | volatile fsl_lbc_t *lbc = LBC_BASE_ADDR; |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 293 | |
| 294 | uint clkdiv; |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 295 | sys_info_t sysinfo; |
| 296 | |
| 297 | get_sys_info(&sysinfo); |
| 298 | clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2; |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 299 | |
| 300 | out_be32(&gur->lbiuiplldcr1, 0x00078080); |
| 301 | if (clkdiv == 16) |
| 302 | out_be32(&gur->lbiuiplldcr0, 0x7c0f1bf0); |
| 303 | else if (clkdiv == 8) |
| 304 | out_be32(&gur->lbiuiplldcr0, 0x6c0f1bf0); |
| 305 | else if (clkdiv == 4) |
| 306 | out_be32(&gur->lbiuiplldcr0, 0x5c0f1bf0); |
| 307 | |
| 308 | out_be32(&lbc->lcrr, (u32)in_be32(&lbc->lcrr)| 0x00030000); |
| 309 | } |
| 310 | |
Anton Vorontsov | 0a154a0 | 2009-10-15 17:47:13 +0400 | [diff] [blame] | 311 | static void fdt_board_disable_serial(void *blob, bd_t *bd, const char *alias) |
| 312 | { |
| 313 | const char *status = "disabled"; |
| 314 | int off; |
| 315 | int err; |
| 316 | |
| 317 | off = fdt_path_offset(blob, alias); |
| 318 | if (off < 0) { |
| 319 | printf("WARNING: could not find %s alias: %s.\n", alias, |
| 320 | fdt_strerror(off)); |
| 321 | return; |
| 322 | } |
| 323 | |
| 324 | err = fdt_setprop(blob, off, "status", status, strlen(status) + 1); |
| 325 | if (err) { |
| 326 | printf("WARNING: could not set status for serial0: %s.\n", |
| 327 | fdt_strerror(err)); |
| 328 | return; |
| 329 | } |
| 330 | } |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 331 | |
| 332 | /* |
| 333 | * Because of an erratum in prototype boards it is impossible to use eSDHC |
| 334 | * without disabling UART0 (which makes it quite easy to 'brick' the board |
| 335 | * by simply issung 'setenv hwconfig esdhc', and not able to interact with |
| 336 | * U-Boot anylonger). |
| 337 | * |
| 338 | * So, but default we assume that the board is a prototype, which is a most |
| 339 | * safe assumption. There is no way to determine board revision from a |
| 340 | * register, so we use hwconfig. |
| 341 | */ |
| 342 | |
| 343 | static int prototype_board(void) |
| 344 | { |
| 345 | if (hwconfig_subarg("board", "rev", NULL)) |
| 346 | return hwconfig_subarg_cmp("board", "rev", "prototype"); |
| 347 | return 1; |
| 348 | } |
| 349 | |
| 350 | static int esdhc_disables_uart0(void) |
| 351 | { |
| 352 | return prototype_board() || |
| 353 | hwconfig_subarg_cmp("esdhc", "mode", "4-bits"); |
| 354 | } |
| 355 | |
Anton Vorontsov | 0a154a0 | 2009-10-15 17:47:13 +0400 | [diff] [blame] | 356 | static void fdt_board_fixup_qe_uart(void *blob, bd_t *bd) |
| 357 | { |
| 358 | u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE; |
| 359 | const char *devtype = "serial"; |
| 360 | const char *compat = "ucc_uart"; |
| 361 | const char *clk = "brg9"; |
| 362 | u32 portnum = 0; |
| 363 | int off = -1; |
| 364 | |
| 365 | if (!hwconfig("qe_uart")) |
| 366 | return; |
| 367 | |
| 368 | if (hwconfig("esdhc") && esdhc_disables_uart0()) { |
| 369 | printf("QE UART: won't enable with esdhc.\n"); |
| 370 | return; |
| 371 | } |
| 372 | |
| 373 | fdt_board_disable_serial(blob, bd, "serial1"); |
| 374 | |
| 375 | while (1) { |
| 376 | const u32 *idx; |
| 377 | int len; |
| 378 | |
| 379 | off = fdt_node_offset_by_compatible(blob, off, "ucc_geth"); |
| 380 | if (off < 0) { |
| 381 | printf("WARNING: unable to fixup device tree for " |
| 382 | "QE UART\n"); |
| 383 | return; |
| 384 | } |
| 385 | |
| 386 | idx = fdt_getprop(blob, off, "cell-index", &len); |
| 387 | if (!idx || len != sizeof(*idx) || *idx != fdt32_to_cpu(2)) |
| 388 | continue; |
| 389 | break; |
| 390 | } |
| 391 | |
| 392 | fdt_setprop(blob, off, "device_type", devtype, strlen(devtype) + 1); |
| 393 | fdt_setprop(blob, off, "compatible", compat, strlen(compat) + 1); |
| 394 | fdt_setprop(blob, off, "tx-clock-name", clk, strlen(clk) + 1); |
| 395 | fdt_setprop(blob, off, "rx-clock-name", clk, strlen(clk) + 1); |
| 396 | fdt_setprop(blob, off, "port-number", &portnum, sizeof(portnum)); |
| 397 | |
| 398 | setbits_8(&bcsr[15], BCSR15_QEUART_EN); |
| 399 | } |
| 400 | |
| 401 | #ifdef CONFIG_FSL_ESDHC |
| 402 | |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 403 | int board_mmc_init(bd_t *bd) |
| 404 | { |
| 405 | struct ccsr_gur *gur = (struct ccsr_gur *)CONFIG_SYS_MPC85xx_GUTS_ADDR; |
| 406 | u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE; |
| 407 | u8 bcsr6 = BCSR6_SD_CARD_1BIT; |
| 408 | |
| 409 | if (!hwconfig("esdhc")) |
| 410 | return 0; |
| 411 | |
| 412 | printf("Enabling eSDHC...\n" |
| 413 | " For eSDHC to function, I2C2 "); |
| 414 | if (esdhc_disables_uart0()) { |
| 415 | printf("and UART0 should be disabled.\n"); |
| 416 | printf(" Redirecting stderr, stdout and stdin to UART1...\n"); |
| 417 | console_assign(stderr, "eserial1"); |
| 418 | console_assign(stdout, "eserial1"); |
| 419 | console_assign(stdin, "eserial1"); |
| 420 | printf("Switched to UART1 (initial log has been printed to " |
| 421 | "UART0).\n"); |
Anton Vorontsov | 0524117 | 2009-12-16 01:14:31 +0300 | [diff] [blame] | 422 | |
| 423 | clrsetbits_be32(&gur->plppar1, PLPPAR1_UART0_BIT_MASK, |
| 424 | PLPPAR1_ESDHC_4BITS_VAL); |
| 425 | clrsetbits_be32(&gur->plpdir1, PLPDIR1_UART0_BIT_MASK, |
| 426 | PLPDIR1_ESDHC_4BITS_VAL); |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 427 | bcsr6 |= BCSR6_SD_CARD_4BITS; |
| 428 | } else { |
| 429 | printf("should be disabled.\n"); |
| 430 | } |
| 431 | |
| 432 | /* Assign I2C2 signals to eSDHC. */ |
| 433 | clrsetbits_be32(&gur->plppar1, PLPPAR1_I2C_BIT_MASK, |
| 434 | PLPPAR1_ESDHC_VAL); |
| 435 | clrsetbits_be32(&gur->plpdir1, PLPDIR1_I2C_BIT_MASK, |
| 436 | PLPDIR1_ESDHC_VAL); |
| 437 | |
| 438 | /* Mux I2C2 (and optionally UART0) signals to eSDHC. */ |
| 439 | setbits_8(&bcsr[6], bcsr6); |
| 440 | |
| 441 | return fsl_esdhc_mmc_init(bd); |
| 442 | } |
| 443 | |
| 444 | static void fdt_board_fixup_esdhc(void *blob, bd_t *bd) |
| 445 | { |
| 446 | const char *status = "disabled"; |
Anton Vorontsov | 0a154a0 | 2009-10-15 17:47:13 +0400 | [diff] [blame] | 447 | int off = -1; |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 448 | |
| 449 | if (!hwconfig("esdhc")) |
| 450 | return; |
| 451 | |
Anton Vorontsov | 0a154a0 | 2009-10-15 17:47:13 +0400 | [diff] [blame] | 452 | if (esdhc_disables_uart0()) |
| 453 | fdt_board_disable_serial(blob, bd, "serial0"); |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 454 | |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 455 | while (1) { |
| 456 | const u32 *idx; |
| 457 | int len; |
| 458 | |
| 459 | off = fdt_node_offset_by_compatible(blob, off, "fsl-i2c"); |
| 460 | if (off < 0) |
| 461 | break; |
| 462 | |
| 463 | idx = fdt_getprop(blob, off, "cell-index", &len); |
| 464 | if (!idx || len != sizeof(*idx)) |
| 465 | continue; |
| 466 | |
| 467 | if (*idx == 1) { |
| 468 | fdt_setprop(blob, off, "status", status, |
| 469 | strlen(status) + 1); |
| 470 | break; |
| 471 | } |
Anton Vorontsov | 0524117 | 2009-12-16 01:14:31 +0300 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | if (hwconfig_subarg_cmp("esdhc", "mode", "4-bits")) { |
| 475 | off = fdt_node_offset_by_compatible(blob, -1, "fsl,esdhc"); |
| 476 | if (off < 0) { |
| 477 | printf("WARNING: could not find esdhc node\n"); |
| 478 | return; |
| 479 | } |
| 480 | fdt_delprop(blob, off, "sdhci,1-bit-only"); |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 481 | } |
| 482 | } |
| 483 | #else |
| 484 | static inline void fdt_board_fixup_esdhc(void *blob, bd_t *bd) {} |
| 485 | #endif |
| 486 | |
Anton Vorontsov | d8e7582 | 2009-10-15 17:47:16 +0400 | [diff] [blame] | 487 | static void fdt_board_fixup_qe_usb(void *blob, bd_t *bd) |
| 488 | { |
| 489 | u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE; |
| 490 | |
| 491 | if (hwconfig_subarg_cmp("qe_usb", "speed", "low")) |
| 492 | clrbits_8(&bcsr[17], BCSR17_nUSBLOWSPD); |
| 493 | else |
| 494 | setbits_8(&bcsr[17], BCSR17_nUSBLOWSPD); |
| 495 | |
| 496 | if (hwconfig_subarg_cmp("qe_usb", "mode", "peripheral")) { |
| 497 | clrbits_8(&bcsr[17], BCSR17_USBVCC); |
| 498 | clrbits_8(&bcsr[17], BCSR17_USBMODE); |
| 499 | do_fixup_by_compat(blob, "fsl,mpc8569-qe-usb", "mode", |
| 500 | "peripheral", sizeof("peripheral"), 1); |
| 501 | } else { |
| 502 | setbits_8(&bcsr[17], BCSR17_USBVCC); |
| 503 | setbits_8(&bcsr[17], BCSR17_USBMODE); |
| 504 | } |
| 505 | |
| 506 | clrbits_8(&bcsr[17], BCSR17_nUSBEN); |
| 507 | } |
| 508 | |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 509 | #ifdef CONFIG_PCI |
Kumar Gala | f9a9603 | 2009-11-04 10:26:30 -0600 | [diff] [blame] | 510 | void pci_init_board(void) |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 511 | { |
Liu Yu | c39aa4f | 2009-11-27 15:31:51 +0800 | [diff] [blame] | 512 | #if defined(CONFIG_PQ_MDS_PIB) |
| 513 | pib_init(); |
| 514 | #endif |
| 515 | |
Kumar Gala | b999ae8 | 2010-12-17 10:18:07 -0600 | [diff] [blame] | 516 | fsl_pcie_init_board(0); |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 517 | } |
| 518 | #endif /* CONFIG_PCI */ |
| 519 | |
| 520 | #if defined(CONFIG_OF_BOARD_SETUP) |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 521 | int ft_board_setup(void *blob, bd_t *bd) |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 522 | { |
Haiying Wang | bc759ee | 2009-05-20 12:30:37 -0400 | [diff] [blame] | 523 | #if defined(CONFIG_SYS_UCC_RMII_MODE) |
| 524 | int nodeoff, off, err; |
| 525 | unsigned int val; |
| 526 | const u32 *ph; |
| 527 | const u32 *index; |
| 528 | |
| 529 | /* fixup device tree for supporting rmii mode */ |
| 530 | nodeoff = -1; |
| 531 | while ((nodeoff = fdt_node_offset_by_compatible(blob, nodeoff, |
| 532 | "ucc_geth")) >= 0) { |
| 533 | err = fdt_setprop_string(blob, nodeoff, "tx-clock-name", |
| 534 | "clk16"); |
| 535 | if (err < 0) { |
| 536 | printf("WARNING: could not set tx-clock-name %s.\n", |
| 537 | fdt_strerror(err)); |
| 538 | break; |
| 539 | } |
| 540 | |
Andy Fleming | 7832a46 | 2011-04-13 00:37:12 -0500 | [diff] [blame] | 541 | err = fdt_fixup_phy_connection(blob, nodeoff, |
| 542 | PHY_INTERFACE_MODE_RMII); |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame] | 543 | |
Haiying Wang | bc759ee | 2009-05-20 12:30:37 -0400 | [diff] [blame] | 544 | if (err < 0) { |
| 545 | printf("WARNING: could not set phy-connection-type " |
| 546 | "%s.\n", fdt_strerror(err)); |
| 547 | break; |
| 548 | } |
| 549 | |
| 550 | index = fdt_getprop(blob, nodeoff, "cell-index", 0); |
| 551 | if (index == NULL) { |
| 552 | printf("WARNING: could not get cell-index of ucc\n"); |
| 553 | break; |
| 554 | } |
| 555 | |
| 556 | ph = fdt_getprop(blob, nodeoff, "phy-handle", 0); |
| 557 | if (ph == NULL) { |
| 558 | printf("WARNING: could not get phy-handle of ucc\n"); |
| 559 | break; |
| 560 | } |
| 561 | |
| 562 | off = fdt_node_offset_by_phandle(blob, *ph); |
| 563 | if (off < 0) { |
| 564 | printf("WARNING: could not get phy node %s.\n", |
| 565 | fdt_strerror(err)); |
| 566 | break; |
| 567 | } |
| 568 | |
| 569 | val = 0x7 + *index; /* RMII phy address starts from 0x8 */ |
| 570 | |
| 571 | err = fdt_setprop(blob, off, "reg", &val, sizeof(u32)); |
| 572 | if (err < 0) { |
| 573 | printf("WARNING: could not set reg for phy-handle " |
| 574 | "%s.\n", fdt_strerror(err)); |
| 575 | break; |
| 576 | } |
| 577 | } |
| 578 | #endif |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 579 | ft_cpu_setup(blob, bd); |
| 580 | |
Kumar Gala | d0f27d3 | 2010-07-08 22:37:44 -0500 | [diff] [blame] | 581 | FT_FSL_PCI_SETUP; |
| 582 | |
Anton Vorontsov | da22594 | 2009-10-15 17:47:06 +0400 | [diff] [blame] | 583 | fdt_board_fixup_esdhc(blob, bd); |
Anton Vorontsov | 0a154a0 | 2009-10-15 17:47:13 +0400 | [diff] [blame] | 584 | fdt_board_fixup_qe_uart(blob, bd); |
Anton Vorontsov | d8e7582 | 2009-10-15 17:47:16 +0400 | [diff] [blame] | 585 | fdt_board_fixup_qe_usb(blob, bd); |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 586 | |
| 587 | return 0; |
Haiying Wang | bd25537 | 2009-03-27 17:02:45 -0400 | [diff] [blame] | 588 | } |
| 589 | #endif |