blob: cce7d6b265e6a51cc676f1431aed175180aaba64 [file] [log] [blame]
Kim Phillips5b8bc602007-12-20 14:09:22 -06001/*
2 * Copyright 2007 Freescale Semiconductor, Inc.
3 *
4 * (C) Copyright 2000
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Kim Phillips5b8bc602007-12-20 14:09:22 -06008 */
9
10#include <common.h>
Kim Phillips5b8bc602007-12-20 14:09:22 -060011#include <libfdt.h>
12#include <fdt_support.h>
Kim Phillips6b70ffb2008-06-16 15:55:53 -050013#include <asm/processor.h>
Kim Phillips5b8bc602007-12-20 14:09:22 -060014
Kumar Gala69018ce2008-01-17 08:25:45 -060015extern void ft_qe_setup(void *blob);
16
Kim Phillips5b8bc602007-12-20 14:09:22 -060017DECLARE_GLOBAL_DATA_PTR;
18
Heiko Schocher62ddcf02010-02-18 08:08:25 +010019#if defined(CONFIG_BOOTCOUNT_LIMIT) && \
20 (defined(CONFIG_QE))
Heiko Schocherf70fd132009-02-24 11:30:51 +010021#include <asm/immap_qe.h>
22
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 Schocher14b93082009-04-24 06:50:45 +020029 do_fixup_by_compat(blob, "fsl,qe-muram-data", "reg",
30 data, sizeof (data), 0);
Heiko Schocherf70fd132009-02-24 11:30:51 +010031}
32#endif
33
Kim Phillips5b8bc602007-12-20 14:09:22 -060034void ft_cpu_setup(void *blob, bd_t *bd)
35{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020036 immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
Kim Phillips6b70ffb2008-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
Kim Phillips5b8bc602007-12-20 14:09:22 -060053#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
richardretanubunc68a05f2008-09-29 18:28:23 -040054 defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3) ||\
55 defined(CONFIG_HAS_ETH4) || defined(CONFIG_HAS_ETH5)
Kumar Galaba37aa02008-08-19 15:41:18 -050056 fdt_fixup_ethernet(blob);
Kim Phillips7120c882009-10-12 11:06:19 -050057#ifdef CONFIG_MPC8313
58 /*
59 * mpc8313e erratum IPIC1 swapped TSEC interrupt ID numbers on rev. 1
60 * h/w (see AN3545). The base device tree in use has rev. 1 ID numbers,
61 * so if on Rev. 2 (and higher) h/w, we fix them up here
62 */
63 if (REVID_MAJOR(immr->sysconf.spridr) >= 2) {
64 int nodeoffset, path;
65 const char *prop;
66
67 nodeoffset = fdt_path_offset(blob, "/aliases");
68 if (nodeoffset >= 0) {
69#if defined(CONFIG_HAS_ETH0)
70 prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL);
71 if (prop) {
72 u32 tmp[] = { 32, 0x8, 33, 0x8, 34, 0x8 };
73
74 path = fdt_path_offset(blob, prop);
Kim Phillipsa2873bd2012-10-29 13:34:39 +000075 prop = fdt_getprop(blob, path, "interrupts",
76 NULL);
Kim Phillips7120c882009-10-12 11:06:19 -050077 if (prop)
78 fdt_setprop(blob, path, "interrupts",
79 &tmp, sizeof(tmp));
80 }
81#endif
82#if defined(CONFIG_HAS_ETH1)
83 prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL);
84 if (prop) {
85 u32 tmp[] = { 35, 0x8, 36, 0x8, 37, 0x8 };
86
87 path = fdt_path_offset(blob, prop);
Kim Phillipsa2873bd2012-10-29 13:34:39 +000088 prop = fdt_getprop(blob, path, "interrupts",
89 NULL);
Kim Phillips7120c882009-10-12 11:06:19 -050090 if (prop)
91 fdt_setprop(blob, path, "interrupts",
92 &tmp, sizeof(tmp));
93 }
94#endif
95 }
96 }
97#endif
Kim Phillips5b8bc602007-12-20 14:09:22 -060098#endif
99
100 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
101 "timebase-frequency", (bd->bi_busfreq / 4), 1);
102 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
103 "bus-frequency", bd->bi_busfreq, 1);
104 do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
Simon Glassc6731fe2012-12-13 20:48:47 +0000105 "clock-frequency", gd->arch.core_clk, 1);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600106 do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
107 "bus-frequency", bd->bi_busfreq, 1);
Anton Vorontsov7fa9cbb2008-03-24 20:47:09 +0300108 do_fixup_by_compat_u32(blob, "fsl,soc",
109 "bus-frequency", bd->bi_busfreq, 1);
110 do_fixup_by_compat_u32(blob, "fsl,soc",
111 "clock-frequency", bd->bi_busfreq, 1);
112 do_fixup_by_compat_u32(blob, "fsl,immr",
113 "bus-frequency", bd->bi_busfreq, 1);
114 do_fixup_by_compat_u32(blob, "fsl,immr",
115 "clock-frequency", bd->bi_busfreq, 1);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600116#ifdef CONFIG_QE
Kumar Gala69018ce2008-01-17 08:25:45 -0600117 ft_qe_setup(blob);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600118#endif
119
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200120#ifdef CONFIG_SYS_NS16550
Kim Phillips5b8bc602007-12-20 14:09:22 -0600121 do_fixup_by_compat_u32(blob, "ns16550",
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200122 "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600123#endif
124
Kim Phillips5b8bc602007-12-20 14:09:22 -0600125 fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
Heiko Schocherf70fd132009-02-24 11:30:51 +0100126
127#if defined(CONFIG_BOOTCOUNT_LIMIT)
128 fdt_fixup_muram (blob);
129#endif
Kim Phillips5b8bc602007-12-20 14:09:22 -0600130}