blob: a4e352b1dfe6e0b95046c12d4bac0a015b517111 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * MTD primitives for XIP support
4 *
5 * Author: Nicolas Pitre
6 * Created: Nov 2, 2004
7 * Copyright: (C) 2004 MontaVista Software, Inc.
8 *
9 * This XIP support for MTD has been loosely inspired
10 * by an earlier patch authored by David Woodhouse.
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 */
12
13#ifndef __LINUX_MTD_XIP_H__
14#define __LINUX_MTD_XIP_H__
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17#ifdef CONFIG_MTD_XIP
18
19/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 * We really don't want gcc to guess anything.
21 * We absolutely _need_ proper inlining.
22 */
23#include <linux/compiler.h>
24
25/*
Nicolas Pitrefb025872005-10-17 22:03:19 +010026 * 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 */
Arnd Bergmann129f6c42017-07-21 22:26:25 +020030#ifdef CONFIG_XIP_KERNEL
31#define __xipram noinline __attribute__ ((__section__ (".xiptext")))
32#endif
Nicolas Pitrefb025872005-10-17 22:03:19 +010033
34/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 * Each architecture has to provide the following macros. They must access
36 * the hardware directly and not rely on any other (XIP) functions since they
37 * won't be available when used (flash not in array mode).
38 *
39 * xip_irqpending()
40 *
41 * return non zero when any hardware interrupt is pending.
42 *
43 * xip_currtime()
44 *
45 * return a platform specific time reference to be used with
46 * xip_elapsed_since().
47 *
48 * xip_elapsed_since(x)
49 *
50 * return in usecs the elapsed timebetween now and the reference x as
51 * returned by xip_currtime().
52 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -030053 * note 1: conversion to usec can be approximated, as long as the
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 * returned value is <= the real elapsed time.
55 * note 2: this should be able to cope with a few seconds without
56 * overflowing.
Thomas Gleixner97f927a2005-07-07 16:50:16 +020057 *
58 * xip_iprefetch()
Thomas Gleixner61ecfa82005-11-07 11:15:31 +000059 *
Thomas Gleixner97f927a2005-07-07 16:50:16 +020060 * Macro to fill instruction prefetch
Thomas Gleixner61ecfa82005-11-07 11:15:31 +000061 * e.g. a series of nops: asm volatile (".rep 8; nop; .endr");
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 */
63
Thomas Gleixner97f927a2005-07-07 16:50:16 +020064#include <asm/mtd-xip.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Thomas Gleixner97f927a2005-07-07 16:50:16 +020066#ifndef xip_irqpending
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68#warning "missing IRQ and timer primitives for XIP MTD support"
69#warning "some of the XIP MTD support code will be disabled"
70#warning "your system will therefore be unresponsive when writing or erasing flash"
71
72#define xip_irqpending() (0)
73#define xip_currtime() (0)
74#define xip_elapsed_since(x) (0)
75
76#endif
77
Thomas Gleixner97f927a2005-07-07 16:50:16 +020078#ifndef xip_iprefetch
79#define xip_iprefetch() do { } while (0)
80#endif
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082/*
83 * xip_cpu_idle() is used when waiting for a delay equal or larger than
84 * the system timer tick period. This should put the CPU into idle mode
85 * to save power and to be woken up only when some interrupts are pending.
Thomas Gleixner97f927a2005-07-07 16:50:16 +020086 * This should not rely upon standard kernel code.
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 */
Thomas Gleixner97f927a2005-07-07 16:50:16 +020088#ifndef xip_cpu_idle
Linus Torvalds1da177e2005-04-16 15:20:36 -070089#define xip_cpu_idle() do { } while (0)
90#endif
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#endif /* CONFIG_MTD_XIP */
93
Arnd Bergmann129f6c42017-07-21 22:26:25 +020094#ifndef __xipram
95#define __xipram
96#endif
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#endif /* __LINUX_MTD_XIP_H__ */