From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756082AbbCRQlr (ORCPT ); Wed, 18 Mar 2015 12:41:47 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:57646 "EHLO mx08-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932225AbbCRQlo (ORCPT ); Wed, 18 Mar 2015 12:41:44 -0400 Message-ID: <5509AAAB.8090906@st.com> Date: Wed, 18 Mar 2015 17:41:15 +0100 From: Maxime Coquelin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Lee Jones , , , , CC: Subject: Re: [STLinux Kernel] [PATCH 2/6] pinctrl: st: Introduce a 'get pin function' call References: <1426675899-19882-1-git-send-email-lee.jones@linaro.org> <1426675899-19882-3-git-send-email-lee.jones@linaro.org> In-Reply-To: <1426675899-19882-3-git-send-email-lee.jones@linaro.org> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.201.23.80] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68,1.0.33,0.0.0000 definitions=2015-03-18_05:2015-03-18,2015-03-18,1970-01-01 signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/18/2015 11:51 AM, Lee Jones wrote: > 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 > --- > 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; Shouldn't we print something if alt is NULL? Else we can think we are on alternate 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) > {