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