summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuinn Jensen <quinn.jensen@freescale.com>2007-10-24 21:26:33 -0600
committerQuinn Jensen <quinn.jensen@freescale.com>2007-10-24 21:26:33 -0600
commit0c129f1be7a29163e62899254326d8d15a9d3ef9 (patch)
tree3db454a7d00e4dc24b80249b18c13e07170f2634
parent3c26454dc04f150f577049bf1f1adf6c999f126b (diff)
CR ENGR00050116 Fix flawed implementation of XIP Macros
Patch for CR ENGR00050116 Fix flawed implementation of XIP Macros. The existing flawed implementations of xip_currtime, xip_elasped_since and xip_irqpending macros are fixed. Applies to linux 2.6.22 kernel for MX platforms. http://www.bitshrine.org/gpp/linux-2.6.22-mx-CR-ENGR00050116-Fix-flawed-implementation-.patch
-rw-r--r--arch/arm/mach-mx27/time.c3
-rw-r--r--arch/arm/plat-mxc/time.c3
-rw-r--r--drivers/mtd/maps/mxc_nor.c5
-rw-r--r--include/asm-arm/arch-mxc/mtd-xip.h24
4 files changed, 29 insertions, 6 deletions
diff --git a/arch/arm/mach-mx27/time.c b/arch/arm/mach-mx27/time.c
index 30d8dbcb192c..3d471b053a5a 100644
--- a/arch/arm/mach-mx27/time.c
+++ b/arch/arm/mach-mx27/time.c
@@ -36,6 +36,7 @@
#include <linux/io.h>
#include <linux/clocksource.h>
#include <linux/clockchips.h>
+#include <linux/mtd/xip.h>
#include <asm/hardware.h>
#include <asm/mach/time.h>
@@ -161,7 +162,7 @@ static struct irqaction timer_irq = {
.handler = mxc_timer_interrupt,
};
-static cycle_t mxc_gpt_read(void)
+static cycle_t __xipram mxc_gpt_read(void)
{
return __raw_readl(MXC_GPT_GPTCNT);
}
diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c
index 4dd10c3f4c7e..5f83111c08db 100644
--- a/arch/arm/plat-mxc/time.c
+++ b/arch/arm/plat-mxc/time.c
@@ -35,6 +35,7 @@
#include <linux/io.h>
#include <linux/clocksource.h>
#include <linux/clockchips.h>
+#include <linux/mtd/xip.h>
#include <asm/hardware.h>
#include <asm/mach/time.h>
@@ -185,7 +186,7 @@ static struct irqaction timer_irq = {
.handler = mxc_timer_interrupt,
};
-static cycle_t mxc_gpt_read(void)
+static cycle_t __xipram mxc_gpt_read(void)
{
return __raw_readl(MXC_GPT_GPTCNT);
}
diff --git a/drivers/mtd/maps/mxc_nor.c b/drivers/mtd/maps/mxc_nor.c
index 14da2a28ea57..6c69e0164c73 100644
--- a/drivers/mtd/maps/mxc_nor.c
+++ b/drivers/mtd/maps/mxc_nor.c
@@ -22,6 +22,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
+#include <linux/clocksource.h>
#include <asm/mach-types.h>
#include <asm/mach/flash.h>
@@ -31,6 +32,8 @@
static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
#endif
+struct clocksource *mtd_xip_clksrc;
+
struct mxcflash_info {
struct mtd_partition *parts;
struct mtd_info *mtd;
@@ -75,6 +78,8 @@ static int __devinit mxcflash_probe(struct platform_device *pdev)
info->map.size = size;
info->map.bankwidth = flash->width;
+ mtd_xip_clksrc = clocksource_get_next();
+
simple_map_init(&info->map);
info->mtd = do_map_probe(flash->map_name, &info->map);
if (!info->mtd) {
diff --git a/include/asm-arm/arch-mxc/mtd-xip.h b/include/asm-arm/arch-mxc/mtd-xip.h
index b934bc894662..e0e91d6b18ff 100644
--- a/include/asm-arm/arch-mxc/mtd-xip.h
+++ b/include/asm-arm/arch-mxc/mtd-xip.h
@@ -20,13 +20,29 @@
#ifndef __ARCH_MXC_MTD_XIP_H__
#define __ARCH_MXC_MTD_XIP_H__
+#include <linux/clocksource.h>
#include <asm/hardware.h>
#include <asm/arch/system.h>
+
#define xip_irqpending() \
- (~(__raw_readl(AVIC_NIVECSR) & __raw_readl(AVIC_FIVECSR)))
-#define xip_currtime() get_cycles()
-#define xip_elapsed_since(x) \
- (signed)(((xip_currtime() - (x)) * USEC_PER_SEC) / LATCH)
+ ((__raw_readl(AVIC_NIVECSR) & __raw_readl(AVIC_FIVECSR)) != 0xFFFFFFFF)
+
+extern struct clocksource *mtd_xip_clksrc;
+
+#define xip_currtime() (unsigned long)clocksource_read(mtd_xip_clksrc)
+
+#if CLOCK_TICK_RATE > 1000000
+#define NUMERATOR 1
+#define DENOMINATOR (CLOCK_TICK_RATE/1000000 + 1)
+#else
+#define NUMERATOR (1000000/CLOCK_TICK_RATE)
+#define DENOMINATOR 1
+#endif
+
+static inline unsigned long xip_elapsed_since(unsigned long x)
+{
+ return (((xip_currtime() - x) * NUMERATOR) / DENOMINATOR);
+}
/*
* Wait For Interrupt command for XIP kernel to put CPU in Idle mode