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