2019-05-19 21:51:31 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-07-05 16:02:59 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved.
|
|
|
|
* Copyright 2008 Juergen Beisert, kernel@pengutronix.de
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* i.MX27 specific CPU detection code
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
2012-09-14 14:14:45 +08:00
|
|
|
#include "hardware.h"
|
2008-07-05 16:02:59 +08:00
|
|
|
|
2011-08-26 13:35:20 +08:00
|
|
|
static int mx27_cpu_rev = -1;
|
|
|
|
static int mx27_cpu_partnumber;
|
2008-07-05 16:02:59 +08:00
|
|
|
|
2009-02-16 22:13:43 +08:00
|
|
|
#define SYS_CHIP_ID 0x00 /* The offset of CHIP ID register */
|
|
|
|
|
2011-08-26 13:35:20 +08:00
|
|
|
static int mx27_read_cpu_rev(void)
|
2008-07-05 16:02:59 +08:00
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
/*
|
|
|
|
* now we have access to the IO registers. As we need
|
|
|
|
* the silicon revision very early we read it here to
|
|
|
|
* avoid any further hooks
|
|
|
|
*/
|
2016-01-28 00:59:35 +08:00
|
|
|
val = imx_readl(MX27_IO_ADDRESS(MX27_SYSCTRL_BASE_ADDR + SYS_CHIP_ID));
|
2008-07-05 16:02:59 +08:00
|
|
|
|
2011-08-26 13:35:20 +08:00
|
|
|
mx27_cpu_partnumber = (int)((val >> 12) & 0xFFFF);
|
|
|
|
|
2010-11-16 01:30:01 +08:00
|
|
|
switch (val >> 28) {
|
|
|
|
case 0:
|
2011-08-26 13:35:20 +08:00
|
|
|
return IMX_CHIP_REVISION_1_0;
|
2010-11-16 01:30:01 +08:00
|
|
|
case 1:
|
2011-08-26 13:35:20 +08:00
|
|
|
return IMX_CHIP_REVISION_2_0;
|
2010-11-16 01:30:01 +08:00
|
|
|
case 2:
|
2011-08-26 13:35:20 +08:00
|
|
|
return IMX_CHIP_REVISION_2_1;
|
2010-11-16 01:30:01 +08:00
|
|
|
default:
|
2011-08-26 13:35:20 +08:00
|
|
|
return IMX_CHIP_REVISION_UNKNOWN;
|
2010-11-16 01:30:01 +08:00
|
|
|
}
|
2008-07-05 16:02:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns:
|
|
|
|
* the silicon revision of the cpu
|
|
|
|
* -EINVAL - not a mx27
|
|
|
|
*/
|
|
|
|
int mx27_revision(void)
|
|
|
|
{
|
2011-08-26 13:35:20 +08:00
|
|
|
if (mx27_cpu_rev == -1)
|
|
|
|
mx27_cpu_rev = mx27_read_cpu_rev();
|
2008-07-05 16:02:59 +08:00
|
|
|
|
2011-08-26 13:35:20 +08:00
|
|
|
if (mx27_cpu_partnumber != 0x8821)
|
2008-07-05 16:02:59 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2011-08-26 13:35:20 +08:00
|
|
|
return mx27_cpu_rev;
|
2008-07-05 16:02:59 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mx27_revision);
|