voltage.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * OMAP Voltage Management Routines
  3. *
  4. * Author: Thara Gopinath <thara@ti.com>
  5. *
  6. * Copyright (C) 2009 Texas Instruments, Inc.
  7. * Thara Gopinath <thara@ti.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
  14. #define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
  15. #include <linux/err.h>
  16. #include <linux/platform_data/voltage-omap.h>
  17. #include "vc.h"
  18. #include "vp.h"
  19. struct powerdomain;
  20. /* XXX document */
  21. #define VOLTSCALE_VPFORCEUPDATE 1
  22. #define VOLTSCALE_VCBYPASS 2
  23. /*
  24. * OMAP3 GENERIC setup times. Revisit to see if these needs to be
  25. * passed from board or PMIC file
  26. */
  27. #define OMAP3_CLKSETUP 0xff
  28. #define OMAP3_VOLTOFFSET 0xff
  29. #define OMAP3_VOLTSETUP2 0xff
  30. /**
  31. * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
  32. * data
  33. * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
  34. * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
  35. * @voltsetup_off_reg: register offset of PRM_VOLTSETUP_OFF from PRM base
  36. *
  37. * XXX What about VOLTOFFSET/VOLTCTRL?
  38. */
  39. struct omap_vfsm_instance {
  40. u32 voltsetup_mask;
  41. u8 voltsetup_reg;
  42. u8 voltsetup_off_reg;
  43. };
  44. /**
  45. * struct voltagedomain - omap voltage domain global structure.
  46. * @name: Name of the voltage domain which can be used as a unique identifier.
  47. * @scalable: Whether or not this voltage domain is scalable
  48. * @node: list_head linking all voltage domains
  49. * @pwrdm_list: list_head linking all powerdomains in this voltagedomain
  50. * @vc: pointer to VC channel associated with this voltagedomain
  51. * @vp: pointer to VP associated with this voltagedomain
  52. * @read: read a VC/VP register
  53. * @write: write a VC/VP register
  54. * @read: read-modify-write a VC/VP register
  55. * @sys_clk: system clock name/frequency, used for various timing calculations
  56. * @scale: function used to scale the voltage of the voltagedomain
  57. * @nominal_volt: current nominal voltage for this voltage domain
  58. * @volt_data: voltage table having the distinct voltages supported
  59. * by the domain and other associated per voltage data.
  60. */
  61. struct voltagedomain {
  62. char *name;
  63. bool scalable;
  64. struct list_head node;
  65. struct list_head pwrdm_list;
  66. struct omap_vc_channel *vc;
  67. const struct omap_vfsm_instance *vfsm;
  68. struct omap_vp_instance *vp;
  69. struct omap_voltdm_pmic *pmic;
  70. struct omap_vp_param *vp_param;
  71. struct omap_vc_param *vc_param;
  72. /* VC/VP register access functions: SoC specific */
  73. u32 (*read) (u8 offset);
  74. void (*write) (u32 val, u8 offset);
  75. u32 (*rmw)(u32 mask, u32 bits, u8 offset);
  76. union {
  77. const char *name;
  78. u32 rate;
  79. } sys_clk;
  80. int (*scale) (struct voltagedomain *voltdm,
  81. unsigned long target_volt);
  82. u32 nominal_volt;
  83. struct omap_volt_data *volt_data;
  84. };
  85. /* Min and max voltages from OMAP perspective */
  86. #define OMAP3430_VP1_VLIMITTO_VDDMIN 850000
  87. #define OMAP3430_VP1_VLIMITTO_VDDMAX 1425000
  88. #define OMAP3430_VP2_VLIMITTO_VDDMIN 900000
  89. #define OMAP3430_VP2_VLIMITTO_VDDMAX 1150000
  90. #define OMAP3630_VP1_VLIMITTO_VDDMIN 900000
  91. #define OMAP3630_VP1_VLIMITTO_VDDMAX 1350000
  92. #define OMAP3630_VP2_VLIMITTO_VDDMIN 900000
  93. #define OMAP3630_VP2_VLIMITTO_VDDMAX 1200000
  94. #define OMAP4_VP_MPU_VLIMITTO_VDDMIN 830000
  95. #define OMAP4_VP_MPU_VLIMITTO_VDDMAX 1410000
  96. #define OMAP4_VP_IVA_VLIMITTO_VDDMIN 830000
  97. #define OMAP4_VP_IVA_VLIMITTO_VDDMAX 1260000
  98. #define OMAP4_VP_CORE_VLIMITTO_VDDMIN 830000
  99. #define OMAP4_VP_CORE_VLIMITTO_VDDMAX 1200000
  100. /**
  101. * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
  102. * @slew_rate: PMIC slew rate (in uv/us)
  103. * @step_size: PMIC voltage step size (in uv)
  104. * @i2c_slave_addr: I2C slave address of PMIC
  105. * @volt_reg_addr: voltage configuration register address
  106. * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
  107. * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
  108. * @i2c_mcode: master code value for I2C high-speed preamble transmission
  109. * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
  110. * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
  111. */
  112. struct omap_voltdm_pmic {
  113. int slew_rate;
  114. int step_size;
  115. u16 i2c_slave_addr;
  116. u16 volt_reg_addr;
  117. u16 cmd_reg_addr;
  118. u8 vp_erroroffset;
  119. u8 vp_vstepmin;
  120. u8 vp_vstepmax;
  121. u32 vddmin;
  122. u32 vddmax;
  123. u8 vp_timeout_us;
  124. bool i2c_high_speed;
  125. u32 i2c_pad_load;
  126. u8 i2c_mcode;
  127. unsigned long (*vsel_to_uv) (const u8 vsel);
  128. u8 (*uv_to_vsel) (unsigned long uV);
  129. };
  130. struct omap_vp_param {
  131. u32 vddmax;
  132. u32 vddmin;
  133. };
  134. struct omap_vc_param {
  135. u32 on;
  136. u32 onlp;
  137. u32 ret;
  138. u32 off;
  139. };
  140. void omap_voltage_get_volttable(struct voltagedomain *voltdm,
  141. struct omap_volt_data **volt_data);
  142. struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
  143. unsigned long volt);
  144. int omap_voltage_register_pmic(struct voltagedomain *voltdm,
  145. struct omap_voltdm_pmic *pmic);
  146. void omap_change_voltscale_method(struct voltagedomain *voltdm,
  147. int voltscale_method);
  148. int omap_voltage_late_init(void);
  149. extern void omap2xxx_voltagedomains_init(void);
  150. extern void omap3xxx_voltagedomains_init(void);
  151. extern void omap44xx_voltagedomains_init(void);
  152. extern void omap54xx_voltagedomains_init(void);
  153. struct voltagedomain *voltdm_lookup(const char *name);
  154. void voltdm_init(struct voltagedomain **voltdm_list);
  155. int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
  156. int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
  157. void *user);
  158. int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
  159. int (*fn)(struct voltagedomain *voltdm,
  160. struct powerdomain *pwrdm));
  161. int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
  162. void voltdm_reset(struct voltagedomain *voltdm);
  163. unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
  164. #endif