Received: by 10.192.165.148 with SMTP id m20csp891532imm; Fri, 27 Apr 2018 09:08:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpfjFJDh9KsT1zcxUSGD7bwe2rC6bmkkbDVFhUFmY527kmAPzPi8411pQMaf1wMsQcwuiVj X-Received: by 2002:a63:6108:: with SMTP id v8-v6mr2604594pgb.245.1524845291766; Fri, 27 Apr 2018 09:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524845291; cv=none; d=google.com; s=arc-20160816; b=JHTBZ/dn1sl7K0dj5iCCg36ZvjRFn+SglFguwLYNB8q9PsKhKipAn6E8ArIgPFjLmu UlV2Vpq5aDyxacbDs3rYsFsk/lA28weIq+F+lkC/oLX/m5+PP2+e8JCaVVDaciWZ94Us T2ZvOfqii1dPLtyWL0XZXbIbgZ27mEjxu4JVPgiOBoteg4OJ0OpRtihIipf3AR2u/OuZ lv7U2BpmhRGBtEYvqCQw6aMCj4ItRMVDLVNTS0piD1SkhFfumQsvAw1VITb1s3YDqzIV DBVM5BM9HpYsWeKbRzIF8/711fDy5oqcD8etxd3eW+yr7Bqozaq/hH5CZ0gWrGgZtQ2i lPEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Dz4Gws3xhUlNx1OTJSYhaIvQraQuR3BAxWDa3g6IUqE=; b=SZuA9HJzOzESYz7qHbyNjaysiadn82+sxaOLu6oTBiv2BtlEH/WCXGBjvVts/9D0rA dmD9yCP538amMGIl0/acwr5tJANipAWo12i+MyqCpnnVfOArf8ryIdD00y1WZ3L59VdA 301cSlEnc4LHaI+oACEV8wP335grgqAH6MDKmhVMqnMWkCdY6OuX5l54+QU0wp/xGIQf LuG56g3MFUQtWzFh/A9Mfu08jkuRU6dqtQ1fx00w2u+8kG/2ARH56uuDHQA2oZrgyyJa 4dzB4i8GzqeNOz6QEZfrNJrDsokkfccFgecK0Wyk8KdjrGUAqM1O4Ro6HrOaPEURxfhj EG9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HCD+bDdg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21-v6si1434750pll.460.2018.04.27.09.07.53; Fri, 27 Apr 2018 09:08:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HCD+bDdg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932879AbeD0QGP (ORCPT + 99 others); Fri, 27 Apr 2018 12:06:15 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:43346 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758639AbeD0QF1 (ORCPT ); Fri, 27 Apr 2018 12:05:27 -0400 Received: by mail-lf0-f66.google.com with SMTP id g12-v6so3425241lfb.10; Fri, 27 Apr 2018 09:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dz4Gws3xhUlNx1OTJSYhaIvQraQuR3BAxWDa3g6IUqE=; b=HCD+bDdg/bhyszY2bbJPs0bMPaPV5NyDROr6Q4fkfWfavqLXAaL98Gs0ODOYZ1Jwou HJW/6GeGHrovRtqITa6vTccMHZUx69G6S9p2wNITs7Qv1m6cLmT1uDoXVbicdLAj8X43 tO/udG165eq7KYfUBtbC+LOu0IjIorfbfzhmXTTfIjeHsuyAiWsaA6RJzklJX/CGGcot dnySbn1TgHWAzqUtROYdJPiDkMm8J8j9gD3w/73vp7qyjQ3fCncc1m3fPgbXwRJbgTsG hC5GcQC8YXGuDzUYEaN+B62GPB8UYF98zWuioDDBXF60pbux8uIbZehKCesFSlH77la6 O0cg== 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=Dz4Gws3xhUlNx1OTJSYhaIvQraQuR3BAxWDa3g6IUqE=; b=lhwpceEkXkOvJBngfUc0mUbTB40YWwRcqCuwHFGh4ARYTV0CJYLWKr01Mkb749jZp+ EbtAqxpo717v5aX+4CP5asPxyVPOA4/b8BdKjQ6P/Oak/yO6zABDCD7DOcU87A9GAGj1 dPw9RzeZ4co8LeYaI26f9JF423NMG5f8VzxafovJGxc+Oa+pwTT1bRtnJw0gOTbolURr YlPkSeal8sCW0+mHPOfVOvOdK9tcBraxjNKRqIEQInGdldeLjFpd0L2xb7TPj+nunkvX kzaTHt3zpe0Tu2ewCA/v4l3XrmiNlLs/XSK08g6nmPVmaBEaX37eZMbX3am5HA0aEkYa ltEw== X-Gm-Message-State: ALQs6tC5kGmUGAKkHrI7M277YPTM5Aor9+6U4A9nBc/enjot9DyH1wAG SnvychKLvbXKhLJEY5WVFvU= X-Received: by 2002:a2e:7113:: with SMTP id m19-v6mr2183857ljc.44.1524845125960; Fri, 27 Apr 2018 09:05:25 -0700 (PDT) Received: from localhost.localdomain (user-94-254-173-44.play-internet.pl. [94.254.173.44]) by smtp.googlemail.com with ESMTPSA id j85-v6sm324083lfh.5.2018.04.27.09.05.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Apr 2018 09:05:25 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Chmiel?= To: lgirdwood@gmail.com, broonie@kernel.org, sre@kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, =?UTF-8?q?Pawe=C5=82=20Chmiel?= Subject: [PATCH 3/4] power: supply: max8998-charger: Parse device tree for required data. Date: Fri, 27 Apr 2018 18:03:01 +0200 Message-Id: <1524844982-4714-4-git-send-email-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524844982-4714-1-git-send-email-pawel.mikolaj.chmiel@gmail.com> References: <1524844982-4714-1-git-send-email-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds missing code for reading charger configuration from devicetree. Fixes: ee999fb3f17f ("mfd: max8998: Add support for Device Tree") Signed-off-by: Paweł Chmiel --- drivers/power/supply/max8998_charger.c | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/power/supply/max8998_charger.c b/drivers/power/supply/max8998_charger.c index 66438029bdd0..8fa0c3357625 100644 --- a/drivers/power/supply/max8998_charger.c +++ b/drivers/power/supply/max8998_charger.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -82,6 +83,49 @@ static const struct power_supply_desc max8998_battery_desc = { .num_properties = ARRAY_SIZE(max8998_battery_props), }; +static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev, + struct max8998_platform_data *pdata) +{ + struct device_node *pmic_np = iodev->dev->of_node; + struct device_node *charger_np; + int ret; + + charger_np = of_get_child_by_name(pmic_np, "charger"); + if (!charger_np) { + dev_err(iodev->dev, "could not find charger sub-node\n"); + return -EINVAL; + } + + ret = of_property_read_u32(charger_np, + "max8998,charge-eoc", + &pdata->eoc); + if (ret < 0) { + dev_err(iodev->dev, + "Could not find max8998,charge-eoc in devicetree\n"); + return ret; + } + + ret = of_property_read_u32(charger_np, + "max8998,charge-restart", + &pdata->restart); + if (ret < 0) { + dev_err(iodev->dev, + "Could not find max8998,charge-restart in devicetree\n"); + return ret; + } + + ret = of_property_read_u32(charger_np, + "max8998,charge-timeout", + &pdata->timeout); + if (ret < 0) { + dev_err(iodev->dev, + "Could not find max8998,charge-timeout in devicetree\n"); + return ret; + } + + return 0; +} + static int max8998_battery_probe(struct platform_device *pdev) { struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent); @@ -96,6 +140,12 @@ static int max8998_battery_probe(struct platform_device *pdev) return -ENODEV; } + if (IS_ENABLED(CONFIG_OF) && iodev->dev->of_node) { + ret = max8998_pmic_dt_parse_pdata(iodev, pdata); + if (ret) + return ret; + } + max8998 = devm_kzalloc(&pdev->dev, sizeof(struct max8998_battery_data), GFP_KERNEL); if (!max8998) -- 2.7.4