From patchwork Sat Jan 23 22:18:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 369459 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2687552jam; Sat, 23 Jan 2021 14:20:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSajOLUEyzBSHTuFdViJHMiCH/huQP5GlN86SZnsNNM6uuxYq7rFf4r3UG1mrz6Kaf33dW X-Received: by 2002:a05:6402:13c8:: with SMTP id a8mr260975edx.191.1611440436796; Sat, 23 Jan 2021 14:20:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611440436; cv=none; d=google.com; s=arc-20160816; b=c7hKR0BPaBsQ2+jw+edZ4tKRdJq4rBRAcyapaOv7SRbZLDBap0vku70A3YIUyAPbVb btOqIqdh8EoYHF2PV7sTDJGGh1/tq7KSbH28zkAJSq5R1ms9Z83FAkcijiZO8YUIMgpz +k1Kw6lKSgR5V0N2nI4AZReC6lSd0ACtXbtoGKKgkBzvUTJKJxN91XzJBuwRxeOzHwxZ UPC0pInSW8uDDu/5RJ2FkCHJhnKmSAx5rYTYv1ElUFSYWfzSwscYrCph5pZ0k7U2vMIV He1llUkmgxnCnxYbe3YzMBS5cmQizwomO4gLRQ/tnpDm0Bl24Ru1fvHq0SQcW8d9snmX EUag== 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=5zILsjb5YiuKMvmLjiNfcPgv+rGP6ByymYCZbye6VpE=; b=bh7ZcengZ+JYEMOzFBJaH7i0eSzOeGFuT9icnrFX4YZKgRLOiUE+3zQVViIpE17UFx vMkd8/+TiYKQuz//YHjZemr3dkyiCSJxEDpen0x+6CJF36ktUGd9GMCT2M1gVwGug2df 8rKBxCsiR6bt9VBOZBNmO9J7SL+Rnbbacp5eVASPr7L9pKpn/Vyk69tkaTf38P5kpUwb IvSDyOxhUYYeo9iE43hVsuo69Bor4Vom/49er2BpnxJpZJmSay19tCpf4qz/rS0gquGb k7rgw5Rl9ZeBOecpIXn8Eanf9FLUC7mXN/VyQayo1JCFcXANwtu35+G4O74lkFXbt0oU GQBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cwFFGxmY; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w3si5278360edr.427.2021.01.23.14.20.36; Sat, 23 Jan 2021 14:20:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=cwFFGxmY; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726288AbhAWWUA (ORCPT + 7 others); Sat, 23 Jan 2021 17:20:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbhAWWT7 (ORCPT ); Sat, 23 Jan 2021 17:19:59 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF005C061786 for ; Sat, 23 Jan 2021 14:19:18 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id a8so12572011lfi.8 for ; Sat, 23 Jan 2021 14:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5zILsjb5YiuKMvmLjiNfcPgv+rGP6ByymYCZbye6VpE=; b=cwFFGxmY7lcebdOAfzrILpwepw6xR+OIFYwYXDB73h7JjCJqDMIDYZfQOKd2CvEziA a2s0E6VgLGwLKLAFAYJfmu+yAIQglpswYqmAkl2vLcx+hicPqRNn0rN56dTIh8eTY+h0 EMoqWJuooRqpZbhD3h+GUT2YDxOCoHp6cX4/q5FqrEEG7B1/0ktOnuYXx84Lzvj92BMG lCcAwbpd2sF8dzScj3i8XTuCm6SoFovh+cHjmExiQxOvLLMeqVwTOPPL9JR//Vy6zYV2 B9uGvuu1qRzqaN0hzoKm33RhB6rYEKZlZiTj/HEuneD8alX2QR8jCNsgKOCCbqvnIg78 P7uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5zILsjb5YiuKMvmLjiNfcPgv+rGP6ByymYCZbye6VpE=; b=PiQH/w7K4P+0eDZNxD/wRN6hkBoCbqbbEOa0E7jCKI94izg4/3WlE2R8Vpab8W2ye1 PH9nA/WvX9pJrrARcCMgIv+bQlGY0LMMaUlMQygixPNMg07hw+ZUfc1kma89mWhPz/ij NvH1YC1KOUIJ/KMYcx1WvPblOi5/ZXVzJI9z/YB0Ku1KPGU5LXSYPSw55DKBfMA+G4ZN LENPfQMrF4Hbnb+JrSQDwPJ2kCsm2rrSMZuDpCemD6Xz6uUyeLsx1HxkTQdpFdm23ZCF siYND81rnCrzCPIOROPk1EE6Ca2e4JFLZnxZnDcVmNysa/JZBgBEGtjGjeJtO/LRsTys OnRw== X-Gm-Message-State: AOAM531z2F0brifiymtlzFXsdUgVQX/0s5GcQR9HfuPvnl4IuNVL6ECP O1/JRB1Ws/molEHNC6DpX2SlOA== X-Received: by 2002:ac2:52a8:: with SMTP id r8mr183707lfm.17.1611440357440; Sat, 23 Jan 2021 14:19:17 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x17sm1313956lfg.0.2021.01.23.14.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 14:19:17 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Lee Jones , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 01/10] power: supply: ab8500: Require device tree Date: Sat, 23 Jan 2021 23:18:59 +0100 Message-Id: <20210123221908.2993388-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210123221908.2993388-1-linus.walleij@linaro.org> References: <20210123221908.2993388-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The core AB8500 driver and the whole platform is completely dependent on being probed from device tree so remove the non-DT probe paths. Signed-off-by: Linus Walleij --- drivers/power/supply/Kconfig | 2 +- drivers/power/supply/ab8500_btemp.c | 10 ++++------ drivers/power/supply/ab8500_charger.c | 15 ++++++--------- drivers/power/supply/ab8500_fg.c | 10 ++++------ drivers/power/supply/abx500_chargalg.c | 10 ++++------ 5 files changed, 19 insertions(+), 28 deletions(-) -- 2.29.2 diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index eec646c568b7..0f617e10dfb7 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -677,7 +677,7 @@ config BATTERY_GAUGE_LTC2941 config AB8500_BM bool "AB8500 Battery Management Driver" - depends on AB8500_CORE && AB8500_GPADC && (IIO = y) + depends on AB8500_CORE && AB8500_GPADC && (IIO = y) && OF help Say Y to include support for AB8500 battery management. diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c index d20345386b1e..3cec0affd866 100644 --- a/drivers/power/supply/ab8500_btemp.c +++ b/drivers/power/supply/ab8500_btemp.c @@ -1008,12 +1008,10 @@ static int ab8500_btemp_probe(struct platform_device *pdev) } di->bm = plat; - if (np) { - ret = ab8500_bm_of_probe(dev, np, di->bm); - if (ret) { - dev_err(dev, "failed to get battery information\n"); - return ret; - } + ret = ab8500_bm_of_probe(dev, np, di->bm); + if (ret) { + dev_err(dev, "failed to get battery information\n"); + return ret; } /* get parent data */ diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index ac77c8882d17..aa573cd299e2 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -3360,15 +3360,12 @@ static int ab8500_charger_probe(struct platform_device *pdev) } di->bm = plat; - if (np) { - ret = ab8500_bm_of_probe(dev, np, di->bm); - if (ret) { - dev_err(dev, "failed to get battery information\n"); - return ret; - } - di->autopower_cfg = of_property_read_bool(np, "autopower_cfg"); - } else - di->autopower_cfg = false; + ret = ab8500_bm_of_probe(dev, np, di->bm); + if (ret) { + dev_err(dev, "failed to get battery information\n"); + return ret; + } + di->autopower_cfg = of_property_read_bool(np, "autopower_cfg"); /* get parent data */ di->dev = dev; diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 3873e4857e3d..9d734fd2b48f 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -3043,12 +3043,10 @@ static int ab8500_fg_probe(struct platform_device *pdev) } di->bm = plat; - if (np) { - ret = ab8500_bm_of_probe(dev, np, di->bm); - if (ret) { - dev_err(dev, "failed to get battery information\n"); - return ret; - } + ret = ab8500_bm_of_probe(dev, np, di->bm); + if (ret) { + dev_err(dev, "failed to get battery information\n"); + return ret; } mutex_init(&di->cc_lock); diff --git a/drivers/power/supply/abx500_chargalg.c b/drivers/power/supply/abx500_chargalg.c index a9d84d845f24..591ddd2987a3 100644 --- a/drivers/power/supply/abx500_chargalg.c +++ b/drivers/power/supply/abx500_chargalg.c @@ -1997,12 +1997,10 @@ static int abx500_chargalg_probe(struct platform_device *pdev) } di->bm = plat; - if (np) { - ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); - if (ret) { - dev_err(&pdev->dev, "failed to get battery information\n"); - return ret; - } + ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); + if (ret) { + dev_err(&pdev->dev, "failed to get battery information\n"); + return ret; } /* get device struct and parent */ From patchwork Sat Jan 23 22:19:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 369460 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2687557jam; Sat, 23 Jan 2021 14:20:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAaNcVOwoDIk5s+7sj+ui6how0PKJ07Pfc3X0o3Y5/xOwKOjqN/1ht3s4ZpeJfy+/xjjss X-Received: by 2002:a50:cd8c:: with SMTP id p12mr1048004edi.380.1611440437176; Sat, 23 Jan 2021 14:20:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611440437; cv=none; d=google.com; s=arc-20160816; b=vUhL0CCXH4lzOR/oci611Df8gzJXPvQT20S2aISCKVZOp6bjUeMjHnLw/3RZciyqww bAuYLLXp/ikjDVpPHoWgbllhQzIiO+7rigsu2jyJ9FFhc7HFiDFczUY98DYfp5Y0+DmT GZb93oSd4Gmtu8SytLQdJCKqATDMckH/ayN+srnqJxUinnW8G4DDK7CCCnePXGUS4gAe LWa1U+HbhP63ybiH7XAmHChz2JkSjM5KMV4X0GGdyjYtaQebG1GBTVAoV6NA822OLidx 57G685HJcIp8VnAlr4WQtMVHj1mBqiyUy0KCX9IiIWw8Sk6sSSDKPOyqlldoGiyr6AEF 9C2g== 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=1+S3c+wvfRymwP+4pXmUkEQAcVBLlJgeBZ+xbX9vFio=; b=wSWGniuVm642noD7YgwQfwokjY1/DKaMdQhnlZ7v/6o44hlnd84jCaHElLem8DjwL3 HF5raP9tH2Bf7WhJYMhtVeisLoFV/6SRbNPs9Fpq72x/rkHQrwB3bueQ/YwOZSZjrsRZ UvXcrN2HkBPyrLXocnUeCCtHlncA0cvRQxRcaSXEL7eZT1rqo5p7GVnxkWe5M/dCz665 KaFUbVH0x+HcFtdW9JehQ8L+OpjIA+VIGzSHGyQsCyZXh7fjPQ3ROIPZnwT+uGeFlvP/ 94+el8PUxhVH6mEmemdBocYBoj+cBSy8B9p7r3hJipAF9UmgMm6VygF+Nju/Ly13hfwz 8BRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="r9LFMr/v"; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w3si5278360edr.427.2021.01.23.14.20.37; Sat, 23 Jan 2021 14:20:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b="r9LFMr/v"; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726291AbhAWWUC (ORCPT + 7 others); Sat, 23 Jan 2021 17:20:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbhAWWUB (ORCPT ); Sat, 23 Jan 2021 17:20:01 -0500 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B6A3C061788 for ; Sat, 23 Jan 2021 14:19:21 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id 3so10797287ljc.4 for ; Sat, 23 Jan 2021 14:19:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1+S3c+wvfRymwP+4pXmUkEQAcVBLlJgeBZ+xbX9vFio=; b=r9LFMr/vNV7GKwBKDulhTms1FUaKBqlb9YQAjrj1l1AuH4M/48DNkwNZYypvbcHpof iJiGBuPxRrgVWlm43gzNQ/AvPQZmK7exRhEvEa3lHyuAvoVAFmuSdavB/9ViEZDELk4a p+K4qbM5KJttpsflA5GWRD3MPBW1xzw5DRLLw72d2HlHuktGhz3Pvnh8xPfbsdPwT5VN oo4K7yL41p7UXNV7NZspv3mdfGYVFMRI3dPLJ+8UScla4jzu+tvS9wzhydVBzd4cSccm 81ziF09qvT0+Gb1yIq4ujJM3j6+bfb8zjwAp7zPU6tKguqpLMbWjEO1kFdAxVE7xUfRp 0Q8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1+S3c+wvfRymwP+4pXmUkEQAcVBLlJgeBZ+xbX9vFio=; b=tq50a8HCHBdZ7wLSh+rjIRRkJt2wWMqQ198Cia7l7z2eDHBRLEZXqUBEYlm3ADQvaL Ml9MpUTB2Riu5vcsQjB569J0To9gaEpG8FnxXQ+SrMy2f8JdRLfJhjGI6JoRKHRUcO5R 4chZESmIws/C0fEIdxz4pKmZm9iqyzwORPjQeDIs2o65BKq8ZD8qX3IX86M0TbpJevef 3iQLpTzmemoXRDtab/CsMSTDakx0VKERnt9adfUeIBIfmbGBLo0VdRlJXIQB837IzzYn foSTaztRIsFulOGgoOM8vZrL2MbYb68fdiKghWsTNSV8HNGMI+k5X583mK7u7uIZdrjR tHVg== X-Gm-Message-State: AOAM531PFIYy5TKUCBV4YezvImH4tKBPBFfJW4YRMSSMGnIiFaHrkeeh poYJeF5gul5DtTTihQD8c7U5NQ== X-Received: by 2002:a2e:860f:: with SMTP id a15mr686824lji.411.1611440359553; Sat, 23 Jan 2021 14:19:19 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x17sm1313956lfg.0.2021.01.23.14.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 14:19:19 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Lee Jones , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 02/10] power: supply: ab8500: Push data to power supply code Date: Sat, 23 Jan 2021 23:19:00 +0100 Message-Id: <20210123221908.2993388-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210123221908.2993388-1-linus.walleij@linaro.org> References: <20210123221908.2993388-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The global definition of platform data for the battery management code has no utility after the OF conversion, move the to be a local file in drivers/power/supply and stop defining the platform data in drivers/power/supply/ab8500_bmdata.c and broadcast to the kernel only to have it assigned as platform data to the MFD cells and then picked back into the same subsystem that defined it in the first place. This kills off a layer of indirection. Signed-off-by: Linus Walleij --- drivers/mfd/ab8500-core.c | 17 +++++---- .../power/supply}/ab8500-bm.h | 19 ++-------- drivers/power/supply/ab8500_bmdata.c | 3 +- drivers/power/supply/ab8500_btemp.c | 35 +++---------------- drivers/power/supply/ab8500_charger.c | 10 ++---- drivers/power/supply/ab8500_fg.c | 10 ++---- drivers/power/supply/abx500_chargalg.c | 10 ++---- drivers/power/supply/pm2301_charger.c | 2 +- 8 files changed, 27 insertions(+), 79 deletions(-) rename {include/linux/mfd/abx500 => drivers/power/supply}/ab8500-bm.h (96%) -- 2.29.2 diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index ba8da061af0e..82db43b2b6f1 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -610,14 +609,14 @@ int ab8500_suspend(struct ab8500 *ab8500) } static const struct mfd_cell ab8500_bm_devs[] = { - MFD_CELL_OF("ab8500-charger", NULL, &ab8500_bm_data, - sizeof(ab8500_bm_data), 0, "stericsson,ab8500-charger"), - MFD_CELL_OF("ab8500-btemp", NULL, &ab8500_bm_data, - sizeof(ab8500_bm_data), 0, "stericsson,ab8500-btemp"), - MFD_CELL_OF("ab8500-fg", NULL, &ab8500_bm_data, - sizeof(ab8500_bm_data), 0, "stericsson,ab8500-fg"), - MFD_CELL_OF("ab8500-chargalg", NULL, &ab8500_bm_data, - sizeof(ab8500_bm_data), 0, "stericsson,ab8500-chargalg"), + MFD_CELL_OF("ab8500-charger", NULL, NULL, 0, 0, + "stericsson,ab8500-charger"), + MFD_CELL_OF("ab8500-btemp", NULL, NULL, 0, 0, + "stericsson,ab8500-btemp"), + MFD_CELL_OF("ab8500-fg", NULL, NULL, 0, 0, + "stericsson,ab8500-fg"), + MFD_CELL_OF("ab8500-chargalg", NULL, NULL, 0, 0, + "stericsson,ab8500-chargalg"), }; static const struct mfd_cell ab8500_devs[] = { diff --git a/include/linux/mfd/abx500/ab8500-bm.h b/drivers/power/supply/ab8500-bm.h similarity index 96% rename from include/linux/mfd/abx500/ab8500-bm.h rename to drivers/power/supply/ab8500-bm.h index 903e94c189d8..a1b31c971a45 100644 --- a/include/linux/mfd/abx500/ab8500-bm.h +++ b/drivers/power/supply/ab8500-bm.h @@ -1,12 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright ST-Ericsson 2012. - * - * Author: Arun Murthy - */ -#ifndef _AB8500_BM_H -#define _AB8500_BM_H +#ifndef _AB8500_CHARGER_H_ +#define _AB8500_CHARGER_H_ #include #include @@ -453,16 +448,11 @@ struct ab8500_bm_data { }; struct ab8500_btemp; -struct ab8500_gpadc; struct ab8500_fg; -#ifdef CONFIG_AB8500_BM extern struct abx500_bm_data ab8500_bm_data; void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); -struct ab8500_btemp *ab8500_btemp_get(void); -int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp); -int ab8500_btemp_get_temp(struct ab8500_btemp *btemp); struct ab8500_fg *ab8500_fg_get(void); int ab8500_fg_inst_curr_blocking(struct ab8500_fg *dev); int ab8500_fg_inst_curr_start(struct ab8500_fg *di); @@ -470,7 +460,4 @@ int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res); int ab8500_fg_inst_curr_started(struct ab8500_fg *di); int ab8500_fg_inst_curr_done(struct ab8500_fg *di); -#else -static struct abx500_bm_data ab8500_bm_data; -#endif -#endif /* _AB8500_BM_H */ +#endif /* _AB8500_CHARGER_H_ */ diff --git a/drivers/power/supply/ab8500_bmdata.c b/drivers/power/supply/ab8500_bmdata.c index f6a66979cbb5..c2b8c0bb77e2 100644 --- a/drivers/power/supply/ab8500_bmdata.c +++ b/drivers/power/supply/ab8500_bmdata.c @@ -4,7 +4,8 @@ #include #include #include -#include + +#include "ab8500-bm.h" /* * These are the defined batteries that uses a NTC and ID resistor placed diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c index 3cec0affd866..fdfcd59fc43e 100644 --- a/drivers/power/supply/ab8500_btemp.c +++ b/drivers/power/supply/ab8500_btemp.c @@ -25,9 +25,10 @@ #include #include #include -#include #include +#include "ab8500-bm.h" + #define VTVOUT_V 1800 #define BTEMP_THERMAL_LOW_LIMIT -10 @@ -119,16 +120,6 @@ static enum power_supply_property ab8500_btemp_props[] = { static LIST_HEAD(ab8500_btemp_list); -/** - * ab8500_btemp_get() - returns a reference to the primary AB8500 BTEMP - * (i.e. the first BTEMP in the instance list) - */ -struct ab8500_btemp *ab8500_btemp_get(void) -{ - return list_first_entry(&ab8500_btemp_list, struct ab8500_btemp, node); -} -EXPORT_SYMBOL(ab8500_btemp_get); - /** * ab8500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance * @di: pointer to the ab8500_btemp structure @@ -754,7 +745,7 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di, * * Returns battery temperature */ -int ab8500_btemp_get_temp(struct ab8500_btemp *di) +static int ab8500_btemp_get_temp(struct ab8500_btemp *di) { int temp = 0; @@ -790,19 +781,6 @@ int ab8500_btemp_get_temp(struct ab8500_btemp *di) } return temp; } -EXPORT_SYMBOL(ab8500_btemp_get_temp); - -/** - * ab8500_btemp_get_batctrl_temp() - get the temperature - * @btemp: pointer to the btemp structure - * - * Returns the batctrl temperature in millidegrees - */ -int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp) -{ - return btemp->bat_temp * 1000; -} -EXPORT_SYMBOL(ab8500_btemp_get_batctrl_temp); /** * ab8500_btemp_get_property() - get the btemp properties @@ -991,7 +969,6 @@ static const struct power_supply_desc ab8500_btemp_desc = { static int ab8500_btemp_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct abx500_bm_data *plat = pdev->dev.platform_data; struct power_supply_config psy_cfg = {}; struct device *dev = &pdev->dev; struct ab8500_btemp *di; @@ -1002,11 +979,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev) if (!di) return -ENOMEM; - if (!plat) { - dev_err(dev, "no battery management data supplied\n"); - return -EINVAL; - } - di->bm = plat; + di->bm = &ab8500_bm_data; ret = ab8500_bm_of_probe(dev, np, di->bm); if (ret) { diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index aa573cd299e2..50989a5ec95c 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -28,12 +28,13 @@ #include #include #include -#include #include #include #include #include +#include "ab8500-bm.h" + /* Charger constants */ #define NO_PW_CONN 0 #define AC_PW_CONN 1 @@ -3344,7 +3345,6 @@ static const struct power_supply_desc ab8500_usb_chg_desc = { static int ab8500_charger_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct abx500_bm_data *plat = pdev->dev.platform_data; struct power_supply_config ac_psy_cfg = {}, usb_psy_cfg = {}; struct ab8500_charger *di; int irq, i, charger_status, ret = 0, ch_stat; @@ -3354,11 +3354,7 @@ static int ab8500_charger_probe(struct platform_device *pdev) if (!di) return -ENOMEM; - if (!plat) { - dev_err(dev, "no battery management data supplied\n"); - return -EINVAL; - } - di->bm = plat; + di->bm = &ab8500_bm_data; ret = ab8500_bm_of_probe(dev, np, di->bm); if (ret) { diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 9d734fd2b48f..8a6d40623731 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -31,10 +31,11 @@ #include #include #include -#include #include #include +#include "ab8500-bm.h" + #define MILLI_TO_MICRO 1000 #define FG_LSB_IN_MA 1627 #define QLSB_NANO_AMP_HOURS_X10 1071 @@ -3026,7 +3027,6 @@ static const struct power_supply_desc ab8500_fg_desc = { static int ab8500_fg_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct abx500_bm_data *plat = pdev->dev.platform_data; struct power_supply_config psy_cfg = {}; struct device *dev = &pdev->dev; struct ab8500_fg *di; @@ -3037,11 +3037,7 @@ static int ab8500_fg_probe(struct platform_device *pdev) if (!di) return -ENOMEM; - if (!plat) { - dev_err(dev, "no battery management data supplied\n"); - return -EINVAL; - } - di->bm = plat; + di->bm = &ab8500_bm_data; ret = ab8500_bm_of_probe(dev, np, di->bm); if (ret) { diff --git a/drivers/power/supply/abx500_chargalg.c b/drivers/power/supply/abx500_chargalg.c index 591ddd2987a3..5b28d58041b4 100644 --- a/drivers/power/supply/abx500_chargalg.c +++ b/drivers/power/supply/abx500_chargalg.c @@ -29,9 +29,10 @@ #include #include #include -#include #include +#include "ab8500-bm.h" + /* Watchdog kick interval */ #define CHG_WD_INTERVAL (6 * HZ) @@ -1980,7 +1981,6 @@ static const struct power_supply_desc abx500_chargalg_desc = { static int abx500_chargalg_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct abx500_bm_data *plat = pdev->dev.platform_data; struct power_supply_config psy_cfg = {}; struct abx500_chargalg *di; int ret = 0; @@ -1991,11 +1991,7 @@ static int abx500_chargalg_probe(struct platform_device *pdev) return -ENOMEM; } - if (!plat) { - dev_err(&pdev->dev, "no battery management data supplied\n"); - return -EINVAL; - } - di->bm = plat; + di->bm = &ab8500_bm_data; ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); if (ret) { diff --git a/drivers/power/supply/pm2301_charger.c b/drivers/power/supply/pm2301_charger.c index ac06ecf7fc9c..5aeff75db33b 100644 --- a/drivers/power/supply/pm2301_charger.c +++ b/drivers/power/supply/pm2301_charger.c @@ -18,13 +18,13 @@ #include #include #include -#include #include #include #include #include #include +#include "ab8500-bm.h" #include "pm2301_charger.h" #define to_pm2xxx_charger_ac_device_info(x) container_of((x), \ From patchwork Sat Jan 23 22:19:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 369461 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2687561jam; Sat, 23 Jan 2021 14:20:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxErbxUUJZ/3rfaBO+6qPcNJphMMfZEmfrV9o7JzUMuhLW1MXP9+FSE640eo5/9gV4IkPl X-Received: by 2002:a17:906:796:: with SMTP id l22mr272523ejc.247.1611440437624; Sat, 23 Jan 2021 14:20:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611440437; cv=none; d=google.com; s=arc-20160816; b=fDYVSCpQsHa+q4pnSV95Gxk105vFWspelC0pvF1wJjvRjz9NvdNRIiB3lG+XBYihbL K+Yndq02tDi/oypeaFG/5NzQp4wwgEdmwudtfxbb5HqyF93wNQWAvYokwhgFEPVgAye4 80Jb/7ysKTnoK/kBwod3rQbmJbtyydI70ZsE10gS++aCwGFoUoQ+lUWqj0Sy7fbtP13k G+xUTLho5kobNknwSB0wLmvHUvUoBHrHOJ4xpnqJyxkhRCCb5bs6GqsIOamABxy1FJgp soql3YWee79tKk+XVScLaDzyli5yTYLM32IsmuTHz3IFY4lz5MotEVndDXtLKxR0lUlU WWLQ== 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=w3IZh6Sr3KpjXM0LqFQFqH1i8vaQmDVN35tRH7/mbAU=; b=j+CKMWe+7cL4RMQOn5S/7iiHTjLD7KSjHs/ZQqbFbH3hvuZzXQVQURUliYLi2H3nKW 5XTkdAwTz043F6CjkBAKaFFawzEe7WB8QOUP7o/oMMRmW4eLUmXUvr04YgterxQ6J0K2 v1ZIxEe8N0/k8x2jSgbE799vy9WSIGVQ/5X/4YywF9gHRiBcuT7xPlWvwsT+a7G62tzg cgPBOvemVVPVDqSifR79zVifPa4nM3r9YQ27bWsMcjrTbfdqKzeD0AMSACq8LvIEjOUa ZHh5b1zNaEQqnsqKziTQIg2gQZicrqu2L2sFnOg+SGMfRrQnyxoKUp2A6QmQykeYCsT7 X8TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pel+8Yp8; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w3si5278360edr.427.2021.01.23.14.20.37; Sat, 23 Jan 2021 14:20:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=Pel+8Yp8; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726294AbhAWWUE (ORCPT + 7 others); Sat, 23 Jan 2021 17:20:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbhAWWUD (ORCPT ); Sat, 23 Jan 2021 17:20:03 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C04FAC06178B for ; Sat, 23 Jan 2021 14:19:22 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id q8so12556665lfm.10 for ; Sat, 23 Jan 2021 14:19:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w3IZh6Sr3KpjXM0LqFQFqH1i8vaQmDVN35tRH7/mbAU=; b=Pel+8Yp8fo5WhTw+yETNHp9WPuCEQufhXwbqQa7SsblscnjE91i15m2h0/YN/sAz7e uTCfOWnOQy0zSjJHGhKPgaoQClVC35lJHLYWN1na5G8SnTD6hvvj/3wMrUnPclqY7lNi QbI+j01ssiMQBnD4KUbwznLjPfGw08sREh4pjx7wlMUGXkrPwvgABXqFVGQFKqzZgFh6 3b+3cR3Nq2Mq1cYmajnxgMA2qN69Moxtx0G1rfSJERgKKt3gtLuaXze8vVGwspudYnSl GbwSUnQec0GdNGkrd+07W+KgzNtoH++PP0vkDo4XsDsy38ORzkvsMrWES6HSoW4vH4uD ikBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w3IZh6Sr3KpjXM0LqFQFqH1i8vaQmDVN35tRH7/mbAU=; b=gK44xwNOCg3Ku/7Jdmbg/iGnhQ/1Ii9UXMqBv4aShArZAtACrpQF+vo9M8w0uYkveX LXeGx8imu4ksT3ef6+evMM96e+3UODLib/s35Wf1f78ZebBlmKiawXBJ/QjVkOmbA4EJ rRZs+yeLxevciJBq9HJTPtK69rG+5Ydicg/CuDdvuklyy99q/p4vj0a26rg8C0HDbsDi mn9MvZ5OR0pCtnh/rqxUrYDPuTA0ClHecrCwuei5gzehqpm7LfEf4kynduoiL7Ea/3N9 48RMSlKGWp7jEic+rLNgJqCSPe4Gof5fISxTqmdsYeSCv71FO5I/vOguDmSiNTgaiJIm OU6A== X-Gm-Message-State: AOAM530zMK7ee+vGGwfoQrM4vufQG5oNJe+IPIyOUBMEIgojxn8C/V1V FTdIWru+bsjSpKepQvWATG9khQ== X-Received: by 2002:ac2:52a6:: with SMTP id r6mr292402lfm.255.1611440361313; Sat, 23 Jan 2021 14:19:21 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x17sm1313956lfg.0.2021.01.23.14.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 14:19:20 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Lee Jones , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 03/10] power: supply: ab8500: Push algorithm to power supply code Date: Sat, 23 Jan 2021 23:19:01 +0100 Message-Id: <20210123221908.2993388-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210123221908.2993388-1-linus.walleij@linaro.org> References: <20210123221908.2993388-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The charging algorithm header is only used locally in the power supply subsystem so push this down into drivers/power/supply and rename from the confusing "ux500_chargalg.h" to "ab8500-chargalg.h" for clarity: it is only used with the AB8500. This is another remnant of non-DT code needing to pass data from boardfiles, which we don't do anymore. Signed-off-by: Linus Walleij --- .../power/supply/ab8500-chargalg.h | 6 +++--- drivers/power/supply/ab8500_charger.c | 2 +- drivers/power/supply/abx500_chargalg.c | 2 +- drivers/power/supply/pm2301_charger.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename include/linux/mfd/abx500/ux500_chargalg.h => drivers/power/supply/ab8500-chargalg.h (93%) -- 2.29.2 diff --git a/include/linux/mfd/abx500/ux500_chargalg.h b/drivers/power/supply/ab8500-chargalg.h similarity index 93% rename from include/linux/mfd/abx500/ux500_chargalg.h rename to drivers/power/supply/ab8500-chargalg.h index 9b97d284d0ce..94a6f9068bc5 100644 --- a/include/linux/mfd/abx500/ux500_chargalg.h +++ b/drivers/power/supply/ab8500-chargalg.h @@ -4,8 +4,8 @@ * Author: Johan Gardsmark for ST-Ericsson. */ -#ifndef _UX500_CHARGALG_H -#define _UX500_CHARGALG_H +#ifndef _AB8500_CHARGALG_H_ +#define _AB8500_CHARGALG_H_ #include @@ -48,4 +48,4 @@ struct ux500_charger { extern struct blocking_notifier_head charger_notifier_list; -#endif +#endif /* _AB8500_CHARGALG_H_ */ diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index 50989a5ec95c..a9be10eb2c22 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -28,12 +28,12 @@ #include #include #include -#include #include #include #include #include "ab8500-bm.h" +#include "ab8500-chargalg.h" /* Charger constants */ #define NO_PW_CONN 0 diff --git a/drivers/power/supply/abx500_chargalg.c b/drivers/power/supply/abx500_chargalg.c index 5b28d58041b4..f5b792243727 100644 --- a/drivers/power/supply/abx500_chargalg.c +++ b/drivers/power/supply/abx500_chargalg.c @@ -28,10 +28,10 @@ #include #include #include -#include #include #include "ab8500-bm.h" +#include "ab8500-chargalg.h" /* Watchdog kick interval */ #define CHG_WD_INTERVAL (6 * HZ) diff --git a/drivers/power/supply/pm2301_charger.c b/drivers/power/supply/pm2301_charger.c index 5aeff75db33b..d53e0c37c059 100644 --- a/drivers/power/supply/pm2301_charger.c +++ b/drivers/power/supply/pm2301_charger.c @@ -18,13 +18,13 @@ #include #include #include -#include #include #include #include #include #include "ab8500-bm.h" +#include "ab8500-chargalg.h" #include "pm2301_charger.h" #define to_pm2xxx_charger_ac_device_info(x) container_of((x), \ From patchwork Sat Jan 23 22:19:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 369462 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2687567jam; Sat, 23 Jan 2021 14:20:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJiNRsA6B74WypONgwP5PZAhs8WraR6wcXuNG82Ts5vCR5wAA5qVENl2/UvcRZi8B+HGxW X-Received: by 2002:a05:6402:1398:: with SMTP id b24mr3260241edv.108.1611440438342; Sat, 23 Jan 2021 14:20:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611440438; cv=none; d=google.com; s=arc-20160816; b=FUvmLpjYuHp9+S+1tgdZXz7hhtyhWy+inxySOPzeSCqVdzuq7HWmZu0Ywj4d/4ZMKz t3F8trmWt2iwbZjJx9ZiUlOOd+SqpvE+OJT5GELv2bkiQzHw8wNHQkKI/oBMFIN9Azc9 DlkMX5B13HQcLyOhuNypKLX9r9PvEpV8Fn9dLQaj6O06N9qFoHcu0fYgecdBcRd7Zb0J Taosv+FH8yMcdK1GBhO8OVSjs3PSkkHFnL/FJuDfoZ3fHUZQ5CLPvstbJtFwaOVtMm2l Uf+Rk1XQ8atqAOR+llOkWv147+zD/wEN9f/pTz0AkRl2SJbcLDxo1bp7PdmWyNcG22jX Auiw== 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=jrbOmmhAhnkN+8R3UIrmGuRyjfELrcl48HCspjRBcUk=; b=hvrCBdHMqsB5gXiuV0ZQc9YLHiTzE1TnjRewVsnyB69WdcrD2r0lNDxxxo3fPTiDil 17A6ZVJMPR7fX+Wse23d3954cj2zUzZm4xcgLQEBvl1eiKdEgiySfGCarb4dlFkzN4AL zq+yNRUlmof5iG6tnOdWGo22AhQu/m7kqEgvjSiSeqGC0ID79g3KKpY9W6P57pz/IQ7E CGCxOZmupfqzI4EibXVIce+7sDZQ3z9MqB1EjevPHcZb7DLIwoIBa7JJqrTIKBYRjDnL zUMDRQIj1z6PglUOMWx0T3eMkCkpYeY3bdfteXEG0iT4r7uthWVLACIHm18SJVDrBPVc 9LcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tnMCKsA6; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w3si5278360edr.427.2021.01.23.14.20.37; Sat, 23 Jan 2021 14:20:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=tnMCKsA6; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726298AbhAWWUG (ORCPT + 7 others); Sat, 23 Jan 2021 17:20:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbhAWWUF (ORCPT ); Sat, 23 Jan 2021 17:20:05 -0500 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C820DC061793 for ; Sat, 23 Jan 2021 14:19:24 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id x23so10766956lji.7 for ; Sat, 23 Jan 2021 14:19:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jrbOmmhAhnkN+8R3UIrmGuRyjfELrcl48HCspjRBcUk=; b=tnMCKsA6n0KYNMZ2TzKO756ORSZMio2QFh7s/wCJDKmeS+Hx6qaLax0tI0HJkvT/6I l+wWC2bB+P+ZzUeGWVnXRJXH55T7EVHb20l7tVvz9oBuM8mWOWD+BOMKSb3+LF/gZfvM WmWOSmjnETC9MEA6dzuFLm1q4AnYEJpfxhUSf6O7EEDR8kVb8DzkVDo/xuwNfdUXEfBE 1TNurX7AriuHMNpNnG4qDAdFEHDm/o5JScFPRbwupq4Otemg7QwvjG7GP0G02KmFE3Ed 0xShRAv1k0xMuJprVIR6YyAlMa4ZZ2piXG6DwrnVwLPltioGYeEZxAr2D0zPg2TWGOZE UDKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jrbOmmhAhnkN+8R3UIrmGuRyjfELrcl48HCspjRBcUk=; b=ekPCe9XeJ9Knc/s35KBSD6RDCBHZjcM9zLvXSjTocT+NXsPFZSBesqR81wPHWlguMa iPFXT7iVpRyQhayIRWa84uy2cLN/y76DuS08Cir/0xlOzplh82XaWM4F2KqN3vp0dKLx nRZ+kBWLhJpJzIKweVtj9ya9xn5wlQjb0d69VyaPU7nOw9ZL0uDtT7qRtg7z046T0SsT BOwTtNGyahzlPBkp/DzdzKxzh/2Ap7Uot/OItDIRDn83GDqF7VE1OEMrgrweVQTJ861Z XK5JFr95qH6RIWlL2tDZThquHXz4LZq8RGNWlS1ACmzMyN2ELmIVLXZxe4Lo3kSIx9UO Es3A== X-Gm-Message-State: AOAM5315vdFsg3lD4RHmypj/989cKMHRvhC75K9bZKHx9yHHw0gjjLk3 Uy+XjUD7iPpMRmEZNmzfucG60Q== X-Received: by 2002:a2e:8297:: with SMTP id y23mr105479ljg.177.1611440363116; Sat, 23 Jan 2021 14:19:23 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x17sm1313956lfg.0.2021.01.23.14.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 14:19:22 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Lee Jones , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 04/10] power: supply: ab8500: Push data to power supply code Date: Sat, 23 Jan 2021 23:19:02 +0100 Message-Id: <20210123221908.2993388-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210123221908.2993388-1-linus.walleij@linaro.org> References: <20210123221908.2993388-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org There is a slew of defines, structs and enums and even a function call only relevant for the charging code that still lives in . Push it down to the "ab8500-bm.h" header in the power supply subsystem where it is actually used. Signed-off-by: Linus Walleij --- drivers/power/supply/ab8500-bm.h | 278 ++++++++++++++++++++++++++++++- include/linux/mfd/abx500.h | 276 ------------------------------ 2 files changed, 274 insertions(+), 280 deletions(-) -- 2.29.2 Acked-by: Lee Jones diff --git a/drivers/power/supply/ab8500-bm.h b/drivers/power/supply/ab8500-bm.h index a1b31c971a45..41c69a4f2a1f 100644 --- a/drivers/power/supply/ab8500-bm.h +++ b/drivers/power/supply/ab8500-bm.h @@ -4,7 +4,6 @@ #define _AB8500_CHARGER_H_ #include -#include /* * System control 2 register offsets. @@ -268,6 +267,277 @@ enum bup_vch_sel { #define BUS_PP_PRECHG_CURRENT_MASK 0x0E #define BUS_POWER_PATH_PRECHG_ENA 0x01 +/* + * ADC for the battery thermistor. + * When using the ABx500_ADC_THERM_BATCTRL the battery ID resistor is combined + * with a NTC resistor to both identify the battery and to measure its + * temperature. Different phone manufactures uses different techniques to both + * identify the battery and to read its temperature. + */ +enum abx500_adc_therm { + ABx500_ADC_THERM_BATCTRL, + ABx500_ADC_THERM_BATTEMP, +}; + +/** + * struct abx500_res_to_temp - defines one point in a temp to res curve. To + * be used in battery packs that combines the identification resistor with a + * NTC resistor. + * @temp: battery pack temperature in Celsius + * @resist: NTC resistor net total resistance + */ +struct abx500_res_to_temp { + int temp; + int resist; +}; + +/** + * struct abx500_v_to_cap - Table for translating voltage to capacity + * @voltage: Voltage in mV + * @capacity: Capacity in percent + */ +struct abx500_v_to_cap { + int voltage; + int capacity; +}; + +/* Forward declaration */ +struct abx500_fg; + +/** + * struct abx500_fg_parameters - Fuel gauge algorithm parameters, in seconds + * if not specified + * @recovery_sleep_timer: Time between measurements while recovering + * @recovery_total_time: Total recovery time + * @init_timer: Measurement interval during startup + * @init_discard_time: Time we discard voltage measurement at startup + * @init_total_time: Total init time during startup + * @high_curr_time: Time current has to be high to go to recovery + * @accu_charging: FG accumulation time while charging + * @accu_high_curr: FG accumulation time in high current mode + * @high_curr_threshold: High current threshold, in mA + * @lowbat_threshold: Low battery threshold, in mV + * @overbat_threshold: Over battery threshold, in mV + * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 + * Resolution in 50 mV step. + * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 + * Resolution in 50 mV step. + * @user_cap_limit Capacity reported from user must be within this + * limit to be considered as sane, in percentage + * points. + * @maint_thres This is the threshold where we stop reporting + * battery full while in maintenance, in per cent + * @pcut_enable: Enable power cut feature in ab8505 + * @pcut_max_time: Max time threshold + * @pcut_flag_time: Flagtime threshold + * @pcut_max_restart: Max number of restarts + * @pcut_debounce_time: Sets battery debounce time + */ +struct abx500_fg_parameters { + int recovery_sleep_timer; + int recovery_total_time; + int init_timer; + int init_discard_time; + int init_total_time; + int high_curr_time; + int accu_charging; + int accu_high_curr; + int high_curr_threshold; + int lowbat_threshold; + int overbat_threshold; + int battok_falling_th_sel0; + int battok_raising_th_sel1; + int user_cap_limit; + int maint_thres; + bool pcut_enable; + u8 pcut_max_time; + u8 pcut_flag_time; + u8 pcut_max_restart; + u8 pcut_debounce_time; +}; + +/** + * struct abx500_charger_maximization - struct used by the board config. + * @use_maxi: Enable maximization for this battery type + * @maxi_chg_curr: Maximum charger current allowed + * @maxi_wait_cycles: cycles to wait before setting charger current + * @charger_curr_step delta between two charger current settings (mA) + */ +struct abx500_maxim_parameters { + bool ena_maxi; + int chg_curr; + int wait_cycles; + int charger_curr_step; +}; + +/** + * struct abx500_battery_type - different batteries supported + * @name: battery technology + * @resis_high: battery upper resistance limit + * @resis_low: battery lower resistance limit + * @charge_full_design: Maximum battery capacity in mAh + * @nominal_voltage: Nominal voltage of the battery in mV + * @termination_vol: max voltage upto which battery can be charged + * @termination_curr battery charging termination current in mA + * @recharge_cap battery capacity limit that will trigger a new + * full charging cycle in the case where maintenan- + * -ce charging has been disabled + * @normal_cur_lvl: charger current in normal state in mA + * @normal_vol_lvl: charger voltage in normal state in mV + * @maint_a_cur_lvl: charger current in maintenance A state in mA + * @maint_a_vol_lvl: charger voltage in maintenance A state in mV + * @maint_a_chg_timer_h: charge time in maintenance A state + * @maint_b_cur_lvl: charger current in maintenance B state in mA + * @maint_b_vol_lvl: charger voltage in maintenance B state in mV + * @maint_b_chg_timer_h: charge time in maintenance B state + * @low_high_cur_lvl: charger current in temp low/high state in mA + * @low_high_vol_lvl: charger voltage in temp low/high state in mV' + * @battery_resistance: battery inner resistance in mOhm. + * @n_r_t_tbl_elements: number of elements in r_to_t_tbl + * @r_to_t_tbl: table containing resistance to temp points + * @n_v_cap_tbl_elements: number of elements in v_to_cap_tbl + * @v_to_cap_tbl: Voltage to capacity (in %) table + * @n_batres_tbl_elements number of elements in the batres_tbl + * @batres_tbl battery internal resistance vs temperature table + */ +struct abx500_battery_type { + int name; + int resis_high; + int resis_low; + int charge_full_design; + int nominal_voltage; + int termination_vol; + int termination_curr; + int recharge_cap; + int normal_cur_lvl; + int normal_vol_lvl; + int maint_a_cur_lvl; + int maint_a_vol_lvl; + int maint_a_chg_timer_h; + int maint_b_cur_lvl; + int maint_b_vol_lvl; + int maint_b_chg_timer_h; + int low_high_cur_lvl; + int low_high_vol_lvl; + int battery_resistance; + int n_temp_tbl_elements; + const struct abx500_res_to_temp *r_to_t_tbl; + int n_v_cap_tbl_elements; + const struct abx500_v_to_cap *v_to_cap_tbl; + int n_batres_tbl_elements; + const struct batres_vs_temp *batres_tbl; +}; + +/** + * struct abx500_bm_capacity_levels - abx500 capacity level data + * @critical: critical capacity level in percent + * @low: low capacity level in percent + * @normal: normal capacity level in percent + * @high: high capacity level in percent + * @full: full capacity level in percent + */ +struct abx500_bm_capacity_levels { + int critical; + int low; + int normal; + int high; + int full; +}; + +/** + * struct abx500_bm_charger_parameters - Charger specific parameters + * @usb_volt_max: maximum allowed USB charger voltage in mV + * @usb_curr_max: maximum allowed USB charger current in mA + * @ac_volt_max: maximum allowed AC charger voltage in mV + * @ac_curr_max: maximum allowed AC charger current in mA + */ +struct abx500_bm_charger_parameters { + int usb_volt_max; + int usb_curr_max; + int ac_volt_max; + int ac_curr_max; +}; + +/** + * struct abx500_bm_data - abx500 battery management data + * @temp_under under this temp, charging is stopped + * @temp_low between this temp and temp_under charging is reduced + * @temp_high between this temp and temp_over charging is reduced + * @temp_over over this temp, charging is stopped + * @temp_now present battery temperature + * @temp_interval_chg temperature measurement interval in s when charging + * @temp_interval_nochg temperature measurement interval in s when not charging + * @main_safety_tmr_h safety timer for main charger + * @usb_safety_tmr_h safety timer for usb charger + * @bkup_bat_v voltage which we charge the backup battery with + * @bkup_bat_i current which we charge the backup battery with + * @no_maintenance indicates that maintenance charging is disabled + * @capacity_scaling indicates whether capacity scaling is to be used + * @abx500_adc_therm placement of thermistor, batctrl or battemp adc + * @chg_unknown_bat flag to enable charging of unknown batteries + * @enable_overshoot flag to enable VBAT overshoot control + * @auto_trig flag to enable auto adc trigger + * @fg_res resistance of FG resistor in 0.1mOhm + * @n_btypes number of elements in array bat_type + * @batt_id index of the identified battery in array bat_type + * @interval_charging charge alg cycle period time when charging (sec) + * @interval_not_charging charge alg cycle period time when not charging (sec) + * @temp_hysteresis temperature hysteresis + * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) + * @n_chg_out_curr number of elements in array chg_output_curr + * @n_chg_in_curr number of elements in array chg_input_curr + * @chg_output_curr charger output current level map + * @chg_input_curr charger input current level map + * @maxi maximization parameters + * @cap_levels capacity in percent for the different capacity levels + * @bat_type table of supported battery types + * @chg_params charger parameters + * @fg_params fuel gauge parameters + */ +struct abx500_bm_data { + int temp_under; + int temp_low; + int temp_high; + int temp_over; + int temp_now; + int temp_interval_chg; + int temp_interval_nochg; + int main_safety_tmr_h; + int usb_safety_tmr_h; + int bkup_bat_v; + int bkup_bat_i; + bool autopower_cfg; + bool ac_enabled; + bool usb_enabled; + bool no_maintenance; + bool capacity_scaling; + bool chg_unknown_bat; + bool enable_overshoot; + bool auto_trig; + enum abx500_adc_therm adc_therm; + int fg_res; + int n_btypes; + int batt_id; + int interval_charging; + int interval_not_charging; + int temp_hysteresis; + int gnd_lift_resistance; + int n_chg_out_curr; + int n_chg_in_curr; + int *chg_output_curr; + int *chg_input_curr; + const struct abx500_maxim_parameters *maxi; + const struct abx500_bm_capacity_levels *cap_levels; + struct abx500_battery_type *bat_type; + const struct abx500_bm_charger_parameters *chg_params; + const struct abx500_fg_parameters *fg_params; +}; + +enum { + NTC_EXTERNAL = 0, + NTC_INTERNAL, +}; + /** * struct res_to_temp - defines one point in a temp to res curve. To * be used in battery packs that combines the identification resistor with a @@ -447,9 +717,6 @@ struct ab8500_bm_data { const struct ab8500_fg_parameters *fg_params; }; -struct ab8500_btemp; -struct ab8500_fg; - extern struct abx500_bm_data ab8500_bm_data; void ab8500_charger_usb_state_changed(u8 bm_usb_state, u16 mA); @@ -459,5 +726,8 @@ int ab8500_fg_inst_curr_start(struct ab8500_fg *di); int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res); int ab8500_fg_inst_curr_started(struct ab8500_fg *di); int ab8500_fg_inst_curr_done(struct ab8500_fg *di); +int ab8500_bm_of_probe(struct device *dev, + struct device_node *np, + struct abx500_bm_data *bm); #endif /* _AB8500_CHARGER_H_ */ diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h index 23040b6f1615..7f07cfe44753 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h @@ -28,282 +28,6 @@ struct abx500_init_settings { u8 setting; }; -/* Battery driver related data */ -/* - * ADC for the battery thermistor. - * When using the ABx500_ADC_THERM_BATCTRL the battery ID resistor is combined - * with a NTC resistor to both identify the battery and to measure its - * temperature. Different phone manufactures uses different techniques to both - * identify the battery and to read its temperature. - */ -enum abx500_adc_therm { - ABx500_ADC_THERM_BATCTRL, - ABx500_ADC_THERM_BATTEMP, -}; - -/** - * struct abx500_res_to_temp - defines one point in a temp to res curve. To - * be used in battery packs that combines the identification resistor with a - * NTC resistor. - * @temp: battery pack temperature in Celsius - * @resist: NTC resistor net total resistance - */ -struct abx500_res_to_temp { - int temp; - int resist; -}; - -/** - * struct abx500_v_to_cap - Table for translating voltage to capacity - * @voltage: Voltage in mV - * @capacity: Capacity in percent - */ -struct abx500_v_to_cap { - int voltage; - int capacity; -}; - -/* Forward declaration */ -struct abx500_fg; - -/** - * struct abx500_fg_parameters - Fuel gauge algorithm parameters, in seconds - * if not specified - * @recovery_sleep_timer: Time between measurements while recovering - * @recovery_total_time: Total recovery time - * @init_timer: Measurement interval during startup - * @init_discard_time: Time we discard voltage measurement at startup - * @init_total_time: Total init time during startup - * @high_curr_time: Time current has to be high to go to recovery - * @accu_charging: FG accumulation time while charging - * @accu_high_curr: FG accumulation time in high current mode - * @high_curr_threshold: High current threshold, in mA - * @lowbat_threshold: Low battery threshold, in mV - * @overbat_threshold: Over battery threshold, in mV - * @battok_falling_th_sel0 Threshold in mV for battOk signal sel0 - * Resolution in 50 mV step. - * @battok_raising_th_sel1 Threshold in mV for battOk signal sel1 - * Resolution in 50 mV step. - * @user_cap_limit Capacity reported from user must be within this - * limit to be considered as sane, in percentage - * points. - * @maint_thres This is the threshold where we stop reporting - * battery full while in maintenance, in per cent - * @pcut_enable: Enable power cut feature in ab8505 - * @pcut_max_time: Max time threshold - * @pcut_flag_time: Flagtime threshold - * @pcut_max_restart: Max number of restarts - * @pcut_debounce_time: Sets battery debounce time - */ -struct abx500_fg_parameters { - int recovery_sleep_timer; - int recovery_total_time; - int init_timer; - int init_discard_time; - int init_total_time; - int high_curr_time; - int accu_charging; - int accu_high_curr; - int high_curr_threshold; - int lowbat_threshold; - int overbat_threshold; - int battok_falling_th_sel0; - int battok_raising_th_sel1; - int user_cap_limit; - int maint_thres; - bool pcut_enable; - u8 pcut_max_time; - u8 pcut_flag_time; - u8 pcut_max_restart; - u8 pcut_debounce_time; -}; - -/** - * struct abx500_charger_maximization - struct used by the board config. - * @use_maxi: Enable maximization for this battery type - * @maxi_chg_curr: Maximum charger current allowed - * @maxi_wait_cycles: cycles to wait before setting charger current - * @charger_curr_step delta between two charger current settings (mA) - */ -struct abx500_maxim_parameters { - bool ena_maxi; - int chg_curr; - int wait_cycles; - int charger_curr_step; -}; - -/** - * struct abx500_battery_type - different batteries supported - * @name: battery technology - * @resis_high: battery upper resistance limit - * @resis_low: battery lower resistance limit - * @charge_full_design: Maximum battery capacity in mAh - * @nominal_voltage: Nominal voltage of the battery in mV - * @termination_vol: max voltage upto which battery can be charged - * @termination_curr battery charging termination current in mA - * @recharge_cap battery capacity limit that will trigger a new - * full charging cycle in the case where maintenan- - * -ce charging has been disabled - * @normal_cur_lvl: charger current in normal state in mA - * @normal_vol_lvl: charger voltage in normal state in mV - * @maint_a_cur_lvl: charger current in maintenance A state in mA - * @maint_a_vol_lvl: charger voltage in maintenance A state in mV - * @maint_a_chg_timer_h: charge time in maintenance A state - * @maint_b_cur_lvl: charger current in maintenance B state in mA - * @maint_b_vol_lvl: charger voltage in maintenance B state in mV - * @maint_b_chg_timer_h: charge time in maintenance B state - * @low_high_cur_lvl: charger current in temp low/high state in mA - * @low_high_vol_lvl: charger voltage in temp low/high state in mV' - * @battery_resistance: battery inner resistance in mOhm. - * @n_r_t_tbl_elements: number of elements in r_to_t_tbl - * @r_to_t_tbl: table containing resistance to temp points - * @n_v_cap_tbl_elements: number of elements in v_to_cap_tbl - * @v_to_cap_tbl: Voltage to capacity (in %) table - * @n_batres_tbl_elements number of elements in the batres_tbl - * @batres_tbl battery internal resistance vs temperature table - */ -struct abx500_battery_type { - int name; - int resis_high; - int resis_low; - int charge_full_design; - int nominal_voltage; - int termination_vol; - int termination_curr; - int recharge_cap; - int normal_cur_lvl; - int normal_vol_lvl; - int maint_a_cur_lvl; - int maint_a_vol_lvl; - int maint_a_chg_timer_h; - int maint_b_cur_lvl; - int maint_b_vol_lvl; - int maint_b_chg_timer_h; - int low_high_cur_lvl; - int low_high_vol_lvl; - int battery_resistance; - int n_temp_tbl_elements; - const struct abx500_res_to_temp *r_to_t_tbl; - int n_v_cap_tbl_elements; - const struct abx500_v_to_cap *v_to_cap_tbl; - int n_batres_tbl_elements; - const struct batres_vs_temp *batres_tbl; -}; - -/** - * struct abx500_bm_capacity_levels - abx500 capacity level data - * @critical: critical capacity level in percent - * @low: low capacity level in percent - * @normal: normal capacity level in percent - * @high: high capacity level in percent - * @full: full capacity level in percent - */ -struct abx500_bm_capacity_levels { - int critical; - int low; - int normal; - int high; - int full; -}; - -/** - * struct abx500_bm_charger_parameters - Charger specific parameters - * @usb_volt_max: maximum allowed USB charger voltage in mV - * @usb_curr_max: maximum allowed USB charger current in mA - * @ac_volt_max: maximum allowed AC charger voltage in mV - * @ac_curr_max: maximum allowed AC charger current in mA - */ -struct abx500_bm_charger_parameters { - int usb_volt_max; - int usb_curr_max; - int ac_volt_max; - int ac_curr_max; -}; - -/** - * struct abx500_bm_data - abx500 battery management data - * @temp_under under this temp, charging is stopped - * @temp_low between this temp and temp_under charging is reduced - * @temp_high between this temp and temp_over charging is reduced - * @temp_over over this temp, charging is stopped - * @temp_now present battery temperature - * @temp_interval_chg temperature measurement interval in s when charging - * @temp_interval_nochg temperature measurement interval in s when not charging - * @main_safety_tmr_h safety timer for main charger - * @usb_safety_tmr_h safety timer for usb charger - * @bkup_bat_v voltage which we charge the backup battery with - * @bkup_bat_i current which we charge the backup battery with - * @no_maintenance indicates that maintenance charging is disabled - * @capacity_scaling indicates whether capacity scaling is to be used - * @abx500_adc_therm placement of thermistor, batctrl or battemp adc - * @chg_unknown_bat flag to enable charging of unknown batteries - * @enable_overshoot flag to enable VBAT overshoot control - * @auto_trig flag to enable auto adc trigger - * @fg_res resistance of FG resistor in 0.1mOhm - * @n_btypes number of elements in array bat_type - * @batt_id index of the identified battery in array bat_type - * @interval_charging charge alg cycle period time when charging (sec) - * @interval_not_charging charge alg cycle period time when not charging (sec) - * @temp_hysteresis temperature hysteresis - * @gnd_lift_resistance Battery ground to phone ground resistance (mOhm) - * @n_chg_out_curr number of elements in array chg_output_curr - * @n_chg_in_curr number of elements in array chg_input_curr - * @chg_output_curr charger output current level map - * @chg_input_curr charger input current level map - * @maxi maximization parameters - * @cap_levels capacity in percent for the different capacity levels - * @bat_type table of supported battery types - * @chg_params charger parameters - * @fg_params fuel gauge parameters - */ -struct abx500_bm_data { - int temp_under; - int temp_low; - int temp_high; - int temp_over; - int temp_now; - int temp_interval_chg; - int temp_interval_nochg; - int main_safety_tmr_h; - int usb_safety_tmr_h; - int bkup_bat_v; - int bkup_bat_i; - bool autopower_cfg; - bool ac_enabled; - bool usb_enabled; - bool no_maintenance; - bool capacity_scaling; - bool chg_unknown_bat; - bool enable_overshoot; - bool auto_trig; - enum abx500_adc_therm adc_therm; - int fg_res; - int n_btypes; - int batt_id; - int interval_charging; - int interval_not_charging; - int temp_hysteresis; - int gnd_lift_resistance; - int n_chg_out_curr; - int n_chg_in_curr; - int *chg_output_curr; - int *chg_input_curr; - const struct abx500_maxim_parameters *maxi; - const struct abx500_bm_capacity_levels *cap_levels; - struct abx500_battery_type *bat_type; - const struct abx500_bm_charger_parameters *chg_params; - const struct abx500_fg_parameters *fg_params; -}; - -enum { - NTC_EXTERNAL = 0, - NTC_INTERNAL, -}; - -int ab8500_bm_of_probe(struct device *dev, - struct device_node *np, - struct abx500_bm_data *bm); - int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg, u8 value); int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg, From patchwork Sat Jan 23 22:19:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 369468 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2688130jam; Sat, 23 Jan 2021 14:21:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2if7ZabaaK8VcYs16cR3zBae9YcktBPTvsygADJEc39zAdnOAZDX9cCGjF1aYcvOO2vCt X-Received: by 2002:a17:906:4159:: with SMTP id l25mr1020370ejk.311.1611440518001; Sat, 23 Jan 2021 14:21:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611440517; cv=none; d=google.com; s=arc-20160816; b=YeTLSowQSDC+1QED/7mcDWqKqvAsJDQeScOPmtaj9hE7DYSYblQ6LoLRgk2CN+P0Nu db9JXJTeUrNamh8RXf9TV+zKcg/nd4IP2kF09L8aD0OrCNuqFzc54i9SFoaHzZ+HsGW+ OvVgK+P4dvUDITplpDcXjlvk7SpuuzRr7GmxjHhO8j+KewRBw0Fb69jehZX+ywnS5qFP hCJ+mtly91L6sjslTcduduii2ci903beu8c6eQhpnxSC8EriODA6W+C7fMAisWuraGFm 26jiLnmBF9j/us4JnFExhTNLn+Ndf4NXEu5KKqw2bF43nIX5fB+jooWU2Q8ZvpY/n8pZ 7wIQ== 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=2GGU/7Le4ybRZyNPKmUxlvmmUnWIr8q5/ilMqtA4HMo=; b=r5bMT1HEjJ2OKKwwpQhTjsH7TIF5fu9Sspa8TYJ8zcUP48UAp81/1HKQPU1VDvQFJM MLVsE1H5ky9MbnOQ8oISg0lG2VYMmtgyVMD1yf6RMVP4kt72xzwrBJ/AExGqgxB2YC/n bbuqpLJITHyZxdHOX5wancvAM57ClIzLTuIz+bn8QjxH4ECX59xjfvvcQjHMfxWjab2v cFgAI9f3e/bIsPG2Qo8UV1Zf69jiYn3TT/m5ImdsQXkLLw+85aARS/kvHxJpRC5jvPC+ OTkMxUryKOayw7R4dco2jFpMEVuj1zoYjoFJAa0gn+MfHhsfp2d+sojfRKOKSnuuyC78 VEKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eW/hoMvY"; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw11si4392384ejb.414.2021.01.23.14.21.57; Sat, 23 Jan 2021 14:21:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b="eW/hoMvY"; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726324AbhAWWUk (ORCPT + 7 others); Sat, 23 Jan 2021 17:20:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbhAWWUi (ORCPT ); Sat, 23 Jan 2021 17:20:38 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A05D2C061794 for ; Sat, 23 Jan 2021 14:19:26 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id a8so12572209lfi.8 for ; Sat, 23 Jan 2021 14:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2GGU/7Le4ybRZyNPKmUxlvmmUnWIr8q5/ilMqtA4HMo=; b=eW/hoMvYdWJEnyOMSrDooyOCqxGHiOvR4l58HMWlyNtTp78rqj+Bl8Ag6+hAgoZjcg RJ5s46BKYFhXwG8qbzyaFX5dsZ9OO2jpSqSSxCTcog6GEMEKew7WfycaZgQc/rWn7jXg 8wbdxoctnP1u80r9I/xZ5f5EHuRteip+ZR5mrinno6D7UQrN3d9Ml+vKdI2qp9L/7j7D LlguKJ+K0U0Hf6d1i99giiVqg4zDsRp4V6Ee+b3mH6CF6fVdjpdsECbxTzF8IvxABRXK LRMOHVfdRqUNjoais+xLQKvuVkGxMYB1RQVggQ34Xy/fqhpQV2L7AsgH6+5ZwAXVaEpo Iahg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2GGU/7Le4ybRZyNPKmUxlvmmUnWIr8q5/ilMqtA4HMo=; b=BeTHzXSFILQeE+v+cF2MudSf6TK4AMwUI/V3hWerBjnZIwdH0RlYyq+K3GPDp8EjMu t5WhnlZHbjxzCsj4ib2OmGRbPI/nZgvOlt8Oyj7VQ/nezSMaRMCTkuAPwTUDqyIYiMw8 PWonFrXwmWMOEXVApX8v0D2c2hr93HF/3cNyol22kFpz/0L57Xe5P67wpDvhZ5sCKx32 C+2f7WD5RW8X4b8OG8DiWc4ch26eu26v0/QJuCLb4BDZygBUoHeAByHvNHQs+ZhQNTaU yumQ5wsXNj26P8GJqsKANgRpP1imu0+OhqS54HXewa5MpmdP0kIH1Po4X+LmXxI6VqDt E1Rw== X-Gm-Message-State: AOAM533Q6uDu2vPDQUgyojXH6qDe4TfCFiFCEEaGk1tLJy6nP10LGWN8 vJ6fyjApN+WfO0zR3gEngR9lNA== X-Received: by 2002:a05:6512:31d3:: with SMTP id j19mr403453lfe.495.1611440364975; Sat, 23 Jan 2021 14:19:24 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x17sm1313956lfg.0.2021.01.23.14.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 14:19:24 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Lee Jones , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 05/10] power: supply: ab8500: Move to componentized binding Date: Sat, 23 Jan 2021 23:19:03 +0100 Message-Id: <20210123221908.2993388-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210123221908.2993388-1-linus.walleij@linaro.org> References: <20210123221908.2993388-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The driver has problems with the different components of the charging code racing with each other to probe(). This results in all four subdrivers populating battery information to ascertain that it is populated for their own needs for example. Fix this by using component probing and thus expressing to the kernel that these are dependent components. The probes can happen in any order and will only acquire resources such as state container, regulators and interrupts and initialize the data structures, but no execution happens until the .bind() callback is called. The charging driver is the main component and binds first, then bind in order the three subcomponents: ab8500-fg, ab8500-btemp and ab8500-chargalg. Do some housekeeping while we are moving the code around. Like use devm_* for IRQs so as to cut down on some boilerplate. Signed-off-by: Linus Walleij --- drivers/power/supply/ab8500-bm.h | 4 + drivers/power/supply/ab8500_btemp.c | 118 ++++----- drivers/power/supply/ab8500_charger.c | 341 +++++++++++++++---------- drivers/power/supply/ab8500_fg.c | 136 +++++----- drivers/power/supply/abx500_chargalg.c | 114 +++++---- 5 files changed, 382 insertions(+), 331 deletions(-) -- 2.29.2 diff --git a/drivers/power/supply/ab8500-bm.h b/drivers/power/supply/ab8500-bm.h index 41c69a4f2a1f..012595a9d269 100644 --- a/drivers/power/supply/ab8500-bm.h +++ b/drivers/power/supply/ab8500-bm.h @@ -730,4 +730,8 @@ int ab8500_bm_of_probe(struct device *dev, struct device_node *np, struct abx500_bm_data *bm); +extern struct platform_driver ab8500_fg_driver; +extern struct platform_driver ab8500_btemp_driver; +extern struct platform_driver abx500_chargalg_driver; + #endif /* _AB8500_CHARGER_H_ */ diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c index fdfcd59fc43e..3598b5a748e7 100644 --- a/drivers/power/supply/ab8500_btemp.c +++ b/drivers/power/supply/ab8500_btemp.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -932,26 +933,6 @@ static int __maybe_unused ab8500_btemp_suspend(struct device *dev) return 0; } -static int ab8500_btemp_remove(struct platform_device *pdev) -{ - struct ab8500_btemp *di = platform_get_drvdata(pdev); - int i, irq; - - /* Disable interrupts */ - for (i = 0; i < ARRAY_SIZE(ab8500_btemp_irq); i++) { - irq = platform_get_irq_byname(pdev, ab8500_btemp_irq[i].name); - free_irq(irq, di); - } - - /* Delete the work queue */ - destroy_workqueue(di->btemp_wq); - - flush_scheduled_work(); - power_supply_unregister(di->btemp_psy); - - return 0; -} - static char *supply_interface[] = { "ab8500_chargalg", "ab8500_fg", @@ -966,6 +947,40 @@ static const struct power_supply_desc ab8500_btemp_desc = { .external_power_changed = ab8500_btemp_external_power_changed, }; +static int ab8500_btemp_bind(struct device *dev, struct device *master, + void *data) +{ + struct ab8500_btemp *di = dev_get_drvdata(dev); + + /* Create a work queue for the btemp */ + di->btemp_wq = + alloc_workqueue("ab8500_btemp_wq", WQ_MEM_RECLAIM, 0); + if (di->btemp_wq == NULL) { + dev_err(dev, "failed to create work queue\n"); + return -ENOMEM; + } + + /* Kick off periodic temperature measurements */ + ab8500_btemp_periodic(di, true); + + return 0; +} + +static void ab8500_btemp_unbind(struct device *dev, struct device *master, + void *data) +{ + struct ab8500_btemp *di = dev_get_drvdata(dev); + + /* Delete the work queue */ + destroy_workqueue(di->btemp_wq); + flush_scheduled_work(); +} + +static const struct component_ops ab8500_btemp_component_ops = { + .bind = ab8500_btemp_bind, + .unbind = ab8500_btemp_unbind, +}; + static int ab8500_btemp_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1011,14 +1026,6 @@ static int ab8500_btemp_probe(struct platform_device *pdev) psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface); psy_cfg.drv_data = di; - /* Create a work queue for the btemp */ - di->btemp_wq = - alloc_workqueue("ab8500_btemp_wq", WQ_MEM_RECLAIM, 0); - if (di->btemp_wq == NULL) { - dev_err(dev, "failed to create work queue\n"); - return -ENOMEM; - } - /* Init work for measuring temperature periodically */ INIT_DEFERRABLE_WORK(&di->btemp_periodic_work, ab8500_btemp_periodic_work); @@ -1031,7 +1038,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev) AB8500_BTEMP_HIGH_TH, &val); if (ret < 0) { dev_err(dev, "%s ab8500 read failed\n", __func__); - goto free_btemp_wq; + return ret; } switch (val) { case BTEMP_HIGH_TH_57_0: @@ -1050,30 +1057,28 @@ static int ab8500_btemp_probe(struct platform_device *pdev) } /* Register BTEMP power supply class */ - di->btemp_psy = power_supply_register(dev, &ab8500_btemp_desc, - &psy_cfg); + di->btemp_psy = devm_power_supply_register(dev, &ab8500_btemp_desc, + &psy_cfg); if (IS_ERR(di->btemp_psy)) { dev_err(dev, "failed to register BTEMP psy\n"); - ret = PTR_ERR(di->btemp_psy); - goto free_btemp_wq; + return PTR_ERR(di->btemp_psy); } /* Register interrupts */ for (i = 0; i < ARRAY_SIZE(ab8500_btemp_irq); i++) { irq = platform_get_irq_byname(pdev, ab8500_btemp_irq[i].name); - if (irq < 0) { - ret = irq; - goto free_irq; - } + if (irq < 0) + return irq; - ret = request_threaded_irq(irq, NULL, ab8500_btemp_irq[i].isr, + ret = devm_request_threaded_irq(dev, irq, NULL, + ab8500_btemp_irq[i].isr, IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_ONESHOT, ab8500_btemp_irq[i].name, di); if (ret) { dev_err(dev, "failed to request %s IRQ %d: %d\n" , ab8500_btemp_irq[i].name, irq, ret); - goto free_irq; + return ret; } dev_dbg(dev, "Requested %s IRQ %d: %d\n", ab8500_btemp_irq[i].name, irq, ret); @@ -1081,23 +1086,16 @@ static int ab8500_btemp_probe(struct platform_device *pdev) platform_set_drvdata(pdev, di); - /* Kick off periodic temperature measurements */ - ab8500_btemp_periodic(di, true); list_add_tail(&di->node, &ab8500_btemp_list); - return ret; + return component_add(dev, &ab8500_btemp_component_ops); +} -free_irq: - /* We also have to free all successfully registered irqs */ - for (i = i - 1; i >= 0; i--) { - irq = platform_get_irq_byname(pdev, ab8500_btemp_irq[i].name); - free_irq(irq, di); - } +static int ab8500_btemp_remove(struct platform_device *pdev) +{ + component_del(&pdev->dev, &ab8500_btemp_component_ops); - power_supply_unregister(di->btemp_psy); -free_btemp_wq: - destroy_workqueue(di->btemp_wq); - return ret; + return 0; } static SIMPLE_DEV_PM_OPS(ab8500_btemp_pm_ops, ab8500_btemp_suspend, ab8500_btemp_resume); @@ -1107,7 +1105,7 @@ static const struct of_device_id ab8500_btemp_match[] = { { }, }; -static struct platform_driver ab8500_btemp_driver = { +struct platform_driver ab8500_btemp_driver = { .probe = ab8500_btemp_probe, .remove = ab8500_btemp_remove, .driver = { @@ -1116,20 +1114,6 @@ static struct platform_driver ab8500_btemp_driver = { .pm = &ab8500_btemp_pm_ops, }, }; - -static int __init ab8500_btemp_init(void) -{ - return platform_driver_register(&ab8500_btemp_driver); -} - -static void __exit ab8500_btemp_exit(void) -{ - platform_driver_unregister(&ab8500_btemp_driver); -} - -device_initcall(ab8500_btemp_init); -module_exit(ab8500_btemp_exit); - MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Johan Palsson, Karl Komierowski, Arun R Murthy"); MODULE_ALIAS("platform:ab8500-btemp"); diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index a9be10eb2c22..704006bf554c 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -3276,10 +3277,74 @@ static struct notifier_block charger_nb = { .notifier_call = ab8500_external_charger_prepare, }; -static int ab8500_charger_remove(struct platform_device *pdev) +static char *supply_interface[] = { + "ab8500_chargalg", + "ab8500_fg", + "ab8500_btemp", +}; + +static const struct power_supply_desc ab8500_ac_chg_desc = { + .name = "ab8500_ac", + .type = POWER_SUPPLY_TYPE_MAINS, + .properties = ab8500_charger_ac_props, + .num_properties = ARRAY_SIZE(ab8500_charger_ac_props), + .get_property = ab8500_charger_ac_get_property, +}; + +static const struct power_supply_desc ab8500_usb_chg_desc = { + .name = "ab8500_usb", + .type = POWER_SUPPLY_TYPE_USB, + .properties = ab8500_charger_usb_props, + .num_properties = ARRAY_SIZE(ab8500_charger_usb_props), + .get_property = ab8500_charger_usb_get_property, +}; + +static int ab8500_charger_bind(struct device *dev) { - struct ab8500_charger *di = platform_get_drvdata(pdev); - int i, irq, ret; + struct ab8500_charger *di = dev_get_drvdata(dev); + int ch_stat; + int ret; + + /* Create a work queue for the charger */ + di->charger_wq = alloc_ordered_workqueue("ab8500_charger_wq", + WQ_MEM_RECLAIM); + if (di->charger_wq == NULL) { + dev_err(dev, "failed to create work queue\n"); + return -ENOMEM; + } + + ch_stat = ab8500_charger_detect_chargers(di, false); + + if (ch_stat & AC_PW_CONN) { + if (is_ab8500(di->parent)) + queue_delayed_work(di->charger_wq, + &di->ac_charger_attached_work, + HZ); + } + if (ch_stat & USB_PW_CONN) { + if (is_ab8500(di->parent)) + queue_delayed_work(di->charger_wq, + &di->usb_charger_attached_work, + HZ); + di->vbus_detected = true; + di->vbus_detected_start = true; + queue_work(di->charger_wq, + &di->detect_usb_type_work); + } + + ret = component_bind_all(dev, di); + if (ret) { + dev_err(dev, "can't bind component devices\n"); + return ret; + } + + return 0; +} + +static void ab8500_charger_unbind(struct device *dev) +{ + struct ab8500_charger *di = dev_get_drvdata(dev); + int ret; /* Disable AC charging */ ab8500_charger_ac_en(&di->ac_chg, false, 0, 0); @@ -3287,68 +3352,47 @@ static int ab8500_charger_remove(struct platform_device *pdev) /* Disable USB charging */ ab8500_charger_usb_en(&di->usb_chg, false, 0, 0); - /* Disable interrupts */ - for (i = 0; i < ARRAY_SIZE(ab8500_charger_irq); i++) { - irq = platform_get_irq_byname(pdev, ab8500_charger_irq[i].name); - free_irq(irq, di); - } - /* Backup battery voltage and current disable */ ret = abx500_mask_and_set_register_interruptible(di->dev, AB8500_RTC, AB8500_RTC_CTRL_REG, RTC_BUP_CH_ENA, 0); if (ret < 0) dev_err(di->dev, "%s mask and set failed\n", __func__); - usb_unregister_notifier(di->usb_phy, &di->nb); - usb_put_phy(di->usb_phy); - /* Delete the work queue */ destroy_workqueue(di->charger_wq); - /* Unregister external charger enable notifier */ - if (!di->ac_chg.enabled) - blocking_notifier_chain_unregister( - &charger_notifier_list, &charger_nb); - flush_scheduled_work(); - if (di->usb_chg.enabled) - power_supply_unregister(di->usb_chg.psy); - if (di->ac_chg.enabled && !di->ac_chg.external) - power_supply_unregister(di->ac_chg.psy); - - return 0; + /* Unbind fg, btemp, algorithm */ + component_unbind_all(dev, di); } -static char *supply_interface[] = { - "ab8500_chargalg", - "ab8500_fg", - "ab8500_btemp", +static const struct component_master_ops ab8500_charger_comp_ops = { + .bind = ab8500_charger_bind, + .unbind = ab8500_charger_unbind, }; -static const struct power_supply_desc ab8500_ac_chg_desc = { - .name = "ab8500_ac", - .type = POWER_SUPPLY_TYPE_MAINS, - .properties = ab8500_charger_ac_props, - .num_properties = ARRAY_SIZE(ab8500_charger_ac_props), - .get_property = ab8500_charger_ac_get_property, +static struct platform_driver *const ab8500_charger_component_drivers[] = { + &ab8500_fg_driver, + &ab8500_btemp_driver, + &abx500_chargalg_driver, }; -static const struct power_supply_desc ab8500_usb_chg_desc = { - .name = "ab8500_usb", - .type = POWER_SUPPLY_TYPE_USB, - .properties = ab8500_charger_usb_props, - .num_properties = ARRAY_SIZE(ab8500_charger_usb_props), - .get_property = ab8500_charger_usb_get_property, -}; +static int ab8500_charger_compare_dev(struct device *dev, void *data) +{ + return dev == data; +} static int ab8500_charger_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct component_match *match = NULL; struct power_supply_config ac_psy_cfg = {}, usb_psy_cfg = {}; struct ab8500_charger *di; - int irq, i, charger_status, ret = 0, ch_stat; - struct device *dev = &pdev->dev; + int charger_status; + int i, irq; + int ret; di = devm_kzalloc(dev, sizeof(*di), GFP_KERNEL); if (!di) @@ -3393,6 +3437,38 @@ static int ab8500_charger_probe(struct platform_device *pdev) return ret; } + /* + * VDD ADC supply needs to be enabled from this driver when there + * is a charger connected to avoid erroneous BTEMP_HIGH/LOW + * interrupts during charging + */ + di->regu = devm_regulator_get(dev, "vddadc"); + if (IS_ERR(di->regu)) { + ret = PTR_ERR(di->regu); + dev_err(dev, "failed to get vddadc regulator\n"); + return ret; + } + + /* Request interrupts */ + for (i = 0; i < ARRAY_SIZE(ab8500_charger_irq); i++) { + irq = platform_get_irq_byname(pdev, ab8500_charger_irq[i].name); + if (irq < 0) + return irq; + + ret = devm_request_threaded_irq(dev, + irq, NULL, ab8500_charger_irq[i].isr, + IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_ONESHOT, + ab8500_charger_irq[i].name, di); + + if (ret != 0) { + dev_err(dev, "failed to request %s IRQ %d: %d\n" + , ab8500_charger_irq[i].name, irq, ret); + return ret; + } + dev_dbg(dev, "Requested %s IRQ %d: %d\n", + ab8500_charger_irq[i].name, irq, ret); + } + /* initialize lock */ spin_lock_init(&di->usb_state.usb_lock); mutex_init(&di->usb_ipt_crnt_lock); @@ -3422,11 +3498,6 @@ static int ab8500_charger_probe(struct platform_device *pdev) di->ac_chg.enabled = di->bm->ac_enabled; di->ac_chg.external = false; - /*notifier for external charger enabling*/ - if (!di->ac_chg.enabled) - blocking_notifier_chain_register( - &charger_notifier_list, &charger_nb); - /* USB supply */ /* ux500_charger sub-class */ di->usb_chg.ops.enable = &ab8500_charger_usb_en; @@ -3442,14 +3513,6 @@ static int ab8500_charger_probe(struct platform_device *pdev) di->usb_chg.external = false; di->usb_state.usb_current = -1; - /* Create a work queue for the charger */ - di->charger_wq = alloc_ordered_workqueue("ab8500_charger_wq", - WQ_MEM_RECLAIM); - if (di->charger_wq == NULL) { - dev_err(dev, "failed to create work queue\n"); - return -ENOMEM; - } - mutex_init(&di->charger_attached_mutex); /* Init work for HW failure check */ @@ -3500,63 +3563,36 @@ static int ab8500_charger_probe(struct platform_device *pdev) INIT_WORK(&di->check_usb_thermal_prot_work, ab8500_charger_check_usb_thermal_prot_work); - /* - * VDD ADC supply needs to be enabled from this driver when there - * is a charger connected to avoid erroneous BTEMP_HIGH/LOW - * interrupts during charging - */ - di->regu = devm_regulator_get(dev, "vddadc"); - if (IS_ERR(di->regu)) { - ret = PTR_ERR(di->regu); - dev_err(dev, "failed to get vddadc regulator\n"); - goto free_charger_wq; - } - /* Initialize OVV, and other registers */ ret = ab8500_charger_init_hw_registers(di); if (ret) { dev_err(dev, "failed to initialize ABB registers\n"); - goto free_charger_wq; + return ret; } /* Register AC charger class */ if (di->ac_chg.enabled) { - di->ac_chg.psy = power_supply_register(dev, + di->ac_chg.psy = devm_power_supply_register(dev, &ab8500_ac_chg_desc, &ac_psy_cfg); if (IS_ERR(di->ac_chg.psy)) { dev_err(dev, "failed to register AC charger\n"); - ret = PTR_ERR(di->ac_chg.psy); - goto free_charger_wq; + return PTR_ERR(di->ac_chg.psy); } } /* Register USB charger class */ if (di->usb_chg.enabled) { - di->usb_chg.psy = power_supply_register(dev, + di->usb_chg.psy = devm_power_supply_register(dev, &ab8500_usb_chg_desc, &usb_psy_cfg); if (IS_ERR(di->usb_chg.psy)) { dev_err(dev, "failed to register USB charger\n"); - ret = PTR_ERR(di->usb_chg.psy); - goto free_ac; + return PTR_ERR(di->usb_chg.psy); } } - di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2); - if (IS_ERR_OR_NULL(di->usb_phy)) { - dev_err(dev, "failed to get usb transceiver\n"); - ret = -EINVAL; - goto free_usb; - } - di->nb.notifier_call = ab8500_charger_usb_notifier_call; - ret = usb_register_notifier(di->usb_phy, &di->nb); - if (ret) { - dev_err(dev, "failed to register usb notifier\n"); - goto put_usb_phy; - } - /* Identify the connected charger types during startup */ charger_status = ab8500_charger_detect_chargers(di, true); if (charger_status & AC_PW_CONN) { @@ -3566,78 +3602,90 @@ static int ab8500_charger_probe(struct platform_device *pdev) sysfs_notify(&di->ac_chg.psy->dev.kobj, NULL, "present"); } - if (charger_status & USB_PW_CONN) { - di->vbus_detected = true; - di->vbus_detected_start = true; - queue_work(di->charger_wq, - &di->detect_usb_type_work); - } + mutex_lock(&di->charger_attached_mutex); - /* Register interrupts */ - for (i = 0; i < ARRAY_SIZE(ab8500_charger_irq); i++) { - irq = platform_get_irq_byname(pdev, ab8500_charger_irq[i].name); - if (irq < 0) { - ret = irq; - goto free_irq; - } + mutex_unlock(&di->charger_attached_mutex); - ret = request_threaded_irq(irq, NULL, ab8500_charger_irq[i].isr, - IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_ONESHOT, - ab8500_charger_irq[i].name, di); + platform_set_drvdata(pdev, di); - if (ret != 0) { - dev_err(dev, "failed to request %s IRQ %d: %d\n" - , ab8500_charger_irq[i].name, irq, ret); - goto free_irq; + /* Create something that will match the subdrivers when we bind */ + for (i = 0; i < ARRAY_SIZE(ab8500_charger_component_drivers); i++) { + struct device_driver *drv = &ab8500_charger_component_drivers[i]->driver; + struct device *p = NULL, *d; + + while ((d = platform_find_device_by_driver(p, drv))) { + put_device(p); + component_match_add(dev, &match, + ab8500_charger_compare_dev, d); + p = d; } - dev_dbg(dev, "Requested %s IRQ %d: %d\n", - ab8500_charger_irq[i].name, irq, ret); + put_device(p); + } + if (!match) { + dev_err(dev, "no matching components\n"); + return -ENODEV; + } + if (IS_ERR(match)) { + dev_err(dev, "could not create component match\n"); + return PTR_ERR(match); } - platform_set_drvdata(pdev, di); + /* Notifier for external charger enabling */ + if (!di->ac_chg.enabled) + blocking_notifier_chain_register( + &charger_notifier_list, &charger_nb); - mutex_lock(&di->charger_attached_mutex); - ch_stat = ab8500_charger_detect_chargers(di, false); - - if ((ch_stat & AC_PW_CONN) == AC_PW_CONN) { - if (is_ab8500(di->parent)) - queue_delayed_work(di->charger_wq, - &di->ac_charger_attached_work, - HZ); + di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2); + if (IS_ERR_OR_NULL(di->usb_phy)) { + dev_err(dev, "failed to get usb transceiver\n"); + ret = -EINVAL; + goto out_charger_notifier; } - if ((ch_stat & USB_PW_CONN) == USB_PW_CONN) { - if (is_ab8500(di->parent)) - queue_delayed_work(di->charger_wq, - &di->usb_charger_attached_work, - HZ); + di->nb.notifier_call = ab8500_charger_usb_notifier_call; + ret = usb_register_notifier(di->usb_phy, &di->nb); + if (ret) { + dev_err(dev, "failed to register usb notifier\n"); + goto put_usb_phy; } - mutex_unlock(&di->charger_attached_mutex); - return ret; + ret = component_master_add_with_match(&pdev->dev, + &ab8500_charger_comp_ops, + match); + if (ret) { + dev_err(dev, "failed to add component master\n"); + goto free_notifier; + } -free_irq: - usb_unregister_notifier(di->usb_phy, &di->nb); + return 0; - /* We also have to free all successfully registered irqs */ - for (i = i - 1; i >= 0; i--) { - irq = platform_get_irq_byname(pdev, ab8500_charger_irq[i].name); - free_irq(irq, di); - } +free_notifier: + usb_unregister_notifier(di->usb_phy, &di->nb); put_usb_phy: usb_put_phy(di->usb_phy); -free_usb: - if (di->usb_chg.enabled) - power_supply_unregister(di->usb_chg.psy); -free_ac: - if (di->ac_chg.enabled) - power_supply_unregister(di->ac_chg.psy); -free_charger_wq: - destroy_workqueue(di->charger_wq); +out_charger_notifier: + if (!di->ac_chg.enabled) + blocking_notifier_chain_unregister( + &charger_notifier_list, &charger_nb); return ret; } +static int ab8500_charger_remove(struct platform_device *pdev) +{ + struct ab8500_charger *di = platform_get_drvdata(pdev); + + component_master_del(&pdev->dev, &ab8500_charger_comp_ops); + + usb_unregister_notifier(di->usb_phy, &di->nb); + usb_put_phy(di->usb_phy); + if (!di->ac_chg.enabled) + blocking_notifier_chain_unregister( + &charger_notifier_list, &charger_nb); + + return 0; +} + static SIMPLE_DEV_PM_OPS(ab8500_charger_pm_ops, ab8500_charger_suspend, ab8500_charger_resume); static const struct of_device_id ab8500_charger_match[] = { @@ -3657,15 +3705,24 @@ static struct platform_driver ab8500_charger_driver = { static int __init ab8500_charger_init(void) { + int ret; + + ret = platform_register_drivers(ab8500_charger_component_drivers, + ARRAY_SIZE(ab8500_charger_component_drivers)); + if (ret) + return ret; + return platform_driver_register(&ab8500_charger_driver); } static void __exit ab8500_charger_exit(void) { + platform_unregister_drivers(ab8500_charger_component_drivers, + ARRAY_SIZE(ab8500_charger_component_drivers)); platform_driver_unregister(&ab8500_charger_driver); } -subsys_initcall_sync(ab8500_charger_init); +module_init(ab8500_charger_init); module_exit(ab8500_charger_exit); MODULE_LICENSE("GPL v2"); diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 8a6d40623731..d9dd13164d28 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -2980,27 +2981,6 @@ static int __maybe_unused ab8500_fg_suspend(struct device *dev) return 0; } -static int ab8500_fg_remove(struct platform_device *pdev) -{ - int ret = 0; - struct ab8500_fg *di = platform_get_drvdata(pdev); - - list_del(&di->node); - - /* Disable coulomb counter */ - ret = ab8500_fg_coulomb_counter(di, false); - if (ret) - dev_err(di->dev, "failed to disable coulomb counter\n"); - - destroy_workqueue(di->fg_wq); - ab8500_fg_sysfs_exit(di); - - flush_scheduled_work(); - ab8500_fg_sysfs_psy_remove_attrs(di); - power_supply_unregister(di->fg_psy); - return ret; -} - /* ab8500 fg driver interrupts and their respective isr */ static struct ab8500_fg_interrupts ab8500_fg_irq[] = { {"NCONV_ACCU", ab8500_fg_cc_convend_handler}, @@ -3024,11 +3004,50 @@ static const struct power_supply_desc ab8500_fg_desc = { .external_power_changed = ab8500_fg_external_power_changed, }; +static int ab8500_fg_bind(struct device *dev, struct device *master, + void *data) +{ + struct ab8500_fg *di = dev_get_drvdata(dev); + + /* Create a work queue for running the FG algorithm */ + di->fg_wq = alloc_ordered_workqueue("ab8500_fg_wq", WQ_MEM_RECLAIM); + if (di->fg_wq == NULL) { + dev_err(dev, "failed to create work queue\n"); + return -ENOMEM; + } + + /* Start the coulomb counter */ + ab8500_fg_coulomb_counter(di, true); + /* Run the FG algorithm */ + queue_delayed_work(di->fg_wq, &di->fg_periodic_work, 0); + + return 0; +} + +static void ab8500_fg_unbind(struct device *dev, struct device *master, + void *data) +{ + struct ab8500_fg *di = dev_get_drvdata(dev); + int ret; + + /* Disable coulomb counter */ + ret = ab8500_fg_coulomb_counter(di, false); + if (ret) + dev_err(dev, "failed to disable coulomb counter\n"); + + destroy_workqueue(di->fg_wq); + flush_scheduled_work(); +} + +static const struct component_ops ab8500_fg_component_ops = { + .bind = ab8500_fg_bind, + .unbind = ab8500_fg_unbind, +}; + static int ab8500_fg_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; - struct power_supply_config psy_cfg = {}; struct device *dev = &pdev->dev; + struct power_supply_config psy_cfg = {}; struct ab8500_fg *di; int i, irq; int ret = 0; @@ -3074,13 +3093,6 @@ static int ab8500_fg_probe(struct platform_device *pdev) ab8500_fg_charge_state_to(di, AB8500_FG_CHARGE_INIT); ab8500_fg_discharge_state_to(di, AB8500_FG_DISCHARGE_INIT); - /* Create a work queue for running the FG algorithm */ - di->fg_wq = alloc_ordered_workqueue("ab8500_fg_wq", WQ_MEM_RECLAIM); - if (di->fg_wq == NULL) { - dev_err(dev, "failed to create work queue\n"); - return -ENOMEM; - } - /* Init work for running the fg algorithm instantly */ INIT_WORK(&di->fg_work, ab8500_fg_instant_work); @@ -3113,7 +3125,7 @@ static int ab8500_fg_probe(struct platform_device *pdev) ret = ab8500_fg_init_hw_registers(di); if (ret) { dev_err(dev, "failed to initialize registers\n"); - goto free_inst_curr_wq; + return ret; } /* Consider battery unknown until we're informed otherwise */ @@ -3121,15 +3133,13 @@ static int ab8500_fg_probe(struct platform_device *pdev) di->flags.batt_id_received = false; /* Register FG power supply class */ - di->fg_psy = power_supply_register(dev, &ab8500_fg_desc, &psy_cfg); + di->fg_psy = devm_power_supply_register(dev, &ab8500_fg_desc, &psy_cfg); if (IS_ERR(di->fg_psy)) { dev_err(dev, "failed to register FG psy\n"); - ret = PTR_ERR(di->fg_psy); - goto free_inst_curr_wq; + return PTR_ERR(di->fg_psy); } di->fg_samples = SEC_TO_SAMPLE(di->bm->fg_params->init_timer); - ab8500_fg_coulomb_counter(di, true); /* * Initialize completion used to notify completion and start @@ -3141,19 +3151,18 @@ static int ab8500_fg_probe(struct platform_device *pdev) /* Register primary interrupt handlers */ for (i = 0; i < ARRAY_SIZE(ab8500_fg_irq); i++) { irq = platform_get_irq_byname(pdev, ab8500_fg_irq[i].name); - if (irq < 0) { - ret = irq; - goto free_irq; - } + if (irq < 0) + return irq; - ret = request_threaded_irq(irq, NULL, ab8500_fg_irq[i].isr, + ret = devm_request_threaded_irq(dev, irq, NULL, + ab8500_fg_irq[i].isr, IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_ONESHOT, ab8500_fg_irq[i].name, di); if (ret != 0) { dev_err(dev, "failed to request %s IRQ %d: %d\n", ab8500_fg_irq[i].name, irq, ret); - goto free_irq; + return ret; } dev_dbg(dev, "Requested %s IRQ %d: %d\n", ab8500_fg_irq[i].name, irq, ret); @@ -3168,14 +3177,14 @@ static int ab8500_fg_probe(struct platform_device *pdev) ret = ab8500_fg_sysfs_init(di); if (ret) { dev_err(dev, "failed to create sysfs entry\n"); - goto free_irq; + return ret; } ret = ab8500_fg_sysfs_psy_create_attrs(di); if (ret) { dev_err(dev, "failed to create FG psy\n"); ab8500_fg_sysfs_exit(di); - goto free_irq; + return ret; } /* Calibrate the fg first time */ @@ -3185,24 +3194,21 @@ static int ab8500_fg_probe(struct platform_device *pdev) /* Use room temp as default value until we get an update from driver. */ di->bat_temp = 210; - /* Run the FG algorithm */ - queue_delayed_work(di->fg_wq, &di->fg_periodic_work, 0); - list_add_tail(&di->node, &ab8500_fg_list); - return ret; + return component_add(dev, &ab8500_fg_component_ops); +} -free_irq: - /* We also have to free all registered irqs */ - while (--i >= 0) { - /* Last assignment of i from primary interrupt handlers */ - irq = platform_get_irq_byname(pdev, ab8500_fg_irq[i].name); - free_irq(irq, di); - } +static int ab8500_fg_remove(struct platform_device *pdev) +{ + int ret = 0; + struct ab8500_fg *di = platform_get_drvdata(pdev); + + component_del(&pdev->dev, &ab8500_fg_component_ops); + list_del(&di->node); + ab8500_fg_sysfs_exit(di); + ab8500_fg_sysfs_psy_remove_attrs(di); - power_supply_unregister(di->fg_psy); -free_inst_curr_wq: - destroy_workqueue(di->fg_wq); return ret; } @@ -3213,7 +3219,7 @@ static const struct of_device_id ab8500_fg_match[] = { { }, }; -static struct platform_driver ab8500_fg_driver = { +struct platform_driver ab8500_fg_driver = { .probe = ab8500_fg_probe, .remove = ab8500_fg_remove, .driver = { @@ -3222,20 +3228,6 @@ static struct platform_driver ab8500_fg_driver = { .pm = &ab8500_fg_pm_ops, }, }; - -static int __init ab8500_fg_init(void) -{ - return platform_driver_register(&ab8500_fg_driver); -} - -static void __exit ab8500_fg_exit(void) -{ - platform_driver_unregister(&ab8500_fg_driver); -} - -subsys_initcall_sync(ab8500_fg_init); -module_exit(ab8500_fg_exit); - MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Johan Palsson, Karl Komierowski"); MODULE_ALIAS("platform:ab8500-fg"); diff --git a/drivers/power/supply/abx500_chargalg.c b/drivers/power/supply/abx500_chargalg.c index f5b792243727..883e3810a22c 100644 --- a/drivers/power/supply/abx500_chargalg.c +++ b/drivers/power/supply/abx500_chargalg.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1943,13 +1944,44 @@ static int __maybe_unused abx500_chargalg_suspend(struct device *dev) return 0; } -static int abx500_chargalg_remove(struct platform_device *pdev) +static char *supply_interface[] = { + "ab8500_fg", +}; + +static const struct power_supply_desc abx500_chargalg_desc = { + .name = "abx500_chargalg", + .type = POWER_SUPPLY_TYPE_BATTERY, + .properties = abx500_chargalg_props, + .num_properties = ARRAY_SIZE(abx500_chargalg_props), + .get_property = abx500_chargalg_get_property, + .external_power_changed = abx500_chargalg_external_power_changed, +}; + +static int abx500_chargalg_bind(struct device *dev, struct device *master, + void *data) { - struct abx500_chargalg *di = platform_get_drvdata(pdev); + struct abx500_chargalg *di = dev_get_drvdata(dev); - /* sysfs interface to enable/disbale charging from user space */ - abx500_chargalg_sysfs_exit(di); + /* Create a work queue for the chargalg */ + di->chargalg_wq = alloc_ordered_workqueue("abx500_chargalg_wq", + WQ_MEM_RECLAIM); + if (di->chargalg_wq == NULL) { + dev_err(di->dev, "failed to create work queue\n"); + return -ENOMEM; + } + + /* Run the charging algorithm */ + queue_delayed_work(di->chargalg_wq, &di->chargalg_periodic_work, 0); + + return 0; +} + +static void abx500_chargalg_unbind(struct device *dev, struct device *master, + void *data) +{ + struct abx500_chargalg *di = dev_get_drvdata(dev); + /* Stop all timers and work */ hrtimer_cancel(&di->safety_timer); hrtimer_cancel(&di->maintenance_timer); @@ -1959,48 +1991,38 @@ static int abx500_chargalg_remove(struct platform_device *pdev) /* Delete the work queue */ destroy_workqueue(di->chargalg_wq); - - power_supply_unregister(di->chargalg_psy); - - return 0; + flush_scheduled_work(); } -static char *supply_interface[] = { - "ab8500_fg", -}; - -static const struct power_supply_desc abx500_chargalg_desc = { - .name = "abx500_chargalg", - .type = POWER_SUPPLY_TYPE_BATTERY, - .properties = abx500_chargalg_props, - .num_properties = ARRAY_SIZE(abx500_chargalg_props), - .get_property = abx500_chargalg_get_property, - .external_power_changed = abx500_chargalg_external_power_changed, +static const struct component_ops abx500_chargalg_component_ops = { + .bind = abx500_chargalg_bind, + .unbind = abx500_chargalg_unbind, }; static int abx500_chargalg_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; struct power_supply_config psy_cfg = {}; struct abx500_chargalg *di; int ret = 0; - di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL); + di = devm_kzalloc(dev, sizeof(*di), GFP_KERNEL); if (!di) { - dev_err(&pdev->dev, "%s no mem for ab8500_chargalg\n", __func__); + dev_err(dev, "%s no mem for ab8500_chargalg\n", __func__); return -ENOMEM; } di->bm = &ab8500_bm_data; - ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); + ret = ab8500_bm_of_probe(dev, np, di->bm); if (ret) { - dev_err(&pdev->dev, "failed to get battery information\n"); + dev_err(dev, "failed to get battery information\n"); return ret; } /* get device struct and parent */ - di->dev = &pdev->dev; + di->dev = dev; di->parent = dev_get_drvdata(pdev->dev.parent); psy_cfg.supplied_to = supply_interface; @@ -2016,14 +2038,6 @@ static int abx500_chargalg_probe(struct platform_device *pdev) di->maintenance_timer.function = abx500_chargalg_maintenance_timer_expired; - /* Create a work queue for the chargalg */ - di->chargalg_wq = alloc_ordered_workqueue("abx500_chargalg_wq", - WQ_MEM_RECLAIM); - if (di->chargalg_wq == NULL) { - dev_err(di->dev, "failed to create work queue\n"); - return -ENOMEM; - } - /* Init work for chargalg */ INIT_DEFERRABLE_WORK(&di->chargalg_periodic_work, abx500_chargalg_periodic_work); @@ -2037,12 +2051,12 @@ static int abx500_chargalg_probe(struct platform_device *pdev) di->chg_info.prev_conn_chg = -1; /* Register chargalg power supply class */ - di->chargalg_psy = power_supply_register(di->dev, &abx500_chargalg_desc, + di->chargalg_psy = devm_power_supply_register(di->dev, + &abx500_chargalg_desc, &psy_cfg); if (IS_ERR(di->chargalg_psy)) { dev_err(di->dev, "failed to register chargalg psy\n"); - ret = PTR_ERR(di->chargalg_psy); - goto free_chargalg_wq; + return PTR_ERR(di->chargalg_psy); } platform_set_drvdata(pdev, di); @@ -2051,21 +2065,24 @@ static int abx500_chargalg_probe(struct platform_device *pdev) ret = abx500_chargalg_sysfs_init(di); if (ret) { dev_err(di->dev, "failed to create sysfs entry\n"); - goto free_psy; + return ret; } di->curr_status.curr_step = CHARGALG_CURR_STEP_HIGH; - /* Run the charging algorithm */ - queue_delayed_work(di->chargalg_wq, &di->chargalg_periodic_work, 0); - dev_info(di->dev, "probe success\n"); - return ret; + return component_add(dev, &abx500_chargalg_component_ops); +} -free_psy: - power_supply_unregister(di->chargalg_psy); -free_chargalg_wq: - destroy_workqueue(di->chargalg_wq); - return ret; +static int abx500_chargalg_remove(struct platform_device *pdev) +{ + struct abx500_chargalg *di = platform_get_drvdata(pdev); + + component_del(&pdev->dev, &abx500_chargalg_component_ops); + + /* sysfs interface to enable/disbale charging from user space */ + abx500_chargalg_sysfs_exit(di); + + return 0; } static SIMPLE_DEV_PM_OPS(abx500_chargalg_pm_ops, abx500_chargalg_suspend, abx500_chargalg_resume); @@ -2075,7 +2092,7 @@ static const struct of_device_id ab8500_chargalg_match[] = { { }, }; -static struct platform_driver abx500_chargalg_driver = { +struct platform_driver abx500_chargalg_driver = { .probe = abx500_chargalg_probe, .remove = abx500_chargalg_remove, .driver = { @@ -2084,9 +2101,6 @@ static struct platform_driver abx500_chargalg_driver = { .pm = &abx500_chargalg_pm_ops, }, }; - -module_platform_driver(abx500_chargalg_driver); - MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Johan Palsson, Karl Komierowski"); MODULE_ALIAS("platform:abx500-chargalg"); From patchwork Sat Jan 23 22:19:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 369463 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2688122jam; Sat, 23 Jan 2021 14:21:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXX3N8B3Wool8F7BnRjR1WbPRjynYNpUHhu1fRk4fAB7KY2U/IH14RCntJc1HopPxhSmxY X-Received: by 2002:aa7:d1d4:: with SMTP id g20mr232067edp.244.1611440517300; Sat, 23 Jan 2021 14:21:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611440517; cv=none; d=google.com; s=arc-20160816; b=VgzbzC0pYukp024gaGVPZE7jhZKiCtFU0rLsYqqo8ZDn5VoinswhsLYhqA3GQIaQIF pbpSxA/GccoHVlsPfrWfiOe4mT4OXx096IfyORlIYPFheIC+4tBVJo+C1YgFGuiwJtqf TLZovCrzuH3iOswmjcTOlUYeodmTwRPUO0aN/XrrW5g8kfYoTrp3wsEa7G7ZWhQFLAfX hwhkfJ2W5BBP1CqxKwISbLTCRg0pSC7ts+9aYZ0j7xbE0tZVdbv6sBBIk9j1yokal10O xOvMao9SQYeylRio+0U4wjrtWInbTb5UbA6hJ/sViZbkLAc55s16FeS7zAXmP9Z4bu7C +LSg== 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=qxqWGsq2hPGcNNxUeBx801l+y29+EGYn44iLZgztEcc=; b=ksTGxoh6HXjsy5vWNc4Yp4zp0ASAbZv3jgqSbDij5U/Px/ZL+fIbkeFxx3WgK8bmMq t6ho4XFKABg/b7yNj6pXlE+vtQvxJDUvr7OZ9AzSLlTAL6xjFvt4IpBrDlXd90/WO3Q+ RodbS7v81E9LjCXpTx+ErsfFkxXqX8JWc2K1kyh+yw8a7V+VrTXIvu/uA+3NbcEi8Rw+ RplC0t0kRrnka4lrwIw/8ud8Dpgxvbale83PIy2EwLhB5GMDz0M9PuNdm73Me7K49ipf N58Ybfh7v8pajZ9iFmZ0dlQXotk+04g7cIVr8WC7JCes4C/Wq8PPwTcd3kNEDMsb+6WB PtCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jh4pVBjD; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw11si4392384ejb.414.2021.01.23.14.21.57; Sat, 23 Jan 2021 14:21:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=Jh4pVBjD; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726315AbhAWWUj (ORCPT + 7 others); Sat, 23 Jan 2021 17:20:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbhAWWUi (ORCPT ); Sat, 23 Jan 2021 17:20:38 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21FCDC061797 for ; Sat, 23 Jan 2021 14:19:28 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id p21so7485948lfu.11 for ; Sat, 23 Jan 2021 14:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qxqWGsq2hPGcNNxUeBx801l+y29+EGYn44iLZgztEcc=; b=Jh4pVBjD18QjyZSpN0luJQcK+55TPY0fmXyzNbIb8795EBbL0ZARlsiGRyWXxZr8ub /rN/aal9hdGaj5OsSwGXTAAvE712ALnSmv+fj+ebv4NEn0KvRYIj0ZdqB+P2k1Td1HEu LKbd+i46W/3O8lWM/N7stxHKfLcC904Nb788FCs+1j9Uwn4sQqEyB875+AGrQuVQKAQy m68aNznvhh/yqwQ1vawM+/y6VB7iwnuwZIPm2uZ4OXm/KU50q884VFHePqE2qfn4N5cr NO5leAWHTz7UnnsahbjJVUpd2qBsTxBs1O6XAkXtakJSY8saa7RKTgL9EiQqDKoSnSQn 8hAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qxqWGsq2hPGcNNxUeBx801l+y29+EGYn44iLZgztEcc=; b=Sdzes8MjgCfKMV+WtgZtjg2l3+dWf3YAU95ZuHdc1dyqpqHu04bo1jtN60FBd/ReT/ WELX5m8JL2qlqunG+goTMeUflsdG75NXouisXryl0UpYfl9uAIOoU4oFaH+e6vq04sei cy4+QYhvVaBboxnBCDI9Wy0e6kVfb0V6Qx2X8Gm0NqrUnUveKIFk148TTaXGelxjxAYd BiGNbdMFCvpu04X8IyvT/d/ln5rKj6picXqcoJo9rOZoAPDVfYZSE42W8Q/01pK/G7zB 4kbwZ3++IUc6+3B2hooF4runj+oSHFXl9EQV6+6EUc7tlzJpAw0lT8ReeJN4jkr2yZIy 7eBA== X-Gm-Message-State: AOAM533TcAAaDh83PbCDSd7bFU5njf8jp1S/ujXlRITxyLoMnNi8jUvg Sr0HN+6ulnQoKRsnmL44O/8aV1ZP3wEOU52E X-Received: by 2002:a05:6512:786:: with SMTP id x6mr1587357lfr.643.1611440366671; Sat, 23 Jan 2021 14:19:26 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x17sm1313956lfg.0.2021.01.23.14.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 14:19:26 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Lee Jones , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 06/10] power: supply: ab8500: Call battery population once Date: Sat, 23 Jan 2021 23:19:04 +0100 Message-Id: <20210123221908.2993388-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210123221908.2993388-1-linus.walleij@linaro.org> References: <20210123221908.2993388-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The code was calling ab8500_bm_of_probe() in four different spots effectively overwriting the same configuration three times. This was done because probe order was uncertain. Since we now used componentized probe, call it only once while probing the main charging component. Signed-off-by: Linus Walleij --- drivers/power/supply/ab8500_btemp.c | 7 ------- drivers/power/supply/ab8500_fg.c | 6 ------ drivers/power/supply/abx500_chargalg.c | 7 ------- 3 files changed, 20 deletions(-) -- 2.29.2 diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c index 3598b5a748e7..5b664d2f6b82 100644 --- a/drivers/power/supply/ab8500_btemp.c +++ b/drivers/power/supply/ab8500_btemp.c @@ -983,7 +983,6 @@ static const struct component_ops ab8500_btemp_component_ops = { static int ab8500_btemp_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; struct power_supply_config psy_cfg = {}; struct device *dev = &pdev->dev; struct ab8500_btemp *di; @@ -996,12 +995,6 @@ static int ab8500_btemp_probe(struct platform_device *pdev) di->bm = &ab8500_bm_data; - ret = ab8500_bm_of_probe(dev, np, di->bm); - if (ret) { - dev_err(dev, "failed to get battery information\n"); - return ret; - } - /* get parent data */ di->dev = dev; di->parent = dev_get_drvdata(pdev->dev.parent); diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index d9dd13164d28..74d55e9c23bc 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -3058,12 +3058,6 @@ static int ab8500_fg_probe(struct platform_device *pdev) di->bm = &ab8500_bm_data; - ret = ab8500_bm_of_probe(dev, np, di->bm); - if (ret) { - dev_err(dev, "failed to get battery information\n"); - return ret; - } - mutex_init(&di->cc_lock); /* get parent data */ diff --git a/drivers/power/supply/abx500_chargalg.c b/drivers/power/supply/abx500_chargalg.c index 883e3810a22c..8b3a2d883a2d 100644 --- a/drivers/power/supply/abx500_chargalg.c +++ b/drivers/power/supply/abx500_chargalg.c @@ -2002,7 +2002,6 @@ static const struct component_ops abx500_chargalg_component_ops = { static int abx500_chargalg_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; struct power_supply_config psy_cfg = {}; struct abx500_chargalg *di; int ret = 0; @@ -2015,12 +2014,6 @@ static int abx500_chargalg_probe(struct platform_device *pdev) di->bm = &ab8500_bm_data; - ret = ab8500_bm_of_probe(dev, np, di->bm); - if (ret) { - dev_err(dev, "failed to get battery information\n"); - return ret; - } - /* get device struct and parent */ di->dev = dev; di->parent = dev_get_drvdata(pdev->dev.parent); From patchwork Sat Jan 23 22:19:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 369464 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2688136jam; Sat, 23 Jan 2021 14:21:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxX9TI1/dBSuksLLTdf/RPBtml5FNWczKf2qdCIU4zykW8EyMgs1x9uPcpFkhxGEc2X9DBq X-Received: by 2002:a17:906:9941:: with SMTP id zm1mr103273ejb.522.1611440518417; Sat, 23 Jan 2021 14:21:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611440518; cv=none; d=google.com; s=arc-20160816; b=D2CuKUqUXF1RibfDTBTlr/WtMDcOxH60X5j8CckNHuIfWXJMXeOoBhdQDTWsGbjyj3 Yel6EMKTL+ylIpMdld9cEKZlxIZuVRLTFbo+PVsXRrNIyLf90alOX6T04jrEn05WbvKp 7LmxCYcgpS6+Nd79T90bttQDUDUKxPne1nmKTy5elvjvyfzu5hINahIjnCeU6BV/zDuM xwrmegPsitJjeWPjGWM0/Xj6Rzk9I6KrTd7qoTScNRjqPCf9B5PrT9EhsTJALi8SdXAS KF3DzVMA4RlYBFxcLifn2YpY20Q+3QL8nRG/v1UBKAn+WMLx6GkUfvgdh2gxkhYmWKcQ PlkQ== 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=/CksNMLgJxQqZTGvVoyYFDLCuLf1sggTOdB/wwyAbMc=; b=UOFVuH5hpCGxPl+0jyglaAMnhKZMNckRu5zt2uQuk8oDKNY3DohNzikUXk9d/5DydT AT8FB8CZmPb25I+kwEU0fjim5hlJY3+UwPqxTOZAWUa9bcXVACNxZwITWkvPSm3SCbhT Rsp0rQuErXh0oEgc9kfSBVQXoJhcV/aBPcTEsLTOCTwvlnkzB6dGr7a1AXKEz/8irQdu xnQPLLxuTgZhj0I1N6jPATSMzfKdAQ4QfhwuUD1hnwvnwccUKavCSooHpahDoDVTiGs5 pCg4QQR9cJAmVJ0cVafE0urOS0vS5GCJi7PjR2aFeaZ4buHTw1hcW07HMhMmY6ENL/NK 0joA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g+doe8cn; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw11si4392384ejb.414.2021.01.23.14.21.58; Sat, 23 Jan 2021 14:21:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=g+doe8cn; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725932AbhAWWUl (ORCPT + 7 others); Sat, 23 Jan 2021 17:20:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbhAWWUk (ORCPT ); Sat, 23 Jan 2021 17:20:40 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C174EC0617A7 for ; Sat, 23 Jan 2021 14:19:29 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id a8so12572281lfi.8 for ; Sat, 23 Jan 2021 14:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/CksNMLgJxQqZTGvVoyYFDLCuLf1sggTOdB/wwyAbMc=; b=g+doe8cnX4AH/zqBgFiZLGkj/6fvpGOj5vh8JVDHl4lCTEjJG8acnX+rgAzu3V50YH I9wGtscjnSn9xzfyLbLi1OxMCJV/Z0uuOOzddkczj2qP29kmJli5f31LduCyzreJNzH9 c09KUX/9aNaymJIckKAu9krYNhrEoILsP6RckvI7kw1HZlc3dWU0mRTXbRved/QmHpcw cV9xCu/Wt317gU87+F/fEBC3Kp5IfVFsovxRaEb1wUp/DXdW2y7caxumNpOdm6fzV06P wb0syQvYwhQANVXZjiwy8xn7oC6MbsSFq23a4nkZrs6zFpy1Nw8MN2V4KL8QVx05T8RZ 8EAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/CksNMLgJxQqZTGvVoyYFDLCuLf1sggTOdB/wwyAbMc=; b=O2rzXV2q7Gr1FByUOtdnjv0GNEitj94pcNp04tqa1lzYWkhasIvQBQ24HAo8vKyHjR J2AVnngBRytZFkPPo8fxkpwZhyRRO3KFNnt7qBeTv/6BvwdTieTsTiJDDe3nMf4Bknl3 /v4rnn4jfyzbY/PBqvTJzjwAbKFoLUqmZ3zcQLOasTyUgI/KhEhFecMucRK+lKHgSppg PHCo17orCdobL35E5M5RPO96XtmkbdyEogoWgBCDI6WRvqutQwuzUsrsKlIBr8CDaj5o z9WSFLEgaPiPTOdAT+NcGcMIcwX5yatCdfyAbuiYoq1AosRoqzu34QNG8vOkps/IUz0F bBLQ== X-Gm-Message-State: AOAM533jFrpfGJi9pJ05LnRSZdpTbaNtHzrXHpXc+mj0b3oslwi+xmrH 4MgMhtZlc1oVNXbLvGSP8qksLg== X-Received: by 2002:a19:3811:: with SMTP id f17mr285263lfa.28.1611440368260; Sat, 23 Jan 2021 14:19:28 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x17sm1313956lfg.0.2021.01.23.14.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 14:19:27 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Lee Jones , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 07/10] power: supply: ab8500: Avoid NULL pointers Date: Sat, 23 Jan 2021 23:19:05 +0100 Message-Id: <20210123221908.2993388-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210123221908.2993388-1-linus.walleij@linaro.org> References: <20210123221908.2993388-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Sometimes the code will crash because we haven't enabled AC or USB charging and thus not created the corresponding psy device. Fix it by checking that it is there before notifying. Signed-off-by: Linus Walleij --- drivers/power/supply/ab8500_charger.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 2.29.2 diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index 704006bf554c..158131ed8b80 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -415,6 +415,14 @@ static void ab8500_enable_disable_sw_fallback(struct ab8500_charger *di, static void ab8500_power_supply_changed(struct ab8500_charger *di, struct power_supply *psy) { + /* + * This happens if we get notifications or interrupts and + * the platform has been configured not to support one or + * other type of charging. + */ + if (!psy) + return; + if (di->autopower_cfg) { if (!di->usb.charger_connected && !di->ac.charger_connected && @@ -441,7 +449,15 @@ static void ab8500_charger_set_usb_connected(struct ab8500_charger *di, if (!connected) di->flags.vbus_drop_end = false; - sysfs_notify(&di->usb_chg.psy->dev.kobj, NULL, "present"); + /* + * Sometimes the platform is configured not to support + * USB charging and no psy has been created, but we still + * will get these notifications. + */ + if (di->usb_chg.psy) { + sysfs_notify(&di->usb_chg.psy->dev.kobj, NULL, + "present"); + } if (connected) { mutex_lock(&di->charger_attached_mutex); From patchwork Sat Jan 23 22:19:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 369465 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2688144jam; Sat, 23 Jan 2021 14:21:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgSI2w5kdJr24FWm0780RVyJ5bLwaMEJloRiEr6HDDHE7GXx0uYONCwyoOqBSg0osfAZA/ X-Received: by 2002:aa7:c983:: with SMTP id c3mr892222edt.327.1611440518806; Sat, 23 Jan 2021 14:21:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611440518; cv=none; d=google.com; s=arc-20160816; b=O9T8bpFj3SVmfYwPHljYdlG8q/4aOQYZ2vVZ6+mb9R+bizL6WjvRn7c6llZcGu5kMk 1xNgX6pI5OCANaGiZqEo97efbId1T3n1cuorVEo0oEgZ0SQO0wQt8TIl+b44PEuJQIFS 2DsP8QisGVJl7JTXSL9TtfTOG0HRcr++H8VFx8ENHqTcPeF1jt5BbDkOTGs1xpnzO0R+ /E0tpkIh7XPfT1LTKCWyCVu1csRl57fsyWJrM6hLXWPICXP/9UOGMEQh54OYzPTPCaFg tjjaMTaGd6GVnzsTqL49r+YB8CAKnYRHlVnQHj18t3o3QtEEgPyZoFH0gfH7Dn3pCvgc /5nA== 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=lDw2Zywr4IODkv/lha2OrxYzfa5j2Qq3VpSO78JP/jI=; b=Ak+00vdGzh+2mjezcXAVGC+5y9kr/Cvw6ZH2sOO3tGl2KJoDujPFLkaRQxZmGM1nk0 qkEvx8P/h1SNUwNo6Zdb2jZjmlmlV14cDWq7fJZ1myvQzeUKSckG5miAyHdVbN1DwC5O sHkFgXWR4SGQb38qt49iSEG1CpDkgeE4pOCMCpHmibIdGkOBFIxh6YQyqGTu8tAxd/ax 9G0F9oTkqb9xROwL+Lv9DB3T7PFhHhRUvNjeHgq1CWnbJWuPnzUMvoj3z3CVz5A0DZpx gIvLbw+CyJS4Y5qSOYGxNNhzhYwzr96ZqvT280hYFlloVl2PF8U9wBdN6BU0Tw/tcIoh kb3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wxlZkpLK; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw11si4392384ejb.414.2021.01.23.14.21.58; Sat, 23 Jan 2021 14:21:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=wxlZkpLK; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726344AbhAWWUm (ORCPT + 7 others); Sat, 23 Jan 2021 17:20:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbhAWWUk (ORCPT ); Sat, 23 Jan 2021 17:20:40 -0500 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD3AC0617AA for ; Sat, 23 Jan 2021 14:19:31 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id f19so1862022ljn.5 for ; Sat, 23 Jan 2021 14:19:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lDw2Zywr4IODkv/lha2OrxYzfa5j2Qq3VpSO78JP/jI=; b=wxlZkpLKQypG9keotJoMSErJwz4HsGAkAPy0XhgVe3QNxXFrGVc4XYS5TaJOEAeYQ4 wGqtn+yXkX/hcGLgBjByRtpp1+xe+Ol4OJPn0kNbCfWJJbT4PeoD+EKpej17cpPhiTgL FNKqtWNdKV2LMNcr7RbKVO9YJwg8j+D8+NSCGC9oh9+tb9yf/N5tCPCRGXc18KlDTRYR YEPkoKH8MoN7zB1jJz4oy6QGJeqZGLuy+Flj8RPTAqRagTXrFmyETGRn+h7ANMvpn9Z2 c+ac+pPTxG60TGLafo7Bb3ztG5sLxHYnJxVN//H/cv7VpdDedWOrrQmzASGXYr9YbhET LpUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lDw2Zywr4IODkv/lha2OrxYzfa5j2Qq3VpSO78JP/jI=; b=HU7+8HzMLTv8DqsnB0AhWp4fnAuJJL+WF2BZY2Dsyr6W6wEI5pYUlDfgt2R0JBhPVl tIUVC/hBa6z/oIBAu/4NgWyRNDnfNiujmaLXP3bBqrIEu4GCJcUZUio9yGWaevqHAglV r5SFrOjZWYvVyNVMaW2BamRR0DbFuMG5vpEDblE35UT/4+4Q0UFX7DobqISGIp+I93OW FvQicDBkEXD618Kp5EWqUHBkCZxq0aJ+dLtdaGIy2X2/yD/P9CupC244MMtJc4jQanTg /fFXmfRqj0zaL3HKIH0DNAEQBYPGsto6hhQ6PBqbXVYW5d8HdsuKodR0/BN8+eujNNZQ 2Pig== X-Gm-Message-State: AOAM532fQGKeDuxRRqnE/PtoMRfuNhRj9yTvRxBhi4FI2ZqQWjcYoRnJ L9X2U0S5NydiJNcqnyKjQBFoDMPWsEqogCv/ X-Received: by 2002:a2e:585:: with SMTP id 127mr135724ljf.131.1611440369780; Sat, 23 Jan 2021 14:19:29 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x17sm1313956lfg.0.2021.01.23.14.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 14:19:29 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Lee Jones , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 08/10] power: supply: ab8500: Enable USB and AC Date: Sat, 23 Jan 2021 23:19:06 +0100 Message-Id: <20210123221908.2993388-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210123221908.2993388-1-linus.walleij@linaro.org> References: <20210123221908.2993388-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The vendor code tree supplies platform data to enable he USB charging for AB8500 and AB8500 and disable the AC charging on the AB8505. This was missed when the driver was submitted to the mainline kernel. Fix this by doing what the vendor kernel does: always register the USB charger, do not register the AC charger on the AB8505. Signed-off-by: Linus Walleij --- drivers/power/supply/ab8500-bm.h | 2 -- drivers/power/supply/ab8500_charger.c | 24 ++++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) -- 2.29.2 diff --git a/drivers/power/supply/ab8500-bm.h b/drivers/power/supply/ab8500-bm.h index 012595a9d269..871bdc1f5cbd 100644 --- a/drivers/power/supply/ab8500-bm.h +++ b/drivers/power/supply/ab8500-bm.h @@ -507,8 +507,6 @@ struct abx500_bm_data { int bkup_bat_v; int bkup_bat_i; bool autopower_cfg; - bool ac_enabled; - bool usb_enabled; bool no_maintenance; bool capacity_scaling; bool chg_unknown_bat; diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index 158131ed8b80..832e01f56a62 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -3511,7 +3511,14 @@ static int ab8500_charger_probe(struct platform_device *pdev) di->ac_chg.max_out_curr = di->bm->chg_output_curr[di->bm->n_chg_out_curr - 1]; di->ac_chg.wdt_refresh = CHG_WD_INTERVAL; - di->ac_chg.enabled = di->bm->ac_enabled; + /* + * The AB8505 only supports USB charging. If we are not the + * AB8505, register an AC charger. + * + * TODO: if this should be opt-in, add DT properties for this. + */ + if (!is_ab8505(di->parent)) + di->ac_chg.enabled = true; di->ac_chg.external = false; /* USB supply */ @@ -3525,7 +3532,6 @@ static int ab8500_charger_probe(struct platform_device *pdev) di->usb_chg.max_out_curr = di->bm->chg_output_curr[di->bm->n_chg_out_curr - 1]; di->usb_chg.wdt_refresh = CHG_WD_INTERVAL; - di->usb_chg.enabled = di->bm->usb_enabled; di->usb_chg.external = false; di->usb_state.usb_current = -1; @@ -3599,14 +3605,12 @@ static int ab8500_charger_probe(struct platform_device *pdev) } /* Register USB charger class */ - if (di->usb_chg.enabled) { - di->usb_chg.psy = devm_power_supply_register(dev, - &ab8500_usb_chg_desc, - &usb_psy_cfg); - if (IS_ERR(di->usb_chg.psy)) { - dev_err(dev, "failed to register USB charger\n"); - return PTR_ERR(di->usb_chg.psy); - } + di->usb_chg.psy = devm_power_supply_register(dev, + &ab8500_usb_chg_desc, + &usb_psy_cfg); + if (IS_ERR(di->usb_chg.psy)) { + dev_err(dev, "failed to register USB charger\n"); + return PTR_ERR(di->usb_chg.psy); } /* Identify the connected charger types during startup */ From patchwork Sat Jan 23 22:19:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 369466 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2688150jam; Sat, 23 Jan 2021 14:21:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdRJ+6ez5glwqquF/S6W+JrSFBcAS0ZruJuPUqpaYXSb2+z4Ikfxa6tOCgX3c99d9t7MEd X-Received: by 2002:a17:906:6846:: with SMTP id a6mr2189063ejs.470.1611440519191; Sat, 23 Jan 2021 14:21:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611440519; cv=none; d=google.com; s=arc-20160816; b=t1+RN8+SL9WaW0xmpHEVqCtdbIZnMpXL8Y4W+KPzKiKY3jW68fDjEkdT5l6Jk85jnI pTzlWm/YIZLS/PZs1abBM3FjSrygo896JyX9Tloeu2nSsc/HI4vijfVpnbShoKVbzdbe jK7mlCpBqwJRLSPjE7apDxwxv9B6UqxjsUUUrbIl3C9SrYtu2JX0SjSHCNjVOW8TYGSI inObpsB70lZZkTmwIPFlK62Z6ClnrjrjqvVFXFf3/AcR5CppVx1/E88AH3dBa/quUIpk vCpDZnVRYXNQVzgqKtdrixw7I9mVYcD0xM6COYItu5MUQHeKqUqTaUFOq3tNdg8GUIrR fIXg== 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=8/JkWsoo9Q6Dhvm5nfPdfL/Tx4n2636EiCOBIgxbDkI=; b=otS8v+8rbl4BONF6fOWzWAlJuCg7FKjolccybyaQ4ouQAuGAgEX4eHUJSNwZDVeB9f qw4xNrYhPW6DTb380aiJ/R51SvTzwUZzW8tNOSL6wiQNpLy8DDzgRvUcO8gJZN4w3c6j rXZqmg8bURLBaa92AAKJHHYquTJUEOHlOTwsZPidLO+OwnzK3tqz3rhE/Vw4/gAshDIt qVra3Qfzhh9BLx6wkBUXC1SrFTiaL124cCmwfZmdlWtENYQzAA3MgPPC5Tm27+Y0Q8Z1 9A8Y1LMYxlRTa0F6YQqWXCZEm+2RJQ9VXH7RToSssCvKYrQwoivw62BfTr1LccuRI02D mgyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=evDEXxX6; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw11si4392384ejb.414.2021.01.23.14.21.59; Sat, 23 Jan 2021 14:21:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=evDEXxX6; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726316AbhAWWUo (ORCPT + 7 others); Sat, 23 Jan 2021 17:20:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbhAWWUm (ORCPT ); Sat, 23 Jan 2021 17:20:42 -0500 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D82BDC0617AB for ; Sat, 23 Jan 2021 14:19:32 -0800 (PST) Received: by mail-lj1-x230.google.com with SMTP id f11so10747415ljm.8 for ; Sat, 23 Jan 2021 14:19:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8/JkWsoo9Q6Dhvm5nfPdfL/Tx4n2636EiCOBIgxbDkI=; b=evDEXxX6//vF92EbY5WWm94jmJ6T7AUu8NaeU5AgS9cVA7aLjSs9L/zxTY207Wmiub s0Uvk1t6pzdtDqKIEqAFSraon8/cCRwtsOZ8hZ3YHFXyUv+Z+TWVirN0Nu8OZiF/EfBp c1/Of9QnOcPh17TyEmOoM7AWMx9GzcavOYDa+JS0LxHxuHzngZgINKxJZSorzhKXRk6j jy2rYl+pgO6AjBGbufpTyDuA5ZoC/tb3INLg1KRQRHHBE8DWJgqv4o3Yw5neRpSDs9R1 YKlsGK+mEfxZ2OccmgZyOgyIo67NpgvR74OzmTaJ8Blo7qV7znxv2WSPyga6dT3meWyi FfjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8/JkWsoo9Q6Dhvm5nfPdfL/Tx4n2636EiCOBIgxbDkI=; b=Z8LHDqfuDEkF0+x78raJJPC+v8tsTrCgfniaRLP4kyCFnJwIPz59Srq4P0hnQx6UNg TtmYlDrWYlI6v0Btj/xzVNJvIp6vHKqC71rVxlum9lcWm/Xu9C41XG5lEutzYZbXd2/B WLrphA2c1HRtfBIyDLWbL2PzHwIPRDo2CmZJBrTsBXpjjoh5upG2Dbnj6fNgv+bfdolo IE2nxlqfbmFT3dWmwl97BEEXYXhQp6Uo2XjGL11BKHyy5gHCoU1PJEygNfU6KsCUQdgg Ia8EBpGR8byRBCgsYeLlaB9EjoPz1drNbSGyAF4CNvrQOWLDUEPid1OYqsCdyuX+0X3Q sXXw== X-Gm-Message-State: AOAM530gFW7BYy6rDfVliwjICRJWHB0w9GlXSKi9BbMcaf8ssmBcTXD+ xDnbeE3EO6p3BFV1bJgSW91Y1g== X-Received: by 2002:a2e:6c0a:: with SMTP id h10mr65100ljc.149.1611440371374; Sat, 23 Jan 2021 14:19:31 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x17sm1313956lfg.0.2021.01.23.14.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 14:19:30 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Lee Jones , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 09/10] power: supply: ab8500: Drop unused member Date: Sat, 23 Jan 2021 23:19:07 +0100 Message-Id: <20210123221908.2993388-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210123221908.2993388-1-linus.walleij@linaro.org> References: <20210123221908.2993388-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This setting is read directly from the device tree in the ab8500_charger.c code. Signed-off-by: Linus Walleij --- drivers/power/supply/ab8500-bm.h | 1 - 1 file changed, 1 deletion(-) -- 2.29.2 diff --git a/drivers/power/supply/ab8500-bm.h b/drivers/power/supply/ab8500-bm.h index 871bdc1f5cbd..0c940571e5b0 100644 --- a/drivers/power/supply/ab8500-bm.h +++ b/drivers/power/supply/ab8500-bm.h @@ -506,7 +506,6 @@ struct abx500_bm_data { int usb_safety_tmr_h; int bkup_bat_v; int bkup_bat_i; - bool autopower_cfg; bool no_maintenance; bool capacity_scaling; bool chg_unknown_bat; From patchwork Sat Jan 23 22:19:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 369467 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp2688153jam; Sat, 23 Jan 2021 14:21:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8DA5xvuf5E/DgqbVHcxE0EQ8gsgJIxKz4Ongn2S+qjJyw7mI4ntqCywqvf9GTjW4smul9 X-Received: by 2002:a05:6402:70a:: with SMTP id w10mr2226326edx.184.1611440519624; Sat, 23 Jan 2021 14:21:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611440519; cv=none; d=google.com; s=arc-20160816; b=qmmmZzIeAOd7ZkX5FZ0OnZLNSHHdlvTk0c+enrXKCP37ge1I74gzQSezqp3c7VpAuG wsp45bVojn9RiCHIdzqzKwn0hVVNv8fx+wW6WV647YnV13wO9oxNmaDmj6fOUoxrog5Y YaEd0DHv0nCci6SPI+G9EhFWIX2wIZZH/F6HuY0Rcb+tg5ANE5vnFza6kk+BK7BimWEO tlW2IMWRBymVMNlyuKswPYRo77r7kTF+1kmEBna+PriMsqkZqpdgIoI30aU529fxLucZ zXv8LK1RK5Oo9Ujb8XLui49OccGI/PGcqQx2do7IJB/vOh4e53fybnxHyArfSPcPVLzN tthA== 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=28GEYQroX9iLNa89d1Np8JOfxiq6yVf6jznvYobgB2M=; b=aTcW1S/QlK4Y6ousnzGob7fG9b2bBnXXWn30cQthYXCIQcw5BBRbc6JFJ9bMa29lVD /x/VSs6foPE1GZ1VqxQHbitm+UU45jOaBSnWAowh5XR02LI9MmvYLkOsamVt21OeSf0v UR+y3utAv3wvIz9aoalLjiGkrZJG8P/mUI+UeixNQb4XUq3KnE0zbMrkFCflSdRUklsV ySDJRuPvFiqNruOSXU/cjWxu1gKioyVop0cMu8xO7stX+d/44THS1Jv/E3+ntOIANr6B QIFNegVQTuDcGVJho5nFfJF5VYiSNIq2U/grOHpFDtgPjU+3G2QcBehA4Bk8l58sLykS kFWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BTxKVf6x; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw11si4392384ejb.414.2021.01.23.14.21.59; Sat, 23 Jan 2021 14:21:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=@linaro.org header.s=google header.b=BTxKVf6x; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726309AbhAWWUo (ORCPT + 7 others); Sat, 23 Jan 2021 17:20:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726334AbhAWWUm (ORCPT ); Sat, 23 Jan 2021 17:20:42 -0500 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59FF5C061351 for ; Sat, 23 Jan 2021 14:19:34 -0800 (PST) Received: by mail-lj1-x22a.google.com with SMTP id i17so10808777ljn.1 for ; Sat, 23 Jan 2021 14:19:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=28GEYQroX9iLNa89d1Np8JOfxiq6yVf6jznvYobgB2M=; b=BTxKVf6x9tkaiDII85SLMqC5J5Az/1TLxrjxydQ9GYNYmCdAGFiQBXTYte9V+OI+fy 9VdGs9TcBDAhxJ+5D6nzq3iowB2hV6IjdlKjQIoKWaEGHoAf6Risro8n4rOdXMZz9zQs p7sD2juSc/O5lXj9GhHNuIYTgb7hw8izL0jYddJgX0YVNNFCiPC35jm8pbTTE1OU/bga 1GvwRehRyqhAJ46geb/JXng9QBp7u3ZAmA1qi9eGeNf55tcLauECnM7qd+l6S2fAEmb3 HK1/Vf0Djs3SfJ+JKD9YuWpdqe67KuYsEi+8Ictd7Yy6HNvS6t1AamrklqMe+3CIFqd0 C0Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=28GEYQroX9iLNa89d1Np8JOfxiq6yVf6jznvYobgB2M=; b=mV5m2w9JvyUpbN8nkyoWq4qCUr451z8UtURr474xVMmmO8be1Hk9yp/5QLe61MLfBC sp+ILkXvpQID07PAuSocyfFwE4dw6bzv/FpEICeo3r1YgDGQV43JBBVuzlDuNcXCY9R+ GSHBYOnyKk9+XZZV0Moe3vRrm8Jgx7m/CZ815JHW/cp6eNzYruiQJplmQMhyeBFC/81R 1vrpLp6AX0uyCtLmrIQBuwNjPLKRvl8y6NvtsKaOgPkr/s8aKa9/gtuLDDOZk08FIyEL l+5Datcfr7ypE6SZNeAaesBsqQKa6u9ErysZ7e9TSLGyyfGx8kRNVmSCrL/ETiptGCbU gN3Q== X-Gm-Message-State: AOAM531e6mZzzatvmwa19r8EEn4huBKLG36Yjm0X1W7hQ4Y7EI5FYMWP OcbCmeFjqQsE5yuYpoh5Gl6BvA== X-Received: by 2002:a2e:3201:: with SMTP id y1mr1442981ljy.12.1611440372881; Sat, 23 Jan 2021 14:19:32 -0800 (PST) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id x17sm1313956lfg.0.2021.01.23.14.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 14:19:32 -0800 (PST) From: Linus Walleij To: Sebastian Reichel , Lee Jones , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 10/10] power: supply: ab8500_bmdata: Use standard phandle Date: Sat, 23 Jan 2021 23:19:08 +0100 Message-Id: <20210123221908.2993388-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210123221908.2993388-1-linus.walleij@linaro.org> References: <20210123221908.2993388-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Look up the battery using the "monitored-battery" phandle as is nowadays a standard DT binding. The actual bindings for these charger elements are not upstream so let's sort out this mess by conforming to the standard. Signed-off-by: Linus Walleij --- drivers/power/supply/ab8500_bmdata.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.29.2 diff --git a/drivers/power/supply/ab8500_bmdata.c b/drivers/power/supply/ab8500_bmdata.c index c2b8c0bb77e2..258f399eaf37 100644 --- a/drivers/power/supply/ab8500_bmdata.c +++ b/drivers/power/supply/ab8500_bmdata.c @@ -499,8 +499,7 @@ int ab8500_bm_of_probe(struct device *dev, const char *btech; int i; - /* get phandle to 'battery-info' node */ - battery_node = of_parse_phandle(np, "battery", 0); + battery_node = of_parse_phandle(np, "monitored-battery", 0); if (!battery_node) { dev_err(dev, "battery node or reference missing\n"); return -EINVAL;