mtd-xip.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * MTD primitives for XIP support. Architecture specific functions.
  4. *
  5. * Do not include this file directly. It's included from linux/mtd/xip.h
  6. *
  7. * Author: Vladimir Barinov <[email protected]>
  8. *
  9. * (c) 2005 MontaVista Software, Inc.
  10. */
  11. #ifndef __ARCH_OMAP_MTD_XIP_H__
  12. #define __ARCH_OMAP_MTD_XIP_H__
  13. #include "hardware.h"
  14. #include <linux/soc/ti/omap1-io.h>
  15. #define OMAP_MPU_TIMER_BASE (0xfffec500)
  16. #define OMAP_MPU_TIMER_OFFSET 0x100
  17. typedef struct {
  18. u32 cntl; /* CNTL_TIMER, R/W */
  19. u32 load_tim; /* LOAD_TIM, W */
  20. u32 read_tim; /* READ_TIM, R */
  21. } xip_omap_mpu_timer_regs_t;
  22. #define xip_omap_mpu_timer_base(n) \
  23. ((volatile xip_omap_mpu_timer_regs_t*)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE + \
  24. (n)*OMAP_MPU_TIMER_OFFSET))
  25. static inline unsigned long xip_omap_mpu_timer_read(int nr)
  26. {
  27. volatile xip_omap_mpu_timer_regs_t* timer = xip_omap_mpu_timer_base(nr);
  28. return timer->read_tim;
  29. }
  30. #define xip_irqpending() \
  31. (omap_readl(OMAP_IH1_ITR) & ~omap_readl(OMAP_IH1_MIR))
  32. #define xip_currtime() (~xip_omap_mpu_timer_read(0))
  33. /*
  34. * It's permitted to do approximation for xip_elapsed_since macro
  35. * (see linux/mtd/xip.h)
  36. */
  37. #ifdef CONFIG_MACH_OMAP_PERSEUS2
  38. #define xip_elapsed_since(x) (signed)((~xip_omap_mpu_timer_read(0) - (x)) / 7)
  39. #else
  40. #define xip_elapsed_since(x) (signed)((~xip_omap_mpu_timer_read(0) - (x)) / 6)
  41. #endif
  42. /*
  43. * xip_cpu_idle() is used when waiting for a delay equal or larger than
  44. * the system timer tick period. This should put the CPU into idle mode
  45. * to save power and to be woken up only when some interrupts are pending.
  46. * As above, this should not rely upon standard kernel code.
  47. */
  48. #define xip_cpu_idle() asm volatile ("mcr p15, 0, %0, c7, c0, 4" :: "r" (1))
  49. #endif /* __ARCH_OMAP_MTD_XIP_H__ */