static int tps6586x_fixed_regulator_disable(struct regulator_dev *rdev) { struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_tps6586x_dev(rdev); return tps6586x_set_bits(parent, ri->enable_reg[0], 1 << ri->enable_bit[0]); }
static int tps6586x_ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) { struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_tps6586x_dev(rdev); return __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV); }
static int tps6586x_fixed_regulator_is_enabled(struct regulator_dev *rdev) { struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_tps6586x_dev(rdev); uint8_t reg_val; int ret; ret = tps6586x_read(parent, ri->enable_reg[0], ®_val); if (ret) return ret; return !(reg_val & (1 << ri->enable_bit[0])); }
static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) { struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_tps6586x_dev(rdev); int ret; ret = __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV); if (ret) return ret; return tps6586x_set_bits(parent, ri->go_reg, 1 << ri->go_bit); }
static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev) { struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_tps6586x_dev(rdev); uint8_t val, mask; int ret; ret = tps6586x_read(parent, ri->volt_reg, &val); if (ret) return ret; mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift; val = (val & mask) >> ri->volt_shift; if (val >= ri->desc.n_voltages) BUG(); return ri->voltages[val] * 1000; }
static int tps6586x_lds_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) { struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); struct device *parent = to_tps6586x_dev(rdev); int ret; ret = gpio_request(ri->volt_shift, "Load Switch"); if (ret) { printk(KERN_ERR "[Load Switch] %s() Fail to request GPIO (%d)\n", __func__, ri->volt_shift); return ret; } gpio_set_value(ri->volt_shift, !!(ri->volt_nbits)); gpio_free(ri->volt_shift); return 0; }