summaryrefslogtreecommitdiffstats
path: root/arch/ppc/mach-mpc85xx/cpu.c
blob: 7c183c1b5ed2e56f6a0f01d6091396b968d804f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * Copyright 2012 GE Intelligent Platforms, Inc
 * Copyright 2004,2007-2011 Freescale Semiconductor, Inc.
 * (C) Copyright 2002, 2003 Motorola Inc.
 * Xianghua Xiao (X.Xiao@motorola.com)
 *
 * (C) Copyright 2000
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <config.h>
#include <common.h>
#include <memory.h>
#include <init.h>
#include <asm/fsl_ddr_sdram.h>
#include <asm-generic/memory_layout.h>
#include <mach/mmu.h>
#include <mach/immap_85xx.h>

void __noreturn reset_cpu(unsigned long addr)
{
	void __iomem *regs = (void __iomem *)MPC85xx_GUTS_ADDR;

	/* Everything after the first generation of PQ3 parts has RSTCR */
	out_be32(regs + MPC85xx_GUTS_RSTCR_OFFSET, 0x2);  /* HRESET_REQ */
	udelay(100);

	while (1)
		;
}

long int initdram(int board_type)
{
	phys_size_t dram_size = 0;

	if (IS_ENABLED(CONFIG_DDR_SPD))
		dram_size = fsl_ddr_sdram();
	else
		dram_size = fixed_sdram();
	dram_size = e500_setup_ddr_tlbs(dram_size / 0x100000);
	dram_size *= 0x100000;

	return dram_size;
}

/*
 * Return the memory size based on the configuration registers.
 */
phys_size_t fsl_get_effective_memsize(void)
{
	void __iomem *regs = (void __iomem *)(MPC85xx_DDR_ADDR);
	phys_size_t sdram_size;
	uint san , ean;
	uint reg;
	int ix;

	sdram_size = 0;

	for (ix = 0; ix < CFG_CHIP_SELECTS_PER_CTRL; ix++) {
		if (in_be32(regs + DDR_OFF(CS0_CONFIG) + (ix * 4)) &
				SDRAM_CFG_MEM_EN) {
			reg = in_be32(regs + DDR_OFF(CS0_BNDS) + (ix * 8));
			/* start address */
			san = (reg & 0x0fff00000) >>  16;
			/* end address   */
			ean = (reg & 0x00000fff);
			sdram_size += ((ean - san + 1) << 24);
		}
	}

	return sdram_size;
}

static int fsl_reserve_region(void)
{
	request_sdram_region("stack", _text_base - STACK_SIZE,
			STACK_SIZE);
	return 0;
}
coredevice_initcall(fsl_reserve_region);