Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014 Freescale Semiconductor, Inc. |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [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> |
Simon Glass | 807765b | 2019-12-28 10:44:54 -0700 | [diff] [blame] | 9 | #include <fdt_support.h> |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 10 | #include <i2c.h> |
Simon Glass | 4d72caa | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 11 | #include <image.h> |
Simon Glass | 5255932 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 12 | #include <init.h> |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 13 | #include <netdev.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <asm/global_data.h> |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 15 | #include <linux/compiler.h> |
| 16 | #include <asm/mmu.h> |
| 17 | #include <asm/processor.h> |
| 18 | #include <asm/cache.h> |
| 19 | #include <asm/immap_85xx.h> |
| 20 | #include <asm/fsl_law.h> |
| 21 | #include <asm/fsl_serdes.h> |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 22 | #include <asm/fsl_liodn.h> |
| 23 | #include <fm_eth.h> |
| 24 | |
| 25 | #include "t4rdb.h" |
Chunhe Lan | ab06b23 | 2014-09-12 14:47:09 +0800 | [diff] [blame] | 26 | #include "cpld.h" |
Ying Zhang | 2f66a82 | 2016-01-22 12:15:13 +0800 | [diff] [blame] | 27 | #include "../common/vid.h" |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 28 | |
| 29 | DECLARE_GLOBAL_DATA_PTR; |
| 30 | |
| 31 | int checkboard(void) |
| 32 | { |
| 33 | struct cpu_type *cpu = gd->arch.cpu; |
Chunhe Lan | ab06b23 | 2014-09-12 14:47:09 +0800 | [diff] [blame] | 34 | u8 sw; |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 35 | |
| 36 | printf("Board: %sRDB, ", cpu->name); |
Chunhe Lan | ab06b23 | 2014-09-12 14:47:09 +0800 | [diff] [blame] | 37 | printf("Board rev: 0x%02x CPLD ver: 0x%02x%02x, ", |
| 38 | CPLD_READ(hw_ver), CPLD_READ(sw_maj_ver), CPLD_READ(sw_min_ver)); |
| 39 | |
| 40 | sw = CPLD_READ(vbank); |
| 41 | sw = sw & CPLD_BANK_SEL_MASK; |
| 42 | |
| 43 | if (sw <= 7) |
| 44 | printf("vBank: %d\n", sw); |
| 45 | else |
| 46 | printf("Unsupported Bank=%x\n", sw); |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 47 | |
| 48 | puts("SERDES Reference Clocks:\n"); |
| 49 | printf(" SERDES1=100MHz SERDES2=156.25MHz\n" |
| 50 | " SERDES3=100MHz SERDES4=100MHz\n"); |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | int board_early_init_r(void) |
| 56 | { |
| 57 | const unsigned int flashbase = CONFIG_SYS_FLASH_BASE; |
York Sun | 9d04568 | 2014-06-24 21:16:20 -0700 | [diff] [blame] | 58 | int flash_esel = find_tlb_idx((void *)flashbase, 1); |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 59 | |
| 60 | /* |
| 61 | * Remap Boot flash + PROMJET region to caching-inhibited |
| 62 | * so that flash can be erased properly. |
| 63 | */ |
| 64 | |
| 65 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 66 | flush_dcache(); |
| 67 | invalidate_icache(); |
| 68 | |
York Sun | 9d04568 | 2014-06-24 21:16:20 -0700 | [diff] [blame] | 69 | if (flash_esel == -1) { |
| 70 | /* very unlikely unless something is messed up */ |
| 71 | puts("Error: Could not find TLB for FLASH BASE\n"); |
| 72 | flash_esel = 2; /* give our best effort to continue */ |
| 73 | } else { |
| 74 | /* invalidate existing TLB entry for flash + promjet */ |
| 75 | disable_tlb(flash_esel); |
| 76 | } |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 77 | |
| 78 | set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, |
| 79 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 80 | 0, flash_esel, BOOKE_PAGESZ_256M, 1); |
| 81 | |
Ying Zhang | 2f66a82 | 2016-01-22 12:15:13 +0800 | [diff] [blame] | 82 | /* |
| 83 | * Adjust core voltage according to voltage ID |
| 84 | * This function changes I2C mux to channel 2. |
| 85 | */ |
| 86 | if (adjust_vdd(0)) |
| 87 | printf("Warning: Adjusting core voltage failed.\n"); |
| 88 | |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | int misc_init_r(void) |
| 93 | { |
| 94 | return 0; |
| 95 | } |
| 96 | |
Masahiro Yamada | b75d8dc | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 97 | int ft_board_setup(void *blob, struct bd_info *bd) |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 98 | { |
| 99 | phys_addr_t base; |
| 100 | phys_size_t size; |
| 101 | |
| 102 | ft_cpu_setup(blob, bd); |
| 103 | |
Simon Glass | 723806c | 2017-08-03 12:22:15 -0600 | [diff] [blame] | 104 | base = env_get_bootm_low(); |
| 105 | size = env_get_bootm_size(); |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 106 | |
| 107 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 108 | |
| 109 | #ifdef CONFIG_PCI |
| 110 | pci_of_setup(blob, bd); |
| 111 | #endif |
| 112 | |
| 113 | fdt_fixup_liodn(blob); |
Sriram Dash | a5c289b | 2016-09-16 17:12:15 +0530 | [diff] [blame] | 114 | fsl_fdt_fixup_dr_usb(blob, bd); |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 115 | |
| 116 | #ifdef CONFIG_SYS_DPAA_FMAN |
Madalin Bucur | 564637a | 2020-04-30 15:59:58 +0300 | [diff] [blame] | 117 | #ifndef CONFIG_DM_ETH |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 118 | fdt_fixup_fman_ethernet(blob); |
Madalin Bucur | 564637a | 2020-04-30 15:59:58 +0300 | [diff] [blame] | 119 | #endif |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 120 | fdt_fixup_board_enet(blob); |
| 121 | #endif |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 122 | |
| 123 | return 0; |
Chunhe Lan | 0b2e13d | 2014-04-14 18:42:06 +0800 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /* |
| 127 | * This function is called by bdinfo to print detail board information. |
| 128 | * As an exmaple for future board, we organize the messages into |
| 129 | * several sections. If applicable, the message is in the format of |
| 130 | * <name> = <value> |
| 131 | * It should aligned with normal output of bdinfo command. |
| 132 | * |
| 133 | * Voltage: Core, DDR and another configurable voltages |
| 134 | * Clock : Critical clocks which are not printed already |
| 135 | * RCW : RCW source if not printed already |
| 136 | * Misc : Other important information not in above catagories |
| 137 | */ |
| 138 | void board_detail(void) |
| 139 | { |
| 140 | int rcwsrc; |
| 141 | |
| 142 | /* RCW section SW3[4] */ |
| 143 | rcwsrc = 0x0; |
| 144 | puts("RCW source = "); |
| 145 | switch (rcwsrc & 0x1) { |
| 146 | case 0x1: |
| 147 | puts("SDHC/eMMC\n"); |
| 148 | break; |
| 149 | default: |
| 150 | puts("I2C normal addressing\n"); |
| 151 | break; |
| 152 | } |
| 153 | } |
Kuldeep Singh | 3bd5ea5 | 2021-08-10 11:20:11 +0530 | [diff] [blame^] | 154 | |
| 155 | ulong *cs4340_get_fw_addr(void) |
| 156 | { |
| 157 | ulong cortina_fw_addr = CONFIG_CORTINA_FW_ADDR; |
| 158 | |
| 159 | #ifdef CONFIG_SYS_CORTINA_FW_IN_NOR |
| 160 | u8 sw; |
| 161 | |
| 162 | sw = CPLD_READ(vbank); |
| 163 | sw = sw & CPLD_BANK_SEL_MASK; |
| 164 | |
| 165 | if (sw == 0) |
| 166 | cortina_fw_addr = CORTINA_FW_ADDR_IFCNOR; |
| 167 | else if (sw == 4) |
| 168 | cortina_fw_addr = CORTINA_FW_ADDR_IFCNOR_ALTBANK; |
| 169 | #endif |
| 170 | |
| 171 | return (ulong *)cortina_fw_addr; |
| 172 | } |