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

Commit b51c4354 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull regulator updates from Mark Brown:
 "A very small set of updates for the regulator API this time around,
  there's a few bug fixes and also:

   - Conversion of the regulator API to use GPIO descriptors rather than
     numbers from Linus Walleij.

   - New drivers for Marvell 88PG86x and Qualcomm PM8998 and PMI8998"

* tag 'regulator-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
  regulator: qcom: smd: Add pm8998 and pmi8998 regulators
  regulator: core: Add missing blank line between functions
  regulator: qcom_smd: Drop regulator/{machine,of_regulator} includes
  regulator: giving regulator controlling gpios a non-empty label when used through the devicetree.
  regulator: gpio: Fix some error handling paths in 'gpio_regulator_probe()'
  regulator: 88pg86x: new i2c dual regulator chip
  regulator: 88pg86x: add DT bindings document
  regulator: da9211: Pass descriptors instead of GPIO numbers
  regulator: da9055: Pass descriptor instead of GPIO number
  regulator: core: Support passing an initialized GPIO enable descriptor
  regulator: dt: regulator-name is required property
  regulator: of: Add a missing 'of_node_put()' in an error handling path of 'of_regulator_match()'
parents ffd776bf 36fd679f
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
Marvell 88PG867/88PG868 voltage regulators

Required properties:
- compatible: one of "marvell,88pg867", "marvell,88pg868";
- reg: I2C slave address.

Optional subnodes for regulators: "buck1", "buck2", using common regulator
bindings given in <Documentation/devicetree/bindings/regulator/regulator.txt>.

Example:

	pg868@19 {
		compatible = "marvell,88pg868";
		reg = <0x19>;

		vcpu: buck1 {
			regulator-boot-on;
			regulator-always-on;
			regulator-min-microvolt = <1000000>;
			regulator-max-microvolt = <1350000>;
		};
	};
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ Fixed Voltage regulators

Required properties:
- compatible: Must be "regulator-fixed";
- regulator-name: Defined in regulator.txt as optional, but required here.

Optional properties:
- gpio: gpio to use for enable control
+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@ GPIO controlled regulators

Required properties:
- compatible		: Must be "regulator-gpio".
- regulator-name	: Defined in regulator.txt as optional, but required
			  here.
- states		: Selection of available voltages and GPIO configs.
                          if there are no states, then use a fixed regulator

+48 −0
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@ Regulator nodes are identified by their compatible:
		    "qcom,rpm-pm8916-regulators"
		    "qcom,rpm-pm8941-regulators"
		    "qcom,rpm-pm8994-regulators"
		    "qcom,rpm-pm8998-regulators"
		    "qcom,rpm-pma8084-regulators"
		    "qcom,rpm-pmi8998-regulators"

- vdd_s1-supply:
- vdd_s2-supply:
@@ -119,6 +121,38 @@ Regulator nodes are identified by their compatible:
	Definition: reference to regulator supplying the input pin, as
		    described in the data sheet

- vdd_s1-supply:
- vdd_s2-supply:
- vdd_s3-supply:
- vdd_s4-supply:
- vdd_s5-supply:
- vdd_s6-supply:
- vdd_s7-supply:
- vdd_s8-supply:
- vdd_s9-supply:
- vdd_s10-supply:
- vdd_s11-supply:
- vdd_s12-supply:
- vdd_s13-supply:
- vdd_l1_l27-supply:
- vdd_l20_l24-supply:
- vdd_l26-supply:
- vdd_l2_l8_l17-supply:
- vdd_l3_l11-supply:
- vdd_l4_l5-supply:
- vdd_l6-supply:
- vdd_l7_l12_l14_l15-supply:
- vdd_l9-supply:
- vdd_l10_l23_l25-supply:
- vdd_l13_l19_l21-supply:
- vdd_l16_l28-supply:
- vdd_l18_l22-supply:
- vdd_lvs1_lvs2-supply:
	Usage: optional (pmi8998 only)
	Value type: <phandle>
	Definition: reference to regulator supplying the input pin, as
		    described in the data sheet

- vdd_s1-supply:
- vdd_s2-supply:
- vdd_s3-supply:
@@ -148,6 +182,12 @@ Regulator nodes are identified by their compatible:
	Definition: reference to regulator supplying the input pin, as
		    described in the data sheet

- vdd_bob-supply:
	Usage: optional (pmi8998 only)
	Value type: <phandle>
	Definition: reference to regulator supplying the input pin, as
		    described in the data sheet

