synchronousMemoryAndDatabase.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * arch/arm/plat-omap/include/plat/dmtimer.h
  3. *
  4. * OMAP Dual-Mode Timers
  5. *
  6. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  7. * Tarun Kanti DebBarma <tarun.kanti@ti.com>
  8. * Thara Gopinath <thara@ti.com>
  9. *
  10. * Platform device conversion and hwmod support.
  11. *
  12. * Copyright (C) 2005 Nokia Corporation
  13. * Author: Lauri Leukkunen <lauri.leukkunen@nokia.com>
  14. * PWM and clock framwork support by Timo Teras.
  15. *
  16. * This program is free software; you can redistribute it and/or modify it
  17. * under the terms of the GNU General Public License as published by the
  18. * Free Software Foundation; either version 2 of the License, or (at your
  19. * option) any later version.
  20. *
  21. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  22. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  23. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  24. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  28. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. * You should have received a copy of the GNU General Public License along
  31. * with this program; if not, write to the Free Software Foundation, Inc.,
  32. * 675 Mass Ave, Cambridge, MA 02139, USA.
  33. */
  34. #include <linux/delay.h>
  35. #include <linux/io.h>
  36. #include <linux/platform_device.h>
  37. #ifndef __ASM_ARCH_DMTIMER_H
  38. #define __ASM_ARCH_DMTIMER_H
  39. /* clock sources */
  40. #define OMAP_TIMER_SRC_SYS_CLK 0x00
  41. #define OMAP_TIMER_SRC_32_KHZ 0x01
  42. #define OMAP_TIMER_SRC_EXT_CLK 0x02
  43. /* timer interrupt enable bits */
  44. #define OMAP_TIMER_INT_CAPTURE (1 << 2)
  45. #define OMAP_TIMER_INT_OVERFLOW (1 << 1)
  46. #define OMAP_TIMER_INT_MATCH (1 << 0)
  47. /* trigger types */
  48. #define OMAP_TIMER_TRIGGER_NONE 0x00
  49. #define OMAP_TIMER_TRIGGER_OVERFLOW 0x01
  50. #define OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE 0x02
  51. /* posted mode types */
  52. #define OMAP_TIMER_NONPOSTED 0x00
  53. #define OMAP_TIMER_POSTED 0x01
  54. /* timer capabilities used in hwmod database */
  55. #define OMAP_TIMER_SECURE 0x80000000
  56. #define OMAP_TIMER_ALWON 0x40000000
  57. #define OMAP_TIMER_HAS_PWM 0x20000000
  58. #define OMAP_TIMER_NEEDS_RESET 0x10000000
  59. #define OMAP_TIMER_HAS_DSP_IRQ 0x08000000
  60. /*
  61. * timer errata flags
  62. *
  63. * Errata i103/i767 impacts all OMAP3/4/5 devices including AM33xx. This
  64. * errata prevents us from using posted mode on these devices, unless the
  65. * timer counter register is never read. For more details please refer to
  66. * the OMAP3/4/5 errata documents.
  67. */
  68. #define OMAP_TIMER_ERRATA_I103_I767 0x80000000
  69. struct omap_timer_capability_dev_attr {
  70. u32 timer_capability;
  71. };
  72. struct timer_regs {
  73. u32 tidr;
  74. u32 tier;
  75. u32 twer;
  76. u32 tclr;
  77. u32 tcrr;
  78. u32 tldr;
  79. u32 ttrg;
  80. u32 twps;
  81. u32 tmar;
  82. u32 tcar1;
  83. u32 tsicr;
  84. u32 tcar2;
  85. u32 tpir;
  86. u32 tnir;
  87. u32 tcvr;
  88. u32 tocr;
  89. u32 towr;
  90. };
  91. struct omap_dm_timer {
  92. int id;
  93. int irq;
  94. struct clk *fclk;
  95. void __iomem *io_base;
  96. void __iomem *irq_stat; /* TISR/IRQSTATUS interrupt status */
  97. void __iomem *irq_ena; /* irq enable */
  98. void __iomem *irq_dis; /* irq disable, only on v2 ip */
  99. void __iomem *pend; /* write pending */
  100. void __iomem *func_base; /* function register base */
  101. unsigned long rate;
  102. unsigned reserved:1;
  103. unsigned posted:1;
  104. struct timer_regs context;
  105. int (*get_context_loss_count)(struct device *);
  106. int ctx_loss_count;
  107. int revision;
  108. u32 capability;
  109. u32 errata;
  110. struct platform_device *pdev;
  111. struct list_head node;
  112. };
  113. int omap_dm_timer_reserve_systimer(int id);
  114. struct omap_dm_timer *omap_dm_timer_request(void);
  115. struct omap_dm_timer *omap_dm_timer_request_specific(int timer_id);
  116. struct omap_dm_timer *omap_dm_timer_request_by_cap(u32 cap);
  117. int omap_dm_timer_free(struct omap_dm_timer *timer);
  118. void omap_dm_timer_enable(struct omap_dm_timer *timer);
  119. void omap_dm_timer_disable(struct omap_dm_timer *timer);
  120. int omap_dm_timer_get_irq(struct omap_dm_timer *timer);
  121. u32 omap_dm_timer_modify_idlect_mask(u32 inputmask);
  122. struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *timer);
  123. int omap_dm_timer_trigger(struct omap_dm_timer *timer);
  124. int omap_dm_timer_start(struct omap_dm_timer *timer);
  125. int omap_dm_timer_stop(struct omap_dm_timer *timer);
  126. int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source);
  127. int omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload, unsigned int value);
  128. int omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload, unsigned int value);
  129. int omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable, unsigned int match);
  130. int omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on, int toggle, int trigger);
  131. int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler);
  132. int omap_dm_timer_set_int_enable(struct omap_dm_timer *timer, unsigned int value);
  133. int omap_dm_timer_set_int_disable(struct omap_dm_timer *timer, u32 mask);
  134. unsigned int omap_dm_timer_read_status(struct omap_dm_timer *timer);
  135. int omap_dm_timer_write_status(struct omap_dm_timer *timer, unsigned int value);
  136. unsigned int omap_dm_timer_read_counter(struct omap_dm_timer *timer);
  137. int omap_dm_timer_write_counter(struct omap_dm_timer *timer, unsigned int value);
  138. int omap_dm_timers_active(void);