From patchwork Thu May 4 09:30:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hermes Zhang X-Patchwork-Id: 90024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp176351vqo; Thu, 4 May 2023 02:38:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5poUzFNcjGSvux2yK19V0W2LtQtnedLMw+P+ZcjgaR1gDyYnr8ELnFSAYPiWM1IxRpOuS5 X-Received: by 2002:a05:6a00:218a:b0:63b:67d5:be9c with SMTP id h10-20020a056a00218a00b0063b67d5be9cmr2043663pfi.29.1683193116098; Thu, 04 May 2023 02:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683193116; cv=none; d=google.com; s=arc-20160816; b=OOUZeJv+VB0MhuaVjhTPY1Wgow3ghxI4BdfkRwh5uTXjvqPEOkgokbbwCeD0DcfuqU iENB87wxHkaBUkGIY0M6UfcRnOV4XwXQPFgfkK4ZNgcBugLCsehrCGxKTW+E3gAlikui Bt/Fyfz5toaOFZPMWw3fgAc9SJeXvSc/zg9/823tAeSlrFtmrKXWmla8BJnNFPbErx5W eMXYxPs8JFF5yl4jWqPnT0H5IYZzjqaZVzXd0fQwefi6n15TRl4pMUh4rHhIFso84YQh E99aUjZ+k9EvVzOtoqgLTsy390RxhN7ZjvsptVZ87/ODJlanoBO6rzlstL59mE1+2fqQ 7jEg== 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=xTuVk6d/jrXuaIb/XYcfnjgJyJ+p5y/gtLPxLnYpBYc=; b=xSibcwH5B6+XwOAaJ0viz7pirb9HKv63ppmU5hFJaY7B3IPIp31Xu4B5JAnr9QuO0Y bAZYLhtGZ1Ea2ADKY4XLOhFo9ZwXD8iLw0XYl/My1SChknaHVUi0H99+28qWVsMVB7xH GalzjO8WoIfG67xz8c329NjoyT/tk4JuASpu93KNqi5st3TKnZ756CoQ3dbSPM5UWlEy BgvU0c7jorhCJfRopl64035xYWiRVgKa0IHfhJtiAhP+z3XkPm4/ZmZLl8GE195O1+Tg Jr9DNnhFvf4oM2F6BOSWi3w7Qcuvtxvipbuvq9FuChZc1DIfST8ZE4b+kfxUMEpia8pX 4kGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=a3M3uutB; 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 x24-20020a63db58000000b00520d737cf49si35320816pgi.271.2023.05.04.02.38.23; Thu, 04 May 2023 02:38:36 -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=a3M3uutB; 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 S230369AbjEDJa7 (ORCPT + 99 others); Thu, 4 May 2023 05:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbjEDJay (ORCPT ); Thu, 4 May 2023 05:30:54 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 191A98F; Thu, 4 May 2023 02:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1683192652; x=1714728652; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xTuVk6d/jrXuaIb/XYcfnjgJyJ+p5y/gtLPxLnYpBYc=; b=a3M3uutBJu7f1inuj05buueZ7ytf2tD+fbaVYqGvmIVbyQOwQM1o6VTF fuDUwYl9BVR7zAED4ySBmkcdKwDoRiwmcu/PvWFwNJuw9Pwm/XRdsYAMP szMsGpf3URL0caoOqTbbkscVNApZ9CWxvuskobTaPX5OcUlzsLzQwyaae Zd0XTe6U7EzPXEG+HBcg1JiZreIC6m7e1TwiWZrI11pTc7kF1gX4Ih5EL Y5dmDBWcKaF1gubP19sjlWf0FmUER7twwogP56ZOOI7Dr8kZeamKsv1NA sd0w8RFdJ/ggC21MbciAzn7dAjLsQaPYrz3R35cpChLJyph82+4jv3jHh g==; From: Hermes Zhang To: , , Rob Herring , Andrew Davis CC: , , Hermes Zhang , Krzysztof Kozlowski , , Subject: [PATCH v5 1/2] dt-bindings: power: supply: bq256xx: Add ti,no-thermistor property Date: Thu, 4 May 2023 17:30:36 +0800 Message-ID: <20230504093037.2056146-2-chenhuiz@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230504093037.2056146-1-chenhuiz@axis.com> References: <20230504093037.2056146-1-chenhuiz@axis.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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?1764955904958171713?= X-GMAIL-MSGID: =?utf-8?q?1764955904958171713?= 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 Reviewed-by: Krzysztof Kozlowski --- Notes: v2: change property name to ti,no-thermistor v3: drop "|" in property description v4: rebase bq256xx_charger.c v5: add Reviewed-by tag from Krzysztof Kozlowski .../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 May 4 09:30:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hermes Zhang X-Patchwork-Id: 90030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp180813vqo; Thu, 4 May 2023 02:49:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4InwH/DSujdWfdH7D8EDveE86dW7XpZOSv8IBhoRdSeO3JlktziEW69lm3rHYuksvRAGW+ X-Received: by 2002:a05:6a20:54a1:b0:f0:71d0:153f with SMTP id i33-20020a056a2054a100b000f071d0153fmr2141882pzk.14.1683193769083; Thu, 04 May 2023 02:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683193769; cv=none; d=google.com; s=arc-20160816; b=KZ5+Z1ZBYBCTWJ55rLKoT0R1FN8ZuGUL1Zmzp0t02Nmx6g5wXh06xsU7NFPb7auVWl jvUEGkYy12mrhnIJ55GfP9E3R6rc+LSHpVko4m7wnQEQx87ESV9nTUiefPZwrFYS+Z/L z/aHzfPEVObvx2P/Eh2X8NJWwdtOGB2Z2CZUGjmZXsFqcZ2PQ9oVyZLigJtsK2IcAGSs MyP0+KlYIRJr4WWaIeFg677+LvCz/lvZtsujZRRgr9UwXlzaCqkF2wrcSGrVd5bRfjCU qrnsTLJTA5EJncC7//A8AJjsmc6aOVwaSjXSpoAfyEbt5yv/l/7OmlOtHLjDwt8/evZL gUyQ== 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=jjCnpEYTLJY9M80b6fAjW9uq9fqde0uLR4TTY9DxBBs=; b=mWRdKwoxXOGasCGC372uSmkeZBWoXxrbtH+OtT0cbH/VTQVuT1bx5Nb5hzbjZIb/TU ezn1jCHLpzyN9x973L4qDjRlPsd254uVNL4Xt1DCwBkQA9jfDWLRpXqn1uNlvkoxqs8G 72/i3MyuFADDfV9ioFHW5xmeWN7duC1unhZKon8NTQuNiTsRoNaYMir3WzDAU/vRzCZ2 bcOXhwSq50pGjBLKg4KSnpmXqmUjV/n3H9ClO84id6zyKTJMpJrXdQuAmEgsCm1r5z64 +vLbPGaP3Pbq+iZAlmBzTU6K3lerC87i+6z9hJL57G9Xi4j98qPL2UwrwD7bQ+2tH4PO 4f8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=BaiDI1GD; 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 bm18-20020a656e92000000b005189417e923si36098078pgb.882.2023.05.04.02.49.13; Thu, 04 May 2023 02:49:29 -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=BaiDI1GD; 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 S230411AbjEDJba (ORCPT + 99 others); Thu, 4 May 2023 05:31:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbjEDJbY (ORCPT ); Thu, 4 May 2023 05:31:24 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23B1449CA; Thu, 4 May 2023 02:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1683192670; x=1714728670; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jjCnpEYTLJY9M80b6fAjW9uq9fqde0uLR4TTY9DxBBs=; b=BaiDI1GD17l24nYK+kL+uAhIUfZsl5QMWimGxidbj4Cx8Lyt+9K8xm8p gQusaz+12tbc9/7ZNceXlCR20lfq2AKSLgcabrLjEOcxnp6dEVgqnEcYd Xto0e7ycDd5DB43/MzZqV5TDUiTrUiY49R4RjlMWddk9hgu343EDVPA7v g8+2kHwrb6LCwLrLY4//YYAdpRNAmLOy3osekFRwGfTMUt2hkJQF9g1r+ 0iULrPz1KHPzPUcdSRc/ieL1bs4RzZap/bFvhxHPz5tgoKNOQDp9sPUOd eS+N0L3m4DxIc5RaKJrx4Fc4XcnOH3xP3RHPxyRDwbdm6TdwI8vsr/OpK Q==; From: Hermes Zhang To: , CC: , , Hermes Zhang , Subject: [PATCH v5 2/2] power: supply: bq256xx: Apply TS_IGNORE from devicetree Date: Thu, 4 May 2023 17:30:37 +0800 Message-ID: <20230504093037.2056146-3-chenhuiz@axis.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230504093037.2056146-1-chenhuiz@axis.com> References: <20230504093037.2056146-1-chenhuiz@axis.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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?1764956590016401061?= X-GMAIL-MSGID: =?utf-8?q?1764956590016401061?= 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 v4: rebase bq256xx_charger.c v5: add Reviewed-by tag from Krzysztof Kozlowski 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 @@ -156,6 +159,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; @@ -166,6 +170,7 @@ struct bq256xx_init_data { u32 vindpm; u32 ichg_max; u32 vbatreg_max; + bool ts_ignore; }; /** @@ -263,6 +268,7 @@ struct bq256xx_device { * @bq256xx_set_iprechg: pointer to instance specific set_iprechg function * @bq256xx_set_vindpm: pointer to instance specific set_vindpm function * @bq256xx_set_charge_type: pointer to instance specific set_charge_type 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 @@ -295,6 +301,7 @@ struct bq256xx_chip_info { int (*bq256xx_set_iprechg)(struct bq256xx_device *bq, int iprechg); int (*bq256xx_set_vindpm)(struct bq256xx_device *bq, int vindpm); int (*bq256xx_set_charge_type)(struct bq256xx_device *bq, int type); + int (*bq256xx_set_ts_ignore)(struct bq256xx_device *bq, bool ts_ignore); int bq256xx_def_ichg; int bq256xx_def_iindpm; @@ -696,6 +703,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; @@ -1312,6 +1325,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, @@ -1351,6 +1365,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_charge_type = bq256xx_set_charge_type, + .bq256xx_set_ts_ignore = NULL, .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1382,6 +1397,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_charge_type = bq256xx_set_charge_type, + .bq256xx_set_ts_ignore = NULL, .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1413,6 +1429,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_charge_type = bq256xx_set_charge_type, + .bq256xx_set_ts_ignore = NULL, .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1444,6 +1461,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_charge_type = bq256xx_set_charge_type, + .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore, .bq256xx_def_ichg = BQ25611D_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1475,6 +1493,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iprechg = bq25618_619_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_charge_type = bq256xx_set_charge_type, + .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore, .bq256xx_def_ichg = BQ25618_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1506,6 +1525,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = { .bq256xx_set_iprechg = bq25618_619_set_prechrg_curr, .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, .bq256xx_set_charge_type = bq256xx_set_charge_type, + .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore, .bq256xx_def_ichg = BQ25618_ICHG_DEF_uA, .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, @@ -1622,6 +1642,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; @@ -1656,6 +1682,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; }