blob: 863fa5a1d24ea6a8aacd646f993c1f8fe765cc82 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 *
Nicolas Pitrefb025872005-10-17 22:03:19 +010015 * $Id: xip.h,v 1.4 2005/10/17 21:03:16 nico Exp $
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 */
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/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 * We really don't want gcc to guess anything.
27 * We absolutely _need_ proper inlining.
28 */
29#include <linux/compiler.h>
30
31/*
Nicolas Pitrefb025872005-10-17 22:03:19 +010032 * Function that are modifying the flash state away from array mode must
33 * obviously not be running from flash. The __xipram is therefore marking
34 * those functions so they get relocated to ram.
35 */
36#define __xipram noinline __attribute__ ((__section__ (".data")))
37
38/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 * 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.
Thomas Gleixner97f927a2005-07-07 16:50:16 +020061 *
62 * xip_iprefetch()
63 *
64 * Macro to fill instruction prefetch
65 * e.g. a series of nops: asm volatile (".rep 8; nop; .endr");
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 */
67
Thomas Gleixner97f927a2005-07-07 16:50:16 +020068#include <asm/mtd-xip.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Thomas Gleixner97f927a2005-07-07 16:50:16 +020070#ifndef xip_irqpending
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72#warning "missing IRQ and timer primitives for XIP MTD support"
73#warning "some of the XIP MTD support code will be disabled"
74#warning "your system will therefore be unresponsive when writing or erasing flash"
75
76#define xip_irqpending() (0)
77#define xip_currtime() (0)
78#define xip_elapsed_since(x) (0)
79
80#endif
81
Thomas Gleixner97f927a2005-07-07 16:50:16 +020082#ifndef xip_iprefetch
83#define xip_iprefetch() do { } while (0)
84#endif
85
Linus Torvalds1da177e2005-04-16 15:20:36 -070086/*
87 * xip_cpu_idle() is used when waiting for a delay equal or larger than
88 * the system timer tick period. This should put the CPU into idle mode
89 * to save power and to be woken up only when some interrupts are pending.
Thomas Gleixner97f927a2005-07-07 16:50:16 +020090 * This should not rely upon standard kernel code.
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 */
Thomas Gleixner97f927a2005-07-07 16:50:16 +020092#ifndef xip_cpu_idle
Linus Torvalds1da177e2005-04-16 15:20:36 -070093#define xip_cpu_idle() do { } while (0)
94#endif
95
96#else
97
98#define __xipram
99
100#endif /* CONFIG_MTD_XIP */
101
102#endif /* __LINUX_MTD_XIP_H__ */