From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD18FC6FA82 for ; Thu, 29 Sep 2022 08:51:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:CC:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sx67SA43uRoQOX1bO3tj1jN57fE27FeCSUdjl1kCIyk=; b=ty1U9qKQvhY28V gmLsZ2sukqtK2JgI3p0ciHkHtCR9GE5EO4ku/G0G66ZN0CPjperSxuNUaK+d4lWi/T8/vtqr/aTuG 1mwHzw+lquHhp4lnse6P78ckdSlyyWLZGoUulTiLeb1dH+TPBjw4ElpxETa7jRK+AJm1EWDOZhLQ/ bnvi0X+xE66QrCc49LOFKYQeSPDFGP3r8NAsNxDyNpkz6/l+w8k7g+dvPj/q2Nvx6J4xlwaylqWGX HxTtgwZgxsEM1vREBUNMnfFZUQoGM/0gx78LUUb8QbwqVaL+EMCYa34XIBpMIuxYRC0PQB9bn8/aU ZlFpDh0P49qUqjsDpnWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odpF2-001ucR-Ss; Thu, 29 Sep 2022 08:50:00 +0000 Received: from mx07-00178001.pphosted.com ([185.132.182.106]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odpEz-001uaR-5n for linux-arm-kernel@lists.infradead.org; Thu, 29 Sep 2022 08:49:59 +0000 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28T3rrg9004118; Thu, 29 Sep 2022 10:49:32 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=Wiofu9rgpuc65f8rPaqHRSUum4t8vxulsqM/fN8xAIQ=; b=g234rio/WSMJtn7ImOlYWED7msuragbYqoRTN/yYULxEHMeqp6jile9k1UgKq075AZko keL7sIRshNQc/dPDPMsGBuog3J4z4qljDQpqf3wu6n1LbZt5gcAG85icT5ZG07pngC83 ii95L6LJa3xQDPcewAKkJVvzqxeKi1QjEyyxDkHIFENih375+BH+Al9+yAU0SmtozOB7 VBz5ruwcXM+7gfe6k6/1Gt5QfxHEYQN25bQR+6A/onR4RypEMAeFC7CwOdNU/rRSbA1N qBgj8KQBJpm7JKBNlduw1Yujj4UXhuSMUIlkbi3crbb+NKg9fLUhN19k7C9RwMxKxMrM vw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3jss82p4r3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Sep 2022 10:49:31 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2301B10002A; Thu, 29 Sep 2022 10:49:30 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 1AA1021A217; Thu, 29 Sep 2022 10:49:30 +0200 (CEST) Received: from [10.201.21.72] (10.75.127.45) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2375.31; Thu, 29 Sep 2022 10:49:29 +0200 Message-ID: <88c9109d-2c97-ac21-91dc-4025dd27b552@foss.st.com> Date: Thu, 29 Sep 2022 10:49:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] pinctrl: st: stop abusing of_get_named_gpio() Content-Language: en-US To: Dmitry Torokhov , Linus Walleij CC: Andy Shevchenko , , , References: From: Patrice CHOTARD In-Reply-To: X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-29_04,2022-09-29_02,2022-06-22_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220929_014957_749190_21DE942E X-CRM114-Status: GOOD ( 28.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Dmitry On 9/28/22 22:20, Dmitry Torokhov wrote: > Pin descriptions for this chip only look like standard GPIO device tree > descriptions, while in fact they contain additional data (in excess of > number of cells specified in description of gpio controllers). They also > refer to only pins/gpios belonging to the driver and not to arbitrary > gpio in the system. > > Because we want to stop exporting OF-specific handlers from gpiolib-of, > let's parse the pin reference ourself instead of trying to call > of_get_named_gpio(). > > Signed-off-by: Dmitry Torokhov > --- > > Just compiled, not tested on real hardware. > > drivers/pinctrl/pinctrl-st.c | 34 ++++++++++++++++++++++++++++++---- > 1 file changed, 30 insertions(+), 4 deletions(-) > > diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c > index 0fea71fd9a00..cf7f9cbe6044 100644 > --- a/drivers/pinctrl/pinctrl-st.c > +++ b/drivers/pinctrl/pinctrl-st.c > @@ -12,7 +12,6 @@ > #include > #include > #include > -#include /* of_get_named_gpio() */ > #include > #include > #include > @@ -1162,6 +1161,31 @@ static void st_parse_syscfgs(struct st_pinctrl *info, int bank, > return; > } > > +static int st_pctl_dt_calculate_pin(struct st_pinctrl *info, > + phandle bank, unsigned int offset) > +{ > + struct device_node *np; > + struct gpio_chip *chip; > + int retval = -EINVAL; > + int i; > + > + np = of_find_node_by_phandle(bank); > + if (!np) > + return -EINVAL; > + > + for (i = 0; i < info->nbanks; i++) { > + chip = &info->banks[i].gpio_chip; > + if (chip->of_node == np) { > + if (offset < chip->ngpio) > + retval = chip->base + offset; > + break; > + } > + } > + > + of_node_put(np); > + return retval; > +} > + > /* > * Each pin is represented in of the below forms. > * > @@ -1175,6 +1199,8 @@ static int st_pctl_dt_parse_groups(struct device_node *np, > struct device *dev = info->dev; > struct st_pinconf *conf; > struct device_node *pins; > + phandle bank; > + unsigned int offset; > int i = 0, npins = 0, nr_props, ret = 0; > > pins = of_get_child_by_name(np, "st,pins"); > @@ -1214,9 +1240,9 @@ static int st_pctl_dt_parse_groups(struct device_node *np, > conf = &grp->pin_conf[i]; > > /* bank & offset */ > - be32_to_cpup(list++); > - be32_to_cpup(list++); > - conf->pin = of_get_named_gpio(pins, pp->name, 0); > + bank = be32_to_cpup(list++); > + offset = be32_to_cpup(list++); > + conf->pin = st_pctl_dt_calculate_pin(info, bank, offset); > conf->name = pp->name; > grp->pins[i] = conf->pin; > /* mux */ I tested it on stih410-b2260 board Tested-by: Patrice Chotard Reviewed-by: Patrice Chotard Thanks Patrice _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel