H A D | lp3972.c | 18 #include <linux/regulator/lp3972.h> 21 struct lp3972 { struct 190 static u8 lp3972_reg_read(struct lp3972 *lp3972, u8 reg) lp3972_reg_read() argument 194 mutex_lock(&lp3972->io_lock); lp3972_reg_read() 196 lp3972_i2c_read(lp3972->i2c, reg, 1, &val); lp3972_reg_read() 198 dev_dbg(lp3972->dev, "reg read 0x%02x -> 0x%02x\n", (int)reg, lp3972_reg_read() 201 mutex_unlock(&lp3972->io_lock); lp3972_reg_read() 206 static int lp3972_set_bits(struct lp3972 *lp3972, u8 reg, u16 mask, u16 val) lp3972_set_bits() argument 211 mutex_lock(&lp3972->io_lock); lp3972_set_bits() 213 ret = lp3972_i2c_read(lp3972->i2c, reg, 1, &tmp); lp3972_set_bits() 216 ret = lp3972_i2c_write(lp3972->i2c, reg, 1, &tmp); lp3972_set_bits() 217 dev_dbg(lp3972->dev, "reg write 0x%02x -> 0x%02x\n", (int)reg, lp3972_set_bits() 220 mutex_unlock(&lp3972->io_lock); lp3972_set_bits() 227 struct lp3972 *lp3972 = rdev_get_drvdata(dev); lp3972_ldo_is_enabled() local 232 val = lp3972_reg_read(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo)); lp3972_ldo_is_enabled() 238 struct lp3972 *lp3972 = rdev_get_drvdata(dev); lp3972_ldo_enable() local 242 return lp3972_set_bits(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo), lp3972_ldo_enable() 248 struct lp3972 *lp3972 = rdev_get_drvdata(dev); lp3972_ldo_disable() local 252 return lp3972_set_bits(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo), lp3972_ldo_disable() 258 struct lp3972 *lp3972 = rdev_get_drvdata(dev); lp3972_ldo_get_voltage_sel() local 263 reg = lp3972_reg_read(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo)); lp3972_ldo_get_voltage_sel() 272 struct lp3972 *lp3972 = rdev_get_drvdata(dev); lp3972_ldo_set_voltage_sel() local 277 ret = lp3972_set_bits(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo), lp3972_ldo_set_voltage_sel() 294 ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG, lp3972_ldo_set_voltage_sel() 300 ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG, lp3972_ldo_set_voltage_sel() 320 struct lp3972 *lp3972 = rdev_get_drvdata(dev); lp3972_dcdc_is_enabled() local 325 val = lp3972_reg_read(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck)); lp3972_dcdc_is_enabled() 331 struct lp3972 *lp3972 = rdev_get_drvdata(dev); lp3972_dcdc_enable() local 336 val = lp3972_set_bits(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck), lp3972_dcdc_enable() 343 struct lp3972 *lp3972 = rdev_get_drvdata(dev); lp3972_dcdc_disable() local 348 val = lp3972_set_bits(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck), lp3972_dcdc_disable() 355 struct lp3972 *lp3972 = rdev_get_drvdata(dev); lp3972_dcdc_get_voltage_sel() local 359 reg = lp3972_reg_read(lp3972, LP3972_BUCK_VOL1_REG(buck)); lp3972_dcdc_get_voltage_sel() 368 struct lp3972 *lp3972 = rdev_get_drvdata(dev); lp3972_dcdc_set_voltage_sel() local 372 ret = lp3972_set_bits(lp3972, LP3972_BUCK_VOL1_REG(buck), lp3972_dcdc_set_voltage_sel() 380 ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG, lp3972_dcdc_set_voltage_sel() 385 return lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG, lp3972_dcdc_set_voltage_sel() 474 static int setup_regulators(struct lp3972 *lp3972, setup_regulators() argument 485 config.dev = lp3972->dev; setup_regulators() 487 config.driver_data = lp3972; setup_regulators() 489 rdev = devm_regulator_register(lp3972->dev, setup_regulators() 493 dev_err(lp3972->dev, "regulator init failed: %d\n", setup_regulators() 505 struct lp3972 *lp3972; lp3972_i2c_probe() local 515 lp3972 = devm_kzalloc(&i2c->dev, sizeof(struct lp3972), GFP_KERNEL); lp3972_i2c_probe() 516 if (!lp3972) lp3972_i2c_probe() 519 lp3972->i2c = i2c; lp3972_i2c_probe() 520 lp3972->dev = &i2c->dev; lp3972_i2c_probe() 522 mutex_init(&lp3972->io_lock); lp3972_i2c_probe() 536 ret = setup_regulators(lp3972, pdata); lp3972_i2c_probe() 540 i2c_set_clientdata(i2c, lp3972); lp3972_i2c_probe() 545 { "lp3972", 0 }, 552 .name = "lp3972",
|