From patchwork Wed Mar 18 10:51:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 451371 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 2E47E14009B for ; Wed, 18 Mar 2015 21:52:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755990AbbCRKvz (ORCPT ); Wed, 18 Mar 2015 06:51:55 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:33602 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755689AbbCRKvx (ORCPT ); Wed, 18 Mar 2015 06:51:53 -0400 Received: by wgbcc7 with SMTP id cc7so31666652wgb.0 for ; Wed, 18 Mar 2015 03:51:52 -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=lR2xGM2uJVjri0uxYMbw6WllKkfA9AnJKsudLQhHsHc=; b=dMzavPH10r2M0bZsTRABnlSH4J5wLKFLBO72xDhHEIUtb3tmJYk1/yKA9jjSXLCpCV shH0eW/r/y7Au81AiOHObYdkCsb8eMLBiyze1PIYSTj477lUfeW05/dZySBheTyCXdTb PnJiFciRwUl4THe6Jg0sCPOcrqwfq5tWJXvxJMFDLlE4bxtgSF0371aqPcZNRcTAXN7w taelZdQQ0HL1cvglJt06ofS3MzpYZMCD63CQMMumZ1gsNbnPi1SQAS1yBn8qtOLwdlsP jo3Al4pifHZN1uiTWZirv9omKYlMe9UR6q7XXxlLBAd1lPtLBpaGS3wkZpQQyxm3bJeY hKpA== X-Gm-Message-State: ALoCoQnSG9+/vnV+J0ZEdqVw18gR0zP03HcsW2CEMkWuefw1aJ/lgT15CRfYHurE8l2DNhwTIkJr X-Received: by 10.180.90.166 with SMTP id bx6mr5533885wib.65.1426675912202; Wed, 18 Mar 2015 03:51:52 -0700 (PDT) Received: from localhost.localdomain ([81.134.86.251]) by mx.google.com with ESMTPSA id gz3sm2665532wib.1.2015.03.18.03.51.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Mar 2015 03:51:51 -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 2/6] pinctrl: st: Introduce a 'get pin function' call Date: Wed, 18 Mar 2015 10:51:35 +0000 Message-Id: <1426675899-19882-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426675899-19882-1-git-send-email-lee.jones@linaro.org> References: <1426675899-19882-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. Signed-off-by: Lee Jones Acked-by: Maxime Coquelin --- 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) {