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

Commit ad02dda3 authored by Ke Liu's avatar Ke Liu
Browse files

regulator: onsemi-ncp6335d: add device tree support for mode selection



Add support to the onsemi-ncp6335d driver to select which regulator
operating mode to utilize. There are two possible mode selections: PWM mode
and auto mode. If no mode property is specified in device tree, the
regulator will operate in the hardware default mode.

CRs-Fixed: 607899
Change-Id: I2e21c452a3ea3963146d9abbc7e89e811fd90388
Signed-off-by: default avatarKe Liu <keliu@codeaurora.org>
parent a18f488c
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -46,7 +46,10 @@ Optional Properties:
				The 2 elements with index[0..1] are:
				[0] => the mask value;
				[1] => the value to write into the masked bits.

- onnn,mode:			A string which specifies the initial mode to use for the regulator.
				Supported values are "pwm" and "auto". PWM mode is more
				robust, but draws more current than auto mode. If this propery
				is not specified, then the regulator will be in the hardware default mode.

Example:
	i2c_0 {
+19 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <linux/of_gpio.h>
#include <linux/regmap.h>
#include <linux/regulator/onsemi-ncp6335d.h>
#include <linux/string.h>
#include <mach/gpiomux.h>

/* registers */
@@ -468,6 +469,7 @@ static struct ncp6335d_platform_data *
{
	struct ncp6335d_platform_data *pdata = NULL;
	struct regulator_init_data *init_data;
	const char *mode_name;
	int rc;

	init_data = of_get_regulator_init_data(&client->dev,
@@ -516,7 +518,23 @@ static struct ncp6335d_platform_data *
	init_data->constraints.valid_modes_mask =
				REGULATOR_MODE_NORMAL |
				REGULATOR_MODE_FAST;
	init_data->constraints.initial_mode = REGULATOR_MODE_NORMAL;

	rc = of_property_read_string(client->dev.of_node, "onnn,mode",
					&mode_name);
	if (!rc) {
		if (strcmp("pwm", mode_name) == 0) {
			init_data->constraints.initial_mode =
							REGULATOR_MODE_FAST;
		} else if (strcmp("auto", mode_name) == 0) {
			init_data->constraints.initial_mode =
							REGULATOR_MODE_NORMAL;
		} else {
			dev_err(&client->dev, "onnn,mode, unknown regulator mode: %s\n",
				mode_name);
			return NULL;
		}
	}

	return pdata;
}