From patchwork Fri Jan 31 05:25:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 3560091 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2AA33C02DC for ; Fri, 31 Jan 2014 05:25:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3FDC2201DD for ; Fri, 31 Jan 2014 05:25:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58A89201BB for ; Fri, 31 Jan 2014 05:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751327AbaAaFZQ (ORCPT ); Fri, 31 Jan 2014 00:25:16 -0500 Received: from mail-pb0-f43.google.com ([209.85.160.43]:35887 "EHLO mail-pb0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751229AbaAaFZP (ORCPT ); Fri, 31 Jan 2014 00:25:15 -0500 Received: by mail-pb0-f43.google.com with SMTP id md12so4028810pbc.2 for ; Thu, 30 Jan 2014 21:25:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:subject:user-agent:from:to:cc:in-reply-to :references:mime-version:content-type; bh=7hxNFnGWLrO2iu+T1rOyJ08TWxSJUJU1CYsz4FiNn5U=; b=aeTzYd6Oo3soWVm1FGVmNOB6Zt2iRFm+x9YyBwfSMIv98ncGwSoIpm1qvL/3b4PF6/ 4YT6huUgDRXzRudonW6OkIzB6CMXTDwf+h3I8Df/+lD95bCmranng5EG33n6ZTv8v21o qp4dyhdwC/1jcSd8F5bvjBXGsKVdzdMlvGxdE4Cwq/Of8So+j0WubeDeLXYSkZTmWd3B sIs6dYPDGKl95MUSkxXtVSz8OxE6Iru+sjZfGngWpKmlNX9/cDR8T3goJKxdHxrWoOI3 DKuWLEM2vaGMsQ0PGWsaCKTRE/HRcJdZQh5xINF+uBN8AYvepgyXTRzY6UcstBeOJtG9 pz9A== X-Received: by 10.68.238.201 with SMTP id vm9mr18389275pbc.18.1391145915085; Thu, 30 Jan 2014 21:25:15 -0800 (PST) Received: from morimoto-Dell-XPS420.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id vf7sm23342415pbc.5.2014.01.30.21.25.13 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 30 Jan 2014 21:25:14 -0800 (PST) Date: Thu, 30 Jan 2014 21:25:14 -0800 (PST) Message-ID: <87eh3o7mfc.wl%kuninori.morimoto.gx@gmail.com> Subject: [PATCH] regulator: gpio: bugfix: add gpios-status for DT User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 From: Kuninori Morimoto To: Mark Brown , Liam Girdwood , Lee Jones Cc: Simon , Magnus , Linux-SH , linux-kernel@vger.kernel.org In-Reply-To: <20140130121251.GO22609@sirena.org.uk> References: <87r47r6v48.wl%kuninori.morimoto.gx@gmail.com> <20140129124516.GZ11841@sirena.org.uk> <87mwieib5x.wl%kuninori.morimoto.gx@gmail.com> <20140130121251.GO22609@sirena.org.uk> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto config->gpios[x].flags indicates initial pin status, and it will be used for drvdata->state on gpio_regulator_probe(). But, current of_get_gpio_regulator_config() doesn't care about this flags. This patch adds new gpios-status property in order to care about initial pin status. Signed-off-by: Kuninori Morimoto --- .../bindings/regulator/gpio-regulator.txt | 1 + drivers/regulator/gpio-regulator.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt index 63c6598..3ecb585 100644 --- a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt @@ -8,6 +8,7 @@ Required properties: Optional properties: - enable-gpio : GPIO to use to enable/disable the regulator. - gpios : GPIO group used to control voltage. +- gpios-states : gpios pin's initial states. 1 means HIGH - startup-delay-us : Startup time in microseconds. - enable-active-high : Polarity of GPIO is active high (default is low). diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index c0a1d00..7c8e37a 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -172,11 +172,22 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) if (!config->gpios) return ERR_PTR(-ENOMEM); + prop = of_find_property(np, "gpios-states", NULL); + if (prop) { + proplen = prop->length / sizeof(int); + if (proplen != config->nr_gpios) { + /* gpios <-> gpios-states mismatch */ + prop = NULL; + } + } + for (i = 0; i < config->nr_gpios; i++) { gpio = of_get_named_gpio(np, "gpios", i); if (gpio < 0) break; config->gpios[i].gpio = gpio; + if (prop && be32_to_cpup((int *)prop->value + i)) + config->gpios[i].flags = GPIOF_OUT_INIT_HIGH; } /* Fetch states. */