blob: 1bd4f2b3449dc9c6690c9d12b4dcb32ef7b7c9fd [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kim Phillipsfd47a742007-12-20 14:09:22 -06002/*
3 * Copyright 2007 Freescale Semiconductor, Inc.
4 *
5 * (C) Copyright 2000
6 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Kim Phillipsfd47a742007-12-20 14:09:22 -06007 */
8
Simon Glass85d65312019-12-28 10:44:58 -07009#include <clock_legacy.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060010#include <asm/global_data.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090011#include <linux/libfdt.h>
Kim Phillipsfd47a742007-12-20 14:09:22 -060012#include <fdt_support.h>
Kim Phillips868e3462008-06-16 15:55:53 -050013#include <asm/processor.h>
Kim Phillipsfd47a742007-12-20 14:09:22 -060014
Kumar Gala1f164482008-01-17 08:25:45 -060015extern void ft_qe_setup(void *blob);
16
Kim Phillipsfd47a742007-12-20 14:09:22 -060017DECLARE_GLOBAL_DATA_PTR;
18
Heiko Schocher466924f2010-02-18 08:08:25 +010019#if defined(CONFIG_BOOTCOUNT_LIMIT) && \
Mario Six9164bdd2019-01-21 09:17:25 +010020 (defined(CONFIG_QE) && !defined(CONFIG_ARCH_MPC831X))
Zhao Qiang978679d2014-06-03 16:27:07 +080021#include <linux/immap_qe.h>
Heiko Schocherd2c4f3a2009-02-24 11:30:51 +010022
23void fdt_fixup_muram (void *blob)
24{
25 ulong data[2];
26
27 data[0] = 0;
28 data[1] = QE_MURAM_SIZE - 2 * sizeof(unsigned long);
Heiko Schocher0b000742009-04-24 06:50:45 +020029 do_fixup_by_compat(blob, "fsl,qe-muram-data", "reg",
30 data, sizeof (data), 0);
Heiko Schocherd2c4f3a2009-02-24 11:30:51 +010031}
32#endif
33
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090034void ft_cpu_setup(void *blob, struct bd_info *bd)
Kim Phillipsfd47a742007-12-20 14:09:22 -060035{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020036 immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
Kim Phillips868e3462008-06-16 15:55:53 -050037 int spridr = immr->sysconf.spridr;
38
39 /*
40 * delete crypto node if not on an E-processor
41 * initial revisions of the MPC834xE/6xE have the original SEC 2.0.
42 * EA revisions got the SEC uprevved to 2.4 but since the default device
43 * tree contains SEC 2.0 properties we uprev them here.
44 */
45 if (!IS_E_PROCESSOR(spridr))
46 fdt_fixup_crypto_node(blob, 0);
47 else if (IS_E_PROCESSOR(spridr) &&
48 (SPR_FAMILY(spridr) == SPR_834X_FAMILY ||
49 SPR_FAMILY(spridr) == SPR_836X_FAMILY) &&
50 REVID_MAJOR(spridr) >= 2)
51 fdt_fixup_crypto_node(blob, 0x0204);
52
Mario Six9164bdd2019-01-21 09:17:25 +010053#ifdef CONFIG_ARCH_MPC8313
Kim Phillips3b1b1442009-10-12 11:06:19 -050054 /*
55 * mpc8313e erratum IPIC1 swapped TSEC interrupt ID numbers on rev. 1
56 * h/w (see AN3545). The base device tree in use has rev. 1 ID numbers,
57 * so if on Rev. 2 (and higher) h/w, we fix them up here
58 */
59 if (REVID_MAJOR(immr->sysconf.spridr) >= 2) {
60 int nodeoffset, path;
61 const char *prop;
62
63 nodeoffset = fdt_path_offset(blob, "/aliases");
64 if (nodeoffset >= 0) {
Kim Phillips3b1b1442009-10-12 11:06:19 -050065 prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL);
66 if (prop) {
67 u32 tmp[] = { 32, 0x8, 33, 0x8, 34, 0x8 };
68
69 path = fdt_path_offset(blob, prop);
Kim Phillipsb5c312a2012-10-29 13:34:39 +000070 prop = fdt_getprop(blob, path, "interrupts",
71 NULL);
Kim Phillips3b1b1442009-10-12 11:06:19 -050072 if (prop)
73 fdt_setprop(blob, path, "interrupts",
74 &tmp, sizeof(tmp));
75 }
Kim Phillips3b1b1442009-10-12 11:06:19 -050076 prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL);
77 if (prop) {
78 u32 tmp[] = { 35, 0x8, 36, 0x8, 37, 0x8 };
79
80 path = fdt_path_offset(blob, prop);
Kim Phillipsb5c312a2012-10-29 13:34:39 +000081 prop = fdt_getprop(blob, path, "interrupts",
82 NULL);
Kim Phillips3b1b1442009-10-12 11:06:19 -050083 if (prop)
84 fdt_setprop(blob, path, "interrupts",
85 &tmp, sizeof(tmp));
86 }
Kim Phillips3b1b1442009-10-12 11:06:19 -050087 }
88 }
89#endif
Kim Phillipsfd47a742007-12-20 14:09:22 -060090
91 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
92 "timebase-frequency", (bd->bi_busfreq / 4), 1);
93 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
94 "bus-frequency", bd->bi_busfreq, 1);
95 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
Simon Glasscc76e9e2012-12-13 20:48:47 +000096 "clock-frequency", gd->arch.core_clk, 1);
Kim Phillipsfd47a742007-12-20 14:09:22 -060097 do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
98 "bus-frequency", bd->bi_busfreq, 1);
Anton Vorontsov3114a9b2008-03-24 20:47:09 +030099 do_fixup_by_compat_u32(blob, "fsl,soc",
100 "bus-frequency", bd->bi_busfreq, 1);
101 do_fixup_by_compat_u32(blob, "fsl,soc",
102 "clock-frequency", bd->bi_busfreq, 1);
103 do_fixup_by_compat_u32(blob, "fsl,immr",
104 "bus-frequency", bd->bi_busfreq, 1);
105 do_fixup_by_compat_u32(blob, "fsl,immr",
106 "clock-frequency", bd->bi_busfreq, 1);
Kim Phillipsfd47a742007-12-20 14:09:22 -0600107#ifdef CONFIG_QE
Kumar Gala1f164482008-01-17 08:25:45 -0600108 ft_qe_setup(blob);
Kim Phillipsfd47a742007-12-20 14:09:22 -0600109#endif
110
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200111#ifdef CONFIG_SYS_NS16550
Mario Sixa3a8d0c2019-01-21 09:18:06 +0100112 do_fixup_by_compat_u32(blob, "ns16550",
113 "clock-frequency", get_serial_clock(), 1);
Kim Phillipsfd47a742007-12-20 14:09:22 -0600114#endif
115
Stefan Roesea13a2aa2020-08-12 13:16:36 +0200116 fdt_fixup_memory(blob, (u64)gd->ram_base, (u64)gd->ram_size);
Heiko Schocherd2c4f3a2009-02-24 11:30:51 +0100117
Heiko Schocher04e3b3a2014-01-25 07:53:47 +0100118#if defined(CONFIG_BOOTCOUNT_LIMIT) && \
Mario Six9164bdd2019-01-21 09:17:25 +0100119 (defined(CONFIG_QE) && !defined(CONFIG_ARCH_MPC831X))
Heiko Schocherd2c4f3a2009-02-24 11:30:51 +0100120 fdt_fixup_muram (blob);
121#endif
Kim Phillipsfd47a742007-12-20 14:09:22 -0600122}