Source
x
/*
* tps65218-regulator.c
*
* Regulator driver for TPS65218 PMIC
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
* kind, whether expressed or implied; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License version 2 for more details.
*/
REGULATOR_LINEAR_RANGE(850000, 0x0, 0x32, 10000),
REGULATOR_LINEAR_RANGE(1375000, 0x33, 0x3f, 25000),
};
static const struct regulator_linear_range ldo1_dcdc3_ranges[] = {
REGULATOR_LINEAR_RANGE(900000, 0x0, 0x1a, 25000),
REGULATOR_LINEAR_RANGE(1600000, 0x1b, 0x3f, 50000),
};
static const struct regulator_linear_range dcdc4_ranges[] = {
REGULATOR_LINEAR_RANGE(1175000, 0x0, 0xf, 25000),
REGULATOR_LINEAR_RANGE(1600000, 0x10, 0x34, 50000),
};
static int tps65218_pmic_set_voltage_sel(struct regulator_dev *dev,
unsigned selector)
{
int ret;
struct tps65218 *tps = rdev_get_drvdata(dev);
unsigned int rid = rdev_get_id(dev);
/* Set the voltage based on vsel value and write protect level is 2 */
ret = tps65218_set_bits(tps, dev->desc->vsel_reg, dev->desc->vsel_mask,
selector, TPS65218_PROTECT_L1);
/* Set GO bit for DCDC1/2 to initiate voltage transistion */
switch (rid) {
case TPS65218_DCDC_1:
case TPS65218_DCDC_2:
ret = tps65218_set_bits(tps, TPS65218_REG_CONTRL_SLEW_RATE,
TPS65218_SLEW_RATE_GO,
TPS65218_SLEW_RATE_GO,
TPS65218_PROTECT_L1);
break;
}