| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | */ | 
|  | 15 |  | 
|  | 16 | #ifndef __LINUX_MTD_XIP_H__ | 
|  | 17 | #define __LINUX_MTD_XIP_H__ | 
|  | 18 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 |  | 
|  | 20 | #ifdef CONFIG_MTD_XIP | 
|  | 21 |  | 
|  | 22 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | * We really don't want gcc to guess anything. | 
|  | 24 | * We absolutely _need_ proper inlining. | 
|  | 25 | */ | 
|  | 26 | #include <linux/compiler.h> | 
|  | 27 |  | 
|  | 28 | /* | 
| Nicolas Pitre | fb02587 | 2005-10-17 22:03:19 +0100 | [diff] [blame] | 29 | * Function that are modifying the flash state away from array mode must | 
|  | 30 | * obviously not be running from flash.  The __xipram is therefore marking | 
|  | 31 | * those functions so they get relocated to ram. | 
|  | 32 | */ | 
|  | 33 | #define __xipram noinline __attribute__ ((__section__ (".data"))) | 
|  | 34 |  | 
|  | 35 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | * Each architecture has to provide the following macros.  They must access | 
|  | 37 | * the hardware directly and not rely on any other (XIP) functions since they | 
|  | 38 | * won't be available when used (flash not in array mode). | 
|  | 39 | * | 
|  | 40 | * xip_irqpending() | 
|  | 41 | * | 
|  | 42 | * 	return non zero when any hardware interrupt is pending. | 
|  | 43 | * | 
|  | 44 | * xip_currtime() | 
|  | 45 | * | 
|  | 46 | * 	return a platform specific time reference to be used with | 
|  | 47 | * 	xip_elapsed_since(). | 
|  | 48 | * | 
|  | 49 | * xip_elapsed_since(x) | 
|  | 50 | * | 
|  | 51 | * 	return in usecs the elapsed timebetween now and the reference x as | 
|  | 52 | * 	returned by xip_currtime(). | 
|  | 53 | * | 
|  | 54 | * 	note 1: convertion to usec can be approximated, as long as the | 
|  | 55 | * 		returned value is <= the real elapsed time. | 
|  | 56 | * 	note 2: this should be able to cope with a few seconds without | 
|  | 57 | * 		overflowing. | 
| Thomas Gleixner | 97f927a | 2005-07-07 16:50:16 +0200 | [diff] [blame] | 58 | * | 
|  | 59 | * xip_iprefetch() | 
| Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 60 | * | 
| Thomas Gleixner | 97f927a | 2005-07-07 16:50:16 +0200 | [diff] [blame] | 61 | *      Macro to fill instruction prefetch | 
| Thomas Gleixner | 61ecfa8 | 2005-11-07 11:15:31 +0000 | [diff] [blame] | 62 | *	e.g. a series of nops:  asm volatile (".rep 8; nop; .endr"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | */ | 
|  | 64 |  | 
| Thomas Gleixner | 97f927a | 2005-07-07 16:50:16 +0200 | [diff] [blame] | 65 | #include <asm/mtd-xip.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 |  | 
| Thomas Gleixner | 97f927a | 2005-07-07 16:50:16 +0200 | [diff] [blame] | 67 | #ifndef xip_irqpending | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 |  | 
|  | 69 | #warning "missing IRQ and timer primitives for XIP MTD support" | 
|  | 70 | #warning "some of the XIP MTD support code will be disabled" | 
|  | 71 | #warning "your system will therefore be unresponsive when writing or erasing flash" | 
|  | 72 |  | 
|  | 73 | #define xip_irqpending()	(0) | 
|  | 74 | #define xip_currtime()		(0) | 
|  | 75 | #define xip_elapsed_since(x)	(0) | 
|  | 76 |  | 
|  | 77 | #endif | 
|  | 78 |  | 
| Thomas Gleixner | 97f927a | 2005-07-07 16:50:16 +0200 | [diff] [blame] | 79 | #ifndef xip_iprefetch | 
|  | 80 | #define xip_iprefetch()		do { } while (0) | 
|  | 81 | #endif | 
|  | 82 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | /* | 
|  | 84 | * xip_cpu_idle() is used when waiting for a delay equal or larger than | 
|  | 85 | * the system timer tick period.  This should put the CPU into idle mode | 
|  | 86 | * to save power and to be woken up only when some interrupts are pending. | 
| Thomas Gleixner | 97f927a | 2005-07-07 16:50:16 +0200 | [diff] [blame] | 87 | * This should not rely upon standard kernel code. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | */ | 
| Thomas Gleixner | 97f927a | 2005-07-07 16:50:16 +0200 | [diff] [blame] | 89 | #ifndef xip_cpu_idle | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | #define xip_cpu_idle()  do { } while (0) | 
|  | 91 | #endif | 
|  | 92 |  | 
|  | 93 | #else | 
|  | 94 |  | 
|  | 95 | #define __xipram | 
|  | 96 |  | 
|  | 97 | #endif /* CONFIG_MTD_XIP */ | 
|  | 98 |  | 
|  | 99 | #endif /* __LINUX_MTD_XIP_H__ */ |