1 /* SPDX-License-Identifier: GPL-2.0-only */ << 2 /* 1 /* 3 * MTD primitives for XIP support 2 * MTD primitives for XIP support 4 * 3 * 5 * Author: Nicolas Pitre 4 * Author: Nicolas Pitre 6 * Created: Nov 2, 2004 5 * Created: Nov 2, 2004 7 * Copyright: (C) 2004 MontaVista Software, 6 * Copyright: (C) 2004 MontaVista Software, Inc. 8 * 7 * 9 * This XIP support for MTD has been loosely i 8 * This XIP support for MTD has been loosely inspired 10 * by an earlier patch authored by David Woodh 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. 11 */ 14 */ 12 15 13 #ifndef __LINUX_MTD_XIP_H__ 16 #ifndef __LINUX_MTD_XIP_H__ 14 #define __LINUX_MTD_XIP_H__ 17 #define __LINUX_MTD_XIP_H__ 15 18 16 19 17 #ifdef CONFIG_MTD_XIP 20 #ifdef CONFIG_MTD_XIP 18 21 19 /* 22 /* 20 * We really don't want gcc to guess anything. 23 * We really don't want gcc to guess anything. 21 * We absolutely _need_ proper inlining. 24 * We absolutely _need_ proper inlining. 22 */ 25 */ 23 #include <linux/compiler.h> 26 #include <linux/compiler.h> 24 27 25 /* 28 /* 26 * Function that are modifying the flash state 29 * Function that are modifying the flash state away from array mode must 27 * obviously not be running from flash. The _ 30 * obviously not be running from flash. The __xipram is therefore marking 28 * those functions so they get relocated to ra 31 * those functions so they get relocated to ram. 29 */ 32 */ 30 #ifdef CONFIG_XIP_KERNEL 33 #ifdef CONFIG_XIP_KERNEL 31 #define __xipram noinline __section(".xiptext" !! 34 #define __xipram noinline __attribute__ ((__section__ (".xiptext"))) 32 #endif 35 #endif 33 36 34 /* 37 /* 35 * Each architecture has to provide the follow 38 * Each architecture has to provide the following macros. They must access 36 * the hardware directly and not rely on any o 39 * the hardware directly and not rely on any other (XIP) functions since they 37 * won't be available when used (flash not in 40 * won't be available when used (flash not in array mode). 38 * 41 * 39 * xip_irqpending() 42 * xip_irqpending() 40 * 43 * 41 * return non zero when any hardware inte 44 * return non zero when any hardware interrupt is pending. 42 * 45 * 43 * xip_currtime() 46 * xip_currtime() 44 * 47 * 45 * return a platform specific time refere 48 * return a platform specific time reference to be used with 46 * xip_elapsed_since(). 49 * xip_elapsed_since(). 47 * 50 * 48 * xip_elapsed_since(x) 51 * xip_elapsed_since(x) 49 * 52 * 50 * return in usecs the elapsed timebetwee 53 * return in usecs the elapsed timebetween now and the reference x as 51 * returned by xip_currtime(). 54 * returned by xip_currtime(). 52 * 55 * 53 * note 1: conversion to usec can be appr 56 * note 1: conversion to usec can be approximated, as long as the 54 * returned value is <= the real 57 * returned value is <= the real elapsed time. 55 * note 2: this should be able to cope wi 58 * note 2: this should be able to cope with a few seconds without 56 * overflowing. 59 * overflowing. 57 * 60 * 58 * xip_iprefetch() 61 * xip_iprefetch() 59 * 62 * 60 * Macro to fill instruction prefetch 63 * Macro to fill instruction prefetch 61 * e.g. a series of nops: asm volatile ( 64 * e.g. a series of nops: asm volatile (".rep 8; nop; .endr"); 62 */ 65 */ 63 66 64 #include <asm/mtd-xip.h> 67 #include <asm/mtd-xip.h> 65 68 66 #ifndef xip_irqpending 69 #ifndef xip_irqpending 67 70 68 #warning "missing IRQ and timer primitives for 71 #warning "missing IRQ and timer primitives for XIP MTD support" 69 #warning "some of the XIP MTD support code wil 72 #warning "some of the XIP MTD support code will be disabled" 70 #warning "your system will therefore be unresp 73 #warning "your system will therefore be unresponsive when writing or erasing flash" 71 74 72 #define xip_irqpending() (0) 75 #define xip_irqpending() (0) 73 #define xip_currtime() (0) 76 #define xip_currtime() (0) 74 #define xip_elapsed_since(x) (0) 77 #define xip_elapsed_since(x) (0) 75 78 76 #endif 79 #endif 77 80 78 #ifndef xip_iprefetch 81 #ifndef xip_iprefetch 79 #define xip_iprefetch() do { } while ( 82 #define xip_iprefetch() do { } while (0) 80 #endif 83 #endif 81 84 82 /* 85 /* 83 * xip_cpu_idle() is used when waiting for a d 86 * xip_cpu_idle() is used when waiting for a delay equal or larger than 84 * the system timer tick period. This should 87 * the system timer tick period. This should put the CPU into idle mode 85 * to save power and to be woken up only when 88 * to save power and to be woken up only when some interrupts are pending. 86 * This should not rely upon standard kernel c 89 * This should not rely upon standard kernel code. 87 */ 90 */ 88 #ifndef xip_cpu_idle 91 #ifndef xip_cpu_idle 89 #define xip_cpu_idle() do { } while (0) 92 #define xip_cpu_idle() do { } while (0) 90 #endif 93 #endif 91 94 92 #endif /* CONFIG_MTD_XIP */ 95 #endif /* CONFIG_MTD_XIP */ 93 96 94 #ifndef __xipram 97 #ifndef __xipram 95 #define __xipram 98 #define __xipram 96 #endif 99 #endif 97 100 98 #endif /* __LINUX_MTD_XIP_H__ */ 101 #endif /* __LINUX_MTD_XIP_H__ */ 99 102
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.