Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp397950pxy; Wed, 5 May 2021 05:06:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW4Whv+rApWo3GVUAWDZ93ZhhkTq7aXN9cMfgQxmHWcOJTF/siNLk/u07QtLVLxeykOyCg X-Received: by 2002:a17:902:7683:b029:ec:a434:1921 with SMTP id m3-20020a1709027683b02900eca4341921mr30691939pll.67.1620216361378; Wed, 05 May 2021 05:06:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620216361; cv=none; d=google.com; s=arc-20160816; b=ZZRgCo+WTYQTuj4mGsyVIvtoqZqc/+asqQo6A8AAp2cJTW2TZmYxpbePA5Z8SEMgST yWaUdiL8MP3nD9ZybhN3+QCX2Ov5NhJMARpFXbsNifyjxsK45+o75DK/9nqOPUw2O9A/ ygvFHUi4YeT66rF1yQy+OfzSEJCryWQ+YNSN/oUYCZrLqj3LzJTXq5hS4/eLLYIRQmqq wvcPdmDkNWye6EhZZ9diNrSW42b5IzpSOEYOJ0TEVYcvT0WaVw3CXh0GfgNWUqUfBfJO S0h9e6/MybSCjN1fBID7lWH3AeVrCZS8C+EB1iPHxeETODy5TmE0mfxvJtvvB3uFuj2f Xs/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-hdrordr; bh=+gH0VAhS77yOc/rdOq7/pB4pbYr9SxQvPAddqs/fCI0=; b=eUJBHIhpves/IRungoF0Hsw8ZdlkHSsIGVNNmPYx/iXq1jw9otDCd1NM9DsIf54dpU sjBmKIBrNoxVdWKi2vqFY3AgUhlA2rMEbRhzHFz2SjlI2leO0VtdDSKtKlIwXwub8M5G 3GcX5ydMzEoSDLUZBri8yEhaF26q1PhsJEvBJPfcSnG692hPMO18eHOMda4rhGM8HDJT 8DZypm8V5nbFSuNSb7IdBtbc+zthRRFOtxtr3yww6f4FXet9lfI6WkG7oXNdkzxysPjS SJ2RRVeXK+3MEY33sjfnd3S41nNpgOkxFy8bQCFtO+60rC8n6aw01G7L0xDFJWHoNnRh +arQ== ARC-Authentication-Results: i=1; mx.google.com; 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 g17si8060696pge.164.2021.05.05.05.05.38; Wed, 05 May 2021 05:06:01 -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; 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 S232925AbhEELaC (ORCPT + 99 others); Wed, 5 May 2021 07:30:02 -0400 Received: from relay2.uni-heidelberg.de ([129.206.119.212]:45457 "EHLO relay2.uni-heidelberg.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbhEELaA (ORCPT ); Wed, 5 May 2021 07:30:00 -0400 X-IPAS-Result: =?us-ascii?q?A2A8AACOgJJg/1BqzoFaGwEBAQEBAQEBBQEBARIBAQEDA?= =?us-ascii?q?wEBAUCBRgMBAQELAYMMa2uERK0MgXMBAQEBAQEBAQEJMQECBAEBhFCBfwIlN?= =?us-ascii?q?wYOAgQBAQEDAgMBAQEBAQYBAQEBAQYEgQSFXYZFBiMEUhAlAh8HAgIUKCETh?= =?us-ascii?q?XmpBX8zgQGIMoELI4EQKgGLOYJNgieBFYNgg38JHDuCejaCKwSCQAdZNb4zB?= =?us-ascii?q?6AxAg4nlEuQVwEtkimhJIVAgWqBfTM+gzhQGQ6OVo4YQi84AgYKAQEDCVkBA?= =?us-ascii?q?Yw0A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jl pt0qMWjbaagwyzIW8njOlQCiwWVE2nRJZ9SCWMfsF9h63icgAYdxb7uRWqzzUIPlfM22pXrG r7NiGQcezMGTNmywNl+5ev1kh1eGWbd193cVZgv+RGZDj7k0c27MvOXI2P6S+qTmY6q9ttbQ 3taScOIw9o2tC83AOUnjHHDnk92pAyJIXmfcYeWqCW1XW3JIKSk6YaW/dS4ZZ+Ldjr9vQGSO SFZmauXX/FIvJs3wyevXA+PiZo7HEijPPzwRXghVLIlkIXEL7XIF58QascLMzZ52/4R+yQ2J E8id4up+O/PiHwbdGBoJunIgJrO1fWoWSsSfsvpo0RtaUutKFrF52eSCDWzhh8rVwDBdaxkF lbTLVw4bjHNIMqd8sOezhB9l5skNiUNkMkvgH/H+dWRyBjs1bLe9eSp7bYo7smBUOM4BH9Pl SS6CVR9fbIVSnr789QN4sgZWBNLEQs4nVr++2PM5DKAAKxbudZ4R60NGS+fLI1ctnKJZwA6h Jhp9eGkO+ce3CmhETevT5nLrlP9GjiS8WoGw6IEfNJ9dv/OVnkuNrc3OejyDPsDT28YAAEgI cAc0oaZMFKkCMjg406yTLacN2+nms1119FpSh6nVvs0JW86GjVHUtaIRTU668mKQV7IzyNl4 DZ6uCW23T2/Shd1ZTCHElWeMtSG9J4dPmAEw5+bc4KvLCp+KIzgiNMJBc2ZlRM/QzA4w== X-IronPort-Anti-Spam-Filtered: true Received: from lemon.iwr.uni-heidelberg.de ([129.206.106.80]) by relay2.uni-heidelberg.de with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 05 May 2021 13:29:03 +0200 Received: from hlauer by lemon.iwr.uni-heidelberg.de with local (Exim 4.92) (envelope-from ) id 1leFiA-0001eS-H6; Wed, 05 May 2021 13:29:02 +0200 Date: Wed, 5 May 2021 13:29:02 +0200 From: Hermann.Lauer@uni-heidelberg.de To: Chen-Yu Tsai Cc: sre@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] power: supply: axp20x_battery: implement writeable status to enable/disable battery charging Message-ID: <20210505112902.GC5302@lemon.iwr.uni-heidelberg.de> References: <20210421090354.GF19953@lemon.iwr.uni-heidelberg.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Maintainers, this patch allows enabling/disabling charging for the axp209 PMIC through a writeable status property. This works on the axp209 of Banana {Pi M1+,Pro}. I have no access to the other chips the driver deals with. Thanks to ChenYu for the idea and greetings Hermann Signed-off-by: Hermann.Lauer@uni-heidelberg.de --- drivers/power/supply/axp20x_battery.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c --- a/drivers/power/supply/axp20x_battery.c +++ b/drivers/power/supply/axp20x_battery.c @@ -40,6 +40,7 @@ #define AXP209_FG_PERCENT GENMASK(6, 0) #define AXP22X_FG_VALID BIT(7) +#define AXP20X_CHRG_CTRL1_ENABLE BIT(7) #define AXP20X_CHRG_CTRL1_TGT_VOLT GENMASK(6, 5) #define AXP20X_CHRG_CTRL1_TGT_4_1V (0 << 5) #define AXP20X_CHRG_CTRL1_TGT_4_15V (1 << 5) @@ -468,7 +469,17 @@ case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: return axp20x_set_max_constant_charge_current(axp20x_batt, val->intval); + case POWER_SUPPLY_PROP_STATUS: + switch (val->intval) { + case POWER_SUPPLY_STATUS_CHARGING: + return regmap_update_bits(axp20x_batt->regmap, AXP20X_CHRG_CTRL1, + AXP20X_CHRG_CTRL1_ENABLE, AXP20X_CHRG_CTRL1_ENABLE); + case POWER_SUPPLY_STATUS_DISCHARGING: + case POWER_SUPPLY_STATUS_NOT_CHARGING: + return regmap_update_bits(axp20x_batt->regmap, AXP20X_CHRG_CTRL1, + AXP20X_CHRG_CTRL1_ENABLE, 0); + } default: return -EINVAL; } @@ -491,7 +502,8 @@ static int axp20x_battery_prop_writeable(struct power_supply *psy, enum power_supply_property psp) { - return psp == POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN || + return psp == POWER_SUPPLY_PROP_STATUS || + psp == POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN || psp == POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN || psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT || psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX;