Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2013 Freescale Semiconductor, Inc. |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <command.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 8 | #include <env.h> |
Simon Glass | 3bbe70c | 2019-12-28 10:44:54 -0700 | [diff] [blame] | 9 | #include <fdt_support.h> |
Zhao Qiang | 81136a1 | 2015-08-28 10:31:50 +0800 | [diff] [blame] | 10 | #include <hwconfig.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 11 | #include <image.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> |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 14 | #include <netdev.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 15 | #include <asm/global_data.h> |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 16 | #include <linux/compiler.h> |
| 17 | #include <asm/mmu.h> |
| 18 | #include <asm/processor.h> |
| 19 | #include <asm/cache.h> |
| 20 | #include <asm/immap_85xx.h> |
Zhao Qiang | 81136a1 | 2015-08-28 10:31:50 +0800 | [diff] [blame] | 21 | #include <asm/fsl_fdt.h> |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 22 | #include <asm/fsl_law.h> |
| 23 | #include <asm/fsl_serdes.h> |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 24 | #include <asm/fsl_liodn.h> |
| 25 | #include <fm_eth.h> |
Tang Yuantian | 760eafc | 2014-11-21 11:17:16 +0800 | [diff] [blame] | 26 | #include "../common/sleep.h" |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 27 | #include "t104xrdb.h" |
Prabhakar Kushwaha | e5e6633 | 2014-04-03 16:50:05 +0530 | [diff] [blame] | 28 | #include "cpld.h" |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 29 | |
| 30 | DECLARE_GLOBAL_DATA_PTR; |
| 31 | |
| 32 | int checkboard(void) |
| 33 | { |
| 34 | struct cpu_type *cpu = gd->arch.cpu; |
Prabhakar Kushwaha | e5e6633 | 2014-04-03 16:50:05 +0530 | [diff] [blame] | 35 | u8 sw; |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 36 | |
Tom Rini | 454a852 | 2022-12-02 16:42:51 -0500 | [diff] [blame] | 37 | #if defined(CONFIG_TARGET_T1042D4RDB) |
Priyanka Jain | e7597fe | 2015-06-05 15:29:02 +0530 | [diff] [blame] | 38 | printf("Board: %sD4RDB\n", cpu->name); |
| 39 | #else |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 40 | printf("Board: %sRDB\n", cpu->name); |
Priyanka Jain | e7597fe | 2015-06-05 15:29:02 +0530 | [diff] [blame] | 41 | #endif |
Prabhakar Kushwaha | e5e6633 | 2014-04-03 16:50:05 +0530 | [diff] [blame] | 42 | printf("Board rev: 0x%02x CPLD ver: 0x%02x, ", |
| 43 | CPLD_READ(hw_ver), CPLD_READ(sw_ver)); |
| 44 | |
| 45 | sw = CPLD_READ(flash_ctl_status); |
| 46 | sw = ((sw & CPLD_LBMAP_MASK) >> CPLD_LBMAP_SHIFT); |
| 47 | |
Priyanka Jain | 86c6bfe | 2015-07-30 10:20:18 +0530 | [diff] [blame] | 48 | printf("vBank: %d\n", sw); |
Prabhakar Kushwaha | e5e6633 | 2014-04-03 16:50:05 +0530 | [diff] [blame] | 49 | |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 50 | return 0; |
| 51 | } |
| 52 | |
Tang Yuantian | 760eafc | 2014-11-21 11:17:16 +0800 | [diff] [blame] | 53 | int board_early_init_f(void) |
| 54 | { |
| 55 | #if defined(CONFIG_DEEP_SLEEP) |
| 56 | if (is_warm_boot()) |
| 57 | fsl_dp_disable_console(); |
| 58 | #endif |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 63 | int board_early_init_r(void) |
| 64 | { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 65 | #ifdef CFG_SYS_FLASH_BASE |
| 66 | const unsigned int flashbase = CFG_SYS_FLASH_BASE; |
York Sun | 220c346 | 2014-06-24 21:16:20 -0700 | [diff] [blame] | 67 | int flash_esel = find_tlb_idx((void *)flashbase, 1); |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 68 | |
| 69 | /* |
| 70 | * Remap Boot flash region to caching-inhibited |
| 71 | * so that flash can be erased properly. |
| 72 | */ |
| 73 | |
| 74 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 75 | flush_dcache(); |
| 76 | invalidate_icache(); |
| 77 | |
York Sun | 220c346 | 2014-06-24 21:16:20 -0700 | [diff] [blame] | 78 | if (flash_esel == -1) { |
| 79 | /* very unlikely unless something is messed up */ |
| 80 | puts("Error: Could not find TLB for FLASH BASE\n"); |
| 81 | flash_esel = 2; /* give our best effort to continue */ |
| 82 | } else { |
| 83 | /* invalidate existing TLB entry for flash */ |
| 84 | disable_tlb(flash_esel); |
| 85 | } |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 86 | |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 87 | set_tlb(1, flashbase, CFG_SYS_FLASH_BASE_PHYS, |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 88 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 89 | 0, flash_esel, BOOKE_PAGESZ_256M, 1); |
| 90 | #endif |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | int misc_init_r(void) |
| 95 | { |
Tom Rini | d5c3bf2 | 2022-10-28 20:27:12 -0400 | [diff] [blame] | 96 | ccsr_gur_t __iomem *gur = (void *)(CFG_SYS_MPC85xx_GUTS_ADDR); |
Priyanka Jain | e7597fe | 2015-06-05 15:29:02 +0530 | [diff] [blame] | 97 | u32 srds_s1; |
| 98 | |
| 99 | srds_s1 = in_be32(&gur->rcwsr[4]) >> 24; |
| 100 | |
| 101 | printf("SERDES Reference : 0x%X\n", srds_s1); |
| 102 | |
| 103 | /* select SGMII*/ |
| 104 | if (srds_s1 == 0x86) |
| 105 | CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) | |
| 106 | MISC_CTL_SG_SEL); |
| 107 | |
| 108 | /* select SGMII and Aurora*/ |
| 109 | if (srds_s1 == 0x8E) |
| 110 | CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) | |
| 111 | MISC_CTL_SG_SEL | MISC_CTL_AURORA_SEL); |
| 112 | |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 113 | return 0; |
| 114 | } |
| 115 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 116 | int ft_board_setup(void *blob, struct bd_info *bd) |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 117 | { |
| 118 | phys_addr_t base; |
| 119 | phys_size_t size; |
| 120 | |
| 121 | ft_cpu_setup(blob, bd); |
| 122 | |
Simon Glass | da1a134 | 2017-08-03 12:22:15 -0600 | [diff] [blame] | 123 | base = env_get_bootm_low(); |
| 124 | size = env_get_bootm_size(); |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 125 | |
| 126 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 127 | |
| 128 | #ifdef CONFIG_PCI |
| 129 | pci_of_setup(blob, bd); |
| 130 | #endif |
| 131 | |
| 132 | fdt_fixup_liodn(blob); |
| 133 | |
| 134 | #ifdef CONFIG_HAS_FSL_DR_USB |
Sriram Dash | 9fd465c | 2016-09-16 17:12:15 +0530 | [diff] [blame] | 135 | fsl_fdt_fixup_dr_usb(blob, bd); |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 136 | #endif |
| 137 | |
| 138 | #ifdef CONFIG_SYS_DPAA_FMAN |
Madalin Bucur | 7084851 | 2020-04-30 15:59:58 +0300 | [diff] [blame] | 139 | #ifndef CONFIG_DM_ETH |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 140 | fdt_fixup_fman_ethernet(blob); |
| 141 | #endif |
Madalin Bucur | 7084851 | 2020-04-30 15:59:58 +0300 | [diff] [blame] | 142 | #endif |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 143 | |
Zhao Qiang | 81136a1 | 2015-08-28 10:31:50 +0800 | [diff] [blame] | 144 | if (hwconfig("qe-tdm")) |
| 145 | fdt_del_diu(blob); |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 146 | return 0; |
Priyanka Jain | 8b1a60e | 2013-10-18 17:19:06 +0530 | [diff] [blame] | 147 | } |