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

Commit 8f48ec6a authored by Kiran Gunda's avatar Kiran Gunda
Browse files

regulator: onsemi-ncp6335d: Add is_enabled API support



Without is_enabled function support, regualtor framework treats
it as an always on regulator and does not invoke the regulator enable
function call. Hence, add support for it.

Also, define a parent supply ("vin") for the regulator. This parent
can be used to pin-control the regulator. While at it, change the initcall
level to subsys_init. so that the driver registers after the parent supply
("vin" - provided by fixed-regualtor).

Change-Id: I93e870d2e4b89f7874c3e17be91bc417dadf1777
Signed-off-by: default avatarKiran Gunda <kgunda@codeaurora.org>
parent 08e56dd3
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -153,6 +153,20 @@ static void ncp633d_slew_delay(struct ncp6335d_info *dd,
	udelay(delay);
}

static int ncp6335d_is_enabled(struct regulator_dev *rdev)
{
	int rc, val = 0;
	struct ncp6335d_info *dd = rdev_get_drvdata(rdev);

	rc = ncp6335x_read(dd, dd->vsel_reg, &val);
	if (rc)
		dev_err(dd->dev, "Unable to read enable register rc(%d)", rc);

	dump_registers(dd, dd->vsel_reg, __func__);

	return ((val & NCP6335D_ENABLE) ? 1 : 0);
}

static int ncp6335d_enable(struct regulator_dev *rdev)
{
	int rc;
@@ -297,6 +311,7 @@ static struct regulator_ops ncp6335d_ops = {
	.set_voltage = ncp6335d_set_voltage,
	.get_voltage = ncp6335d_get_voltage,
	.list_voltage = ncp6335d_list_voltage,
	.is_enabled = ncp6335d_is_enabled,
	.enable = ncp6335d_enable,
	.disable = ncp6335d_disable,
	.set_mode = ncp6335d_set_mode,
@@ -305,6 +320,7 @@ static struct regulator_ops ncp6335d_ops = {

static struct regulator_desc rdesc = {
	.name = "ncp6335d",
	.supply_name = "vin",
	.owner = THIS_MODULE,
	.n_voltages = NCP6335D_VOLTAGE_STEPS,
	.ops = &ncp6335d_ops,
@@ -748,7 +764,7 @@ int __init ncp6335d_regulator_init(void)
	return i2c_add_driver(&ncp6335d_regulator_driver);
}
EXPORT_SYMBOL(ncp6335d_regulator_init);
arch_initcall(ncp6335d_regulator_init);
subsys_initcall(ncp6335d_regulator_init);

static void __exit ncp6335d_regulator_exit(void)
{