Roy Zang | 3f7f6b8 | 2011-06-09 11:30:52 +0800 | [diff] [blame] | 1 | /* |
ramneek mehresh | 3d7506f | 2012-04-18 19:39:53 +0000 | [diff] [blame] | 2 | * Copyright 2010-2012 Freescale Semiconductor, Inc. |
Roy Zang | 3f7f6b8 | 2011-06-09 11:30:52 +0800 | [diff] [blame] | 3 | * |
| 4 | * Authors: Roy Zang <tie-fei.zang@freescale.com> |
| 5 | * Chunhe Lan <b25806@freescale.com> |
| 6 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Roy Zang | 3f7f6b8 | 2011-06-09 11:30:52 +0800 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <command.h> |
| 12 | #include <pci.h> |
| 13 | #include <asm/io.h> |
| 14 | #include <asm/cache.h> |
| 15 | #include <asm/processor.h> |
| 16 | #include <asm/mmu.h> |
| 17 | #include <asm/immap_85xx.h> |
| 18 | #include <asm/fsl_pci.h> |
York Sun | 5614e71 | 2013-09-30 09:22:09 -0700 | [diff] [blame] | 19 | #include <fsl_ddr_sdram.h> |
Roy Zang | 3f7f6b8 | 2011-06-09 11:30:52 +0800 | [diff] [blame] | 20 | #include <asm/fsl_portals.h> |
| 21 | #include <libfdt.h> |
| 22 | #include <fdt_support.h> |
| 23 | #include <netdev.h> |
| 24 | #include <malloc.h> |
Roy Zang | fe1a1da | 2011-02-04 13:42:45 -0600 | [diff] [blame] | 25 | #include <fm_eth.h> |
| 26 | #include <fsl_mdio.h> |
| 27 | #include <miiphy.h> |
| 28 | #include <phy.h> |
| 29 | #include <asm/fsl_dtsec.h> |
Roy Zang | 3f7f6b8 | 2011-06-09 11:30:52 +0800 | [diff] [blame] | 30 | |
| 31 | #include "bcsr.h" |
| 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
| 35 | int board_early_init_f(void) |
| 36 | { |
| 37 | fsl_lbc_t *lbc = LBC_BASE_ADDR; |
| 38 | |
| 39 | /* Set ABSWP to implement conversion of addresses in the LBC */ |
| 40 | setbits_be32(&lbc->lbcr, CONFIG_SYS_LBC_LBCR); |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | int checkboard(void) |
| 46 | { |
| 47 | u8 *bcsr = (u8 *)BCSR_ACCESS_REG_ADDR; |
| 48 | |
| 49 | printf("Board: P1023 RDS\n"); |
| 50 | |
| 51 | clrbits_8(&bcsr[15], BCSR15_I2C_BUS0_SEG_CLR); |
| 52 | setbits_8(&bcsr[15], BCSR15_I2C_BUS0_SEG0); |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | /* Fixed sdram init -- doesn't use serial presence detect. */ |
| 58 | phys_size_t fixed_sdram(void) |
| 59 | { |
| 60 | #ifndef CONFIG_SYS_RAMBOOT |
York Sun | 9a17eb5 | 2013-11-18 10:29:32 -0800 | [diff] [blame] | 61 | struct ccsr_ddr __iomem *ddr = |
| 62 | (struct ccsr_ddr __iomem *)CONFIG_SYS_FSL_DDR_ADDR; |
Roy Zang | 3f7f6b8 | 2011-06-09 11:30:52 +0800 | [diff] [blame] | 63 | |
| 64 | set_next_law(0, LAW_SIZE_2G, LAW_TRGT_IF_DDR_1); |
| 65 | |
| 66 | out_be32(&ddr->cs0_bnds, CONFIG_SYS_DDR_CS0_BNDS); |
| 67 | out_be32(&ddr->cs0_config, CONFIG_SYS_DDR_CS0_CONFIG); |
| 68 | out_be32(&ddr->cs1_bnds, CONFIG_SYS_DDR_CS1_BNDS); |
| 69 | out_be32(&ddr->cs1_config, CONFIG_SYS_DDR_CS1_CONFIG); |
| 70 | out_be32(&ddr->timing_cfg_3, CONFIG_SYS_DDR_TIMING_3); |
| 71 | out_be32(&ddr->timing_cfg_0, CONFIG_SYS_DDR_TIMING_0); |
| 72 | out_be32(&ddr->timing_cfg_1, CONFIG_SYS_DDR_TIMING_1); |
| 73 | out_be32(&ddr->timing_cfg_2, CONFIG_SYS_DDR_TIMING_2); |
| 74 | out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_CONTROL2); |
| 75 | out_be32(&ddr->sdram_mode, CONFIG_SYS_DDR_MODE_1); |
| 76 | out_be32(&ddr->sdram_mode_2, CONFIG_SYS_DDR_MODE_2); |
| 77 | out_be32(&ddr->sdram_interval, CONFIG_SYS_DDR_INTERVAL); |
| 78 | out_be32(&ddr->sdram_data_init, CONFIG_SYS_DDR_DATA_INIT); |
| 79 | out_be32(&ddr->sdram_clk_cntl, CONFIG_SYS_DDR_CLK_CTRL); |
| 80 | out_be32(&ddr->timing_cfg_4, CONFIG_SYS_DDR_TIMING_4); |
| 81 | out_be32(&ddr->timing_cfg_5, CONFIG_SYS_DDR_TIMING_5); |
| 82 | out_be32(&ddr->ddr_zq_cntl, CONFIG_SYS_DDR_ZQ_CNTL); |
| 83 | out_be32(&ddr->ddr_wrlvl_cntl, CONFIG_SYS_DDR_WRLVL_CNTL); |
| 84 | out_be32(&ddr->ddr_cdr1, CONFIG_SYS_DDR_CDR_1); |
| 85 | out_be32(&ddr->ddr_cdr2, CONFIG_SYS_DDR_CDR_2); |
| 86 | out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL); |
| 87 | #endif |
| 88 | return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024ul; |
| 89 | } |
| 90 | |
| 91 | #ifdef CONFIG_PCI |
| 92 | void pci_init_board(void) |
| 93 | { |
| 94 | fsl_pcie_init_board(0); |
| 95 | } |
| 96 | #endif |
| 97 | |
| 98 | int board_early_init_r(void) |
| 99 | { |
| 100 | const unsigned int flashbase = CONFIG_SYS_BCSR_BASE; |
| 101 | const u8 flash_esel = find_tlb_idx((void *)flashbase, 1); |
| 102 | |
| 103 | /* |
| 104 | * Remap Boot flash + BCSR region to caching-inhibited |
| 105 | * so that flash can be erased properly. |
| 106 | */ |
| 107 | |
| 108 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 109 | flush_dcache(); |
| 110 | invalidate_icache(); |
| 111 | |
| 112 | /* invalidate existing TLB entry for flash + bcsr */ |
| 113 | disable_tlb(flash_esel); |
| 114 | |
| 115 | set_tlb(1, flashbase, CONFIG_SYS_BCSR_BASE_PHYS, |
| 116 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 117 | 0, flash_esel, BOOKE_PAGESZ_256M, 1); |
| 118 | |
| 119 | setup_portals(); |
| 120 | |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | unsigned long get_board_sys_clk(ulong dummy) |
| 125 | { |
| 126 | return gd->bus_clk; |
| 127 | } |
| 128 | |
| 129 | unsigned long get_board_ddr_clk(ulong dummy) |
| 130 | { |
| 131 | return gd->mem_clk; |
| 132 | } |
| 133 | |
| 134 | int board_eth_init(bd_t *bis) |
| 135 | { |
Roy Zang | fe1a1da | 2011-02-04 13:42:45 -0600 | [diff] [blame] | 136 | u8 *bcsr = (u8 *)BCSR_ACCESS_REG_ADDR; |
| 137 | ccsr_gur_t *gur = (ccsr_gur_t *)CONFIG_SYS_MPC85xx_GUTS_ADDR; |
| 138 | struct fsl_pq_mdio_info dtsec_mdio_info; |
| 139 | |
| 140 | /* |
| 141 | * Need to set dTSEC 1 pin multiplexing to TSEC. The default setting |
| 142 | * is not correct. |
| 143 | */ |
| 144 | setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_TSEC1_1); |
| 145 | |
| 146 | dtsec_mdio_info.regs = |
| 147 | (struct tsec_mii_mng *)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR; |
| 148 | dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME; |
| 149 | |
| 150 | /* Register the 1G MDIO bus */ |
| 151 | fsl_pq_mdio_init(bis, &dtsec_mdio_info); |
| 152 | |
| 153 | fm_info_set_phy_address(FM1_DTSEC1, CONFIG_SYS_FM1_DTSEC1_PHY_ADDR); |
| 154 | fm_info_set_phy_address(FM1_DTSEC2, CONFIG_SYS_FM1_DTSEC2_PHY_ADDR); |
| 155 | |
| 156 | fm_info_set_mdio(FM1_DTSEC1, |
| 157 | miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME)); |
| 158 | fm_info_set_mdio(FM1_DTSEC2, |
| 159 | miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME)); |
| 160 | |
| 161 | /* Make SERDES connected to SGMII by cleaing bcsr19[7] */ |
| 162 | if (fm_info_get_enet_if(FM1_DTSEC1) == PHY_INTERFACE_MODE_SGMII) |
| 163 | clrbits_8(&bcsr[19], BCSR19_SGMII_SEL_L); |
| 164 | |
| 165 | #ifdef CONFIG_FMAN_ENET |
| 166 | cpu_eth_init(bis); |
| 167 | #endif |
| 168 | |
Roy Zang | 3f7f6b8 | 2011-06-09 11:30:52 +0800 | [diff] [blame] | 169 | return pci_eth_init(bis); |
| 170 | } |
| 171 | |
| 172 | #if defined(CONFIG_OF_BOARD_SETUP) |
| 173 | void ft_board_setup(void *blob, bd_t *bd) |
| 174 | { |
| 175 | phys_addr_t base; |
| 176 | phys_size_t size; |
| 177 | |
| 178 | ft_cpu_setup(blob, bd); |
| 179 | |
| 180 | base = getenv_bootm_low(); |
| 181 | size = getenv_bootm_size(); |
| 182 | |
| 183 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
Roy Zang | fe1a1da | 2011-02-04 13:42:45 -0600 | [diff] [blame] | 184 | |
Chunhe Lan | 617e46e | 2012-04-18 15:58:56 -0500 | [diff] [blame] | 185 | /* By default NOR is on, and NAND is disabled */ |
| 186 | #ifdef CONFIG_NAND_U_BOOT |
| 187 | do_fixup_by_path_string(blob, "nor_flash", "status", "disabled"); |
| 188 | do_fixup_by_path_string(blob, "nand_flash", "status", "okay"); |
| 189 | #endif |
ramneek mehresh | 3d7506f | 2012-04-18 19:39:53 +0000 | [diff] [blame] | 190 | #ifdef CONFIG_HAS_FSL_DR_USB |
| 191 | fdt_fixup_dr_usb(blob, bd); |
| 192 | #endif |
Chunhe Lan | 617e46e | 2012-04-18 15:58:56 -0500 | [diff] [blame] | 193 | |
Roy Zang | fe1a1da | 2011-02-04 13:42:45 -0600 | [diff] [blame] | 194 | fdt_fixup_fman_ethernet(blob); |
Roy Zang | 3f7f6b8 | 2011-06-09 11:30:52 +0800 | [diff] [blame] | 195 | } |
| 196 | #endif |