int mc13xxx_fixed_regulator_get_voltage(struct regulator_dev *rdev) { struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; int id = rdev_get_id(rdev); dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); return mc13xxx_regulators[id].voltages[0]; }
static int ab8500_ext_regulator_enable(struct regulator_dev *rdev) { int ret; struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev); u8 regval; if (info == NULL) { dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); return -EINVAL; } ret = enable(info, ®val); dev_dbg(rdev_get_dev(rdev), "%s-enable (bank, reg, mask, value):" " 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", info->desc.name, info->update_bank, info->update_reg, info->update_mask, regval); return ret; }
static int mc13xxx_regulator_disable(struct regulator_dev *rdev) { struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; int id = rdev_get_id(rdev); dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); return mc13xxx_reg_rmw(priv->mc13xxx, mc13xxx_regulators[id].reg, mc13xxx_regulators[id].enable_bit, 0); }
static int ab8500_ext_fixed_get_voltage(struct regulator_dev *rdev) { struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev); if (info == NULL) { dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); return -EINVAL; } return info->fixed_uV; }
static int db8500_regulator_is_enabled(struct regulator_dev *rdev) { struct db8500_regulator_info *info = rdev_get_drvdata(rdev); if (info == NULL) return -EINVAL; dev_vdbg(rdev_get_dev(rdev), "regulator-%s-is_enabled (is_enabled):" " %i\n", info->desc.name, info->is_enabled); return info->is_enabled; }
static int ab8500_ext_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, unsigned *selector) { struct regulation_constraints *regu_constraints = rdev->constraints; if (!regu_constraints) { dev_err(rdev_get_dev(rdev), "No regulator constraints\n"); return -EINVAL; } if (regu_constraints->min_uV == min_uV && regu_constraints->max_uV == max_uV) return 0; dev_err(rdev_get_dev(rdev), "Requested min %duV max %duV != constrained min %duV max %duV\n", min_uV, max_uV, regu_constraints->min_uV, regu_constraints->max_uV); return -EINVAL; }
static int bq24022_set_current_limit(struct regulator_dev *rdev, int min_uA, int max_uA) { struct bq24022_mach_info *pdata = rdev_get_drvdata(rdev); dev_dbg(rdev_get_dev(rdev), "setting current limit to %s mA\n", max_uA >= 500000 ? "500" : "100"); /* REVISIT: maybe return error if min_uA != 0 ? */ gpio_set_value(pdata->gpio_iset2, max_uA >= 500000); return 0; }
static int proccomm_vreg_enable(struct regulator_dev *rdev) { struct proccomm_regulator_drvdata *ddata; int rc; ddata = rdev_get_drvdata(rdev); rc = _vreg_switch(rdev_get_id(rdev), VREG_SWITCH_ENABLE); if (rc) { dev_err(rdev_get_dev(rdev), "could not enable regulator %d (%s): %d\n", rdev_get_id(rdev), ddata->rdesc.name, rc); } else { dev_dbg(rdev_get_dev(rdev), "enabled regulator %d (%s)\n", rdev_get_id(rdev), ddata->rdesc.name); ddata->enabled = 1; } return rc; }
static int ab8500_regulator_set_mode(struct regulator_dev *rdev, unsigned int mode) { int ret = 0; struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); if (info == NULL) { dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); return -EINVAL; } switch (mode) { case REGULATOR_MODE_NORMAL: info->update_val = info->update_val_normal; break; case REGULATOR_MODE_IDLE: info->update_val = info->update_val_idle; break; default: return -EINVAL; } if (info->is_enabled) { ret = abx500_mask_and_set_register_interruptible(info->dev, info->update_bank, info->update_reg, info->update_mask, info->update_val); if (ret < 0) dev_err(rdev_get_dev(rdev), "couldn't set regulator mode\n"); dev_vdbg(rdev_get_dev(rdev), "%s-set_mode (bank, reg, mask, value): " "0x%x, 0x%x, 0x%x, 0x%x\n", info->desc.name, info->update_bank, info->update_reg, info->update_mask, info->update_val); } return ret; }
static int ab8500_ext_regulator_set_mode(struct regulator_dev *rdev, unsigned int mode) { int ret = 0; struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev); if (info == NULL) { dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); return -EINVAL; } switch (mode) { case REGULATOR_MODE_NORMAL: info->update_val = info->update_val_hp; break; case REGULATOR_MODE_IDLE: info->update_val = info->update_val_lp; break; default: return -EINVAL; } if (info->is_enabled) { u8 regval; ret = enable(info, ®val); if (ret < 0) dev_err(rdev_get_dev(rdev), "Could not set regulator mode.\n"); dev_dbg(rdev_get_dev(rdev), "%s-set_mode (bank, reg, mask, value): " "0x%x, 0x%x, 0x%x, 0x%x\n", info->desc.name, info->update_bank, info->update_reg, info->update_mask, regval); } return ret; }
static int da903x_is_enabled(struct regulator_dev *rdev) { struct da903x_regulator_info *info = rdev_get_drvdata(rdev); struct device *da9034_dev = rdev_get_dev(rdev)->parent; uint8_t reg_val; int ret; ret = da903x_read(da9034_dev, info->enable_reg, ®_val); if (ret) return ret; return reg_val & (1 << info->enable_bit); }
static int mc13892_sw_regulator_get_voltage_sel(struct regulator_dev *rdev) { struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); int ret, id = rdev_get_id(rdev); unsigned int val; dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); mc13xxx_lock(priv->mc13xxx); ret = mc13xxx_reg_read(priv->mc13xxx, mc13892_regulators[id].vsel_reg, &val); mc13xxx_unlock(priv->mc13xxx); if (ret) return ret; val = (val & mc13892_regulators[id].vsel_mask) >> mc13892_regulators[id].vsel_shift; dev_dbg(rdev_get_dev(rdev), "%s id: %d val: %d\n", __func__, id, val); return val; }
static int mc13892_sw_regulator_get_voltage_sel(struct regulator_dev *rdev) { struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); int ret, id = rdev_get_id(rdev); unsigned int val, selector; dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); mc13xxx_lock(priv->mc13xxx); ret = mc13xxx_reg_read(priv->mc13xxx, mc13892_regulators[id].vsel_reg, &val); mc13xxx_unlock(priv->mc13xxx); if (ret) return ret; /* * Figure out if the HI bit is set inside the switcher mode register * since this means the selector value we return is at a different * offset into the selector table. * * According to the MC13892 documentation note 59 (Table 47) the SW1 * buck switcher does not support output range programming therefore * the HI bit must always remain 0. So do not do anything strange if * our register is MC13892_SWITCHERS0. */ selector = val & mc13892_regulators[id].vsel_mask; if ((mc13892_regulators[id].vsel_reg != MC13892_SWITCHERS0) && (val & MC13892_SWITCHERS0_SWxHI)) { selector += MC13892_SWxHI_SEL_OFFSET; } dev_dbg(rdev_get_dev(rdev), "%s id: %d val: 0x%08x selector: %d\n", __func__, id, val, selector); return selector; }
static int db8500_regulator_switch_disable(struct regulator_dev *rdev) { struct db8500_regulator_info *info = rdev_get_drvdata(rdev); int ret; if (info == NULL) return -EINVAL; dev_vdbg(rdev_get_dev(rdev), "regulator-switch-%s-disable\n", info->desc.name); ret = disable_epod(info->epod_id, info->is_ramret); if (ret < 0) { dev_err(rdev_get_dev(rdev), "regulator_switch-%s-disable: prcmu call failed\n", info->desc.name); goto out; } info->is_enabled = 0; out: return ret; }
static int mc13783_fixed_regulator_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) { int id = rdev_get_id(rdev); dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", __func__, id, min_uV, max_uV); if (min_uV >= mc13783_regulators[id].voltages[0] && max_uV <= mc13783_regulators[id].voltages[0]) return 0; else return -EINVAL; }
void ab8500_ext_regulator_exit(struct platform_device *pdev) { int i; for (i = 0; i < ARRAY_SIZE(ab8500_ext_regulator_info); i++) { struct ab8500_ext_regulator_info *info = NULL; info = &ab8500_ext_regulator_info[i]; dev_vdbg(rdev_get_dev(info->rdev), "%s-remove\n", info->desc.name); regulator_unregister(info->rdev); } }
static int mc13xxx_regulator_get_voltage(struct regulator_dev *rdev) { struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); struct mc13xxx_regulator *mc13xxx_regulators = priv->mc13xxx_regulators; int ret, id = rdev_get_id(rdev); unsigned int val; dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); ret = mc13xxx_reg_read(priv->mc13xxx, mc13xxx_regulators[id].vsel_reg, &val); if (ret) return ret; val = (val & mc13xxx_regulators[id].vsel_mask) >> mc13xxx_regulators[id].vsel_shift; dev_dbg(rdev_get_dev(rdev), "%s id: %d val: %d\n", __func__, id, val); BUG_ON(val >= mc13xxx_regulators[id].desc.n_voltages); return rdev->desc->volt_table[val]; }
static int ab8500_regulator_disable(struct regulator_dev *rdev) { int ret; struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); if (info == NULL) { dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); return -EINVAL; } ret = abx500_mask_and_set_register_interruptible(info->dev, info->update_bank, info->update_reg, info->update_mask, 0x0); if (ret < 0) dev_err(rdev_get_dev(rdev), "couldn't set disable bits for regulator\n"); dev_vdbg(rdev_get_dev(rdev), "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n", info->desc.name, info->update_bank, info->update_reg, info->update_mask, 0x0); return ret; }
static int mc13783_regulator_disable(struct regulator_dev *rdev) { struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev); int id = rdev_get_id(rdev); int ret; dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); mc13783_lock(priv->mc13783); ret = mc13783_reg_rmw(priv->mc13783, mc13783_regulators[id].reg, mc13783_regulators[id].enable_bit, 0); mc13783_unlock(priv->mc13783); return ret; }
static int mc13783_regulator_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) { struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev); int value, id = rdev_get_id(rdev); int ret; dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", __func__, id, min_uV, max_uV); /* Find the best index */ value = mc13783_get_best_voltage_index(rdev, min_uV, max_uV); dev_dbg(rdev_get_dev(rdev), "%s best value: %d \n", __func__, value); if (value < 0) return value; mc13783_lock(priv->mc13783); ret = mc13783_reg_rmw(priv->mc13783, mc13783_regulators[id].vsel_reg, mc13783_regulators[id].vsel_mask, value << mc13783_regulators[id].vsel_shift); mc13783_unlock(priv->mc13783); return ret; }
static int mc13892_gpo_regulator_disable(struct regulator_dev *rdev) { struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); int id = rdev_get_id(rdev); u32 dis_val = 0; dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id); /* Power Gate disable value is 1 */ if (id == MC13892_PWGT1SPI || id == MC13892_PWGT2SPI) dis_val = mc13892_regulators[id].enable_bit; return mc13892_powermisc_rmw(priv, mc13892_regulators[id].enable_bit, dis_val); }
static int ab8500_ext_regulator_enable(struct regulator_dev *rdev) { int ret; struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev); u8 regval; if (info == NULL) { dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); return -EINVAL; } /* * To satisfy both HW high power request and SW request, the regulator * must be on in high power. */ if (info->cfg && info->cfg->hwreq) regval = info->update_val_hp; else regval = info->update_val; ret = abx500_mask_and_set_register_interruptible(info->dev, info->update_bank, info->update_reg, info->update_mask, regval); if (ret < 0) { dev_err(rdev_get_dev(info->rdev), "couldn't set enable bits for regulator\n"); return ret; } dev_dbg(rdev_get_dev(rdev), "%s-enable (bank, reg, mask, value): 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", info->desc.name, info->update_bank, info->update_reg, info->update_mask, regval); return 0; }
static int proccomm_vreg_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, unsigned *sel) { struct proccomm_regulator_drvdata *ddata = rdev_get_drvdata(rdev); int level_mV = UV_TO_MV(min_uV); int rc; rc = _vreg_set_level(rdev_get_id(rdev), ddata->negative ? -level_mV : level_mV); if (rc) { dev_err(rdev_get_dev(rdev), "could not set voltage for regulator %d (%s) " "to %d mV: %d\n", rdev_get_id(rdev), ddata->rdesc.name, level_mV, rc); } else { dev_dbg(rdev_get_dev(rdev), "voltage for regulator %d (%s) set to %d mV\n", rdev_get_id(rdev), ddata->rdesc.name, level_mV); ddata->last_voltage = level_mV; } return rc; }
static unsigned int pm800_get_optimum_mode(struct regulator_dev *rdev, int input_uV, int output_uV, int current_uA) { struct pm800_regulator_info *info = rdev_get_drvdata(rdev); if (!info) { dev_err(rdev_get_dev(rdev), "return REGULATOR_MODE_IDLE by default\n"); return REGULATOR_MODE_IDLE; } if (current_uA < 0) { dev_err(rdev_get_dev(rdev), "return REGULATOR_MODE_IDLE for unexpected current\n"); return REGULATOR_MODE_IDLE; } /* * get_optimum_mode be called at enbale/disable_regulator function. * If current_uA is not set it will be 0, * set defult value to be REGULATOR_MODE_IDLE. */ return (MAX_SLEEP_CURRENT > current_uA) ? REGULATOR_MODE_IDLE : REGULATOR_MODE_NORMAL; }
static int __exit db8500_regulator_remove(struct platform_device *pdev) { int i; for (i = 0; i < ARRAY_SIZE(db8500_regulator_info); i++) { struct db8500_regulator_info *info; info = &db8500_regulator_info[i]; dev_vdbg(rdev_get_dev(info->rdev), "regulator-%s-remove\n", info->desc.name); regulator_unregister(info->rdev); } return 0; }
static int ab8500_ext_list_voltage(struct regulator_dev *rdev, unsigned selector) { struct regulation_constraints *regu_constraints = rdev->constraints; if (regu_constraints == NULL) { dev_err(rdev_get_dev(rdev), "regulator constraints null pointer\n"); return -EINVAL; } /* return the uV for the fixed regulators */ if (regu_constraints->min_uV && regu_constraints->max_uV) { if (regu_constraints->min_uV == regu_constraints->max_uV) return regu_constraints->min_uV; } return -EINVAL; }
int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, unsigned *selector) { int id = rdev_get_id(rdev); dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", __func__, id, min_uV, max_uV); if (min_uV <= rdev->desc->volt_table[0] && rdev->desc->volt_table[0] <= max_uV) { *selector = 0; return 0; } else { return -EINVAL; } }
static int db8500_regulator_enable(struct regulator_dev *rdev) { struct db8500_regulator_info *info = rdev_get_drvdata(rdev); if (info == NULL) return -EINVAL; dev_vdbg(rdev_get_dev(rdev), "regulator-%s-enable\n", info->desc.name); info->is_enabled = true; if (!info->exclude_from_power_state) power_state_active_enable(); return 0; }
static int ab8500_regulator_enable(struct regulator_dev *rdev) { int regulator_id, ret; struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); regulator_id = rdev_get_id(rdev); if (regulator_id >= AB8500_NUM_REGULATORS) return -EINVAL; ret = ab8500_set_bits(info->ab8500, info->update_reg, info->mask, info->enable); if (ret < 0) dev_err(rdev_get_dev(rdev), "couldn't set enable bits for regulator\n"); return ret; }
static int ab8500_ext_list_voltage(struct regulator_dev *rdev, unsigned selector) { struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev); if (info == NULL) { dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); return -EINVAL; } /* return the uV for the fixed regulators */ if (info->fixed_uV) return info->fixed_uV; return -EINVAL; }