Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * MX31 CPU type detection
0004  *
0005  * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
0006  */
0007 
0008 #include <linux/module.h>
0009 #include <linux/of_address.h>
0010 #include <linux/io.h>
0011 
0012 #include "common.h"
0013 #include "hardware.h"
0014 #include "iim.h"
0015 
0016 static int mx31_cpu_rev = -1;
0017 
0018 static struct {
0019     u8 srev;
0020     const char *name;
0021     unsigned int rev;
0022 } mx31_cpu_type[] = {
0023     { .srev = 0x00, .name = "i.MX31(L)", .rev = IMX_CHIP_REVISION_1_0 },
0024     { .srev = 0x10, .name = "i.MX31",    .rev = IMX_CHIP_REVISION_1_1 },
0025     { .srev = 0x11, .name = "i.MX31L",   .rev = IMX_CHIP_REVISION_1_1 },
0026     { .srev = 0x12, .name = "i.MX31",    .rev = IMX_CHIP_REVISION_1_1 },
0027     { .srev = 0x13, .name = "i.MX31L",   .rev = IMX_CHIP_REVISION_1_1 },
0028     { .srev = 0x14, .name = "i.MX31",    .rev = IMX_CHIP_REVISION_1_2 },
0029     { .srev = 0x15, .name = "i.MX31L",   .rev = IMX_CHIP_REVISION_1_2 },
0030     { .srev = 0x28, .name = "i.MX31",    .rev = IMX_CHIP_REVISION_2_0 },
0031     { .srev = 0x29, .name = "i.MX31L",   .rev = IMX_CHIP_REVISION_2_0 },
0032 };
0033 
0034 static int mx31_read_cpu_rev(void)
0035 {
0036     void __iomem *iim_base;
0037     struct device_node *np;
0038     u32 i, srev;
0039 
0040     np = of_find_compatible_node(NULL, NULL, "fsl,imx31-iim");
0041     iim_base = of_iomap(np, 0);
0042     BUG_ON(!iim_base);
0043 
0044     /* read SREV register from IIM module */
0045     srev = imx_readl(iim_base + MXC_IIMSREV);
0046     srev &= 0xff;
0047 
0048     for (i = 0; i < ARRAY_SIZE(mx31_cpu_type); i++)
0049         if (srev == mx31_cpu_type[i].srev) {
0050             imx_print_silicon_rev(mx31_cpu_type[i].name,
0051                         mx31_cpu_type[i].rev);
0052             return mx31_cpu_type[i].rev;
0053         }
0054 
0055     imx_print_silicon_rev("i.MX31", IMX_CHIP_REVISION_UNKNOWN);
0056     return IMX_CHIP_REVISION_UNKNOWN;
0057 }
0058 
0059 int mx31_revision(void)
0060 {
0061     if (mx31_cpu_rev == -1)
0062         mx31_cpu_rev = mx31_read_cpu_rev();
0063 
0064     return mx31_cpu_rev;
0065 }
0066 EXPORT_SYMBOL(mx31_revision);