static unsigned int vreg_get_mode(struct regulator_dev *rdev) { struct vreg *vreg = rdev_get_drvdata(rdev); return vreg->mode; }
static int saw_get_voltage(struct regulator_dev *rdev) { struct saw_vreg *vreg = rdev_get_drvdata(rdev); return vreg->uV; }
static int regulator_stub_disable(struct regulator_dev *rdev) { struct regulator_stub *vreg_priv = rdev_get_drvdata(rdev); vreg_priv->enabled = false; return 0; }
static int bq24022_is_enabled(struct regulator_dev *rdev) { struct bq24022_mach_info *pdata = rdev_get_drvdata(rdev); return !gpio_get_value(pdata->gpio_nce); }
static int pm800_get_current_limit(struct regulator_dev *rdev) { struct pm800_regulator_info *info = rdev_get_drvdata(rdev); return info->max_ua; }
/* * Applied internal pulldown resistor on EN input pin. * If pulldown EN pin outside, it would be better. */ static int max8649_disable(struct regulator_dev *rdev) { struct max8649_regulator_info *info = rdev_get_drvdata(rdev); return max8649_set_bits(info->i2c, MAX8649_CONTROL, MAX8649_EN_PD, MAX8649_EN_PD); }
static int vp_reg_get_voltage(struct regulator_dev *rdev) { struct msm_vp *vp = rdev_get_drvdata(rdev); return MV_TO_UV(vp->current_voltage); }
static int qpnp_regulator_common_enable_time(struct regulator_dev *rdev) { struct qpnp_regulator *vreg = rdev_get_drvdata(rdev); return vreg->enable_time; }
static void qpnp_vreg_show_state(struct regulator_dev *rdev, enum qpnp_regulator_action action) { struct qpnp_regulator *vreg = rdev_get_drvdata(rdev); const char *action_label = qpnp_print_actions[action]; unsigned int mode = 0; int uV = 0; const char *mode_label = ""; enum qpnp_regulator_logical_type type; const char *enable_label; char pc_enable_label[5] = {'\0'}; char pc_mode_label[8] = {'\0'}; bool show_req, show_dupe, show_init, has_changed; u8 en_reg, mode_reg; /* Do not print unless appropriate flags are set. */ show_req = qpnp_vreg_debug_mask & QPNP_VREG_DEBUG_REQUEST; show_dupe = qpnp_vreg_debug_mask & QPNP_VREG_DEBUG_DUPLICATE; show_init = qpnp_vreg_debug_mask & QPNP_VREG_DEBUG_INIT; has_changed = vreg->write_count != vreg->prev_write_count; if (!((show_init && action == QPNP_REGULATOR_ACTION_INIT) || (show_req && (has_changed || show_dupe)))) { return; } vreg->prev_write_count = vreg->write_count; type = vreg->logical_type; enable_label = qpnp_regulator_common_is_enabled(rdev) ? "on " : "off"; if (type == QPNP_REGULATOR_LOGICAL_TYPE_SMPS || type == QPNP_REGULATOR_LOGICAL_TYPE_LDO || type == QPNP_REGULATOR_LOGICAL_TYPE_FTSMPS) uV = qpnp_regulator_common_get_voltage(rdev); if (type == QPNP_REGULATOR_LOGICAL_TYPE_BOOST) uV = qpnp_regulator_boost_get_voltage(rdev); if (type == QPNP_REGULATOR_LOGICAL_TYPE_SMPS || type == QPNP_REGULATOR_LOGICAL_TYPE_LDO || type == QPNP_REGULATOR_LOGICAL_TYPE_FTSMPS) { mode = qpnp_regulator_common_get_mode(rdev); mode_label = mode == REGULATOR_MODE_NORMAL ? "HPM" : "LPM"; } if (type == QPNP_REGULATOR_LOGICAL_TYPE_SMPS || type == QPNP_REGULATOR_LOGICAL_TYPE_LDO || type == QPNP_REGULATOR_LOGICAL_TYPE_VS) { en_reg = vreg->ctrl_reg[QPNP_COMMON_IDX_ENABLE]; pc_enable_label[0] = en_reg & QPNP_COMMON_ENABLE_FOLLOW_HW_EN3_MASK ? '3' : '_'; pc_enable_label[1] = en_reg & QPNP_COMMON_ENABLE_FOLLOW_HW_EN2_MASK ? '2' : '_'; pc_enable_label[2] = en_reg & QPNP_COMMON_ENABLE_FOLLOW_HW_EN1_MASK ? '1' : '_'; pc_enable_label[3] = en_reg & QPNP_COMMON_ENABLE_FOLLOW_HW_EN0_MASK ? '0' : '_'; } switch (type) { case QPNP_REGULATOR_LOGICAL_TYPE_SMPS: mode_reg = vreg->ctrl_reg[QPNP_COMMON_IDX_MODE]; pc_mode_label[0] = mode_reg & QPNP_COMMON_MODE_AUTO_MASK ? 'A' : '_'; pc_mode_label[1] = mode_reg & QPNP_COMMON_MODE_FOLLOW_AWAKE_MASK ? 'W' : '_'; pc_mode_label[2] = mode_reg & QPNP_COMMON_MODE_FOLLOW_HW_EN3_MASK ? '3' : '_'; pc_mode_label[3] = mode_reg & QPNP_COMMON_MODE_FOLLOW_HW_EN2_MASK ? '2' : '_'; pc_mode_label[4] = mode_reg & QPNP_COMMON_MODE_FOLLOW_HW_EN1_MASK ? '1' : '_'; pc_mode_label[5] = mode_reg & QPNP_COMMON_MODE_FOLLOW_HW_EN0_MASK ? '0' : '_'; pr_info("%s %-11s: %s, v=%7d uV, mode=%s, pc_en=%s, " "alt_mode=%s\n", action_label, vreg->rdesc.name, enable_label, uV, mode_label, pc_enable_label, pc_mode_label); break; case QPNP_REGULATOR_LOGICAL_TYPE_LDO: mode_reg = vreg->ctrl_reg[QPNP_COMMON_IDX_MODE]; pc_mode_label[0] = mode_reg & QPNP_COMMON_MODE_AUTO_MASK ? 'A' : '_'; pc_mode_label[1] = mode_reg & QPNP_COMMON_MODE_BYPASS_MASK ? 'B' : '_'; pc_mode_label[2] = mode_reg & QPNP_COMMON_MODE_FOLLOW_AWAKE_MASK ? 'W' : '_'; pc_mode_label[3] = mode_reg & QPNP_COMMON_MODE_FOLLOW_HW_EN3_MASK ? '3' : '_'; pc_mode_label[4] = mode_reg & QPNP_COMMON_MODE_FOLLOW_HW_EN2_MASK ? '2' : '_'; pc_mode_label[5] = mode_reg & QPNP_COMMON_MODE_FOLLOW_HW_EN1_MASK ? '1' : '_'; pc_mode_label[6] = mode_reg & QPNP_COMMON_MODE_FOLLOW_HW_EN0_MASK ? '0' : '_'; pr_info("%s %-11s: %s, v=%7d uV, mode=%s, pc_en=%s, " "alt_mode=%s\n", action_label, vreg->rdesc.name, enable_label, uV, mode_label, pc_enable_label, pc_mode_label); break; case QPNP_REGULATOR_LOGICAL_TYPE_VS: mode_reg = vreg->ctrl_reg[QPNP_COMMON_IDX_MODE]; pc_mode_label[0] = mode_reg & QPNP_COMMON_MODE_AUTO_MASK ? 'A' : '_'; pc_mode_label[1] = mode_reg & QPNP_COMMON_MODE_FOLLOW_AWAKE_MASK ? 'W' : '_'; pr_info("%s %-11s: %s, pc_en=%s, alt_mode=%s\n", action_label, vreg->rdesc.name, enable_label, pc_enable_label, pc_mode_label); break; case QPNP_REGULATOR_LOGICAL_TYPE_BOOST: pr_info("%s %-11s: %s, v=%7d uV\n", action_label, vreg->rdesc.name, enable_label, uV); break; case QPNP_REGULATOR_LOGICAL_TYPE_FTSMPS: mode_reg = vreg->ctrl_reg[QPNP_COMMON_IDX_MODE]; pc_mode_label[0] = mode_reg & QPNP_COMMON_MODE_AUTO_MASK ? 'A' : '_'; pr_info("%s %-11s: %s, v=%7d uV, mode=%s, alt_mode=%s\n", action_label, vreg->rdesc.name, enable_label, uV, mode_label, pc_mode_label); break; default: break; } }
static int vreg_get_voltage(struct regulator_dev *rdev) { struct vreg *vreg = rdev_get_drvdata(rdev); return vreg->save_uV; }
static int vreg_set_mode(struct regulator_dev *rdev, unsigned int mode) { struct vreg *vreg = rdev_get_drvdata(rdev); unsigned int mask[2] = {0}, val[2] = {0}; int rc = 0; int peak_uA; mutex_lock(&vreg->pc_lock); peak_uA = MILLI_TO_MICRO((vreg->req[vreg->part->ip.word].value & vreg->part->ip.mask) >> vreg->part->ip.shift); if (mode == config->mode_hpm) { /* Make sure that request currents are in HPM range. */ if (peak_uA < vreg_hpm_min_uA(vreg)) { val[vreg->part->ip.word] = MICRO_TO_MILLI(vreg_hpm_min_uA(vreg)) << vreg->part->ip.shift; mask[vreg->part->ip.word] = vreg->part->ip.mask; if (config->ia_follows_ip) { val[vreg->part->ia.word] |= MICRO_TO_MILLI(vreg_hpm_min_uA(vreg)) << vreg->part->ia.shift; mask[vreg->part->ia.word] |= vreg->part->ia.mask; } } } else if (mode == config->mode_lpm) { /* Make sure that request currents are in LPM range. */ if (peak_uA > vreg_lpm_max_uA(vreg)) { val[vreg->part->ip.word] = MICRO_TO_MILLI(vreg_lpm_max_uA(vreg)) << vreg->part->ip.shift; mask[vreg->part->ip.word] = vreg->part->ip.mask; if (config->ia_follows_ip) { val[vreg->part->ia.word] |= MICRO_TO_MILLI(vreg_lpm_max_uA(vreg)) << vreg->part->ia.shift; mask[vreg->part->ia.word] |= vreg->part->ia.mask; } } } else { vreg_err(vreg, "invalid mode: %u\n", mode); mutex_unlock(&vreg->pc_lock); return -EINVAL; } if (vreg->is_enabled) { rc = vreg_set(vreg, mask[0], val[0], mask[1], val[1], vreg->part->request_len); } else { /* Regulator is disabled; store but don't send new request. */ rc = vreg_store(vreg, mask[0], val[0], mask[1], val[1]); } if (rc) vreg_err(vreg, "vreg_set failed, rc=%d\n", rc); else vreg->mode = mode; mutex_unlock(&vreg->pc_lock); return rc; }
static int vreg_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, unsigned *selector) { struct vreg *vreg = rdev_get_drvdata(rdev); struct vreg_range *range = &vreg->set_points->range[0]; unsigned int mask[2] = {0}, val[2] = {0}; int rc = 0, uV = min_uV; int lim_min_uV, lim_max_uV, i; /* Check if request voltage is outside of physically settable range. */ lim_min_uV = vreg->set_points->range[0].min_uV; lim_max_uV = vreg->set_points->range[vreg->set_points->count - 1].max_uV; if (uV < lim_min_uV && max_uV >= lim_min_uV) uV = lim_min_uV; if (uV < lim_min_uV || uV > lim_max_uV) { vreg_err(vreg, "request v=[%d, %d] is outside possible v=[%d, %d]\n", min_uV, max_uV, lim_min_uV, lim_max_uV); return -EINVAL; } /* Find the range which uV is inside of. */ for (i = vreg->set_points->count - 1; i > 0; i--) { if (uV > vreg->set_points->range[i - 1].max_uV) { range = &vreg->set_points->range[i]; break; } } /* * Force uV to be an allowed set point and apply a ceiling function * to non-set point values. */ uV = (uV - range->min_uV + range->step_uV - 1) / range->step_uV; uV = uV * range->step_uV + range->min_uV; if (uV > max_uV) { vreg_err(vreg, "request v=[%d, %d] cannot be met by any set point; " "next set point: %d\n", min_uV, max_uV, uV); return -EINVAL; } if (vreg->part->uV.mask) { val[vreg->part->uV.word] = uV << vreg->part->uV.shift; mask[vreg->part->uV.word] = vreg->part->uV.mask; } else { val[vreg->part->mV.word] = MICRO_TO_MILLI(uV) << vreg->part->mV.shift; mask[vreg->part->mV.word] = vreg->part->mV.mask; } mutex_lock(&vreg->pc_lock); /* * Only send a request for a new voltage if the regulator is currently * enabled. This will ensure that LDO and SMPS regulators are not * inadvertently turned on because voltage > 0 is equivalent to * enabling. For NCP, this just removes unnecessary RPM requests. */ if (vreg->is_enabled) { rc = vreg_set(vreg, mask[0], val[0], mask[1], val[1], vreg->part->request_len); if (rc) vreg_err(vreg, "vreg_set failed, rc=%d\n", rc); } else if (vreg->type == RPM_REGULATOR_TYPE_NCP) { /* Regulator is disabled; store but don't send new request. */ rc = vreg_store(vreg, mask[0], val[0], mask[1], val[1]); } if (!rc && (!vreg->pdata.sleep_selectable || !vreg->is_enabled)) vreg->save_uV = uV; mutex_unlock(&vreg->pc_lock); return rc; }
static int vreg_enable_time(struct regulator_dev *rdev) { struct vreg *vreg = rdev_get_drvdata(rdev); return vreg->pdata.enable_time; }
/* * Returns the logical pin control enable state because the pin control options * present in the hardware out of restart could be different from those desired * by the consumer. */ static int vreg_pin_control_is_enabled(struct regulator_dev *rdev) { struct vreg *vreg = rdev_get_drvdata(rdev); return vreg->is_enabled_pc; }
static int gpio_regulator_is_enabled(struct regulator_dev *dev) { struct gpio_regulator_data *data = rdev_get_drvdata(dev); return data->is_enabled; }
static int ricoh61x_list_voltage(struct regulator_dev *rdev, unsigned index) { struct ricoh61x_regulator *ri = rdev_get_drvdata(rdev); return ri->min_uV + (ri->step_uV * index); }
static int gpio_regulator_enable_time(struct regulator_dev *dev) { struct gpio_regulator_data *data = rdev_get_drvdata(dev); return data->startup_delay; }
static int da9063_suspend_disable(struct regulator_dev *rdev) { struct da9063_regulator *regl = rdev_get_drvdata(rdev); return regmap_field_write(regl->suspend, 0); }
static int max8986_regulator_is_enabled(struct regulator_dev *rdev) { struct max8986_regl_priv *regl_priv = rdev_get_drvdata(rdev); int id = rdev_get_id(rdev); return _max8986_regulator_is_enabled(regl_priv, id); }
static int footswitch_is_enabled(struct regulator_dev *rdev) { struct footswitch *fs = rdev_get_drvdata(rdev); return fs->is_enabled; }
static int bq24022_get_current_limit(struct regulator_dev *rdev) { struct bq24022_mach_info *pdata = rdev_get_drvdata(rdev); return gpio_get_value(pdata->gpio_iset2) ? 500000 : 100000; }
static int footswitch_disable(struct regulator_dev *rdev) { struct footswitch *fs = rdev_get_drvdata(rdev); uint32_t regval, rc = 0; /* Return early if already disabled. */ regval = readl_relaxed(fs->gfs_ctl_reg); if ((regval & ENABLE_BIT) == 0) return 0; /* Make sure required clocks are on at the correct rates. */ rc = setup_clocks(fs); if (rc) goto out; /* Halt all bus ports in the power domain. */ if (fs->bus_port1) { rc = msm_bus_axi_porthalt(fs->bus_port1); if (rc) { pr_err("%s: Port 1 halt failed.\n", __func__); goto out; } } if (fs->bus_port2) { rc = msm_bus_axi_porthalt(fs->bus_port2); if (rc) { pr_err("%s: Port 1 halt failed.\n", __func__); goto err_port2_halt; } } /* * Assert resets for all clocks in the clock domain so that * outputs settle prior to clamping. */ if (fs->axi_clk) clk_reset(fs->axi_clk, CLK_RESET_ASSERT); clk_reset(fs->ahb_clk, CLK_RESET_ASSERT); clk_reset(fs->core_clk, CLK_RESET_ASSERT); /* Wait for synchronous resets to propagate. */ udelay(RESET_DELAY_US); /* * Clamp the I/O ports of the core to ensure the values * remain fixed while the core is collapsed. */ regval |= CLAMP_BIT; writel_relaxed(regval, fs->gfs_ctl_reg); /* Collapse the power rail at the footswitch. */ regval &= ~ENABLE_BIT; writel_relaxed(regval, fs->gfs_ctl_reg); /* Return clocks to their state before this function. */ restore_clocks(fs); fs->is_enabled = false; return rc; err_port2_halt: msm_bus_axi_portunhalt(fs->bus_port1); out: return rc; }
static int set_charge_current_limit(struct regulator_dev *rdev, int min_uA, int max_uA) { struct tps80031_charger *charger = rdev_get_drvdata(rdev); int max_vbus_current = 1500; int max_charge_current = 1500; int ret; dev_info(charger->dev, "%s(): Min curr %dmA and max current %dmA\n", __func__, min_uA/1000, max_uA/1000); if (!max_uA) { ret = tps80031_write(charger->dev->parent, SLAVE_ID2, CONTROLLER_CTRL1, 0x0); if (ret < 0) dev_err(charger->dev, "%s(): Failed in writing register 0x%02x\n", __func__, CONTROLLER_CTRL1); ret = tps80031_write(charger->dev->parent, SLAVE_ID2, CONTROLLER_WDG, 0x0); if (ret < 0) dev_err(charger->dev, "%s(): Failed in writing register 0x%02x\n", __func__, CONTROLLER_WDG); charger->state = charging_state_charging_stopped; if (charger->charger_cb) charger->charger_cb(charger->state, charger->charger_cb_data); return ret; } max_vbus_current = min(max_uA/1000, max_vbus_current); max_vbus_current = max_vbus_current/50; if (max_vbus_current) max_vbus_current--; ret = tps80031_update(charger->dev->parent, SLAVE_ID2, CHARGERUSB_CINLIMIT, charging_current_val_code[max_vbus_current], 0x3F); if (ret < 0) { dev_err(charger->dev, "%s(): Failed in writing register 0x%02x\n", __func__, CHARGERUSB_CINLIMIT); return ret; } max_charge_current = min(max_uA/1000, max_charge_current); if (max_charge_current <= 300) max_charge_current = 0; else if ((max_charge_current > 300) && (max_charge_current <= 500)) max_charge_current = (max_charge_current - 300)/50; else max_charge_current = (max_charge_current - 500) / 100 + 4; ret = tps80031_update(charger->dev->parent, SLAVE_ID2, CHARGERUSB_VICHRG, (uint8_t)max_charge_current, 0xF); if (ret < 0) { dev_err(charger->dev, "%s(): Failed in writing register 0x%02x\n", __func__, CHARGERUSB_VICHRG); return ret; } /* Enable watchdog timer */ ret = tps80031_write(charger->dev->parent, SLAVE_ID2, CONTROLLER_WDG, charger->watch_time_sec); if (ret < 0) { dev_err(charger->dev, "%s(): Failed in writing register 0x%02x\n", __func__, CONTROLLER_WDG); return ret; } /* Enable the charging */ ret = tps80031_write(charger->dev->parent, SLAVE_ID2, CONTROLLER_CTRL1, 0x30); if (ret < 0) { dev_err(charger->dev, "%s(): Failed in writing register 0x%02x\n", __func__, CONTROLLER_CTRL1); return ret; } charger->state = charging_state_charging_in_progress; if (charger->charger_cb) charger->charger_cb(charger->state, charger->charger_cb_data); return 0; }
static int gfx2d_footswitch_enable(struct regulator_dev *rdev) { struct footswitch *fs = rdev_get_drvdata(rdev); uint32_t regval, rc = 0; mutex_lock(&claim_lock); fs->is_claimed = true; mutex_unlock(&claim_lock); /* Return early if already enabled. */ regval = readl_relaxed(fs->gfs_ctl_reg); if ((regval & (ENABLE_BIT | CLAMP_BIT)) == ENABLE_BIT) return 0; /* Make sure required clocks are on at the correct rates. */ rc = setup_clocks(fs); if (rc) goto out; /* Un-halt all bus ports in the power domain. */ if (fs->bus_port1) { rc = msm_bus_axi_portunhalt(fs->bus_port1); if (rc) { pr_err("%s: Port 1 unhalt failed.\n", __func__); goto out; } } /* Disable core clock. */ clk_disable(fs->core_clk); /* * (Re-)Assert resets for all clocks in the clock domain, since * footswitch_enable() is first called before footswitch_disable() * and resets should be asserted before power is restored. */ if (fs->axi_clk) clk_reset(fs->axi_clk, CLK_RESET_ASSERT); clk_reset(fs->ahb_clk, CLK_RESET_ASSERT); clk_reset(fs->core_clk, CLK_RESET_ASSERT); /* Wait for synchronous resets to propagate. */ udelay(20); /* Enable the power rail at the footswitch. */ regval |= ENABLE_BIT; writel_relaxed(regval, fs->gfs_ctl_reg); mb(); udelay(1); /* Un-clamp the I/O ports. */ regval &= ~CLAMP_BIT; writel_relaxed(regval, fs->gfs_ctl_reg); /* Deassert resets for all clocks in the power domain. */ if (fs->axi_clk) clk_reset(fs->axi_clk, CLK_RESET_DEASSERT); clk_reset(fs->ahb_clk, CLK_RESET_DEASSERT); clk_reset(fs->core_clk, CLK_RESET_DEASSERT); udelay(20); /* Re-enable core clock. */ clk_enable(fs->core_clk); /* Return clocks to their state before this function. */ restore_clocks(fs); fs->is_enabled = true; out: return rc; }
static int tps6586x_regulator_enable_time(struct regulator_dev *rdev) { struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); return ri->delay; }
static int syr82x_dcdc_suspend_disable(struct regulator_dev *dev) { struct syr82x *syr82x = rdev_get_drvdata(dev); u16 mask=0x80; return syr82x_set_bits(syr82x, SYR82X_BUCK1_SLP_VOL_BASE, mask, 0); }
static int saw_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, unsigned *selector) { struct saw_vreg *vreg = rdev_get_drvdata(rdev); int uV = min_uV; int rc; u8 vprog, band; if (uV < FTSMPS_BAND1_UV_MIN && max_uV >= FTSMPS_BAND1_UV_MIN) uV = FTSMPS_BAND1_UV_MIN; if (uV < FTSMPS_BAND1_UV_MIN || uV > FTSMPS_BAND3_UV_MAX) { pr_err("%s: request v=[%d, %d] is outside possible " "v=[%d, %d]\n", vreg->name, min_uV, max_uV, FTSMPS_BAND1_UV_MIN, FTSMPS_BAND3_UV_MAX); return -EINVAL; } /* Round up for set points in the gaps between bands. */ if (uV > FTSMPS_BAND1_UV_MAX && uV < FTSMPS_BAND2_UV_MIN) uV = FTSMPS_BAND2_UV_MIN; else if (uV > FTSMPS_BAND2_UV_MAX && uV < FTSMPS_BAND3_UV_SET_POINT_MIN) uV = FTSMPS_BAND3_UV_SET_POINT_MIN; if (uV > FTSMPS_BAND2_UV_MAX) { vprog = (uV - FTSMPS_BAND3_UV_MIN + FTSMPS_BAND3_UV_STEP - 1) / FTSMPS_BAND3_UV_STEP; band = FTSMPS_VCTRL_BAND_3; uV = FTSMPS_BAND3_UV_MIN + vprog * FTSMPS_BAND3_UV_STEP; } else if (uV > FTSMPS_BAND1_UV_MAX) { vprog = (uV - FTSMPS_BAND2_UV_MIN + FTSMPS_BAND2_UV_STEP - 1) / FTSMPS_BAND2_UV_STEP; band = FTSMPS_VCTRL_BAND_2; uV = FTSMPS_BAND2_UV_MIN + vprog * FTSMPS_BAND2_UV_STEP; } else { vprog = (uV - FTSMPS_BAND1_UV_MIN + FTSMPS_BAND1_UV_LOG_STEP - 1) / FTSMPS_BAND1_UV_LOG_STEP; uV = FTSMPS_BAND1_UV_MIN + vprog * FTSMPS_BAND1_UV_LOG_STEP; vprog *= FTSMPS_BAND1_UV_LOG_STEP / FTSMPS_BAND1_UV_PHYS_STEP; band = FTSMPS_VCTRL_BAND_1; } if (uV > max_uV) { pr_err("%s: request v=[%d, %d] cannot be met by any setpoint\n", vreg->name, min_uV, max_uV); return -EINVAL; } rc = msm_spm_set_vdd(rdev_get_id(rdev), band | vprog); if (!rc) { if (uV > vreg->uV) { /* Wait for voltage to stabalize. */ udelay((uV - vreg->uV) / REGULATOR_SLEW_RATE); } vreg->uV = uV; } else { pr_err("%s: msm_spm_set_vdd failed %d\n", vreg->name, rc); } return rc; }
static int papyrus_display_is_enabled(struct regulator_dev *reg) { struct papyrus *papyrus = rdev_get_drvdata(reg); return gpio_get_value(papyrus->gpio_pmic_wakeup); }
static int regulator_stub_is_enabled(struct regulator_dev *rdev) { struct regulator_stub *vreg_priv = rdev_get_drvdata(rdev); return vreg_priv->enabled; }
return 900 + (bits * 100); } static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev, <<<<<<< HEAD int min_uV, int max_uV, unsigned *selector) ======= int min_uV, int max_uV) >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a { struct pcf50633 *pcf; int regulator_id, millivolts; u8 volt_bits, regnr; pcf = rdev_get_drvdata(rdev); regulator_id = rdev_get_id(rdev); if (regulator_id >= PCF50633_NUM_REGULATORS) return -EINVAL; millivolts = min_uV / 1000; regnr = pcf50633_regulator_registers[regulator_id]; switch (regulator_id) { case PCF50633_REGULATOR_AUTO: volt_bits = auto_voltage_bits(millivolts); break; case PCF50633_REGULATOR_DOWN1: volt_bits = down_voltage_bits(millivolts);