All of lore.kernel.org
 help / color / mirror / Atom feed
From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: linux-omap@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Cc: Tony Lindgren <tony@atomide.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Russell King <linux@armlinux.org.uk>,
	Lee Jones <lee.jones@linaro.org>,
	Sebastian Reichel <sre@kernel.org>,
	grygorii.strashko@ti.com, javier@dowhile0.org
Subject: [PATCH 4/4] power: supply: tps65217: able to disable the charger block.
Date: Mon, 12 Jun 2017 23:24:12 +0200	[thread overview]
Message-ID: <20170612212412.22719-4-enric.balletbo@collabora.com> (raw)
In-Reply-To: <20170612212412.22719-1-enric.balletbo@collabora.com>

The TPS65217 charger is enabled by default, but by default the DT binding
sets the charger as disabled, so currently all the devices that include
the tps65217 binding have the charger enabled. This patch adds a check in
the probe function of the tps65217 charger and disables it if the device
status is disabled.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---
 drivers/power/supply/tps65217_charger.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/power/supply/tps65217_charger.c b/drivers/power/supply/tps65217_charger.c
index 1f52340..55308f4 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -203,6 +203,23 @@ static int tps65217_charger_probe(struct platform_device *pdev)
 	int ret;
 	int i;
 
+	/*
+	 * By default the charger is enabled but if device is disabled stop
+	 * the charger accordingly to the configuration.
+	 */
+	if (!of_device_is_available(pdev->dev.of_node)) {
+		dev_dbg(&pdev->dev, "charger disabled\n");
+		ret = tps65217_clear_bits(tps, TPS65217_REG_CHGCONFIG1,
+					  TPS65217_CHGCONFIG1_CHG_EN,
+					  TPS65217_PROTECT_NONE);
+		if (ret) {
+			dev_err(&pdev->dev, "Error writing in reg 0x%x: %d\n",
+				TPS65217_REG_CHGCONFIG1, ret);
+			return ret;
+		}
+		return -ENODEV;
+	}
+
 	charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
 	if (!charger)
 		return -ENOMEM;
-- 
2.9.3

      parent reply	other threads:[~2017-06-12 21:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-12 21:24 [PATCH 1/4] ARM: dts: tps65217: Add charger interrupts to the common tps65217.dtsi file Enric Balletbo i Serra
2017-06-12 21:24 ` Enric Balletbo i Serra
2017-06-12 21:24 ` [PATCH 2/4] ARM: dts: tps65217: Add power button interrupt " Enric Balletbo i Serra
2017-06-13  7:35   ` Tony Lindgren
2017-06-13  9:08     ` Enric Balletbo Serra
2017-06-14  4:55       ` Tony Lindgren
2017-06-14  4:55         ` Tony Lindgren
2017-08-10 16:24         ` Tony Lindgren
2017-08-10 16:24           ` Tony Lindgren
2017-06-12 21:24 ` [PATCH 3/4] mfd: tps65217: remove duplicated interrupt resources Enric Balletbo i Serra
2017-06-12 22:41   ` Grygorii Strashko
2017-06-12 22:41     ` Grygorii Strashko
2017-06-13  8:18     ` Enric Balletbo Serra
2017-06-13  8:18       ` Enric Balletbo Serra
2017-06-13 23:05       ` Grygorii Strashko
2017-06-13 23:05         ` Grygorii Strashko
2017-06-12 21:24 ` Enric Balletbo i Serra [this message]

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=20170612212412.22719-4-enric.balletbo@collabora.com \
    --to=enric.balletbo@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=grygorii.strashko@ti.com \
    --cc=javier@dowhile0.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.