blob: b487e31cc0f75fe9deff81da11d792763efbe370 [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
9#include <common.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090010#include <linux/libfdt.h>
Kim Phillipsfd47a742007-12-20 14:09:22 -060011#include <fdt_support.h>
Kim Phillips868e3462008-06-16 15:55:53 -050012#include <asm/processor.h>
Kim Phillipsfd47a742007-12-20 14:09:22 -060013
Kumar Gala1f164482008-01-17 08:25:45 -060014extern void ft_qe_setup(void *blob);
15
Kim Phillipsfd47a742007-12-20 14:09:22 -060016DECLARE_GLOBAL_DATA_PTR;
17
Heiko Schocher466924f2010-02-18 08:08:25 +010018#if defined(CONFIG_BOOTCOUNT_LIMIT) && \
Mario Six9164bdd2019-01-21 09:17:25 +010019 (defined(CONFIG_QE) && !defined(CONFIG_ARCH_MPC831X))
Zhao Qiang978679d2014-06-03 16:27:07 +080020#include <linux/immap_qe.h>
Heiko Schocherd2c4f3a2009-02-24 11:30:51 +010021
22void fdt_fixup_muram (void *blob)
23{
24 ulong data[2];
25
26 data[0] = 0;
27 data[1] = QE_MURAM_SIZE - 2 * sizeof(unsigned long);
Heiko Schocher0b000742009-04-24 06:50:45 +020028 do_fixup_by_compat(blob, "fsl,qe-muram-data", "reg",
29 data, sizeof (data), 0);
Heiko Schocherd2c4f3a2009-02-24 11:30:51 +010030}
31#endif
32
Kim Phillipsfd47a742007-12-20 14:09:22 -060033void ft_cpu_setup(void *blob, bd_t *bd)
34{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020035 immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
Kim Phillips868e3462008-06-16 15:55:53 -050036 int spridr = immr->sysconf.spridr;
37
38 /*
39 * delete crypto node if not on an E-processor
40 * initial revisions of the MPC834xE/6xE have the original SEC 2.0.
41 * EA revisions got the SEC uprevved to 2.4 but since the default device
42 * tree contains SEC 2.0 properties we uprev them here.
43 */
44 if (!IS_E_PROCESSOR(spridr))
45 fdt_fixup_crypto_node(blob, 0);
46 else if (IS_E_PROCESSOR(spridr) &&
47 (SPR_FAMILY(spridr) == SPR_834X_FAMILY ||
48 SPR_FAMILY(spridr) == SPR_836X_FAMILY) &&
49 REVID_MAJOR(spridr) >= 2)
50 fdt_fixup_crypto_node(blob, 0x0204);
51
Kim Phillipsfd47a742007-12-20 14:09:22 -060052#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
richardretanubune5167f12008-09-29 18:28:23 -040053 defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3) ||\
54 defined(CONFIG_HAS_ETH4) || defined(CONFIG_HAS_ETH5)
Mario Six9164bdd2019-01-21 09:17:25 +010055#ifdef CONFIG_ARCH_MPC8313
Kim Phillips3b1b1442009-10-12 11:06:19 -050056 /*
57 * mpc8313e erratum IPIC1 swapped TSEC interrupt ID numbers on rev. 1
58 * h/w (see AN3545). The base device tree in use has rev. 1 ID numbers,
59 * so if on Rev. 2 (and higher) h/w, we fix them up here
60 */
61 if (REVID_MAJOR(immr->sysconf.spridr) >= 2) {
62 int nodeoffset, path;
63 const char *prop;
64
65 nodeoffset = fdt_path_offset(blob, "/aliases");
66 if (nodeoffset >= 0) {
67#if defined(CONFIG_HAS_ETH0)
68 prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL);
69 if (prop) {
70 u32 tmp[] = { 32, 0x8, 33, 0x8, 34, 0x8 };
71
72 path = fdt_path_offset(blob, prop);
Kim Phillipsb5c312a2012-10-29 13:34:39 +000073 prop = fdt_getprop(blob, path, "interrupts",
74 NULL);
Kim Phillips3b1b1442009-10-12 11:06:19 -050075 if (prop)
76 fdt_setprop(blob, path, "interrupts",
77 &tmp, sizeof(tmp));
78 }
79#endif
80#if defined(CONFIG_HAS_ETH1)
81 prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL);
82 if (prop) {
83 u32 tmp[] = { 35, 0x8, 36, 0x8, 37, 0x8 };
84
85 path = fdt_path_offset(blob, prop);
Kim Phillipsb5c312a2012-10-29 13:34:39 +000086 prop = fdt_getprop(blob, path, "interrupts",
87 NULL);
Kim Phillips3b1b1442009-10-12 11:06:19 -050088 if (prop)
89 fdt_setprop(blob, path, "interrupts",
90 &tmp, sizeof(tmp));
91 }
92#endif
93 }
94 }
95#endif
Kim Phillipsfd47a742007-12-20 14:09:22 -060096#endif
97
98 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
99 "timebase-frequency", (bd->bi_busfreq / 4), 1);
100 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
101 "bus-frequency", bd->bi_busfreq, 1);
102 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
Simon Glasscc76e9e2012-12-13 20:48:47 +0000103 "clock-frequency", gd->arch.core_clk, 1);
Kim Phillipsfd47a742007-12-20 14:09:22 -0600104 do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
105 "bus-frequency", bd->bi_busfreq, 1);
Anton Vorontsov3114a9b2008-03-24 20:47:09 +0300106 do_fixup_by_compat_u32(blob, "fsl,soc",
107 "bus-frequency", bd->bi_busfreq, 1);
108 do_fixup_by_compat_u32(blob, "fsl,soc",
109 "clock-frequency", bd->bi_busfreq, 1);
110 do_fixup_by_compat_u32(blob, "fsl,immr",
111 "bus-frequency", bd->bi_busfreq, 1);
112 do_fixup_by_compat_u32(blob, "fsl,immr",
113 "clock-frequency", bd->bi_busfreq, 1);
Kim Phillipsfd47a742007-12-20 14:09:22 -0600114#ifdef CONFIG_QE
Kumar Gala1f164482008-01-17 08:25:45 -0600115 ft_qe_setup(blob);
Kim Phillipsfd47a742007-12-20 14:09:22 -0600116#endif
117
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200118#ifdef CONFIG_SYS_NS16550
Mario Sixa3a8d0c2019-01-21 09:18:06 +0100119 do_fixup_by_compat_u32(blob, "ns16550",
120 "clock-frequency", get_serial_clock(), 1);
Kim Phillipsfd47a742007-12-20 14:09:22 -0600121#endif
122
Kim Phillipsfd47a742007-12-20 14:09:22 -0600123 fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
Heiko Schocherd2c4f3a2009-02-24 11:30:51 +0100124
Heiko Schocher04e3b3a2014-01-25 07:53:47 +0100125#if defined(CONFIG_BOOTCOUNT_LIMIT) && \
Mario Six9164bdd2019-01-21 09:17:25 +0100126 (defined(CONFIG_QE) && !defined(CONFIG_ARCH_MPC831X))
Heiko Schocherd2c4f3a2009-02-24 11:30:51 +0100127 fdt_fixup_muram (blob);
128#endif
Kim Phillipsfd47a742007-12-20 14:09:22 -0600129}