Re: [PATCH 2/2] spi: qup: Request CS GPIO's during probe

From: Ivan T. Ivanov
Date: Mon Mar 09 2015 - 04:20:23 EST



Hi Stephen,

> On Mar 6, 2015, at 8:34 PM, Stephen Boyd <sboyd@xxxxxxxxxxxxxx> 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.

> > Signed-off-by: Ivan T. Ivanov <iivanov@xxxxxxxxxx>
> > ---
> > 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 <linux/clk.h>
> > #include <linux/delay.h>
> > #include <linux/err.h>
> > +#include <linux/gpio.h>
> > #include <linux/interrupt.h>
> > #include <linux/io.h>
> > #include <linux/list.h>
> > #include <linux/module.h>
> > #include <linux/of.h>
> > +#include <linux/of_gpio.h>
> > #include <linux/platform_device.h>
> > #include <linux/pm_runtime.h>
> > #include <linux/spi/spi.h>
> > @@ -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.

> [1] https://lkml.org/lkml/2014/5/27/784

I have missed this one. I have considered same approach, but abandoned
it, because of issues related to double request reasons mentioned by Mark.

Regards,
Ivan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/