18 #include <linux/kernel.h>
25 #define OMAP3_SRI2C_SLAVE_ADDR 0x12
26 #define OMAP3_VDD_MPU_SR_CONTROL_REG 0x00
27 #define OMAP3_VDD_CORE_SR_CONTROL_REG 0x01
28 #define OMAP3_VP_CONFIG_ERROROFFSET 0x00
29 #define OMAP3_VP_VSTEPMIN_VSTEPMIN 0x1
30 #define OMAP3_VP_VSTEPMAX_VSTEPMAX 0x04
31 #define OMAP3_VP_VLIMITTO_TIMEOUT_US 200
33 #define OMAP3430_VP1_VLIMITTO_VDDMIN 0x14
34 #define OMAP3430_VP1_VLIMITTO_VDDMAX 0x42
35 #define OMAP3430_VP2_VLIMITTO_VDDMIN 0x18
36 #define OMAP3430_VP2_VLIMITTO_VDDMAX 0x2c
38 #define OMAP3630_VP1_VLIMITTO_VDDMIN 0x18
39 #define OMAP3630_VP1_VLIMITTO_VDDMAX 0x3c
40 #define OMAP3630_VP2_VLIMITTO_VDDMIN 0x18
41 #define OMAP3630_VP2_VLIMITTO_VDDMAX 0x30
43 #define OMAP4_SRI2C_SLAVE_ADDR 0x12
44 #define OMAP4_VDD_MPU_SR_VOLT_REG 0x55
45 #define OMAP4_VDD_MPU_SR_CMD_REG 0x56
46 #define OMAP4_VDD_IVA_SR_VOLT_REG 0x5B
47 #define OMAP4_VDD_IVA_SR_CMD_REG 0x5C
48 #define OMAP4_VDD_CORE_SR_VOLT_REG 0x61
49 #define OMAP4_VDD_CORE_SR_CMD_REG 0x62
51 #define OMAP4_VP_CONFIG_ERROROFFSET 0x00
52 #define OMAP4_VP_VSTEPMIN_VSTEPMIN 0x01
53 #define OMAP4_VP_VSTEPMAX_VSTEPMAX 0x04
54 #define OMAP4_VP_VLIMITTO_TIMEOUT_US 200
56 #define OMAP4_VP_MPU_VLIMITTO_VDDMIN 0xA
57 #define OMAP4_VP_MPU_VLIMITTO_VDDMAX 0x39
58 #define OMAP4_VP_IVA_VLIMITTO_VDDMIN 0xA
59 #define OMAP4_VP_IVA_VLIMITTO_VDDMAX 0x2D
60 #define OMAP4_VP_CORE_VLIMITTO_VDDMIN 0xA
61 #define OMAP4_VP_CORE_VLIMITTO_VDDMAX 0x28
63 static bool is_offset_valid;
64 static u8 smps_offset;
71 #define TWL4030_DCDC_GLOBAL_CFG 0x06
72 #define REG_SMPS_OFFSET 0xE0
73 #define SMARTREFLEX_ENABLE BIT(3)
75 static unsigned long twl4030_vsel_to_uv(
const u8 vsel)
77 return (((vsel * 125) + 6000)) * 100;
80 static u8 twl4030_uv_to_vsel(
unsigned long uv)
85 static unsigned long twl6030_vsel_to_uv(
const u8 vsel)
95 if (!is_offset_valid) {
98 is_offset_valid =
true;
113 if (smps_offset & 0x8)
114 return ((((vsel - 1) * 1266) + 70900)) * 10;
116 return ((((vsel - 1) * 1266) + 60770)) * 10;
119 static u8 twl6030_uv_to_vsel(
unsigned long uv)
129 if (!is_offset_valid) {
132 is_offset_valid =
true;
144 if (uv > twl6030_vsel_to_uv(0x39)) {
147 pr_err(
"%s:OUT OF RANGE! non mapped vsel for %ld Vs max %ld\n",
148 __func__, uv, twl6030_vsel_to_uv(0x39));
152 if (smps_offset & 0x8)
162 .onlp_volt = 1000000,
165 .volt_setup_time = 0xfff,
174 .i2c_high_speed =
true,
175 .vsel_to_uv = twl4030_vsel_to_uv,
176 .uv_to_vsel = twl4030_uv_to_vsel,
183 .onlp_volt = 1000000,
186 .volt_setup_time = 0xfff,
195 .i2c_high_speed =
true,
196 .vsel_to_uv = twl4030_vsel_to_uv,
197 .uv_to_vsel = twl4030_uv_to_vsel,
204 .onlp_volt = 1375000,
207 .volt_setup_time = 0,
217 .i2c_high_speed =
true,
218 .vsel_to_uv = twl6030_vsel_to_uv,
219 .uv_to_vsel = twl6030_uv_to_vsel,
226 .onlp_volt = 1188000,
229 .volt_setup_time = 0,
239 .i2c_high_speed =
true,
240 .vsel_to_uv = twl6030_vsel_to_uv,
241 .uv_to_vsel = twl6030_uv_to_vsel,
248 .onlp_volt = 1200000,
251 .volt_setup_time = 0,
261 .vsel_to_uv = twl6030_vsel_to_uv,
262 .uv_to_vsel = twl6030_uv_to_vsel,
307 if (!twl_sr_enable_autoinit)
336 if (twl_sr_enable_autoinit)
337 pr_warning(
"%s: unexpected multiple calls\n", __func__);
352 twl_sr_enable_autoinit =
true;
356 pr_err(
"%s: Error access to TWL4030 (%d)\n", __func__, ret);