Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / arch / arm / mach-imx / cpu-imx25.c
blobcc86977d0a3407aa13a8068a91eaebd436e997df
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * MX25 CPU type detection
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>
13 #include "iim.h"
14 #include "hardware.h"
16 static int mx25_cpu_rev = -1;
18 static int mx25_read_cpu_rev(void)
20 u32 rev;
21 void __iomem *iim_base;
22 struct device_node *np;
24 np = of_find_compatible_node(NULL, NULL, "fsl,imx25-iim");
25 iim_base = of_iomap(np, 0);
26 of_node_put(np);
27 BUG_ON(!iim_base);
28 rev = readl(iim_base + MXC_IIMSREV);
29 iounmap(iim_base);
31 switch (rev) {
32 case 0x00:
33 return IMX_CHIP_REVISION_1_0;
34 case 0x01:
35 return IMX_CHIP_REVISION_1_1;
36 case 0x02:
37 return IMX_CHIP_REVISION_1_2;
38 default:
39 return IMX_CHIP_REVISION_UNKNOWN;
43 int mx25_revision(void)
45 if (mx25_cpu_rev == -1)
46 mx25_cpu_rev = mx25_read_cpu_rev();
48 return mx25_cpu_rev;
50 EXPORT_SYMBOL(mx25_revision);