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