From patchwork Thu Mar 23 07:23:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hermes Zhang X-Patchwork-Id: 73869 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2769831wrt; Thu, 23 Mar 2023 00:36:03 -0700 (PDT) X-Google-Smtp-Source: AK7set9dJTIIiTw/vNyU3l+/LKLMNwzm7T492oebRAWK9O+oi0LanJjmsznQlSx0NOJyU17sOSpW X-Received: by 2002:aa7:d610:0:b0:4fd:c5e:79b8 with SMTP id c16-20020aa7d610000000b004fd0c5e79b8mr10519566edr.32.1679556963013; Thu, 23 Mar 2023 00:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679556962; cv=none; d=google.com; s=arc-20160816; b=fYGFZVxvYRleLLqRxGWjYC9vzjBvgncShf9rjgyzfqB7SKo09TFkPGGWZa9JuGI+gW 8rQRBIwc18zbtKQ37Hlf7FuXMo44+zVna2bmgjjNi8fXqP+ReSSyf68eDVzUw9jIQ4A7 K7BbRPUzfXw7kZQNz3GqiJe5EJIzURVoDIg2EeNj3eIU/KH7gkmpdIZpz60iX8qxJd6N FPpHOoN7iQkSS2MyoianoYDQ9bW3xL/yPt+noos4hx4IA8Ah0r8unLM5KtZ2g1HvgXN/ V6qjxZtzxz8yfhbqT3F+6y0ugljMfHYxIvsNX4i6PPhtSRLw6z1t20l9zqlB+wh1hFN/ Ph9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SvXAG2jDNuLCJnrfLAviQ8j1hoAX9mmEncQJwxlEACw=; b=EIFct8t5//uH2cfmNVJ5NiXp6VIrM6xH/RAU1mdukuHNjwekdFaykNVeOUelT+bo9E U4N03UbV+Tp4bNJkwlrwdMnX2wI2Q7eZWRkH+uFEWt+uZOYFqnmp89VGpCtgBiA+b01v t9+dK6QYniegza/xQaLjZED4pBNNKFlHsD/QeJQLph70kMpNA+T6EMCiBGevdK+AO1VO bHSQAS0eFkf5OZbNQSWOjMWGu3yQyQQxFDlAASnV0wRtGNBHqd8ht7QEss6Jj/llEWyv FzVrYJ6efFJFXhv7l8vIPrylsD/SSvP9u8S94FHjITgCdbRVv5kDwt4eUHcBFCay0p3y lIPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=Eqt+OyVx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n25-20020a170906119900b00930f71275d5si14853079eja.941.2023.03.23.00.35.39; Thu, 23 Mar 2023 00:36:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=Eqt+OyVx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbjCWHYD (ORCPT + 99 others); Thu, 23 Mar 2023 03:24:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjCWHYC (ORCPT ); Thu, 23 Mar 2023 03:24:02 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D880DD314; Thu, 23 Mar 2023 00:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1679556237; x=1711092237; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=SvXAG2jDNuLCJnrfLAviQ8j1hoAX9mmEncQJwxlEACw=; b=Eqt+OyVxzUyDqxDmnHAWClEllrOlWq+Zm/tYjYYAdgQjQ0Ruh+snSilw whAWKu7i8Z2RuU/elIQfXq6wrcXDbYrF2Hi7jLbCX7chboxciLtH43Tdb 5Yjkpcgk9WZEUc/9LOikUzuTHK+8Na8IIC961xe79aYNnAvOrFEoLjg5Z hNHewz8NsgzYVoWWJoLUmO7n0u829IHOdJ3Pktoxtz4LEzJNQGNBxOE+u HwsAfvjkg5dwwzPzjHFLxbcTVAjiHw6DkiRzlc76J5Tj192/h9e1YnCPL lcDg30A3aQjP/kj/dHLxoOauJAYamqiM5aJUfwLfj9nt2FZP0m8vNM0Eo A==; From: Hermes Zhang To: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Andrew Davis CC: , , Hermes Zhang , , Subject: [PATCH v3 1/2] dt-bindings: power: supply: bq256xx: Add ti,no-thermistor property Date: Thu, 23 Mar 2023 15:23:46 +0800 Message-ID: <20230323072347.438932-1-chenhuiz@axis.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761143122129198819?= X-GMAIL-MSGID: =?utf-8?q?1761143122129198819?= Add a new property ti,no-thermistor to indicate that no thermistor is connected to the TS pin of the chip. Signed-off-by: Hermes Zhang --- Notes: v2: change property name to ti,no-thermistor v3: drop "|" in property description .../bindings/power/supply/bq256xx.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml index 82f382a7ffb3..4fe9c3705265 100644 --- a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml @@ -68,11 +68,29 @@ properties: Interrupt sends an active low, 256 μs pulse to host to report the charger device status and faults. + ti,no-thermistor: + type: boolean + description: Indicates that no thermistor is connected to the TS pin + required: - compatible - reg - monitored-battery +allOf: + - if: + properties: + compatible: + contains: + enum: + - ti,bq25600 + - ti,bq25601 + - ti,bq25600d + - ti,bq25601d + then: + properties: + ti,no-thermistor: false + additionalProperties: false examples: From patchwork Thu Mar 23 07:23:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Zhang X-Patchwork-Id: 73865 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2766974wrt; Thu, 23 Mar 2023 00:27:12 -0700 (PDT) X-Google-Smtp-Source: AK7set8NK6XCcb5dAWS2AG3onh/oz35Z61Zq+/5bhEpB4SsJOhLTxE2lkcsyMvmmNe1X/iJPgPXD X-Received: by 2002:a17:906:b7d7:b0:937:9a24:370b with SMTP id fy23-20020a170906b7d700b009379a24370bmr8887309ejb.67.1679556431825; Thu, 23 Mar 2023 00:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679556431; cv=none; d=google.com; s=arc-20160816; b=A2+UsqrV5eWM5bvAcHuzN+ufVkJNYQYE9qYRjtqg8UJOuE75dNQylzUAyAhpJiHWTr nh+E4QoDRbGeljU0D9Qp+rfB3/eXHgnU/xQR2qLlgtewawyWqKnOiTluB/L93+NgQDAv G5ste5NEFkN+QR3/IDqrGX9DUHGLQ8NxVWNyLNamoxduv6Umk+QHXuex+uE30R8UJUcA +y9A3wwZFaltaBlNKvcg5QFketzrknADM3SBY0ZgEEZBVJgteQbNxMUvsBQ/zGpzbPi2 G6NwVFQscbQ1VfAF9yHWMFMAb8hmJDLrk3RAk+dOrVAmnqHdN7ssJ7SeoBbsAzG9ZrKI QEeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=U5FeI+aG2h+MviWYRg4Ym0QkhQ+gjHx8yklsv2kVRUc=; b=C+2D/cG2Yvd+MQ//bkHacz+0dAq7Mftt1Vkl8z9dXVxyUV220t6aLPEdxZPHlOZs9z knMWiZ4NE4RBnEburok05ItdUWN0pckn+RF55WKKfr4G9xpJYc4d/8oWF1L6CcGfI8EA ZhYgFhbzu2yyzsDznCN7XV3pJ3MAPSJo7CDX+IGFBObFpwQY4y+ABeAzOMztaWSAqecT Abw0q6JMNKrLj/EEiZp64tSxOU2oD4r4PwCTvZpD5z9bP9vySPuAkTp4wa4FmpvGvLDd zwcS0QEeJcdCClbRQDKkQORwoGi5KKl9NGR5XPsylI4EddvBNmn9Fj+E2mlDQinZ0nKn emhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=gYGzml+K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg3-20020a170907970300b0093112944d07si21295355ejc.44.2023.03.23.00.26.47; Thu, 23 Mar 2023 00:27:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=gYGzml+K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229773AbjCWHY4 (ORCPT + 99 others); Thu, 23 Mar 2023 03:24:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230310AbjCWHYx (ORCPT ); Thu, 23 Mar 2023 03:24:53 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07FEFEF86; Thu, 23 Mar 2023 00:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1679556269; x=1711092269; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=U5FeI+aG2h+MviWYRg4Ym0QkhQ+gjHx8yklsv2kVRUc=; b=gYGzml+KO+WdWAGIFt4B33LOUGoktl5pCg5Rgz4U7ztxIcWToTOSPg8k asqtqKtzW07r9nAS/pFPM0shybX7l38gb3D0JF+/5Rvbtreuy9DFi8HYb gYOzQSeZa6c70ykovWAZnJ4osCRytOxf91b/7M7TWnVT+unkq0apVnCjO /IwA8Z0AFT0Di/48fIgK2eqzyFVo/aorQnylZ0I8UU5SvgZ/ZcY5/QGwW xmFvaaPE7Qja22PonX1K4KY2ZrAZGCdx3PiZ+pHcnjbmuUqLpIQbNMc6F Tm9xnEP/u1hJ30Pb8TLwRHMky9vvQVqdK3YBrPMf78dj/vG112JqbWIQl A==; From: Hermes Zhang To: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Andrew Davis CC: , , Hermes Zhang , , Subject: [PATCH v3 2/2] power: supply: bq256xx: Apply TS_IGNORE from devicetree Date: Thu, 23 Mar 2023 15:23:47 +0800 Message-ID: <20230323072347.438932-2-chenhuiz@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230323072347.438932-1-chenhuiz@axis.com> References: <20230323072347.438932-1-chenhuiz@axis.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761142564738482691?= X-GMAIL-MSGID: =?utf-8?q?1761142564738482691?= TS_IGNORE is default off in bq256xx chip. For some HW which doesn't have the NTC, we need to set TS_IGNORE to 1 to make the charge work. The new "ti,no-thermistor" is introduced to toggle it. Signed-off-by: Hermes Zhang --- Notes: v2: change property name to ti,no-thermistor v3: drop "|" in property description drivers/power/supply/bq256xx_charger.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c index 9cf4936440c9..cacaae1d559b 100644 --- a/drivers/power/supply/bq256xx_charger.c +++ b/drivers/power/supply/bq256xx_charger.c @@ -41,6 +41,9 @@ #define BQ256XX_IINDPM_MAX_uA 3200000 #define BQ256XX_IINDPM_DEF_uA 2400000 +#define BQ256XX_TS_IGNORE BIT(6) +#define BQ256XX_TS_IGNORE_SHIFT 6 + #define BQ256XX_VINDPM_MASK GENMASK(3, 0) #define BQ256XX_VINDPM_STEP_uV 100000 #define BQ256XX_VINDPM_OFFSET_uV 3900000 @@ -153,6 +156,7 @@ * @vindpm: input voltage limit * @ichg_max: maximum fast charge current * @vbatreg_max: maximum charge voltage + * @ts_ignore: TS_IGNORE flag */ struct bq256xx_init_data { u32 ichg; @@ -163,6 +167,7 @@ struct bq256xx_init_data { u32 vindpm; u32 ichg_max; u32 vbatreg_max; + bool ts_ignore; }; /** @@ -259,6 +264,7 @@ struct bq256xx_device { * @bq256xx_set_iterm: pointer to instance specific set_iterm function * @bq256xx_set_iprechg: pointer to instance specific set_iprechg function * @bq256xx_set_vindpm: pointer to instance specific set_vindpm function + * @bq256xx_set_ts_ignore: pointer to instance specific set_ts_ignore function * * @bq256xx_def_ichg: default ichg value in microamps * @bq256xx_def_iindpm: default iindpm value in microamps @@ -290,6 +296,7 @@ struct bq256xx_chip_info { int (*bq256xx_set_iterm)(struct bq256xx_device *bq, int iterm); int (*bq256xx_set_iprechg)(struct bq256xx_device *bq, int iprechg); int (*bq256xx_set_vindpm)(struct bq256xx_device *bq, int vindpm); + int (*bq256xx_set_ts_ignore)(struct bq256xx_device *bq, bool ts_ignore); int bq256xx_def_ichg; int bq256xx_def_iindpm; @@ -670,6 +677,12 @@ static int bq25601d_set_chrg_volt(struct bq256xx_device *bq, int vbatreg) BQ256XX_VBATREG_BIT_SHIFT); } +static int bq256xx_set_ts_ignore(struct bq256xx_device *bq, bool ts_ignore) +{ + return regmap_update_bits(bq->regmap, BQ256XX_INPUT_CURRENT_LIMIT, + BQ256XX_TS_IGNORE, (ts_ignore ? 1 : 0) << BQ256XX_TS_IGNORE_SHIFT); +} + static int bq256xx_get_prechrg_curr(struct bq256xx_device *bq) { unsigned int prechg_and_term_curr_lim; @@ -1279,6 +1292,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_get_iterm = bq256xx_get_term_curr, .bq256xx_get_iprechg = bq256xx_get_prechrg_curr, .bq256xx_get_vindpm = bq256xx_get_input_volt_lim, + .bq256xx_set_ts_ignore = NULL, .bq256xx_set_ichg = bq256xx_set_ichg_curr, .bq256xx_set_iindpm = bq256xx_set_input_curr_lim, @@ -1316,6 +1330,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iterm = bq256xx_set_term_curr, .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, + .bq256xx_set_ts_ignore = NULL, .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1346,6 +1361,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iterm = bq256xx_set_term_curr, .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, + .bq256xx_set_ts_ignore = NULL, .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1376,6 +1392,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iterm = bq256xx_set_term_curr, .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, + .bq256xx_set_ts_ignore = NULL, .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1406,6 +1423,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iterm = bq256xx_set_term_curr, .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, + .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore, .bq256xx_def_ichg = BQ25611D_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1436,6 +1454,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iterm = bq25618_619_set_term_curr, .bq256xx_set_iprechg = bq25618_619_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, + .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore, .bq256xx_def_ichg = BQ25618_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1466,6 +1485,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iterm = bq25618_619_set_term_curr, .bq256xx_set_iprechg = bq25618_619_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, + .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore, .bq256xx_def_ichg = BQ25618_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1582,6 +1602,12 @@ static int bq256xx_hw_init(struct bq256xx_device *bq) if (ret) return ret; + if (bq->chip_info->bq256xx_set_ts_ignore) { + ret = bq->chip_info->bq256xx_set_ts_ignore(bq, bq->init_data.ts_ignore); + if (ret) + return ret; + } + power_supply_put_battery_info(bq->charger, bat_info); return 0; @@ -1616,6 +1642,8 @@ static int bq256xx_parse_dt(struct bq256xx_device *bq, if (ret) bq->init_data.iindpm = bq->chip_info->bq256xx_def_iindpm; + bq->init_data.ts_ignore = device_property_read_bool(bq->dev, "ti,no-thermistor"); + return 0; }