Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1360484pxb; Sat, 30 Oct 2021 11:35:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCRpWMvmkQ0N1kCHQ0B4U53rzaqH8ji8eBOwRvsAWUAVBdfUmi52YoYxbrkSLrY3J8N0I1 X-Received: by 2002:a05:6402:1348:: with SMTP id y8mr26243326edw.35.1635618912159; Sat, 30 Oct 2021 11:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635618912; cv=none; d=google.com; s=arc-20160816; b=OdKtVvucNkoQrtg3KDvWlMmTVmR5hZswHqrG3cBkF+XuG7roUPPj3T1RZdRrj2p92E oiE6F1te5XcCqc+F3KwEzIEmujFVbl3v+4CgSDxglDBWZy4Azt9fnvcH1Hf2ICdSYt4z VHuLVn9ttqAXsvjw6WgxZm9lOp0w60zJBEAns9YhkCsUV14oDKNihFewgYbZPLqKGPq3 yduaiy6hllwlrSIFOAhnVrSq5uvQzPBDFAoZirsGuAzvxolrJPOiMMo8ZQNycjjYP5Ng RytI/gLPKJOXKvV3TaJAXHZWLoBsDvuxOcHcjxQS41dwvG1GcZT0F5TiL62SoGbaZGko B+qA== 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=v+AVB+iQtmAvSP/G/6vABVHFG7BeK3k8Ncl4QBHM/dc=; b=WgRyn2tPjvJPfe+/qFmCQpDAhmfxG/xebEFvv7tvvfK3MYzOjYGd4xtmQLKSyHTEqk Ia4BpgDXJiP+MSqtVs7ylIrRON7LpmwXQtqU/MkrEzWBBYMQHpXAxisblcsyrhziLsqm EIcB1Z2uzUJaO4Aa9NQEAvOUGnxfQ3rUarnjER3rbLkvlJN/eP7Ja1zYnpPoLfTC2T1v dcDXqJixCcqLIh40FPFL6gmMHdAO5NDwK1MHBh/m5xYJaS95kxlAJoZ216ciCTXgkmAW LMvDoLkmG3r0alYKK2WmXcuWdT6UjN1hrbwalp4HmcYq2oNUrZv9TuKG2+xH6dVC/4K3 4KDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bjA4gsM2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si14342820edi.381.2021.10.30.11.34.47; Sat, 30 Oct 2021 11:35:12 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bjA4gsM2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbhJ3SdO (ORCPT + 99 others); Sat, 30 Oct 2021 14:33:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25088 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232037AbhJ3SbM (ORCPT ); Sat, 30 Oct 2021 14:31:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635618521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v+AVB+iQtmAvSP/G/6vABVHFG7BeK3k8Ncl4QBHM/dc=; b=bjA4gsM2HXcR674pkSI5MDHD/sovuLOHCqLdZ3Z2jA3tgRs2d7rWJB5BcWyxgdd6MXAA00 76xpaXeui4uA9rHwXDEfZ2SHfH+N+FgSw5jOjuPD8D7CIbx2vg5trL6AobyaLJQ83cbD88 KhCxK3CnW6uMfS4+omgC4x5z2LLfUJU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-OGzIgCvkO62ic-hRyno7HQ-1; Sat, 30 Oct 2021 14:28:38 -0400 X-MC-Unique: OGzIgCvkO62ic-hRyno7HQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1ED1B1808317; Sat, 30 Oct 2021 18:28:36 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5736B5F4E1; Sat, 30 Oct 2021 18:28:33 +0000 (UTC) From: Hans de Goede To: Mark Gross , Andy Shevchenko , Wolfram Sang , Sebastian Reichel , MyungJoo Ham , Chanwoo Choi , Ard Biesheuvel Cc: Hans de Goede , Yauhen Kharuzhy , Tsuchiya Yuto , platform-driver-x86@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: [PATCH 06/13] power: supply: bq25890: Add support for skipping initialization Date: Sat, 30 Oct 2021 20:28:06 +0200 Message-Id: <20211030182813.116672-7-hdegoede@redhat.com> In-Reply-To: <20211030182813.116672-1-hdegoede@redhat.com> References: <20211030182813.116672-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On most X86/ACPI devices there is no devicetree to supply the necessary init-data. Instead the firmware already fully initializes the bq25890 charger at boot. At support for a new "ti,skip-init" boolean property to support this. So far this new property is only used on X86/ACPI (non devicetree) devs, IOW it is not used in actual devicetree files. The devicetree-bindings maintainers have requested properties like these to not be added to the devicetree-bindings, so the new property is deliberately not added to the existing devicetree-bindings. Signed-off-by: Hans de Goede --- drivers/power/supply/bq25890_charger.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 1ec93a565631..280821a6a6c6 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -73,6 +73,7 @@ enum bq25890_fields { /* initial field values, converted to register values */ struct bq25890_init_data { + u8 write_cfg; /* write firmware cfg to chip? */ u8 ichg; /* charge current */ u8 vreg; /* regulation voltage */ u8 iterm; /* termination current */ @@ -638,7 +639,7 @@ static int bq25890_chip_reset(struct bq25890_device *bq) static int bq25890_rw_init_data(struct bq25890_device *bq) { - bool write = true; + bool write = bq->init_data.write_cfg; int ret; int i; @@ -682,10 +683,12 @@ static int bq25890_hw_init(struct bq25890_device *bq) { int ret; - ret = bq25890_chip_reset(bq); - if (ret < 0) { - dev_dbg(bq->dev, "Reset failed %d\n", ret); - return ret; + if (bq->init_data.write_cfg) { + ret = bq25890_chip_reset(bq); + if (ret < 0) { + dev_dbg(bq->dev, "Reset failed %d\n", ret); + return ret; + } } /* disable watchdog */ @@ -920,6 +923,10 @@ static int bq25890_fw_probe(struct bq25890_device *bq) int ret; struct bq25890_init_data *init = &bq->init_data; + init->write_cfg = !device_property_read_bool(bq->dev, "ti,skip-init"); + if (!init->write_cfg) + return 0; + ret = bq25890_fw_read_u32_props(bq); if (ret < 0) return ret; @@ -1033,8 +1040,10 @@ static int bq25890_remove(struct i2c_client *client) if (!IS_ERR_OR_NULL(bq->usb_phy)) usb_unregister_notifier(bq->usb_phy, &bq->usb_nb); - /* reset all registers to default values */ - bq25890_chip_reset(bq); + if (bq->init_data.write_cfg) { + /* reset all registers to default values */ + bq25890_chip_reset(bq); + } return 0; } -- 2.31.1