Lines Matching +full:pmic +full:- +full:specific

22 #include "prm-regbits-34xx.h"
23 #include "prm-regbits-44xx.h"
55 * struct omap_vc_channel_cfg - describe the cfg_channel bitfield
104 * omap_vc_config_channel - configure VC channel to PMIC mappings
107 * Configures the VC channel to PMIC mappings for the following
108 * PMIC settings
109 * - i2c slave address (SA)
110 * - voltage configuration address (RAV)
111 * - command configuration address (RAC) and enable bit (RACEN)
112 * - command values for ON, ONLP, RET and OFF (CMD)
115 * non-default channel. Starting with OMAP4, there are more than 2
117 * Only the non-default channel can be configured.
121 struct omap_vc_channel *vc = voltdm->vc; in omap_vc_config_channel()
127 if (vc->flags & OMAP_VC_CHANNEL_DEFAULT) in omap_vc_config_channel()
128 vc->cfg_channel &= vc_cfg_bits->racen; in omap_vc_config_channel()
130 voltdm->rmw(CFG_CHANNEL_MASK << vc->cfg_channel_sa_shift, in omap_vc_config_channel()
131 vc->cfg_channel << vc->cfg_channel_sa_shift, in omap_vc_config_channel()
132 vc->cfg_channel_reg); in omap_vc_config_channel()
142 struct omap_vc_channel *vc = voltdm->vc; in omap_vc_pre_scale()
145 /* Check if sufficient pmic info is available for this vdd */ in omap_vc_pre_scale()
146 if (!voltdm->pmic) { in omap_vc_pre_scale()
147 pr_err("%s: Insufficient pmic info to scale the vdd_%s\n", in omap_vc_pre_scale()
148 __func__, voltdm->name); in omap_vc_pre_scale()
149 return -EINVAL; in omap_vc_pre_scale()
152 if (!voltdm->pmic->uv_to_vsel) { in omap_vc_pre_scale()
153 …pr_err("%s: PMIC function to convert voltage in uV to vsel not registered. Hence unable to scale v… in omap_vc_pre_scale()
154 __func__, voltdm->name); in omap_vc_pre_scale()
155 return -ENODATA; in omap_vc_pre_scale()
158 if (!voltdm->read || !voltdm->write) { in omap_vc_pre_scale()
160 __func__, voltdm->name); in omap_vc_pre_scale()
161 return -EINVAL; in omap_vc_pre_scale()
164 *target_vsel = voltdm->pmic->uv_to_vsel(target_volt); in omap_vc_pre_scale()
165 *current_vsel = voltdm->pmic->uv_to_vsel(voltdm->nominal_volt); in omap_vc_pre_scale()
168 vc_cmdval = voltdm->read(vc->cmdval_reg); in omap_vc_pre_scale()
169 vc_cmdval &= ~vc->common->cmd_on_mask; in omap_vc_pre_scale()
170 vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift); in omap_vc_pre_scale()
171 voltdm->write(vc_cmdval, vc->cmdval_reg); in omap_vc_pre_scale()
173 voltdm->vc_param->on = target_volt; in omap_vc_pre_scale()
186 smps_steps = abs(target_vsel - current_vsel); in omap_vc_post_scale()
188 smps_delay = ((smps_steps * voltdm->pmic->step_size) / in omap_vc_post_scale()
189 voltdm->pmic->slew_rate) + 2; in omap_vc_post_scale()
193 /* vc_bypass_scale - VC bypass method of voltage scaling */
197 struct omap_vc_channel *vc = voltdm->vc; in omap_vc_bypass_scale()
207 vc_valid = vc->common->valid; in omap_vc_bypass_scale()
208 vc_bypass_val_reg = vc->common->bypass_val_reg; in omap_vc_bypass_scale()
209 vc_bypass_value = (target_vsel << vc->common->data_shift) | in omap_vc_bypass_scale()
210 (vc->volt_reg_addr << vc->common->regaddr_shift) | in omap_vc_bypass_scale()
211 (vc->i2c_slave_addr << vc->common->slaveaddr_shift); in omap_vc_bypass_scale()
213 voltdm->write(vc_bypass_value, vc_bypass_val_reg); in omap_vc_bypass_scale()
214 voltdm->write(vc_bypass_value | vc_valid, vc_bypass_val_reg); in omap_vc_bypass_scale()
216 vc_bypass_value = voltdm->read(vc_bypass_val_reg); in omap_vc_bypass_scale()
227 return -ETIMEDOUT; in omap_vc_bypass_scale()
235 vc_bypass_value = voltdm->read(vc_bypass_val_reg); in omap_vc_bypass_scale()
278 voltsetup2 = c->voltsetup2; in omap3_vc_set_pmic_signaling()
280 voltsetup1 = c->voltsetup1; in omap3_vc_set_pmic_signaling()
288 voltsetup1 = c->voltsetup1; in omap3_vc_set_pmic_signaling()
293 vd->write(voltctrl, OMAP3_PRM_VOLTCTRL_OFFSET); in omap3_vc_set_pmic_signaling()
297 vd->write(c->voltsetup1, in omap3_vc_set_pmic_signaling()
302 vd->write(c->voltsetup2, in omap3_vc_set_pmic_signaling()
325 vd->write(val, OMAP4_PRM_VOLTCTRL_OFFSET); in omap4_vc_set_pmic_signaling()
342 val = voltdm->read(OMAP3_PRM_POLCTRL_OFFSET); in omap3_vc_init_pmic_signaling()
349 voltdm->write(val, OMAP3_PRM_POLCTRL_OFFSET); in omap3_vc_init_pmic_signaling()
357 * idle. And we can also scale voltages to zero for off-idle. in omap3_vc_init_pmic_signaling()
358 * Note that no actual voltage scaling during off-idle will in omap3_vc_init_pmic_signaling()
359 * happen unless the board specific twl4030 PMIC scripts are in omap3_vc_init_pmic_signaling()
363 val = voltdm->read(OMAP3_PRM_VOLTCTRL_OFFSET); in omap3_vc_init_pmic_signaling()
368 voltdm->write(val, OMAP3_PRM_VOLTCTRL_OFFSET); in omap3_vc_init_pmic_signaling()
380 val = (voltdm->vc_param->on - idle) / voltdm->pmic->slew_rate; in omap3_init_voltsetup1()
381 val *= voltdm->sys_clk.rate / 8 / 1000000 + 1; in omap3_init_voltsetup1()
382 val <<= __ffs(voltdm->vfsm->voltsetup_mask); in omap3_init_voltsetup1()
383 c->voltsetup1 &= ~voltdm->vfsm->voltsetup_mask; in omap3_init_voltsetup1()
384 c->voltsetup1 |= val; in omap3_init_voltsetup1()
388 * omap3_set_i2c_timings - sets i2c sleep timings for a channel
396 * off-mode.
398 * Note that pmic is not controlling the voltage scaling during
408 omap3_init_voltsetup1(voltdm, c, voltdm->vc_param->off); in omap3_set_i2c_timings()
411 omap3_init_voltsetup1(voltdm, c, voltdm->vc_param->ret); in omap3_set_i2c_timings()
415 * omap3_set_off_timings - sets off-mode timings for a channel
418 * Calculates and sets up off-mode timings for a channel. Off-mode
434 if (c->voltsetup2) in omap3_set_off_timings()
439 pr_debug("PM: oscillator start-up time not initialized, using 10ms\n"); in omap3_set_off_timings()
450 * start-up time since voltoffset2 = clksetup - voltoffset. in omap3_set_off_timings()
453 c->voltsetup2 = clksetup - voltoffset; in omap3_set_off_timings()
454 voltdm->write(clksetup, OMAP3_PRM_CLKSETUP_OFFSET); in omap3_set_off_timings()
455 voltdm->write(voltoffset, OMAP3_PRM_VOLTOFFSET_OFFSET); in omap3_set_off_timings()
466 * omap4_calc_volt_ramp - calculates voltage ramping delays on omap4
481 time = voltage_diff / voltdm->pmic->slew_rate; in omap4_calc_volt_ramp()
483 cycles = voltdm->sys_clk.rate / 1000 * time / 1000; in omap4_calc_volt_ramp()
511 voltdm->name); in omap4_calc_volt_ramp()
522 * omap4_usec_to_val_scrm - convert microsecond value to SCRM module bitfield
546 * omap4_set_timings - set voltage ramp timings for a channel
548 * @off_mode: whether off-mode values are used
561 voltdm->vc_param->on - voltdm->vc_param->off); in omap4_set_timings()
562 offset = voltdm->vfsm->voltsetup_off_reg; in omap4_set_timings()
565 voltdm->vc_param->on - voltdm->vc_param->ret); in omap4_set_timings()
566 offset = voltdm->vfsm->voltsetup_reg; in omap4_set_timings()
572 val = voltdm->read(offset); in omap4_set_timings()
578 voltdm->write(val, offset); in omap4_set_timings()
596 voltdm->write(OMAP4_VDD_DEFAULT_VAL, OMAP4_PRM_VOLTCTRL_OFFSET); in omap4_vc_init_pmic_signaling()
599 /* OMAP4 specific voltage init functions */
657 * omap4_vc_i2c_timing_init - sets up board I2C timing parameters
660 * Use PMIC + board supplied settings for calculating the total I2C
662 * Pre-calculated values are provided in data tables, as it is not
672 if (!voltdm->pmic->i2c_high_speed) { in omap4_vc_i2c_timing_init()
673 pr_info("%s: using bootloader low-speed timings\n", __func__); in omap4_vc_i2c_timing_init()
683 /* PMIC pad capacitance */ in omap4_vc_i2c_timing_init()
684 capacitance += voltdm->pmic->i2c_pad_load; in omap4_vc_i2c_timing_init()
689 while (i2c_data->load > capacitance) in omap4_vc_i2c_timing_init()
693 switch (voltdm->sys_clk.rate) { in omap4_vc_i2c_timing_init()
695 hsscll = i2c_data->hsscll_38_4; in omap4_vc_i2c_timing_init()
698 hsscll = i2c_data->hsscll_26; in omap4_vc_i2c_timing_init()
701 hsscll = i2c_data->hsscll_19_2; in omap4_vc_i2c_timing_init()
704 hsscll = i2c_data->hsscll_16_8; in omap4_vc_i2c_timing_init()
707 hsscll = i2c_data->hsscll_12; in omap4_vc_i2c_timing_init()
711 voltdm->sys_clk.rate); in omap4_vc_i2c_timing_init()
716 val = i2c_data->loadbits << 25 | i2c_data->loadbits << 29; in omap4_vc_i2c_timing_init()
727 voltdm->write(val, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET); in omap4_vc_i2c_timing_init()
733 * omap_vc_i2c_init - initialize I2C interface to PMIC
736 * Use PMIC supplied settings for I2C high-speed mode and
747 struct omap_vc_channel *vc = voltdm->vc; in omap_vc_i2c_init()
753 if (voltdm->pmic->i2c_high_speed != i2c_high_speed) in omap_vc_i2c_init()
755 __func__, voltdm->name, i2c_high_speed); in omap_vc_i2c_init()
766 i2c_high_speed = voltdm->pmic->i2c_high_speed; in omap_vc_i2c_init()
768 voltdm->rmw(vc->common->i2c_cfg_clear_mask, in omap_vc_i2c_init()
769 vc->common->i2c_cfg_hsen_mask, in omap_vc_i2c_init()
770 vc->common->i2c_cfg_reg); in omap_vc_i2c_init()
772 mcode = voltdm->pmic->i2c_mcode; in omap_vc_i2c_init()
774 voltdm->rmw(vc->common->i2c_mcode_mask, in omap_vc_i2c_init()
775 mcode << __ffs(vc->common->i2c_mcode_mask), in omap_vc_i2c_init()
776 vc->common->i2c_cfg_reg); in omap_vc_i2c_init()
785 * omap_vc_calc_vsel - calculate vsel value for a channel
789 * Converts a microvolt value to vsel value for the used PMIC.
796 if (voltdm->pmic->vddmin > uvolt) in omap_vc_calc_vsel()
797 uvolt = voltdm->pmic->vddmin; in omap_vc_calc_vsel()
798 if (voltdm->pmic->vddmax < uvolt) { in omap_vc_calc_vsel()
799 WARN(1, "%s: voltage not supported by pmic: %u vs max %u\n", in omap_vc_calc_vsel()
800 __func__, uvolt, voltdm->pmic->vddmax); in omap_vc_calc_vsel()
802 uvolt = voltdm->pmic->vddmax; in omap_vc_calc_vsel()
805 return voltdm->pmic->uv_to_vsel(uvolt); in omap_vc_calc_vsel()
810 * omap_pm_setup_sr_i2c_pcb_length - set length of SR I2C traces on PCB
825 struct omap_vc_channel *vc = voltdm->vc; in omap_vc_init_channel()
829 if (!voltdm->pmic || !voltdm->pmic->uv_to_vsel) { in omap_vc_init_channel()
830 pr_err("%s: No PMIC info for vdd_%s\n", __func__, voltdm->name); in omap_vc_init_channel()
834 if (!voltdm->read || !voltdm->write) { in omap_vc_init_channel()
836 __func__, voltdm->name); in omap_vc_init_channel()
840 vc->cfg_channel = 0; in omap_vc_init_channel()
841 if (vc->flags & OMAP_VC_CHANNEL_CFG_MUTANT) in omap_vc_init_channel()
846 /* get PMIC/board specific settings */ in omap_vc_init_channel()
847 vc->i2c_slave_addr = voltdm->pmic->i2c_slave_addr; in omap_vc_init_channel()
848 vc->volt_reg_addr = voltdm->pmic->volt_reg_addr; in omap_vc_init_channel()
849 vc->cmd_reg_addr = voltdm->pmic->cmd_reg_addr; in omap_vc_init_channel()
852 voltdm->rmw(vc->smps_sa_mask, in omap_vc_init_channel()
853 vc->i2c_slave_addr << __ffs(vc->smps_sa_mask), in omap_vc_init_channel()
854 vc->smps_sa_reg); in omap_vc_init_channel()
855 vc->cfg_channel |= vc_cfg_bits->sa; in omap_vc_init_channel()
858 * Configure the PMIC register addresses. in omap_vc_init_channel()
860 voltdm->rmw(vc->smps_volra_mask, in omap_vc_init_channel()
861 vc->volt_reg_addr << __ffs(vc->smps_volra_mask), in omap_vc_init_channel()
862 vc->smps_volra_reg); in omap_vc_init_channel()
863 vc->cfg_channel |= vc_cfg_bits->rav; in omap_vc_init_channel()
865 if (vc->cmd_reg_addr) { in omap_vc_init_channel()
866 voltdm->rmw(vc->smps_cmdra_mask, in omap_vc_init_channel()
867 vc->cmd_reg_addr << __ffs(vc->smps_cmdra_mask), in omap_vc_init_channel()
868 vc->smps_cmdra_reg); in omap_vc_init_channel()
869 vc->cfg_channel |= vc_cfg_bits->rac; in omap_vc_init_channel()
872 if (vc->cmd_reg_addr == vc->volt_reg_addr) in omap_vc_init_channel()
873 vc->cfg_channel |= vc_cfg_bits->racen; in omap_vc_init_channel()
876 on_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->on); in omap_vc_init_channel()
877 onlp_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->onlp); in omap_vc_init_channel()
878 ret_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->ret); in omap_vc_init_channel()
879 off_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->off); in omap_vc_init_channel()
881 val = ((on_vsel << vc->common->cmd_on_shift) | in omap_vc_init_channel()
882 (onlp_vsel << vc->common->cmd_onlp_shift) | in omap_vc_init_channel()
883 (ret_vsel << vc->common->cmd_ret_shift) | in omap_vc_init_channel()
884 (off_vsel << vc->common->cmd_off_shift)); in omap_vc_init_channel()
885 voltdm->write(val, vc->cmdval_reg); in omap_vc_init_channel()
886 vc->cfg_channel |= vc_cfg_bits->cmd; in omap_vc_init_channel()