From patchwork Fri Jun 17 05:00:22 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: 9182441 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 E06E26075F for ; Fri, 17 Jun 2016 05:01:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D584F2094F for ; Fri, 17 Jun 2016 05:01:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8E38283A8; Fri, 17 Jun 2016 05:01: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=-6.8 required=2.0 tests=BAYES_00,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 28B7D2094F for ; Fri, 17 Jun 2016 05:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933546AbcFQFAs (ORCPT ); Fri, 17 Jun 2016 01:00:48 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:35597 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933517AbcFQFAq (ORCPT ); Fri, 17 Jun 2016 01:00:46 -0400 Received: by mail-pa0-f65.google.com with SMTP id hf6so5001584pac.2 for ; Thu, 16 Jun 2016 22:00:46 -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=R28uQmG8BET4Bp2RZGL7w6q4vRV9v2V9hrIUD025ZC8=; b=ZlAIlUcCwWmyILW+2LZ0r3gRUdgUZc46GTcdVz/rJRY0hFPYij4Hm7J9wOy/jy48Hd +CfgP5GTVX3jabI99bLN66oBqU5/XDRRKIPRlqi4xRGjlDfiODzCNCO2WcCY8JbgjZsY VLpRVjM8imQwzVo3XbkZE4T+csM9KvnkHkhlkz8bIWDEs4wS6uyR4WbihfelvjHhR80k Qw7XdxPtHXrIHo5lK83ToxS+TsDvwQuMElgGfD+elUoiWF7Eg+HAcGHzbWstB2O4oO+z waHjYPdcICawl+AeeYhUDAMU/z3ODpQE+pKvhX6y45knnaTSlFHHz6YCjNyX4N3h5O3M bt7A== 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=R28uQmG8BET4Bp2RZGL7w6q4vRV9v2V9hrIUD025ZC8=; b=a63k3zAdmNDyXx54W97lLLUfolo+TXoY3ItynU8+wy7u1ZfvfxRUXK4bx9pQCz28aQ s+5+8LXxKcm8F7snso8gDzYh9GTtKjwskU7mncBd0U8QkLBZbGnnPLSuP4rsUeJTKj0q yN1buRtGaHeqm59gN5ybaiPgdNLbjd9EnZzRTQp2Jxau8B43ylP7KaPKNtnGUOHh2eyg 8YUBM0txEQaCAE3KW/SS0hMBOzryafxY9+K5h94tRy3SFv5B6lzfKY3xuWhFxFE5ND3s haVyZjrXhHALL1PcZMQG43x9Xlxf+C12H65OFZzT/x/ybbDixDQiL1HInUm0jEdA9Ha1 5ztA== X-Gm-Message-State: ALyK8tJvTCQYbbTcTmEMO00/pxFZZC5Qq2mC7rJlBYVt7k5cuLJMyTeKZH3pFcYzuhonzg== X-Received: by 10.66.47.196 with SMTP id f4mr240898pan.126.1466139646088; Thu, 16 Jun 2016 22:00:46 -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 d2sm60999741pfk.36.2016.06.16.22.00.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jun 2016 22:00:45 -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 v3 3/7] max8903: cleans up confusing relationship between dc_valid, dok and dcm. Date: Fri, 17 Jun 2016 15:00:22 +1000 Message-Id: <1466139626-51434-4-git-send-email-chris@lapa.com.au> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466139626-51434-1-git-send-email-chris@lapa.com.au> References: <1464849897-21527-3-git-send-email-chris@lapa.com.au> <1466139626-51434-1-git-send-email-chris@lapa.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 | 23 ++++++++++------------- include/linux/power/max8903_charger.h | 6 +++--- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/power/max8903_charger.c b/drivers/power/max8903_charger.c index 0a5b0e1..dbd911c4 100644 --- a/drivers/power/max8903_charger.c +++ b/drivers/power/max8903_charger.c @@ -211,27 +211,24 @@ 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. */