Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3953103ybz; Mon, 4 May 2020 12:50:43 -0700 (PDT) X-Google-Smtp-Source: APiQypIb5lmvWo0MArjAdrL5ym/vW2oVA8WulhowYENKQgd+q5EZ3B6Fep48qk/rsnudmPZlTo6F X-Received: by 2002:a05:6402:6c4:: with SMTP id n4mr16469434edy.368.1588621843360; Mon, 04 May 2020 12:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588621843; cv=none; d=google.com; s=arc-20160816; b=xA22ObOi3lfSA+2Z9yA9I5015fG+P5LFjuIIBnGnynMyIHkv5tVSFnoM33ZmuTkCKe pX/dGAFQgEfXKWVva3qaoS183iXlnBGZQRaMkpgTnF8CPVMpQ0wkC/QaUr3KRw3RgE87 koG88HL3qc5wdufotTjZswVeiZzkzkQpHjH7D7EKCNX8qabyBGIzrdZjBWUOCFVr799g TpN4eM8wx9jcS+6s0L9MzPby/CBcQn0HkMARKj1Ba1BOub+CJ6X+qmnon+46T+vGgQAG ECR6cEj1tWqdaujB9a2Sx5H+7ce6KGfTe/Jt2GiZY1MuYL2XW8gRElvf6/xE7DoZvH+W bpqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:content-transfer-encoding :mime-version:subject:from:references:in-reply-to:message-id:date :dkim-signature; bh=GHBLZ7bbckjbjHEJBwctIcyRIlr5M44EjWzF6hbC1oI=; b=h6qlAdeLfEcBgEE4tySYP7vhOg8RG02LjT2WekZDoKFdlCT41j7etZi176JXbkDnAK XJAV8IX7GVD+n1XTxnSQURja6+Jvtif47vGbm2f1k48SpvgYZvKQ7fW5vsiROt4qxK+l uRcAOBMD2fALkipNFCamwZYwOQ2QEqj+aPDfld75buNHZAlPDRPFnhkNovE2hDa6W0BD qOnLKFgZ2/KQUg/LwdAfbNsDn1OluEuoZeUYVPXrdiyPPxNrDqWQtA2meRCdLmXn78cB 3+3Vpxql4SiPxeUqCO8fe3LPq7FUdtBwuWJSve0C/+DDzdWqivuALtf6MToO84lOrsYh lUSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=XZvSQYHN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q13si7599955edn.307.2020.05.04.12.50.19; Mon, 04 May 2020 12:50:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=XZvSQYHN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728074AbgEDTsL (ORCPT + 99 others); Mon, 4 May 2020 15:48:11 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:2691 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727839AbgEDTrt (ORCPT ); Mon, 4 May 2020 15:47:49 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49GD0f3WsZzLn; Mon, 4 May 2020 21:47:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1588621666; bh=cQuVrUR3wgTd8lZabcNbfWQeqVxfRyNFlVyOZvgXwJk=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=XZvSQYHN9LeJpr3cfWfmFvU1OLPJHpuQVUUKBiQZGCpGExaESjaBqGLsRiiZKF7YR LmLUoTX3yjb3cBHu+GIkAzjSL9CxlYwJxYxbUi6mfKNeuHPlGj5UN0UC1aanJAVXgn ks5GaQ2vtvABsuQMRtP83X8vrrOu875OupshO9WHR8ko+RIowC8SjpcGprhb/7K1DW WHHGwf8zNECtxWsyzoa6gn34k+nE3tLZR0htnY/DNdWIY+4d/OPzvNowzk+qZ5MNi/ 96T1fbyVjyLsmnkBadI16bmwWvArpficzy9334M3t8bqPIrUUWo5rH0/iy9FZkdbPs vt/OVUGdX68ew== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Mon, 04 May 2020 21:47:46 +0200 Message-Id: <7c42c59a5f27a8f88dad6501d9032189d1878614.1588621247.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH v3 4/8] power: bq25890: implement CHARGE_TYPE property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Angus Ainslie , Rob Herring , Sebastian Reichel , Yauhen Kharuzhy Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Report charging type based on recently read state. Signed-off-by: Michał Mirosław --- drivers/power/supply/bq25890_charger.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 322d48d28fe5..02e62ac76e15 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -427,6 +427,18 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, break; + case POWER_SUPPLY_PROP_CHARGE_TYPE: + if (!state.online || state.chrg_status == STATUS_NOT_CHARGING || + state.chrg_status == STATUS_TERMINATION_DONE) + val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE; + else if (state.chrg_status == STATUS_PRE_CHARGING) + val->intval = POWER_SUPPLY_CHARGE_TYPE_STANDARD; + else if (state.chrg_status == STATUS_FAST_CHARGING) + val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST; + else /* unreachable */ + val->intval = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN; + break; + case POWER_SUPPLY_PROP_MANUFACTURER: val->strval = BQ25890_MANUFACTURER; break; @@ -668,6 +680,7 @@ static const enum power_supply_property bq25890_power_supply_props[] = { POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_CHARGE_TYPE, POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, -- 2.20.1