From patchwork Wed Dec 11 07:29:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau via B4 Relay X-Patchwork-Id: 13903052 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A70861C5F00; Wed, 11 Dec 2024 07:29:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733902174; cv=none; b=ds17KKtDNwq3jRfqScR3YXpnWFTR3A8uQ7UbFusiZKHZh8DhFztaBt7fDsKej9I09VEf0aJhridCua6mbx0WlLZ6lW06kNjKTkEoNySRmzDUcWo0tk0QS1oDmpxAzlpmgVBQnlJvV7EAmbXXxYJkRxab8/LAtXzWnp8D8XOwVHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733902174; c=relaxed/simple; bh=9vAnAd2QwKydelMDaBCoKBb1aZfGFP/9QHN/QjRUQWU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kQtrSu8XrHrHOfnACzhW3cvUyBpW+W8j/xBrPlGC4/d2hP9tbOQVQSKlMDM78EWbh9wPRS2Dkh6zGFpKza0iHB0E6tHdIZKZRbQvlzfYV7ZN42o4slyCqZHHAKF+I2AK1ovExUOToVJfX+bTJS5Iy2wiWCmNr9ljZXYjRvS1tvg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=esERtU2b; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="esERtU2b" Received: by smtp.kernel.org (Postfix) with ESMTPS id 36E11C4CEE0; Wed, 11 Dec 2024 07:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733902174; bh=9vAnAd2QwKydelMDaBCoKBb1aZfGFP/9QHN/QjRUQWU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=esERtU2bYfpXYc0VQSkD9XSUIFlP23vO7DOlrnzPnxqZwqZWBRWKxpeUaI2lx7XeW 4nFv+t4HxRlKaY+4OpgPWFxiIHqP6BZUEaqrc/ncCWzoX9xuuHOQY+cPIYMeNIGNTm aZFscoGwIRjhS3oyShsFpn5N0qQMt5dRChu70PZMZTUzCBJZCZEC0BmEm7YJ+Y40gl LAwc7PkVgmw8ZLuL/fuuFm+ipDicIUND1XkDQpOKUM9c07UEX4eM9eKBL73k4KN9/j fAavjTZ02H3qPs1DOd3S9CCcmQ/A2Exvlj+17umAb8faOGv0UYjGAkGNidoJYHfmSF HMT4TOF45NBUQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13057E77180; Wed, 11 Dec 2024 07:29:34 +0000 (UTC) From: Dimitri Fedrau via B4 Relay Date: Wed, 11 Dec 2024 08:29:09 +0100 Subject: [PATCH 1/2] dt-bindings: power: supply: gpio-charger: add support for default charge current limit Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241211-default-charge-current-limit-v1-1-7819ba06ee2a@liebherr.com> References: <20241211-default-charge-current-limit-v1-0-7819ba06ee2a@liebherr.com> In-Reply-To: <20241211-default-charge-current-limit-v1-0-7819ba06ee2a@liebherr.com> To: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Dimitri Fedrau , Dimitri Fedrau X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733902172; l=942; i=dimitri.fedrau@liebherr.com; s=20241202; h=from:subject:message-id; bh=Pxa2UR9+jiJf91z+v5TVU4+c8Xt5Dl0NVFgqfKJqVu4=; b=u37K86IYjQzBWwkt1ZG7stCRoxjAK/KU//ICWnpPcv+Gu3I/b2+JEDN6Lh4igcLFXsr7RXnsd W4WNCm1lSpwBRqlTf6uCAsr2J8P6h0DEqF9sJQDMOwgT2/tTYJ4/pR8 X-Developer-Key: i=dimitri.fedrau@liebherr.com; a=ed25519; pk=rT653x09JSQvotxIqQl4/XiI4AOiBZrdOGvxDUbb5m8= X-Endpoint-Received: by B4 Relay for dimitri.fedrau@liebherr.com/20241202 with auth_id=290 X-Original-From: Dimitri Fedrau Reply-To: dimitri.fedrau@liebherr.com From: Dimitri Fedrau Add binding for default charge current limit. Signed-off-by: Dimitri Fedrau --- Documentation/devicetree/bindings/power/supply/gpio-charger.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml b/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml index 89f8e2bcb2d7836c6a4308aff51721bd83fa3ba1..545fdd7133daf67b5bc238c5af26d0cbd8b44eae 100644 --- a/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml +++ b/Documentation/devicetree/bindings/power/supply/gpio-charger.yaml @@ -58,6 +58,10 @@ properties: charge-current-limit-gpios property. Bit 1 second to last GPIO and so on. + charge-current-limit-default: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Default charge current limit in uA. + required: - compatible From patchwork Wed Dec 11 07:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Fedrau via B4 Relay X-Patchwork-Id: 13903053 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A71311C5F0C; Wed, 11 Dec 2024 07:29:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733902174; cv=none; b=G6IxB13x9eshP1UEdF7nBLraI8xNYQQ3T5QenbMdPSmYPzzJG4QrSa8+b7Hq2tWyQVTqsCmPge4+iM74OcsJVL2yBCw6OzAuit+qKZuM6OuoGzmACfINHgwaKYi/NtwibseJbRJaLcpCWTqlyghoakzGvTg5DNgynFKM65humGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733902174; c=relaxed/simple; bh=kE9grQmLn6LHMLUwo50GIjdSNUInWEzzqpTKkKa/hkc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pWZDScTYEu08I0Y3PQJNCDEnL5b53jkZ6wIGiSqKXxn+aAaH+od6jkqbjSkbODjEdtPIPA2c5e7y+sljFviLq5DHqKVvqCqmNHHXTVWrxTczCAMgaY4ANmgW8eAJRphQ5/nfna2veGJIaBUMFVOUyhNo2k/kW2oO+bI30wDu0zw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OQtqNQ5i; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OQtqNQ5i" Received: by smtp.kernel.org (Postfix) with ESMTPS id 46846C4CEDF; Wed, 11 Dec 2024 07:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733902174; bh=kE9grQmLn6LHMLUwo50GIjdSNUInWEzzqpTKkKa/hkc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=OQtqNQ5i83nJoTgEiQRuOvahuc+ongdQ8RMDh6WVZcHY6Nt8P2k4hkzeoUaYok5Zl kNnnp/5WUBjy8daGfUrsO9LuUCNdBYWrvWJwGh0qLzHNogLaBEvSpZkyebVhQB+CSt oJU4Gk2KJtMJsh3PtUoL2fz+DvxUZTxlr76+veAKNIgYyyZXPz8iVN+NB5jdFE0Cuu YKYWwVn/I3ilhYHMGL4SfQQeVP/uN53u7y2LLE3iBYji4DmjAxBr9elmO2xIrWCHyI tIJRkeFkt+2H99iiGtxyCQPJHIA5K+juoKMbelGsgJvlp1AqtxBIIv2hp0WGADBFqd io+ch03Tp0ecg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22782E77183; Wed, 11 Dec 2024 07:29:34 +0000 (UTC) From: Dimitri Fedrau via B4 Relay Date: Wed, 11 Dec 2024 08:29:10 +0100 Subject: [PATCH 2/2] power: supply: gpio-charger: add support for default charge current limit Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241211-default-charge-current-limit-v1-2-7819ba06ee2a@liebherr.com> References: <20241211-default-charge-current-limit-v1-0-7819ba06ee2a@liebherr.com> In-Reply-To: <20241211-default-charge-current-limit-v1-0-7819ba06ee2a@liebherr.com> To: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Dimitri Fedrau , Dimitri Fedrau X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733902172; l=1905; i=dimitri.fedrau@liebherr.com; s=20241202; h=from:subject:message-id; bh=5B4rPOB+5702QfWy45U125DyTvkQjxqeDuDwvqB5EFA=; b=l8QShK3uZiH18nY4r7xOEo4cv0gfqVRaW/2J265DhezaihkaAy0HwBwCqQ+G6mRZfyWcwg0Sa 0VNOLf+2hZQD7E3yzorunI2tX/1KVje4RqETuOmCDQ7PLRD3q3h3ut6 X-Developer-Key: i=dimitri.fedrau@liebherr.com; a=ed25519; pk=rT653x09JSQvotxIqQl4/XiI4AOiBZrdOGvxDUbb5m8= X-Endpoint-Received: by B4 Relay for dimitri.fedrau@liebherr.com/20241202 with auth_id=290 X-Original-From: Dimitri Fedrau Reply-To: dimitri.fedrau@liebherr.com From: Dimitri Fedrau The driver defaults to smallest current limitation for safety reasons. Add support for setting default current limitation via DT. Signed-off-by: Dimitri Fedrau --- drivers/power/supply/gpio-charger.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/power/supply/gpio-charger.c b/drivers/power/supply/gpio-charger.c index 68212b39785beabfe5536a18fa15bc249f7b1eea..1c1fce6579464b61dbaf4125d0a91dc34c18c4d0 100644 --- a/drivers/power/supply/gpio-charger.c +++ b/drivers/power/supply/gpio-charger.c @@ -187,6 +187,8 @@ static int init_charge_current_limit(struct device *dev, { int i, len; u32 cur_limit = U32_MAX; + bool set_def_limit; + u32 def_limit; gpio_charger->current_limit_gpios = devm_gpiod_get_array_optional(dev, "charge-current-limit", GPIOD_OUT_LOW); @@ -220,6 +222,9 @@ static int init_charge_current_limit(struct device *dev, if (len < 0) return len; + set_def_limit = !device_property_read_u32(dev, + "charge-current-limit-default", + &def_limit); for (i=0; i < gpio_charger->current_limit_map_size; i++) { if (gpio_charger->current_limit_map[i].limit_ua > cur_limit) { dev_err(dev, "charge-current-limit-mapping not sorted by current in descending order\n"); @@ -227,8 +232,16 @@ static int init_charge_current_limit(struct device *dev, } cur_limit = gpio_charger->current_limit_map[i].limit_ua; + if (set_def_limit && def_limit == cur_limit) { + set_charge_current_limit(gpio_charger, cur_limit); + return 0; + } } + if (set_def_limit) + dev_warn(dev, "charge-current-limit-default %u not listed in charge-current-limit-mapping\n", + def_limit); + /* default to smallest current limitation for safety reasons */ len = gpio_charger->current_limit_map_size - 1; set_charge_current_limit(gpio_charger,