From patchwork Fri Apr 14 18:25:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 9681541 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 1E72160384 for ; Fri, 14 Apr 2017 18:26:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 127F4286B3 for ; Fri, 14 Apr 2017 18:26:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 053C0285F3; Fri, 14 Apr 2017 18:26:13 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham 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 26129285F3 for ; Fri, 14 Apr 2017 18:26:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752152AbdDNS0K (ORCPT ); Fri, 14 Apr 2017 14:26:10 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.219]:15511 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752080AbdDNS0J (ORCPT ); Fri, 14 Apr 2017 14:26:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1492194367; l=2316; s=domk; d=goldelico.com; h=References:In-Reply-To:References:In-Reply-To:Date:Subject:Cc:To: From; bh=TXYr9uz5xlo4OSuyMay4DsLObxGtzPdpFl7uy0Dq9Fk=; b=NAr3UrjtbncTgq1misrv4eXlZDVCvt66IuMujPSTC4jzQnG30/dcNxrInH6E8mUWw2 kujG0I52Ae+1ht1gv9PyiJRuX4DmYMcy4AEfFf637z9hkZUyWmvX+xgs9koWsZWTorAy V3BSIeEhlpP/kRAD+ohCbg1WaAd5cFKMWmKHI= X-RZG-AUTH: :JGIXVUS7cutRB/49FwqZ7WcecEarQROEYabkiUo6mSAGQ+qKID81PEKVI58= X-RZG-CLASS-ID: mo00 Received: from localhost.localdomain (p57AE0DE0.dip0.t-ipconnect.de [87.174.13.224]) by smtp.strato.de (RZmta 40.4 DYNA|AUTH) with ESMTPSA id 20b4c7t3EIPwbaz (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Fri, 14 Apr 2017 20:25:58 +0200 (CEST) From: "H. Nikolaus Schaller" To: Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse Cc: Grazvydas Ignotas , Andreas Kemnade , linux-pm@vger.kernel.org, letux-kernel@openphoenux.org, linux-kernel@vger.kernel.org, "H. Nikolaus Schaller" Subject: [PATCH v3 1/3] drivers:power:twl4030-charger: don't check if battery is present Date: Fri, 14 Apr 2017 20:25:55 +0200 Message-Id: <442f66835ab6e1359540a3a4c9bb9718d31b40bb.1492194356.git.hns@goldelico.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: References: In-Reply-To: References: 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 We can't assume that the battery is or stays present after probing on devices with replaceable battery. On some devices (e.g. GTA04 or OpenPanodra) it can be removed and even be hot swapped by the user while device continues to operate through external AC or USB power (as long as system power consumption remains below ca. 500mA as provided by USB). So it makes no sense to check for this situation during probe and make the charger driver (and its status reports) completely non-operational if the battery can be inserted later. Tested on: GTA04 and OpenPandora. Signed-off-by: H. Nikolaus Schaller --- drivers/power/supply/twl4030_charger.c | 36 ---------------------------------- 1 file changed, 36 deletions(-) diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c index 7bcff1c1..34e389d 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -206,35 +206,6 @@ static int twl4030bci_read_adc_val(u8 reg) } /* - * Check if Battery Pack was present - */ -static int twl4030_is_battery_present(struct twl4030_bci *bci) -{ - int ret; - u8 val = 0; - - /* Battery presence in Main charge? */ - ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, &val, TWL4030_BCIMFSTS3); - if (ret) - return ret; - if (val & TWL4030_BATSTSMCHG) - return 0; - - /* - * OK, It could be that bootloader did not enable main charger, - * pre-charge is h/w auto. So, Battery presence in Pre-charge? - */ - ret = twl_i2c_read_u8(TWL4030_MODULE_PRECHARGE, &val, - TWL4030_BCIMFSTS1); - if (ret) - return ret; - if (val & TWL4030_BATSTSPCHG) - return 0; - - return -ENODEV; -} - -/* * TI provided formulas: * CGAIN == 0: ICHG = (BCIICHG * 1.7) / (2^10 - 1) - 0.85 * CGAIN == 1: ICHG = (BCIICHG * 3.4) / (2^10 - 1) - 1.7 @@ -1011,13 +982,6 @@ static int twl4030_bci_probe(struct platform_device *pdev) bci->irq_chg = platform_get_irq(pdev, 0); bci->irq_bci = platform_get_irq(pdev, 1); - /* Only proceed further *IF* battery is physically present */ - ret = twl4030_is_battery_present(bci); - if (ret) { - dev_crit(&pdev->dev, "Battery was not detected:%d\n", ret); - return ret; - } - if (bci->dev->of_node) { struct device_node *phynode;