99 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * MTD primitives for XIP support4 *5 * Author: Nicolas Pitre6 * Created: Nov 2, 20047 * Copyright: (C) 2004 MontaVista Software, Inc.8 *9 * This XIP support for MTD has been loosely inspired10 * by an earlier patch authored by David Woodhouse.11 */12 13#ifndef __LINUX_MTD_XIP_H__14#define __LINUX_MTD_XIP_H__15 16 17#ifdef CONFIG_MTD_XIP18 19/*20 * We really don't want gcc to guess anything.21 * We absolutely _need_ proper inlining.22 */23#include <linux/compiler.h>24 25/*26 * Function that are modifying the flash state away from array mode must27 * obviously not be running from flash. The __xipram is therefore marking28 * those functions so they get relocated to ram.29 */30#ifdef CONFIG_XIP_KERNEL31#define __xipram noinline __section(".xiptext")32#endif33 34/*35 * Each architecture has to provide the following macros. They must access36 * the hardware directly and not rely on any other (XIP) functions since they37 * 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 with46 * xip_elapsed_since().47 *48 * xip_elapsed_since(x)49 *50 * return in usecs the elapsed timebetween now and the reference x as51 * returned by xip_currtime().52 *53 * note 1: conversion to usec can be approximated, as long as the54 * returned value is <= the real elapsed time.55 * note 2: this should be able to cope with a few seconds without56 * overflowing.57 *58 * xip_iprefetch()59 *60 * Macro to fill instruction prefetch61 * e.g. a series of nops: asm volatile (".rep 8; nop; .endr");62 */63 64#include <asm/mtd-xip.h>65 66#ifndef xip_irqpending67 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#endif77 78#ifndef xip_iprefetch79#define xip_iprefetch() do { } while (0)80#endif81 82/*83 * xip_cpu_idle() is used when waiting for a delay equal or larger than84 * the system timer tick period. This should put the CPU into idle mode85 * to save power and to be woken up only when some interrupts are pending.86 * This should not rely upon standard kernel code.87 */88#ifndef xip_cpu_idle89#define xip_cpu_idle() do { } while (0)90#endif91 92#endif /* CONFIG_MTD_XIP */93 94#ifndef __xipram95#define __xipram96#endif97 98#endif /* __LINUX_MTD_XIP_H__ */99