From patchwork Mon Jun 12 21:24:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo i Serra X-Patchwork-Id: 9782819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 59E7A60382 for ; Mon, 12 Jun 2017 21:25:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CAC9281E1 for ; Mon, 12 Jun 2017 21:25:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40A4827FB7; Mon, 12 Jun 2017 21:25:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBA1127FB7 for ; Mon, 12 Jun 2017 21:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752847AbdFLVYk (ORCPT ); Mon, 12 Jun 2017 17:24:40 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:60694 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752654AbdFLVYZ (ORCPT ); Mon, 12 Jun 2017 17:24:25 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 47D6326B9FA From: Enric Balletbo i Serra To: linux-omap@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Tony Lindgren , Rob Herring , Mark Rutland , Russell King , Lee Jones , Sebastian Reichel , 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 Message-Id: <20170612212412.22719-4-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170612212412.22719-1-enric.balletbo@collabora.com> References: <20170612212412.22719-1-enric.balletbo@collabora.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;