From patchwork Wed Mar 18 17:21:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 451557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 54FF014008F for ; Thu, 19 Mar 2015 04:22:48 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756559AbbCRRVb (ORCPT ); Wed, 18 Mar 2015 13:21:31 -0400 Received: from mail-wg0-f52.google.com ([74.125.82.52]:34895 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756543AbbCRRV3 (ORCPT ); Wed, 18 Mar 2015 13:21:29 -0400 Received: by wgdm6 with SMTP id m6so41084448wgd.2 for ; Wed, 18 Mar 2015 10:21:28 -0700 (PDT) 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=3NsCESBAso1qkyANxkkmYGgOYg17apWoecfHQy82hms=; b=JZbJ+HIyQAC8PxSEv7l5Fq1swKRpoQBIXGpoSo+NLUC6kPVI8pwzMZMUO+rtqtfZXc YAvLLZEaX8mybCMIktWrskDk1bjuQHBik2LsGK7SY93eBCurejzXK8jAdzwsmzLyGF99 Fwu0q9tPnTfzOtD+XgdhX3SA7ie7To69op2CZRZz7XPLaDR4ErqxD64t9Lv2rRJhkYTZ faL+2On8fuD10TrJMcsLP7OKi9qmoeHtrdJDn1D3Yl/y+TuDfRRL1gYn5rFvj0jt6OZr Hj2qlldDUquz+MiX1u8aHGC3kWR4LECT9Y0Xh6H7pbbZxlj61HqAZLoJjlBmKM8VVheW 9W+w== X-Gm-Message-State: ALoCoQkmtq8vJa9NJ/ZnTXIO3XYLqdPat015HBkA8V295GbcfNtuNYcPMTN+UGg+Qx3hiv2mhhCf X-Received: by 10.180.208.33 with SMTP id mb1mr8667313wic.69.1426699287945; Wed, 18 Mar 2015 10:21:27 -0700 (PDT) Received: from localhost.localdomain ([81.134.86.251]) by mx.google.com with ESMTPSA id v13sm4021936wij.10.2015.03.18.10.21.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Mar 2015 10:21:27 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, linux-gpio@vger.kernel.org Cc: lee.jones@linaro.org, kernel@stlinux.com Subject: [PATCH v2 2/6] pinctrl: st: Introduce a 'get pin function' call Date: Wed, 18 Mar 2015 17:21:15 +0000 Message-Id: <1426699279-9258-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426699279-9258-1-git-send-email-lee.jones@linaro.org> References: <1426699279-9258-1-git-send-email-lee.jones@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This call fetches the numerical function value a specified pin is currently operating in. Function zero is more often than not the GPIO function. Greater than zero values represent an alternative function. You'd need to either look those up in the Device Tree sources or the Programmer's Manual. Acked-by: Maxime Coquelin Signed-off-by: Lee Jones --- drivers/pinctrl/pinctrl-st.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 9e5ec00..5362e45 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -460,6 +460,20 @@ static void st_pctl_set_function(struct st_pio_control *pc, regmap_field_write(alt, val); } +static unsigned int st_pctl_get_pin_function(struct st_pio_control *pc, int pin) +{ + struct regmap_field *alt = pc->alt; + unsigned int val; + int offset = pin * 4; + + if (!alt) + return 0; + + regmap_field_read(alt, &val); + + return (val >> offset) & 0xf; +} + static unsigned long st_pinconf_delay_to_bit(unsigned int delay, const struct st_pctl_data *data, unsigned long config) {