summaryrefslogtreecommitdiff
path: root/arch/arm/mach-mvf/cpu.c
blob: 4c6d018cd076233f04a91304055ad056393a3d5b (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
/*
 * Copyright 2012 Freescale Semiconductor, Inc.
 *
 * 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.

 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/clk.h>
#include <linux/module.h>
#include <linux/iram_alloc.h>
#include <linux/delay.h>

#include <mach/hardware.h>
#include <asm/io.h>
#include <asm/mach/map.h>
#include <mach/mvf.h>
#include "crm_regs.h"


struct cpu_op *(*get_cpu_op)(int *op);
bool enable_wait_mode;

void __iomem *gpc_base;
void __iomem *ccm_base;

static int cpu_silicon_rev = -1;
#define SI_REV_OFFSET	0x80

static int get_mvf_srev(void)
{
	void __iomem *romcp = ioremap(BOOT_ROM_BASE_ADDR, SZ_8K);
	u32 rev;

	if (!romcp) {
		cpu_silicon_rev = -EINVAL;
		return 0;
	}

	rev = __raw_readl(romcp + SI_REV_OFFSET);
	rev &= 0xff;

	iounmap(romcp);
	if (rev == 0x10)
		return IMX_CHIP_REVISION_1_0;
	else if (rev == 0x11)
		return IMX_CHIP_REVISION_1_1;
	else if (rev == 0x20)
		return IMX_CHIP_REVISION_2_0;
	return 0;
}

/*
 * Returns:
 *	the silicon revision of the cpu
 *	-EINVAL - not a mvf
 */
int mvf_revision(void)
{

	if (cpu_silicon_rev == -1)
		cpu_silicon_rev = get_mvf_srev();

	return cpu_silicon_rev;

}
EXPORT_SYMBOL(mvf_revision);

static int __init post_cpu_init(void)
{
	iram_init(MVF_IRAM_BASE_ADDR, MVF_IRAM_SIZE);

	/* Move wait routine into iRAM */
	ccm_base = MVF_IO_ADDRESS(MVF_CCM_BASE_ADDR);

	return 0;
}
postcore_initcall(post_cpu_init);