2007-11-29 06:15:30 +00:00
|
|
|
/*
|
2010-12-30 18:09:53 +00:00
|
|
|
* Copyright 2007-2011 Freescale Semiconductor, Inc.
|
2007-11-29 06:15:30 +00:00
|
|
|
*
|
|
|
|
* (C) Copyright 2000
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2007-11-29 06:15:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <libfdt.h>
|
|
|
|
#include <fdt_support.h>
|
2008-05-29 16:22:06 +00:00
|
|
|
#include <asm/processor.h>
|
2009-09-22 07:18:27 +00:00
|
|
|
#include <linux/ctype.h>
|
2009-03-19 08:40:08 +00:00
|
|
|
#include <asm/io.h>
|
2015-08-28 02:31:50 +00:00
|
|
|
#include <asm/fsl_fdt.h>
|
2009-09-10 08:02:13 +00:00
|
|
|
#include <asm/fsl_portals.h>
|
2014-06-05 13:19:57 +00:00
|
|
|
#include <hwconfig.h>
|
2009-09-02 05:55:08 +00:00
|
|
|
#ifdef CONFIG_FSL_ESDHC
|
|
|
|
#include <fsl_esdhc.h>
|
|
|
|
#endif
|
2016-02-18 05:02:00 +00:00
|
|
|
#ifdef CONFIG_SYS_DPAA_FMAN
|
|
|
|
#include <fsl_fman.h>
|
|
|
|
#endif
|
2007-11-29 06:15:30 +00:00
|
|
|
|
mpc8[56]xx: Put localbus clock in device tree
Export the localbus frequency in the device tree, the same way the CPU, TB,
CCB, and various other frequencies are exported in their respective device
tree nodes.
Some localbus devices need this information to be programed correctly, so
it makes sense to export it along with the other frequencies.
Unfortunately, when someone wrote the localbus dts bindings, they didn't
bother to define what the "compatible" property should be. So it seems no
one was quite sure what to put in their dts files.
Based on current existing dts files in the kernel source, I've used
"fsl,pq3-localbus" and "fsl,elbc" for MPC85xx, which are used by almost all
of the 85xx devices, and are looked for by the Linux code. The eLBC is
apparently not entirely backward compatible with the pq3 LBC and so eLBC
equipped platforms like 8572 won't use pq3-localbus.
For MPC86xx, I've used "fsl,elbc" which is used by some of the 86xx systems
and is also looked for by the Linux code. On MPC8641, I've also used
"fsl,mpc8641-localbus" as it is also commonly used in dts files, some of
which don't use "fsl,elbc" or any other acceptable name to match on.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Jon Loeliger <jdl@freescale.com>
2008-12-03 23:16:38 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2008-01-17 14:25:45 +00:00
|
|
|
extern void ft_qe_setup(void *blob);
|
2009-09-02 14:10:36 +00:00
|
|
|
extern void ft_fixup_num_cores(void *blob);
|
2010-12-30 18:09:53 +00:00
|
|
|
extern void ft_srio_setup(void *blob);
|
2008-06-16 20:55:53 +00:00
|
|
|
|
2008-01-17 22:48:33 +00:00
|
|
|
#ifdef CONFIG_MP
|
|
|
|
#include "mp.h"
|
|
|
|
|
|
|
|
void ft_fixup_cpu(void *blob, u64 memory_limit)
|
|
|
|
{
|
|
|
|
int off;
|
2012-10-08 07:44:30 +00:00
|
|
|
phys_addr_t spin_tbl_addr = get_spin_phys_addr();
|
2012-10-08 07:44:25 +00:00
|
|
|
u32 bootpg = determine_mp_bootpg(NULL);
|
2009-04-01 04:11:05 +00:00
|
|
|
u32 id = get_my_id();
|
2010-09-30 17:22:16 +00:00
|
|
|
const char *enable_method;
|
2014-06-05 13:19:57 +00:00
|
|
|
#if defined(T1040_TDM_QUIRK_CCSR_BASE)
|
|
|
|
int ret;
|
|
|
|
int tdm_hwconfig_enabled = 0;
|
|
|
|
char buffer[HWCONFIG_BUFFER_SIZE] = {0};
|
|
|
|
#endif
|
2008-01-17 22:48:33 +00:00
|
|
|
|
|
|
|
off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
|
|
|
|
while (off != -FDT_ERR_NOTFOUND) {
|
|
|
|
u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
|
|
|
|
|
|
|
|
if (reg) {
|
2012-08-17 08:20:26 +00:00
|
|
|
u32 phys_cpu_id = thread_to_core(*reg);
|
|
|
|
u64 val = phys_cpu_id * SIZE_BOOT_ENTRY + spin_tbl_addr;
|
|
|
|
val = cpu_to_fdt64(val);
|
2008-01-17 22:48:33 +00:00
|
|
|
if (*reg == id) {
|
2010-08-19 18:57:48 +00:00
|
|
|
fdt_setprop_string(blob, off, "status",
|
|
|
|
"okay");
|
2008-01-17 22:48:33 +00:00
|
|
|
} else {
|
|
|
|
fdt_setprop_string(blob, off, "status",
|
|
|
|
"disabled");
|
|
|
|
}
|
2010-09-30 17:22:16 +00:00
|
|
|
|
|
|
|
if (hold_cores_in_reset(0)) {
|
|
|
|
#ifdef CONFIG_FSL_CORENET
|
|
|
|
/* Cores held in reset, use BRR to release */
|
|
|
|
enable_method = "fsl,brr-holdoff";
|
|
|
|
#else
|
|
|
|
/* Cores held in reset, use EEBPCR to release */
|
|
|
|
enable_method = "fsl,eebpcr-holdoff";
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
/* Cores out of reset and in a spin-loop */
|
|
|
|
enable_method = "spin-table";
|
|
|
|
|
|
|
|
fdt_setprop(blob, off, "cpu-release-addr",
|
|
|
|
&val, sizeof(val));
|
|
|
|
}
|
|
|
|
|
2010-08-19 18:57:48 +00:00
|
|
|
fdt_setprop_string(blob, off, "enable-method",
|
2010-09-30 17:22:16 +00:00
|
|
|
enable_method);
|
2008-01-17 22:48:33 +00:00
|
|
|
} else {
|
|
|
|
printf ("cpu NULL\n");
|
|
|
|
}
|
|
|
|
off = fdt_node_offset_by_prop_value(blob, off,
|
|
|
|
"device_type", "cpu", 4);
|
|
|
|
}
|
|
|
|
|
2014-06-05 13:19:57 +00:00
|
|
|
#if defined(T1040_TDM_QUIRK_CCSR_BASE)
|
|
|
|
#define CONFIG_MEM_HOLE_16M 0x1000000
|
|
|
|
/*
|
|
|
|
* Extract hwconfig from environment.
|
|
|
|
* Search for tdm entry in hwconfig.
|
|
|
|
*/
|
|
|
|
ret = getenv_f("hwconfig", buffer, sizeof(buffer));
|
|
|
|
if (ret > 0)
|
|
|
|
tdm_hwconfig_enabled = hwconfig_f("tdm", buffer);
|
|
|
|
|
|
|
|
/* Reserve the memory hole created by TDM LAW, so OSes dont use it */
|
|
|
|
if (tdm_hwconfig_enabled) {
|
|
|
|
off = fdt_add_mem_rsv(blob, T1040_TDM_QUIRK_CCSR_BASE,
|
|
|
|
CONFIG_MEM_HOLE_16M);
|
|
|
|
if (off < 0)
|
|
|
|
printf("Failed to reserve memory for tdm: %s\n",
|
|
|
|
fdt_strerror(off));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-01-17 22:48:33 +00:00
|
|
|
/* Reserve the boot page so OSes dont use it */
|
|
|
|
if ((u64)bootpg < memory_limit) {
|
|
|
|
off = fdt_add_mem_rsv(blob, bootpg, (u64)4096);
|
|
|
|
if (off < 0)
|
2012-10-08 07:44:30 +00:00
|
|
|
printf("Failed to reserve memory for bootpg: %s\n",
|
|
|
|
fdt_strerror(off));
|
|
|
|
}
|
2012-12-14 06:21:58 +00:00
|
|
|
|
|
|
|
#ifndef CONFIG_MPC8xxx_DISABLE_BPTR
|
|
|
|
/*
|
|
|
|
* Reserve the default boot page so OSes dont use it.
|
|
|
|
* The default boot page is always mapped to bootpg above using
|
|
|
|
* boot page translation.
|
|
|
|
*/
|
|
|
|
if (0xfffff000ull < memory_limit) {
|
|
|
|
off = fdt_add_mem_rsv(blob, 0xfffff000ull, (u64)4096);
|
|
|
|
if (off < 0) {
|
|
|
|
printf("Failed to reserve memory for 0xfffff000: %s\n",
|
|
|
|
fdt_strerror(off));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-10-08 07:44:30 +00:00
|
|
|
/* Reserve spin table page */
|
|
|
|
if (spin_tbl_addr < memory_limit) {
|
|
|
|
off = fdt_add_mem_rsv(blob,
|
|
|
|
(spin_tbl_addr & ~0xffful), 4096);
|
|
|
|
if (off < 0)
|
|
|
|
printf("Failed to reserve memory for spin table: %s\n",
|
|
|
|
fdt_strerror(off));
|
2008-01-17 22:48:33 +00:00
|
|
|
}
|
2014-07-23 09:27:53 +00:00
|
|
|
#ifdef CONFIG_DEEP_SLEEP
|
|
|
|
#ifdef CONFIG_SPL_MMC_BOOT
|
|
|
|
off = fdt_add_mem_rsv(blob, CONFIG_SYS_MMC_U_BOOT_START,
|
|
|
|
CONFIG_SYS_MMC_U_BOOT_SIZE);
|
|
|
|
if (off < 0)
|
|
|
|
printf("Failed to reserve memory for SD deep sleep: %s\n",
|
|
|
|
fdt_strerror(off));
|
|
|
|
#elif defined(CONFIG_SPL_SPI_BOOT)
|
|
|
|
off = fdt_add_mem_rsv(blob, CONFIG_SYS_SPI_FLASH_U_BOOT_START,
|
|
|
|
CONFIG_SYS_SPI_FLASH_U_BOOT_SIZE);
|
|
|
|
if (off < 0)
|
|
|
|
printf("Failed to reserve memory for SPI deep sleep: %s\n",
|
|
|
|
fdt_strerror(off));
|
|
|
|
#endif
|
|
|
|
#endif
|
2008-01-17 22:48:33 +00:00
|
|
|
}
|
|
|
|
#endif
|
2008-01-17 14:25:45 +00:00
|
|
|
|
2009-03-19 08:40:08 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_CPC
|
|
|
|
static inline void ft_fixup_l3cache(void *blob, int off)
|
|
|
|
{
|
|
|
|
u32 line_size, num_ways, size, num_sets;
|
|
|
|
cpc_corenet_t *cpc = (void *)CONFIG_SYS_FSL_CPC_ADDR;
|
|
|
|
u32 cfg0 = in_be32(&cpc->cpccfg0);
|
|
|
|
|
|
|
|
size = CPC_CFG0_SZ_K(cfg0) * 1024 * CONFIG_SYS_NUM_CPC;
|
|
|
|
num_ways = CPC_CFG0_NUM_WAYS(cfg0);
|
|
|
|
line_size = CPC_CFG0_LINE_SZ(cfg0);
|
|
|
|
num_sets = size / (line_size * num_ways);
|
|
|
|
|
|
|
|
fdt_setprop(blob, off, "cache-unified", NULL, 0);
|
|
|
|
fdt_setprop_cell(blob, off, "cache-block-size", line_size);
|
|
|
|
fdt_setprop_cell(blob, off, "cache-size", size);
|
|
|
|
fdt_setprop_cell(blob, off, "cache-sets", num_sets);
|
|
|
|
fdt_setprop_cell(blob, off, "cache-level", 3);
|
|
|
|
#ifdef CONFIG_SYS_CACHE_STASHING
|
|
|
|
fdt_setprop_cell(blob, off, "cache-stash-id", 1);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#else
|
2009-03-19 14:16:10 +00:00
|
|
|
#define ft_fixup_l3cache(x, y)
|
2009-03-19 08:40:08 +00:00
|
|
|
#endif
|
2009-03-19 14:16:10 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_L2_CACHE)
|
2008-05-29 16:22:06 +00:00
|
|
|
/* return size in kilobytes */
|
|
|
|
static inline u32 l2cache_size(void)
|
|
|
|
{
|
2008-10-16 13:01:15 +00:00
|
|
|
volatile ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR;
|
2008-05-29 16:22:06 +00:00
|
|
|
volatile u32 l2siz_field = (l2cache->l2ctl >> 28) & 0x3;
|
|
|
|
u32 ver = SVR_SOC_VER(get_svr());
|
|
|
|
|
|
|
|
switch (l2siz_field) {
|
|
|
|
case 0x0:
|
|
|
|
break;
|
|
|
|
case 0x1:
|
|
|
|
if (ver == SVR_8540 || ver == SVR_8560 ||
|
2012-07-06 22:10:33 +00:00
|
|
|
ver == SVR_8541 || ver == SVR_8555)
|
2008-05-29 16:22:06 +00:00
|
|
|
return 128;
|
|
|
|
else
|
|
|
|
return 256;
|
|
|
|
break;
|
|
|
|
case 0x2:
|
|
|
|
if (ver == SVR_8540 || ver == SVR_8560 ||
|
2012-07-06 22:10:33 +00:00
|
|
|
ver == SVR_8541 || ver == SVR_8555)
|
2008-05-29 16:22:06 +00:00
|
|
|
return 256;
|
|
|
|
else
|
|
|
|
return 512;
|
|
|
|
break;
|
|
|
|
case 0x3:
|
|
|
|
return 1024;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ft_fixup_l2cache(void *blob)
|
|
|
|
{
|
|
|
|
int len, off;
|
|
|
|
u32 *ph;
|
|
|
|
struct cpu_type *cpu = identify_cpu(SVR_SOC_VER(get_svr()));
|
|
|
|
|
|
|
|
const u32 line_size = 32;
|
|
|
|
const u32 num_ways = 8;
|
|
|
|
const u32 size = l2cache_size() * 1024;
|
|
|
|
const u32 num_sets = size / (line_size * num_ways);
|
|
|
|
|
|
|
|
off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
|
|
|
|
if (off < 0) {
|
|
|
|
debug("no cpu node fount\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ph = (u32 *)fdt_getprop(blob, off, "next-level-cache", 0);
|
|
|
|
|
|
|
|
if (ph == NULL) {
|
|
|
|
debug("no next-level-cache property\n");
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
off = fdt_node_offset_by_phandle(blob, *ph);
|
|
|
|
if (off < 0) {
|
|
|
|
printf("%s: %s\n", __func__, fdt_strerror(off));
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cpu) {
|
2011-04-29 23:08:44 +00:00
|
|
|
char buf[40];
|
|
|
|
|
|
|
|
if (isdigit(cpu->name[0])) {
|
|
|
|
/* MPCxxxx, where xxxx == 4-digit number */
|
|
|
|
len = sprintf(buf, "fsl,mpc%s-l2-cache-controller",
|
|
|
|
cpu->name) + 1;
|
|
|
|
} else {
|
|
|
|
/* Pxxxx or Txxxx, where xxxx == 4-digit number */
|
|
|
|
len = sprintf(buf, "fsl,%c%s-l2-cache-controller",
|
|
|
|
tolower(cpu->name[0]), cpu->name + 1) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* append "cache" after the NULL character that the previous
|
|
|
|
* sprintf wrote. This is how a device tree stores multiple
|
|
|
|
* strings in a property.
|
|
|
|
*/
|
|
|
|
len += sprintf(buf + len, "cache") + 1;
|
2009-09-22 07:18:27 +00:00
|
|
|
|
2011-04-29 23:08:44 +00:00
|
|
|
fdt_setprop(blob, off, "compatible", buf, len);
|
2008-05-29 16:22:06 +00:00
|
|
|
}
|
|
|
|
fdt_setprop(blob, off, "cache-unified", NULL, 0);
|
|
|
|
fdt_setprop_cell(blob, off, "cache-block-size", line_size);
|
|
|
|
fdt_setprop_cell(blob, off, "cache-size", size);
|
|
|
|
fdt_setprop_cell(blob, off, "cache-sets", num_sets);
|
|
|
|
fdt_setprop_cell(blob, off, "cache-level", 2);
|
2009-03-19 14:16:10 +00:00
|
|
|
|
|
|
|
/* we dont bother w/L3 since no platform of this type has one */
|
|
|
|
}
|
2012-10-08 07:44:08 +00:00
|
|
|
#elif defined(CONFIG_BACKSIDE_L2_CACHE) || \
|
|
|
|
defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2)
|
2009-03-19 14:16:10 +00:00
|
|
|
static inline void ft_fixup_l2cache(void *blob)
|
|
|
|
{
|
|
|
|
int off, l2_off, l3_off = -1;
|
|
|
|
u32 *ph;
|
2012-10-08 07:44:08 +00:00
|
|
|
#ifdef CONFIG_BACKSIDE_L2_CACHE
|
2009-03-19 14:16:10 +00:00
|
|
|
u32 l2cfg0 = mfspr(SPRN_L2CFG0);
|
2012-10-08 07:44:08 +00:00
|
|
|
#else
|
|
|
|
struct ccsr_cluster_l2 *l2cache =
|
|
|
|
(struct ccsr_cluster_l2 __iomem *)(CONFIG_SYS_FSL_CLUSTER_1_L2);
|
|
|
|
u32 l2cfg0 = in_be32(&l2cache->l2cfg0);
|
|
|
|
#endif
|
2009-03-19 14:16:10 +00:00
|
|
|
u32 size, line_size, num_ways, num_sets;
|
2011-07-21 05:20:21 +00:00
|
|
|
int has_l2 = 1;
|
|
|
|
|
|
|
|
/* P2040/P2040E has no L2, so dont set any L2 props */
|
2012-07-06 22:10:33 +00:00
|
|
|
if (SVR_SOC_VER(get_svr()) == SVR_P2040)
|
2011-07-21 05:20:21 +00:00
|
|
|
has_l2 = 0;
|
2009-03-19 14:16:10 +00:00
|
|
|
|
|
|
|
size = (l2cfg0 & 0x3fff) * 64 * 1024;
|
|
|
|
num_ways = ((l2cfg0 >> 14) & 0x1f) + 1;
|
|
|
|
line_size = (((l2cfg0 >> 23) & 0x3) + 1) * 32;
|
|
|
|
num_sets = size / (line_size * num_ways);
|
|
|
|
|
|
|
|
off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
|
|
|
|
|
|
|
|
while (off != -FDT_ERR_NOTFOUND) {
|
|
|
|
ph = (u32 *)fdt_getprop(blob, off, "next-level-cache", 0);
|
|
|
|
|
|
|
|
if (ph == NULL) {
|
|
|
|
debug("no next-level-cache property\n");
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
|
|
|
l2_off = fdt_node_offset_by_phandle(blob, *ph);
|
|
|
|
if (l2_off < 0) {
|
|
|
|
printf("%s: %s\n", __func__, fdt_strerror(off));
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
2011-07-21 05:20:21 +00:00
|
|
|
if (has_l2) {
|
2009-03-19 07:53:01 +00:00
|
|
|
#ifdef CONFIG_SYS_CACHE_STASHING
|
|
|
|
u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
|
2013-08-29 07:40:38 +00:00
|
|
|
#if defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2) && defined(CONFIG_E6500)
|
2012-10-08 07:44:08 +00:00
|
|
|
/* Only initialize every eighth thread */
|
2014-03-27 01:30:56 +00:00
|
|
|
if (reg && !((*reg) % 8)) {
|
|
|
|
fdt_setprop_cell(blob, l2_off, "cache-stash-id",
|
|
|
|
(*reg / 4) + 32 + 1);
|
|
|
|
}
|
2012-10-08 07:44:08 +00:00
|
|
|
#else
|
2014-03-27 01:30:56 +00:00
|
|
|
if (reg) {
|
2009-03-19 07:53:01 +00:00
|
|
|
fdt_setprop_cell(blob, l2_off, "cache-stash-id",
|
2014-03-27 01:30:56 +00:00
|
|
|
(*reg * 2) + 32 + 1);
|
|
|
|
}
|
|
|
|
#endif
|
2009-03-19 07:53:01 +00:00
|
|
|
#endif
|
|
|
|
|
2011-07-21 05:20:21 +00:00
|
|
|
fdt_setprop(blob, l2_off, "cache-unified", NULL, 0);
|
|
|
|
fdt_setprop_cell(blob, l2_off, "cache-block-size",
|
|
|
|
line_size);
|
|
|
|
fdt_setprop_cell(blob, l2_off, "cache-size", size);
|
|
|
|
fdt_setprop_cell(blob, l2_off, "cache-sets", num_sets);
|
|
|
|
fdt_setprop_cell(blob, l2_off, "cache-level", 2);
|
|
|
|
fdt_setprop(blob, l2_off, "compatible", "cache", 6);
|
|
|
|
}
|
2009-03-19 14:16:10 +00:00
|
|
|
|
|
|
|
if (l3_off < 0) {
|
|
|
|
ph = (u32 *)fdt_getprop(blob, l2_off, "next-level-cache", 0);
|
|
|
|
|
|
|
|
if (ph == NULL) {
|
|
|
|
debug("no next-level-cache property\n");
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
l3_off = *ph;
|
|
|
|
}
|
|
|
|
next:
|
|
|
|
off = fdt_node_offset_by_prop_value(blob, off,
|
|
|
|
"device_type", "cpu", 4);
|
|
|
|
}
|
|
|
|
if (l3_off > 0) {
|
|
|
|
l3_off = fdt_node_offset_by_phandle(blob, l3_off);
|
|
|
|
if (l3_off < 0) {
|
|
|
|
printf("%s: %s\n", __func__, fdt_strerror(off));
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
ft_fixup_l3cache(blob, l3_off);
|
|
|
|
}
|
2008-05-29 16:22:06 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define ft_fixup_l2cache(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline void ft_fixup_cache(void *blob)
|
|
|
|
{
|
|
|
|
int off;
|
|
|
|
|
|
|
|
off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
|
|
|
|
|
|
|
|
while (off != -FDT_ERR_NOTFOUND) {
|
|
|
|
u32 l1cfg0 = mfspr(SPRN_L1CFG0);
|
|
|
|
u32 l1cfg1 = mfspr(SPRN_L1CFG1);
|
|
|
|
u32 isize, iline_size, inum_sets, inum_ways;
|
|
|
|
u32 dsize, dline_size, dnum_sets, dnum_ways;
|
|
|
|
|
|
|
|
/* d-side config */
|
|
|
|
dsize = (l1cfg0 & 0x7ff) * 1024;
|
|
|
|
dnum_ways = ((l1cfg0 >> 11) & 0xff) + 1;
|
|
|
|
dline_size = (((l1cfg0 >> 23) & 0x3) + 1) * 32;
|
|
|
|
dnum_sets = dsize / (dline_size * dnum_ways);
|
|
|
|
|
|
|
|
fdt_setprop_cell(blob, off, "d-cache-block-size", dline_size);
|
|
|
|
fdt_setprop_cell(blob, off, "d-cache-size", dsize);
|
|
|
|
fdt_setprop_cell(blob, off, "d-cache-sets", dnum_sets);
|
|
|
|
|
2009-03-19 07:53:01 +00:00
|
|
|
#ifdef CONFIG_SYS_CACHE_STASHING
|
|
|
|
{
|
|
|
|
u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
|
|
|
|
if (reg)
|
|
|
|
fdt_setprop_cell(blob, off, "cache-stash-id",
|
|
|
|
(*reg * 2) + 32 + 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-05-29 16:22:06 +00:00
|
|
|
/* i-side config */
|
|
|
|
isize = (l1cfg1 & 0x7ff) * 1024;
|
|
|
|
inum_ways = ((l1cfg1 >> 11) & 0xff) + 1;
|
|
|
|
iline_size = (((l1cfg1 >> 23) & 0x3) + 1) * 32;
|
|
|
|
inum_sets = isize / (iline_size * inum_ways);
|
|
|
|
|
|
|
|
fdt_setprop_cell(blob, off, "i-cache-block-size", iline_size);
|
|
|
|
fdt_setprop_cell(blob, off, "i-cache-size", isize);
|
|
|
|
fdt_setprop_cell(blob, off, "i-cache-sets", inum_sets);
|
|
|
|
|
|
|
|
off = fdt_node_offset_by_prop_value(blob, off,
|
|
|
|
"device_type", "cpu", 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
ft_fixup_l2cache(blob);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-07 13:09:50 +00:00
|
|
|
void fdt_add_enet_stashing(void *fdt)
|
|
|
|
{
|
|
|
|
do_fixup_by_compat(fdt, "gianfar", "bd-stash", NULL, 0, 1);
|
|
|
|
|
|
|
|
do_fixup_by_compat_u32(fdt, "gianfar", "rx-stash-len", 96, 1);
|
|
|
|
|
|
|
|
do_fixup_by_compat_u32(fdt, "gianfar", "rx-stash-idx", 0, 1);
|
2011-01-25 09:14:57 +00:00
|
|
|
do_fixup_by_compat(fdt, "fsl,etsec2", "bd-stash", NULL, 0, 1);
|
|
|
|
do_fixup_by_compat_u32(fdt, "fsl,etsec2", "rx-stash-len", 96, 1);
|
|
|
|
do_fixup_by_compat_u32(fdt, "fsl,etsec2", "rx-stash-idx", 0, 1);
|
2008-10-07 13:09:50 +00:00
|
|
|
}
|
|
|
|
|
2009-03-19 07:46:28 +00:00
|
|
|
#if defined(CONFIG_SYS_DPAA_FMAN) || defined(CONFIG_SYS_DPAA_PME)
|
2011-07-31 17:55:39 +00:00
|
|
|
#ifdef CONFIG_SYS_DPAA_FMAN
|
2010-07-10 11:38:16 +00:00
|
|
|
static void ft_fixup_clks(void *blob, const char *compat, u32 offset,
|
|
|
|
unsigned long freq)
|
2009-03-19 07:46:28 +00:00
|
|
|
{
|
2010-07-10 11:38:16 +00:00
|
|
|
phys_addr_t phys = offset + CONFIG_SYS_CCSRBAR_PHYS;
|
|
|
|
int off = fdt_node_offset_by_compat_reg(blob, compat, phys);
|
2009-03-19 07:46:28 +00:00
|
|
|
|
|
|
|
if (off >= 0) {
|
|
|
|
off = fdt_setprop_cell(blob, off, "clock-frequency", freq);
|
|
|
|
if (off > 0)
|
|
|
|
printf("WARNING enable to set clock-frequency "
|
2010-07-10 11:38:16 +00:00
|
|
|
"for %s: %s\n", compat, fdt_strerror(off));
|
2009-03-19 07:46:28 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-31 17:55:39 +00:00
|
|
|
#endif
|
2009-03-19 07:46:28 +00:00
|
|
|
|
|
|
|
static void ft_fixup_dpaa_clks(void *blob)
|
|
|
|
{
|
|
|
|
sys_info_t sysinfo;
|
|
|
|
|
|
|
|
get_sys_info(&sysinfo);
|
2011-07-31 17:55:39 +00:00
|
|
|
#ifdef CONFIG_SYS_DPAA_FMAN
|
2010-07-10 11:38:16 +00:00
|
|
|
ft_fixup_clks(blob, "fsl,fman", CONFIG_SYS_FSL_FM1_OFFSET,
|
2013-08-16 09:22:26 +00:00
|
|
|
sysinfo.freq_fman[0]);
|
2009-03-19 07:46:28 +00:00
|
|
|
|
|
|
|
#if (CONFIG_SYS_NUM_FMAN == 2)
|
2010-07-10 11:38:16 +00:00
|
|
|
ft_fixup_clks(blob, "fsl,fman", CONFIG_SYS_FSL_FM2_OFFSET,
|
2013-08-16 09:22:26 +00:00
|
|
|
sysinfo.freq_fman[1]);
|
2009-03-19 07:46:28 +00:00
|
|
|
#endif
|
2011-07-31 17:55:39 +00:00
|
|
|
#endif
|
2009-03-19 07:46:28 +00:00
|
|
|
|
2012-10-11 07:13:39 +00:00
|
|
|
#ifdef CONFIG_SYS_DPAA_QBMAN
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,qman",
|
2013-08-16 09:22:26 +00:00
|
|
|
"clock-frequency", sysinfo.freq_qman, 1);
|
2012-10-11 07:13:39 +00:00
|
|
|
#endif
|
|
|
|
|
2009-03-19 07:46:28 +00:00
|
|
|
#ifdef CONFIG_SYS_DPAA_PME
|
2010-07-10 11:38:16 +00:00
|
|
|
do_fixup_by_compat_u32(blob, "fsl,pme",
|
2013-08-16 09:22:26 +00:00
|
|
|
"clock-frequency", sysinfo.freq_pme, 1);
|
2009-03-19 07:46:28 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define ft_fixup_dpaa_clks(x)
|
|
|
|
#endif
|
|
|
|
|
2010-01-15 06:58:40 +00:00
|
|
|
#ifdef CONFIG_QE
|
|
|
|
static void ft_fixup_qe_snum(void *blob)
|
|
|
|
{
|
|
|
|
unsigned int svr;
|
|
|
|
|
|
|
|
svr = mfspr(SPRN_SVR);
|
2012-07-06 22:10:33 +00:00
|
|
|
if (SVR_SOC_VER(svr) == SVR_8569) {
|
2010-01-15 06:58:40 +00:00
|
|
|
if(IS_SVR_REV(svr, 1, 0))
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,qe",
|
|
|
|
"fsl,qe-num-snums", 46, 1);
|
|
|
|
else
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,qe",
|
|
|
|
"fsl,qe-num-snums", 76, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-14 06:47:27 +00:00
|
|
|
#if defined(CONFIG_PPC_P4080)
|
2011-10-14 08:26:06 +00:00
|
|
|
static void fdt_fixup_usb(void *fdt)
|
|
|
|
{
|
|
|
|
ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
|
|
|
|
u32 rcwsr11 = in_be32(&gur->rcwsr[11]);
|
|
|
|
int off;
|
|
|
|
|
|
|
|
off = fdt_node_offset_by_compatible(fdt, -1, "fsl,mpc85xx-usb2-mph");
|
|
|
|
if ((rcwsr11 & FSL_CORENET_RCWSR11_EC1) !=
|
|
|
|
FSL_CORENET_RCWSR11_EC1_FM1_USB1)
|
|
|
|
fdt_status_disabled(fdt, off);
|
|
|
|
|
|
|
|
off = fdt_node_offset_by_compatible(fdt, -1, "fsl,mpc85xx-usb2-dr");
|
|
|
|
if ((rcwsr11 & FSL_CORENET_RCWSR11_EC2) !=
|
|
|
|
FSL_CORENET_RCWSR11_EC2_USB2)
|
|
|
|
fdt_status_disabled(fdt, off);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define fdt_fixup_usb(x)
|
|
|
|
#endif
|
|
|
|
|
2014-05-19 07:08:14 +00:00
|
|
|
#if defined(CONFIG_PPC_T2080) || defined(CONFIG_PPC_T4240) || \
|
|
|
|
defined(CONFIG_PPC_T4160) || defined(CONFIG_PPC_T4080)
|
|
|
|
void fdt_fixup_dma3(void *blob)
|
|
|
|
{
|
|
|
|
/* the 3rd DMA is not functional if SRIO2 is chosen */
|
|
|
|
int nodeoff;
|
|
|
|
ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
|
|
|
|
|
|
|
|
#define CONFIG_SYS_ELO3_DMA3 (0xffe000000 + 0x102300)
|
|
|
|
#if defined(CONFIG_PPC_T2080)
|
|
|
|
u32 srds_prtcl_s2 = in_be32(&gur->rcwsr[4]) &
|
|
|
|
FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
|
|
|
|
srds_prtcl_s2 >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
|
|
|
|
|
|
|
|
switch (srds_prtcl_s2) {
|
|
|
|
case 0x29:
|
|
|
|
case 0x2d:
|
|
|
|
case 0x2e:
|
|
|
|
#elif defined(CONFIG_PPC_T4240) || defined(CONFIG_PPC_T4160) || \
|
|
|
|
defined(CONFIG_PPC_T4080)
|
|
|
|
u32 srds_prtcl_s4 = in_be32(&gur->rcwsr[4]) &
|
|
|
|
FSL_CORENET2_RCWSR4_SRDS4_PRTCL;
|
|
|
|
srds_prtcl_s4 >>= FSL_CORENET2_RCWSR4_SRDS4_PRTCL_SHIFT;
|
|
|
|
|
|
|
|
switch (srds_prtcl_s4) {
|
|
|
|
case 6:
|
|
|
|
case 8:
|
|
|
|
case 14:
|
|
|
|
case 16:
|
|
|
|
#endif
|
|
|
|
nodeoff = fdt_node_offset_by_compat_reg(blob, "fsl,elo3-dma",
|
|
|
|
CONFIG_SYS_ELO3_DMA3);
|
|
|
|
if (nodeoff > 0)
|
|
|
|
fdt_status_disabled(blob, nodeoff);
|
|
|
|
else
|
|
|
|
printf("WARNING: unable to disable dma3\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define fdt_fixup_dma3(x)
|
|
|
|
#endif
|
|
|
|
|
2014-03-28 16:57:29 +00:00
|
|
|
#if defined(CONFIG_PPC_T1040)
|
|
|
|
static void fdt_fixup_l2_switch(void *blob)
|
|
|
|
{
|
|
|
|
uchar l2swaddr[6];
|
|
|
|
int node;
|
|
|
|
|
|
|
|
/* The l2switch node from device-tree has
|
|
|
|
* compatible string "vitesse-9953" */
|
|
|
|
node = fdt_node_offset_by_compatible(blob, -1, "vitesse-9953");
|
|
|
|
if (node == -FDT_ERR_NOTFOUND)
|
|
|
|
/* no l2switch node has been found */
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Get MAC address for the l2switch from "l2switchaddr"*/
|
|
|
|
if (!eth_getenv_enetaddr("l2switchaddr", l2swaddr)) {
|
|
|
|
printf("Warning: MAC address for l2switch not found\n");
|
|
|
|
memset(l2swaddr, 0, sizeof(l2swaddr));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add MAC address to l2switch node */
|
|
|
|
fdt_setprop(blob, node, "local-mac-address", l2swaddr,
|
|
|
|
sizeof(l2swaddr));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define fdt_fixup_l2_switch(x)
|
|
|
|
#endif
|
|
|
|
|
2007-11-29 06:15:30 +00:00
|
|
|
void ft_cpu_setup(void *blob, bd_t *bd)
|
|
|
|
{
|
2009-01-15 16:58:35 +00:00
|
|
|
int off;
|
|
|
|
int val;
|
2013-10-23 12:20:45 +00:00
|
|
|
int len;
|
2009-01-15 16:58:35 +00:00
|
|
|
sys_info_t sysinfo;
|
|
|
|
|
2008-06-16 20:55:53 +00:00
|
|
|
/* delete crypto node if not on an E-processor */
|
|
|
|
if (!IS_E_PROCESSOR(get_svr()))
|
|
|
|
fdt_fixup_crypto_node(blob, 0);
|
2013-01-23 22:52:31 +00:00
|
|
|
#if CONFIG_SYS_FSL_SEC_COMPAT >= 4
|
|
|
|
else {
|
|
|
|
ccsr_sec_t __iomem *sec;
|
|
|
|
|
|
|
|
sec = (void __iomem *)CONFIG_SYS_FSL_SEC_ADDR;
|
2014-09-09 06:20:31 +00:00
|
|
|
fdt_fixup_crypto_node(blob, sec_in32(&sec->secvid_ms));
|
2013-01-23 22:52:31 +00:00
|
|
|
}
|
|
|
|
#endif
|
2008-06-16 20:55:53 +00:00
|
|
|
|
2008-08-19 20:41:18 +00:00
|
|
|
fdt_fixup_ethernet(blob);
|
2008-10-07 13:09:50 +00:00
|
|
|
|
|
|
|
fdt_add_enet_stashing(blob);
|
2007-11-29 06:15:30 +00:00
|
|
|
|
2013-06-25 18:37:41 +00:00
|
|
|
#ifndef CONFIG_FSL_TBCLK_EXTRA_DIV
|
|
|
|
#define CONFIG_FSL_TBCLK_EXTRA_DIV 1
|
|
|
|
#endif
|
2007-11-29 06:15:30 +00:00
|
|
|
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
2013-06-25 18:37:41 +00:00
|
|
|
"timebase-frequency", get_tbclk() / CONFIG_FSL_TBCLK_EXTRA_DIV,
|
|
|
|
1);
|
2007-11-29 06:15:30 +00:00
|
|
|
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
|
|
|
"bus-frequency", bd->bi_busfreq, 1);
|
2009-01-15 16:58:35 +00:00
|
|
|
get_sys_info(&sysinfo);
|
|
|
|
off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
|
|
|
|
while (off != -FDT_ERR_NOTFOUND) {
|
2013-10-23 12:20:45 +00:00
|
|
|
u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", &len);
|
|
|
|
val = cpu_to_fdt32(sysinfo.freq_processor[(*reg) / (len / 4)]);
|
2009-01-15 16:58:35 +00:00
|
|
|
fdt_setprop(blob, off, "clock-frequency", &val, 4);
|
|
|
|
off = fdt_node_offset_by_prop_value(blob, off, "device_type",
|
|
|
|
"cpu", 4);
|
|
|
|
}
|
2007-11-29 06:15:30 +00:00
|
|
|
do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
|
|
|
|
"bus-frequency", bd->bi_busfreq, 1);
|
mpc8[56]xx: Put localbus clock in device tree
Export the localbus frequency in the device tree, the same way the CPU, TB,
CCB, and various other frequencies are exported in their respective device
tree nodes.
Some localbus devices need this information to be programed correctly, so
it makes sense to export it along with the other frequencies.
Unfortunately, when someone wrote the localbus dts bindings, they didn't
bother to define what the "compatible" property should be. So it seems no
one was quite sure what to put in their dts files.
Based on current existing dts files in the kernel source, I've used
"fsl,pq3-localbus" and "fsl,elbc" for MPC85xx, which are used by almost all
of the 85xx devices, and are looked for by the Linux code. The eLBC is
apparently not entirely backward compatible with the pq3 LBC and so eLBC
equipped platforms like 8572 won't use pq3-localbus.
For MPC86xx, I've used "fsl,elbc" which is used by some of the 86xx systems
and is also looked for by the Linux code. On MPC8641, I've also used
"fsl,mpc8641-localbus" as it is also commonly used in dts files, some of
which don't use "fsl,elbc" or any other acceptable name to match on.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Jon Loeliger <jdl@freescale.com>
2008-12-03 23:16:38 +00:00
|
|
|
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,pq3-localbus",
|
2012-12-13 20:48:48 +00:00
|
|
|
"bus-frequency", gd->arch.lbc_clk, 1);
|
mpc8[56]xx: Put localbus clock in device tree
Export the localbus frequency in the device tree, the same way the CPU, TB,
CCB, and various other frequencies are exported in their respective device
tree nodes.
Some localbus devices need this information to be programed correctly, so
it makes sense to export it along with the other frequencies.
Unfortunately, when someone wrote the localbus dts bindings, they didn't
bother to define what the "compatible" property should be. So it seems no
one was quite sure what to put in their dts files.
Based on current existing dts files in the kernel source, I've used
"fsl,pq3-localbus" and "fsl,elbc" for MPC85xx, which are used by almost all
of the 85xx devices, and are looked for by the Linux code. The eLBC is
apparently not entirely backward compatible with the pq3 LBC and so eLBC
equipped platforms like 8572 won't use pq3-localbus.
For MPC86xx, I've used "fsl,elbc" which is used by some of the 86xx systems
and is also looked for by the Linux code. On MPC8641, I've also used
"fsl,mpc8641-localbus" as it is also commonly used in dts files, some of
which don't use "fsl,elbc" or any other acceptable name to match on.
Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Jon Loeliger <jdl@freescale.com>
2008-12-03 23:16:38 +00:00
|
|
|
do_fixup_by_compat_u32(blob, "fsl,elbc",
|
2012-12-13 20:48:48 +00:00
|
|
|
"bus-frequency", gd->arch.lbc_clk, 1);
|
2007-11-29 06:15:30 +00:00
|
|
|
#ifdef CONFIG_QE
|
2008-01-17 14:25:45 +00:00
|
|
|
ft_qe_setup(blob);
|
2010-01-15 06:58:40 +00:00
|
|
|
ft_fixup_qe_snum(blob);
|
2007-11-29 06:15:30 +00:00
|
|
|
#endif
|
|
|
|
|
2016-02-18 05:02:00 +00:00
|
|
|
#ifdef CONFIG_SYS_DPAA_FMAN
|
2011-05-03 18:35:11 +00:00
|
|
|
fdt_fixup_fman_firmware(blob);
|
2016-02-18 05:02:00 +00:00
|
|
|
#endif
|
2011-05-03 18:35:11 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_NS16550
|
2007-11-29 06:15:30 +00:00
|
|
|
do_fixup_by_compat_u32(blob, "ns16550",
|
2008-10-16 13:01:15 +00:00
|
|
|
"clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
|
2007-11-29 06:15:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_CPM2
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,cpm2-scc-uart",
|
2014-04-04 11:09:58 +00:00
|
|
|
"current-speed", gd->baudrate, 1);
|
2007-11-29 06:15:30 +00:00
|
|
|
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,cpm2-brg",
|
|
|
|
"clock-frequency", bd->bi_brgfreq, 1);
|
|
|
|
#endif
|
|
|
|
|
2010-07-10 11:55:41 +00:00
|
|
|
#ifdef CONFIG_FSL_CORENET
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,qoriq-clockgen-1.0",
|
|
|
|
"clock-frequency", CONFIG_SYS_CLK_FREQ, 1);
|
2013-06-17 20:10:28 +00:00
|
|
|
do_fixup_by_compat_u32(blob, "fsl,qoriq-clockgen-2.0",
|
2013-02-28 23:24:34 +00:00
|
|
|
"clock-frequency", CONFIG_SYS_CLK_FREQ, 1);
|
2013-01-30 18:51:52 +00:00
|
|
|
do_fixup_by_compat_u32(blob, "fsl,mpic",
|
|
|
|
"clock-frequency", get_bus_freq(0)/2, 1);
|
|
|
|
#else
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,mpic",
|
|
|
|
"clock-frequency", get_bus_freq(0), 1);
|
2010-07-10 11:55:41 +00:00
|
|
|
#endif
|
|
|
|
|
2007-11-29 06:15:30 +00:00
|
|
|
fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
|
2008-01-17 22:48:33 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_MP
|
|
|
|
ft_fixup_cpu(blob, (u64)bd->bi_memstart + (u64)bd->bi_memsize);
|
2009-09-02 14:10:36 +00:00
|
|
|
ft_fixup_num_cores(blob);
|
2010-06-10 03:33:53 +00:00
|
|
|
#endif
|
2008-05-29 16:22:06 +00:00
|
|
|
|
|
|
|
ft_fixup_cache(blob);
|
2009-09-02 05:55:08 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_FSL_ESDHC)
|
|
|
|
fdt_fixup_esdhc(blob, bd);
|
|
|
|
#endif
|
2009-03-19 07:46:28 +00:00
|
|
|
|
|
|
|
ft_fixup_dpaa_clks(blob);
|
2009-09-10 08:02:13 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_SYS_BMAN_MEM_PHYS)
|
|
|
|
fdt_portal(blob, "fsl,bman-portal", "bman-portals",
|
|
|
|
(u64)CONFIG_SYS_BMAN_MEM_PHYS,
|
|
|
|
CONFIG_SYS_BMAN_MEM_SIZE);
|
2011-03-01 14:30:07 +00:00
|
|
|
fdt_fixup_bportals(blob);
|
2009-09-10 08:02:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_SYS_QMAN_MEM_PHYS)
|
|
|
|
fdt_portal(blob, "fsl,qman-portal", "qman-portals",
|
|
|
|
(u64)CONFIG_SYS_QMAN_MEM_PHYS,
|
|
|
|
CONFIG_SYS_QMAN_MEM_SIZE);
|
|
|
|
|
|
|
|
fdt_fixup_qportals(blob);
|
|
|
|
#endif
|
2010-12-30 18:09:53 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_SRIO
|
|
|
|
ft_srio_setup(blob);
|
|
|
|
#endif
|
2011-02-02 14:44:28 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* system-clock = CCB clock/2
|
|
|
|
* Here gd->bus_clk = CCB clock
|
|
|
|
* We are using the system clock as 1588 Timer reference
|
|
|
|
* clock source select
|
|
|
|
*/
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,gianfar-ptp-timer",
|
|
|
|
"timer-frequency", gd->bus_clk/2, 1);
|
2011-03-04 14:57:58 +00:00
|
|
|
|
2011-11-15 07:04:11 +00:00
|
|
|
/*
|
|
|
|
* clock-freq should change to clock-frequency and
|
|
|
|
* flexcan-v1.0 should change to p1010-flexcan respectively
|
|
|
|
* in the future.
|
|
|
|
*/
|
2011-03-04 14:57:58 +00:00
|
|
|
do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
|
2011-11-15 07:04:11 +00:00
|
|
|
"clock_freq", gd->bus_clk/2, 1);
|
|
|
|
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
|
|
|
|
"clock-frequency", gd->bus_clk/2, 1);
|
|
|
|
|
|
|
|
do_fixup_by_compat_u32(blob, "fsl,p1010-flexcan",
|
|
|
|
"clock-frequency", gd->bus_clk/2, 1);
|
2011-10-14 08:26:06 +00:00
|
|
|
|
|
|
|
fdt_fixup_usb(blob);
|
2014-03-28 16:57:29 +00:00
|
|
|
|
|
|
|
fdt_fixup_l2_switch(blob);
|
2014-05-19 07:08:14 +00:00
|
|
|
|
|
|
|
fdt_fixup_dma3(blob);
|
2007-11-29 06:15:30 +00:00
|
|
|
}
|
2011-05-03 18:24:08 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For some CCSR devices, we only have the virtual address, not the physical
|
|
|
|
* address. This is because we map CCSR as a whole, so we typically don't need
|
|
|
|
* a macro for the physical address of any device within CCSR. In this case,
|
|
|
|
* we calculate the physical address of that device using it's the difference
|
|
|
|
* between the virtual address of the device and the virtual address of the
|
|
|
|
* beginning of CCSR.
|
|
|
|
*/
|
|
|
|
#define CCSR_VIRT_TO_PHYS(x) \
|
|
|
|
(CONFIG_SYS_CCSRBAR_PHYS + ((x) - CONFIG_SYS_CCSRBAR))
|
|
|
|
|
2011-11-16 19:28:34 +00:00
|
|
|
static void msg(const char *name, uint64_t uaddr, uint64_t daddr)
|
|
|
|
{
|
|
|
|
printf("Warning: U-Boot configured %s at address %llx,\n"
|
|
|
|
"but the device tree has it at %llx\n", name, uaddr, daddr);
|
|
|
|
}
|
|
|
|
|
2011-05-03 18:24:08 +00:00
|
|
|
/*
|
|
|
|
* Verify the device tree
|
|
|
|
*
|
|
|
|
* This function compares several CONFIG_xxx macros that contain physical
|
|
|
|
* addresses with the corresponding nodes in the device tree, to see if
|
|
|
|
* the physical addresses are all correct. For example, if
|
|
|
|
* CONFIG_SYS_NS16550_COM1 is defined, then it contains the virtual address
|
|
|
|
* of the first UART. We convert this to a physical address and compare
|
|
|
|
* that with the physical address of the first ns16550-compatible node
|
|
|
|
* in the device tree. If they don't match, then we display a warning.
|
|
|
|
*
|
|
|
|
* Returns 1 on success, 0 on failure
|
|
|
|
*/
|
|
|
|
int ft_verify_fdt(void *fdt)
|
|
|
|
{
|
2011-11-16 19:28:34 +00:00
|
|
|
uint64_t addr = 0;
|
2011-05-03 18:24:08 +00:00
|
|
|
int aliases;
|
|
|
|
int off;
|
|
|
|
|
|
|
|
/* First check the CCSR base address */
|
|
|
|
off = fdt_node_offset_by_prop_value(fdt, -1, "device_type", "soc", 4);
|
|
|
|
if (off > 0)
|
2011-11-16 19:28:34 +00:00
|
|
|
addr = fdt_get_base_address(fdt, off);
|
2011-05-03 18:24:08 +00:00
|
|
|
|
2011-11-16 19:28:34 +00:00
|
|
|
if (!addr) {
|
2011-05-03 18:24:08 +00:00
|
|
|
printf("Warning: could not determine base CCSR address in "
|
|
|
|
"device tree\n");
|
|
|
|
/* No point in checking anything else */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-16 19:28:34 +00:00
|
|
|
if (addr != CONFIG_SYS_CCSRBAR_PHYS) {
|
|
|
|
msg("CCSR", CONFIG_SYS_CCSRBAR_PHYS, addr);
|
2011-05-03 18:24:08 +00:00
|
|
|
/* No point in checking anything else */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-11-16 19:28:34 +00:00
|
|
|
* Check some nodes via aliases. We assume that U-Boot and the device
|
|
|
|
* tree enumerate the devices equally. E.g. the first serial port in
|
|
|
|
* U-Boot is the same as "serial0" in the device tree.
|
2011-05-03 18:24:08 +00:00
|
|
|
*/
|
|
|
|
aliases = fdt_path_offset(fdt, "/aliases");
|
|
|
|
if (aliases > 0) {
|
|
|
|
#ifdef CONFIG_SYS_NS16550_COM1
|
|
|
|
if (!fdt_verify_alias_address(fdt, aliases, "serial0",
|
|
|
|
CCSR_VIRT_TO_PHYS(CONFIG_SYS_NS16550_COM1)))
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SYS_NS16550_COM2
|
|
|
|
if (!fdt_verify_alias_address(fdt, aliases, "serial1",
|
|
|
|
CCSR_VIRT_TO_PHYS(CONFIG_SYS_NS16550_COM2)))
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-11-16 19:28:34 +00:00
|
|
|
/*
|
|
|
|
* The localbus node is typically a root node, even though the lbc
|
|
|
|
* controller is part of CCSR. If we were to put the lbc node under
|
|
|
|
* the SOC node, then the 'ranges' property in the lbc node would
|
|
|
|
* translate through the 'ranges' property of the parent SOC node, and
|
|
|
|
* we don't want that. Since it's a separate node, it's possible for
|
|
|
|
* the 'reg' property to be wrong, so check it here. For now, we
|
|
|
|
* only check for "fsl,elbc" nodes.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_SYS_LBC_ADDR
|
|
|
|
off = fdt_node_offset_by_compatible(fdt, -1, "fsl,elbc");
|
|
|
|
if (off > 0) {
|
2013-01-16 14:00:11 +00:00
|
|
|
const fdt32_t *reg = fdt_getprop(fdt, off, "reg", NULL);
|
2011-11-16 19:28:34 +00:00
|
|
|
if (reg) {
|
|
|
|
uint64_t uaddr = CCSR_VIRT_TO_PHYS(CONFIG_SYS_LBC_ADDR);
|
|
|
|
|
|
|
|
addr = fdt_translate_address(fdt, off, reg);
|
|
|
|
if (uaddr != addr) {
|
|
|
|
msg("the localbus", uaddr, addr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-05-03 18:24:08 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2015-08-28 02:31:50 +00:00
|
|
|
|
|
|
|
void fdt_del_diu(void *blob)
|
|
|
|
{
|
|
|
|
int nodeoff = 0;
|
|
|
|
|
|
|
|
while ((nodeoff = fdt_node_offset_by_compatible(blob, 0,
|
|
|
|
"fsl,diu")) >= 0) {
|
|
|
|
fdt_del_node(blob, nodeoff);
|
|
|
|
}
|
|
|
|
}
|