Linux 5.7.7
[linux/fpc-iii.git] / arch / arm / mach-imx / cpu-imx31.c
blob3ee684b71006f24c37a72911a5dd571665ebb29d
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * MX31 CPU type detection
5 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
6 */
8 #include <linux/module.h>
9 #include <linux/io.h>
11 #include "common.h"
12 #include "hardware.h"
13 #include "iim.h"
15 static int mx31_cpu_rev = -1;
17 static struct {
18 u8 srev;
19 const char *name;
20 unsigned int rev;
21 } mx31_cpu_type[] = {
22 { .srev = 0x00, .name = "i.MX31(L)", .rev = IMX_CHIP_REVISION_1_0 },
23 { .srev = 0x10, .name = "i.MX31", .rev = IMX_CHIP_REVISION_1_1 },
24 { .srev = 0x11, .name = "i.MX31L", .rev = IMX_CHIP_REVISION_1_1 },
25 { .srev = 0x12, .name = "i.MX31", .rev = IMX_CHIP_REVISION_1_1 },
26 { .srev = 0x13, .name = "i.MX31L", .rev = IMX_CHIP_REVISION_1_1 },
27 { .srev = 0x14, .name = "i.MX31", .rev = IMX_CHIP_REVISION_1_2 },
28 { .srev = 0x15, .name = "i.MX31L", .rev = IMX_CHIP_REVISION_1_2 },
29 { .srev = 0x28, .name = "i.MX31", .rev = IMX_CHIP_REVISION_2_0 },
30 { .srev = 0x29, .name = "i.MX31L", .rev = IMX_CHIP_REVISION_2_0 },
33 static int mx31_read_cpu_rev(void)
35 u32 i, srev;
37 /* read SREV register from IIM module */
38 srev = imx_readl(MX31_IO_ADDRESS(MX31_IIM_BASE_ADDR + MXC_IIMSREV));
39 srev &= 0xff;
41 for (i = 0; i < ARRAY_SIZE(mx31_cpu_type); i++)
42 if (srev == mx31_cpu_type[i].srev) {
43 imx_print_silicon_rev(mx31_cpu_type[i].name,
44 mx31_cpu_type[i].rev);
45 return mx31_cpu_type[i].rev;
48 imx_print_silicon_rev("i.MX31", IMX_CHIP_REVISION_UNKNOWN);
49 return IMX_CHIP_REVISION_UNKNOWN;
52 int mx31_revision(void)
54 if (mx31_cpu_rev == -1)
55 mx31_cpu_rev = mx31_read_cpu_rev();
57 return mx31_cpu_rev;
59 EXPORT_SYMBOL(mx31_revision);