Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2013 Freescale Semiconductor, Inc. |
| 4 | * |
| 5 | * Authors: Roy Zang <tie-fei.zang@freescale.com> |
| 6 | * Chunhe Lan <Chunhe.Lan@freescale.com> |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <command.h> |
Simon Glass | 7b51b57 | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 11 | #include <env.h> |
Simon Glass | 4d72caa | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 12 | #include <image.h> |
Simon Glass | 5255932 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 13 | #include <init.h> |
Simon Glass | 90526e9 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 14 | #include <net.h> |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 15 | #include <pci.h> |
| 16 | #include <asm/io.h> |
| 17 | #include <asm/cache.h> |
| 18 | #include <asm/processor.h> |
| 19 | #include <asm/mmu.h> |
| 20 | #include <asm/immap_85xx.h> |
| 21 | #include <asm/fsl_pci.h> |
York Sun | 5614e71 | 2013-09-30 09:22:09 -0700 | [diff] [blame] | 22 | #include <fsl_ddr_sdram.h> |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 23 | #include <asm/fsl_portals.h> |
Ahmed Mansour | 4426232 | 2017-12-15 16:01:00 -0500 | [diff] [blame] | 24 | #include <fsl_qbman.h> |
Masahiro Yamada | b08c8c4 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 25 | #include <linux/libfdt.h> |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 26 | #include <fdt_support.h> |
| 27 | #include <netdev.h> |
| 28 | #include <malloc.h> |
| 29 | #include <fm_eth.h> |
| 30 | #include <fsl_mdio.h> |
| 31 | #include <miiphy.h> |
| 32 | #include <phy.h> |
Shaohui Xie | 8225b2f | 2015-10-26 19:47:47 +0800 | [diff] [blame] | 33 | #include <fsl_dtsec.h> |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 34 | |
| 35 | DECLARE_GLOBAL_DATA_PTR; |
| 36 | |
| 37 | int board_early_init_f(void) |
| 38 | { |
| 39 | fsl_lbc_t *lbc = LBC_BASE_ADDR; |
| 40 | |
| 41 | /* Set ABSWP to implement conversion of addresses in the LBC */ |
| 42 | setbits_be32(&lbc->lbcr, CONFIG_SYS_LBC_LBCR); |
| 43 | |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | int checkboard(void) |
| 48 | { |
| 49 | printf("Board: P1023 RDB\n"); |
| 50 | |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | #ifdef CONFIG_PCI |
| 55 | void pci_init_board(void) |
| 56 | { |
| 57 | fsl_pcie_init_board(0); |
| 58 | } |
| 59 | #endif |
| 60 | |
| 61 | int board_early_init_r(void) |
| 62 | { |
| 63 | const unsigned int flashbase = CONFIG_SYS_FLASH_BASE; |
York Sun | 9d04568 | 2014-06-24 21:16:20 -0700 | [diff] [blame] | 64 | int flash_esel = find_tlb_idx((void *)flashbase, 1); |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 65 | |
| 66 | /* |
| 67 | * Remap Boot flash + PROMJET region to caching-inhibited |
| 68 | * so that flash can be erased properly. |
| 69 | */ |
| 70 | |
| 71 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 72 | flush_dcache(); |
| 73 | invalidate_icache(); |
| 74 | |
York Sun | 9d04568 | 2014-06-24 21:16:20 -0700 | [diff] [blame] | 75 | if (flash_esel == -1) { |
| 76 | /* very unlikely unless something is messed up */ |
| 77 | puts("Error: Could not find TLB for FLASH BASE\n"); |
| 78 | flash_esel = 2; /* give our best effort to continue */ |
| 79 | } else { |
| 80 | /* invalidate existing TLB entry for flash + promjet */ |
| 81 | disable_tlb(flash_esel); |
| 82 | } |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 83 | |
| 84 | set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, |
| 85 | MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 86 | 0, flash_esel, BOOKE_PAGESZ_256M, 1); |
| 87 | |
Ahmed Mansour | 4426232 | 2017-12-15 16:01:00 -0500 | [diff] [blame] | 88 | setup_qbman_portals(); |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | unsigned long get_board_sys_clk(ulong dummy) |
| 94 | { |
| 95 | return gd->bus_clk; |
| 96 | } |
| 97 | |
| 98 | unsigned long get_board_ddr_clk(ulong dummy) |
| 99 | { |
| 100 | return gd->mem_clk; |
| 101 | } |
| 102 | |
Masahiro Yamada | b75d8dc | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 103 | int board_eth_init(struct bd_info *bis) |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 104 | { |
| 105 | ccsr_gur_t *gur = (ccsr_gur_t *)CONFIG_SYS_MPC85xx_GUTS_ADDR; |
| 106 | struct fsl_pq_mdio_info dtsec_mdio_info; |
| 107 | |
| 108 | /* |
| 109 | * Need to set dTSEC 1 pin multiplexing to TSEC. The default setting |
| 110 | * is not correct. |
| 111 | */ |
| 112 | setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_TSEC1_1); |
| 113 | |
| 114 | dtsec_mdio_info.regs = |
| 115 | (struct tsec_mii_mng *)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR; |
| 116 | dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME; |
| 117 | |
| 118 | /* Register the 1G MDIO bus */ |
| 119 | fsl_pq_mdio_init(bis, &dtsec_mdio_info); |
| 120 | |
| 121 | fm_info_set_phy_address(FM1_DTSEC1, CONFIG_SYS_FM1_DTSEC1_PHY_ADDR); |
| 122 | fm_info_set_phy_address(FM1_DTSEC2, CONFIG_SYS_FM1_DTSEC2_PHY_ADDR); |
| 123 | |
| 124 | fm_info_set_mdio(FM1_DTSEC1, |
| 125 | miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME)); |
| 126 | fm_info_set_mdio(FM1_DTSEC2, |
| 127 | miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME)); |
| 128 | |
| 129 | #ifdef CONFIG_FMAN_ENET |
| 130 | cpu_eth_init(bis); |
| 131 | #endif |
| 132 | |
| 133 | return pci_eth_init(bis); |
| 134 | } |
| 135 | |
| 136 | #if defined(CONFIG_OF_BOARD_SETUP) |
Masahiro Yamada | b75d8dc | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 137 | int ft_board_setup(void *blob, struct bd_info *bd) |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 138 | { |
| 139 | phys_addr_t base; |
| 140 | phys_size_t size; |
| 141 | |
| 142 | ft_cpu_setup(blob, bd); |
| 143 | |
Simon Glass | 723806c | 2017-08-03 12:22:15 -0600 | [diff] [blame] | 144 | base = env_get_bootm_low(); |
| 145 | size = env_get_bootm_size(); |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 146 | |
| 147 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 148 | |
| 149 | #ifdef CONFIG_HAS_FSL_DR_USB |
Sriram Dash | a5c289b | 2016-09-16 17:12:15 +0530 | [diff] [blame] | 150 | fsl_fdt_fixup_dr_usb(blob, bd); |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 151 | #endif |
| 152 | |
Madalin Bucur | 564637a | 2020-04-30 15:59:58 +0300 | [diff] [blame] | 153 | #ifdef CONFIG_SYS_DPAA_FMAN |
| 154 | #ifndef CONFIG_DM_ETH |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 155 | fdt_fixup_fman_ethernet(blob); |
Madalin Bucur | 564637a | 2020-04-30 15:59:58 +0300 | [diff] [blame] | 156 | #endif |
| 157 | #endif |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 158 | return 0; |
Chunhe Lan | 5707233 | 2013-06-14 16:21:48 +0800 | [diff] [blame] | 159 | } |
| 160 | #endif |