Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
Xiaowei Bao | 3a13e29 | 2020-01-08 14:29:54 +0800 | [diff] [blame] | 3 | * Copyright 2018-2020 NXP |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 85d6531 | 2019-12-28 10:44:58 -0700 | [diff] [blame] | 7 | #include <clock_legacy.h> |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 8 | #include <dm.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | #include <asm/global_data.h> |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 11 | #include <dm/platform_data/serial_pl01x.h> |
| 12 | #include <i2c.h> |
| 13 | #include <malloc.h> |
| 14 | #include <errno.h> |
| 15 | #include <netdev.h> |
| 16 | #include <fsl_ddr.h> |
| 17 | #include <fsl_sec.h> |
| 18 | #include <asm/io.h> |
| 19 | #include <fdt_support.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 20 | #include <linux/bitops.h> |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 21 | #include <linux/libfdt.h> |
Yangbo Lu | e1a3cc7 | 2020-06-17 18:08:59 +0800 | [diff] [blame] | 22 | #include <linux/delay.h> |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 23 | #include <fsl-mc/fsl_mc.h> |
Simon Glass | 9d1f619 | 2019-08-02 09:44:25 -0600 | [diff] [blame] | 24 | #include <env_internal.h> |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 25 | #include <efi_loader.h> |
| 26 | #include <asm/arch/mmu.h> |
| 27 | #include <hwconfig.h> |
Pankaj Bansal | c6b6ba6 | 2019-08-17 01:07:32 +0000 | [diff] [blame] | 28 | #include <asm/arch/clock.h> |
| 29 | #include <asm/arch/config.h> |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 30 | #include <asm/arch/fsl_serdes.h> |
| 31 | #include <asm/arch/soc.h> |
| 32 | #include "../common/qixis.h" |
| 33 | #include "../common/vid.h" |
| 34 | #include <fsl_immap.h> |
Laurentiu Tudor | 7085d07 | 2019-10-18 09:01:55 +0000 | [diff] [blame] | 35 | #include <asm/arch-fsl-layerscape/fsl_icid.h> |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 36 | #include "lx2160a.h" |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 37 | |
Meenakshi Aggarwal | 936a68d | 2018-11-30 22:32:12 +0530 | [diff] [blame] | 38 | #ifdef CONFIG_EMC2305 |
| 39 | #include "../common/emc2305.h" |
| 40 | #endif |
| 41 | |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 42 | #if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 43 | #define CFG_MUX_I2C_SDHC(reg, value) ((reg & 0x3f) | value) |
| 44 | #define SET_CFG_MUX1_SDHC1_SDHC(reg) (reg & 0x3f) |
| 45 | #define SET_CFG_MUX2_SDHC1_SPI(reg, value) ((reg & 0xcf) | value) |
| 46 | #define SET_CFG_MUX3_SDHC1_SPI(reg, value) ((reg & 0xf8) | value) |
| 47 | #define SET_CFG_MUX_SDHC2_DSPI(reg, value) ((reg & 0xf8) | value) |
| 48 | #define SET_CFG_MUX1_SDHC1_DSPI(reg, value) ((reg & 0x3f) | value) |
| 49 | #define SDHC1_BASE_PMUX_DSPI 2 |
| 50 | #define SDHC2_BASE_PMUX_DSPI 2 |
| 51 | #define IIC5_PMUX_SPI3 3 |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 52 | #endif /* CONFIG_TARGET_LX2160AQDS or CONFIG_TARGET_LX2162AQDS */ |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 53 | |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 54 | DECLARE_GLOBAL_DATA_PTR; |
| 55 | |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 56 | static struct pl01x_serial_plat serial0 = { |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 57 | #if CONFIG_CONS_INDEX == 0 |
| 58 | .base = CONFIG_SYS_SERIAL0, |
| 59 | #elif CONFIG_CONS_INDEX == 1 |
| 60 | .base = CONFIG_SYS_SERIAL1, |
| 61 | #else |
| 62 | #error "Unsupported console index value." |
| 63 | #endif |
| 64 | .type = TYPE_PL011, |
| 65 | }; |
| 66 | |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 67 | U_BOOT_DRVINFO(nxp_serial0) = { |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 68 | .name = "serial_pl01x", |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 69 | .plat = &serial0, |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 72 | static struct pl01x_serial_plat serial1 = { |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 73 | .base = CONFIG_SYS_SERIAL1, |
| 74 | .type = TYPE_PL011, |
| 75 | }; |
| 76 | |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 77 | U_BOOT_DRVINFO(nxp_serial1) = { |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 78 | .name = "serial_pl01x", |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 79 | .plat = &serial1, |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | int select_i2c_ch_pca9547(u8 ch) |
| 83 | { |
| 84 | int ret; |
| 85 | |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame^] | 86 | #if !CONFIG_IS_ENABLED(DM_I2C) |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 87 | ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1); |
Chuanhua Han | 37c2c5e | 2019-07-10 21:00:20 +0800 | [diff] [blame] | 88 | #else |
| 89 | struct udevice *dev; |
| 90 | |
| 91 | ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, &dev); |
| 92 | if (!ret) |
| 93 | ret = dm_i2c_write(dev, 0, &ch, 1); |
| 94 | #endif |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 95 | if (ret) { |
| 96 | puts("PCA: failed to select proper channel\n"); |
| 97 | return ret; |
| 98 | } |
| 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | static void uart_get_clock(void) |
| 104 | { |
| 105 | serial0.clock = get_serial_clock(); |
| 106 | serial1.clock = get_serial_clock(); |
| 107 | } |
| 108 | |
| 109 | int board_early_init_f(void) |
| 110 | { |
| 111 | #ifdef CONFIG_SYS_I2C_EARLY_INIT |
| 112 | i2c_early_init_f(); |
| 113 | #endif |
| 114 | /* get required clock for UART IP */ |
| 115 | uart_get_clock(); |
| 116 | |
Meenakshi Aggarwal | 936a68d | 2018-11-30 22:32:12 +0530 | [diff] [blame] | 117 | #ifdef CONFIG_EMC2305 |
| 118 | select_i2c_ch_pca9547(I2C_MUX_CH_EMC2305); |
Wasim Khan | 1424198 | 2020-08-27 19:13:34 +0530 | [diff] [blame] | 119 | emc2305_init(I2C_EMC2305_ADDR); |
| 120 | set_fan_speed(I2C_EMC2305_PWM, I2C_EMC2305_ADDR); |
Meenakshi Aggarwal | 936a68d | 2018-11-30 22:32:12 +0530 | [diff] [blame] | 121 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT); |
| 122 | #endif |
| 123 | |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 124 | fsl_lsch3_early_init_f(); |
| 125 | return 0; |
| 126 | } |
| 127 | |
Pankaj Bansal | c6b6ba6 | 2019-08-17 01:07:32 +0000 | [diff] [blame] | 128 | #ifdef CONFIG_OF_BOARD_FIXUP |
| 129 | int board_fix_fdt(void *fdt) |
| 130 | { |
| 131 | char *reg_names, *reg_name; |
| 132 | int names_len, old_name_len, new_name_len, remaining_names_len; |
| 133 | struct str_map { |
| 134 | char *old_str; |
| 135 | char *new_str; |
| 136 | } reg_names_map[] = { |
Pankaj Bansal | 58ace21 | 2019-11-20 09:12:47 +0000 | [diff] [blame] | 137 | { "ccsr", "dbi" }, |
Pankaj Bansal | c6b6ba6 | 2019-08-17 01:07:32 +0000 | [diff] [blame] | 138 | { "pf_ctrl", "ctrl" } |
| 139 | }; |
Pankaj Bansal | 844e0ed | 2020-01-15 05:57:00 +0000 | [diff] [blame] | 140 | int off = -1, i = 0; |
Pankaj Bansal | c6b6ba6 | 2019-08-17 01:07:32 +0000 | [diff] [blame] | 141 | |
| 142 | if (IS_SVR_REV(get_svr(), 1, 0)) |
| 143 | return 0; |
| 144 | |
| 145 | off = fdt_node_offset_by_compatible(fdt, -1, "fsl,lx2160a-pcie"); |
| 146 | while (off != -FDT_ERR_NOTFOUND) { |
| 147 | fdt_setprop(fdt, off, "compatible", "fsl,ls-pcie", |
| 148 | strlen("fsl,ls-pcie") + 1); |
| 149 | |
| 150 | reg_names = (char *)fdt_getprop(fdt, off, "reg-names", |
| 151 | &names_len); |
| 152 | if (!reg_names) |
| 153 | continue; |
| 154 | |
| 155 | reg_name = reg_names; |
| 156 | remaining_names_len = names_len - (reg_name - reg_names); |
Vikas Singh | 1fe634a | 2020-02-12 13:47:09 +0530 | [diff] [blame] | 157 | i = 0; |
Pankaj Bansal | 844e0ed | 2020-01-15 05:57:00 +0000 | [diff] [blame] | 158 | while ((i < ARRAY_SIZE(reg_names_map)) && remaining_names_len) { |
Pankaj Bansal | c6b6ba6 | 2019-08-17 01:07:32 +0000 | [diff] [blame] | 159 | old_name_len = strlen(reg_names_map[i].old_str); |
| 160 | new_name_len = strlen(reg_names_map[i].new_str); |
| 161 | if (memcmp(reg_name, reg_names_map[i].old_str, |
| 162 | old_name_len) == 0) { |
| 163 | /* first only leave required bytes for new_str |
| 164 | * and copy rest of the string after it |
| 165 | */ |
| 166 | memcpy(reg_name + new_name_len, |
| 167 | reg_name + old_name_len, |
| 168 | remaining_names_len - old_name_len); |
| 169 | /* Now copy new_str */ |
| 170 | memcpy(reg_name, reg_names_map[i].new_str, |
| 171 | new_name_len); |
| 172 | names_len -= old_name_len; |
| 173 | names_len += new_name_len; |
Pankaj Bansal | 844e0ed | 2020-01-15 05:57:00 +0000 | [diff] [blame] | 174 | i++; |
Pankaj Bansal | c6b6ba6 | 2019-08-17 01:07:32 +0000 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | reg_name = memchr(reg_name, '\0', remaining_names_len); |
| 178 | if (!reg_name) |
| 179 | break; |
| 180 | |
| 181 | reg_name += 1; |
| 182 | |
| 183 | remaining_names_len = names_len - |
| 184 | (reg_name - reg_names); |
| 185 | } |
| 186 | |
| 187 | fdt_setprop(fdt, off, "reg-names", reg_names, names_len); |
| 188 | off = fdt_node_offset_by_compatible(fdt, off, |
| 189 | "fsl,lx2160a-pcie"); |
| 190 | } |
| 191 | |
| 192 | return 0; |
| 193 | } |
| 194 | #endif |
| 195 | |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 196 | #if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 197 | void esdhc_dspi_status_fixup(void *blob) |
| 198 | { |
| 199 | const char esdhc0_path[] = "/soc/esdhc@2140000"; |
| 200 | const char esdhc1_path[] = "/soc/esdhc@2150000"; |
Xiaowei Bao | 3a13e29 | 2020-01-08 14:29:54 +0800 | [diff] [blame] | 201 | const char dspi0_path[] = "/soc/spi@2100000"; |
| 202 | const char dspi1_path[] = "/soc/spi@2110000"; |
| 203 | const char dspi2_path[] = "/soc/spi@2120000"; |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 204 | |
| 205 | struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
| 206 | u32 sdhc1_base_pmux; |
| 207 | u32 sdhc2_base_pmux; |
| 208 | u32 iic5_pmux; |
| 209 | |
| 210 | /* Check RCW field sdhc1_base_pmux to enable/disable |
| 211 | * esdhc0/dspi0 DT node |
| 212 | */ |
| 213 | sdhc1_base_pmux = gur_in32(&gur->rcwsr[FSL_CHASSIS3_RCWSR12_REGSR - 1]) |
| 214 | & FSL_CHASSIS3_SDHC1_BASE_PMUX_MASK; |
| 215 | sdhc1_base_pmux >>= FSL_CHASSIS3_SDHC1_BASE_PMUX_SHIFT; |
| 216 | |
| 217 | if (sdhc1_base_pmux == SDHC1_BASE_PMUX_DSPI) { |
| 218 | do_fixup_by_path(blob, dspi0_path, "status", "okay", |
| 219 | sizeof("okay"), 1); |
| 220 | do_fixup_by_path(blob, esdhc0_path, "status", "disabled", |
| 221 | sizeof("disabled"), 1); |
| 222 | } else { |
| 223 | do_fixup_by_path(blob, esdhc0_path, "status", "okay", |
| 224 | sizeof("okay"), 1); |
| 225 | do_fixup_by_path(blob, dspi0_path, "status", "disabled", |
| 226 | sizeof("disabled"), 1); |
| 227 | } |
| 228 | |
| 229 | /* Check RCW field sdhc2_base_pmux to enable/disable |
| 230 | * esdhc1/dspi1 DT node |
| 231 | */ |
| 232 | sdhc2_base_pmux = gur_in32(&gur->rcwsr[FSL_CHASSIS3_RCWSR13_REGSR - 1]) |
| 233 | & FSL_CHASSIS3_SDHC2_BASE_PMUX_MASK; |
| 234 | sdhc2_base_pmux >>= FSL_CHASSIS3_SDHC2_BASE_PMUX_SHIFT; |
| 235 | |
| 236 | if (sdhc2_base_pmux == SDHC2_BASE_PMUX_DSPI) { |
| 237 | do_fixup_by_path(blob, dspi1_path, "status", "okay", |
| 238 | sizeof("okay"), 1); |
| 239 | do_fixup_by_path(blob, esdhc1_path, "status", "disabled", |
| 240 | sizeof("disabled"), 1); |
| 241 | } else { |
| 242 | do_fixup_by_path(blob, esdhc1_path, "status", "okay", |
| 243 | sizeof("okay"), 1); |
| 244 | do_fixup_by_path(blob, dspi1_path, "status", "disabled", |
| 245 | sizeof("disabled"), 1); |
| 246 | } |
| 247 | |
| 248 | /* Check RCW field IIC5 to enable dspi2 DT node */ |
| 249 | iic5_pmux = gur_in32(&gur->rcwsr[FSL_CHASSIS3_RCWSR12_REGSR - 1]) |
| 250 | & FSL_CHASSIS3_IIC5_PMUX_MASK; |
| 251 | iic5_pmux >>= FSL_CHASSIS3_IIC5_PMUX_SHIFT; |
| 252 | |
Xiaowei Bao | 3a13e29 | 2020-01-08 14:29:54 +0800 | [diff] [blame] | 253 | if (iic5_pmux == IIC5_PMUX_SPI3) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 254 | do_fixup_by_path(blob, dspi2_path, "status", "okay", |
| 255 | sizeof("okay"), 1); |
Xiaowei Bao | 3a13e29 | 2020-01-08 14:29:54 +0800 | [diff] [blame] | 256 | else |
| 257 | do_fixup_by_path(blob, dspi2_path, "status", "disabled", |
| 258 | sizeof("disabled"), 1); |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 259 | } |
| 260 | #endif |
| 261 | |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 262 | int esdhc_status_fixup(void *blob, const char *compat) |
| 263 | { |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 264 | #if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 265 | /* Enable esdhc and dspi DT nodes based on RCW fields */ |
| 266 | esdhc_dspi_status_fixup(blob); |
| 267 | #else |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 268 | /* Enable both esdhc DT nodes for LX2160ARDB */ |
| 269 | do_fixup_by_compat(blob, compat, "status", "okay", |
| 270 | sizeof("okay"), 1); |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 271 | #endif |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 272 | return 0; |
| 273 | } |
| 274 | |
| 275 | #if defined(CONFIG_VID) |
| 276 | int i2c_multiplexer_select_vid_channel(u8 channel) |
| 277 | { |
| 278 | return select_i2c_ch_pca9547(channel); |
| 279 | } |
| 280 | |
Priyanka Jain | e94c324 | 2019-02-04 06:32:36 +0000 | [diff] [blame] | 281 | int init_func_vid(void) |
| 282 | { |
Meenakshi Aggarwal | cdc1200 | 2020-02-26 16:46:48 +0530 | [diff] [blame] | 283 | int set_vid; |
| 284 | |
| 285 | if (IS_SVR_REV(get_svr(), 1, 0)) |
| 286 | set_vid = adjust_vdd(800); |
| 287 | else |
| 288 | set_vid = adjust_vdd(0); |
| 289 | |
| 290 | if (set_vid < 0) |
Priyanka Jain | e94c324 | 2019-02-04 06:32:36 +0000 | [diff] [blame] | 291 | printf("core voltage not adjusted\n"); |
| 292 | |
| 293 | return 0; |
| 294 | } |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 295 | #endif |
| 296 | |
| 297 | int checkboard(void) |
| 298 | { |
| 299 | enum boot_src src = get_boot_src(); |
| 300 | char buf[64]; |
| 301 | u8 sw; |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 302 | #if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 303 | int clock; |
| 304 | static const char *const freq[] = {"100", "125", "156.25", |
| 305 | "161.13", "322.26", "", "", "", |
| 306 | "", "", "", "", "", "", "", |
| 307 | "100 separate SSCG"}; |
| 308 | #endif |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 309 | |
| 310 | cpu_name(buf); |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 311 | #if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 312 | printf("Board: %s-QDS, ", buf); |
| 313 | #else |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 314 | printf("Board: %s-RDB, ", buf); |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 315 | #endif |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 316 | |
| 317 | sw = QIXIS_READ(arch); |
| 318 | printf("Board version: %c, boot from ", (sw & 0xf) - 1 + 'A'); |
| 319 | |
| 320 | if (src == BOOT_SOURCE_SD_MMC) { |
| 321 | puts("SD\n"); |
Meenakshi Aggarwal | 74bd499 | 2020-01-23 17:55:10 +0530 | [diff] [blame] | 322 | } else if (src == BOOT_SOURCE_SD_MMC2) { |
| 323 | puts("eMMC\n"); |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 324 | } else { |
| 325 | sw = QIXIS_READ(brdcfg[0]); |
| 326 | sw = (sw >> QIXIS_XMAP_SHIFT) & QIXIS_XMAP_MASK; |
| 327 | switch (sw) { |
| 328 | case 0: |
| 329 | case 4: |
| 330 | puts("FlexSPI DEV#0\n"); |
| 331 | break; |
| 332 | case 1: |
| 333 | puts("FlexSPI DEV#1\n"); |
| 334 | break; |
| 335 | case 2: |
| 336 | case 3: |
| 337 | puts("FlexSPI EMU\n"); |
| 338 | break; |
| 339 | default: |
| 340 | printf("invalid setting, xmap: %d\n", sw); |
| 341 | break; |
| 342 | } |
| 343 | } |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 344 | #if defined(CONFIG_TARGET_LX2160ARDB) |
| 345 | printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata)); |
| 346 | |
| 347 | puts("SERDES1 Reference: Clock1 = 161.13MHz Clock2 = 161.13MHz\n"); |
| 348 | puts("SERDES2 Reference: Clock1 = 100MHz Clock2 = 100MHz\n"); |
| 349 | puts("SERDES3 Reference: Clock1 = 100MHz Clock2 = 100MHz\n"); |
| 350 | #else |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 351 | printf("FPGA: v%d (%s), build %d", |
| 352 | (int)QIXIS_READ(scver), qixis_read_tag(buf), |
| 353 | (int)qixis_read_minor()); |
| 354 | /* the timestamp string contains "\n" at the end */ |
| 355 | printf(" on %s", qixis_read_time(buf)); |
| 356 | |
| 357 | puts("SERDES1 Reference : "); |
| 358 | sw = QIXIS_READ(brdcfg[2]); |
| 359 | clock = sw >> 4; |
| 360 | printf("Clock1 = %sMHz ", freq[clock]); |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 361 | #if defined(CONFIG_TARGET_LX2160AQDS) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 362 | clock = sw & 0x0f; |
| 363 | printf("Clock2 = %sMHz", freq[clock]); |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 364 | #endif |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 365 | sw = QIXIS_READ(brdcfg[3]); |
| 366 | puts("\nSERDES2 Reference : "); |
| 367 | clock = sw >> 4; |
| 368 | printf("Clock1 = %sMHz ", freq[clock]); |
| 369 | clock = sw & 0x0f; |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 370 | printf("Clock2 = %sMHz\n", freq[clock]); |
| 371 | #if defined(CONFIG_TARGET_LX2160AQDS) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 372 | sw = QIXIS_READ(brdcfg[12]); |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 373 | puts("SERDES3 Reference : "); |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 374 | clock = sw >> 4; |
| 375 | printf("Clock1 = %sMHz Clock2 = %sMHz\n", freq[clock], freq[clock]); |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 376 | #endif |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 377 | #endif |
| 378 | return 0; |
| 379 | } |
| 380 | |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 381 | #if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 382 | /* |
| 383 | * implementation of CONFIG_ESDHC_DETECT_QUIRK Macro. |
| 384 | */ |
| 385 | u8 qixis_esdhc_detect_quirk(void) |
| 386 | { |
Yangbo Lu | e1a3cc7 | 2020-06-17 18:08:59 +0800 | [diff] [blame] | 387 | /* |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 388 | * SDHC1 Card ID: |
| 389 | * Specifies the type of card installed in the SDHC1 adapter slot. |
| 390 | * 000= (reserved) |
| 391 | * 001= eMMC V4.5 adapter is installed. |
| 392 | * 010= SD/MMC 3.3V adapter is installed. |
| 393 | * 011= eMMC V4.4 adapter is installed. |
| 394 | * 100= eMMC V5.0 adapter is installed. |
| 395 | * 101= MMC card/Legacy (3.3V) adapter is installed. |
| 396 | * 110= SDCard V2/V3 adapter installed. |
| 397 | * 111= no adapter is installed. |
| 398 | */ |
Yangbo Lu | e1a3cc7 | 2020-06-17 18:08:59 +0800 | [diff] [blame] | 399 | return ((QIXIS_READ(sdhc1) & QIXIS_SDID_MASK) != |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 400 | QIXIS_ESDHC_NO_ADAPTER); |
| 401 | } |
| 402 | |
Yangbo Lu | e1a3cc7 | 2020-06-17 18:08:59 +0800 | [diff] [blame] | 403 | static void esdhc_adapter_card_ident(void) |
| 404 | { |
| 405 | u8 card_id, val; |
| 406 | |
| 407 | val = QIXIS_READ(sdhc1); |
| 408 | card_id = val & QIXIS_SDID_MASK; |
| 409 | |
| 410 | switch (card_id) { |
| 411 | case QIXIS_ESDHC_ADAPTER_TYPE_SD: |
| 412 | /* Power cycle to card */ |
| 413 | val &= ~QIXIS_SDHC1_S1V3; |
| 414 | QIXIS_WRITE(sdhc1, val); |
| 415 | mdelay(1); |
| 416 | val |= QIXIS_SDHC1_S1V3; |
| 417 | QIXIS_WRITE(sdhc1, val); |
| 418 | /* Route to SDHC1_VS */ |
| 419 | val = QIXIS_READ(brdcfg[11]); |
| 420 | val |= QIXIS_SDHC1_VS; |
| 421 | QIXIS_WRITE(brdcfg[11], val); |
| 422 | break; |
| 423 | default: |
| 424 | break; |
| 425 | } |
| 426 | } |
| 427 | |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 428 | int config_board_mux(void) |
| 429 | { |
| 430 | u8 reg11, reg5, reg13; |
| 431 | struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
| 432 | u32 sdhc1_base_pmux; |
| 433 | u32 sdhc2_base_pmux; |
| 434 | u32 iic5_pmux; |
| 435 | |
| 436 | /* Routes {I2C2_SCL, I2C2_SDA} to SDHC1 as {SDHC1_CD_B, SDHC1_WP}. |
| 437 | * Routes {I2C3_SCL, I2C3_SDA} to CAN transceiver as {CAN1_TX,CAN1_RX}. |
| 438 | * Routes {I2C4_SCL, I2C4_SDA} to CAN transceiver as {CAN2_TX,CAN2_RX}. |
| 439 | * Qixis and remote systems are isolated from the I2C1 bus. |
| 440 | * Processor connections are still available. |
| 441 | * SPI2 CS2_B controls EN25S64 SPI memory device. |
| 442 | * SPI3 CS2_B controls EN25S64 SPI memory device. |
| 443 | * EC2 connects to PHY #2 using RGMII protocol. |
| 444 | * CLK_OUT connects to FPGA for clock measurement. |
| 445 | */ |
| 446 | |
| 447 | reg5 = QIXIS_READ(brdcfg[5]); |
| 448 | reg5 = CFG_MUX_I2C_SDHC(reg5, 0x40); |
| 449 | QIXIS_WRITE(brdcfg[5], reg5); |
| 450 | |
| 451 | /* Check RCW field sdhc1_base_pmux |
| 452 | * esdhc0 : sdhc1_base_pmux = 0 |
| 453 | * dspi0 : sdhc1_base_pmux = 2 |
| 454 | */ |
| 455 | sdhc1_base_pmux = gur_in32(&gur->rcwsr[FSL_CHASSIS3_RCWSR12_REGSR - 1]) |
| 456 | & FSL_CHASSIS3_SDHC1_BASE_PMUX_MASK; |
| 457 | sdhc1_base_pmux >>= FSL_CHASSIS3_SDHC1_BASE_PMUX_SHIFT; |
| 458 | |
| 459 | if (sdhc1_base_pmux == SDHC1_BASE_PMUX_DSPI) { |
| 460 | reg11 = QIXIS_READ(brdcfg[11]); |
| 461 | reg11 = SET_CFG_MUX1_SDHC1_DSPI(reg11, 0x40); |
| 462 | QIXIS_WRITE(brdcfg[11], reg11); |
| 463 | } else { |
| 464 | /* - Routes {SDHC1_CMD, SDHC1_CLK } to SDHC1 adapter slot. |
| 465 | * {SDHC1_DAT3, SDHC1_DAT2} to SDHC1 adapter slot. |
| 466 | * {SDHC1_DAT1, SDHC1_DAT0} to SDHC1 adapter slot. |
| 467 | */ |
| 468 | reg11 = QIXIS_READ(brdcfg[11]); |
| 469 | reg11 = SET_CFG_MUX1_SDHC1_SDHC(reg11); |
| 470 | QIXIS_WRITE(brdcfg[11], reg11); |
| 471 | } |
| 472 | |
| 473 | /* Check RCW field sdhc2_base_pmux |
| 474 | * esdhc1 : sdhc2_base_pmux = 0 (default) |
| 475 | * dspi1 : sdhc2_base_pmux = 2 |
| 476 | */ |
| 477 | sdhc2_base_pmux = gur_in32(&gur->rcwsr[FSL_CHASSIS3_RCWSR13_REGSR - 1]) |
| 478 | & FSL_CHASSIS3_SDHC2_BASE_PMUX_MASK; |
| 479 | sdhc2_base_pmux >>= FSL_CHASSIS3_SDHC2_BASE_PMUX_SHIFT; |
| 480 | |
| 481 | if (sdhc2_base_pmux == SDHC2_BASE_PMUX_DSPI) { |
| 482 | reg13 = QIXIS_READ(brdcfg[13]); |
| 483 | reg13 = SET_CFG_MUX_SDHC2_DSPI(reg13, 0x01); |
| 484 | QIXIS_WRITE(brdcfg[13], reg13); |
| 485 | } else { |
| 486 | reg13 = QIXIS_READ(brdcfg[13]); |
| 487 | reg13 = SET_CFG_MUX_SDHC2_DSPI(reg13, 0x00); |
| 488 | QIXIS_WRITE(brdcfg[13], reg13); |
| 489 | } |
| 490 | |
| 491 | /* Check RCW field IIC5 to enable dspi2 DT nodei |
| 492 | * dspi2: IIC5 = 3 |
| 493 | */ |
| 494 | iic5_pmux = gur_in32(&gur->rcwsr[FSL_CHASSIS3_RCWSR12_REGSR - 1]) |
| 495 | & FSL_CHASSIS3_IIC5_PMUX_MASK; |
| 496 | iic5_pmux >>= FSL_CHASSIS3_IIC5_PMUX_SHIFT; |
| 497 | |
| 498 | if (iic5_pmux == IIC5_PMUX_SPI3) { |
| 499 | /* - Routes {SDHC1_DAT4} to SPI3 devices as {SPI3_M_CS0_B}. */ |
| 500 | reg11 = QIXIS_READ(brdcfg[11]); |
| 501 | reg11 = SET_CFG_MUX2_SDHC1_SPI(reg11, 0x10); |
| 502 | QIXIS_WRITE(brdcfg[11], reg11); |
| 503 | |
| 504 | /* - Routes {SDHC1_DAT5, SDHC1_DAT6} nowhere. |
| 505 | * {SDHC1_DAT7, SDHC1_DS } to {nothing, SPI3_M0_CLK }. |
| 506 | * {I2C5_SCL, I2C5_SDA } to {SPI3_M0_MOSI, SPI3_M0_MISO}. |
| 507 | */ |
| 508 | reg11 = QIXIS_READ(brdcfg[11]); |
| 509 | reg11 = SET_CFG_MUX3_SDHC1_SPI(reg11, 0x01); |
| 510 | QIXIS_WRITE(brdcfg[11], reg11); |
| 511 | } else { |
Yangbo Lu | a0923d7 | 2020-03-19 15:18:54 +0800 | [diff] [blame] | 512 | /* |
| 513 | * If {SDHC1_DAT4} has been configured to route to SDHC1_VS, |
| 514 | * do not change it. |
| 515 | * Otherwise route {SDHC1_DAT4} to SDHC1 adapter slot. |
| 516 | */ |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 517 | reg11 = QIXIS_READ(brdcfg[11]); |
Yangbo Lu | a0923d7 | 2020-03-19 15:18:54 +0800 | [diff] [blame] | 518 | if ((reg11 & 0x30) != 0x30) { |
| 519 | reg11 = SET_CFG_MUX2_SDHC1_SPI(reg11, 0x00); |
| 520 | QIXIS_WRITE(brdcfg[11], reg11); |
| 521 | } |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 522 | |
| 523 | /* - Routes {SDHC1_DAT5, SDHC1_DAT6} to SDHC1 adapter slot. |
| 524 | * {SDHC1_DAT7, SDHC1_DS } to SDHC1 adapter slot. |
| 525 | * {I2C5_SCL, I2C5_SDA } to SDHC1 adapter slot. |
| 526 | */ |
| 527 | reg11 = QIXIS_READ(brdcfg[11]); |
| 528 | reg11 = SET_CFG_MUX3_SDHC1_SPI(reg11, 0x00); |
| 529 | QIXIS_WRITE(brdcfg[11], reg11); |
| 530 | } |
| 531 | |
| 532 | return 0; |
| 533 | } |
Yangbo Lu | e1a3cc7 | 2020-06-17 18:08:59 +0800 | [diff] [blame] | 534 | |
| 535 | int board_early_init_r(void) |
| 536 | { |
| 537 | esdhc_adapter_card_ident(); |
| 538 | return 0; |
| 539 | } |
Pankaj Bansal | 504472c | 2019-07-17 09:34:34 +0000 | [diff] [blame] | 540 | #elif defined(CONFIG_TARGET_LX2160ARDB) |
| 541 | int config_board_mux(void) |
| 542 | { |
| 543 | u8 brdcfg; |
| 544 | |
| 545 | brdcfg = QIXIS_READ(brdcfg[4]); |
| 546 | /* The BRDCFG4 register controls general board configuration. |
| 547 | *|-------------------------------------------| |
| 548 | *|Field | Function | |
| 549 | *|-------------------------------------------| |
| 550 | *|5 | CAN I/O Enable (net CFG_CAN_EN_B):| |
| 551 | *|CAN_EN | 0= CAN transceivers are disabled. | |
| 552 | *| | 1= CAN transceivers are enabled. | |
| 553 | *|-------------------------------------------| |
| 554 | */ |
| 555 | brdcfg |= BIT_MASK(5); |
| 556 | QIXIS_WRITE(brdcfg[4], brdcfg); |
| 557 | |
| 558 | return 0; |
| 559 | } |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 560 | #else |
| 561 | int config_board_mux(void) |
| 562 | { |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 563 | return 0; |
| 564 | } |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 565 | #endif |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 566 | |
| 567 | unsigned long get_board_sys_clk(void) |
| 568 | { |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 569 | #if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 570 | u8 sysclk_conf = QIXIS_READ(brdcfg[1]); |
| 571 | |
| 572 | switch (sysclk_conf & 0x03) { |
| 573 | case QIXIS_SYSCLK_100: |
| 574 | return 100000000; |
| 575 | case QIXIS_SYSCLK_125: |
| 576 | return 125000000; |
| 577 | case QIXIS_SYSCLK_133: |
| 578 | return 133333333; |
| 579 | } |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 580 | return 100000000; |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 581 | #else |
| 582 | return 100000000; |
| 583 | #endif |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | unsigned long get_board_ddr_clk(void) |
| 587 | { |
Meenakshi Aggarwal | 8a03b0d | 2020-12-04 20:17:28 +0530 | [diff] [blame] | 588 | #if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS) |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 589 | u8 ddrclk_conf = QIXIS_READ(brdcfg[1]); |
| 590 | |
| 591 | switch ((ddrclk_conf & 0x30) >> 4) { |
| 592 | case QIXIS_DDRCLK_100: |
| 593 | return 100000000; |
| 594 | case QIXIS_DDRCLK_125: |
| 595 | return 125000000; |
| 596 | case QIXIS_DDRCLK_133: |
| 597 | return 133333333; |
| 598 | } |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 599 | return 100000000; |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 600 | #else |
| 601 | return 100000000; |
| 602 | #endif |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | int board_init(void) |
| 606 | { |
Florin Chiculita | d90d506 | 2019-04-22 11:57:47 +0300 | [diff] [blame] | 607 | #if defined(CONFIG_FSL_MC_ENET) && defined(CONFIG_TARGET_LX2160ARDB) |
| 608 | u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE; |
| 609 | #endif |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 610 | #ifdef CONFIG_ENV_IS_NOWHERE |
| 611 | gd->env_addr = (ulong)&default_environment[0]; |
| 612 | #endif |
| 613 | |
| 614 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT); |
| 615 | |
Florin Chiculita | d90d506 | 2019-04-22 11:57:47 +0300 | [diff] [blame] | 616 | #if defined(CONFIG_FSL_MC_ENET) && defined(CONFIG_TARGET_LX2160ARDB) |
| 617 | /* invert AQR107 IRQ pins polarity */ |
| 618 | out_le32(irq_ccsr + IRQCR_OFFSET / 4, AQR107_IRQ_MASK); |
| 619 | #endif |
| 620 | |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 621 | #ifdef CONFIG_FSL_CAAM |
| 622 | sec_init(); |
| 623 | #endif |
| 624 | |
Ioana Ciornei | cffa3b1 | 2020-04-27 15:21:15 +0300 | [diff] [blame] | 625 | #if !defined(CONFIG_SYS_EARLY_PCI_INIT) && defined(CONFIG_DM_ETH) |
| 626 | pci_init(); |
| 627 | #endif |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | void detail_board_ddr_info(void) |
| 632 | { |
| 633 | int i; |
| 634 | u64 ddr_size = 0; |
| 635 | |
| 636 | puts("\nDDR "); |
| 637 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) |
| 638 | ddr_size += gd->bd->bi_dram[i].size; |
| 639 | print_size(ddr_size, ""); |
| 640 | print_ddr_info(0); |
| 641 | } |
| 642 | |
Alex Marginean | b4f8023 | 2020-01-11 01:05:36 +0200 | [diff] [blame] | 643 | #ifdef CONFIG_MISC_INIT_R |
| 644 | int misc_init_r(void) |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 645 | { |
Pankaj Bansal | 338baa3 | 2019-02-08 10:29:58 +0000 | [diff] [blame] | 646 | config_board_mux(); |
| 647 | |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 648 | return 0; |
| 649 | } |
| 650 | #endif |
| 651 | |
| 652 | #ifdef CONFIG_FSL_MC_ENET |
| 653 | extern int fdt_fixup_board_phy(void *fdt); |
| 654 | |
| 655 | void fdt_fixup_board_enet(void *fdt) |
| 656 | { |
| 657 | int offset; |
| 658 | |
| 659 | offset = fdt_path_offset(fdt, "/soc/fsl-mc"); |
| 660 | |
| 661 | if (offset < 0) |
| 662 | offset = fdt_path_offset(fdt, "/fsl-mc"); |
| 663 | |
| 664 | if (offset < 0) { |
| 665 | printf("%s: fsl-mc node not found in device tree (error %d)\n", |
| 666 | __func__, offset); |
| 667 | return; |
| 668 | } |
| 669 | |
Mian Yousaf Kaukab | c387c01 | 2019-05-23 10:57:33 +0200 | [diff] [blame] | 670 | if (get_mc_boot_status() == 0 && |
| 671 | (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0)) { |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 672 | fdt_status_okay(fdt, offset); |
Ioana Ciornei | cffa3b1 | 2020-04-27 15:21:15 +0300 | [diff] [blame] | 673 | #ifndef CONFIG_DM_ETH |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 674 | fdt_fixup_board_phy(fdt); |
Ioana Ciornei | cffa3b1 | 2020-04-27 15:21:15 +0300 | [diff] [blame] | 675 | #endif |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 676 | } else { |
| 677 | fdt_status_fail(fdt, offset); |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | void board_quiesce_devices(void) |
| 682 | { |
| 683 | fsl_mc_ldpaa_exit(gd->bd); |
| 684 | } |
| 685 | #endif |
| 686 | |
| 687 | #ifdef CONFIG_OF_BOARD_SETUP |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 688 | int ft_board_setup(void *blob, struct bd_info *bd) |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 689 | { |
| 690 | int i; |
Meenakshi Aggarwal | d67ae48 | 2019-05-23 15:13:43 +0530 | [diff] [blame] | 691 | u16 mc_memory_bank = 0; |
| 692 | |
| 693 | u64 *base; |
| 694 | u64 *size; |
| 695 | u64 mc_memory_base = 0; |
| 696 | u64 mc_memory_size = 0; |
| 697 | u16 total_memory_banks; |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 698 | |
| 699 | ft_cpu_setup(blob, bd); |
| 700 | |
Meenakshi Aggarwal | d67ae48 | 2019-05-23 15:13:43 +0530 | [diff] [blame] | 701 | fdt_fixup_mc_ddr(&mc_memory_base, &mc_memory_size); |
| 702 | |
| 703 | if (mc_memory_base != 0) |
| 704 | mc_memory_bank++; |
| 705 | |
| 706 | total_memory_banks = CONFIG_NR_DRAM_BANKS + mc_memory_bank; |
| 707 | |
| 708 | base = calloc(total_memory_banks, sizeof(u64)); |
| 709 | size = calloc(total_memory_banks, sizeof(u64)); |
| 710 | |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 711 | /* fixup DT for the three GPP DDR banks */ |
| 712 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 713 | base[i] = gd->bd->bi_dram[i].start; |
| 714 | size[i] = gd->bd->bi_dram[i].size; |
| 715 | } |
| 716 | |
| 717 | #ifdef CONFIG_RESV_RAM |
| 718 | /* reduce size if reserved memory is within this bank */ |
| 719 | if (gd->arch.resv_ram >= base[0] && |
| 720 | gd->arch.resv_ram < base[0] + size[0]) |
| 721 | size[0] = gd->arch.resv_ram - base[0]; |
| 722 | else if (gd->arch.resv_ram >= base[1] && |
| 723 | gd->arch.resv_ram < base[1] + size[1]) |
| 724 | size[1] = gd->arch.resv_ram - base[1]; |
| 725 | else if (gd->arch.resv_ram >= base[2] && |
| 726 | gd->arch.resv_ram < base[2] + size[2]) |
| 727 | size[2] = gd->arch.resv_ram - base[2]; |
| 728 | #endif |
| 729 | |
Meenakshi Aggarwal | d67ae48 | 2019-05-23 15:13:43 +0530 | [diff] [blame] | 730 | if (mc_memory_base != 0) { |
| 731 | for (i = 0; i <= total_memory_banks; i++) { |
| 732 | if (base[i] == 0 && size[i] == 0) { |
| 733 | base[i] = mc_memory_base; |
| 734 | size[i] = mc_memory_size; |
| 735 | break; |
| 736 | } |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | fdt_fixup_memory_banks(blob, base, size, total_memory_banks); |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 741 | |
| 742 | #ifdef CONFIG_USB |
| 743 | fsl_fdt_fixup_dr_usb(blob, bd); |
| 744 | #endif |
| 745 | |
| 746 | #ifdef CONFIG_FSL_MC_ENET |
| 747 | fdt_fsl_mc_fixup_iommu_map_entry(blob); |
| 748 | fdt_fixup_board_enet(blob); |
| 749 | #endif |
Laurentiu Tudor | 7085d07 | 2019-10-18 09:01:55 +0000 | [diff] [blame] | 750 | fdt_fixup_icid(blob); |
Priyanka Jain | fd45ca0 | 2018-11-28 13:04:27 +0000 | [diff] [blame] | 751 | |
| 752 | return 0; |
| 753 | } |
| 754 | #endif |
| 755 | |
| 756 | void qixis_dump_switch(void) |
| 757 | { |
| 758 | int i, nr_of_cfgsw; |
| 759 | |
| 760 | QIXIS_WRITE(cms[0], 0x00); |
| 761 | nr_of_cfgsw = QIXIS_READ(cms[1]); |
| 762 | |
| 763 | puts("DIP switch settings dump:\n"); |
| 764 | for (i = 1; i <= nr_of_cfgsw; i++) { |
| 765 | QIXIS_WRITE(cms[0], i); |
| 766 | printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1])); |
| 767 | } |
| 768 | } |