The regulator node houses sub-nodes for each regulator within the device. Each
sub-node is identified using the node's name, with valid values listed for each
of the pmics below.
@@ -169,11 +209,19 @@ pm8994:
	l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20,
	l21, l22, l23, l24, l25, l26, l27, l28, l29, l30, l31, l32, lvs1, lvs2

pm8998:
	s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, l1, l2, l3, l4,
	l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19,
	l20, l21, l22, l23, l24, l25, l26, l27, l28, lvs1, lvs2

pma8084:
	s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, l1, l2, l3, l4, l5,
	l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20,
	l21, l22, l23, l24, l25, l26, l27, lvs1, lvs2, lvs3, lvs4, 5vs1

pmi8998:
	bob

The content of each sub-node is defined by the standard binding for regulators -
see regulator.txt.

+114 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/of.h>
#include <linux/regulator/driver.h>
#include <linux/regmap.h>

static const struct regulator_ops pg86x_ops = {
	.set_voltage_sel = regulator_set_voltage_sel_regmap,
	.get_voltage_sel = regulator_get_voltage_sel_regmap,
	.list_voltage = regulator_list_voltage_linear_range,
};

static const struct regulator_linear_range pg86x_buck1_ranges[] = {
	REGULATOR_LINEAR_RANGE(      0,  0, 10,     0),
	REGULATOR_LINEAR_RANGE(1000000, 11, 34, 25000),
	REGULATOR_LINEAR_RANGE(1600000, 35, 47, 50000),
};

static const struct regulator_linear_range pg86x_buck2_ranges[] = {
	REGULATOR_LINEAR_RANGE(      0,  0, 15,     0),
	REGULATOR_LINEAR_RANGE(1000000, 16, 39, 25000),
	REGULATOR_LINEAR_RANGE(1600000, 40, 52, 50000),
};

static const struct regulator_desc pg86x_regulators[] = {
	{
		.id = 0,
		.type = REGULATOR_VOLTAGE,
		.name = "buck1",
		.of_match = of_match_ptr("buck1"),
		.n_voltages = 11 + 24 + 13,
		.linear_ranges = pg86x_buck1_ranges,
		.n_linear_ranges = 3,
		.vsel_reg  = 0x24,
		.vsel_mask = 0xff,
		.ops = &pg86x_ops,
		.owner = THIS_MODULE
	},
	{
		.id = 1,
		.type = REGULATOR_VOLTAGE,
		.name = "buck2",
		.of_match = of_match_ptr("buck2"),
		.n_voltages = 16 + 24 + 13,
		.linear_ranges = pg86x_buck2_ranges,
		.n_linear_ranges = 3,
		.vsel_reg  = 0x13,
		.vsel_mask = 0xff,
		.ops = &pg86x_ops,
		.owner = THIS_MODULE
	},
};

static const struct regmap_config pg86x_regmap = {
	.reg_bits = 8,
	.val_bits = 8,
};

static int pg86x_i2c_probe(struct i2c_client *i2c)
{
	int id, ret;
	struct regulator_config config = {.dev = &i2c->dev};
	struct regmap *regmap = devm_regmap_init_i2c(i2c, &pg86x_regmap);

	if (IS_ERR(regmap)) {
		ret = PTR_ERR(regmap);
		dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
		return ret;
	}

	for (id = 0; id < ARRAY_SIZE(pg86x_regulators); id++) {
		struct regulator_dev *rdev;
		rdev = devm_regulator_register(&i2c->dev,
					       &pg86x_regulators[id],
					       &config);
		if (IS_ERR(rdev)) {
			ret = PTR_ERR(rdev);
			dev_err(&i2c->dev, "failed to register %s: %d\n",
				pg86x_regulators[id].name, ret);
			return ret;
		}
	}
	return 0;
}

static const struct of_device_id pg86x_dt_ids [] = {
	{ .compatible = "marvell,88pg867" },
	{ .compatible = "marvell,88pg868" },
	{ }
};
MODULE_DEVICE_TABLE(of, pg86x_dt_ids);

static const struct i2c_device_id pg86x_i2c_id[] = {
	{ "88pg867", },
	{ "88pg868", },
	{ }
};
MODULE_DEVICE_TABLE(i2c, pg86x_i2c_id);

static struct i2c_driver pg86x_regulator_driver = {
	.driver = {
		.name = "88pg86x",
		.of_match_table = of_match_ptr(pg86x_dt_ids),
	},
	.probe_new = pg86x_i2c_probe,
	.id_table = pg86x_i2c_id,
};

module_i2c_driver(pg86x_regulator_driver);

MODULE_DESCRIPTION("Marvell 88PG86X voltage regulator");
MODULE_AUTHOR("Alexander Monakov <amonakov@gmail.com>");
MODULE_LICENSE("GPL");
Loading