Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp334512lqh; Fri, 31 May 2024 02:48:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrEYsPIJ5T/XfePHn9iXSjQMIugExxw7+r96znQWOdYLWhGU4Ns9BoV9j27Dyo2wnCrJ70NqlaX5xiDntUoHV0nZKKH4e/KA0dOV73Nw== X-Google-Smtp-Source: AGHT+IHwOTw3osctrzRZ3VrnE6Np7noRziGG4DigZwsHCCfNFwDVypoTCJPf38geXctCI5a2kzjQ X-Received: by 2002:a17:903:2342:b0:1f4:8358:47d5 with SMTP id d9443c01a7336-1f636fc5375mr15117255ad.7.1717148904502; Fri, 31 May 2024 02:48:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717148904; cv=pass; d=google.com; s=arc-20160816; b=kYH+NiZC1Q/5S2zQzAxRHokZJn4VYFtRieuu1aq2RwpsifdDiUSUYRYw5e0DhsTNWJ Ys4ojBU5iyt72DDEWQ0hMIosHxIlxLnC37nhuu3wX53ei+A7UrKDsx8ssK4kEjE2j6hK 8GABHyQzuuPjZGnW79p2RvTVxN4/EbSZVU1y2zLAfwrwO2cHG6kOpOKN7iuL9rVsWYal nQCg4zjiOp8fpdwWXOq+lMy0NcDzLaay8HVx2hBfhcKac/Zj+Vnxsezvo/P/NJ54SKQo 7Z4tGEosj1i05VNAZ6ngsO19xeqwU2jB5s/g7u208ouS71aziSjQghCCW4sEyqtv1w1N k12g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=erMNflkXkxaRMmXHRUTV3gldoBv3D8NnSJjARqL+zFw=; fh=ylcVy5KY3iICrPqUdbWwOp/E129+4WKkxGHtK7JY+xM=; b=Asjhl5gRe+u5jmD21GELqO++nXWOTlVWXMrmafcmXyNT+B5sa36PFK+fDe8B0pVFqh H+CGD5INHy/VJBsJXR0AuMiegpY4Cyok2wjoZExTnfGp7nfj4DYzGRwA0TlGRD7QaKbx hYRnUNVWzbS9QmTnrC63+z04kabFFiGwpBZCWoKyVTfR6SDc9EexmgX66TLyYM84Io9d 0ED+XH54Nc2v280U8vsRkUUE0QJNnhslLi5YJdRrRdyftxdHJ1aRDw2sRgMJuf7+WSII iRWJMkfHlnj3U1ljceozEfAq8Zgi99EBgB4eSItxDh+Y00iWs6OkwLp3ppDWRtuQioX7 Ya6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MtJccM8H; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196622-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6323dd568si12886375ad.242.2024.05.31.02.48.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 02:48:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MtJccM8H; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196622-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 19A5B285968 for ; Fri, 31 May 2024 09:48:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 891841420D5; Fri, 31 May 2024 09:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MtJccM8H" 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 7B05878C69; Fri, 31 May 2024 09:47:53 +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=1717148873; cv=none; b=cqUrW1sLEC8Dp6t3veMGzC67jEkh/Q7l+maAMO9U+HEdZa9Xm/LfS541F4/ZGCqy5kkNndr4z3l+OWjZH8y1T/ePifaXhKJ4uF1Qu0KHoaTwj2pqKeaTvlLIV0bc/2bBH8kCHDPdGy7fsbSeM/KEgY8LkfQKTPeK4qItEd6dB1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717148873; c=relaxed/simple; bh=0AqNLvKpg/geJIUQwuuG7BWkHpEirvzj8sd+Eo2HCbs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NZjxZkkdJ+SGdHIOx8QYI7Xzennq5DBZwJ9xoIyktb2SfwwIV4qiutWbP60/M6XujJxiXYUw/fVXay7lP+QmhytnU4oWsRt9OPY0nq9FV0n3NILT5SNeVAC3KopCA0MtwqPnX246HbXJP6cA1kmTm5U+l30iRzh9pKEx+8Q9NCo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MtJccM8H; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B96BCC116B1; Fri, 31 May 2024 09:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717148873; bh=0AqNLvKpg/geJIUQwuuG7BWkHpEirvzj8sd+Eo2HCbs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=MtJccM8H82DKhcLR/0SkystafddpIZhrxib+SWKxcXaZro5clMJtZ3dh5yqthHZBp KQmoZWs7/Po4lA53a3Vzrpbzt98YufIqh0UlM1pkenZA7zUsM8POH3QzPibMcLU6pn TvWKkv+TshtkwIMCAlw/htI2QM2t9Bfm/NlgGwUVZiLTlWVY6Mzj0Su/QdMuwM7luS 3b19+bjNwR1bfNv0HoMI/0EYiRjmIsYlgntnO2ysAO75Ls8BNDX8vDYso1tDa4ozu0 a3+BUL0KOHR3SodPbesbZLQKPJAUZ+enEYdZYmWqx8giq3xMZGLtIR2t01gFtE1nIx 8lTcO3iDTjnig== Message-ID: Date: Fri, 31 May 2024 11:47:46 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC 06/11] power: supply: max77693: Set charge current limits during init To: Artur Weber , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli References: <20240530-max77693-charger-extcon-v1-0-dc2a9e5bdf30@gmail.com> <20240530-max77693-charger-extcon-v1-6-dc2a9e5bdf30@gmail.com> From: Krzysztof Kozlowski Content-Language: en-US Autocrypt: addr=krzk@kernel.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZoV+Bd5kWvN79 cFgcqTTuNHjAvxtUG8pQgGTHAObYs6xeYJtjUH0ZX6ndJ33FJYf5V3yXqqjcZ30FgHzJCFUu JMp7PSyMPzpUXfU12yfcRYVEMQrmplNZssmYhiTeVicuOOypWugZKVLGNm0IweVCaZ/DJDIH gNbpvVwjcKYrx85m9cBVEBUGaQP6AT7qlVCkrf50v8bofSIyVa2xmubbAwwFA1oxoOusjPIE J3iadrwpFvsZjF5uHAKS+7wHLoW9hVzOnLbX6ajk5Hf8Pb1m+VH/E8bPBNNYKkfTtypTDUCj NYcd27tjnXfG+SDs/EXNUAIRefCyvaRG7oRYF3Ec+2RgQDRnmmjCjoQNbFrJvJkFHlPeHaeS BosGY+XWKydnmsfY7SSnjAzLUGAFhLd/XDVpb1Een2XucPpKvt9ORF+48gy12FA5GduRLhQU vK4tU7ojoem/G23PcowM1CwPurC8sAVsQb9KmwTGh7rVz3ks3w/zfGBy3+WmLg++C2Wct6nM Pd8/6CBVjEWqD06/RjI2AnjIq5fSEH/BIfXXfC68nMp9BZoy3So4ZsbOlBmtAPvMYX6U8VwD TNeBxJu5Ex0Izf1NV9CzC3nNaFUYOY8KfN01X5SExAoVTr09ewARAQABzSVLcnp5c3p0b2Yg S296bG93c2tpIDxrcnprQGtlcm5lbC5vcmc+wsGVBBMBCgA/AhsDBgsJCAcDAgYVCAIJCgsE FgIDAQIeAQIXgBYhBJvQfg4MUfjVlne3VBuTQ307QWKbBQJgPO8PBQkUX63hAAoJEBuTQ307 QWKbBn8P+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g9hmCEuNSr+CLMdnRBY fv0= In-Reply-To: <20240530-max77693-charger-extcon-v1-6-dc2a9e5bdf30@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 30/05/2024 10:55, Artur Weber wrote: > There are two charger current limit registers: > > - Fast charge current limit (which controls current going from the > charger to the battery); > - CHGIN input current limit (which controls current going into the > charger through the cable, and is managed by the CHARGER regulator). > > Add functions for setting both of the values, and set them to a > safe default value of 500mA at initialization. > > The default value for the fast charge current limit can be modified > by setting the maxim,fast-charge-current-microamp DT property; the > CHGIN input current limit will be set up later in the charger detection > mechanism. > > Signed-off-by: Artur Weber > --- > drivers/power/supply/max77693_charger.c | 45 +++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > > diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c > index 894c35b750b3..d59b1524b0a4 100644 > --- a/drivers/power/supply/max77693_charger.c > +++ b/drivers/power/supply/max77693_charger.c > @@ -28,6 +28,7 @@ struct max77693_charger { > u32 min_system_volt; > u32 thermal_regulation_temp; > u32 batttery_overcurrent; > + u32 fast_charge_current; > u32 charge_input_threshold_volt; > }; > > @@ -591,6 +592,35 @@ static int max77693_set_batttery_overcurrent(struct max77693_charger *chg, > CHG_CNFG_12_B2SOVRC_MASK, data); > } > > +static int max77693_set_input_current_limit(struct max77693_charger *chg, > + unsigned int uamp) > +{ > + dev_dbg(chg->dev, "CHGIN input current limit: %u\n", uamp); That's quite useless debug. It duplicates max77693_set_fast_charge_current(). Just drop entire wrapper. > + > + return regulator_set_current_limit(chg->regu, (int)uamp, (int)uamp); > +} > + > +static int max77693_set_fast_charge_current(struct max77693_charger *chg, > + unsigned int uamp) > +{ > + unsigned int data; > + > + data = (uamp / 1000) * 10 / 333; /* 0.1A/3 steps */ > + > + if (data > CHG_CNFG_02_CC_MASK) { > + dev_err(chg->dev, "Wrong value for fast charge current\n"); > + return -EINVAL; > + } > + > + data <<= CHG_CNFG_02_CC_SHIFT; > + > + dev_dbg(chg->dev, "Fast charge current: %u (0x%x)\n", uamp, data); > + > + return regmap_update_bits(chg->max77693->regmap, > + MAX77693_CHG_REG_CHG_CNFG_02, > + CHG_CNFG_02_CC_MASK, data); I am surprised that you set current limit via regulator but actual charging current value here. I think both should go to regulator in such case. > Best regards, Krzysztof