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