Lines Matching +full:ramp +full:- +full:speed
1 // SPDX-License-Identifier: GPL-2.0-only
19 #include "prm-regbits-34xx.h"
20 #include "prm-regbits-44xx.h"
52 * struct omap_vc_channel_cfg - describe the cfg_channel bitfield
101 * omap_vc_config_channel - configure VC channel to PMIC mappings
106 * - i2c slave address (SA)
107 * - voltage configuration address (RAV)
108 * - command configuration address (RAC) and enable bit (RACEN)
109 * - command values for ON, ONLP, RET and OFF (CMD)
112 * non-default channel. Starting with OMAP4, there are more than 2
114 * Only the non-default channel can be configured.
118 struct omap_vc_channel *vc = voltdm->vc; in omap_vc_config_channel()
124 if (vc->flags & OMAP_VC_CHANNEL_DEFAULT) in omap_vc_config_channel()
125 vc->cfg_channel &= vc_cfg_bits->racen; in omap_vc_config_channel()
127 voltdm->rmw(CFG_CHANNEL_MASK << vc->cfg_channel_sa_shift, in omap_vc_config_channel()
128 vc->cfg_channel << vc->cfg_channel_sa_shift, in omap_vc_config_channel()
129 vc->cfg_channel_reg); in omap_vc_config_channel()
139 struct omap_vc_channel *vc = voltdm->vc; in omap_vc_pre_scale()
143 if (!voltdm->pmic) { in omap_vc_pre_scale()
145 __func__, voltdm->name); in omap_vc_pre_scale()
146 return -EINVAL; in omap_vc_pre_scale()
149 if (!voltdm->pmic->uv_to_vsel) { in omap_vc_pre_scale()
151 __func__, voltdm->name); in omap_vc_pre_scale()
152 return -ENODATA; in omap_vc_pre_scale()
155 if (!voltdm->read || !voltdm->write) { in omap_vc_pre_scale()
157 __func__, voltdm->name); in omap_vc_pre_scale()
158 return -EINVAL; in omap_vc_pre_scale()
161 *target_vsel = voltdm->pmic->uv_to_vsel(target_volt); in omap_vc_pre_scale()
162 *current_vsel = voltdm->pmic->uv_to_vsel(voltdm->nominal_volt); in omap_vc_pre_scale()
165 vc_cmdval = voltdm->read(vc->cmdval_reg); in omap_vc_pre_scale()
166 vc_cmdval &= ~vc->common->cmd_on_mask; in omap_vc_pre_scale()
167 vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift); in omap_vc_pre_scale()
168 voltdm->write(vc_cmdval, vc->cmdval_reg); in omap_vc_pre_scale()
170 voltdm->vc_param->on = target_volt; in omap_vc_pre_scale()
183 smps_steps = abs(target_vsel - current_vsel); in omap_vc_post_scale()
185 smps_delay = ((smps_steps * voltdm->pmic->step_size) / in omap_vc_post_scale()
186 voltdm->pmic->slew_rate) + 2; in omap_vc_post_scale()
190 /* vc_bypass_scale - VC bypass method of voltage scaling */
194 struct omap_vc_channel *vc = voltdm->vc; in omap_vc_bypass_scale()
204 vc_valid = vc->common->valid; in omap_vc_bypass_scale()
205 vc_bypass_val_reg = vc->common->bypass_val_reg; in omap_vc_bypass_scale()
206 vc_bypass_value = (target_vsel << vc->common->data_shift) | in omap_vc_bypass_scale()
207 (vc->volt_reg_addr << vc->common->regaddr_shift) | in omap_vc_bypass_scale()
208 (vc->i2c_slave_addr << vc->common->slaveaddr_shift); in omap_vc_bypass_scale()
210 voltdm->write(vc_bypass_value, vc_bypass_val_reg); in omap_vc_bypass_scale()
211 voltdm->write(vc_bypass_value | vc_valid, vc_bypass_val_reg); in omap_vc_bypass_scale()
213 vc_bypass_value = voltdm->read(vc_bypass_val_reg); in omap_vc_bypass_scale()
224 return -ETIMEDOUT; in omap_vc_bypass_scale()
232 vc_bypass_value = voltdm->read(vc_bypass_val_reg); in omap_vc_bypass_scale()
275 voltsetup2 = c->voltsetup2; in omap3_vc_set_pmic_signaling()
277 voltsetup1 = c->voltsetup1; in omap3_vc_set_pmic_signaling()
285 voltsetup1 = c->voltsetup1; in omap3_vc_set_pmic_signaling()
290 vd->write(voltctrl, OMAP3_PRM_VOLTCTRL_OFFSET); in omap3_vc_set_pmic_signaling()
294 vd->write(c->voltsetup1, in omap3_vc_set_pmic_signaling()
299 vd->write(c->voltsetup2, in omap3_vc_set_pmic_signaling()
322 vd->write(val, OMAP4_PRM_VOLTCTRL_OFFSET); in omap4_vc_set_pmic_signaling()
339 val = voltdm->read(OMAP3_PRM_POLCTRL_OFFSET); in omap3_vc_init_pmic_signaling()
346 voltdm->write(val, OMAP3_PRM_POLCTRL_OFFSET); in omap3_vc_init_pmic_signaling()
354 * idle. And we can also scale voltages to zero for off-idle. in omap3_vc_init_pmic_signaling()
355 * Note that no actual voltage scaling during off-idle will in omap3_vc_init_pmic_signaling()
360 val = voltdm->read(OMAP3_PRM_VOLTCTRL_OFFSET); in omap3_vc_init_pmic_signaling()
365 voltdm->write(val, OMAP3_PRM_VOLTCTRL_OFFSET); in omap3_vc_init_pmic_signaling()
377 val = (voltdm->vc_param->on - idle) / voltdm->pmic->slew_rate; in omap3_init_voltsetup1()
378 val *= voltdm->sys_clk.rate / 8 / 1000000 + 1; in omap3_init_voltsetup1()
379 val <<= __ffs(voltdm->vfsm->voltsetup_mask); in omap3_init_voltsetup1()
380 c->voltsetup1 &= ~voltdm->vfsm->voltsetup_mask; in omap3_init_voltsetup1()
381 c->voltsetup1 |= val; in omap3_init_voltsetup1()
385 * omap3_set_i2c_timings - sets i2c sleep timings for a channel
393 * off-mode.
405 omap3_init_voltsetup1(voltdm, c, voltdm->vc_param->off); in omap3_set_i2c_timings()
408 omap3_init_voltsetup1(voltdm, c, voltdm->vc_param->ret); in omap3_set_i2c_timings()
412 * omap3_set_off_timings - sets off-mode timings for a channel
415 * Calculates and sets up off-mode timings for a channel. Off-mode
431 if (c->voltsetup2) in omap3_set_off_timings()
436 pr_debug("PM: oscillator start-up time not initialized, using 10ms\n"); in omap3_set_off_timings()
447 * start-up time since voltoffset2 = clksetup - voltoffset. in omap3_set_off_timings()
450 c->voltsetup2 = clksetup - voltoffset; in omap3_set_off_timings()
451 voltdm->write(clksetup, OMAP3_PRM_CLKSETUP_OFFSET); in omap3_set_off_timings()
452 voltdm->write(voltoffset, OMAP3_PRM_VOLTOFFSET_OFFSET); in omap3_set_off_timings()
463 * omap4_calc_volt_ramp - calculates voltage ramping delays on omap4
467 * Calculates voltage ramp prescaler + counter values for a voltage
478 time = voltage_diff / voltdm->pmic->slew_rate; in omap4_calc_volt_ramp()
480 cycles = voltdm->sys_clk.rate / 1000 * time / 1000; in omap4_calc_volt_ramp()
505 /* check for overflow => invalid ramp time */ in omap4_calc_volt_ramp()
508 voltdm->name); in omap4_calc_volt_ramp()
519 * omap4_usec_to_val_scrm - convert microsecond value to SCRM module bitfield
543 * omap4_set_timings - set voltage ramp timings for a channel
545 * @off_mode: whether off-mode values are used
547 * Calculates and sets the voltage ramp up / down values for a channel.
552 u32 ramp; in omap4_set_timings() local
557 ramp = omap4_calc_volt_ramp(voltdm, in omap4_set_timings()
558 voltdm->vc_param->on - voltdm->vc_param->off); in omap4_set_timings()
559 offset = voltdm->vfsm->voltsetup_off_reg; in omap4_set_timings()
561 ramp = omap4_calc_volt_ramp(voltdm, in omap4_set_timings()
562 voltdm->vc_param->on - voltdm->vc_param->ret); in omap4_set_timings()
563 offset = voltdm->vfsm->voltsetup_reg; in omap4_set_timings()
566 if (!ramp) in omap4_set_timings()
569 val = voltdm->read(offset); in omap4_set_timings()
571 val |= ramp << OMAP4430_RAMP_DOWN_COUNT_SHIFT; in omap4_set_timings()
573 val |= ramp << OMAP4430_RAMP_UP_COUNT_SHIFT; in omap4_set_timings()
575 voltdm->write(val, offset); in omap4_set_timings()
593 voltdm->write(OMAP4_VDD_DEFAULT_VAL, OMAP4_PRM_VOLTCTRL_OFFSET); in omap4_vc_init_pmic_signaling()
654 * omap4_vc_i2c_timing_init - sets up board I2C timing parameters
659 * Pre-calculated values are provided in data tables, as it is not
669 if (!voltdm->pmic->i2c_high_speed) { in omap4_vc_i2c_timing_init()
670 pr_info("%s: using bootloader low-speed timings\n", __func__); in omap4_vc_i2c_timing_init()
681 capacitance += voltdm->pmic->i2c_pad_load; in omap4_vc_i2c_timing_init()
686 while (i2c_data->load > capacitance) in omap4_vc_i2c_timing_init()
690 switch (voltdm->sys_clk.rate) { in omap4_vc_i2c_timing_init()
692 hsscll = i2c_data->hsscll_38_4; in omap4_vc_i2c_timing_init()
695 hsscll = i2c_data->hsscll_26; in omap4_vc_i2c_timing_init()
698 hsscll = i2c_data->hsscll_19_2; in omap4_vc_i2c_timing_init()
701 hsscll = i2c_data->hsscll_16_8; in omap4_vc_i2c_timing_init()
704 hsscll = i2c_data->hsscll_12; in omap4_vc_i2c_timing_init()
708 voltdm->sys_clk.rate); in omap4_vc_i2c_timing_init()
713 val = i2c_data->loadbits << 25 | i2c_data->loadbits << 29; in omap4_vc_i2c_timing_init()
724 voltdm->write(val, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET); in omap4_vc_i2c_timing_init()
730 * omap_vc_i2c_init - initialize I2C interface to PMIC
733 * Use PMIC supplied settings for I2C high-speed mode and
744 struct omap_vc_channel *vc = voltdm->vc; in omap_vc_i2c_init()
750 if (voltdm->pmic->i2c_high_speed != i2c_high_speed) in omap_vc_i2c_init()
752 __func__, voltdm->name, i2c_high_speed); in omap_vc_i2c_init()
763 i2c_high_speed = voltdm->pmic->i2c_high_speed; in omap_vc_i2c_init()
765 voltdm->rmw(vc->common->i2c_cfg_clear_mask, in omap_vc_i2c_init()
766 vc->common->i2c_cfg_hsen_mask, in omap_vc_i2c_init()
767 vc->common->i2c_cfg_reg); in omap_vc_i2c_init()
769 mcode = voltdm->pmic->i2c_mcode; in omap_vc_i2c_init()
771 voltdm->rmw(vc->common->i2c_mcode_mask, in omap_vc_i2c_init()
772 mcode << __ffs(vc->common->i2c_mcode_mask), in omap_vc_i2c_init()
773 vc->common->i2c_cfg_reg); in omap_vc_i2c_init()
782 * omap_vc_calc_vsel - calculate vsel value for a channel
793 if (voltdm->pmic->vddmin > uvolt) in omap_vc_calc_vsel()
794 uvolt = voltdm->pmic->vddmin; in omap_vc_calc_vsel()
795 if (voltdm->pmic->vddmax < uvolt) { in omap_vc_calc_vsel()
797 __func__, uvolt, voltdm->pmic->vddmax); in omap_vc_calc_vsel()
799 uvolt = voltdm->pmic->vddmax; in omap_vc_calc_vsel()
802 return voltdm->pmic->uv_to_vsel(uvolt); in omap_vc_calc_vsel()
807 struct omap_vc_channel *vc = voltdm->vc; in omap_vc_init_channel()
811 if (!voltdm->pmic || !voltdm->pmic->uv_to_vsel) { in omap_vc_init_channel()
812 pr_err("%s: No PMIC info for vdd_%s\n", __func__, voltdm->name); in omap_vc_init_channel()
816 if (!voltdm->read || !voltdm->write) { in omap_vc_init_channel()
818 __func__, voltdm->name); in omap_vc_init_channel()
822 vc->cfg_channel = 0; in omap_vc_init_channel()
823 if (vc->flags & OMAP_VC_CHANNEL_CFG_MUTANT) in omap_vc_init_channel()
829 vc->i2c_slave_addr = voltdm->pmic->i2c_slave_addr; in omap_vc_init_channel()
830 vc->volt_reg_addr = voltdm->pmic->volt_reg_addr; in omap_vc_init_channel()
831 vc->cmd_reg_addr = voltdm->pmic->cmd_reg_addr; in omap_vc_init_channel()
834 voltdm->rmw(vc->smps_sa_mask, in omap_vc_init_channel()
835 vc->i2c_slave_addr << __ffs(vc->smps_sa_mask), in omap_vc_init_channel()
836 vc->smps_sa_reg); in omap_vc_init_channel()
837 vc->cfg_channel |= vc_cfg_bits->sa; in omap_vc_init_channel()
842 voltdm->rmw(vc->smps_volra_mask, in omap_vc_init_channel()
843 vc->volt_reg_addr << __ffs(vc->smps_volra_mask), in omap_vc_init_channel()
844 vc->smps_volra_reg); in omap_vc_init_channel()
845 vc->cfg_channel |= vc_cfg_bits->rav; in omap_vc_init_channel()
847 if (vc->cmd_reg_addr) { in omap_vc_init_channel()
848 voltdm->rmw(vc->smps_cmdra_mask, in omap_vc_init_channel()
849 vc->cmd_reg_addr << __ffs(vc->smps_cmdra_mask), in omap_vc_init_channel()
850 vc->smps_cmdra_reg); in omap_vc_init_channel()
851 vc->cfg_channel |= vc_cfg_bits->rac; in omap_vc_init_channel()
854 if (vc->cmd_reg_addr == vc->volt_reg_addr) in omap_vc_init_channel()
855 vc->cfg_channel |= vc_cfg_bits->racen; in omap_vc_init_channel()
858 on_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->on); in omap_vc_init_channel()
859 onlp_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->onlp); in omap_vc_init_channel()
860 ret_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->ret); in omap_vc_init_channel()
861 off_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->off); in omap_vc_init_channel()
863 val = ((on_vsel << vc->common->cmd_on_shift) | in omap_vc_init_channel()
864 (onlp_vsel << vc->common->cmd_onlp_shift) | in omap_vc_init_channel()
865 (ret_vsel << vc->common->cmd_ret_shift) | in omap_vc_init_channel()
866 (off_vsel << vc->common->cmd_off_shift)); in omap_vc_init_channel()
867 voltdm->write(val, vc->cmdval_reg); in omap_vc_init_channel()
868 vc->cfg_channel |= vc_cfg_bits->cmd; in omap_vc_init_channel()