From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933175AbbCQLCU (ORCPT ); Tue, 17 Mar 2015 07:02:20 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:42424 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933072AbbCQLCO (ORCPT ); Tue, 17 Mar 2015 07:02:14 -0400 Message-ID: <1426590128.2330.25.camel@mm-sol.com> Subject: Re: [PATCH 2/2] spi: qup: Request CS GPIO's during probe From: "Ivan T. Ivanov" To: Stephen Boyd Cc: Mark Brown , linus.walleij@linaro.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Date: Tue, 17 Mar 2015 13:02:08 +0200 In-Reply-To: <54FDEC36.5080403@codeaurora.org> References: <1425655578-22400-1-git-send-email-iivanov@mm-sol.com> <1425655578-22400-2-git-send-email-iivanov@mm-sol.com> <54F9F31A.3050501@codeaurora.org> <1425889207.2440.9.camel@mm-sol.com> <54FDEC36.5080403@codeaurora.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.13.7-fta1.2~trusty Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, 2015-03-09 at 11:53 -0700, Stephen Boyd wrote: > On 03/09/15 01:20, Ivan T. Ivanov wrote: > > Hi Stephen, > > > > > On Mar 6, 2015, at 8:34 PM, Stephen Boyd wrote: > > > On 03/06/15 07:26, Ivan T. Ivanov wrote: > > > > Ensure that driver is owner of the GPIO's used for CS signals. > > > Why? What happens if we don’t? > > We can have wrong DT configuration, which could reconfigure > > GPIO’s without any warning or error. > > Ouch. That sounds bad. Can you please add this information to the commit > text? > > > > > Signed-off-by: Ivan T. Ivanov > > > > --- > > > > drivers/spi/spi-qup.c | 17 ++++++++++++++++- > > > > 1 file changed, 16 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c > > > > index 2b2c359..a07ba46 100644 > > > > --- a/drivers/spi/spi-qup.c > > > > +++ b/drivers/spi/spi-qup.c > > > > @@ -14,11 +14,13 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -499,7 +501,7 @@ static int spi_qup_probe(struct platform_device *pdev) > > > > struct device *dev; > > > > void __iomem *base; > > > > u32 max_freq, iomode, num_cs; > > > > - int ret, irq, size; > > > > + int ret, irq, size, cs, cs_gpio; > > > > > > > > dev = &pdev->dev; > > > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > > > @@ -556,6 +558,19 @@ static int spi_qup_probe(struct platform_device *pdev) > > > > else > > > > master->num_chipselect = num_cs; > > > > > > > > + for (cs = 0; cs < master->num_chipselect; cs++) { > > > > + cs_gpio = of_get_named_gpio(dev->of_node, "cs-gpios", cs); > > > > + > > > > + if (!gpio_is_valid(cs_gpio)) > > > > + continue; > > > > + > > > > + ret = devm_gpio_request(&pdev->dev, cs_gpio, "spi-qup-cs"); > > > > + if (ret) { > > > > + dev_err(&pdev->dev, "can't get cs gpios\n"); > > > > + goto error; > > > > + } > > > > + } > > > > + > > > > master->bus_num = pdev->id; > > > Is this related to [1]? In that case I was just relying on DT/pinctrl to > > > properly request the gpios. > > But the DT/pinctrl did not request GPIO’s, it just configure them. > > For some reason we are ending without any pinctrl_map of type > > PIN_MAP_TYPE_MUX_GROUP, which is used for pin reservation. I will like to withdraw this patch. It fix the problem only for CS lines, but misconfiguration could happen also for the rest for the lines. I will take a look in the pinctrl core code to see would it be possible to print warning or something, when one driver reconfigure pins already configured by another driver. Regards, Ivan