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