1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2a47a12beSStefan Roese /*
3a47a12beSStefan Roese * Copyright 2007 Freescale Semiconductor, Inc.
4a47a12beSStefan Roese *
5a47a12beSStefan Roese * (C) Copyright 2000
6a47a12beSStefan Roese * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7a47a12beSStefan Roese */
8a47a12beSStefan Roese
9a47a12beSStefan Roese #include <common.h>
10b08c8c48SMasahiro Yamada #include <linux/libfdt.h>
11a47a12beSStefan Roese #include <fdt_support.h>
12a47a12beSStefan Roese #include <asm/processor.h>
13a47a12beSStefan Roese
14a47a12beSStefan Roese extern void ft_qe_setup(void *blob);
15a47a12beSStefan Roese
16a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR;
17a47a12beSStefan Roese
1862ddcf05SHeiko Schocher #if defined(CONFIG_BOOTCOUNT_LIMIT) && \
1999509695SHeiko Schocher (defined(CONFIG_QE) && !defined(CONFIG_MPC831x))
2038d67a4eSZhao Qiang #include <linux/immap_qe.h>
21a47a12beSStefan Roese
fdt_fixup_muram(void * blob)22a47a12beSStefan Roese void fdt_fixup_muram (void *blob)
23a47a12beSStefan Roese {
24a47a12beSStefan Roese ulong data[2];
25a47a12beSStefan Roese
26a47a12beSStefan Roese data[0] = 0;
27a47a12beSStefan Roese data[1] = QE_MURAM_SIZE - 2 * sizeof(unsigned long);
28a47a12beSStefan Roese do_fixup_by_compat(blob, "fsl,qe-muram-data", "reg",
29a47a12beSStefan Roese data, sizeof (data), 0);
30a47a12beSStefan Roese }
31a47a12beSStefan Roese #endif
32a47a12beSStefan Roese
ft_cpu_setup(void * blob,bd_t * bd)33a47a12beSStefan Roese void ft_cpu_setup(void *blob, bd_t *bd)
34a47a12beSStefan Roese {
35a47a12beSStefan Roese immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
36a47a12beSStefan Roese int spridr = immr->sysconf.spridr;
37a47a12beSStefan Roese
38a47a12beSStefan Roese /*
39a47a12beSStefan Roese * delete crypto node if not on an E-processor
40a47a12beSStefan Roese * initial revisions of the MPC834xE/6xE have the original SEC 2.0.
41a47a12beSStefan Roese * EA revisions got the SEC uprevved to 2.4 but since the default device
42a47a12beSStefan Roese * tree contains SEC 2.0 properties we uprev them here.
43a47a12beSStefan Roese */
44a47a12beSStefan Roese if (!IS_E_PROCESSOR(spridr))
45a47a12beSStefan Roese fdt_fixup_crypto_node(blob, 0);
46a47a12beSStefan Roese else if (IS_E_PROCESSOR(spridr) &&
47a47a12beSStefan Roese (SPR_FAMILY(spridr) == SPR_834X_FAMILY ||
48a47a12beSStefan Roese SPR_FAMILY(spridr) == SPR_836X_FAMILY) &&
49a47a12beSStefan Roese REVID_MAJOR(spridr) >= 2)
50a47a12beSStefan Roese fdt_fixup_crypto_node(blob, 0x0204);
51a47a12beSStefan Roese
52a47a12beSStefan Roese #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
53a47a12beSStefan Roese defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3) ||\
54a47a12beSStefan Roese defined(CONFIG_HAS_ETH4) || defined(CONFIG_HAS_ETH5)
55a47a12beSStefan Roese #ifdef CONFIG_MPC8313
56a47a12beSStefan Roese /*
57a47a12beSStefan Roese * mpc8313e erratum IPIC1 swapped TSEC interrupt ID numbers on rev. 1
58a47a12beSStefan Roese * h/w (see AN3545). The base device tree in use has rev. 1 ID numbers,
59a47a12beSStefan Roese * so if on Rev. 2 (and higher) h/w, we fix them up here
60a47a12beSStefan Roese */
61a47a12beSStefan Roese if (REVID_MAJOR(immr->sysconf.spridr) >= 2) {
62a47a12beSStefan Roese int nodeoffset, path;
63a47a12beSStefan Roese const char *prop;
64a47a12beSStefan Roese
65a47a12beSStefan Roese nodeoffset = fdt_path_offset(blob, "/aliases");
66a47a12beSStefan Roese if (nodeoffset >= 0) {
67a47a12beSStefan Roese #if defined(CONFIG_HAS_ETH0)
68a47a12beSStefan Roese prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL);
69a47a12beSStefan Roese if (prop) {
70a47a12beSStefan Roese u32 tmp[] = { 32, 0x8, 33, 0x8, 34, 0x8 };
71a47a12beSStefan Roese
72a47a12beSStefan Roese path = fdt_path_offset(blob, prop);
73a2873bdeSKim Phillips prop = fdt_getprop(blob, path, "interrupts",
74a2873bdeSKim Phillips NULL);
75a47a12beSStefan Roese if (prop)
76a47a12beSStefan Roese fdt_setprop(blob, path, "interrupts",
77a47a12beSStefan Roese &tmp, sizeof(tmp));
78a47a12beSStefan Roese }
79a47a12beSStefan Roese #endif
80a47a12beSStefan Roese #if defined(CONFIG_HAS_ETH1)
81a47a12beSStefan Roese prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL);
82a47a12beSStefan Roese if (prop) {
83a47a12beSStefan Roese u32 tmp[] = { 35, 0x8, 36, 0x8, 37, 0x8 };
84a47a12beSStefan Roese
85a47a12beSStefan Roese path = fdt_path_offset(blob, prop);
86a2873bdeSKim Phillips prop = fdt_getprop(blob, path, "interrupts",
87a2873bdeSKim Phillips NULL);
88a47a12beSStefan Roese if (prop)
89a47a12beSStefan Roese fdt_setprop(blob, path, "interrupts",
90a47a12beSStefan Roese &tmp, sizeof(tmp));
91a47a12beSStefan Roese }
92a47a12beSStefan Roese #endif
93a47a12beSStefan Roese }
94a47a12beSStefan Roese }
95a47a12beSStefan Roese #endif
96a47a12beSStefan Roese #endif
97a47a12beSStefan Roese
98a47a12beSStefan Roese do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
99a47a12beSStefan Roese "timebase-frequency", (bd->bi_busfreq / 4), 1);
100a47a12beSStefan Roese do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
101a47a12beSStefan Roese "bus-frequency", bd->bi_busfreq, 1);
102a47a12beSStefan Roese do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
103c6731fe2SSimon Glass "clock-frequency", gd->arch.core_clk, 1);
104a47a12beSStefan Roese do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
105a47a12beSStefan Roese "bus-frequency", bd->bi_busfreq, 1);
106a47a12beSStefan Roese do_fixup_by_compat_u32(blob, "fsl,soc",
107a47a12beSStefan Roese "bus-frequency", bd->bi_busfreq, 1);
108a47a12beSStefan Roese do_fixup_by_compat_u32(blob, "fsl,soc",
109a47a12beSStefan Roese "clock-frequency", bd->bi_busfreq, 1);
110a47a12beSStefan Roese do_fixup_by_compat_u32(blob, "fsl,immr",
111a47a12beSStefan Roese "bus-frequency", bd->bi_busfreq, 1);
112a47a12beSStefan Roese do_fixup_by_compat_u32(blob, "fsl,immr",
113a47a12beSStefan Roese "clock-frequency", bd->bi_busfreq, 1);
114a47a12beSStefan Roese #ifdef CONFIG_QE
115a47a12beSStefan Roese ft_qe_setup(blob);
116a47a12beSStefan Roese #endif
117a47a12beSStefan Roese
118a47a12beSStefan Roese #ifdef CONFIG_SYS_NS16550
119a47a12beSStefan Roese do_fixup_by_compat_u32(blob, "ns16550",
120a47a12beSStefan Roese "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
121a47a12beSStefan Roese #endif
122a47a12beSStefan Roese
123a47a12beSStefan Roese fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
124a47a12beSStefan Roese
12599509695SHeiko Schocher #if defined(CONFIG_BOOTCOUNT_LIMIT) && \
12699509695SHeiko Schocher (defined(CONFIG_QE) && !defined(CONFIG_MPC831x))
127a47a12beSStefan Roese fdt_fixup_muram (blob);
128a47a12beSStefan Roese #endif
129a47a12beSStefan Roese }
130