Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 1 | /* |
| 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 Guo | 17c342a | 2012-09-13 21:18:39 +0800 | [diff] [blame] | 13 | |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 14 | #include "hardware.h" |
Shawn Guo | 17c342a | 2012-09-13 21:18:39 +0800 | [diff] [blame] | 15 | #include "iim.h" |
Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 16 | |
Jason Liu | 8d75a26 | 2011-08-26 13:35:22 +0800 | [diff] [blame] | 17 | static int mx35_cpu_rev = -1; |
Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 18 | |
Jason Liu | 8d75a26 | 2011-08-26 13:35:22 +0800 | [diff] [blame] | 19 | static int mx35_read_cpu_rev(void) |
Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 20 | { |
| 21 | u32 rev; |
Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 22 | |
Johannes Berg | c553138 | 2016-01-27 17:59:35 +0100 | [diff] [blame] | 23 | rev = imx_readl(MX35_IO_ADDRESS(MX35_IIM_BASE_ADDR + MXC_IIMSREV)); |
Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 24 | switch (rev) { |
| 25 | case 0x00: |
Jason Liu | 8d75a26 | 2011-08-26 13:35:22 +0800 | [diff] [blame] | 26 | return IMX_CHIP_REVISION_1_0; |
Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 27 | case 0x10: |
Jason Liu | 8d75a26 | 2011-08-26 13:35:22 +0800 | [diff] [blame] | 28 | return IMX_CHIP_REVISION_2_0; |
Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 29 | case 0x11: |
Jason Liu | 8d75a26 | 2011-08-26 13:35:22 +0800 | [diff] [blame] | 30 | return IMX_CHIP_REVISION_2_1; |
Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 31 | default: |
Jason Liu | 8d75a26 | 2011-08-26 13:35:22 +0800 | [diff] [blame] | 32 | return IMX_CHIP_REVISION_UNKNOWN; |
Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 33 | } |
Uwe Kleine-König | 27ad4bf | 2011-03-17 09:40:29 +0100 | [diff] [blame] | 34 | } |
Jason Liu | 8d75a26 | 2011-08-26 13:35:22 +0800 | [diff] [blame] | 35 | |
| 36 | int 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 | } |
| 43 | EXPORT_SYMBOL(mx35_revision); |