xref: /openbmc/linux/arch/arm/mach-imx/cpu-imx25.c (revision 53f9cd5c)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * MX25 CPU type detection
4  *
5  * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
6  * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved
7  */
8 #include <linux/module.h>
9 #include <linux/io.h>
10 #include <linux/of.h>
11 #include <linux/of_address.h>
12 
13 #include "iim.h"
14 #include "hardware.h"
15 
16 static int mx25_cpu_rev = -1;
17 
18 static int mx25_read_cpu_rev(void)
19 {
20 	u32 rev;
21 	void __iomem *iim_base;
22 	struct device_node *np;
23 
24 	np = of_find_compatible_node(NULL, NULL, "fsl,imx25-iim");
25 	iim_base = of_iomap(np, 0);
26 	BUG_ON(!iim_base);
27 	rev = readl(iim_base + MXC_IIMSREV);
28 	iounmap(iim_base);
29 
30 	switch (rev) {
31 	case 0x00:
32 		return IMX_CHIP_REVISION_1_0;
33 	case 0x01:
34 		return IMX_CHIP_REVISION_1_1;
35 	case 0x02:
36 		return IMX_CHIP_REVISION_1_2;
37 	default:
38 		return IMX_CHIP_REVISION_UNKNOWN;
39 	}
40 }
41 
42 int mx25_revision(void)
43 {
44 	if (mx25_cpu_rev == -1)
45 		mx25_cpu_rev = mx25_read_cpu_rev();
46 
47 	return mx25_cpu_rev;
48 }
49 EXPORT_SYMBOL(mx25_revision);
50