vp.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * OMAP3/4 Voltage Processor (VP) structure and macro definitions
  3. *
  4. * Copyright (C) 2007, 2010 Texas Instruments, Inc.
  5. * Rajendra Nayak <rnayak@ti.com>
  6. * Lesly A M <x0080970@ti.com>
  7. * Thara Gopinath <thara@ti.com>
  8. *
  9. * Copyright (C) 2008, 2011 Nokia Corporation
  10. * Kalle Jokiniemi
  11. * Paul Walmsley
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License version
  15. * 2 as published by the Free Software Foundation.
  16. */
  17. #ifndef __ARCH_ARM_MACH_OMAP2_VP_H
  18. #define __ARCH_ARM_MACH_OMAP2_VP_H
  19. #include <linux/kernel.h>
  20. struct voltagedomain;
  21. /*
  22. * Voltage Processor (VP) identifiers
  23. */
  24. #define OMAP3_VP_VDD_MPU_ID 0
  25. #define OMAP3_VP_VDD_CORE_ID 1
  26. #define OMAP4_VP_VDD_CORE_ID 0
  27. #define OMAP4_VP_VDD_IVA_ID 1
  28. #define OMAP4_VP_VDD_MPU_ID 2
  29. /* XXX document */
  30. #define VP_IDLE_TIMEOUT 200
  31. #define VP_TRANXDONE_TIMEOUT 300
  32. /**
  33. * struct omap_vp_ops - per-VP operations
  34. * @check_txdone: check for VP transaction done
  35. * @clear_txdone: clear VP transaction done status
  36. */
  37. struct omap_vp_ops {
  38. u32 (*check_txdone)(u8 vp_id);
  39. void (*clear_txdone)(u8 vp_id);
  40. };
  41. /**
  42. * struct omap_vp_common_data - register data common to all VDDs
  43. * @vpconfig_errorgain_mask: ERRORGAIN bitmask in the PRM_VP*_CONFIG reg
  44. * @vpconfig_initvoltage_mask: INITVOLTAGE bitmask in the PRM_VP*_CONFIG reg
  45. * @vpconfig_timeouten_mask: TIMEOUT bitmask in the PRM_VP*_CONFIG reg
  46. * @vpconfig_initvdd: INITVDD bitmask in the PRM_VP*_CONFIG reg
  47. * @vpconfig_forceupdate: FORCEUPDATE bitmask in the PRM_VP*_CONFIG reg
  48. * @vpconfig_vpenable: VPENABLE bitmask in the PRM_VP*_CONFIG reg
  49. * @vpconfig_erroroffset_shift: ERROROFFSET field shift in PRM_VP*_CONFIG reg
  50. * @vpconfig_errorgain_shift: ERRORGAIN field shift in PRM_VP*_CONFIG reg
  51. * @vpconfig_initvoltage_shift: INITVOLTAGE field shift in PRM_VP*_CONFIG reg
  52. * @vpconfig_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg
  53. * @vpconfig_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg
  54. * @vpconfig_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg
  55. * @vpconfig_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg
  56. * @vpconfig_vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
  57. * @vpconfig_vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
  58. * @vpconfig_vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
  59. * @prm_mod: PRM module id used for PRM register access
  60. *
  61. * XXX It it not necessary to have both a mask and a shift for the same
  62. * bitfield - remove one
  63. * XXX Many of these fields are wrongly named -- e.g., vpconfig_smps* -- fix!
  64. */
  65. struct omap_vp_common_data {
  66. u32 vpconfig_errorgain_mask;
  67. u32 vpconfig_initvoltage_mask;
  68. u32 vpconfig_timeouten;
  69. u32 vpconfig_initvdd;
  70. u32 vpconfig_forceupdate;
  71. u32 vpconfig_vpenable;
  72. s16 prm_mod;
  73. u8 vpconfig_erroroffset_shift;
  74. u8 vpconfig_errorgain_shift;
  75. u8 vpconfig_initvoltage_shift;
  76. u8 vstepmin_stepmin_shift;
  77. u8 vstepmin_smpswaittimemin_shift;
  78. u8 vstepmax_stepmax_shift;
  79. u8 vstepmax_smpswaittimemax_shift;
  80. u8 vlimitto_vddmin_shift;
  81. u8 vlimitto_vddmax_shift;
  82. u8 vlimitto_timeout_shift;
  83. const struct omap_vp_ops *ops;
  84. };
  85. /**
  86. * struct omap_vp_instance_data - VP register offsets (per-VDD)
  87. * @vp_common: pointer to struct omap_vp_common_data * for this SoC
  88. * @vpconfig: PRM_VP*_CONFIG reg offset from PRM start
  89. * @vstepmin: PRM_VP*_VSTEPMIN reg offset from PRM start
  90. * @vlimitto: PRM_VP*_VLIMITTO reg offset from PRM start
  91. * @vstatus: PRM_VP*_VSTATUS reg offset from PRM start
  92. * @voltage: PRM_VP*_VOLTAGE reg offset from PRM start
  93. * @id: Unique identifier for VP instance.
  94. *
  95. * XXX vp_common is probably not needed since it is per-SoC
  96. */
  97. struct omap_vp_instance_data {
  98. const struct omap_vp_common_data *vp_common;
  99. u8 vpconfig;
  100. u8 vstepmin;
  101. u8 vstepmax;
  102. u8 vlimitto;
  103. u8 vstatus;
  104. u8 voltage;
  105. u8 id;
  106. };
  107. /**
  108. * struct omap_vp_runtime_data - VP data populated at runtime by code
  109. * @vpconfig_erroroffset: value of ERROROFFSET bitfield in PRM_VP*_CONFIG
  110. * @vpconfig_errorgain: value of ERRORGAIN bitfield in PRM_VP*_CONFIG
  111. * @vstepmin_smpswaittimemin: value of SMPSWAITTIMEMIN bitfield in PRM_VP*_VSTEPMIN
  112. * @vstepmax_smpswaittimemax: value of SMPSWAITTIMEMAX bitfield in PRM_VP*_VSTEPMAX
  113. * @vlimitto_timeout: value of TIMEOUT bitfield in PRM_VP*_VLIMITTO
  114. * @vstepmin_stepmin: value of VSTEPMIN bitfield in PRM_VP*_VSTEPMIN
  115. * @vstepmax_stepmax: value of VSTEPMAX bitfield in PRM_VP*_VSTEPMAX
  116. * @vlimitto_vddmin: value of VDDMIN bitfield in PRM_VP*_VLIMITTO
  117. * @vlimitto_vddmax: value of VDDMAX bitfield in PRM_VP*_VLIMITTO
  118. *
  119. * XXX Is this structure really needed? Why not just program the
  120. * device directly? They are in PRM space, therefore in the WKUP
  121. * powerdomain, so register contents should not be lost in off-mode.
  122. * XXX Some of these fields are incorrectly named, e.g., vstep*
  123. */
  124. struct omap_vp_runtime_data {
  125. u32 vpconfig_erroroffset;
  126. u16 vpconfig_errorgain;
  127. u16 vstepmin_smpswaittimemin;
  128. u16 vstepmax_smpswaittimemax;
  129. u16 vlimitto_timeout;
  130. u8 vstepmin_stepmin;
  131. u8 vstepmax_stepmax;
  132. u8 vlimitto_vddmin;
  133. u8 vlimitto_vddmax;
  134. };
  135. extern struct omap_vp_instance_data omap3_vp1_data;
  136. extern struct omap_vp_instance_data omap3_vp2_data;
  137. extern struct omap_vp_instance_data omap4_vp_mpu_data;
  138. extern struct omap_vp_instance_data omap4_vp_iva_data;
  139. extern struct omap_vp_instance_data omap4_vp_core_data;
  140. void omap_vp_init(struct voltagedomain *voltdm);
  141. void omap_vp_enable(struct voltagedomain *voltdm);
  142. void omap_vp_disable(struct voltagedomain *voltdm);
  143. unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm);
  144. int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
  145. unsigned long target_volt);
  146. #endif