diff options
Diffstat (limited to 'include/linux/mtd/xip.h')
-rw-r--r-- | include/linux/mtd/xip.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/include/linux/mtd/xip.h b/include/linux/mtd/xip.h new file mode 100644 index 000000000000..fc071125cbcc --- /dev/null +++ b/include/linux/mtd/xip.h | |||
@@ -0,0 +1,107 @@ | |||
1 | /* | ||
2 | * MTD primitives for XIP support | ||
3 | * | ||
4 | * Author: Nicolas Pitre | ||
5 | * Created: Nov 2, 2004 | ||
6 | * Copyright: (C) 2004 MontaVista Software, Inc. | ||
7 | * | ||
8 | * This XIP support for MTD has been loosely inspired | ||
9 | * by an earlier patch authored by David Woodhouse. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | * | ||
15 | * $Id: xip.h,v 1.2 2004/12/01 15:49:10 nico Exp $ | ||
16 | */ | ||
17 | |||
18 | #ifndef __LINUX_MTD_XIP_H__ | ||
19 | #define __LINUX_MTD_XIP_H__ | ||
20 | |||
21 | #include <linux/config.h> | ||
22 | |||
23 | #ifdef CONFIG_MTD_XIP | ||
24 | |||
25 | /* | ||
26 | * Function that are modifying the flash state away from array mode must | ||
27 | * obviously not be running from flash. The __xipram is therefore marking | ||
28 | * those functions so they get relocated to ram. | ||
29 | */ | ||
30 | #define __xipram __attribute__ ((__section__ (".data"))) | ||
31 | |||
32 | /* | ||
33 | * We really don't want gcc to guess anything. | ||
34 | * We absolutely _need_ proper inlining. | ||
35 | */ | ||
36 | #include <linux/compiler.h> | ||
37 | |||
38 | /* | ||
39 | * Each architecture has to provide the following macros. They must access | ||
40 | * the hardware directly and not rely on any other (XIP) functions since they | ||
41 | * won't be available when used (flash not in array mode). | ||
42 | * | ||
43 | * xip_irqpending() | ||
44 | * | ||
45 | * return non zero when any hardware interrupt is pending. | ||
46 | * | ||
47 | * xip_currtime() | ||
48 | * | ||
49 | * return a platform specific time reference to be used with | ||
50 | * xip_elapsed_since(). | ||
51 | * | ||
52 | * xip_elapsed_since(x) | ||
53 | * | ||
54 | * return in usecs the elapsed timebetween now and the reference x as | ||
55 | * returned by xip_currtime(). | ||
56 | * | ||
57 | * note 1: convertion to usec can be approximated, as long as the | ||
58 | * returned value is <= the real elapsed time. | ||
59 | * note 2: this should be able to cope with a few seconds without | ||
60 | * overflowing. | ||
61 | */ | ||
62 | |||
63 | #if defined(CONFIG_ARCH_SA1100) || defined(CONFIG_ARCH_PXA) | ||
64 | |||
65 | #include <asm/hardware.h> | ||
66 | #ifdef CONFIG_ARCH_PXA | ||
67 | #include <asm/arch/pxa-regs.h> | ||
68 | #endif | ||
69 | |||
70 | #define xip_irqpending() (ICIP & ICMR) | ||
71 | |||
72 | /* we sample OSCR and convert desired delta to usec (1/4 ~= 1000000/3686400) */ | ||
73 | #define xip_currtime() (OSCR) | ||
74 | #define xip_elapsed_since(x) (signed)((OSCR - (x)) / 4) | ||
75 | |||
76 | #else | ||
77 | |||
78 | #warning "missing IRQ and timer primitives for XIP MTD support" | ||
79 | #warning "some of the XIP MTD support code will be disabled" | ||
80 | #warning "your system will therefore be unresponsive when writing or erasing flash" | ||
81 | |||
82 | #define xip_irqpending() (0) | ||
83 | #define xip_currtime() (0) | ||
84 | #define xip_elapsed_since(x) (0) | ||
85 | |||
86 | #endif | ||
87 | |||
88 | /* | ||
89 | * xip_cpu_idle() is used when waiting for a delay equal or larger than | ||
90 | * the system timer tick period. This should put the CPU into idle mode | ||
91 | * to save power and to be woken up only when some interrupts are pending. | ||
92 | * As above, this should not rely upon standard kernel code. | ||
93 | */ | ||
94 | |||
95 | #if defined(CONFIG_CPU_XSCALE) | ||
96 | #define xip_cpu_idle() asm volatile ("mcr p14, 0, %0, c7, c0, 0" :: "r" (1)) | ||
97 | #else | ||
98 | #define xip_cpu_idle() do { } while (0) | ||
99 | #endif | ||
100 | |||
101 | #else | ||
102 | |||
103 | #define __xipram | ||
104 | |||
105 | #endif /* CONFIG_MTD_XIP */ | ||
106 | |||
107 | #endif /* __LINUX_MTD_XIP_H__ */ | ||