blob: 8a54234df23b582b5bac78d365f2e35b4fe6cc84 [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>
Shawn Guo17c342a2012-09-13 21:18:39 +080013
Shawn Guo50f2de62012-09-14 14:14:45 +080014#include "hardware.h"
Shawn Guo17c342a2012-09-13 21:18:39 +080015#include "iim.h"
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010016
Jason Liu8d75a262011-08-26 13:35:22 +080017static int mx35_cpu_rev = -1;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010018
Jason Liu8d75a262011-08-26 13:35:22 +080019static int mx35_read_cpu_rev(void)
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010020{
21 u32 rev;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010022
Johannes Bergc5531382016-01-27 17:59:35 +010023 rev = imx_readl(MX35_IO_ADDRESS(MX35_IIM_BASE_ADDR + MXC_IIMSREV));
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010024 switch (rev) {
25 case 0x00:
Jason Liu8d75a262011-08-26 13:35:22 +080026 return IMX_CHIP_REVISION_1_0;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010027 case 0x10:
Jason Liu8d75a262011-08-26 13:35:22 +080028 return IMX_CHIP_REVISION_2_0;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010029 case 0x11:
Jason Liu8d75a262011-08-26 13:35:22 +080030 return IMX_CHIP_REVISION_2_1;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010031 default:
Jason Liu8d75a262011-08-26 13:35:22 +080032 return IMX_CHIP_REVISION_UNKNOWN;
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010033 }
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +010034}
Jason Liu8d75a262011-08-26 13:35:22 +080035
36int mx35_revision(void)
37{
38 if (mx35_cpu_rev == -1)
39 mx35_cpu_rev = mx35_read_cpu_rev();
40
41 return mx35_cpu_rev;
42}
43EXPORT_SYMBOL(mx35_revision);