From patchwork Fri Jun 24 02:26:08 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: 9196415 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 D89FA60871 for ; Fri, 24 Jun 2016 02:27:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9C802847E for ; Fri, 24 Jun 2016 02:27:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEA1F28485; Fri, 24 Jun 2016 02:27:54 +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=unavailable 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 C56622847E for ; Fri, 24 Jun 2016 02:27:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751590AbcFXC0h (ORCPT ); Thu, 23 Jun 2016 22:26:37 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:36059 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752009AbcFXC0f (ORCPT ); Thu, 23 Jun 2016 22:26:35 -0400 Received: by mail-pa0-f65.google.com with SMTP id av7so1661270pac.3 for ; Thu, 23 Jun 2016 19:26:35 -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=BNrojdQrjkdjVW4NkJjpvxhFGbNoI/mDTRtRGd8Bv2o=; b=VF1A1zvPE4gg3awDQocUE/AgyVWyzeMi3cipbOf3mttSuXFIu+xlMOWRK91Zw9Wwc3 dGDsXxPmNaovOv096Hc6k9ZBusgd0GdF6p4/Oy4l1rifCy2ufRKGqViLuTIJraMMuFmr /wuFYhIDolNeyTBhgKaQBZSUh1W9Dm/2hZUJpd3v15lc/HHlsO46QOj5vE9RLl2BChEd iiG7Fmlww6CyOsJ3SbTKE0Nxgkrp5rpU7asG+rWt04827aSFYwtjNm9bPdfV5DSAH4Uu 9vrUy8DHUQBJVzUWxM/Oy1BUolsdvFRVQaH0MWXWM4eRpJwpk8rmclOsLUS8rGXbOLi3 tuIQ== 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=BNrojdQrjkdjVW4NkJjpvxhFGbNoI/mDTRtRGd8Bv2o=; b=WSRaI5yFCUFVi9tt/FPy7O3RKvWvAvvG7VYGKoywX3O/xXlsdA+aAwnJ3odLUT45Wa YUevlNQ/Rr94ylNx7cTfU7aWX0KrL/0lyzBtMmUNeJrG94x9km/WA/BlYGkMrLDhXJfo a0tBDslmeCKP2seh2MgWm9UqSHGxe+bXUhw4JmpaXeGkBl1P87MGso+lZDyP2vgwz0sl yQ5R/FXUGOrl2Y+R8L4Af0rrBptcQxpAtYJ0LE8hZNyfsBAVtoXpUcxiyJWwPz6MJgDJ aKhPwQOOrBlxGm3OxWwfk4zAwfcni6kygC1cZhoWYcTxj1hBxkUHltvHPIObjq0F/GcV c8vQ== X-Gm-Message-State: ALyK8tLLrHxcA7tOQGPVmse5b1vNjsT27pf+hIhn9bzmlUcn/UNq0nHsoGp8BSujs3IR6A== X-Received: by 10.66.21.132 with SMTP id v4mr3180108pae.54.1466735194413; Thu, 23 Jun 2016 19:26:34 -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 y63sm3094614pfb.13.2016.06.23.19.26.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jun 2016 19:26:33 -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 v5 3/7] max8903: cleans up confusing relationship between dc_valid, dok and dcm. Date: Fri, 24 Jun 2016 12:26:08 +1000 Message-Id: <1466735172-13372-4-git-send-email-chris@cpdesign.com.au> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466735172-13372-1-git-send-email-chris@cpdesign.com.au> References: <1464849897-21527-3-git-send-email-chris@lapa.com.au> <1466735172-13372-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. */