Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f1aa350 authored by Mark Brown's avatar Mark Brown
Browse files

Merge remote-tracking branches 'regulator/topic/mt6397', 'regulator/topic/of',...

Merge remote-tracking branches 'regulator/topic/mt6397', 'regulator/topic/of', 'regulator/topic/pfuze100', 'regulator/topic/pwm' and 'regulator/topic/qcom-smd' into regulator-next
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -38,13 +38,18 @@ NB: To be clear, if voltage-table is provided, then the device will be used
in Voltage Table Mode.  If no voltage-table is provided, then the device will
in Voltage Table Mode.  If no voltage-table is provided, then the device will
be used in Continuous Voltage Mode.
be used in Continuous Voltage Mode.


Optional properties:
--------------------
- enable-gpios:		GPIO to use to enable/disable the regulator

Any property defined as part of the core regulator binding can also be used.
Any property defined as part of the core regulator binding can also be used.
(See: ../regulator/regulator.txt)
(See: ../regulator/regulator.txt)


Continuous Voltage Example:
Continuous Voltage With Enable GPIO Example:
	pwm_regulator {
	pwm_regulator {
		compatible = "pwm-regulator;
		compatible = "pwm-regulator;
		pwms = <&pwm1 0 8448 0>;
		pwms = <&pwm1 0 8448 0>;
		enable-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;
		regulator-min-microvolt = <1016000>;
		regulator-min-microvolt = <1016000>;
		regulator-max-microvolt = <1114000>;
		regulator-max-microvolt = <1114000>;
		regulator-name = "vdd_logic";
		regulator-name = "vdd_logic";
+2 −2
Original line number Original line Diff line number Diff line
@@ -552,12 +552,12 @@ config REGULATOR_PCF50633
	 on PCF50633
	 on PCF50633


config REGULATOR_PFUZE100
config REGULATOR_PFUZE100
	tristate "Freescale PFUZE100/PFUZE200 regulator driver"
	tristate "Freescale PFUZE100/200/3000 regulator driver"
	depends on I2C
	depends on I2C
	select REGMAP_I2C
	select REGMAP_I2C
	help
	help
	  Say y here to support the regulators found on the Freescale
	  Say y here to support the regulators found on the Freescale
	  PFUZE100/PFUZE200 PMIC.
	  PFUZE100/200/3000 PMIC.


config REGULATOR_PV88060
config REGULATOR_PV88060
	tristate "Powerventure Semiconductor PV88060 regulator"
	tristate "Powerventure Semiconductor PV88060 regulator"
+83 −12
Original line number Original line Diff line number Diff line
@@ -23,6 +23,9 @@
#include <linux/regulator/mt6397-regulator.h>
#include <linux/regulator/mt6397-regulator.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/of_regulator.h>


#define MT6397_BUCK_MODE_AUTO	0
#define MT6397_BUCK_MODE_FORCE_PWM	1

/*
/*
 * MT6397 regulators' information
 * MT6397 regulators' information
 *
 *
@@ -38,10 +41,14 @@ struct mt6397_regulator_info {
	u32 vselon_reg;
	u32 vselon_reg;
	u32 vselctrl_reg;
	u32 vselctrl_reg;
	u32 vselctrl_mask;
	u32 vselctrl_mask;
	u32 modeset_reg;
	u32 modeset_mask;
	u32 modeset_shift;
};
};


#define MT6397_BUCK(match, vreg, min, max, step, volt_ranges, enreg,	\
#define MT6397_BUCK(match, vreg, min, max, step, volt_ranges, enreg,	\
		vosel, vosel_mask, voselon, vosel_ctrl)			\
		vosel, vosel_mask, voselon, vosel_ctrl, _modeset_reg,	\
		_modeset_shift)					\
[MT6397_ID_##vreg] = {							\
[MT6397_ID_##vreg] = {							\
	.desc = {							\
	.desc = {							\
		.name = #vreg,						\
		.name = #vreg,						\
@@ -62,6 +69,9 @@ struct mt6397_regulator_info {
	.vselon_reg = voselon,						\
	.vselon_reg = voselon,						\
	.vselctrl_reg = vosel_ctrl,					\
	.vselctrl_reg = vosel_ctrl,					\
	.vselctrl_mask = BIT(1),					\
	.vselctrl_mask = BIT(1),					\
	.modeset_reg = _modeset_reg,					\
	.modeset_mask = BIT(_modeset_shift),				\
	.modeset_shift = _modeset_shift					\
}
}


#define MT6397_LDO(match, vreg, ldo_volt_table, enreg, enbit, vosel,	\
#define MT6397_LDO(match, vreg, ldo_volt_table, enreg, enbit, vosel,	\
@@ -145,6 +155,63 @@ static const u32 ldo_volt_table7[] = {
	1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000,
	1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000,
};
};


static int mt6397_regulator_set_mode(struct regulator_dev *rdev,
				     unsigned int mode)
{
	struct mt6397_regulator_info *info = rdev_get_drvdata(rdev);
	int ret, val;

	switch (mode) {
	case REGULATOR_MODE_FAST:
		val = MT6397_BUCK_MODE_FORCE_PWM;
		break;
	case REGULATOR_MODE_NORMAL:
		val = MT6397_BUCK_MODE_AUTO;
		break;
	default:
		ret = -EINVAL;
		goto err_mode;
	}

	dev_dbg(&rdev->dev, "mt6397 buck set_mode %#x, %#x, %#x, %#x\n",
		info->modeset_reg, info->modeset_mask,
		info->modeset_shift, val);

	val <<= info->modeset_shift;
	ret = regmap_update_bits(rdev->regmap, info->modeset_reg,
				 info->modeset_mask, val);
err_mode:
	if (ret != 0) {
		dev_err(&rdev->dev,
			"Failed to set mt6397 buck mode: %d\n", ret);
		return ret;
	}

	return 0;
}

static unsigned int mt6397_regulator_get_mode(struct regulator_dev *rdev)
{
	struct mt6397_regulator_info *info = rdev_get_drvdata(rdev);
	int ret, regval;

	ret = regmap_read(rdev->regmap, info->modeset_reg, &regval);
	if (ret != 0) {
		dev_err(&rdev->dev,
			"Failed to get mt6397 buck mode: %d\n", ret);
		return ret;
	}

	switch ((regval & info->modeset_mask) >> info->modeset_shift) {
	case MT6397_BUCK_MODE_AUTO:
		return REGULATOR_MODE_NORMAL;
	case MT6397_BUCK_MODE_FORCE_PWM:
		return REGULATOR_MODE_FAST;
	default:
		return -EINVAL;
	}
}

static int mt6397_get_status(struct regulator_dev *rdev)
static int mt6397_get_status(struct regulator_dev *rdev)
{
{
	int ret;
	int ret;
@@ -160,7 +227,7 @@ static int mt6397_get_status(struct regulator_dev *rdev)
	return (regval & info->qi) ? REGULATOR_STATUS_ON : REGULATOR_STATUS_OFF;
	return (regval & info->qi) ? REGULATOR_STATUS_ON : REGULATOR_STATUS_OFF;
}
}


static struct regulator_ops mt6397_volt_range_ops = {
static const struct regulator_ops mt6397_volt_range_ops = {
	.list_voltage = regulator_list_voltage_linear_range,
	.list_voltage = regulator_list_voltage_linear_range,
	.map_voltage = regulator_map_voltage_linear_range,
	.map_voltage = regulator_map_voltage_linear_range,
	.set_voltage_sel = regulator_set_voltage_sel_regmap,
	.set_voltage_sel = regulator_set_voltage_sel_regmap,
@@ -170,9 +237,11 @@ static struct regulator_ops mt6397_volt_range_ops = {
	.disable = regulator_disable_regmap,
	.disable = regulator_disable_regmap,
	.is_enabled = regulator_is_enabled_regmap,
	.is_enabled = regulator_is_enabled_regmap,
	.get_status = mt6397_get_status,
	.get_status = mt6397_get_status,
	.set_mode = mt6397_regulator_set_mode,
	.get_mode = mt6397_regulator_get_mode,
};
};


static struct regulator_ops mt6397_volt_table_ops = {
static const struct regulator_ops mt6397_volt_table_ops = {
	.list_voltage = regulator_list_voltage_table,
	.list_voltage = regulator_list_voltage_table,
	.map_voltage = regulator_map_voltage_iterate,
	.map_voltage = regulator_map_voltage_iterate,
	.set_voltage_sel = regulator_set_voltage_sel_regmap,
	.set_voltage_sel = regulator_set_voltage_sel_regmap,
@@ -184,7 +253,7 @@ static struct regulator_ops mt6397_volt_table_ops = {
	.get_status = mt6397_get_status,
	.get_status = mt6397_get_status,
};
};


static struct regulator_ops mt6397_volt_fixed_ops = {
static const struct regulator_ops mt6397_volt_fixed_ops = {
	.list_voltage = regulator_list_voltage_linear,
	.list_voltage = regulator_list_voltage_linear,
	.enable = regulator_enable_regmap,
	.enable = regulator_enable_regmap,
	.disable = regulator_disable_regmap,
	.disable = regulator_disable_regmap,
@@ -196,28 +265,30 @@ static struct regulator_ops mt6397_volt_fixed_ops = {
static struct mt6397_regulator_info mt6397_regulators[] = {
static struct mt6397_regulator_info mt6397_regulators[] = {
	MT6397_BUCK("buck_vpca15", VPCA15, 700000, 1493750, 6250,
	MT6397_BUCK("buck_vpca15", VPCA15, 700000, 1493750, 6250,
		buck_volt_range1, MT6397_VCA15_CON7, MT6397_VCA15_CON9, 0x7f,
		buck_volt_range1, MT6397_VCA15_CON7, MT6397_VCA15_CON9, 0x7f,
		MT6397_VCA15_CON10, MT6397_VCA15_CON5),
		MT6397_VCA15_CON10, MT6397_VCA15_CON5, MT6397_VCA15_CON2, 11),
	MT6397_BUCK("buck_vpca7", VPCA7, 700000, 1493750, 6250,
	MT6397_BUCK("buck_vpca7", VPCA7, 700000, 1493750, 6250,
		buck_volt_range1, MT6397_VPCA7_CON7, MT6397_VPCA7_CON9, 0x7f,
		buck_volt_range1, MT6397_VPCA7_CON7, MT6397_VPCA7_CON9, 0x7f,
		MT6397_VPCA7_CON10, MT6397_VPCA7_CON5),
		MT6397_VPCA7_CON10, MT6397_VPCA7_CON5, MT6397_VPCA7_CON2, 8),
	MT6397_BUCK("buck_vsramca15", VSRAMCA15, 700000, 1493750, 6250,
	MT6397_BUCK("buck_vsramca15", VSRAMCA15, 700000, 1493750, 6250,
		buck_volt_range1, MT6397_VSRMCA15_CON7, MT6397_VSRMCA15_CON9,
		buck_volt_range1, MT6397_VSRMCA15_CON7, MT6397_VSRMCA15_CON9,
		0x7f, MT6397_VSRMCA15_CON10, MT6397_VSRMCA15_CON5),
		0x7f, MT6397_VSRMCA15_CON10, MT6397_VSRMCA15_CON5,
		MT6397_VSRMCA15_CON2, 8),
	MT6397_BUCK("buck_vsramca7", VSRAMCA7, 700000, 1493750, 6250,
	MT6397_BUCK("buck_vsramca7", VSRAMCA7, 700000, 1493750, 6250,
		buck_volt_range1, MT6397_VSRMCA7_CON7, MT6397_VSRMCA7_CON9,
		buck_volt_range1, MT6397_VSRMCA7_CON7, MT6397_VSRMCA7_CON9,
		0x7f, MT6397_VSRMCA7_CON10, MT6397_VSRMCA7_CON5),
		0x7f, MT6397_VSRMCA7_CON10, MT6397_VSRMCA7_CON5,
		MT6397_VSRMCA7_CON2, 8),
	MT6397_BUCK("buck_vcore", VCORE, 700000, 1493750, 6250,
	MT6397_BUCK("buck_vcore", VCORE, 700000, 1493750, 6250,
		buck_volt_range1, MT6397_VCORE_CON7, MT6397_VCORE_CON9, 0x7f,
		buck_volt_range1, MT6397_VCORE_CON7, MT6397_VCORE_CON9, 0x7f,
		MT6397_VCORE_CON10, MT6397_VCORE_CON5),
		MT6397_VCORE_CON10, MT6397_VCORE_CON5, MT6397_VCORE_CON2, 8),
	MT6397_BUCK("buck_vgpu", VGPU, 700000, 1493750, 6250, buck_volt_range1,
	MT6397_BUCK("buck_vgpu", VGPU, 700000, 1493750, 6250, buck_volt_range1,
		MT6397_VGPU_CON7, MT6397_VGPU_CON9, 0x7f,
		MT6397_VGPU_CON7, MT6397_VGPU_CON9, 0x7f,
		MT6397_VGPU_CON10, MT6397_VGPU_CON5),
		MT6397_VGPU_CON10, MT6397_VGPU_CON5, MT6397_VGPU_CON2, 8),
	MT6397_BUCK("buck_vdrm", VDRM, 800000, 1593750, 6250, buck_volt_range2,
	MT6397_BUCK("buck_vdrm", VDRM, 800000, 1593750, 6250, buck_volt_range2,
		MT6397_VDRM_CON7, MT6397_VDRM_CON9, 0x7f,
		MT6397_VDRM_CON7, MT6397_VDRM_CON9, 0x7f,
		MT6397_VDRM_CON10, MT6397_VDRM_CON5),
		MT6397_VDRM_CON10, MT6397_VDRM_CON5, MT6397_VDRM_CON2, 8),
	MT6397_BUCK("buck_vio18", VIO18, 1500000, 2120000, 20000,
	MT6397_BUCK("buck_vio18", VIO18, 1500000, 2120000, 20000,
		buck_volt_range3, MT6397_VIO18_CON7, MT6397_VIO18_CON9, 0x1f,
		buck_volt_range3, MT6397_VIO18_CON7, MT6397_VIO18_CON9, 0x1f,
		MT6397_VIO18_CON10, MT6397_VIO18_CON5),
		MT6397_VIO18_CON10, MT6397_VIO18_CON5, MT6397_VIO18_CON2, 8),
	MT6397_REG_FIXED("ldo_vtcxo", VTCXO, MT6397_ANALDO_CON0, 10, 2800000),
	MT6397_REG_FIXED("ldo_vtcxo", VTCXO, MT6397_ANALDO_CON0, 10, 2800000),
	MT6397_REG_FIXED("ldo_va28", VA28, MT6397_ANALDO_CON1, 14, 2800000),
	MT6397_REG_FIXED("ldo_va28", VA28, MT6397_ANALDO_CON1, 14, 2800000),
	MT6397_LDO("ldo_vcama", VCAMA, ldo_volt_table1,
	MT6397_LDO("ldo_vcama", VCAMA, ldo_volt_table1,
+3 −0
Original line number Original line Diff line number Diff line
@@ -163,6 +163,9 @@ static void of_get_regulation_constraints(struct device_node *np,
					"regulator-suspend-microvolt", &pval))
					"regulator-suspend-microvolt", &pval))
			suspend_state->uV = pval;
			suspend_state->uV = pval;


		if (i == PM_SUSPEND_MEM)
			constraints->initial_state = PM_SUSPEND_MEM;

		of_node_put(suspend_np);
		of_node_put(suspend_np);
		suspend_state = NULL;
		suspend_state = NULL;
		suspend_np = NULL;
		suspend_np = NULL;
+7 −8
Original line number Original line Diff line number Diff line
@@ -70,6 +70,7 @@ struct pfuze_chip {
	struct device *dev;
	struct device *dev;
	struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR];
	struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR];
	struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR];
	struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR];
	struct pfuze_regulator *pfuze_regulators;
};
};


static const int pfuze100_swbst[] = {
static const int pfuze100_swbst[] = {
@@ -334,8 +335,6 @@ static struct pfuze_regulator pfuze3000_regulators[] = {
	PFUZE100_VGEN_REG(PFUZE3000, VLDO4, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000),
	PFUZE100_VGEN_REG(PFUZE3000, VLDO4, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000),
};
};


static struct pfuze_regulator *pfuze_regulators;

#ifdef CONFIG_OF
#ifdef CONFIG_OF
/* PFUZE100 */
/* PFUZE100 */
static struct of_regulator_match pfuze100_matches[] = {
static struct of_regulator_match pfuze100_matches[] = {
@@ -563,21 +562,21 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
	/* use the right regulators after identify the right device */
	/* use the right regulators after identify the right device */
	switch (pfuze_chip->chip_id) {
	switch (pfuze_chip->chip_id) {
	case PFUZE3000:
	case PFUZE3000:
		pfuze_regulators = pfuze3000_regulators;
		pfuze_chip->pfuze_regulators = pfuze3000_regulators;
		regulator_num = ARRAY_SIZE(pfuze3000_regulators);
		regulator_num = ARRAY_SIZE(pfuze3000_regulators);
		sw_check_start = PFUZE3000_SW2;
		sw_check_start = PFUZE3000_SW2;
		sw_check_end = PFUZE3000_SW2;
		sw_check_end = PFUZE3000_SW2;
		sw_hi = 1 << 3;
		sw_hi = 1 << 3;
		break;
		break;
	case PFUZE200:
	case PFUZE200:
		pfuze_regulators = pfuze200_regulators;
		pfuze_chip->pfuze_regulators = pfuze200_regulators;
		regulator_num = ARRAY_SIZE(pfuze200_regulators);
		regulator_num = ARRAY_SIZE(pfuze200_regulators);
		sw_check_start = PFUZE200_SW2;
		sw_check_start = PFUZE200_SW2;
		sw_check_end = PFUZE200_SW3B;
		sw_check_end = PFUZE200_SW3B;
		break;
		break;
	case PFUZE100:
	case PFUZE100:
	default:
	default:
		pfuze_regulators = pfuze100_regulators;
		pfuze_chip->pfuze_regulators = pfuze100_regulators;
		regulator_num = ARRAY_SIZE(pfuze100_regulators);
		regulator_num = ARRAY_SIZE(pfuze100_regulators);
		sw_check_start = PFUZE100_SW2;
		sw_check_start = PFUZE100_SW2;
		sw_check_end = PFUZE100_SW4;
		sw_check_end = PFUZE100_SW4;
@@ -587,7 +586,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
		(pfuze_chip->chip_id == PFUZE100) ? "100" :
		(pfuze_chip->chip_id == PFUZE100) ? "100" :
		((pfuze_chip->chip_id == PFUZE200) ? "200" : "3000"));
		((pfuze_chip->chip_id == PFUZE200) ? "200" : "3000"));


	memcpy(pfuze_chip->regulator_descs, pfuze_regulators,
	memcpy(pfuze_chip->regulator_descs, pfuze_chip->pfuze_regulators,
		sizeof(pfuze_chip->regulator_descs));
		sizeof(pfuze_chip->regulator_descs));


	ret = pfuze_parse_regulators_dt(pfuze_chip);
	ret = pfuze_parse_regulators_dt(pfuze_chip);
@@ -631,7 +630,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
			devm_regulator_register(&client->dev, desc, &config);
			devm_regulator_register(&client->dev, desc, &config);
		if (IS_ERR(pfuze_chip->regulators[i])) {
		if (IS_ERR(pfuze_chip->regulators[i])) {
			dev_err(&client->dev, "register regulator%s failed\n",
			dev_err(&client->dev, "register regulator%s failed\n",
				pfuze_regulators[i].desc.name);
				pfuze_chip->pfuze_regulators[i].desc.name);
			return PTR_ERR(pfuze_chip->regulators[i]);
			return PTR_ERR(pfuze_chip->regulators[i]);
		}
		}
	}
	}
@@ -650,5 +649,5 @@ static struct i2c_driver pfuze_driver = {
module_i2c_driver(pfuze_driver);
module_i2c_driver(pfuze_driver);


MODULE_AUTHOR("Robin Gong <b38343@freescale.com>");
MODULE_AUTHOR("Robin Gong <b38343@freescale.com>");
MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/PFUZE200 PMIC");
MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/200/3000 PMIC");
MODULE_LICENSE("GPL v2");
MODULE_LICENSE("GPL v2");
Loading