1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor, Inc.
7 #include <clock_legacy.h>
9 #include <asm/global_data.h>
10 #include <linux/libfdt.h>
11 #include <fdt_support.h>
13 #include <asm/processor.h>
14 #include <asm/arch/clock.h>
15 #include <linux/ctype.h>
16 #ifdef CONFIG_FSL_ESDHC
17 #include <fsl_esdhc.h>
20 #include <asm/arch/immap_ls102xa.h>
24 DECLARE_GLOBAL_DATA_PTR;
26 void ft_fixup_enet_phy_connect_type(void *fdt)
31 struct eth_device *dev;
33 struct tsec_private *priv;
34 const char *enet_path, *phy_path;
41 char *name[3] = { "ethernet@2d10000", "ethernet@2d50000",
44 char *name[3] = { "eTSEC1", "eTSEC2", "eTSEC3" };
47 for (; i < ARRAY_SIZE(name); i++) {
48 dev = eth_get_dev_by_name(name[i]);
50 sprintf(enet, "ethernet%d", i);
51 sprintf(phy, "enet%d_rgmii_phy", i);
57 priv = dev_get_priv(dev);
61 if (priv->flags & TSEC_SGMII)
64 enet_path = fdt_get_alias(fdt, enet);
68 phy_path = fdt_get_alias(fdt, phy);
72 phy_node = fdt_path_offset(fdt, phy_path);
76 ph = fdt_create_phandle(fdt, phy_node);
78 do_fixup_by_path_u32(fdt, enet_path,
81 do_fixup_by_path(fdt, enet_path, "phy-connection-type",
82 phy_string_for_interface(
83 PHY_INTERFACE_MODE_RGMII_ID),
84 strlen(phy_string_for_interface(
85 PHY_INTERFACE_MODE_RGMII_ID)) + 1,
90 void ft_cpu_setup(void *blob, struct bd_info *bd)
94 const char *sysclk_path;
95 struct ccsr_gur __iomem *gur = (void *)(CFG_SYS_FSL_GUTS_ADDR);
97 svr = in_be32(&gur->svr);
99 unsigned long busclk = get_bus_freq(0);
101 /* delete crypto node if not on an E-processor */
102 if (!IS_E_PROCESSOR(svr))
103 fdt_fixup_crypto_node(blob, 0);
104 #if CONFIG_SYS_FSL_SEC_COMPAT >= 4
106 ccsr_sec_t __iomem *sec;
108 sec = (void __iomem *)CFG_SYS_FSL_SEC_ADDR;
109 fdt_fixup_crypto_node(blob, sec_in32(&sec->secvid_ms));
113 off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
114 while (off != -FDT_ERR_NOTFOUND) {
116 fdt_setprop(blob, off, "clock-frequency", &val, 4);
117 off = fdt_node_offset_by_prop_value(blob, off,
118 "device_type", "cpu", 4);
121 do_fixup_by_prop_u32(blob, "device_type", "soc",
122 4, "bus-frequency", busclk, 1);
124 ft_fixup_enet_phy_connect_type(blob);
126 #ifdef CONFIG_SYS_NS16550
127 do_fixup_by_compat_u32(blob, "fsl,16550-FIFO64",
128 "clock-frequency", CFG_SYS_NS16550_CLK, 1);
131 sysclk_path = fdt_get_alias(blob, "sysclk");
133 do_fixup_by_path_u32(blob, sysclk_path, "clock-frequency",
134 get_board_sys_clk(), 1);
135 do_fixup_by_compat_u32(blob, "fsl,qoriq-sysclk-2.0",
136 "clock-frequency", get_board_sys_clk(), 1);
138 #if defined(CONFIG_DEEP_SLEEP) && defined(CONFIG_SD_BOOT)
139 #define UBOOT_HEAD_LEN 0x1000
141 * Reserved memory in SD boot deep sleep case.
142 * Second stage uboot binary and malloc space should be reserved.
143 * If the memory they occupied has not been reserved, then this
144 * space would be used by kernel and overwritten in uboot when
145 * deep sleep resume, which cause deep sleep failed.
146 * Since second uboot binary has a head, that space need to be
147 * reserved either(assuming its size is less than 0x1000).
149 off = fdt_add_mem_rsv(blob, CONFIG_TEXT_BASE - UBOOT_HEAD_LEN,
150 CONFIG_SYS_MONITOR_LEN +
151 CONFIG_SYS_SPL_MALLOC_SIZE + UBOOT_HEAD_LEN);
153 printf("Failed to reserve memory for SD boot deep sleep: %s\n",
157 #if defined(CONFIG_FSL_ESDHC)
158 fdt_fixup_esdhc(blob, bd);
162 * platform bus clock = system bus clock/2
163 * Here busclk = system bus clock
164 * We are using the platform bus clock as 1588 Timer reference
165 * clock source select
167 do_fixup_by_compat_u32(blob, "fsl, gianfar-ptp-timer",
168 "timer-frequency", busclk / 2, 1);
171 * clock-freq should change to clock-frequency and
172 * flexcan-v1.0 should change to p1010-flexcan respectively
175 do_fixup_by_compat_u32(blob, "fsl, flexcan-v1.0",
176 "clock_freq", busclk / 2, 1);
178 do_fixup_by_compat_u32(blob, "fsl, flexcan-v1.0",
179 "clock-frequency", busclk / 2, 1);
181 do_fixup_by_compat_u32(blob, "fsl, ls1021a-flexcan",
182 "clock-frequency", busclk / 2, 1);
184 #if defined(CONFIG_QSPI_BOOT) || defined(CONFIG_SD_BOOT_QSPI)
185 off = fdt_node_offset_by_compat_reg(blob, FSL_IFC_COMPAT,
187 fdt_set_node_status(blob, off, FDT_STATUS_DISABLED);
189 off = fdt_node_offset_by_compat_reg(blob, FSL_QSPI_COMPAT,
191 fdt_set_node_status(blob, off, FDT_STATUS_DISABLED);
192 off = fdt_node_offset_by_compat_reg(blob, FSL_DSPI_COMPAT,
194 fdt_set_node_status(blob, off, FDT_STATUS_DISABLED);