10 #include <linux/kernel.h>
66 #define CFG_CHANNEL_MASK 0x1f
84 static int omap_vc_config_channel(
struct voltagedomain *voltdm)
104 unsigned long target_volt,
105 u8 *target_vsel,
u8 *current_vsel)
112 pr_err(
"%s: Insufficient pmic info to scale the vdd_%s\n",
113 __func__, voltdm->
name);
117 if (!voltdm->
pmic->uv_to_vsel) {
118 pr_err(
"%s: PMIC function to convert voltage in uV to vsel not registered. Hence unable to scale voltage for vdd_%s\n",
119 __func__, voltdm->
name);
124 pr_err(
"%s: No read/write API for accessing vdd_%s regs\n",
125 __func__, voltdm->
name);
129 *target_vsel = voltdm->
pmic->uv_to_vsel(target_volt);
134 vc_cmdval &= ~vc->
common->cmd_on_mask;
135 vc_cmdval |= (*target_vsel << vc->
common->cmd_on_shift);
144 unsigned long target_volt,
145 u8 target_vsel,
u8 current_vsel)
147 u32 smps_steps = 0, smps_delay = 0;
149 smps_steps =
abs(target_vsel - current_vsel);
151 smps_delay = ((smps_steps * voltdm->
pmic->step_size) /
152 voltdm->
pmic->slew_rate) + 2;
158 unsigned long target_volt)
161 u32 loop_cnt = 0, retries_cnt = 0;
162 u32 vc_valid, vc_bypass_val_reg, vc_bypass_value;
163 u8 target_vsel, current_vsel;
170 vc_valid = vc->
common->valid;
171 vc_bypass_val_reg = vc->
common->bypass_val_reg;
172 vc_bypass_value = (target_vsel << vc->
common->data_shift) |
176 voltdm->
write(vc_bypass_value, vc_bypass_val_reg);
177 voltdm->
write(vc_bypass_value | vc_valid, vc_bypass_val_reg);
179 vc_bypass_value = voltdm->
read(vc_bypass_val_reg);
185 while (!(vc_bypass_value & vc_valid)) {
188 if (retries_cnt > 10) {
189 pr_warning(
"%s: Retry count exceeded\n", __func__);
198 vc_bypass_value = voltdm->
read(vc_bypass_val_reg);
218 static bool is_initialized;
223 omap3_vfsm_init(voltdm);
225 is_initialized =
true;
232 static bool is_initialized;
242 is_initialized =
true;
266 if (voltdm->
pmic->i2c_high_speed != i2c_high_speed)
267 pr_warn(
"%s: I2C config for vdd_%s does not match other channels (%u).\n",
268 __func__, voltdm->
name, i2c_high_speed);
272 i2c_high_speed = voltdm->
pmic->i2c_high_speed;
274 voltdm->
rmw(vc->
common->i2c_cfg_hsen_mask,
275 vc->
common->i2c_cfg_hsen_mask,
278 mcode = voltdm->
pmic->i2c_mcode;
290 u8 on_vsel, onlp_vsel, ret_vsel, off_vsel;
293 if (!voltdm->
pmic || !voltdm->
pmic->uv_to_vsel) {
294 pr_err(
"%s: No PMIC info for vdd_%s\n", __func__, voltdm->
name);
299 pr_err(
"%s: No read/write API for accessing vdd_%s regs\n",
300 __func__, voltdm->
name);
306 vc_cfg_bits = &vc_mutant_channel_cfg;
308 vc_cfg_bits = &vc_default_channel_cfg;
338 on_vsel = voltdm->
pmic->uv_to_vsel(voltdm->
pmic->on_volt);
339 onlp_vsel = voltdm->
pmic->uv_to_vsel(voltdm->
pmic->onlp_volt);
340 ret_vsel = voltdm->
pmic->uv_to_vsel(voltdm->
pmic->ret_volt);
341 off_vsel = voltdm->
pmic->uv_to_vsel(voltdm->
pmic->off_volt);
342 val = ((on_vsel << vc->
common->cmd_on_shift) |
343 (onlp_vsel << vc->
common->cmd_onlp_shift) |
344 (ret_vsel << vc->
common->cmd_ret_shift) |
345 (off_vsel << vc->
common->cmd_off_shift));
350 omap_vc_config_channel(voltdm);
353 voltdm->
rmw(voltdm->
vfsm->voltsetup_mask,
355 voltdm->
vfsm->voltsetup_reg);
357 omap_vc_i2c_init(voltdm);
360 omap3_vc_init_channel(voltdm);
362 omap4_vc_init_channel(voltdm);