linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Liam Breck <liam@networkimprov.net>
To: Sebastian Reichel <sre@kernel.org>, linux-pm@vger.kernel.org
Cc: Tony Lindgren <tony@atomide.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Liam Breck <kernel@networkimprov.net>
Subject: [PATCH v2 4/5] power: bq24190_charger: Add property system-minimum-microvolt
Date: Mon,  7 Aug 2017 12:54:19 -0700	[thread overview]
Message-ID: <20170807195420.20767-5-liam@networkimprov.net> (raw)
In-Reply-To: <20170807195420.20767-1-liam@networkimprov.net>

From: Liam Breck <kernel@networkimprov.net>

Set minimum system voltage limit obtained from device property.

Cc: Tony Lindgren <tony@atomide.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Liam Breck <kernel@networkimprov.net>
---
 drivers/power/supply/bq24190_charger.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 2ab580bf..f20d2c68 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -43,6 +43,8 @@
 #define BQ24190_REG_POC_CHG_CONFIG_OTG			0x2
 #define BQ24190_REG_POC_SYS_MIN_MASK		(BIT(3) | BIT(2) | BIT(1))
 #define BQ24190_REG_POC_SYS_MIN_SHIFT		1
+#define BQ24190_REG_POC_SYS_MIN_MIN			3000
+#define BQ24190_REG_POC_SYS_MIN_MAX			3700
 #define BQ24190_REG_POC_BOOST_LIM_MASK		BIT(0)
 #define BQ24190_REG_POC_BOOST_LIM_SHIFT		0
 
@@ -159,6 +161,7 @@ struct bq24190_dev_info {
 	char				model_name[I2C_NAME_SIZE];
 	bool				initialized;
 	bool				irq_event;
+	u16				sys_min;
 	struct mutex			f_reg_lock;
 	u8				f_reg;
 	u8				ss_reg;
@@ -530,6 +533,16 @@ static int bq24190_set_config(struct bq24190_dev_info *bdi)
 	if (ret < 0)
 		return ret;
 
+	if (bdi->sys_min) {
+		v = bdi->sys_min / 100 - 30; // manual section 9.5.1.2, table 9
+		ret = bq24190_write_mask(bdi, BQ24190_REG_POC,
+					 BQ24190_REG_POC_SYS_MIN_MASK,
+					 BQ24190_REG_POC_SYS_MIN_SHIFT,
+					 v);
+		if (ret < 0)
+			return ret;
+	}
+
 	return 0;
 }
 
@@ -1471,11 +1484,21 @@ static int bq24190_hw_init(struct bq24190_dev_info *bdi)
 static int bq24190_get_config(struct bq24190_dev_info *bdi)
 {
 #ifdef CONFIG_OF
+	const char * const s = "ti,system-minimum-microvolt";
 	int v;
 
 	if (!bdi->dev->of_node)
 		return -EINVAL;
 
+	if (device_property_read_u32(bdi->dev, s, &v) == 0) {
+		v /= 1000;
+		if (v >= BQ24190_REG_POC_SYS_MIN_MIN
+		 && v <= BQ24190_REG_POC_SYS_MIN_MAX)
+			bdi->sys_min = v;
+		else
+			dev_warn(bdi->dev, "invalid value for %s: %u\n", s, v);
+	}
+
 #endif
 	return 0;
 }
-- 
2.13.2

  parent reply	other threads:[~2017-08-07 19:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-07 19:54 [PATCH v2 0/5] BQ24190 devicetree config Liam Breck
2017-08-07 19:54 ` [PATCH v2 1/5] power: bq24190_charger: Add ti,bq24192i to devicetree table Liam Breck
2017-08-25 20:28   ` Tony Lindgren
2017-08-07 19:54 ` [PATCH v2 2/5] devicetree: power: Add docs for TI BQ24190 battery charger Liam Breck
     [not found]   ` <20170807195420.20767-3-liam-RYWXG+zxWwBdeoIcmNTgJF6hYfS7NtTn@public.gmane.org>
2017-08-11  2:50     ` Rob Herring
2017-08-11 21:57       ` Liam Breck
2017-08-12 16:42         ` Sebastian Reichel
2017-08-12 19:00           ` Liam Breck
     [not found]             ` <CAKvHMgR+GxSqhy+iwdYmku2600HzoF__oXV7_w72ZJg-aK7O-Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-16 15:47               ` Tony Lindgren
2017-08-16 20:11                 ` Liam Breck
     [not found]                   ` <CAKvHMgTvVMsvmyi0o89m1SfS9A4U1GbNuU05Tkt6C0ARR9NyWw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-16 21:06                     ` Tony Lindgren
2017-08-16 21:16                       ` Liam Breck
     [not found]                         ` <CAKvHMgTJjTxffoP4Kt=KzGvCQ-BihLeQn3i4TaF4OBSXV7i6TA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-18  0:16                           ` Tony Lindgren
2017-08-25 20:29                           ` Tony Lindgren
2017-08-07 19:54 ` [PATCH v2 3/5] power: bq24190_charger: Enable devicetree config Liam Breck
2017-08-07 19:54 ` Liam Breck [this message]
2017-08-07 19:54 ` [PATCH v2 5/5] power: bq24190_charger: Add power_supply_battery_info support Liam Breck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170807195420.20767-5-liam@networkimprov.net \
    --to=liam@networkimprov.net \
    --cc=hdegoede@redhat.com \
    --cc=kernel@networkimprov.net \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).