Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2007 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * (C) Copyright 2000 |
| 5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 6 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 11 | #include <linux/libfdt.h> |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 12 | #include <fdt_support.h> |
Kim Phillips | 868e346 | 2008-06-16 15:55:53 -0500 | [diff] [blame] | 13 | #include <asm/processor.h> |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 14 | |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 15 | extern void ft_qe_setup(void *blob); |
| 16 | |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
Heiko Schocher | 466924f | 2010-02-18 08:08:25 +0100 | [diff] [blame] | 19 | #if defined(CONFIG_BOOTCOUNT_LIMIT) && \ |
Heiko Schocher | 04e3b3a | 2014-01-25 07:53:47 +0100 | [diff] [blame] | 20 | (defined(CONFIG_QE) && !defined(CONFIG_MPC831x)) |
Zhao Qiang | 978679d | 2014-06-03 16:27:07 +0800 | [diff] [blame] | 21 | #include <linux/immap_qe.h> |
Heiko Schocher | d2c4f3a | 2009-02-24 11:30:51 +0100 | [diff] [blame] | 22 | |
| 23 | void 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 Schocher | 0b00074 | 2009-04-24 06:50:45 +0200 | [diff] [blame] | 29 | do_fixup_by_compat(blob, "fsl,qe-muram-data", "reg", |
| 30 | data, sizeof (data), 0); |
Heiko Schocher | d2c4f3a | 2009-02-24 11:30:51 +0100 | [diff] [blame] | 31 | } |
| 32 | #endif |
| 33 | |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 34 | void ft_cpu_setup(void *blob, bd_t *bd) |
| 35 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 36 | immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; |
Kim Phillips | 868e346 | 2008-06-16 15:55:53 -0500 | [diff] [blame] | 37 | 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 Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 53 | #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\ |
richardretanubun | e5167f1 | 2008-09-29 18:28:23 -0400 | [diff] [blame] | 54 | defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3) ||\ |
| 55 | defined(CONFIG_HAS_ETH4) || defined(CONFIG_HAS_ETH5) |
Kim Phillips | 3b1b144 | 2009-10-12 11:06:19 -0500 | [diff] [blame] | 56 | #ifdef CONFIG_MPC8313 |
| 57 | /* |
| 58 | * mpc8313e erratum IPIC1 swapped TSEC interrupt ID numbers on rev. 1 |
| 59 | * h/w (see AN3545). The base device tree in use has rev. 1 ID numbers, |
| 60 | * so if on Rev. 2 (and higher) h/w, we fix them up here |
| 61 | */ |
| 62 | if (REVID_MAJOR(immr->sysconf.spridr) >= 2) { |
| 63 | int nodeoffset, path; |
| 64 | const char *prop; |
| 65 | |
| 66 | nodeoffset = fdt_path_offset(blob, "/aliases"); |
| 67 | if (nodeoffset >= 0) { |
| 68 | #if defined(CONFIG_HAS_ETH0) |
| 69 | prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL); |
| 70 | if (prop) { |
| 71 | u32 tmp[] = { 32, 0x8, 33, 0x8, 34, 0x8 }; |
| 72 | |
| 73 | path = fdt_path_offset(blob, prop); |
Kim Phillips | b5c312a | 2012-10-29 13:34:39 +0000 | [diff] [blame] | 74 | prop = fdt_getprop(blob, path, "interrupts", |
| 75 | NULL); |
Kim Phillips | 3b1b144 | 2009-10-12 11:06:19 -0500 | [diff] [blame] | 76 | if (prop) |
| 77 | fdt_setprop(blob, path, "interrupts", |
| 78 | &tmp, sizeof(tmp)); |
| 79 | } |
| 80 | #endif |
| 81 | #if defined(CONFIG_HAS_ETH1) |
| 82 | prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL); |
| 83 | if (prop) { |
| 84 | u32 tmp[] = { 35, 0x8, 36, 0x8, 37, 0x8 }; |
| 85 | |
| 86 | path = fdt_path_offset(blob, prop); |
Kim Phillips | b5c312a | 2012-10-29 13:34:39 +0000 | [diff] [blame] | 87 | prop = fdt_getprop(blob, path, "interrupts", |
| 88 | NULL); |
Kim Phillips | 3b1b144 | 2009-10-12 11:06:19 -0500 | [diff] [blame] | 89 | if (prop) |
| 90 | fdt_setprop(blob, path, "interrupts", |
| 91 | &tmp, sizeof(tmp)); |
| 92 | } |
| 93 | #endif |
| 94 | } |
| 95 | } |
| 96 | #endif |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 97 | #endif |
| 98 | |
| 99 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, |
| 100 | "timebase-frequency", (bd->bi_busfreq / 4), 1); |
| 101 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, |
| 102 | "bus-frequency", bd->bi_busfreq, 1); |
| 103 | do_fixup_by_prop_u32(blob, "device_type", "cpu", 4, |
Simon Glass | cc76e9e | 2012-12-13 20:48:47 +0000 | [diff] [blame] | 104 | "clock-frequency", gd->arch.core_clk, 1); |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 105 | do_fixup_by_prop_u32(blob, "device_type", "soc", 4, |
| 106 | "bus-frequency", bd->bi_busfreq, 1); |
Anton Vorontsov | 3114a9b | 2008-03-24 20:47:09 +0300 | [diff] [blame] | 107 | do_fixup_by_compat_u32(blob, "fsl,soc", |
| 108 | "bus-frequency", bd->bi_busfreq, 1); |
| 109 | do_fixup_by_compat_u32(blob, "fsl,soc", |
| 110 | "clock-frequency", bd->bi_busfreq, 1); |
| 111 | do_fixup_by_compat_u32(blob, "fsl,immr", |
| 112 | "bus-frequency", bd->bi_busfreq, 1); |
| 113 | do_fixup_by_compat_u32(blob, "fsl,immr", |
| 114 | "clock-frequency", bd->bi_busfreq, 1); |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 115 | #ifdef CONFIG_QE |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 116 | ft_qe_setup(blob); |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 117 | #endif |
| 118 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 119 | #ifdef CONFIG_SYS_NS16550 |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 120 | do_fixup_by_compat_u32(blob, "ns16550", |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 121 | "clock-frequency", CONFIG_SYS_NS16550_CLK, 1); |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 122 | #endif |
| 123 | |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 124 | fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize); |
Heiko Schocher | d2c4f3a | 2009-02-24 11:30:51 +0100 | [diff] [blame] | 125 | |
Heiko Schocher | 04e3b3a | 2014-01-25 07:53:47 +0100 | [diff] [blame] | 126 | #if defined(CONFIG_BOOTCOUNT_LIMIT) && \ |
| 127 | (defined(CONFIG_QE) && !defined(CONFIG_MPC831x)) |
Heiko Schocher | d2c4f3a | 2009-02-24 11:30:51 +0100 | [diff] [blame] | 128 | fdt_fixup_muram (blob); |
| 129 | #endif |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 130 | } |