1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * MX31 CPU type detection
5 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
8 #include <linux/module.h>
15 static int mx31_cpu_rev
= -1;
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)
37 /* read SREV register from IIM module */
38 srev
= imx_readl(MX31_IO_ADDRESS(MX31_IIM_BASE_ADDR
+ MXC_IIMSREV
));
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();
59 EXPORT_SYMBOL(mx31_revision
);