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