2018-05-30 16:43:43 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
// Copyright (C) 2018 ROHM Semiconductors
|
2018-09-14 16:32:26 +08:00
|
|
|
// bd71837-regulator.c ROHM BD71837MWV/BD71847MWV regulator driver
|
2018-05-30 16:43:43 +08:00
|
|
|
|
2018-06-28 19:22:23 +08:00
|
|
|
#include <linux/delay.h>
|
2018-05-30 16:43:43 +08:00
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/interrupt.h>
|
2018-06-28 19:22:23 +08:00
|
|
|
#include <linux/kernel.h>
|
2018-07-30 19:50:08 +08:00
|
|
|
#include <linux/mfd/rohm-bd718x7.h>
|
2018-06-28 19:22:23 +08:00
|
|
|
#include <linux/module.h>
|
2018-10-29 20:16:30 +08:00
|
|
|
#include <linux/of.h>
|
2018-05-30 16:43:43 +08:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/regulator/driver.h>
|
|
|
|
#include <linux/regulator/machine.h>
|
|
|
|
#include <linux/regulator/of_regulator.h>
|
2018-06-28 19:22:23 +08:00
|
|
|
#include <linux/slab.h>
|
2018-05-30 16:43:43 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* BUCK1/2/3/4
|
|
|
|
* BUCK1RAMPRATE[1:0] BUCK1 DVS ramp rate setting
|
|
|
|
* 00: 10.00mV/usec 10mV 1uS
|
|
|
|
* 01: 5.00mV/usec 10mV 2uS
|
|
|
|
* 10: 2.50mV/usec 10mV 4uS
|
|
|
|
* 11: 1.25mV/usec 10mV 8uS
|
|
|
|
*/
|
2018-09-14 16:32:26 +08:00
|
|
|
static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev,
|
2018-05-30 16:43:43 +08:00
|
|
|
int ramp_delay)
|
|
|
|
{
|
2019-04-07 17:03:02 +08:00
|
|
|
int id = rdev_get_id(rdev);
|
|
|
|
unsigned int ramp_value;
|
2018-05-30 16:43:43 +08:00
|
|
|
|
2018-10-04 15:25:58 +08:00
|
|
|
dev_dbg(&rdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1,
|
2018-05-30 16:43:43 +08:00
|
|
|
ramp_delay);
|
|
|
|
switch (ramp_delay) {
|
|
|
|
case 1 ... 1250:
|
|
|
|
ramp_value = BUCK_RAMPRATE_1P25MV;
|
|
|
|
break;
|
|
|
|
case 1251 ... 2500:
|
|
|
|
ramp_value = BUCK_RAMPRATE_2P50MV;
|
|
|
|
break;
|
|
|
|
case 2501 ... 5000:
|
|
|
|
ramp_value = BUCK_RAMPRATE_5P00MV;
|
|
|
|
break;
|
|
|
|
case 5001 ... 10000:
|
|
|
|
ramp_value = BUCK_RAMPRATE_10P00MV;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ramp_value = BUCK_RAMPRATE_10P00MV;
|
2018-10-04 15:25:58 +08:00
|
|
|
dev_err(&rdev->dev,
|
2018-05-30 16:43:43 +08:00
|
|
|
"%s: ramp_delay: %d not supported, setting 10000mV//us\n",
|
|
|
|
rdev->desc->name, ramp_delay);
|
|
|
|
}
|
|
|
|
|
2018-10-04 15:25:58 +08:00
|
|
|
return regmap_update_bits(rdev->regmap, BD718XX_REG_BUCK1_CTRL + id,
|
2018-05-30 16:43:43 +08:00
|
|
|
BUCK_RAMPRATE_MASK, ramp_value << 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Bucks 1 to 4 support DVS. PWM mode is used when voltage is changed.
|
|
|
|
* Bucks 5 to 8 and LDOs can use PFM and must be disabled when voltage
|
|
|
|
* is changed. Hence we return -EBUSY for these if voltage is changed
|
|
|
|
* when BUCK/LDO is enabled.
|
|
|
|
*/
|
2018-09-14 16:27:46 +08:00
|
|
|
static int bd718xx_set_voltage_sel_restricted(struct regulator_dev *rdev,
|
2018-05-30 16:43:43 +08:00
|
|
|
unsigned int sel)
|
|
|
|
{
|
2018-06-27 20:40:14 +08:00
|
|
|
if (regulator_is_enabled_regmap(rdev))
|
|
|
|
return -EBUSY;
|
2018-05-30 16:43:43 +08:00
|
|
|
|
2018-06-27 20:40:14 +08:00
|
|
|
return regulator_set_voltage_sel_regmap(rdev, sel);
|
2018-05-30 16:43:43 +08:00
|
|
|
}
|
|
|
|
|
2018-09-14 16:33:11 +08:00
|
|
|
static int bd718xx_set_voltage_sel_pickable_restricted(
|
|
|
|
struct regulator_dev *rdev, unsigned int sel)
|
|
|
|
{
|
|
|
|
if (regulator_is_enabled_regmap(rdev))
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
return regulator_set_voltage_sel_pickable_regmap(rdev, sel);
|
|
|
|
}
|
|
|
|
|
2019-01-24 18:02:08 +08:00
|
|
|
static const struct regulator_ops bd718xx_pickable_range_ldo_ops = {
|
2018-09-14 16:33:11 +08:00
|
|
|
.enable = regulator_enable_regmap,
|
|
|
|
.disable = regulator_disable_regmap,
|
|
|
|
.is_enabled = regulator_is_enabled_regmap,
|
|
|
|
.list_voltage = regulator_list_voltage_pickable_linear_range,
|
|
|
|
.set_voltage_sel = bd718xx_set_voltage_sel_pickable_restricted,
|
|
|
|
.get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
|
|
|
|
};
|
|
|
|
|
2019-01-24 18:02:08 +08:00
|
|
|
static const struct regulator_ops bd718xx_pickable_range_buck_ops = {
|
2018-09-14 16:33:11 +08:00
|
|
|
.enable = regulator_enable_regmap,
|
|
|
|
.disable = regulator_disable_regmap,
|
|
|
|
.is_enabled = regulator_is_enabled_regmap,
|
|
|
|
.list_voltage = regulator_list_voltage_pickable_linear_range,
|
|
|
|
.set_voltage_sel = bd718xx_set_voltage_sel_pickable_restricted,
|
|
|
|
.get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
|
|
|
|
.set_voltage_time_sel = regulator_set_voltage_time_sel,
|
|
|
|
};
|
|
|
|
|
2019-01-24 18:02:08 +08:00
|
|
|
static const struct regulator_ops bd718xx_ldo_regulator_ops = {
|
2018-05-30 16:43:43 +08:00
|
|
|
.enable = regulator_enable_regmap,
|
|
|
|
.disable = regulator_disable_regmap,
|
|
|
|
.is_enabled = regulator_is_enabled_regmap,
|
|
|
|
.list_voltage = regulator_list_voltage_linear_range,
|
2018-09-14 16:27:46 +08:00
|
|
|
.set_voltage_sel = bd718xx_set_voltage_sel_restricted,
|
2018-05-30 16:43:43 +08:00
|
|
|
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
|
|
|
};
|
|
|
|
|
2019-01-24 18:02:08 +08:00
|
|
|
static const struct regulator_ops bd718xx_ldo_regulator_nolinear_ops = {
|
2018-05-30 16:43:43 +08:00
|
|
|
.enable = regulator_enable_regmap,
|
|
|
|
.disable = regulator_disable_regmap,
|
|
|
|
.is_enabled = regulator_is_enabled_regmap,
|
|
|
|
.list_voltage = regulator_list_voltage_table,
|
2018-09-14 16:27:46 +08:00
|
|
|
.set_voltage_sel = bd718xx_set_voltage_sel_restricted,
|
2018-05-30 16:43:43 +08:00
|
|
|
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
|
|
|
};
|
|
|
|
|
2019-01-24 18:02:08 +08:00
|
|
|
static const struct regulator_ops bd718xx_buck_regulator_ops = {
|
2018-05-30 16:43:43 +08:00
|
|
|
.enable = regulator_enable_regmap,
|
|
|
|
.disable = regulator_disable_regmap,
|
|
|
|
.is_enabled = regulator_is_enabled_regmap,
|
|
|
|
.list_voltage = regulator_list_voltage_linear_range,
|
2018-09-14 16:27:46 +08:00
|
|
|
.set_voltage_sel = bd718xx_set_voltage_sel_restricted,
|
2018-05-30 16:43:43 +08:00
|
|
|
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
|
|
|
.set_voltage_time_sel = regulator_set_voltage_time_sel,
|
|
|
|
};
|
|
|
|
|
2019-01-24 18:02:08 +08:00
|
|
|
static const struct regulator_ops bd718xx_buck_regulator_nolinear_ops = {
|
2018-05-30 16:43:43 +08:00
|
|
|
.enable = regulator_enable_regmap,
|
|
|
|
.disable = regulator_disable_regmap,
|
|
|
|
.is_enabled = regulator_is_enabled_regmap,
|
|
|
|
.list_voltage = regulator_list_voltage_table,
|
2018-11-10 11:50:03 +08:00
|
|
|
.map_voltage = regulator_map_voltage_ascend,
|
2018-09-14 16:27:46 +08:00
|
|
|
.set_voltage_sel = bd718xx_set_voltage_sel_restricted,
|
2018-05-30 16:43:43 +08:00
|
|
|
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
|
|
|
.set_voltage_time_sel = regulator_set_voltage_time_sel,
|
|
|
|
};
|
|
|
|
|
2019-01-24 18:02:08 +08:00
|
|
|
static const struct regulator_ops bd718xx_dvs_buck_regulator_ops = {
|
2018-05-30 16:43:43 +08:00
|
|
|
.enable = regulator_enable_regmap,
|
|
|
|
.disable = regulator_disable_regmap,
|
|
|
|
.is_enabled = regulator_is_enabled_regmap,
|
|
|
|
.list_voltage = regulator_list_voltage_linear_range,
|
|
|
|
.set_voltage_sel = regulator_set_voltage_sel_regmap,
|
|
|
|
.get_voltage_sel = regulator_get_voltage_sel_regmap,
|
|
|
|
.set_voltage_time_sel = regulator_set_voltage_time_sel,
|
2018-09-14 16:32:26 +08:00
|
|
|
.set_ramp_delay = bd718xx_buck1234_set_ramp_delay,
|
2018-05-30 16:43:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2018-09-14 16:27:46 +08:00
|
|
|
* BD71837 BUCK1/2/3/4
|
|
|
|
* BD71847 BUCK1/2
|
2018-05-30 16:43:43 +08:00
|
|
|
* 0.70 to 1.30V (10mV step)
|
|
|
|
*/
|
2018-09-14 16:27:46 +08:00
|
|
|
static const struct regulator_linear_range bd718xx_dvs_buck_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(700000, 0x00, 0x3C, 10000),
|
|
|
|
REGULATOR_LINEAR_RANGE(1300000, 0x3D, 0x3F, 0),
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2018-09-14 16:27:46 +08:00
|
|
|
* BD71837 BUCK5
|
2018-09-14 16:33:11 +08:00
|
|
|
* 0.7V to 1.35V (range 0)
|
|
|
|
* and
|
|
|
|
* 0.675 to 1.325 (range 1)
|
|
|
|
*/
|
|
|
|
static const struct regulator_linear_range bd71837_buck5_volts[] = {
|
|
|
|
/* Ranges when VOLT_SEL bit is 0 */
|
|
|
|
REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
|
|
|
|
REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
|
|
|
|
REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
|
|
|
|
/* Ranges when VOLT_SEL bit is 1 */
|
|
|
|
REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
|
|
|
|
REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
|
|
|
|
REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Range selector for first 3 linear ranges is 0x0
|
|
|
|
* and 0x1 for last 3 ranges.
|
|
|
|
*/
|
|
|
|
static const unsigned int bd71837_buck5_volt_range_sel[] = {
|
|
|
|
0x0, 0x0, 0x0, 0x80, 0x80, 0x80
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2018-09-14 16:27:46 +08:00
|
|
|
* BD71847 BUCK3
|
2018-05-30 16:43:43 +08:00
|
|
|
*/
|
2018-09-14 16:33:11 +08:00
|
|
|
static const struct regulator_linear_range bd71847_buck3_volts[] = {
|
|
|
|
/* Ranges when VOLT_SEL bits are 00 */
|
2018-05-30 16:43:43 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
|
|
|
|
REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
|
|
|
|
REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
|
2018-09-14 16:33:11 +08:00
|
|
|
/* Ranges when VOLT_SEL bits are 01 */
|
|
|
|
REGULATOR_LINEAR_RANGE(550000, 0x0, 0x7, 50000),
|
|
|
|
/* Ranges when VOLT_SEL bits are 11 */
|
|
|
|
REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
|
|
|
|
REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
|
|
|
|
REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
|
|
|
|
};
|
|
|
|
|
|
|
|
static const unsigned int bd71847_buck3_volt_range_sel[] = {
|
|
|
|
0x0, 0x0, 0x0, 0x40, 0x80, 0x80, 0x80
|
2018-05-30 16:43:43 +08:00
|
|
|
};
|
|
|
|
|
2018-09-14 16:33:11 +08:00
|
|
|
static const struct regulator_linear_range bd71847_buck4_volts[] = {
|
2018-09-14 16:27:46 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
|
2018-09-14 16:33:11 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(2600000, 0x00, 0x03, 100000),
|
2018-09-14 16:27:46 +08:00
|
|
|
};
|
|
|
|
|
2018-09-14 16:33:11 +08:00
|
|
|
static const unsigned int bd71847_buck4_volt_range_sel[] = { 0x0, 0x40 };
|
|
|
|
|
2018-05-30 16:43:43 +08:00
|
|
|
/*
|
|
|
|
* BUCK6
|
|
|
|
* 3.0V to 3.3V (step 100mV)
|
|
|
|
*/
|
2018-09-14 16:33:11 +08:00
|
|
|
static const struct regulator_linear_range bd71837_buck6_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2018-09-14 16:27:46 +08:00
|
|
|
* BD71837 BUCK7
|
|
|
|
* BD71847 BUCK5
|
2018-05-30 16:43:43 +08:00
|
|
|
* 000 = 1.605V
|
|
|
|
* 001 = 1.695V
|
|
|
|
* 010 = 1.755V
|
|
|
|
* 011 = 1.8V (Initial)
|
|
|
|
* 100 = 1.845V
|
|
|
|
* 101 = 1.905V
|
|
|
|
* 110 = 1.95V
|
|
|
|
* 111 = 1.995V
|
|
|
|
*/
|
2018-09-14 16:27:46 +08:00
|
|
|
static const unsigned int bd718xx_3rd_nodvs_buck_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
1605000, 1695000, 1755000, 1800000, 1845000, 1905000, 1950000, 1995000
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BUCK8
|
|
|
|
* 0.8V to 1.40V (step 10mV)
|
|
|
|
*/
|
2018-09-14 16:27:46 +08:00
|
|
|
static const struct regulator_linear_range bd718xx_4th_nodvs_buck_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(800000, 0x00, 0x3C, 10000),
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* LDO1
|
|
|
|
* 3.0 to 3.3V (100mV step)
|
|
|
|
*/
|
2018-09-14 16:27:46 +08:00
|
|
|
static const struct regulator_linear_range bd718xx_ldo1_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
|
2018-09-14 16:33:11 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(1600000, 0x00, 0x03, 100000),
|
2018-05-30 16:43:43 +08:00
|
|
|
};
|
|
|
|
|
2018-09-14 16:33:11 +08:00
|
|
|
static const unsigned int bd718xx_ldo1_volt_range_sel[] = { 0x0, 0x20 };
|
|
|
|
|
2018-05-30 16:43:43 +08:00
|
|
|
/*
|
|
|
|
* LDO2
|
|
|
|
* 0.8 or 0.9V
|
|
|
|
*/
|
2018-06-27 20:40:13 +08:00
|
|
|
static const unsigned int ldo_2_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
900000, 800000
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* LDO3
|
|
|
|
* 1.8 to 3.3V (100mV step)
|
|
|
|
*/
|
2018-09-14 16:27:46 +08:00
|
|
|
static const struct regulator_linear_range bd718xx_ldo3_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* LDO4
|
|
|
|
* 0.9 to 1.8V (100mV step)
|
|
|
|
*/
|
2018-09-14 16:27:46 +08:00
|
|
|
static const struct regulator_linear_range bd718xx_ldo4_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2018-09-14 16:27:46 +08:00
|
|
|
* LDO5 for BD71837
|
2018-05-30 16:43:43 +08:00
|
|
|
* 1.8 to 3.3V (100mV step)
|
|
|
|
*/
|
2018-09-14 16:33:11 +08:00
|
|
|
static const struct regulator_linear_range bd71837_ldo5_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
|
|
|
|
};
|
|
|
|
|
2018-09-14 16:33:11 +08:00
|
|
|
/*
|
|
|
|
* LDO5 for BD71837
|
|
|
|
* 1.8 to 3.3V (100mV step)
|
|
|
|
*/
|
|
|
|
static const struct regulator_linear_range bd71847_ldo5_volts[] = {
|
|
|
|
REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
|
|
|
|
REGULATOR_LINEAR_RANGE(800000, 0x00, 0x0F, 100000),
|
|
|
|
};
|
|
|
|
|
|
|
|
static const unsigned int bd71847_ldo5_volt_range_sel[] = { 0x0, 0x20 };
|
|
|
|
|
2018-05-30 16:43:43 +08:00
|
|
|
/*
|
|
|
|
* LDO6
|
|
|
|
* 0.9 to 1.8V (100mV step)
|
|
|
|
*/
|
2018-09-14 16:27:46 +08:00
|
|
|
static const struct regulator_linear_range bd718xx_ldo6_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* LDO7
|
|
|
|
* 1.8 to 3.3V (100mV step)
|
|
|
|
*/
|
2018-09-14 16:27:46 +08:00
|
|
|
static const struct regulator_linear_range bd71837_ldo7_volts[] = {
|
2018-05-30 16:43:43 +08:00
|
|
|
REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
|
|
|
|
};
|
|
|
|
|
2018-09-14 16:27:46 +08:00
|
|
|
struct reg_init {
|
|
|
|
unsigned int reg;
|
|
|
|
unsigned int mask;
|
|
|
|
unsigned int val;
|
|
|
|
};
|
|
|
|
struct bd718xx_regulator_data {
|
|
|
|
struct regulator_desc desc;
|
|
|
|
const struct reg_init init;
|
|
|
|
const struct reg_init *additional_inits;
|
|
|
|
int additional_init_amnt;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There is a HW quirk in BD71837. The shutdown sequence timings for
|
|
|
|
* bucks/LDOs which are controlled via register interface are changed.
|
|
|
|
* At PMIC poweroff the voltage for BUCK6/7 is cut immediately at the
|
|
|
|
* beginning of shut-down sequence. As bucks 6 and 7 are parent
|
|
|
|
* supplies for LDO5 and LDO6 - this causes LDO5/6 voltage
|
|
|
|
* monitoring to errorneously detect under voltage and force PMIC to
|
|
|
|
* emergency state instead of poweroff. In order to avoid this we
|
|
|
|
* disable voltage monitoring for LDO5 and LDO6
|
|
|
|
*/
|
|
|
|
static const struct reg_init bd71837_ldo5_inits[] = {
|
|
|
|
{
|
|
|
|
.reg = BD718XX_REG_MVRFLTMASK2,
|
|
|
|
.mask = BD718XX_LDO5_VRMON80,
|
|
|
|
.val = BD718XX_LDO5_VRMON80,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct reg_init bd71837_ldo6_inits[] = {
|
|
|
|
{
|
|
|
|
.reg = BD718XX_REG_MVRFLTMASK2,
|
|
|
|
.mask = BD718XX_LDO6_VRMON80,
|
|
|
|
.val = BD718XX_LDO6_VRMON80,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-02-14 17:39:36 +08:00
|
|
|
#define NUM_DVS_BUCKS 4
|
|
|
|
|
|
|
|
struct of_dvs_setting {
|
|
|
|
const char *prop;
|
|
|
|
unsigned int reg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int set_dvs_levels(const struct of_dvs_setting *dvs,
|
|
|
|
struct device_node *np,
|
|
|
|
const struct regulator_desc *desc,
|
|
|
|
struct regmap *regmap)
|
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
unsigned int uv;
|
|
|
|
|
|
|
|
ret = of_property_read_u32(np, dvs->prop, &uv);
|
|
|
|
if (ret) {
|
|
|
|
if (ret != -EINVAL)
|
|
|
|
return ret;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < desc->n_voltages; i++) {
|
|
|
|
ret = regulator_desc_list_voltage_linear_range(desc, i);
|
|
|
|
if (ret < 0)
|
|
|
|
continue;
|
|
|
|
if (ret == uv) {
|
|
|
|
i <<= ffs(desc->vsel_mask) - 1;
|
|
|
|
ret = regmap_update_bits(regmap, dvs->reg,
|
|
|
|
DVS_BUCK_RUN_MASK, i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int buck4_set_hw_dvs_levels(struct device_node *np,
|
|
|
|
const struct regulator_desc *desc,
|
|
|
|
struct regulator_config *cfg)
|
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
const struct of_dvs_setting dvs[] = {
|
|
|
|
{
|
|
|
|
.prop = "rohm,dvs-run-voltage",
|
|
|
|
.reg = BD71837_REG_BUCK4_VOLT_RUN,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dvs); i++) {
|
|
|
|
ret = set_dvs_levels(&dvs[i], np, desc, cfg->regmap);
|
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
static int buck3_set_hw_dvs_levels(struct device_node *np,
|
|
|
|
const struct regulator_desc *desc,
|
|
|
|
struct regulator_config *cfg)
|
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
const struct of_dvs_setting dvs[] = {
|
|
|
|
{
|
|
|
|
.prop = "rohm,dvs-run-voltage",
|
|
|
|
.reg = BD71837_REG_BUCK3_VOLT_RUN,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dvs); i++) {
|
|
|
|
ret = set_dvs_levels(&dvs[i], np, desc, cfg->regmap);
|
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int buck2_set_hw_dvs_levels(struct device_node *np,
|
|
|
|
const struct regulator_desc *desc,
|
|
|
|
struct regulator_config *cfg)
|
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
const struct of_dvs_setting dvs[] = {
|
|
|
|
{
|
|
|
|
.prop = "rohm,dvs-run-voltage",
|
|
|
|
.reg = BD718XX_REG_BUCK2_VOLT_RUN,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.prop = "rohm,dvs-idle-voltage",
|
|
|
|
.reg = BD718XX_REG_BUCK2_VOLT_IDLE,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dvs); i++) {
|
|
|
|
ret = set_dvs_levels(&dvs[i], np, desc, cfg->regmap);
|
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int buck1_set_hw_dvs_levels(struct device_node *np,
|
|
|
|
const struct regulator_desc *desc,
|
|
|
|
struct regulator_config *cfg)
|
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
const struct of_dvs_setting dvs[] = {
|
|
|
|
{
|
|
|
|
.prop = "rohm,dvs-run-voltage",
|
|
|
|
.reg = BD718XX_REG_BUCK1_VOLT_RUN,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.prop = "rohm,dvs-idle-voltage",
|
|
|
|
.reg = BD718XX_REG_BUCK1_VOLT_IDLE,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.prop = "rohm,dvs-suspend-voltage",
|
|
|
|
.reg = BD718XX_REG_BUCK1_VOLT_SUSP,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dvs); i++) {
|
|
|
|
ret = set_dvs_levels(&dvs[i], np, desc, cfg->regmap);
|
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-09-14 16:27:46 +08:00
|
|
|
static const struct bd718xx_regulator_data bd71847_regulators[] = {
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "buck1",
|
|
|
|
.of_match = of_match_ptr("BUCK1"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK1,
|
|
|
|
.ops = &bd718xx_dvs_buck_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_dvs_buck_volts,
|
|
|
|
.n_linear_ranges =
|
|
|
|
ARRAY_SIZE(bd718xx_dvs_buck_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_BUCK1_VOLT_RUN,
|
|
|
|
.vsel_mask = DVS_BUCK_RUN_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_BUCK1_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
2019-02-14 17:39:36 +08:00
|
|
|
.of_parse_cb = buck1_set_hw_dvs_levels,
|
2018-09-14 16:27:46 +08:00
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_BUCK1_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "buck2",
|
|
|
|
.of_match = of_match_ptr("BUCK2"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK2,
|
|
|
|
.ops = &bd718xx_dvs_buck_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_dvs_buck_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_BUCK2_VOLT_RUN,
|
|
|
|
.vsel_mask = DVS_BUCK_RUN_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_BUCK2_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
2019-02-14 17:39:36 +08:00
|
|
|
.of_parse_cb = buck2_set_hw_dvs_levels,
|
2018-09-14 16:27:46 +08:00
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_BUCK2_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "buck3",
|
|
|
|
.of_match = of_match_ptr("BUCK3"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK3,
|
2018-09-14 16:33:11 +08:00
|
|
|
.ops = &bd718xx_pickable_range_buck_ops,
|
2018-09-14 16:27:46 +08:00
|
|
|
.type = REGULATOR_VOLTAGE,
|
2018-09-14 16:33:11 +08:00
|
|
|
.n_voltages = BD71847_BUCK3_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd71847_buck3_volts,
|
2018-09-14 16:27:46 +08:00
|
|
|
.n_linear_ranges =
|
2018-09-14 16:33:11 +08:00
|
|
|
ARRAY_SIZE(bd71847_buck3_volts),
|
2018-09-14 16:27:46 +08:00
|
|
|
.vsel_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
|
|
|
|
.vsel_mask = BD718XX_1ST_NODVS_BUCK_MASK,
|
2018-09-14 16:33:11 +08:00
|
|
|
.vsel_range_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
|
|
|
|
.vsel_range_mask = BD71847_BUCK3_RANGE_MASK,
|
|
|
|
.linear_range_selectors = bd71847_buck3_volt_range_sel,
|
2018-09-14 16:27:46 +08:00
|
|
|
.enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "buck4",
|
|
|
|
.of_match = of_match_ptr("BUCK4"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK4,
|
2018-09-14 16:33:11 +08:00
|
|
|
.ops = &bd718xx_pickable_range_buck_ops,
|
2018-09-14 16:27:46 +08:00
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD71847_BUCK4_VOLTAGE_NUM,
|
2018-09-14 16:33:11 +08:00
|
|
|
.linear_ranges = bd71847_buck4_volts,
|
2018-09-14 16:27:46 +08:00
|
|
|
.n_linear_ranges =
|
2018-09-14 16:33:11 +08:00
|
|
|
ARRAY_SIZE(bd71847_buck4_volts),
|
2018-09-14 16:27:46 +08:00
|
|
|
.enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
|
|
|
|
.vsel_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
|
|
|
|
.vsel_mask = BD71847_BUCK4_MASK,
|
2018-09-14 16:33:11 +08:00
|
|
|
.vsel_range_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
|
|
|
|
.vsel_range_mask = BD71847_BUCK4_RANGE_MASK,
|
|
|
|
.linear_range_selectors = bd71847_buck4_volt_range_sel,
|
2018-09-14 16:27:46 +08:00
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "buck5",
|
|
|
|
.of_match = of_match_ptr("BUCK5"),
|
2018-09-14 16:32:26 +08:00
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
2018-09-14 16:27:46 +08:00
|
|
|
.id = BD718XX_BUCK5,
|
|
|
|
.ops = &bd718xx_buck_regulator_nolinear_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.volt_table = &bd718xx_3rd_nodvs_buck_volts[0],
|
|
|
|
.n_voltages = ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_3RD_NODVS_BUCK_VOLT,
|
|
|
|
.vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "buck6",
|
|
|
|
.of_match = of_match_ptr("BUCK6"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK6,
|
|
|
|
.ops = &bd718xx_buck_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
2018-09-14 16:32:26 +08:00
|
|
|
.n_voltages = BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM,
|
2018-09-14 16:27:46 +08:00
|
|
|
.linear_ranges = bd718xx_4th_nodvs_buck_volts,
|
|
|
|
.n_linear_ranges =
|
|
|
|
ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_4TH_NODVS_BUCK_VOLT,
|
|
|
|
.vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "ldo1",
|
|
|
|
.of_match = of_match_ptr("LDO1"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO1,
|
2018-09-14 16:33:11 +08:00
|
|
|
.ops = &bd718xx_pickable_range_ldo_ops,
|
2018-09-14 16:27:46 +08:00
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_LDO1_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_ldo1_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo1_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_LDO1_VOLT,
|
|
|
|
.vsel_mask = BD718XX_LDO1_MASK,
|
2018-09-14 16:33:11 +08:00
|
|
|
.vsel_range_reg = BD718XX_REG_LDO1_VOLT,
|
|
|
|
.vsel_range_mask = BD718XX_LDO1_RANGE_MASK,
|
|
|
|
.linear_range_selectors = bd718xx_ldo1_volt_range_sel,
|
2018-09-14 16:27:46 +08:00
|
|
|
.enable_reg = BD718XX_REG_LDO1_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO1_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "ldo2",
|
|
|
|
.of_match = of_match_ptr("LDO2"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO2,
|
|
|
|
.ops = &bd718xx_ldo_regulator_nolinear_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.volt_table = &ldo_2_volts[0],
|
|
|
|
.vsel_reg = BD718XX_REG_LDO2_VOLT,
|
|
|
|
.vsel_mask = BD718XX_LDO2_MASK,
|
|
|
|
.n_voltages = ARRAY_SIZE(ldo_2_volts),
|
|
|
|
.enable_reg = BD718XX_REG_LDO2_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO2_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "ldo3",
|
|
|
|
.of_match = of_match_ptr("LDO3"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO3,
|
|
|
|
.ops = &bd718xx_ldo_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_LDO3_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_ldo3_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo3_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_LDO3_VOLT,
|
|
|
|
.vsel_mask = BD718XX_LDO3_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_LDO3_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO3_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "ldo4",
|
|
|
|
.of_match = of_match_ptr("LDO4"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO4,
|
|
|
|
.ops = &bd718xx_ldo_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_LDO4_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_ldo4_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo4_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_LDO4_VOLT,
|
|
|
|
.vsel_mask = BD718XX_LDO4_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_LDO4_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO4_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "ldo5",
|
|
|
|
.of_match = of_match_ptr("LDO5"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO5,
|
2018-09-14 16:33:11 +08:00
|
|
|
.ops = &bd718xx_pickable_range_ldo_ops,
|
2018-09-14 16:27:46 +08:00
|
|
|
.type = REGULATOR_VOLTAGE,
|
2018-09-14 16:33:11 +08:00
|
|
|
.n_voltages = BD71847_LDO5_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd71847_ldo5_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd71847_ldo5_volts),
|
2018-09-14 16:27:46 +08:00
|
|
|
.vsel_reg = BD718XX_REG_LDO5_VOLT,
|
|
|
|
.vsel_mask = BD71847_LDO5_MASK,
|
2018-09-14 16:33:11 +08:00
|
|
|
.vsel_range_reg = BD718XX_REG_LDO5_VOLT,
|
|
|
|
.vsel_range_mask = BD71847_LDO5_RANGE_MASK,
|
|
|
|
.linear_range_selectors = bd71847_ldo5_volt_range_sel,
|
2018-09-14 16:27:46 +08:00
|
|
|
.enable_reg = BD718XX_REG_LDO5_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO5_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "ldo6",
|
|
|
|
.of_match = of_match_ptr("LDO6"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO6,
|
|
|
|
.ops = &bd718xx_ldo_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_LDO6_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_ldo6_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo6_volts),
|
|
|
|
/* LDO6 is supplied by buck5 */
|
|
|
|
.supply_name = "buck5",
|
|
|
|
.vsel_reg = BD718XX_REG_LDO6_VOLT,
|
|
|
|
.vsel_mask = BD718XX_LDO6_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_LDO6_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO6_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct bd718xx_regulator_data bd71837_regulators[] = {
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "buck1",
|
|
|
|
.of_match = of_match_ptr("BUCK1"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK1,
|
|
|
|
.ops = &bd718xx_dvs_buck_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_dvs_buck_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_BUCK1_VOLT_RUN,
|
|
|
|
.vsel_mask = DVS_BUCK_RUN_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_BUCK1_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
2019-02-14 17:39:36 +08:00
|
|
|
.of_parse_cb = buck1_set_hw_dvs_levels,
|
2018-09-14 16:27:46 +08:00
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_BUCK1_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "buck2",
|
|
|
|
.of_match = of_match_ptr("BUCK2"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK2,
|
|
|
|
.ops = &bd718xx_dvs_buck_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_dvs_buck_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_BUCK2_VOLT_RUN,
|
|
|
|
.vsel_mask = DVS_BUCK_RUN_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_BUCK2_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
2019-02-14 17:39:36 +08:00
|
|
|
.of_parse_cb = buck2_set_hw_dvs_levels,
|
2018-09-14 16:27:46 +08:00
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_BUCK2_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "buck3",
|
|
|
|
.of_match = of_match_ptr("BUCK3"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK3,
|
|
|
|
.ops = &bd718xx_dvs_buck_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_dvs_buck_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
|
|
|
|
.vsel_reg = BD71837_REG_BUCK3_VOLT_RUN,
|
|
|
|
.vsel_mask = DVS_BUCK_RUN_MASK,
|
|
|
|
.enable_reg = BD71837_REG_BUCK3_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
2019-02-14 17:39:36 +08:00
|
|
|
.of_parse_cb = buck3_set_hw_dvs_levels,
|
2018-09-14 16:27:46 +08:00
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD71837_REG_BUCK3_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "buck4",
|
|
|
|
.of_match = of_match_ptr("BUCK4"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK4,
|
|
|
|
.ops = &bd718xx_dvs_buck_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_dvs_buck_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
|
|
|
|
.vsel_reg = BD71837_REG_BUCK4_VOLT_RUN,
|
|
|
|
.vsel_mask = DVS_BUCK_RUN_MASK,
|
|
|
|
.enable_reg = BD71837_REG_BUCK4_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
2019-02-14 17:39:36 +08:00
|
|
|
.of_parse_cb = buck4_set_hw_dvs_levels,
|
2018-09-14 16:27:46 +08:00
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD71837_REG_BUCK4_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "buck5",
|
|
|
|
.of_match = of_match_ptr("BUCK5"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK5,
|
2018-09-14 16:33:11 +08:00
|
|
|
.ops = &bd718xx_pickable_range_buck_ops,
|
2018-09-14 16:27:46 +08:00
|
|
|
.type = REGULATOR_VOLTAGE,
|
2018-09-14 16:33:11 +08:00
|
|
|
.n_voltages = BD71837_BUCK5_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd71837_buck5_volts,
|
2018-09-14 16:27:46 +08:00
|
|
|
.n_linear_ranges =
|
2018-09-14 16:33:11 +08:00
|
|
|
ARRAY_SIZE(bd71837_buck5_volts),
|
2018-09-14 16:27:46 +08:00
|
|
|
.vsel_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
|
2018-09-14 16:33:11 +08:00
|
|
|
.vsel_mask = BD71837_BUCK5_MASK,
|
|
|
|
.vsel_range_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
|
|
|
|
.vsel_range_mask = BD71837_BUCK5_RANGE_MASK,
|
|
|
|
.linear_range_selectors = bd71837_buck5_volt_range_sel,
|
2018-09-14 16:27:46 +08:00
|
|
|
.enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "buck6",
|
|
|
|
.of_match = of_match_ptr("BUCK6"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK6,
|
|
|
|
.ops = &bd718xx_buck_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD71837_BUCK6_VOLTAGE_NUM,
|
2018-09-14 16:33:11 +08:00
|
|
|
.linear_ranges = bd71837_buck6_volts,
|
2018-09-14 16:27:46 +08:00
|
|
|
.n_linear_ranges =
|
2018-09-14 16:33:11 +08:00
|
|
|
ARRAY_SIZE(bd71837_buck6_volts),
|
2018-09-14 16:27:46 +08:00
|
|
|
.vsel_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
|
|
|
|
.vsel_mask = BD71837_BUCK6_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "buck7",
|
|
|
|
.of_match = of_match_ptr("BUCK7"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK7,
|
|
|
|
.ops = &bd718xx_buck_regulator_nolinear_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.volt_table = &bd718xx_3rd_nodvs_buck_volts[0],
|
|
|
|
.n_voltages = ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_3RD_NODVS_BUCK_VOLT,
|
|
|
|
.vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
{
|
2018-09-14 16:27:46 +08:00
|
|
|
.desc = {
|
|
|
|
.name = "buck8",
|
|
|
|
.of_match = of_match_ptr("BUCK8"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_BUCK8,
|
|
|
|
.ops = &bd718xx_buck_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
2018-09-14 16:32:26 +08:00
|
|
|
.n_voltages = BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM,
|
2018-09-14 16:27:46 +08:00
|
|
|
.linear_ranges = bd718xx_4th_nodvs_buck_volts,
|
|
|
|
.n_linear_ranges =
|
|
|
|
ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_4TH_NODVS_BUCK_VOLT,
|
|
|
|
.vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
|
|
|
|
.enable_mask = BD718XX_BUCK_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
|
|
|
|
.mask = BD718XX_BUCK_SEL,
|
|
|
|
.val = BD718XX_BUCK_SEL,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "ldo1",
|
|
|
|
.of_match = of_match_ptr("LDO1"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO1,
|
2018-09-14 16:33:11 +08:00
|
|
|
.ops = &bd718xx_pickable_range_ldo_ops,
|
2018-09-14 16:27:46 +08:00
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_LDO1_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_ldo1_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo1_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_LDO1_VOLT,
|
|
|
|
.vsel_mask = BD718XX_LDO1_MASK,
|
2018-09-14 16:33:11 +08:00
|
|
|
.vsel_range_reg = BD718XX_REG_LDO1_VOLT,
|
|
|
|
.vsel_range_mask = BD718XX_LDO1_RANGE_MASK,
|
|
|
|
.linear_range_selectors = bd718xx_ldo1_volt_range_sel,
|
2018-09-14 16:27:46 +08:00
|
|
|
.enable_reg = BD718XX_REG_LDO1_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO1_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "ldo2",
|
|
|
|
.of_match = of_match_ptr("LDO2"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO2,
|
|
|
|
.ops = &bd718xx_ldo_regulator_nolinear_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.volt_table = &ldo_2_volts[0],
|
|
|
|
.vsel_reg = BD718XX_REG_LDO2_VOLT,
|
|
|
|
.vsel_mask = BD718XX_LDO2_MASK,
|
|
|
|
.n_voltages = ARRAY_SIZE(ldo_2_volts),
|
|
|
|
.enable_reg = BD718XX_REG_LDO2_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO2_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "ldo3",
|
|
|
|
.of_match = of_match_ptr("LDO3"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO3,
|
|
|
|
.ops = &bd718xx_ldo_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_LDO3_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_ldo3_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo3_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_LDO3_VOLT,
|
|
|
|
.vsel_mask = BD718XX_LDO3_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_LDO3_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO3_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "ldo4",
|
|
|
|
.of_match = of_match_ptr("LDO4"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO4,
|
|
|
|
.ops = &bd718xx_ldo_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_LDO4_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_ldo4_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo4_volts),
|
|
|
|
.vsel_reg = BD718XX_REG_LDO4_VOLT,
|
|
|
|
.vsel_mask = BD718XX_LDO4_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_LDO4_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO4_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "ldo5",
|
|
|
|
.of_match = of_match_ptr("LDO5"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO5,
|
|
|
|
.ops = &bd718xx_ldo_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
2018-09-14 16:33:11 +08:00
|
|
|
.n_voltages = BD71837_LDO5_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd71837_ldo5_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd71837_ldo5_volts),
|
2018-09-14 16:27:46 +08:00
|
|
|
/* LDO5 is supplied by buck6 */
|
|
|
|
.supply_name = "buck6",
|
|
|
|
.vsel_reg = BD718XX_REG_LDO5_VOLT,
|
|
|
|
.vsel_mask = BD71837_LDO5_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_LDO5_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO5_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
|
|
|
.additional_inits = bd71837_ldo5_inits,
|
|
|
|
.additional_init_amnt = ARRAY_SIZE(bd71837_ldo5_inits),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "ldo6",
|
|
|
|
.of_match = of_match_ptr("LDO6"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO6,
|
|
|
|
.ops = &bd718xx_ldo_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD718XX_LDO6_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd718xx_ldo6_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd718xx_ldo6_volts),
|
|
|
|
/* LDO6 is supplied by buck7 */
|
|
|
|
.supply_name = "buck7",
|
|
|
|
.vsel_reg = BD718XX_REG_LDO6_VOLT,
|
|
|
|
.vsel_mask = BD718XX_LDO6_MASK,
|
|
|
|
.enable_reg = BD718XX_REG_LDO6_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD718XX_REG_LDO6_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
|
|
|
.additional_inits = bd71837_ldo6_inits,
|
|
|
|
.additional_init_amnt = ARRAY_SIZE(bd71837_ldo6_inits),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.desc = {
|
|
|
|
.name = "ldo7",
|
|
|
|
.of_match = of_match_ptr("LDO7"),
|
|
|
|
.regulators_node = of_match_ptr("regulators"),
|
|
|
|
.id = BD718XX_LDO7,
|
|
|
|
.ops = &bd718xx_ldo_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.n_voltages = BD71837_LDO7_VOLTAGE_NUM,
|
|
|
|
.linear_ranges = bd71837_ldo7_volts,
|
|
|
|
.n_linear_ranges = ARRAY_SIZE(bd71837_ldo7_volts),
|
|
|
|
.vsel_reg = BD71837_REG_LDO7_VOLT,
|
|
|
|
.vsel_mask = BD71837_LDO7_MASK,
|
|
|
|
.enable_reg = BD71837_REG_LDO7_VOLT,
|
|
|
|
.enable_mask = BD718XX_LDO_EN,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.init = {
|
|
|
|
.reg = BD71837_REG_LDO7_VOLT,
|
|
|
|
.mask = BD718XX_LDO_SEL,
|
|
|
|
.val = BD718XX_LDO_SEL,
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-09-14 16:27:46 +08:00
|
|
|
struct bd718xx_pmic_inits {
|
2018-10-29 00:09:22 +08:00
|
|
|
const struct bd718xx_regulator_data *r_datas;
|
2018-09-14 16:27:46 +08:00
|
|
|
unsigned int r_amount;
|
2018-05-30 16:43:43 +08:00
|
|
|
};
|
|
|
|
|
2018-09-14 16:32:26 +08:00
|
|
|
static int bd718xx_probe(struct platform_device *pdev)
|
2018-05-30 16:43:43 +08:00
|
|
|
{
|
2018-10-04 15:25:58 +08:00
|
|
|
struct bd718xx *mfd;
|
2018-05-30 16:43:43 +08:00
|
|
|
struct regulator_config config = { 0 };
|
2019-06-03 15:24:32 +08:00
|
|
|
struct bd718xx_pmic_inits pmic_regulators[ROHM_CHIP_TYPE_AMOUNT] = {
|
|
|
|
[ROHM_CHIP_TYPE_BD71837] = {
|
2018-10-29 00:09:22 +08:00
|
|
|
.r_datas = bd71837_regulators,
|
2018-09-14 16:27:46 +08:00
|
|
|
.r_amount = ARRAY_SIZE(bd71837_regulators),
|
|
|
|
},
|
2019-06-03 15:24:32 +08:00
|
|
|
[ROHM_CHIP_TYPE_BD71847] = {
|
2018-10-29 00:09:22 +08:00
|
|
|
.r_datas = bd71847_regulators,
|
2018-09-14 16:27:46 +08:00
|
|
|
.r_amount = ARRAY_SIZE(bd71847_regulators),
|
|
|
|
},
|
2018-05-30 16:43:43 +08:00
|
|
|
};
|
|
|
|
|
2018-09-14 16:27:46 +08:00
|
|
|
int i, j, err;
|
2019-02-14 17:39:36 +08:00
|
|
|
bool use_snvs;
|
2018-05-30 16:43:43 +08:00
|
|
|
|
2018-10-04 15:25:58 +08:00
|
|
|
mfd = dev_get_drvdata(pdev->dev.parent);
|
|
|
|
if (!mfd) {
|
2018-05-30 16:43:43 +08:00
|
|
|
dev_err(&pdev->dev, "No MFD driver data\n");
|
|
|
|
err = -EINVAL;
|
|
|
|
goto err;
|
|
|
|
}
|
2018-10-04 15:25:58 +08:00
|
|
|
|
2019-06-03 15:24:32 +08:00
|
|
|
if (mfd->chip.chip_type >= ROHM_CHIP_TYPE_AMOUNT ||
|
|
|
|
!pmic_regulators[mfd->chip.chip_type].r_datas) {
|
2018-09-14 16:27:46 +08:00
|
|
|
dev_err(&pdev->dev, "Unsupported chip type\n");
|
|
|
|
err = -EINVAL;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2018-05-30 16:43:43 +08:00
|
|
|
/* Register LOCK release */
|
2019-06-03 15:24:32 +08:00
|
|
|
err = regmap_update_bits(mfd->chip.regmap, BD718XX_REG_REGLOCK,
|
2018-05-30 16:43:43 +08:00
|
|
|
(REGLOCK_PWRSEQ | REGLOCK_VREG), 0);
|
|
|
|
if (err) {
|
2018-10-04 15:25:58 +08:00
|
|
|
dev_err(&pdev->dev, "Failed to unlock PMIC (%d)\n", err);
|
2018-05-30 16:43:43 +08:00
|
|
|
goto err;
|
|
|
|
} else {
|
2018-10-04 15:25:58 +08:00
|
|
|
dev_dbg(&pdev->dev, "Unlocked lock register 0x%x\n",
|
2018-09-14 16:27:46 +08:00
|
|
|
BD718XX_REG_REGLOCK);
|
2018-08-29 20:36:10 +08:00
|
|
|
}
|
|
|
|
|
2019-02-14 17:39:36 +08:00
|
|
|
use_snvs = of_property_read_bool(pdev->dev.parent->of_node,
|
|
|
|
"rohm,reset-snvs-powered");
|
|
|
|
|
|
|
|
/*
|
2018-11-07 21:41:26 +08:00
|
|
|
* Change the next stage from poweroff to be READY instead of SNVS
|
|
|
|
* for all reset types because OTP loading at READY will clear SEL
|
|
|
|
* bit allowing HW defaults for power rails to be used
|
|
|
|
*/
|
2019-02-14 17:39:36 +08:00
|
|
|
if (!use_snvs) {
|
2019-06-03 15:24:32 +08:00
|
|
|
err = regmap_update_bits(mfd->chip.regmap,
|
|
|
|
BD718XX_REG_TRANS_COND1,
|
2019-02-14 17:39:36 +08:00
|
|
|
BD718XX_ON_REQ_POWEROFF_MASK |
|
|
|
|
BD718XX_SWRESET_POWEROFF_MASK |
|
|
|
|
BD718XX_WDOG_POWEROFF_MASK |
|
|
|
|
BD718XX_KEY_L_POWEROFF_MASK,
|
|
|
|
BD718XX_POWOFF_TO_RDY);
|
|
|
|
if (err) {
|
|
|
|
dev_err(&pdev->dev, "Failed to change reset target\n");
|
|
|
|
goto err;
|
|
|
|
} else {
|
|
|
|
dev_dbg(&pdev->dev,
|
|
|
|
"Changed all resets from SVNS to READY\n");
|
|
|
|
}
|
2018-11-07 21:41:26 +08:00
|
|
|
}
|
|
|
|
|
2019-06-03 15:24:32 +08:00
|
|
|
for (i = 0; i < pmic_regulators[mfd->chip.chip_type].r_amount; i++) {
|
2018-05-30 16:43:43 +08:00
|
|
|
|
2018-09-14 16:27:46 +08:00
|
|
|
const struct regulator_desc *desc;
|
2018-05-30 16:43:43 +08:00
|
|
|
struct regulator_dev *rdev;
|
2018-09-14 16:27:46 +08:00
|
|
|
const struct bd718xx_regulator_data *r;
|
2018-05-30 16:43:43 +08:00
|
|
|
|
2019-06-03 15:24:32 +08:00
|
|
|
r = &pmic_regulators[mfd->chip.chip_type].r_datas[i];
|
2018-09-14 16:27:46 +08:00
|
|
|
desc = &r->desc;
|
2018-05-30 16:43:43 +08:00
|
|
|
|
|
|
|
config.dev = pdev->dev.parent;
|
2019-06-03 15:24:32 +08:00
|
|
|
config.regmap = mfd->chip.regmap;
|
2018-05-30 16:43:43 +08:00
|
|
|
|
|
|
|
rdev = devm_regulator_register(&pdev->dev, desc, &config);
|
|
|
|
if (IS_ERR(rdev)) {
|
2018-10-04 15:25:58 +08:00
|
|
|
dev_err(&pdev->dev,
|
2018-05-30 16:43:43 +08:00
|
|
|
"failed to register %s regulator\n",
|
|
|
|
desc->name);
|
|
|
|
err = PTR_ERR(rdev);
|
|
|
|
goto err;
|
|
|
|
}
|
2019-02-14 17:39:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Regulator register gets the regulator constraints and
|
2018-05-30 16:43:43 +08:00
|
|
|
* applies them (set_machine_constraints). This should have
|
|
|
|
* turned the control register(s) to correct values and we
|
|
|
|
* can now switch the control from PMIC state machine to the
|
|
|
|
* register interface
|
2019-02-14 17:39:36 +08:00
|
|
|
*
|
|
|
|
* At poweroff transition PMIC HW disables EN bit for
|
|
|
|
* regulators but leaves SEL bit untouched. So if state
|
|
|
|
* transition from POWEROFF is done to SNVS - then all power
|
|
|
|
* rails controlled by SW (having SEL bit set) stay disabled
|
|
|
|
* as EN is cleared. This will result boot failure if any
|
|
|
|
* crucial systems are powered by these rails. We don't
|
|
|
|
* enable SW control for crucial regulators if snvs state is
|
|
|
|
* used
|
2018-05-30 16:43:43 +08:00
|
|
|
*/
|
2019-02-14 17:39:36 +08:00
|
|
|
if (!use_snvs || !rdev->constraints->always_on ||
|
|
|
|
!rdev->constraints->boot_on) {
|
2019-06-03 15:24:32 +08:00
|
|
|
err = regmap_update_bits(mfd->chip.regmap, r->init.reg,
|
2019-02-14 17:39:36 +08:00
|
|
|
r->init.mask, r->init.val);
|
|
|
|
if (err) {
|
|
|
|
dev_err(&pdev->dev,
|
|
|
|
"Failed to take control for (%s)\n",
|
|
|
|
desc->name);
|
|
|
|
goto err;
|
|
|
|
}
|
2018-05-30 16:43:43 +08:00
|
|
|
}
|
2018-09-14 16:27:46 +08:00
|
|
|
for (j = 0; j < r->additional_init_amnt; j++) {
|
2019-06-03 15:24:32 +08:00
|
|
|
err = regmap_update_bits(mfd->chip.regmap,
|
2018-09-14 16:27:46 +08:00
|
|
|
r->additional_inits[j].reg,
|
|
|
|
r->additional_inits[j].mask,
|
|
|
|
r->additional_inits[j].val);
|
|
|
|
if (err) {
|
2018-10-04 15:25:58 +08:00
|
|
|
dev_err(&pdev->dev,
|
2018-09-14 16:27:46 +08:00
|
|
|
"Buck (%s) initialization failed\n",
|
|
|
|
desc->name);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
2018-05-30 16:43:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
err:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2018-09-14 16:32:26 +08:00
|
|
|
static struct platform_driver bd718xx_regulator = {
|
2018-05-30 16:43:43 +08:00
|
|
|
.driver = {
|
2018-09-14 16:27:46 +08:00
|
|
|
.name = "bd718xx-pmic",
|
2018-05-30 16:43:43 +08:00
|
|
|
},
|
2018-09-14 16:32:26 +08:00
|
|
|
.probe = bd718xx_probe,
|
2018-05-30 16:43:43 +08:00
|
|
|
};
|
|
|
|
|
2018-09-14 16:32:26 +08:00
|
|
|
module_platform_driver(bd718xx_regulator);
|
2018-05-30 16:43:43 +08:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
|
2018-09-14 16:32:26 +08:00
|
|
|
MODULE_DESCRIPTION("BD71837/BD71847 voltage regulator driver");
|
2018-05-30 16:43:43 +08:00
|
|
|
MODULE_LICENSE("GPL");
|
2019-10-01 04:26:00 +08:00
|
|
|
MODULE_ALIAS("platform:bd718xx-pmic");
|