Jason Liu | d27536c | 2011-08-26 13:35:19 +0800 | [diff] [blame] | 1 | /* |
| 2 | * MX25 CPU type detection |
| 3 | * |
| 4 | * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de> |
| 5 | * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/io.h> |
Fabio Estevam | 8b88f7e | 2015-03-13 10:31:54 -0300 | [diff] [blame^] | 14 | #include <linux/of.h> |
| 15 | #include <linux/of_address.h> |
Shawn Guo | 17c342a | 2012-09-13 21:18:39 +0800 | [diff] [blame] | 16 | |
| 17 | #include "iim.h" |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 18 | #include "hardware.h" |
Jason Liu | d27536c | 2011-08-26 13:35:19 +0800 | [diff] [blame] | 19 | |
| 20 | static int mx25_cpu_rev = -1; |
| 21 | |
| 22 | static int mx25_read_cpu_rev(void) |
| 23 | { |
| 24 | u32 rev; |
Fabio Estevam | 8b88f7e | 2015-03-13 10:31:54 -0300 | [diff] [blame^] | 25 | void __iomem *iim_base; |
| 26 | struct device_node *np; |
Jason Liu | d27536c | 2011-08-26 13:35:19 +0800 | [diff] [blame] | 27 | |
Fabio Estevam | 8b88f7e | 2015-03-13 10:31:54 -0300 | [diff] [blame^] | 28 | np = of_find_compatible_node(NULL, NULL, "fsl,imx25-iim"); |
| 29 | iim_base = of_iomap(np, 0); |
| 30 | BUG_ON(!iim_base); |
| 31 | rev = readl(iim_base + MXC_IIMSREV); |
| 32 | iounmap(iim_base); |
| 33 | |
Jason Liu | d27536c | 2011-08-26 13:35:19 +0800 | [diff] [blame] | 34 | switch (rev) { |
| 35 | case 0x00: |
| 36 | return IMX_CHIP_REVISION_1_0; |
| 37 | case 0x01: |
| 38 | return IMX_CHIP_REVISION_1_1; |
| 39 | default: |
| 40 | return IMX_CHIP_REVISION_UNKNOWN; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | int mx25_revision(void) |
| 45 | { |
| 46 | if (mx25_cpu_rev == -1) |
| 47 | mx25_cpu_rev = mx25_read_cpu_rev(); |
| 48 | |
| 49 | return mx25_cpu_rev; |
| 50 | } |
| 51 | EXPORT_SYMBOL(mx25_revision); |