From patchwork Fri Aug 26 12:19:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 74788 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp308760qga; Fri, 26 Aug 2016 05:19:26 -0700 (PDT) X-Received: by 10.66.136.49 with SMTP id px17mr5465354pab.122.1472213965984; Fri, 26 Aug 2016 05:19:25 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si20997207pao.113.2016.08.26.05.19.25; Fri, 26 Aug 2016 05:19:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752381AbcHZMTY (ORCPT + 4 others); Fri, 26 Aug 2016 08:19:24 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:36433 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976AbcHZMTY (ORCPT ); Fri, 26 Aug 2016 08:19:24 -0400 Received: by mail-pa0-f43.google.com with SMTP id di2so26983419pad.3 for ; Fri, 26 Aug 2016 05:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=VCl1M5nFSjrAdyGVaxAKb2+mnGbwkE0rEeQeBr89VRI=; b=VQ7aoxbo/H8vy11IbQ1GC5K84jtfYi05TZ8KgSOKUqEu16OZnhp+5HkWH47kSNcCqt jIXvNysiVPTt7yLW5/8qHE7XxUiXOsqHyMoLMXp0RS4zwrrZakkp7mGtEpfG2eYMcRy4 wbaK4s2BsUaN8+QlxCa5wgdQ7PhnF2l3WgErg= 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; bh=VCl1M5nFSjrAdyGVaxAKb2+mnGbwkE0rEeQeBr89VRI=; b=F5mbUYWSWZrq8ocPO08d6iH2ClDCXi7KjdjHTxzBQzpTZtLtJgAZLQvej4svCJ0nFE h+7qkkXl6PgR3//XRSSvMkmbRmJov2C6hYkC5qGP4f9fbcJI93Ih0QDBlxKWFRNJg2U0 /0V48rYAHI5NrFMVj14hcCCxAmDghiUaSexQrBZ5wBt98u4cGTgvr6rAIzjCPmF7DVzs kvuHMLsJSKYXYEw6Rsx6I+08U1fk0KQLLrLCdSo2694+Eetgy4v8Pz8UJZ3Kf2dCPhz0 MjWjnPngQVo/Pmtr1r1FORT6Zn5fk2XKSU+UhLjZMxcXPikcTrUpymIp6haVz+w97YNy lXqQ== X-Gm-Message-State: AE9vXwOTGJE9peXCZHyNwiGtqDvCgn+41t7L8CMO2R9ZlBPzvkF1zdqtyW6l3u2EsPv8Hd4/ X-Received: by 10.66.136.74 with SMTP id py10mr5586761pab.114.1472213963213; Fri, 26 Aug 2016 05:19:23 -0700 (PDT) Received: from localhost.localdomain ([104.237.91.147]) by smtp.gmail.com with ESMTPSA id c64sm28442223pfg.35.2016.08.26.05.19.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Aug 2016 05:19:22 -0700 (PDT) From: Jun Nie To: devicetree@vger.kernel.org, linus.walleij@linaro.org, linux-gpio@vger.kernel.org Cc: shawn.guo@linaro.org, jason.liu@linaro.org, Jun Nie Subject: [PATCH 1/3] pinctrl: export pin_request to support parent pin Date: Fri, 26 Aug 2016 20:19:02 +0800 Message-Id: <1472213942-4815-1-git-send-email-jun.nie@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Some pin functions may be controlled in 2nd level multiplex. We need configure 1st level multiplex when request such functions. Export pin_request functionality so that parent can be configured automatically with calling it in pinmux_ops->request(). Signed-off-by: Jun Nie --- drivers/pinctrl/core.c | 20 ++++++++++++++++++++ drivers/pinctrl/pinmux.c | 3 ++- drivers/pinctrl/pinmux.h | 9 +++++++++ include/linux/pinctrl/pinctrl.h | 2 ++ 4 files changed, 33 insertions(+), 1 deletion(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index fb38e20..0782a93 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -688,6 +688,26 @@ int pinctrl_gpio_direction_output(unsigned gpio) } EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_output); +/** + * pinctrl_request_pin() - request a single pin to be used + * @offset: the pin number from pinctrl dev pin number space + */ +int pinctrl_request_pin(struct pinctrl_dev *pctldev, + int offset, const char *owner) +{ + int ret; + + mutex_lock(&pctldev->mutex); + + ret = pin_request(pctldev, offset, owner, NULL); + + mutex_unlock(&pctldev->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(pinctrl_request_pin); + + static struct pinctrl_state *find_state(struct pinctrl *p, const char *name) { diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index ece7028..b18c1f0 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -80,7 +80,7 @@ int pinmux_validate_map(struct pinctrl_map const *map, int i) * @gpio_range: the range matching the GPIO pin if this is a request for a * single GPIO pin */ -static int pin_request(struct pinctrl_dev *pctldev, +int pin_request(struct pinctrl_dev *pctldev, int pin, const char *owner, struct pinctrl_gpio_range *gpio_range) { @@ -180,6 +180,7 @@ out: return status; } +EXPORT_SYMBOL(pin_request); /** * pin_free() - release a single muxed in pin so something else can be muxed diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h index d1a98b1c..6ff9baf 100644 --- a/drivers/pinctrl/pinmux.h +++ b/drivers/pinctrl/pinmux.h @@ -30,6 +30,9 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, void pinmux_free_setting(struct pinctrl_setting const *setting); int pinmux_enable_setting(struct pinctrl_setting const *setting); void pinmux_disable_setting(struct pinctrl_setting const *setting); +int pin_request(struct pinctrl_dev *pctldev, + int pin, const char *owner, + struct pinctrl_gpio_range *gpio_range); #else @@ -83,6 +86,12 @@ static inline void pinmux_disable_setting( { } +int pin_request(struct pinctrl_dev *pctldev, + int pin, const char *owner, + struct pinctrl_gpio_range *gpio_range) +{ +} + #endif #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS) diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h index a42e57d..13bb7a1 100644 --- a/include/linux/pinctrl/pinctrl.h +++ b/include/linux/pinctrl/pinctrl.h @@ -167,6 +167,8 @@ pinctrl_find_gpio_range_from_pin(struct pinctrl_dev *pctldev, extern int pinctrl_get_group_pins(struct pinctrl_dev *pctldev, const char *pin_group, const unsigned **pins, unsigned *num_pins); +extern int pinctrl_request_pin(struct pinctrl_dev *pctldev, + int offset, const char *owner); #ifdef CONFIG_OF extern struct pinctrl_dev *of_pinctrl_get(struct device_node *np);