From patchwork Sun Jun 19 22:27:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chris@lapa.com.au X-Patchwork-Id: 9186759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2544D60756 for ; Mon, 20 Jun 2016 07:23:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A2C323F88 for ; Mon, 20 Jun 2016 07:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F31F724B48; Mon, 20 Jun 2016 07:23:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58B1525221 for ; Mon, 20 Jun 2016 07:22:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753003AbcFTHWt (ORCPT ); Mon, 20 Jun 2016 03:22:49 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:33927 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751743AbcFTHWj (ORCPT ); Mon, 20 Jun 2016 03:22:39 -0400 Received: by mail-pa0-f68.google.com with SMTP id us13so10372750pab.1 for ; Mon, 20 Jun 2016 00:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lapa-com-au.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Za6LXYgbcTbhZOXaU5OzNDYW7juzEUg8wCUHYefIU74=; b=0gQpar7y/s/czMTxq+N0kNYwcDVys0r5zfJAoFw7We1EYCHp+XtVcaDfryrgBlUgBd NyTSozYLuEuir/cRYshzdprwV4cIYe+40YXFhTI6IuYsNOLN6DzqD2vCoPx9CYluTnob jvibXnvreF/8Hu7uK65rv+NFPvPf7JrmNOmEz9MXFIzS8Z4YOubkfDkCn4kZWD2Na17Q ZNBGIjuwWU5yv1geyv8h23/+V9pBlIZn6ux3XcCCgShXMRj94fKoEXmScKvuWqBFbcQj ieP6bf0AEvrTrHA/+QXB48POKbpBa//CAO0XPmr5jj3kPAUwuLx6tUMwDgFhHFfJJz25 9Bjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Za6LXYgbcTbhZOXaU5OzNDYW7juzEUg8wCUHYefIU74=; b=Gs29rjnaQzpczF830/BjaeII/dGGbqlhdlnS9sIgDyCr+QJjRO8HtujfNF0Wgcfnzm 90J91BftSbL0VfoHOrI4zW7U1xueKdXgTkBkbFY8Qhi52p0jGTTiY6P3/1uiQ8Y/BQ1P fqwmUQ5J6AK5kQ9dqAMR0nvaumgiHmUafSU/1TaK6zSh0vrern/Vuy2jSDQv3VQdFppl vp/Zicqtx4MNTfop4XdqQZ9eSYmE/X2s6aUajZIDj+XjvRBqVEg1gpseriqu4FrLwta4 ka5sRaomAP9EQ6SvALGF+NMeMJpxc+v6lceoH2FJ/xxoUeBNHi4AKj35ZEGdxqv1ffxT WhPQ== X-Gm-Message-State: ALyK8tJK7wS9qO0Yw9wVidNAKzmrBYInXQLu5ZjF6PCD3FysXcbenuSLkOAdr9cDRcQSaA== X-Received: by 10.66.101.231 with SMTP id fj7mr20232812pab.59.1466406442123; Mon, 20 Jun 2016 00:07:22 -0700 (PDT) Received: from bbb-dev.management.cpd (163.164.70.115.static.exetel.com.au. [115.70.164.163]) by smtp.gmail.com with ESMTPSA id h5sm78872398pfb.81.2016.06.20.00.07.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jun 2016 00:07:21 -0700 (PDT) From: Chris Lapa X-Google-Original-From: Chris Lapa To: k.kozlowski@samsung.com, dwmw2@infradead.org, dbaryshkov@gmail.com, sre@kernel.org, mark.rutland@arm.com, robh+dt@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Chris Lapa Subject: [PATCH v4 3/7] max8903: cleans up confusing relationship between dc_valid, dok and dcm. Date: Mon, 20 Jun 2016 08:27:18 +1000 Message-Id: <1466375242-38354-4-git-send-email-chris@cpdesign.com.au> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466375242-38354-1-git-send-email-chris@cpdesign.com.au> References: <1464849897-21527-3-git-send-email-chris@lapa.com.au> <1466375242-38354-1-git-send-email-chris@cpdesign.com.au> In-Reply-To: <1464849897-21527-3-git-send-email-chris@lapa.com.au> References: <1464849897-21527-3-git-send-email-chris@lapa.com.au> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Chris Lapa The max8903_charger.h file indicated that dcm and dok were not optional when dc_valid is set. It makes sense to have dok as a compulsory pin when dc_valid is given. However dcm can be optionally wired to a fixed level especially when the circuit is configured for dc power exclusively. The previous implementation already allowed for this somewhat, however no error was given if dok wasn't given whilst dc_valid was. The new implementation enforces dok presence when dc_valid is given. Whilst allowing dcm to be optional. Signed-off-by: Chris Lapa Reviewed-by: Krzysztof Kozlowski --- drivers/power/max8903_charger.c | 22 +++++++++------------- include/linux/power/max8903_charger.h | 6 +++--- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/power/max8903_charger.c b/drivers/power/max8903_charger.c index 0a5b0e1..6ec705f 100644 --- a/drivers/power/max8903_charger.c +++ b/drivers/power/max8903_charger.c @@ -211,27 +211,23 @@ static int max8903_probe(struct platform_device *pdev) } if (pdata->dc_valid) { - if (pdata->dok && gpio_is_valid(pdata->dok) && - pdata->dcm && gpio_is_valid(pdata->dcm)) { + if (pdata->dok && gpio_is_valid(pdata->dok)) { gpio = pdata->dok; /* PULL_UPed Interrupt */ ta_in = gpio_get_value(gpio) ? 0 : 1; + } else { + dev_err(dev, "When DC is wired, DOK should be wired as well.\n"); + return -EINVAL; + } + } + if (pdata->dcm) { + if (gpio_is_valid(pdata->dcm)) { gpio = pdata->dcm; /* Output */ gpio_set_value(gpio, ta_in); } else { - dev_err(dev, "When DC is wired, DOK and DCM should" - " be wired as well.\n"); + dev_err(dev, "Invalid pin: dcm.\n"); return -EINVAL; } - } else { - if (pdata->dcm) { - if (gpio_is_valid(pdata->dcm)) - gpio_set_value(pdata->dcm, 0); - else { - dev_err(dev, "Invalid pin: dcm.\n"); - return -EINVAL; - } - } } if (pdata->usb_valid) { diff --git a/include/linux/power/max8903_charger.h b/include/linux/power/max8903_charger.h index 24f51db..89d3f1c 100644 --- a/include/linux/power/max8903_charger.h +++ b/include/linux/power/max8903_charger.h @@ -26,8 +26,8 @@ struct max8903_pdata { /* * GPIOs - * cen, chg, flt, and usus are optional. - * dok, dcm, and uok are not optional depending on the status of + * cen, chg, flt, dcm and usus are optional. + * dok and uok are not optional depending on the status of * dc_valid and usb_valid. */ int cen; /* Charger Enable input */ @@ -41,7 +41,7 @@ struct max8903_pdata { /* * DC(Adapter/TA) is wired * When dc_valid is true, - * dok and dcm should be valid. + * dok should be valid. * * At least one of dc_valid or usb_valid should be true. */