/*1* Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved.2* Copyright 2008 Juergen Beisert, [email protected]3*4* This program is free software; you can redistribute it and/or5* modify it under the terms of the GNU General Public License6* as published by the Free Software Foundation; either version 27* of the License, or (at your option) any later version.8* This program is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License14* along with this program; if not, write to the Free Software15* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,16* MA 02110-1301, USA.17*/1819/*20* i.MX27 specific CPU detection code21*/2223#include <linux/io.h>24#include <linux/module.h>2526#include <mach/hardware.h>2728static int cpu_silicon_rev = -1;29static int cpu_partnumber;3031#define SYS_CHIP_ID 0x00 /* The offset of CHIP ID register */3233static void query_silicon_parameter(void)34{35u32 val;36/*37* now we have access to the IO registers. As we need38* the silicon revision very early we read it here to39* avoid any further hooks40*/41val = __raw_readl(MX27_IO_ADDRESS(MX27_SYSCTRL_BASE_ADDR42+ SYS_CHIP_ID));4344switch (val >> 28) {45case 0:46cpu_silicon_rev = IMX_CHIP_REVISION_1_0;47break;48case 1:49cpu_silicon_rev = IMX_CHIP_REVISION_2_0;50break;51case 2:52cpu_silicon_rev = IMX_CHIP_REVISION_2_1;53break;54default:55cpu_silicon_rev = IMX_CHIP_REVISION_UNKNOWN;56}57cpu_partnumber = (int)((val >> 12) & 0xFFFF);58}5960/*61* Returns:62* the silicon revision of the cpu63* -EINVAL - not a mx2764*/65int mx27_revision(void)66{67if (cpu_silicon_rev == -1)68query_silicon_parameter();6970if (cpu_partnumber != 0x8821)71return -EINVAL;7273return cpu_silicon_rev;74}75EXPORT_SYMBOL(mx27_revision);767778