Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * MX25 CPU type detection
0004  *
0005  * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
0006  * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved
0007  */
0008 #include <linux/module.h>
0009 #include <linux/io.h>
0010 #include <linux/of.h>
0011 #include <linux/of_address.h>
0012 
0013 #include "iim.h"
0014 #include "hardware.h"
0015 
0016 static int mx25_cpu_rev = -1;
0017 
0018 static int mx25_read_cpu_rev(void)
0019 {
0020     u32 rev;
0021     void __iomem *iim_base;
0022     struct device_node *np;
0023 
0024     np = of_find_compatible_node(NULL, NULL, "fsl,imx25-iim");
0025     iim_base = of_iomap(np, 0);
0026     BUG_ON(!iim_base);
0027     rev = readl(iim_base + MXC_IIMSREV);
0028     iounmap(iim_base);
0029 
0030     switch (rev) {
0031     case 0x00:
0032         return IMX_CHIP_REVISION_1_0;
0033     case 0x01:
0034         return IMX_CHIP_REVISION_1_1;
0035     case 0x02:
0036         return IMX_CHIP_REVISION_1_2;
0037     default:
0038         return IMX_CHIP_REVISION_UNKNOWN;
0039     }
0040 }
0041 
0042 int mx25_revision(void)
0043 {
0044     if (mx25_cpu_rev == -1)
0045         mx25_cpu_rev = mx25_read_cpu_rev();
0046 
0047     return mx25_cpu_rev;
0048 }
0049 EXPORT_SYMBOL(mx25_revision);