blob: 846e46eb8cbfd87f2ad61131e7794fc27ca14e2a [file] [log] [blame]
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +01001/*
2 * MX35 CPU type detection
3 *
4 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#include <linux/module.h>
12#include <linux/io.h>
13#include <mach/hardware.h>
14#include <mach/iim.h>
15
Jason Liu8d75a262011-08-26 13:35:22 +080016static int mx35_cpu_rev = -1;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010017
Jason Liu8d75a262011-08-26 13:35:22 +080018static int mx35_read_cpu_rev(void)
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010019{
20 u32 rev;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010021
22 rev = __raw_readl(MX35_IO_ADDRESS(MX35_IIM_BASE_ADDR + MXC_IIMSREV));
23 switch (rev) {
24 case 0x00:
Jason Liu8d75a262011-08-26 13:35:22 +080025 return IMX_CHIP_REVISION_1_0;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010026 case 0x10:
Jason Liu8d75a262011-08-26 13:35:22 +080027 return IMX_CHIP_REVISION_2_0;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010028 case 0x11:
Jason Liu8d75a262011-08-26 13:35:22 +080029 return IMX_CHIP_REVISION_2_1;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010030 default:
Jason Liu8d75a262011-08-26 13:35:22 +080031 return IMX_CHIP_REVISION_UNKNOWN;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010032 }
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010033}
Jason Liu8d75a262011-08-26 13:35:22 +080034
35int mx35_revision(void)
36{
37 if (mx35_cpu_rev == -1)
38 mx35_cpu_rev = mx35_read_cpu_rev();
39
40 return mx35_cpu_rev;
41}
42EXPORT_SYMBOL(mx35_revision);