From patchwork Fri Jun 10 12:32:49 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: 9169633 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 2CF53607DA for ; Fri, 10 Jun 2016 12:33:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BC9D20700 for ; Fri, 10 Jun 2016 12:33:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10AFB28367; Fri, 10 Jun 2016 12:33:25 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FSL_HELO_HOME, 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 8C3E72835E for ; Fri, 10 Jun 2016 12:33:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932806AbcFJMdL (ORCPT ); Fri, 10 Jun 2016 08:33:11 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33873 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753492AbcFJMdI (ORCPT ); Fri, 10 Jun 2016 08:33:08 -0400 Received: by mail-pf0-f194.google.com with SMTP id 66so3251524pfy.1 for ; Fri, 10 Jun 2016 05:33:08 -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; bh=UnpN+JolSNtoRZvxXHPBNzRqqQss0GPIDauaglnhhUk=; b=rk4oEY8VAHfpXrQSMXvdr5srJ8YoeRni0gMJh8PrKn83hjicxfeoFseyVKSoWLvf/2 h67IXh50ci3x59Rp2V0njXJptjMwAxwvw2oDTvRQXIiFx7mDNqxNe82xD6PfMRU2h6mA uPLpzomHsq36da4uY85WjWrmSDOZiX8r0uavO/6FTlvrpDHiYwJJhcMfaF3h29VpYTHP LvKgiIVgvklGEtp/KlpgaypzBk+EnI7X4cZX0DKKLcsBHtgOCFZH/i7qUUZh0Qknm0dx XssPyaR2Vs8LoiWYgnJvJA1AmfDFb+IjGd2AJqA/bhtMbzSHHEHT9SyGvVq7FSWX9rlE np1A== 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; bh=UnpN+JolSNtoRZvxXHPBNzRqqQss0GPIDauaglnhhUk=; b=TgQhSC3Q9Fk9+uUC+OmibVv0my4Key5/oPYvgoZwOu3AV61oHyP0aRSKO7pSyF8YaV e2h36T3+EeibkDbef/cRIHTbK4kSz5zFMvmd+ITqYlL/QPyA2Har4m36+eSkuvSoTTlX 4J0UtcLPp1InxwgW429slfdd/0Yw9FRrIrmHmsbfsfTANP7As71A5tDz24c28Ud9ui+Z NXB2knnh5hWeqYMvO/0wMPBl+qI9qlouJPNr5Euon2sCSBLPBJ6AFPQqwPdgn0M8YKYy AaS1sKzsG32Lw6+pmxw/bbfE7iHihxS3Fdj/vTw5zmIGye3XYNEviIt4V+T6ULm56IwC kz5Q== X-Gm-Message-State: ALyK8tIiAl457ge2teFJsuAVW+fWSuJmW1NjV1P6TNVmIlrctwtnMrOsRG68w83xjt1nbg== X-Received: by 10.98.51.197 with SMTP id z188mr2142246pfz.100.1465561988134; Fri, 10 Jun 2016 05:33:08 -0700 (PDT) Received: from bbb-dev.home.lapa (c49-177-140-90.brasd4.vic.optusnet.com.au. [49.177.140.90]) by smtp.gmail.com with ESMTPSA id d8sm17506194pfg.72.2016.06.10.05.33.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jun 2016 05:33:07 -0700 (PDT) From: Chris Lapa X-Google-Original-From: Chris Lapa To: k.kozlowski@samsung.com Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Chris Lapa Subject: [PATCH v2 3/4] max8903: cleans up confusing relationship between dc_valid, dok and dcm. Date: Fri, 10 Jun 2016 22:32:49 +1000 Message-Id: <1465561970-18377-4-git-send-email-chris@lapa.com.au> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465561970-18377-1-git-send-email-chris@lapa.com.au> References: <1464849897-21527-3-git-send-email-chris@lapa.com.au> <1465561970-18377-1-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 --- drivers/power/max8903_charger.c | 40 ++++++++++++----------------------- include/linux/power/max8903_charger.h | 6 +++--- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/drivers/power/max8903_charger.c b/drivers/power/max8903_charger.c index d7544c8..20d4b55 100644 --- a/drivers/power/max8903_charger.c +++ b/drivers/power/max8903_charger.c @@ -282,9 +282,7 @@ static int max8903_probe(struct platform_device *pdev) if (charger->pdata->dc_valid) { if (charger->pdata->dok && - gpio_is_valid(charger->pdata->dok) && - charger->pdata->dcm && - gpio_is_valid(charger->pdata->dcm)) { + gpio_is_valid(charger->pdata->dok)) { ret = devm_gpio_request(dev, charger->pdata->dok, charger->psy_desc.name); @@ -295,6 +293,17 @@ static int max8903_probe(struct platform_device *pdev) return -EINVAL; } + gpio = charger->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 (charger->pdata->dcm) { + if (gpio_is_valid(charger->pdata->dcm)) { ret = devm_gpio_request(dev, charger->pdata->dcm, charger->psy_desc.name); @@ -305,35 +314,12 @@ static int max8903_probe(struct platform_device *pdev) return -EINVAL; } - gpio = charger->pdata->dok; /* PULL_UPed Interrupt */ - ta_in = gpio_get_value(gpio) ? 0 : 1; - gpio = charger->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 (charger->pdata->dcm) { - if (gpio_is_valid(charger->pdata->dcm)) { - ret = devm_gpio_request(dev, - charger->pdata->dcm, - charger->psy_desc.name); - if (ret) { - dev_err(dev, - "Failed GPIO request for dcm: %d err %d\n", - charger->pdata->dcm, ret); - return -EINVAL; - } - - gpio_set_value(charger->pdata->dcm, 0); - } else { - dev_err(dev, "Invalid pin: dcm.\n"); - return -EINVAL; - } - } } if (charger->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. */